diff options
-rw-r--r-- | base/gfx/native_widget_types.h | 4 | ||||
-rw-r--r-- | chrome/common/common.scons | 11 | ||||
-rw-r--r-- | chrome/common/gfx/chrome_font.cc | 2 | ||||
-rw-r--r-- | chrome/common/gfx/chrome_font.h | 20 | ||||
-rw-r--r-- | chrome/common/gfx/chrome_font_skia.cc | 10 | ||||
-rw-r--r-- | chrome/test/unit/unit_tests.scons | 2 |
6 files changed, 28 insertions, 21 deletions
diff --git a/base/gfx/native_widget_types.h b/base/gfx/native_widget_types.h index 2bdb4e9..1f696b0 100644 --- a/base/gfx/native_widget_types.h +++ b/base/gfx/native_widget_types.h @@ -31,7 +31,6 @@ class NSWindow; class NSTextField; #endif // __OBJC__ #elif defined(OS_LINUX) -class SkTypeface; typedef struct _GtkWidget GtkWidget; #endif @@ -41,17 +40,14 @@ namespace gfx { typedef HWND NativeView; typedef HWND NativeWindow; typedef HWND NativeEditView; -typedef struct HFONT__* NativeFont; #elif defined(OS_MACOSX) typedef NSView* NativeView; typedef NSWindow* NativeWindow; typedef NSTextField* NativeEditView; -typedef void* NativeFont; // TODO(port): set the correct type here #elif defined(OS_LINUX) typedef GtkWidget* NativeView; typedef GtkWidget* NativeWindow; typedef GtkWidget* NativeEditView; -typedef SkTypeface* NativeFont; #else // null port. #error No known OS defined #endif diff --git a/chrome/common/common.scons b/chrome/common/common.scons index 6cbca92..eba23c6 100644 --- a/chrome/common/common.scons +++ b/chrome/common/common.scons @@ -110,17 +110,18 @@ if env['PLATFORM'] == 'win32': 'win_util.cc', 'worker_thread_ticker.cc', ]) -elif env['PLATFORM'] == 'posix': - input_files.extend([ - 'gfx/chrome_font_skia.cc', - ]) if env['PLATFORM'] == 'win32': # Windows specific files input_files.extend([ 'ipc_channel_win.cc', ]) -else: +elif env['PLATFORM'] == 'posix': + input_files.extend([ + 'gfx/chrome_font_skia.cc', + ]) + +if env['PLATFORM'] in ['posix', 'mac']: input_files.extend([ 'ipc_channel_posix.cc', ]) diff --git a/chrome/common/gfx/chrome_font.cc b/chrome/common/gfx/chrome_font.cc index 6600abe..062b578 100644 --- a/chrome/common/gfx/chrome_font.cc +++ b/chrome/common/gfx/chrome_font.cc @@ -51,7 +51,7 @@ int ChromeFont::style() const { return font_ref_->style(); } -gfx::NativeFont ChromeFont::nativeFont() const { +NativeFont ChromeFont::nativeFont() const { return hfont(); } diff --git a/chrome/common/gfx/chrome_font.h b/chrome/common/gfx/chrome_font.h index a26ceaf..cac7499 100644 --- a/chrome/common/gfx/chrome_font.h +++ b/chrome/common/gfx/chrome_font.h @@ -6,7 +6,6 @@ #define CHROME_COMMON_GFX_CHROME_FONT_H_ #include "build/build_config.h" -#include "base/gfx/native_widget_types.h" #include <string> @@ -18,6 +17,17 @@ class SkPaint; class SkTypeface; #endif +#if defined(OS_WIN) +typedef struct HFONT__* NativeFont; +#elif defined(OS_MACOSX) +typedef void* NativeFont; // TODO(port): set the correct type here +#elif defined(OS_LINUX) +class SkTypeface; +typedef SkTypeface* NativeFont; +#else // null port. +#error No known OS defined +#endif + #include "base/basictypes.h" #include "base/ref_counted.h" @@ -31,7 +41,7 @@ class ChromeFont { BOLD = 1, ITALIC = 2, UNDERLINED = 4, - WEB = 8, // TODO: what does this mean? + WEB = 8, // TODO(agl): what does this mean? }; // Creates a ChromeFont given font name (e.g. arial), font size (e.g. 12). @@ -81,7 +91,7 @@ class ChromeFont { // Font Size. int FontSize(); - gfx::NativeFont nativeFont() const; + NativeFont nativeFont() const; #if defined(OS_WIN) // Creates a font with the default name and style. @@ -104,7 +114,7 @@ class ChromeFont { return dlus * font_ref_->height() / 8; } #elif defined(OS_LINUX) - // We need a copy constructor to deal with the Skia reference counting + // We need a copy constructor to deal with the Skia reference counting. ChromeFont(const ChromeFont& other); #endif @@ -172,7 +182,7 @@ class ChromeFont { explicit ChromeFont(SkTypeface* typeface, const std::wstring& name, int size, int style); // Setup a Skia context to use the current typeface - void setupPaint(SkPaint* paint) const; + void PaintSetup(SkPaint* paint) const; // Calculate and cache the font metrics void calculateMetrics(); diff --git a/chrome/common/gfx/chrome_font_skia.cc b/chrome/common/gfx/chrome_font_skia.cc index 17e5fdf..77a9661 100644 --- a/chrome/common/gfx/chrome_font_skia.cc +++ b/chrome/common/gfx/chrome_font_skia.cc @@ -35,7 +35,7 @@ void ChromeFont::calculateMetrics() { SkPaint paint; SkPaint::FontMetrics metrics; - setupPaint(&paint); + PaintSetup(&paint); paint.getFontMetrics(&metrics); if (metrics.fVDMXMetricsValid) { @@ -47,7 +47,7 @@ void ChromeFont::calculateMetrics() { } if (metrics.fAvgCharWidth) { - avg_width_ = SkScalarRound(metrics.fAvgCharWidth); + avg_width_ = SkScalarRound(metrics.fAvgCharWidth); } else { static const char x_char = 'x'; paint.setTextEncoding(SkPaint::kUTF8_TextEncoding); @@ -104,7 +104,7 @@ ChromeFont ChromeFont::DeriveFont(int size_delta, int style) const { return ChromeFont(tf, font_name_, font_size_ + size_delta, skstyle); } -void ChromeFont::setupPaint(SkPaint* paint) const { +void ChromeFont::PaintSetup(SkPaint* paint) const { paint->setAntiAlias(false); paint->setSubpixelText(false); paint->setTextSize(SkFloatToScalar(font_size_)); @@ -118,7 +118,7 @@ int ChromeFont::GetStringWidth(const std::wstring& text) const { const std::string utf8(base::SysWideToUTF8(text)); SkPaint paint; - setupPaint(&paint); + PaintSetup(&paint); paint.setTextEncoding(SkPaint::kUTF8_TextEncoding); SkScalar width = paint.measureText(utf8.data(), utf8.size()); @@ -142,6 +142,6 @@ int ChromeFont::FontSize() { return font_size_; } -gfx::NativeFont ChromeFont::nativeFont() const { +NativeFont ChromeFont::nativeFont() const { return typeface_; } diff --git a/chrome/test/unit/unit_tests.scons b/chrome/test/unit/unit_tests.scons index 70eded7..6d53901 100644 --- a/chrome/test/unit/unit_tests.scons +++ b/chrome/test/unit/unit_tests.scons @@ -133,9 +133,9 @@ if env['PLATFORM'] in ('posix', 'win32'): '$CHROME_DIR/browser/safe_browsing/safe_browsing_util_unittest.cc', '$CHROME_DIR/common/animation_unittest.cc', '$CHROME_DIR/common/bzip2_unittest.cc', + '$CHROME_DIR/common/gfx/chrome_font_unittest.cc', '$CHROME_DIR/common/jpeg_codec_unittest.cc', '$CHROME_DIR/common/json_value_serializer_unittest.cc', - '$CHROME_DIR/common/gfx/chrome_font_unittest.cc', ]) if env['PLATFORM'] == 'win32': |