diff options
author | derat <derat@chromium.org> | 2015-02-11 16:10:41 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-12 00:11:28 +0000 |
commit | cd2d6fbd501376345db3964e9a5d89047ae2842d (patch) | |
tree | 9a8a779b822dadb3688452a996a0999d584edbea | |
parent | c161f20c53d160be364a1909ca85a28eee7b7399 (diff) | |
download | chromium_src-cd2d6fbd501376345db3964e9a5d89047ae2842d.zip chromium_src-cd2d6fbd501376345db3964e9a5d89047ae2842d.tar.gz chromium_src-cd2d6fbd501376345db3964e9a5d89047ae2842d.tar.bz2 |
Rename PlatformFontPango to PlatformFontLinux.
The Linux PlatformFont implementation no longer has any
dependencies on Pango. Rename it and compile it
unconditionally on Linux. Also drop some Pango build
dependencies and delete the now-unneeded PlatformFontOzone
implementation.
BUG=398885,393067
TBR=sky@chromium.org
Review URL: https://codereview.chromium.org/912293006
Cr-Commit-Position: refs/heads/master@{#315874}
-rw-r--r-- | WATCHLISTS | 4 | ||||
-rw-r--r-- | chrome/browser/chromeos/base/locale_util.cc | 4 | ||||
-rw-r--r-- | ui/base/resource/resource_bundle.cc | 6 | ||||
-rw-r--r-- | ui/gfx/BUILD.gn | 39 | ||||
-rw-r--r-- | ui/gfx/gfx.gyp | 10 | ||||
-rw-r--r-- | ui/gfx/gfx_tests.gyp | 28 | ||||
-rw-r--r-- | ui/gfx/platform_font_linux.cc (renamed from ui/gfx/platform_font_pango.cc) | 56 | ||||
-rw-r--r-- | ui/gfx/platform_font_linux.h (renamed from ui/gfx/platform_font_pango.h) | 23 | ||||
-rw-r--r-- | ui/gfx/platform_font_linux_unittest.cc (renamed from ui/gfx/platform_font_pango_unittest.cc) | 24 | ||||
-rw-r--r-- | ui/gfx/platform_font_ozone.cc | 20 |
10 files changed, 68 insertions, 146 deletions
@@ -422,8 +422,8 @@ }, 'linux_fonts': { 'filepath': 'ui/gfx/font_render_params_.*|'\ - 'ui/gfx/platform_font_pango.*|'\ - 'ui/gfx/render_text_linux.*', + 'ui/gfx/platform_font_linux.*|'\ + 'ui/gfx/render_text_harfbuzz.*', }, 'linux_sandboxing': { 'filepath': 'sandbox/linux/', diff --git a/chrome/browser/chromeos/base/locale_util.cc b/chrome/browser/chromeos/base/locale_util.cc index 39e3893..c185d78 100644 --- a/chrome/browser/chromeos/base/locale_util.cc +++ b/chrome/browser/chromeos/base/locale_util.cc @@ -11,7 +11,7 @@ #include "content/public/browser/browser_thread.h" #include "ui/base/ime/chromeos/input_method_manager.h" #include "ui/base/resource/resource_bundle.h" -#include "ui/gfx/platform_font_pango.h" +#include "ui/gfx/platform_font_linux.h" namespace chromeos { @@ -86,7 +86,7 @@ void FinishSwitchLanguage(scoped_ptr<SwitchLanguageData> data) { } } } - gfx::PlatformFontPango::ReloadDefaultFont(); + gfx::PlatformFontLinux::ReloadDefaultFont(); if (!data->callback.is_null()) data->callback.Run(data->result); } diff --git a/ui/base/resource/resource_bundle.cc b/ui/base/resource/resource_bundle.cc index 7c12b2a..755307c 100644 --- a/ui/base/resource/resource_bundle.cc +++ b/ui/base/resource/resource_bundle.cc @@ -42,7 +42,7 @@ #if defined(OS_CHROMEOS) #include "ui/base/font_helper_chromeos.h" -#include "ui/gfx/platform_font_pango.h" +#include "ui/gfx/platform_font_linux.h" #endif #if defined(OS_WIN) @@ -671,7 +671,7 @@ void ResourceBundle::AddDataPack(DataPack* data_pack) { } void ResourceBundle::InitDefaultFontList() { -#if defined(OS_CHROMEOS) && defined(USE_PANGO) +#if defined(OS_CHROMEOS) std::string font_family = base::UTF16ToUTF8( GetLocalizedString(IDS_UI_FONT_FAMILY_CROS)); ui::ReplaceNotoSansWithRobotoIfEnabled(&font_family); @@ -680,7 +680,7 @@ void ResourceBundle::InitDefaultFontList() { // TODO(yukishiino): Remove SetDefaultFontDescription() once the migration to // the font list is done. We will no longer need SetDefaultFontDescription() // after every client gets started using a FontList instead of a Font. - gfx::PlatformFontPango::SetDefaultFontDescription(font_family); + gfx::PlatformFontLinux::SetDefaultFontDescription(font_family); #else // Use a single default font as the default font list. gfx::FontList::SetDefaultFontDescription(std::string()); diff --git a/ui/gfx/BUILD.gn b/ui/gfx/BUILD.gn index cc1de9a..b037516 100644 --- a/ui/gfx/BUILD.gn +++ b/ui/gfx/BUILD.gn @@ -154,6 +154,8 @@ component("gfx") { "platform_font_android.cc", "platform_font_ios.h", "platform_font_ios.mm", + "platform_font_linux.cc", + "platform_font_linux.h", "platform_font_mac.h", "platform_font_mac.mm", "platform_font_win.cc", @@ -319,15 +321,6 @@ component("gfx") { # Linux. if (is_linux) { configs += [ "//build/config/linux:fontconfig" ] - sources += [ - "platform_font_pango.cc", - "platform_font_pango.h", - ] - } - - # Ozone stuff. - if (use_ozone) { - sources += [ "platform_font_ozone.cc" ] } if (!use_aura) { @@ -346,12 +339,9 @@ component("gfx") { sources -= [ "path_x11.cc" ] } - if (use_pango) { + if (use_cairo) { configs += [ "//build/config/linux:pangocairo" ] } - if (use_pango && use_ozone) { - sources -= [ "platform_font_ozone.cc" ] - } } # Looking for gfx_geometry? It's //ui/gfx/geometry:geometry @@ -397,11 +387,13 @@ source_set("test_support") { test("gfx_unittests") { sources = [ + "font_render_params_linux_unittest.cc", "font_unittest.cc", "image/image_family_unittest.cc", "image/image_ios_unittest.mm", "image/image_skia_unittest.cc", "image/image_unittest.cc", + "platform_font_linux_unittest.cc", "screen_unittest.cc", "test/run_all_unittests.cc", "text_elider_unittest.cc", @@ -473,17 +465,6 @@ test("gfx_unittests") { "//ui/resources:ui_test_pak", ] - if (use_pango) { - sources += [ - "font_render_params_linux_unittest.cc", - "platform_font_pango_unittest.cc", - ] - configs += [ - "//build/config/linux:pangocairo", - "//build/config/linux:pangoft2", - ] - } - if (!is_mac && !is_ios) { sources += [ "transform_unittest.cc", @@ -491,16 +472,6 @@ test("gfx_unittests") { ] } - if (use_ozone && !use_pango) { - sources -= [ - "canvas_unittest.cc", - "font_list_unittest.cc", - "font_unittest.cc", - "render_text_unittest.cc", - "text_elider_unittest.cc", - ] - } - if (is_android) { sources -= [ # Do not run display_change_notifier_unittest.cc on Android because it diff --git a/ui/gfx/gfx.gyp b/ui/gfx/gfx.gyp index 4fbd908..f1e9585 100644 --- a/ui/gfx/gfx.gyp +++ b/ui/gfx/gfx.gyp @@ -232,11 +232,10 @@ 'platform_font_android.cc', 'platform_font_ios.h', 'platform_font_ios.mm', + 'platform_font_linux.cc', + 'platform_font_linux.h', 'platform_font_mac.h', 'platform_font_mac.mm', - 'platform_font_ozone.cc', - 'platform_font_pango.cc', - 'platform_font_pango.h', 'platform_font_win.cc', 'platform_font_win.h', 'range/range.cc', @@ -400,13 +399,10 @@ 'x/gfx_x11.gyp:gfx_x11', ], }], - ['use_pango==1', { + ['use_cairo==1', { 'dependencies': [ '<(DEPTH)/build/linux/system.gyp:pangocairo', ], - 'sources!': [ - 'platform_font_ozone.cc', - ], }], ['desktop_linux==1 or chromeos==1', { 'dependencies': [ diff --git a/ui/gfx/gfx_tests.gyp b/ui/gfx/gfx_tests.gyp index f576da4..7602754 100644 --- a/ui/gfx/gfx_tests.gyp +++ b/ui/gfx/gfx_tests.gyp @@ -42,6 +42,7 @@ 'display_change_notifier_unittest.cc', 'display_unittest.cc', 'font_list_unittest.cc', + 'font_render_params_linux_unittest.cc', 'geometry/box_unittest.cc', 'geometry/cubic_bezier_unittest.cc', 'geometry/insets_unittest.cc', @@ -59,6 +60,7 @@ 'image/image_mac_unittest.mm', 'image/image_util_unittest.cc', 'mac/coordinate_conversion_unittest.mm', + 'platform_font_linux_unittest.cc', 'platform_font_mac_unittest.mm', 'range/range_mac_unittest.mm', 'range/range_unittest.cc', @@ -95,32 +97,6 @@ 'interpolated_transform_unittest.cc', ], }], - ['use_pango == 1', { - 'dependencies': [ - '../../build/linux/system.gyp:fontconfig', - '../../build/linux/system.gyp:pangocairo', - ], - 'sources': [ - 'font_render_params_linux_unittest.cc', - 'platform_font_pango_unittest.cc', - ], - 'conditions': [ - ['use_allocator!="none"', { - 'dependencies': [ - '../../base/allocator/allocator.gyp:allocator', - ], - }], - ], - }], - ['use_ozone==1 and use_pango==0', { - 'sources!': [ - 'canvas_unittest.cc', - 'font_list_unittest.cc', - 'font_unittest.cc', - 'render_text_unittest.cc', - 'text_elider_unittest.cc', - ], - }], ['OS == "android"', { 'dependencies': [ '../../testing/android/native_test.gyp:native_test_native_code', diff --git a/ui/gfx/platform_font_pango.cc b/ui/gfx/platform_font_linux.cc index 25dc29f..2f1bbf1 100644 --- a/ui/gfx/platform_font_pango.cc +++ b/ui/gfx/platform_font_linux.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ui/gfx/platform_font_pango.h" +#include "ui/gfx/platform_font_linux.h" #include <algorithm> #include <string> @@ -30,7 +30,7 @@ namespace { const char* kFallbackFontFamilyName = "sans"; // The default font, used for the default constructor. -base::LazyInstance<scoped_refptr<PlatformFontPango>>::Leaky g_default_font = +base::LazyInstance<scoped_refptr<PlatformFontLinux>>::Leaky g_default_font = LAZY_INSTANCE_INITIALIZER; // Creates a SkTypeface for the passed-in Font::FontStyle and family. If a @@ -62,13 +62,13 @@ skia::RefPtr<SkTypeface> CreateSkTypeface(int style, std::string* family) { } // namespace #if defined(OS_CHROMEOS) -std::string* PlatformFontPango::default_font_description_ = NULL; +std::string* PlatformFontLinux::default_font_description_ = NULL; #endif //////////////////////////////////////////////////////////////////////////////// -// PlatformFontPango, public: +// PlatformFontLinux, public: -PlatformFontPango::PlatformFontPango() { +PlatformFontLinux::PlatformFontLinux() { if (!g_default_font.Get()) { std::string family = kFallbackFontFamilyName; int size_pixels = 12; @@ -98,14 +98,14 @@ PlatformFontPango::PlatformFontPango() { } #endif - g_default_font.Get() = new PlatformFontPango( + g_default_font.Get() = new PlatformFontLinux( CreateSkTypeface(style, &family), family, size_pixels, style, params); } InitFromPlatformFont(g_default_font.Get().get()); } -PlatformFontPango::PlatformFontPango(const std::string& font_name, +PlatformFontLinux::PlatformFontLinux(const std::string& font_name, int font_size_pixels) { FontRenderParamsQuery query(false); query.families.push_back(font_name); @@ -116,17 +116,17 @@ PlatformFontPango::PlatformFontPango(const std::string& font_name, } //////////////////////////////////////////////////////////////////////////////// -// PlatformFontPango, PlatformFont implementation: +// PlatformFontLinux, PlatformFont implementation: // static -void PlatformFontPango::ReloadDefaultFont() { +void PlatformFontLinux::ReloadDefaultFont() { // Reset the scoped_refptr. g_default_font.Get() = nullptr; } #if defined(OS_CHROMEOS) // static -void PlatformFontPango::SetDefaultFontDescription( +void PlatformFontLinux::SetDefaultFontDescription( const std::string& font_description) { delete default_font_description_; default_font_description_ = new std::string(font_description); @@ -134,7 +134,7 @@ void PlatformFontPango::SetDefaultFontDescription( #endif -Font PlatformFontPango::DeriveFont(int size_delta, int style) const { +Font PlatformFontLinux::DeriveFont(int size_delta, int style) const { const int new_size = font_size_pixels_ + size_delta; DCHECK_GT(new_size, 0); @@ -148,45 +148,45 @@ Font PlatformFontPango::DeriveFont(int size_delta, int style) const { query.pixel_size = new_size; query.style = style; - return Font(new PlatformFontPango(typeface, new_family, new_size, style, + return Font(new PlatformFontLinux(typeface, new_family, new_size, style, gfx::GetFontRenderParams(query, NULL))); } -int PlatformFontPango::GetHeight() const { +int PlatformFontLinux::GetHeight() const { return height_pixels_; } -int PlatformFontPango::GetBaseline() const { +int PlatformFontLinux::GetBaseline() const { return ascent_pixels_; } -int PlatformFontPango::GetCapHeight() const { +int PlatformFontLinux::GetCapHeight() const { return cap_height_pixels_; } -int PlatformFontPango::GetExpectedTextWidth(int length) const { +int PlatformFontLinux::GetExpectedTextWidth(int length) const { return round(static_cast<float>(length) * average_width_pixels_); } -int PlatformFontPango::GetStyle() const { +int PlatformFontLinux::GetStyle() const { return style_; } -std::string PlatformFontPango::GetFontName() const { +std::string PlatformFontLinux::GetFontName() const { return font_family_; } -std::string PlatformFontPango::GetActualFontNameForTesting() const { +std::string PlatformFontLinux::GetActualFontNameForTesting() const { SkString family_name; typeface_->getFamilyName(&family_name); return family_name.c_str(); } -int PlatformFontPango::GetFontSize() const { +int PlatformFontLinux::GetFontSize() const { return font_size_pixels_; } -const FontRenderParams& PlatformFontPango::GetFontRenderParams() { +const FontRenderParams& PlatformFontLinux::GetFontRenderParams() { #if defined(OS_CHROMEOS) float current_scale_factor = GetFontRenderParamsDeviceScaleFactor(); if (current_scale_factor != device_scale_factor_) { @@ -203,9 +203,9 @@ const FontRenderParams& PlatformFontPango::GetFontRenderParams() { } //////////////////////////////////////////////////////////////////////////////// -// PlatformFontPango, private: +// PlatformFontLinux, private: -PlatformFontPango::PlatformFontPango(const skia::RefPtr<SkTypeface>& typeface, +PlatformFontLinux::PlatformFontLinux(const skia::RefPtr<SkTypeface>& typeface, const std::string& family, int size_pixels, int style, @@ -213,9 +213,9 @@ PlatformFontPango::PlatformFontPango(const skia::RefPtr<SkTypeface>& typeface, InitFromDetails(typeface, family, size_pixels, style, render_params); } -PlatformFontPango::~PlatformFontPango() {} +PlatformFontLinux::~PlatformFontLinux() {} -void PlatformFontPango::InitFromDetails( +void PlatformFontLinux::InitFromDetails( const skia::RefPtr<SkTypeface>& typeface, const std::string& font_family, int font_size_pixels, @@ -249,7 +249,7 @@ void PlatformFontPango::InitFromDetails( average_width_pixels_ = SkScalarToDouble(metrics.fAvgCharWidth); } -void PlatformFontPango::InitFromPlatformFont(const PlatformFontPango* other) { +void PlatformFontLinux::InitFromPlatformFont(const PlatformFontLinux* other) { typeface_ = other->typeface_; font_family_ = other->font_family_; font_size_pixels_ = other->font_size_pixels_; @@ -269,13 +269,13 @@ void PlatformFontPango::InitFromPlatformFont(const PlatformFontPango* other) { // static PlatformFont* PlatformFont::CreateDefault() { - return new PlatformFontPango; + return new PlatformFontLinux; } // static PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, int font_size) { - return new PlatformFontPango(font_name, font_size); + return new PlatformFontLinux(font_name, font_size); } } // namespace gfx diff --git a/ui/gfx/platform_font_pango.h b/ui/gfx/platform_font_linux.h index 500cd48..c31f249 100644 --- a/ui/gfx/platform_font_pango.h +++ b/ui/gfx/platform_font_linux.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef UI_GFX_PLATFORM_FONT_PANGO_H_ -#define UI_GFX_PLATFORM_FONT_PANGO_H_ +#ifndef UI_GFX_PLATFORM_FONT_LINUX_H_ +#define UI_GFX_PLATFORM_FONT_LINUX_H_ #include <string> @@ -19,14 +19,13 @@ class SkPaint; namespace gfx { -// TODO(derat): Rename this to PlatformFontLinux. -class GFX_EXPORT PlatformFontPango : public PlatformFont { +class GFX_EXPORT PlatformFontLinux : public PlatformFont { public: // TODO(derat): Get rid of the default constructor in favor of using // gfx::FontList (which also has the concept of a default font but may contain // multiple font families) everywhere. See http://crbug.com/398885#c16. - PlatformFontPango(); - PlatformFontPango(const std::string& font_name, int font_size_pixels); + PlatformFontLinux(); + PlatformFontLinux(const std::string& font_name, int font_size_pixels); // Resets and reloads the cached system font used by the default constructor. // This function is useful when the system font has changed, for example, when @@ -54,12 +53,12 @@ class GFX_EXPORT PlatformFontPango : public PlatformFont { private: // Create a new instance of this object with the specified properties. Called // from DeriveFont. - PlatformFontPango(const skia::RefPtr<SkTypeface>& typeface, + PlatformFontLinux(const skia::RefPtr<SkTypeface>& typeface, const std::string& family, int size_pixels, int style, const FontRenderParams& params); - ~PlatformFontPango() override; + ~PlatformFontLinux() override; // Initializes this object based on the passed-in details. If |typeface| is // empty, a new typeface will be loaded. @@ -70,8 +69,8 @@ class GFX_EXPORT PlatformFontPango : public PlatformFont { int style, const FontRenderParams& params); - // Initializes this object as a copy of another PlatformFontPango. - void InitFromPlatformFont(const PlatformFontPango* other); + // Initializes this object as a copy of another PlatformFontLinux. + void InitFromPlatformFont(const PlatformFontLinux* other); skia::RefPtr<SkTypeface> typeface_; @@ -98,9 +97,9 @@ class GFX_EXPORT PlatformFontPango : public PlatformFont { static std::string* default_font_description_; #endif - DISALLOW_COPY_AND_ASSIGN(PlatformFontPango); + DISALLOW_COPY_AND_ASSIGN(PlatformFontLinux); }; } // namespace gfx -#endif // UI_GFX_PLATFORM_FONT_PANGO_H_ +#endif // UI_GFX_PLATFORM_FONT_LINUX_H_ diff --git a/ui/gfx/platform_font_pango_unittest.cc b/ui/gfx/platform_font_linux_unittest.cc index ece6a6f..b729c8e 100644 --- a/ui/gfx/platform_font_pango_unittest.cc +++ b/ui/gfx/platform_font_linux_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ui/gfx/platform_font_pango.h" +#include "ui/gfx/platform_font_linux.h" #include <string> @@ -52,15 +52,15 @@ class TestFontDelegate : public LinuxFontDelegate { DISALLOW_COPY_AND_ASSIGN(TestFontDelegate); }; -class PlatformFontPangoTest : public testing::Test { +class PlatformFontLinuxTest : public testing::Test { public: - PlatformFontPangoTest() { + PlatformFontLinuxTest() { SetUpFontconfig(); original_font_delegate_ = LinuxFontDelegate::instance(); LinuxFontDelegate::SetInstance(&test_font_delegate_); } - ~PlatformFontPangoTest() override { + ~PlatformFontLinuxTest() override { LinuxFontDelegate::SetInstance( const_cast<LinuxFontDelegate*>(original_font_delegate_)); TearDownFontconfig(); @@ -73,17 +73,17 @@ class PlatformFontPangoTest : public testing::Test { // Originally-registered delegate. const LinuxFontDelegate* original_font_delegate_; - DISALLOW_COPY_AND_ASSIGN(PlatformFontPangoTest); + DISALLOW_COPY_AND_ASSIGN(PlatformFontLinuxTest); }; -// Test that PlatformFontPango's default constructor initializes the instance +// Test that PlatformFontLinux's default constructor initializes the instance // with the correct parameters. -TEST_F(PlatformFontPangoTest, DefaultFont) { +TEST_F(PlatformFontLinuxTest, DefaultFont) { ASSERT_TRUE(LoadSystemFontIntoFontconfig("arial.ttf")); ASSERT_TRUE(LoadSystemFontIntoFontconfig("times_new_roman.ttf")); #if defined(OS_CHROMEOS) - PlatformFontPango::SetDefaultFontDescription("Arial,Times New Roman,13px"); + PlatformFontLinux::SetDefaultFontDescription("Arial,Times New Roman,13px"); #else test_font_delegate_.set_family("Arial"); test_font_delegate_.set_size_pixels(13); @@ -93,7 +93,7 @@ TEST_F(PlatformFontPangoTest, DefaultFont) { params.hinting = FontRenderParams::HINTING_FULL; test_font_delegate_.set_params(params); #endif - scoped_refptr<gfx::PlatformFontPango> font(new gfx::PlatformFontPango()); + scoped_refptr<gfx::PlatformFontLinux> font(new gfx::PlatformFontLinux()); EXPECT_EQ("Arial", font->GetFontName()); EXPECT_EQ(13, font->GetFontSize()); EXPECT_EQ(gfx::Font::NORMAL, font->GetStyle()); @@ -105,15 +105,15 @@ TEST_F(PlatformFontPangoTest, DefaultFont) { // Drop the old default font and check that new settings are loaded. #if defined(OS_CHROMEOS) - PlatformFontPango::SetDefaultFontDescription( + PlatformFontLinux::SetDefaultFontDescription( "Times New Roman,Arial,Bold 15px"); #else test_font_delegate_.set_family("Times New Roman"); test_font_delegate_.set_size_pixels(15); test_font_delegate_.set_style(gfx::Font::BOLD); #endif - PlatformFontPango::ReloadDefaultFont(); - scoped_refptr<gfx::PlatformFontPango> font2(new gfx::PlatformFontPango()); + PlatformFontLinux::ReloadDefaultFont(); + scoped_refptr<gfx::PlatformFontLinux> font2(new gfx::PlatformFontLinux()); EXPECT_EQ("Times New Roman", font2->GetFontName()); EXPECT_EQ(15, font2->GetFontSize()); EXPECT_EQ(gfx::Font::BOLD, font2->GetStyle()); diff --git a/ui/gfx/platform_font_ozone.cc b/ui/gfx/platform_font_ozone.cc deleted file mode 100644 index b1a463c..0000000 --- a/ui/gfx/platform_font_ozone.cc +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ui/gfx/platform_font.h" - -namespace gfx { - -// static -PlatformFont* PlatformFont::CreateDefault() { - return NULL; -} - -// static -PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, - int font_size) { - return NULL; -} - -} // namespace gfx |