summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-15 02:16:10 +0000
committerbeng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-15 02:16:10 +0000
commit7322c44018c4e7b8bd58c67f52986660fb365d76 (patch)
tree4bb67ec23689e83682a5aa228e3b8c402880baa8
parent0c875075a6c45e9979b8345e5f5f9d4b747e05c3 (diff)
downloadchromium_src-7322c44018c4e7b8bd58c67f52986660fb365d76.zip
chromium_src-7322c44018c4e7b8bd58c67f52986660fb365d76.tar.gz
chromium_src-7322c44018c4e7b8bd58c67f52986660fb365d76.tar.bz2
ChromeFont->gfx::Font
Does not rename the files yet. http://crbug.com/11387 Review URL: http://codereview.chromium.org/113441 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16141 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--app/gfx/chrome_canvas.cc2
-rw-r--r--app/gfx/chrome_canvas.h10
-rw-r--r--app/gfx/chrome_canvas_linux.cc18
-rw-r--r--app/gfx/chrome_canvas_win.cc6
-rw-r--r--app/gfx/chrome_font.h56
-rw-r--r--app/gfx/chrome_font_gtk.cc12
-rw-r--r--app/gfx/chrome_font_mac.mm37
-rw-r--r--app/gfx/chrome_font_skia.cc51
-rw-r--r--app/gfx/chrome_font_unittest.cc34
-rw-r--r--app/gfx/chrome_font_win.cc59
-rw-r--r--app/gfx/text_elider.cc6
-rw-r--r--app/gfx/text_elider.h6
-rw-r--r--app/gfx/text_elider_unittest.cc6
-rw-r--r--app/resource_bundle.cc14
-rw-r--r--app/resource_bundle.h22
-rw-r--r--app/win_util.cc4
-rw-r--r--app/win_util.h2
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_win.cc2
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_win.h4
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_view.h4
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc18
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_view_win.cc8
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_view_win.h8
-rw-r--r--chrome/browser/cocoa/status_bubble_mac.mm6
-rw-r--r--chrome/browser/debugger/debugger_view.h2
-rw-r--r--chrome/browser/gtk/download_item_gtk.cc6
-rw-r--r--chrome/browser/gtk/sad_tab_gtk.cc6
-rw-r--r--chrome/browser/gtk/tabs/tab_renderer_gtk.cc4
-rw-r--r--chrome/browser/gtk/tabs/tab_renderer_gtk.h2
-rw-r--r--chrome/browser/jsmessage_box_handler.cc2
-rw-r--r--chrome/browser/printing/print_job.h1
-rw-r--r--chrome/browser/printing/printed_document.cc6
-rw-r--r--chrome/browser/printing/printed_document.h4
-rw-r--r--chrome/browser/shell_dialogs.h6
-rw-r--r--chrome/browser/views/about_chrome_view.cc10
-rw-r--r--chrome/browser/views/about_chrome_view.h4
-rw-r--r--chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc18
-rw-r--r--chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h4
-rw-r--r--chrome/browser/views/bookmark_bar_view.cc2
-rw-r--r--chrome/browser/views/bookmark_table_view.cc6
-rw-r--r--chrome/browser/views/bookmark_table_view.h6
-rw-r--r--chrome/browser/views/constrained_window_impl.cc6
-rw-r--r--chrome/browser/views/download_item_view.h2
-rw-r--r--chrome/browser/views/first_run_bubble.cc4
-rw-r--r--chrome/browser/views/frame/opaque_browser_frame_view.cc4
-rw-r--r--chrome/browser/views/frame/opaque_browser_frame_view.h6
-rw-r--r--chrome/browser/views/location_bar_view.cc4
-rw-r--r--chrome/browser/views/location_bar_view.h6
-rw-r--r--chrome/browser/views/options/advanced_contents_view.cc4
-rw-r--r--chrome/browser/views/options/fonts_page_view.cc22
-rw-r--r--chrome/browser/views/options/fonts_page_view.h2
-rw-r--r--chrome/browser/views/options/languages_page_view.cc2
-rw-r--r--chrome/browser/views/options/options_group_view.cc6
-rw-r--r--chrome/browser/views/page_info_window.cc2
-rw-r--r--chrome/browser/views/sad_tab_view.cc10
-rw-r--r--chrome/browser/views/sad_tab_view.h4
-rw-r--r--chrome/browser/views/shelf_item_dialog.cc2
-rw-r--r--chrome/browser/views/shell_dialogs_win.cc2
-rw-r--r--chrome/browser/views/status_bubble_views.cc2
-rw-r--r--chrome/browser/views/tabs/tab.cc4
-rw-r--r--chrome/browser/views/tabs/tab_renderer.cc4
-rw-r--r--views/controls/button/native_button.h10
-rw-r--r--views/controls/button/native_button_wrapper.h2
-rw-r--r--views/controls/button/text_button.h2
-rw-r--r--views/controls/combo_box.cc2
-rw-r--r--views/controls/label.cc10
-rw-r--r--views/controls/label.h12
-rw-r--r--views/controls/label_unittest.cc4
-rw-r--r--views/controls/link.cc12
-rw-r--r--views/controls/link.h2
-rw-r--r--views/controls/menu/chrome_menu.cc8
-rw-r--r--views/controls/menu/chrome_menu.h4
-rw-r--r--views/controls/menu/menu_win.cc4
-rw-r--r--views/controls/text_field.cc4
-rw-r--r--views/controls/text_field.h6
-rw-r--r--views/drag_utils.cc2
-rw-r--r--views/widget/tooltip_manager.cc16
-rw-r--r--views/widget/tooltip_manager.h6
-rw-r--r--views/window/custom_frame_view.cc6
-rw-r--r--views/window/custom_frame_view.h4
-rw-r--r--views/window/dialog_client_view.cc4
-rw-r--r--views/window/dialog_client_view.h2
-rw-r--r--views/window/window_win.cc4
83 files changed, 367 insertions, 341 deletions
diff --git a/app/gfx/chrome_canvas.cc b/app/gfx/chrome_canvas.cc
index 9898168..4419b0f 100644
--- a/app/gfx/chrome_canvas.cc
+++ b/app/gfx/chrome_canvas.cc
@@ -217,7 +217,7 @@ void ChromeCanvas::DrawBitmapInt(const SkBitmap& bitmap, int src_x, int src_y,
}
void ChromeCanvas::DrawStringInt(const std::wstring& text,
- const ChromeFont& font,
+ const gfx::Font& font,
const SkColor& color,
int x, int y,
int w, int h) {
diff --git a/app/gfx/chrome_canvas.h b/app/gfx/chrome_canvas.h
index 3f2932a..84c5320 100644
--- a/app/gfx/chrome_canvas.h
+++ b/app/gfx/chrome_canvas.h
@@ -14,8 +14,8 @@
#include "base/basictypes.h"
#include "skia/ext/platform_canvas.h"
-class ChromeFont;
namespace gfx {
+class Font;
class Rect;
}
@@ -152,13 +152,13 @@ class ChromeCanvas : public skia::PlatformCanvas {
// Draws text with the specified color, font and location. The text is
// aligned to the left, vertically centered, clipped to the region. If the
// text is too big, it is truncated and '...' is added to the end.
- void DrawStringInt(const std::wstring& text, const ChromeFont& font,
+ void DrawStringInt(const std::wstring& text, const gfx::Font& font,
const SkColor& color, int x, int y, int w, int h);
// Draws text with the specified color, font and location. The last argument
// specifies flags for how the text should be rendered. It can be one of
// TEXT_ALIGN_CENTER, TEXT_ALIGN_RIGHT or TEXT_ALIGN_LEFT.
- void DrawStringInt(const std::wstring& text, const ChromeFont& font,
+ void DrawStringInt(const std::wstring& text, const gfx::Font& font,
const SkColor& color, int x, int y, int w, int h,
int flags);
@@ -167,7 +167,7 @@ class ChromeCanvas : public skia::PlatformCanvas {
// ClearType to be drawn to an otherwise transparenct bitmap for drag images.
// Drag images have only 1-bit of transparency, so we don't do any fancy
// blurring.
- void DrawStringWithHalo(const std::wstring& text, const ChromeFont& font,
+ void DrawStringWithHalo(const std::wstring& text, const gfx::Font& font,
const SkColor& text_color, const SkColor& halo_color,
int x, int y, int w, int h, int flags);
#endif
@@ -194,7 +194,7 @@ class ChromeCanvas : public skia::PlatformCanvas {
// Attempts to fit the text with the provided width and height. Increases
// height and then width as needed to make the text fit. This method
// supports multiple lines.
- static void SizeStringInt(const std::wstring& test, const ChromeFont& font,
+ static void SizeStringInt(const std::wstring& test, const gfx::Font& font,
int *width, int* height, int flags);
private:
diff --git a/app/gfx/chrome_canvas_linux.cc b/app/gfx/chrome_canvas_linux.cc
index d875f2d..12602d9 100644
--- a/app/gfx/chrome_canvas_linux.cc
+++ b/app/gfx/chrome_canvas_linux.cc
@@ -14,23 +14,23 @@
namespace {
// Returns a new pango font, free with pango_font_description_free().
-PangoFontDescription* PangoFontFromChromeFont(const ChromeFont& chrome_font) {
- ChromeFont font = chrome_font; // Copy so we can call non-const methods.
+PangoFontDescription* PangoFontFromGfxFont(const gfx::Font& gfx_font) {
+ gfx::Font font = gfx_font; // Copy so we can call non-const methods.
PangoFontDescription* pfd = pango_font_description_new();
pango_font_description_set_family(pfd, WideToUTF8(font.FontName()).c_str());
pango_font_description_set_size(pfd, font.FontSize() * PANGO_SCALE);
switch (font.style()) {
- case ChromeFont::NORMAL:
+ case gfx::Font::NORMAL:
// Nothing to do, should already be PANGO_STYLE_NORMAL.
break;
- case ChromeFont::BOLD:
+ case gfx::Font::BOLD:
pango_font_description_set_weight(pfd, PANGO_WEIGHT_BOLD);
break;
- case ChromeFont::ITALIC:
+ case gfx::Font::ITALIC:
pango_font_description_set_style(pfd, PANGO_STYLE_ITALIC);
break;
- case ChromeFont::UNDERLINED:
+ case gfx::Font::UNDERLINED:
// TODO(deanm): How to do underlined? Where do we use it? Probably have
// to paint it ourselves, see pango_font_metrics_get_underline_position.
break;
@@ -53,7 +53,7 @@ ChromeCanvas::~ChromeCanvas() {
// static
void ChromeCanvas::SizeStringInt(const std::wstring& text,
- const ChromeFont& font,
+ const gfx::Font& font,
int* width, int* height, int flags) {
NOTIMPLEMENTED();
}
@@ -72,7 +72,7 @@ void ChromeCanvas::ApplySkiaMatrixToCairoContext(cairo_t* cr) {
}
void ChromeCanvas::DrawStringInt(const std::wstring& text,
- const ChromeFont& font,
+ const gfx::Font& font,
const SkColor& color, int x, int y, int w,
int h, int flags) {
cairo_surface_t* surface = beginPlatformPaint();
@@ -112,7 +112,7 @@ void ChromeCanvas::DrawStringInt(const std::wstring& text,
std::string utf8 = WideToUTF8(text);
pango_layout_set_text(layout, utf8.data(), utf8.size());
- PangoFontDescription* desc = PangoFontFromChromeFont(font);
+ PangoFontDescription* desc = PangoFontFromGfxFont(font);
pango_layout_set_font_description(layout, desc);
pango_font_description_free(desc);
diff --git a/app/gfx/chrome_canvas_win.cc b/app/gfx/chrome_canvas_win.cc
index e1d2da85a..267a510 100644
--- a/app/gfx/chrome_canvas_win.cc
+++ b/app/gfx/chrome_canvas_win.cc
@@ -129,7 +129,7 @@ ChromeCanvas::~ChromeCanvas() {
// static
void ChromeCanvas::SizeStringInt(const std::wstring& text,
- const ChromeFont& font,
+ const gfx::Font& font,
int *width, int *height, int flags) {
HDC dc = GetDC(NULL);
HFONT old_font = static_cast<HFONT>(SelectObject(dc, font.hfont()));
@@ -182,7 +182,7 @@ void ChromeCanvas::DrawStringInt(const std::wstring& text, HFONT font,
}
void ChromeCanvas::DrawStringInt(const std::wstring& text,
- const ChromeFont& font,
+ const gfx::Font& font,
const SkColor& color,
int x, int y, int w, int h, int flags) {
DrawStringInt(text, font.hfont(), color, x, y, w, h, flags);
@@ -216,7 +216,7 @@ static bool pixelShouldGetHalo(const SkBitmap& bitmap, int x, int y,
}
void ChromeCanvas::DrawStringWithHalo(const std::wstring& text,
- const ChromeFont& font,
+ const gfx::Font& font,
const SkColor& text_color,
const SkColor& halo_color_in,
int x, int y, int w, int h,
diff --git a/app/gfx/chrome_font.h b/app/gfx/chrome_font.h
index e0479f4..a4b14e9 100644
--- a/app/gfx/chrome_font.h
+++ b/app/gfx/chrome_font.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 APP_GFX_CHROME_FONT_H_
-#define APP_GFX_CHROME_FONT_H_
+#ifndef APP_GFX_FONT_H_
+#define APP_GFX_FONT_H_
#include "build/build_config.h"
@@ -37,9 +37,11 @@ typedef SkTypeface* NativeFont;
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
-// ChromeFont provides a wrapper around an underlying font. Copy and assignment
+namespace gfx {
+
+// Font provides a wrapper around an underlying font. Copy and assignment
// operators are explicitly allowed, and cheap.
-class ChromeFont {
+class Font {
public:
// The following constants indicate the font style.
enum {
@@ -49,16 +51,16 @@ class ChromeFont {
UNDERLINED = 4,
};
- // Creates a ChromeFont given font name (e.g. arial), font size (e.g. 12).
+ // Creates a Font given font name (e.g. arial), font size (e.g. 12).
// Skia actually expects a family name and not a font name.
- static ChromeFont CreateFont(const std::wstring& font_name, int font_size);
+ static Font CreateFont(const std::wstring& font_name, int font_size);
- ~ChromeFont() { }
+ ~Font() { }
// Returns a new Font derived from the existing font.
// size_deta is the size to add to the current font. For example, a value
// of 5 results in a font 5 units bigger than this font.
- ChromeFont DeriveFont(int size_delta) const {
+ Font DeriveFont(int size_delta) const {
return DeriveFont(size_delta, style());
}
@@ -67,7 +69,7 @@ class ChromeFont {
// argument version of this method for an example.
// The style parameter specifies the new style for the font, and is a
// bitmask of the values: BOLD, ITALIC and UNDERLINED.
- ChromeFont DeriveFont(int size_delta, int style) const;
+ Font DeriveFont(int size_delta, int style) const;
// Returns the number of vertical pixels needed to display characters from
// the specified font.
@@ -102,12 +104,12 @@ class ChromeFont {
NativeFont nativeFont() const;
// Creates a font with the default name and style.
- ChromeFont();
+ Font();
#if defined(OS_WIN)
- // Creates a ChromeFont from the specified HFONT. The supplied HFONT is
- // effectively copied.
- static ChromeFont CreateFont(HFONT hfont);
+ // Creates a Font from the specified HFONT. The supplied HFONT is effectively
+ // copied.
+ static Font CreateFont(HFONT hfont);
// Returns the handle to the underlying HFONT. This is used by ChromeCanvas to
// draw text.
@@ -124,8 +126,8 @@ class ChromeFont {
#elif defined(OS_LINUX)
// We need a copy constructor and assignment operator to deal with
// the Skia reference counting.
- ChromeFont(const ChromeFont& other);
- ChromeFont& operator=(const ChromeFont& other);
+ Font(const Font& other);
+ Font& operator=(const Font& other);
// Setup a Skia context to use the current typeface
void PaintSetup(SkPaint* paint) const;
#endif
@@ -135,14 +137,12 @@ class ChromeFont {
#if defined(OS_WIN)
// Chrome text drawing bottoms out in the Windows GDI functions that take an
// HFONT (an opaque handle into Windows). To avoid lots of GDI object
- // allocation and destruction, ChromeFont indirectly refers to the HFONT
- // by way of an HFontRef. That is, every ChromeFont has an HFontRef, which
- // has an HFONT.
+ // allocation and destruction, Font indirectly refers to the HFONT by way of
+ // an HFontRef. That is, every Font has an HFontRef, which has an HFONT.
//
// HFontRef is reference counted. Upon deletion, it deletes the HFONT.
// By making HFontRef maintain the reference to the HFONT, multiple
- // HFontRefs can share the same HFONT, and ChromeFont can provide value
- // semantics.
+ // HFontRefs can share the same HFONT, and Font can provide value semantics.
class HFontRef : public base::RefCounted<HFontRef> {
public:
// This constructor takes control of the HFONT, and will delete it when
@@ -182,7 +182,7 @@ class ChromeFont {
// Creates and returns a new HFONTRef from the specified HFONT.
static HFontRef* CreateHFontRef(HFONT font);
- explicit ChromeFont(HFontRef* font_ref) : font_ref_(font_ref) { }
+ explicit Font(HFontRef* font_ref) : font_ref_(font_ref) { }
// Reference to the base font all fonts are derived from.
static HFontRef* base_font_ref_;
@@ -190,15 +190,15 @@ class ChromeFont {
// Indirect reference to the HFontRef, which references the underlying HFONT.
scoped_refptr<HFontRef> font_ref_;
#elif defined(OS_LINUX)
- explicit ChromeFont(SkTypeface* typeface, const std::wstring& name,
- int size, int style);
+ explicit Font(SkTypeface* typeface, const std::wstring& name,
+ int size, int style);
// Calculate and cache the font metrics.
void calculateMetrics();
// Make |this| a copy of |other|.
- void CopyChromeFont(const ChromeFont& other);
+ void CopyFont(const Font& other);
// The default font, used for the default constructor.
- static ChromeFont* default_font_;
+ static Font* default_font_;
// These two both point to the same SkTypeface. We use the SkAutoUnref to
// handle the reference counting, but without @typeface_ we would have to
@@ -217,7 +217,7 @@ class ChromeFont {
int ascent_;
int avg_width_;
#elif defined(OS_MACOSX)
- explicit ChromeFont(const std::wstring& font_name, int font_size, int style);
+ explicit Font(const std::wstring& font_name, int font_size, int style);
// Calculate and cache the font metrics.
void calculateMetrics();
@@ -234,4 +234,6 @@ class ChromeFont {
};
-#endif // APP_GFX_CHROME_FONT_H_
+} // namespace gfx
+
+#endif // APP_GFX_FONT_H_
diff --git a/app/gfx/chrome_font_gtk.cc b/app/gfx/chrome_font_gtk.cc
index 39acf85..babeff5 100644
--- a/app/gfx/chrome_font_gtk.cc
+++ b/app/gfx/chrome_font_gtk.cc
@@ -9,7 +9,9 @@
#include "base/string_util.h"
-ChromeFont* ChromeFont::default_font_ = NULL;
+namespace gfx {
+
+Font* Font::default_font_ = NULL;
// Find the best match font for |family_name| in the same way as Skia
// to make sure CreateFont() successfully creates default font.
@@ -45,7 +47,7 @@ static std::wstring FindBestMatchFontFamilyName(const char* family_name) {
}
// Get the default gtk system font (name and size).
-ChromeFont::ChromeFont() {
+Font::Font() {
if (default_font_ == NULL) {
gtk_init(NULL, NULL);
GtkSettings* settings = gtk_settings_get_default();
@@ -72,7 +74,7 @@ ChromeFont::ChromeFont() {
// TODO(agl): remove this.
std::wstring font_family = FindBestMatchFontFamilyName(family_name);
- default_font_ = new ChromeFont(CreateFont(font_family, size / PANGO_SCALE));
+ default_font_ = new Font(CreateFont(font_family, size / PANGO_SCALE));
pango_font_description_free(desc);
g_free(font_name);
@@ -81,5 +83,7 @@ ChromeFont::ChromeFont() {
DCHECK(default_font_);
}
- CopyChromeFont(*default_font_);
+ CopyFont(*default_font_);
}
+
+} // namespace gfx
diff --git a/app/gfx/chrome_font_mac.mm b/app/gfx/chrome_font_mac.mm
index 87605ad..885c3b1 100644
--- a/app/gfx/chrome_font_mac.mm
+++ b/app/gfx/chrome_font_mac.mm
@@ -9,20 +9,21 @@
#include "base/logging.h"
#include "base/sys_string_conversions.h"
+namespace gfx {
+
// static
-ChromeFont ChromeFont::CreateFont(const std::wstring& font_name,
- int font_size) {
- return ChromeFont(font_name, font_size, NORMAL);
+Font Font::CreateFont(const std::wstring& font_name, int font_size) {
+ return Font(font_name, font_size, NORMAL);
}
-ChromeFont::ChromeFont(const std::wstring& font_name, int font_size, int style)
+Font::Font(const std::wstring& font_name, int font_size, int style)
: font_name_(font_name),
font_size_(font_size),
style_(style) {
calculateMetrics();
}
-ChromeFont::ChromeFont()
+Font::Font()
: font_size_([NSFont systemFontSize]),
style_(NORMAL) {
NSFont* system_font = [NSFont systemFontOfSize:font_size_];
@@ -30,30 +31,30 @@ ChromeFont::ChromeFont()
calculateMetrics();
}
-void ChromeFont::calculateMetrics() {
+void Font::calculateMetrics() {
NSFont* font = nativeFont();
height_ = [font xHeight];
ascent_ = [font ascender];
avg_width_ = [font boundingRectForGlyph:[font glyphWithName:@"x"]].size.width;
}
-ChromeFont ChromeFont::DeriveFont(int size_delta, int style) const {
- return ChromeFont(font_name_, font_size_ + size_delta, style);
+Font Font::DeriveFont(int size_delta, int style) const {
+ return Font(font_name_, font_size_ + size_delta, style);
}
-int ChromeFont::height() const {
+int Font::height() const {
return height_;
}
-int ChromeFont::baseline() const {
+int Font::baseline() const {
return ascent_;
}
-int ChromeFont::ave_char_width() const {
+int Font::ave_char_width() const {
return avg_width_;
}
-int ChromeFont::GetStringWidth(const std::wstring& text) const {
+int Font::GetStringWidth(const std::wstring& text) const {
NSFont* font = nativeFont();
NSString* ns_string = base::SysWideToNSString(text);
NSDictionary* attributes =
@@ -62,26 +63,28 @@ int ChromeFont::GetStringWidth(const std::wstring& text) const {
return string_size.width;
}
-int ChromeFont::GetExpectedTextWidth(int length) const {
+int Font::GetExpectedTextWidth(int length) const {
return length * avg_width_;
}
-int ChromeFont::style() const {
+int Font::style() const {
return style_;
}
-std::wstring ChromeFont::FontName() {
+std::wstring Font::FontName() {
return font_name_;
}
-int ChromeFont::FontSize() {
+int Font::FontSize() {
return font_size_;
}
-NativeFont ChromeFont::nativeFont() const {
+NativeFont Font::nativeFont() const {
// TODO(pinkerton): apply |style_| to font.
// We could cache this, but then we'd have to conditionally change the
// dtor just for MacOS. Not sure if we want to/need to do that.
return [NSFont fontWithName:base::SysWideToNSString(font_name_)
size:font_size_];
}
+
+} // namespace gfx
diff --git a/app/gfx/chrome_font_skia.cc b/app/gfx/chrome_font_skia.cc
index 6c1b6d5..9622a70 100644
--- a/app/gfx/chrome_font_skia.cc
+++ b/app/gfx/chrome_font_skia.cc
@@ -10,17 +10,19 @@
#include "third_party/skia/include/core/SkTypeface.h"
#include "third_party/skia/include/core/SkPaint.h"
-ChromeFont::ChromeFont(const ChromeFont& other) {
- CopyChromeFont(other);
+namespace gfx {
+
+Font::Font(const Font& other) {
+ CopyFont(other);
}
-ChromeFont& ChromeFont::operator=(const ChromeFont& other) {
- CopyChromeFont(other);
+Font& Font::operator=(const Font& other) {
+ CopyFont(other);
return *this;
}
-ChromeFont::ChromeFont(SkTypeface* tf, const std::wstring& font_family,
- int font_size, int style)
+Font::Font(SkTypeface* tf, const std::wstring& font_family, int font_size,
+ int style)
: typeface_helper_(new SkAutoUnref(tf)),
typeface_(tf),
font_family_(font_family),
@@ -30,7 +32,7 @@ ChromeFont::ChromeFont(SkTypeface* tf, const std::wstring& font_family,
calculateMetrics();
}
-void ChromeFont::calculateMetrics() {
+void Font::calculateMetrics() {
SkPaint paint;
SkPaint::FontMetrics metrics;
@@ -52,7 +54,7 @@ void ChromeFont::calculateMetrics() {
}
}
-void ChromeFont::CopyChromeFont(const ChromeFont& other) {
+void Font::CopyFont(const Font& other) {
typeface_helper_.reset(new SkAutoUnref(other.typeface_));
typeface_ = other.typeface_;
typeface_->ref();
@@ -64,20 +66,19 @@ void ChromeFont::CopyChromeFont(const ChromeFont& other) {
avg_width_ = other.avg_width_;
}
-int ChromeFont::height() const {
+int Font::height() const {
return height_;
}
-int ChromeFont::baseline() const {
+int Font::baseline() const {
return ascent_;
}
-int ChromeFont::ave_char_width() const {
+int Font::ave_char_width() const {
return avg_width_;
}
-ChromeFont ChromeFont::CreateFont(const std::wstring& font_family,
- int font_size) {
+Font Font::CreateFont(const std::wstring& font_family, int font_size) {
DCHECK_GT(font_size, 0);
SkTypeface* tf = SkTypeface::CreateFromName(
@@ -85,10 +86,10 @@ ChromeFont ChromeFont::CreateFont(const std::wstring& font_family,
DCHECK(tf) << "Could not find font: " << base::SysWideToUTF8(font_family);
SkAutoUnref tf_helper(tf);
- return ChromeFont(tf, font_family, font_size, NORMAL);
+ return Font(tf, font_family, font_size, NORMAL);
}
-ChromeFont ChromeFont::DeriveFont(int size_delta, int style) const {
+Font Font::DeriveFont(int size_delta, int style) const {
// If the delta is negative, if must not push the size below 1
if (size_delta < 0) {
DCHECK_LT(-size_delta, font_size_);
@@ -96,7 +97,7 @@ ChromeFont ChromeFont::DeriveFont(int size_delta, int style) const {
if (style == style_) {
// Fast path, we just use the same typeface at a different size
- return ChromeFont(typeface_, font_family_, font_size_ + size_delta, style_);
+ return Font(typeface_, font_family_, font_size_ + size_delta, style_);
}
// If the style has changed we may need to load a new face
@@ -111,10 +112,10 @@ ChromeFont ChromeFont::DeriveFont(int size_delta, int style) const {
static_cast<SkTypeface::Style>(skstyle));
SkAutoUnref tf_helper(tf);
- return ChromeFont(tf, font_family_, font_size_ + size_delta, skstyle);
+ return Font(tf, font_family_, font_size_ + size_delta, skstyle);
}
-void ChromeFont::PaintSetup(SkPaint* paint) const {
+void Font::PaintSetup(SkPaint* paint) const {
paint->setAntiAlias(false);
paint->setSubpixelText(false);
paint->setTextSize(SkFloatToScalar(font_size_));
@@ -124,7 +125,7 @@ void ChromeFont::PaintSetup(SkPaint* paint) const {
-SK_Scalar1/4 : 0);
}
-int ChromeFont::GetStringWidth(const std::wstring& text) const {
+int Font::GetStringWidth(const std::wstring& text) const {
const std::string utf8(base::SysWideToUTF8(text));
SkPaint paint;
@@ -142,23 +143,25 @@ int ChromeFont::GetStringWidth(const std::wstring& text) const {
return breadth;
}
-int ChromeFont::GetExpectedTextWidth(int length) const {
+int Font::GetExpectedTextWidth(int length) const {
return length * avg_width_;
}
-int ChromeFont::style() const {
+int Font::style() const {
return style_;
}
-std::wstring ChromeFont::FontName() {
+std::wstring Font::FontName() {
return font_family_;
}
-int ChromeFont::FontSize() {
+int Font::FontSize() {
return font_size_;
}
-NativeFont ChromeFont::nativeFont() const {
+NativeFont Font::nativeFont() const {
return typeface_;
}
+
+} // namespace gfx
diff --git a/app/gfx/chrome_font_unittest.cc b/app/gfx/chrome_font_unittest.cc
index 5ad7973..0bb840b4 100644
--- a/app/gfx/chrome_font_unittest.cc
+++ b/app/gfx/chrome_font_unittest.cc
@@ -8,46 +8,48 @@
namespace {
-class ChromeFontTest : public testing::Test {
+using gfx::Font;
+
+class FontTest : public testing::Test {
};
-TEST_F(ChromeFontTest, LoadArial) {
- ChromeFont cf(ChromeFont::CreateFont(L"Arial", 16));
+TEST_F(FontTest, LoadArial) {
+ Font cf(Font::CreateFont(L"Arial", 16));
ASSERT_TRUE(cf.nativeFont());
- ASSERT_EQ(cf.style(), ChromeFont::NORMAL);
+ ASSERT_EQ(cf.style(), Font::NORMAL);
ASSERT_EQ(cf.FontSize(), 16);
ASSERT_EQ(cf.FontName(), L"Arial");
}
-TEST_F(ChromeFontTest, LoadArialBold) {
- ChromeFont cf(ChromeFont::CreateFont(L"Arial", 16));
- ChromeFont bold(cf.DeriveFont(0, ChromeFont::BOLD));
+TEST_F(FontTest, LoadArialBold) {
+ Font cf(Font::CreateFont(L"Arial", 16));
+ Font bold(cf.DeriveFont(0, Font::BOLD));
ASSERT_TRUE(bold.nativeFont());
- ASSERT_EQ(bold.style(), ChromeFont::BOLD);
+ ASSERT_EQ(bold.style(), Font::BOLD);
}
-TEST_F(ChromeFontTest, Ascent) {
- ChromeFont cf(ChromeFont::CreateFont(L"Arial", 16));
+TEST_F(FontTest, Ascent) {
+ Font cf(Font::CreateFont(L"Arial", 16));
ASSERT_GT(cf.baseline(), 2);
ASSERT_LT(cf.baseline(), 20);
}
-TEST_F(ChromeFontTest, Height) {
- ChromeFont cf(ChromeFont::CreateFont(L"Arial", 16));
+TEST_F(FontTest, Height) {
+ Font cf(Font::CreateFont(L"Arial", 16));
ASSERT_GT(cf.baseline(), 2);
ASSERT_LT(cf.baseline(), 20);
}
-TEST_F(ChromeFontTest, AvgWidths) {
- ChromeFont cf(ChromeFont::CreateFont(L"Arial", 16));
+TEST_F(FontTest, AvgWidths) {
+ Font cf(Font::CreateFont(L"Arial", 16));
ASSERT_EQ(cf.GetExpectedTextWidth(0), 0);
ASSERT_GT(cf.GetExpectedTextWidth(1), cf.GetExpectedTextWidth(0));
ASSERT_GT(cf.GetExpectedTextWidth(2), cf.GetExpectedTextWidth(1));
ASSERT_GT(cf.GetExpectedTextWidth(3), cf.GetExpectedTextWidth(2));
}
-TEST_F(ChromeFontTest, Widths) {
- ChromeFont cf(ChromeFont::CreateFont(L"Arial", 16));
+TEST_F(FontTest, Widths) {
+ Font cf(Font::CreateFont(L"Arial", 16));
ASSERT_EQ(cf.GetStringWidth(L""), 0);
ASSERT_GT(cf.GetStringWidth(L"a"), cf.GetStringWidth(L""));
ASSERT_GT(cf.GetStringWidth(L"ab"), cf.GetStringWidth(L"a"));
diff --git a/app/gfx/chrome_font_win.cc b/app/gfx/chrome_font_win.cc
index b5ddb18..1cbe500 100644
--- a/app/gfx/chrome_font_win.cc
+++ b/app/gfx/chrome_font_win.cc
@@ -15,92 +15,93 @@
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
+namespace gfx {
+
/*static*/
-ChromeFont::HFontRef* ChromeFont::base_font_ref_;
+Font::HFontRef* Font::base_font_ref_;
// If the tmWeight field of a TEXTMETRIC structure has a value >= this, the
// font is bold.
static const int kTextMetricWeightBold = 700;
//
-// ChromeFont
+// Font
//
-ChromeFont::ChromeFont()
+Font::Font()
: font_ref_(GetBaseFontRef()) {
}
-int ChromeFont::height() const {
+int Font::height() const {
return font_ref_->height();
}
-int ChromeFont::baseline() const {
+int Font::baseline() const {
return font_ref_->baseline();
}
-int ChromeFont::ave_char_width() const {
+int Font::ave_char_width() const {
return font_ref_->ave_char_width();
}
-int ChromeFont::GetExpectedTextWidth(int length) const {
+int Font::GetExpectedTextWidth(int length) const {
return length * std::min(font_ref_->dlu_base_x(), ave_char_width());
}
-int ChromeFont::style() const {
+int Font::style() const {
return font_ref_->style();
}
-NativeFont ChromeFont::nativeFont() const {
+NativeFont Font::nativeFont() const {
return hfont();
}
// static
-ChromeFont ChromeFont::CreateFont(HFONT font) {
+Font Font::CreateFont(HFONT font) {
DCHECK(font);
LOGFONT font_info;
GetObject(font, sizeof(LOGFONT), &font_info);
- return ChromeFont(CreateHFontRef(CreateFontIndirect(&font_info)));
+ return Font(CreateHFontRef(CreateFontIndirect(&font_info)));
}
-ChromeFont ChromeFont::CreateFont(const std::wstring& font_name,
- int font_size) {
+Font Font::CreateFont(const std::wstring& font_name, int font_size) {
HDC hdc = GetDC(NULL);
long lf_height = -MulDiv(font_size, GetDeviceCaps(hdc, LOGPIXELSY), 72);
ReleaseDC(NULL, hdc);
HFONT hf = ::CreateFont(lf_height, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
font_name.c_str());
- return ChromeFont::CreateFont(hf);
+ return Font::CreateFont(hf);
}
// static
-ChromeFont::HFontRef* ChromeFont::GetBaseFontRef() {
+Font::HFontRef* Font::GetBaseFontRef() {
if (base_font_ref_ == NULL) {
NONCLIENTMETRICS metrics;
win_util::GetNonClientMetrics(&metrics);
l10n_util::AdjustUIFont(&metrics.lfMessageFont);
- // See comment in ChromeFont::DeriveFont() about font size.
+ // See comment in Font::DeriveFont() about font size.
// TODO(jungshik): Add a per-locale resource entry for the minimum
// font size and actually enforce the lower-bound. 5 is way too small
// for CJK, Thai, and Indian locales.
DCHECK_GE(abs(metrics.lfMessageFont.lfHeight), 5);
HFONT font = CreateFontIndirect(&metrics.lfMessageFont);
DLOG_ASSERT(font);
- base_font_ref_ = ChromeFont::CreateHFontRef(font);
+ base_font_ref_ = Font::CreateHFontRef(font);
// base_font_ref_ is global, up the ref count so it's never deleted.
base_font_ref_->AddRef();
}
return base_font_ref_;
}
-std::wstring ChromeFont::FontName() {
+std::wstring Font::FontName() {
LOGFONT font_info;
GetObject(hfont(), sizeof(LOGFONT), &font_info);
return (std::wstring(font_info.lfFaceName));
}
-int ChromeFont::FontSize() {
+int Font::FontSize() {
LOGFONT font_info;
GetObject(hfont(), sizeof(LOGFONT), &font_info);
long lf_height = font_info.lfHeight;
@@ -115,7 +116,7 @@ int ChromeFont::FontSize() {
return font_size;
}
-ChromeFont::HFontRef::HFontRef(HFONT hfont,
+Font::HFontRef::HFontRef(HFONT hfont,
int height,
int baseline,
int ave_char_width,
@@ -130,12 +131,12 @@ ChromeFont::HFontRef::HFontRef(HFONT hfont,
DLOG_ASSERT(hfont);
}
-ChromeFont::HFontRef::~HFontRef() {
+Font::HFontRef::~HFontRef() {
DeleteObject(hfont_);
}
-ChromeFont ChromeFont::DeriveFont(int size_delta, int style) const {
+Font Font::DeriveFont(int size_delta, int style) const {
LOGFONT font_info;
GetObject(hfont(), sizeof(LOGFONT), &font_info);
// LOGFONT returns two types of font heights, negative is measured slightly
@@ -154,10 +155,10 @@ ChromeFont ChromeFont::DeriveFont(int size_delta, int style) const {
font_info.lfWeight = (style & BOLD) ? FW_BOLD : FW_NORMAL;
HFONT hfont = CreateFontIndirect(&font_info);
- return ChromeFont(CreateHFontRef(hfont));
+ return Font(CreateHFontRef(hfont));
}
-int ChromeFont::GetStringWidth(const std::wstring& text) const {
+int Font::GetStringWidth(const std::wstring& text) const {
int width = 0;
HDC dc = GetDC(NULL);
HFONT previous_font = static_cast<HFONT>(SelectObject(dc, hfont()));
@@ -173,7 +174,7 @@ int ChromeFont::GetStringWidth(const std::wstring& text) const {
return width;
}
-ChromeFont::HFontRef* ChromeFont::CreateHFontRef(HFONT font) {
+Font::HFontRef* Font::CreateHFontRef(HFONT font) {
TEXTMETRIC font_metrics;
HDC screen_dc = GetDC(NULL);
HFONT previous_font = static_cast<HFONT>(SelectObject(screen_dc, font));
@@ -197,15 +198,17 @@ ChromeFont::HFontRef* ChromeFont::CreateHFontRef(HFONT font) {
std::max(1, static_cast<int>(font_metrics.tmAveCharWidth));
int style = 0;
if (font_metrics.tmItalic) {
- style |= ChromeFont::ITALIC;
+ style |= Font::ITALIC;
}
if (font_metrics.tmUnderlined) {
- style |= ChromeFont::UNDERLINED;
+ style |= Font::UNDERLINED;
}
if (font_metrics.tmWeight >= kTextMetricWeightBold) {
- style |= ChromeFont::BOLD;
+ style |= Font::BOLD;
}
return new HFontRef(font, height, baseline, ave_char_width, style,
dlu_base_x);
}
+
+} // namespace gfx
diff --git a/app/gfx/text_elider.cc b/app/gfx/text_elider.cc
index 6e20314..93653e0 100644
--- a/app/gfx/text_elider.cc
+++ b/app/gfx/text_elider.cc
@@ -44,7 +44,7 @@ static void AppendFormattedComponent(const std::string& spec,
// a rendered string is always the sum of the widths of its substrings. Also I
// suspect it could be made simpler.
std::wstring ElideUrl(const GURL& url,
- const ChromeFont& font,
+ const gfx::Font& font,
int available_pixel_width,
const std::wstring& languages) {
// Get a formatted string and corresponding parsing of the url.
@@ -271,7 +271,7 @@ std::wstring ElideUrl(const GURL& url,
}
std::wstring ElideFilename(const FilePath& filename,
- const ChromeFont& font,
+ const gfx::Font& font,
int available_pixel_width) {
int full_width = font.GetStringWidth(filename.ToWStringHack());
if (full_width <= available_pixel_width)
@@ -302,7 +302,7 @@ std::wstring ElideFilename(const FilePath& filename,
// This function adds an ellipsis at the end of the text if the text
// does not fit the given pixel width.
std::wstring ElideText(const std::wstring& text,
- const ChromeFont& font,
+ const gfx::Font& font,
int available_pixel_width){
if (text.empty())
return text;
diff --git a/app/gfx/text_elider.h b/app/gfx/text_elider.h
index 61bfada..5872ed4 100644
--- a/app/gfx/text_elider.h
+++ b/app/gfx/text_elider.h
@@ -47,19 +47,19 @@ std::wstring GetCleanStringFromUrl(const GURL& url,
// is displayed properly in an RTL context. Please refer to
// http://crbug.com/6487 for more information.
std::wstring ElideUrl(const GURL& url,
- const ChromeFont& font,
+ const gfx::Font& font,
int available_pixel_width,
const std::wstring& languages);
std::wstring ElideText(const std::wstring& text,
- const ChromeFont& font,
+ const gfx::Font& font,
int available_pixel_width);
// Elide a filename to fit a given pixel width, with an emphasis on not hiding
// the extension unless we have to. If filename contains a path, the path will
// be removed if filename doesn't fit into available_pixel_width.
std::wstring ElideFilename(const FilePath& filename,
- const ChromeFont& font,
+ const gfx::Font& font,
int available_pixel_width);
// SortedDisplayURL maintains a string from a URL suitable for display to the
diff --git a/app/gfx/text_elider_unittest.cc b/app/gfx/text_elider_unittest.cc
index 0f17f9f..28691d7 100644
--- a/app/gfx/text_elider_unittest.cc
+++ b/app/gfx/text_elider_unittest.cc
@@ -37,7 +37,7 @@ struct TestData {
};
void RunTest(Testcase* testcases, size_t num_testcases) {
- static const ChromeFont font;
+ static const gfx::Font font;
for (size_t i = 0; i < num_testcases; ++i) {
const GURL url(testcases[i].input);
// Should we test with non-empty language list?
@@ -175,7 +175,7 @@ TEST(TextEliderTest, TestFilenameEliding) {
L"filename.mid" + kEllipsisStr + L".longext"}
};
- static const ChromeFont font;
+ static const gfx::Font font;
for (size_t i = 0; i < arraysize(testcases); ++i) {
FilePath filepath(testcases[i].input);
EXPECT_EQ(testcases[i].output, ElideFilename(filepath,
@@ -210,7 +210,7 @@ TEST(TextEliderTest, ElideTextLongStrings) {
data_scheme + std::wstring(156, L'a') + kEllipsisStr},
};
- const ChromeFont font;
+ const gfx::Font font;
int ellipsis_width = font.GetStringWidth(kEllipsisStr);
for (size_t i = 0; i < arraysize(testcases); ++i) {
// Compare sizes rather than actual contents because if the test fails,
diff --git a/app/resource_bundle.cc b/app/resource_bundle.cc
index 85fd0b9..96bc714 100644
--- a/app/resource_bundle.cc
+++ b/app/resource_bundle.cc
@@ -159,24 +159,24 @@ SkBitmap* ResourceBundle::GetBitmapNamed(int resource_id) {
void ResourceBundle::LoadFontsIfNecessary() {
AutoLock lock_scope(lock_);
if (!base_font_.get()) {
- base_font_.reset(new ChromeFont());
+ base_font_.reset(new gfx::Font());
- small_font_.reset(new ChromeFont());
+ small_font_.reset(new gfx::Font());
*small_font_ = base_font_->DeriveFont(-2);
- medium_font_.reset(new ChromeFont());
+ medium_font_.reset(new gfx::Font());
*medium_font_ = base_font_->DeriveFont(3);
- medium_bold_font_.reset(new ChromeFont());
+ medium_bold_font_.reset(new gfx::Font());
*medium_bold_font_ =
- base_font_->DeriveFont(3, base_font_->style() | ChromeFont::BOLD);
+ base_font_->DeriveFont(3, base_font_->style() | gfx::Font::BOLD);
- large_font_.reset(new ChromeFont());
+ large_font_.reset(new gfx::Font());
*large_font_ = base_font_->DeriveFont(8);
}
}
-ChromeFont ResourceBundle::GetFont(FontStyle style) {
+gfx::Font ResourceBundle::GetFont(FontStyle style) {
LoadFontsIfNecessary();
switch(style) {
case SmallFont:
diff --git a/app/resource_bundle.h b/app/resource_bundle.h
index 1ed44b0..ed17616 100644
--- a/app/resource_bundle.h
+++ b/app/resource_bundle.h
@@ -23,12 +23,14 @@
#if defined(OS_LINUX) || defined(OS_MACOSX)
namespace base {
class DataPack;
-};
+}
#endif
#if defined(OS_LINUX)
typedef struct _GdkPixbuf GdkPixbuf;
#endif
-class ChromeFont;
+namespace gfx{
+class Font;
+}
class SkBitmap;
typedef uint32 SkColor;
class StringPiece;
@@ -102,7 +104,7 @@ class ResourceBundle {
string16 GetLocalizedString(int message_id);
// Returns the font for the specified style.
- ChromeFont GetFont(FontStyle style);
+ gfx::Font GetFont(FontStyle style);
#if defined(OS_WIN)
// Loads and returns an icon from the theme dll.
@@ -154,7 +156,7 @@ class ResourceBundle {
// external data module.
void LoadResources(const std::wstring& pref_locale);
- // Initialize all the ChromeFont members if they haven't yet been initialized.
+ // Initialize all the gfx::Font members if they haven't yet been initialized.
void LoadFontsIfNecessary();
// Returns the full pathname of the locale file to load. May return an empty
@@ -192,12 +194,12 @@ class ResourceBundle {
#endif
// The various fonts used. Cached to avoid repeated GDI creation/destruction.
- scoped_ptr<ChromeFont> base_font_;
- scoped_ptr<ChromeFont> small_font_;
- scoped_ptr<ChromeFont> medium_font_;
- scoped_ptr<ChromeFont> medium_bold_font_;
- scoped_ptr<ChromeFont> large_font_;
- scoped_ptr<ChromeFont> web_font_;
+ scoped_ptr<gfx::Font> base_font_;
+ scoped_ptr<gfx::Font> small_font_;
+ scoped_ptr<gfx::Font> medium_font_;
+ scoped_ptr<gfx::Font> medium_bold_font_;
+ scoped_ptr<gfx::Font> large_font_;
+ scoped_ptr<gfx::Font> web_font_;
static ResourceBundle* g_shared_instance_;
diff --git a/app/win_util.cc b/app/win_util.cc
index 511b965..ace5f52 100644
--- a/app/win_util.cc
+++ b/app/win_util.cc
@@ -813,12 +813,12 @@ int MessageBox(HWND hwnd,
return ::MessageBox(hwnd, text_ptr, caption_ptr, actual_flags);
}
-ChromeFont GetWindowTitleFont() {
+gfx::Font GetWindowTitleFont() {
NONCLIENTMETRICS ncm;
win_util::GetNonClientMetrics(&ncm);
l10n_util::AdjustUIFont(&(ncm.lfCaptionFont));
ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont)));
- return ChromeFont::CreateFont(caption_font);
+ return gfx::Font::CreateFont(caption_font);
}
} // namespace win_util
diff --git a/app/win_util.h b/app/win_util.h
index 1c384c9..2b5bdce 100644
--- a/app/win_util.h
+++ b/app/win_util.h
@@ -285,7 +285,7 @@ int MessageBox(HWND hwnd,
UINT flags);
// Returns the system set window title font.
-ChromeFont GetWindowTitleFont();
+gfx::Font GetWindowTitleFont();
// The thickness of an auto-hide taskbar in pixels.
extern const int kAutoHideTaskbarThicknessPx;
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
index 35bd86b..1dabca1 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
@@ -390,7 +390,7 @@ base::LazyInstance<PaintPatcher> g_paint_patcher(base::LINKER_INITIALIZED);
} // namespace
AutocompleteEditViewWin::AutocompleteEditViewWin(
- const ChromeFont& font,
+ const gfx::Font& font,
AutocompleteEditController* controller,
ToolbarModel* toolbar_model,
views::View* parent_view,
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.h b/chrome/browser/autocomplete/autocomplete_edit_view_win.h
index 7b00044..053adcd 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_win.h
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.h
@@ -60,7 +60,7 @@ class AutocompleteEditViewWin
DECLARE_WND_CLASS(L"Chrome_AutocompleteEditView");
- AutocompleteEditViewWin(const ChromeFont& font,
+ AutocompleteEditViewWin(const gfx::Font& font,
AutocompleteEditController* controller,
ToolbarModel* toolbar_model,
views::View* parent_view,
@@ -428,7 +428,7 @@ class AutocompleteEditViewWin
// Font we're using. We keep a reference to make sure the font supplied to
// the constructor doesn't go away before we do.
- ChromeFont font_;
+ gfx::Font font_;
// Metrics about the font, which we keep so we don't need to recalculate them
// every time we paint. |font_y_adjustment_| is the number of pixels we need
diff --git a/chrome/browser/autocomplete/autocomplete_popup_view.h b/chrome/browser/autocomplete/autocomplete_popup_view.h
index c532847..f287d63 100644
--- a/chrome/browser/autocomplete/autocomplete_popup_view.h
+++ b/chrome/browser/autocomplete/autocomplete_popup_view.h
@@ -13,8 +13,8 @@
class AutocompleteEditView;
class AutocompletePopupModel;
-class ChromeFont;
namespace gfx {
+class Font;
class Rect;
}
#if defined(OS_WIN)
@@ -60,7 +60,7 @@ class AutocompletePopupView {
// Create a popup view implementation. It may make sense for this to become
// platform independent eventually.
static AutocompletePopupView* CreatePopupView(
- const ChromeFont& font,
+ const gfx::Font& font,
AutocompleteEditViewWin* edit_view,
AutocompleteEditModel* edit_model,
Profile* profile,
diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc
index a671e40..5301f68 100644
--- a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc
+++ b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc
@@ -60,25 +60,25 @@ const int kRightPadding = 3;
// the total width.
const float kContentWidthPercentage = 0.7;
-// TODO(deanm): We should put this on ChromeFont so it can be shared.
+// TODO(deanm): We should put this on gfx::Font so it can be shared.
// Returns a new pango font, free with pango_font_description_free().
-PangoFontDescription* PangoFontFromChromeFont(const ChromeFont& chrome_font) {
- ChromeFont font = chrome_font; // Copy so we can call non-const methods.
+PangoFontDescription* PangoFontFromGfxFont(const gfx::Font& chrome_font) {
+ gfx::Font font = chrome_font; // Copy so we can call non-const methods.
PangoFontDescription* pfd = pango_font_description_new();
pango_font_description_set_family(pfd, WideToUTF8(font.FontName()).c_str());
pango_font_description_set_size(pfd, font.FontSize() * PANGO_SCALE);
switch (font.style()) {
- case ChromeFont::NORMAL:
+ case gfx::Font::NORMAL:
// Nothing to do, should already be PANGO_STYLE_NORMAL.
break;
- case ChromeFont::BOLD:
+ case gfx::Font::BOLD:
pango_font_description_set_weight(pfd, PANGO_WEIGHT_BOLD);
break;
- case ChromeFont::ITALIC:
+ case gfx::Font::ITALIC:
pango_font_description_set_style(pfd, PANGO_STYLE_ITALIC);
break;
- case ChromeFont::UNDERLINED:
+ case gfx::Font::UNDERLINED:
// TODO(deanm): How to do underlined? Where do we use it? Probably have
// to paint it ourselves, see pango_font_metrics_get_underline_position.
break;
@@ -246,9 +246,9 @@ AutocompletePopupViewGtk::AutocompletePopupViewGtk(
// We always ellipsize when drawing our text runs.
pango_layout_set_ellipsize(layout_, PANGO_ELLIPSIZE_END);
// TODO(deanm): We might want to eventually follow what Windows does and
- // plumb a ChromeFont through. This is because popup windows have a
+ // plumb a gfx::Font through. This is because popup windows have a
// different font size, although we could just derive that font here.
- PangoFontDescription* pfd = PangoFontFromChromeFont(ChromeFont());
+ PangoFontDescription* pfd = PangoFontFromGfxFont(gfx::Font());
pango_layout_set_font_description(layout_, pfd);
pango_font_description_free(pfd);
diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_win.cc b/chrome/browser/autocomplete/autocomplete_popup_view_win.cc
index 98be163..7450655 100644
--- a/chrome/browser/autocomplete/autocomplete_popup_view_win.cc
+++ b/chrome/browser/autocomplete/autocomplete_popup_view_win.cc
@@ -87,10 +87,10 @@ int AutocompletePopupViewWin::MirroringContext::GetLeft(int x1, int x2) const {
const wchar_t AutocompletePopupViewWin::DrawLineInfo::ellipsis_str[] =
L"\x2026";
-AutocompletePopupViewWin::DrawLineInfo::DrawLineInfo(const ChromeFont& font) {
+AutocompletePopupViewWin::DrawLineInfo::DrawLineInfo(const gfx::Font& font) {
// Create regular and bold fonts.
regular_font = font.DeriveFont(-1);
- bold_font = regular_font.DeriveFont(0, ChromeFont::BOLD);
+ bold_font = regular_font.DeriveFont(0, gfx::Font::BOLD);
// The total padding added to each line (bottom padding is what is
// left over after DrawEntry() specifies its top offset).
@@ -186,7 +186,7 @@ COLORREF AutocompletePopupViewWin::DrawLineInfo::AlphaBlend(
}
AutocompletePopupViewWin::AutocompletePopupViewWin(
- const ChromeFont& font,
+ const gfx::Font& font,
AutocompleteEditViewWin* edit_view,
AutocompleteEditModel* edit_model,
Profile* profile)
@@ -680,7 +680,7 @@ void AutocompletePopupViewWin::DrawStar(HDC dc, int x, int y) const {
// static
AutocompletePopupView* AutocompletePopupView::CreatePopupView(
- const ChromeFont& font,
+ const gfx::Font& font,
AutocompleteEditViewWin* edit_view,
AutocompleteEditModel* edit_model,
Profile* profile,
diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_win.h b/chrome/browser/autocomplete/autocomplete_popup_view_win.h
index f98346d..bc4e135 100644
--- a/chrome/browser/autocomplete/autocomplete_popup_view_win.h
+++ b/chrome/browser/autocomplete/autocomplete_popup_view_win.h
@@ -48,7 +48,7 @@ class AutocompletePopupViewWin
MSG_WM_PAINT(OnPaint)
END_MSG_MAP()
- AutocompletePopupViewWin(const ChromeFont& font,
+ AutocompletePopupViewWin(const gfx::Font& font,
AutocompleteEditViewWin* edit_view,
AutocompleteEditModel* edit_model,
Profile* profile);
@@ -82,7 +82,7 @@ class AutocompletePopupViewWin
MAX_STATUS_ENTRIES
};
- explicit DrawLineInfo(const ChromeFont& font);
+ explicit DrawLineInfo(const gfx::Font& font);
~DrawLineInfo();
static COLORREF AlphaBlend(COLORREF foreground,
@@ -91,8 +91,8 @@ class AutocompletePopupViewWin
static const wchar_t ellipsis_str[];
- ChromeFont regular_font; // Fonts used for rendering AutocompleteMatches.
- ChromeFont bold_font;
+ gfx::Font regular_font; // Fonts used for rendering AutocompleteMatches.
+ gfx::Font bold_font;
int font_height; // Height (in pixels) of a line of text w/o
// padding.
int line_height; // Height (in pixels) of a line of text w/padding.
diff --git a/chrome/browser/cocoa/status_bubble_mac.mm b/chrome/browser/cocoa/status_bubble_mac.mm
index 67addcf..eeb82d1 100644
--- a/chrome/browser/cocoa/status_bubble_mac.mm
+++ b/chrome/browser/cocoa/status_bubble_mac.mm
@@ -83,9 +83,9 @@ void StatusBubbleMac::SetURL(const GURL& url, const std::wstring& languages) {
kTextPositionX -
kTextPadding);
NSFont* font = [[window_ contentView] font];
- ChromeFont font_chr =
- ChromeFont::CreateFont(base::SysNSStringToWide([font fontName]),
- [font pointSize]);
+ gfx::Font font_chr =
+ gfx::Font::CreateFont(base::SysNSStringToWide([font fontName]),
+ [font pointSize]);
std::wstring status = gfx::ElideUrl(url, font_chr, text_width, languages);
NSString* status_ns = base::SysWideToNSString(status);
diff --git a/chrome/browser/debugger/debugger_view.h b/chrome/browser/debugger/debugger_view.h
index 6d52686..f0eba87 100644
--- a/chrome/browser/debugger/debugger_view.h
+++ b/chrome/browser/debugger/debugger_view.h
@@ -88,7 +88,7 @@ class DebuggerView : public views::View,
void ExecuteJavascript(const std::string& js);
DebuggerWindow* window_;
- ChromeFont font_;
+ gfx::Font font_;
TabContents* tab_contents_;
TabContentsContainerView* web_container_;
std::vector<std::wstring> pending_output_;
diff --git a/chrome/browser/gtk/download_item_gtk.cc b/chrome/browser/gtk/download_item_gtk.cc
index 95db3c2..588af8a 100644
--- a/chrome/browser/gtk/download_item_gtk.cc
+++ b/chrome/browser/gtk/download_item_gtk.cc
@@ -165,12 +165,12 @@ DownloadItemGtk::DownloadItemGtk(DownloadShelfGtk* parent_shelf,
name_label_ = gtk_label_new(NULL);
// TODO(estade): This is at best an educated guess, since we don't actually
- // use ChromeFont() to draw the text. This is why we need to add so
- // much padding when we set the size request. We need to either use ChromeFont
+ // use gfx::Font() to draw the text. This is why we need to add so
+ // much padding when we set the size request. We need to either use gfx::Font
// or somehow extend TextElider.
std::wstring elided_filename = gfx::ElideFilename(
download_model_->download()->GetFileName(),
- ChromeFont(), kTextWidth);
+ gfx::Font(), kTextWidth);
gchar* label_markup =
g_markup_printf_escaped(kLabelColorMarkup, kFilenameColor,
WideToUTF8(elided_filename).c_str());
diff --git a/chrome/browser/gtk/sad_tab_gtk.cc b/chrome/browser/gtk/sad_tab_gtk.cc
index 4ec8e19..912988a 100644
--- a/chrome/browser/gtk/sad_tab_gtk.cc
+++ b/chrome/browser/gtk/sad_tab_gtk.cc
@@ -36,7 +36,7 @@ struct SadTabGtkConstants {
ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_SAD_TAB)),
title_font(
ResourceBundle::GetSharedInstance().GetFont(
- ResourceBundle::BaseFont).DeriveFont(2, ChromeFont::BOLD)),
+ ResourceBundle::BaseFont).DeriveFont(2, gfx::Font::BOLD)),
message_font(
ResourceBundle::GetSharedInstance().GetFont(
ResourceBundle::BaseFont).DeriveFont(1)),
@@ -44,8 +44,8 @@ struct SadTabGtkConstants {
message(l10n_util::GetString(IDS_SAD_TAB_MESSAGE)) {}
const SkBitmap* sad_tab_bitmap;
- ChromeFont title_font;
- ChromeFont message_font;
+ gfx::Font title_font;
+ gfx::Font message_font;
std::wstring title;
std::wstring message;
};
diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
index e840290..5584b3a 100644
--- a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
+++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
@@ -85,7 +85,7 @@ TabRendererGtk::TabImage TabRendererGtk::tab_active_ = {0};
TabRendererGtk::TabImage TabRendererGtk::tab_inactive_ = {0};
TabRendererGtk::TabImage TabRendererGtk::tab_alpha = {0};
TabRendererGtk::TabImage TabRendererGtk::tab_hover_ = {0};
-ChromeFont* TabRendererGtk::title_font_ = NULL;
+gfx::Font* TabRendererGtk::title_font_ = NULL;
int TabRendererGtk::title_font_height_ = 0;
SkBitmap* TabRendererGtk::download_icon_ = NULL;
int TabRendererGtk::download_icon_width_ = 0;
@@ -589,7 +589,7 @@ void TabRendererGtk::InitResources() {
LoadTabImages();
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- title_font_ = new ChromeFont(rb.GetFont(ResourceBundle::BaseFont));
+ title_font_ = new gfx::Font(rb.GetFont(ResourceBundle::BaseFont));
title_font_height_ = title_font_->height();
InitializeLoadingAnimationData(&rb, &loading_animation_data);
diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.h b/chrome/browser/gtk/tabs/tab_renderer_gtk.h
index e3d3a91..15b620f 100644
--- a/chrome/browser/gtk/tabs/tab_renderer_gtk.h
+++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.h
@@ -207,7 +207,7 @@ class TabRendererGtk : public AnimationDelegate {
static TabImage tab_alpha;
static TabImage tab_hover_;
- static ChromeFont* title_font_;
+ static gfx::Font* title_font_;
static int title_font_height_;
static SkBitmap* download_icon_;
diff --git a/chrome/browser/jsmessage_box_handler.cc b/chrome/browser/jsmessage_box_handler.cc
index 7de44e8..151a33a 100644
--- a/chrome/browser/jsmessage_box_handler.cc
+++ b/chrome/browser/jsmessage_box_handler.cc
@@ -48,7 +48,7 @@ std::wstring GetWindowTitle(TabContents* tab_contents, const GURL& frame_url,
// TODO(brettw) it should be easier than this to do the correct language
// handling without getting the accept language from the profile.
- std::wstring base_address = gfx::ElideUrl(clean_url, ChromeFont(), 0,
+ std::wstring base_address = gfx::ElideUrl(clean_url, gfx::Font(), 0,
tab_contents->profile()->GetPrefs()->GetString(prefs::kAcceptLanguages));
// Force URL to have LTR directionality.
if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT)
diff --git a/chrome/browser/printing/print_job.h b/chrome/browser/printing/print_job.h
index 217b304..22c61de 100644
--- a/chrome/browser/printing/print_job.h
+++ b/chrome/browser/printing/print_job.h
@@ -12,7 +12,6 @@
#include "chrome/browser/printing/print_job_worker_owner.h"
#include "chrome/common/notification_observer.h"
-class ChromeFont;
class GURL;
class Thread;
diff --git a/chrome/browser/printing/printed_document.cc b/chrome/browser/printing/printed_document.cc
index 08dc09f..f3fb5af 100644
--- a/chrome/browser/printing/printed_document.cc
+++ b/chrome/browser/printing/printed_document.cc
@@ -130,12 +130,12 @@ void PrintedDocument::RenderPrintedPage(const PrintedPage& page,
}
// Print the header and footer.
- int base_font_size = ChromeFont().height();
+ int base_font_size = gfx::Font().height();
int new_font_size = ConvertUnit(10,
immutable_.settings_.desired_dpi,
immutable_.settings_.dpi());
DCHECK_GT(new_font_size, base_font_size);
- ChromeFont font(ChromeFont().DeriveFont(new_font_size - base_font_size));
+ gfx::Font font(gfx::Font().DeriveFont(new_font_size - base_font_size));
HGDIOBJ old_font = SelectObject(context, font.hfont());
DCHECK(old_font != NULL);
// We don't want a white square around the text ever if overflowing.
@@ -264,7 +264,7 @@ void PrintedDocument::PrintHeaderFooter(HDC context,
const PrintedPage& page,
PageOverlays::HorizontalPosition x,
PageOverlays::VerticalPosition y,
- const ChromeFont& font) const {
+ const gfx::Font& font) const {
const PrintSettings& settings = immutable_.settings_;
const std::wstring& line = settings.overlays.GetOverlay(x, y);
if (line.empty()) {
diff --git a/chrome/browser/printing/printed_document.h b/chrome/browser/printing/printed_document.h
index fadfbd6..6080e0d 100644
--- a/chrome/browser/printing/printed_document.h
+++ b/chrome/browser/printing/printed_document.h
@@ -13,11 +13,11 @@
#include "chrome/browser/printing/print_settings.h"
#include "googleurl/src/gurl.h"
-class ChromeFont;
class MessageLoop;
namespace gfx {
class Emf;
+class Font;
}
namespace printing {
@@ -171,7 +171,7 @@ class PrintedDocument : public base::RefCountedThreadSafe<PrintedDocument> {
const PrintedPage& page,
PageOverlays::HorizontalPosition x,
PageOverlays::VerticalPosition y,
- const ChromeFont& font) const;
+ const gfx::Font& font) const;
// Calls the render source to render a page. Makes sure to execute the call in
// the right thread context.
diff --git a/chrome/browser/shell_dialogs.h b/chrome/browser/shell_dialogs.h
index 27ea52a..f9a3baa 100644
--- a/chrome/browser/shell_dialogs.h
+++ b/chrome/browser/shell_dialogs.h
@@ -13,7 +13,9 @@
#include "base/ref_counted.h"
#include "base/string16.h"
-class ChromeFont;
+namespace gfx {
+class Font;
+}
// A base class for shell dialogs.
class BaseShellDialog {
@@ -132,7 +134,7 @@ class SelectFontDialog
// Notifies the Listener that a font selection has been made. The font
// details are supplied in |font|. |params| is contextual passed to
// SelectFile.
- virtual void FontSelected(const ChromeFont& font, void* params) = 0;
+ virtual void FontSelected(const gfx::Font& font, void* params) = 0;
// Notifies the Listener that the font selection was aborted (via the user
// canceling or closing the selection dialog box, for example). |params| is
diff --git a/chrome/browser/views/about_chrome_view.cc b/chrome/browser/views/about_chrome_view.cc
index cc4e294..1468a24 100644
--- a/chrome/browser/views/about_chrome_view.cc
+++ b/chrome/browser/views/about_chrome_view.cc
@@ -226,7 +226,7 @@ void AboutChromeView::Init() {
// Create a label and add the full text so we can query it for the height.
views::Label dummy_text(full_text);
dummy_text.SetMultiLine(true);
- ChromeFont font =
+ gfx::Font font =
ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont);
// Add up the height of the various elements on the page.
@@ -360,8 +360,8 @@ void AboutChromeView::Paint(ChromeCanvas* canvas) {
canvas->TileImageInt(*kBackgroundBmp, 0, 0,
dialog_dimensions_.width(), kBackgroundBmp->height());
- ChromeFont font =
- ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont);
+ gfx::Font font =
+ ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont);
const gfx::Rect label_bounds = main_text_label_->bounds();
@@ -430,7 +430,7 @@ void AboutChromeView::DrawTextAndPositionUrl(ChromeCanvas* canvas,
gfx::Rect* rect,
gfx::Size* position,
const gfx::Rect& bounds,
- const ChromeFont& font) {
+ const gfx::Font& font) {
DCHECK(canvas && position);
// What we get passed in as |text| is potentially a mix of LTR and RTL "runs"
@@ -483,7 +483,7 @@ void AboutChromeView::DrawTextStartingFrom(ChromeCanvas* canvas,
const std::wstring& text,
gfx::Size* position,
const gfx::Rect& bounds,
- const ChromeFont& font,
+ const gfx::Font& font,
bool ltr_within_rtl) {
// Iterate through line breaking opportunities (which in English would be
// spaces and such. This tells us where to wrap.
diff --git a/chrome/browser/views/about_chrome_view.h b/chrome/browser/views/about_chrome_view.h
index 7d33641..8b87624 100644
--- a/chrome/browser/views/about_chrome_view.h
+++ b/chrome/browser/views/about_chrome_view.h
@@ -99,7 +99,7 @@ class AboutChromeView : public views::View,
gfx::Rect* rect,
gfx::Size* position,
const gfx::Rect& bounds,
- const ChromeFont& font);
+ const gfx::Font& font);
// A helper function for DrawTextAndPositionUrl, which simply draws the text
// from a certain starting point |position| and wraps within bounds.
@@ -110,7 +110,7 @@ class AboutChromeView : public views::View,
const std::wstring& text,
gfx::Size* position,
const gfx::Rect& bounds,
- const ChromeFont& font,
+ const gfx::Font& font,
bool word_for_word);
// A simply utility function that calculates whether a word of width
diff --git a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc
index ffeee23..43f4d98 100644
--- a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc
+++ b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc
@@ -60,14 +60,14 @@ static const int kRowRightPadding = 3;
// of the text.
static const int kIconTextSpacing = 9;
// The size delta between the font used for the edit and the result rows. Passed
-// to ChromeFont::DeriveFont.
+// to gfx::Font::DeriveFont.
static const int kEditFontAdjust = -1;
class AutocompleteResultView : public views::View {
public:
AutocompleteResultView(AutocompleteResultViewModel* model,
int model_index,
- const ChromeFont& font);
+ const gfx::Font& font);
virtual ~AutocompleteResultView();
// Overridden from views::View:
@@ -108,7 +108,7 @@ class AutocompleteResultView : public views::View {
int y);
// Gets the font and text color for a fragment with the specified style.
- ChromeFont GetFragmentFont(int style) const;
+ gfx::Font GetFragmentFont(int style) const;
SkColor GetFragmentTextColor(int style) const;
// This row's model and model index.
@@ -119,7 +119,7 @@ class AutocompleteResultView : public views::View {
bool hot_;
// The font used to derive fonts for rendering the text in this row.
- ChromeFont font_;
+ gfx::Font font_;
// A context used for mirroring regions.
class MirroringContext;
@@ -272,7 +272,7 @@ int AutocompleteResultView::MirroringContext::GetLeft(int x1, int x2) const {
AutocompleteResultView::AutocompleteResultView(
AutocompleteResultViewModel* model,
int model_index,
- const ChromeFont& font)
+ const gfx::Font& font)
: model_(model),
model_index_(model_index),
hot_(false),
@@ -499,7 +499,7 @@ int AutocompleteResultView::DrawStringFragment(
int style,
int x,
int y) {
- ChromeFont display_font = GetFragmentFont(style);
+ gfx::Font display_font = GetFragmentFont(style);
// Clamp text width to the available width within the popup so we elide if
// necessary.
int string_width = std::min(display_font.GetStringWidth(text),
@@ -511,9 +511,9 @@ int AutocompleteResultView::DrawStringFragment(
return string_width;
}
-ChromeFont AutocompleteResultView::GetFragmentFont(int style) const {
+gfx::Font AutocompleteResultView::GetFragmentFont(int style) const {
if (style & ACMatchClassification::MATCH)
- return font_.DeriveFont(0, ChromeFont::BOLD);
+ return font_.DeriveFont(0, gfx::Font::BOLD);
return font_;
}
@@ -651,7 +651,7 @@ void PopupBorder::InitClass() {
// AutocompletePopupContentsView, public:
AutocompletePopupContentsView::AutocompletePopupContentsView(
- const ChromeFont& font,
+ const gfx::Font& font,
AutocompleteEditViewWin* edit_view,
AutocompleteEditModel* edit_model,
Profile* profile,
diff --git a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h
index 19323eb..85cecbf 100644
--- a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h
+++ b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h
@@ -46,7 +46,7 @@ class AutocompletePopupContentsView : public views::View,
public AutocompleteResultViewModel,
public AutocompletePopupView {
public:
- AutocompletePopupContentsView(const ChromeFont& font,
+ AutocompletePopupContentsView(const gfx::Font& font,
AutocompleteEditViewWin* edit_view,
AutocompleteEditModel* edit_model,
Profile* profile,
@@ -105,7 +105,7 @@ class AutocompletePopupContentsView : public views::View,
// The font that we should use for result rows. This is based on the font used
// by the edit that created us.
- ChromeFont result_font_;
+ gfx::Font result_font_;
DISALLOW_COPY_AND_ASSIGN(AutocompletePopupContentsView);
};
diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc
index 71b4051..1d552dd 100644
--- a/chrome/browser/views/bookmark_bar_view.cc
+++ b/chrome/browser/views/bookmark_bar_view.cc
@@ -149,7 +149,7 @@ static std::wstring CreateToolTipForURLAndTitle(const gfx::Point& screen_loc,
const std::wstring& languages) {
const gfx::Rect monitor_bounds = win_util::GetMonitorBoundsForRect(
gfx::Rect(screen_loc.x(), screen_loc.y(), 1, 1));
- ChromeFont tt_font = views::TooltipManager::GetDefaultFont();
+ gfx::Font tt_font = views::TooltipManager::GetDefaultFont();
std::wstring result;
// First the title.
diff --git a/chrome/browser/views/bookmark_table_view.cc b/chrome/browser/views/bookmark_table_view.cc
index edbedf0..5c2c787 100644
--- a/chrome/browser/views/bookmark_table_view.cc
+++ b/chrome/browser/views/bookmark_table_view.cc
@@ -418,7 +418,7 @@ void BookmarkTableView::PaintAltText() {
return;
HDC dc = GetDC(GetNativeControlHWND());
- ChromeFont font = GetAltTextFont();
+ gfx::Font font = GetAltTextFont();
gfx::Rect bounds = GetAltTextBounds();
ChromeCanvas canvas(bounds.width(), bounds.height(), false);
// Pad by 1 for halo.
@@ -435,12 +435,12 @@ gfx::Rect BookmarkTableView::GetAltTextBounds() {
RECT client_rect_rect;
GetClientRect(GetNativeControlHWND(), &client_rect_rect);
gfx::Rect client_rect(client_rect_rect);
- ChromeFont font = GetAltTextFont();
+ gfx::Font font = GetAltTextFont();
// Pad height by 2 for halo.
return gfx::Rect(kXOffset, content_offset(), client_rect.width() - kXOffset,
std::max(kImageSize, font.height() + 2));
}
-ChromeFont BookmarkTableView::GetAltTextFont() {
+gfx::Font BookmarkTableView::GetAltTextFont() {
return ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont);
}
diff --git a/chrome/browser/views/bookmark_table_view.h b/chrome/browser/views/bookmark_table_view.h
index cde2bd0..ed83bcb 100644
--- a/chrome/browser/views/bookmark_table_view.h
+++ b/chrome/browser/views/bookmark_table_view.h
@@ -13,7 +13,9 @@
class BookmarkModel;
class BookmarkNode;
class BookmarkTableModel;
-class ChromeFont;
+namespace gfx {
+class Font;
+}
class OSExchangeData;
class PrefService;
class Profile;
@@ -144,7 +146,7 @@ class BookmarkTableView : public views::TableView {
gfx::Rect GetAltTextBounds();
// Returns the font used for alt text.
- ChromeFont GetAltTextFont();
+ gfx::Font GetAltTextFont();
Profile* profile_;
diff --git a/chrome/browser/views/constrained_window_impl.cc b/chrome/browser/views/constrained_window_impl.cc
index 9b4ee70..695d450 100644
--- a/chrome/browser/views/constrained_window_impl.cc
+++ b/chrome/browser/views/constrained_window_impl.cc
@@ -237,12 +237,12 @@ class ConstrainedWindowFrameView
static void InitClass();
// The font to be used to render the titlebar text.
- static ChromeFont* title_font_;
+ static gfx::Font* title_font_;
DISALLOW_EVIL_CONSTRUCTORS(ConstrainedWindowFrameView);
};
-ChromeFont* ConstrainedWindowFrameView::title_font_ = NULL;
+gfx::Font* ConstrainedWindowFrameView::title_font_ = NULL;
namespace {
// The frame border is only visible in restored mode and is hardcoded to 4 px on
@@ -568,7 +568,7 @@ void ConstrainedWindowFrameView::InitWindowResources() {
void ConstrainedWindowFrameView::InitClass() {
static bool initialized = false;
if (!initialized) {
- title_font_ = new ChromeFont(win_util::GetWindowTitleFont());
+ title_font_ = new gfx::Font(win_util::GetWindowTitleFont());
initialized = true;
}
diff --git a/chrome/browser/views/download_item_view.h b/chrome/browser/views/download_item_view.h
index 264d98d..f81242f 100644
--- a/chrome/browser/views/download_item_view.h
+++ b/chrome/browser/views/download_item_view.h
@@ -165,7 +165,7 @@ class DownloadItemView : public views::ButtonListener,
bool show_status_text_;
// The font used to print the file name and status.
- ChromeFont font_;
+ gfx::Font font_;
// The current state (normal, hot or pushed) of the body and drop-down.
State body_state_;
diff --git a/chrome/browser/views/first_run_bubble.cc b/chrome/browser/views/first_run_bubble.cc
index 552bb44..0ca491c 100644
--- a/chrome/browser/views/first_run_bubble.cc
+++ b/chrome/browser/views/first_run_bubble.cc
@@ -60,11 +60,11 @@ class FirstRunBubbleView : public views::View,
label3_(NULL),
keep_button_(NULL),
change_button_(NULL) {
- ChromeFont& font =
+ gfx::Font& font =
ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::MediumFont);
label1_ = new views::Label(l10n_util::GetString(IDS_FR_BUBBLE_TITLE));
- label1_->SetFont(font.DeriveFont(3, ChromeFont::BOLD));
+ label1_->SetFont(font.DeriveFont(3, gfx::Font::BOLD));
label1_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
AddChildView(label1_);
diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.cc b/chrome/browser/views/frame/opaque_browser_frame_view.cc
index 3e58d71..89b50f5 100644
--- a/chrome/browser/views/frame/opaque_browser_frame_view.cc
+++ b/chrome/browser/views/frame/opaque_browser_frame_view.cc
@@ -24,7 +24,7 @@
// static
SkBitmap* OpaqueBrowserFrameView::distributor_logo_ = NULL;
-ChromeFont* OpaqueBrowserFrameView::title_font_ = NULL;
+gfx::Font* OpaqueBrowserFrameView::title_font_ = NULL;
namespace {
// The frame border is only visible in restored mode and is hardcoded to 4 px on
@@ -948,7 +948,7 @@ void OpaqueBrowserFrameView::InitClass() {
void OpaqueBrowserFrameView::InitAppWindowResources() {
static bool initialized = false;
if (!initialized) {
- title_font_ = new ChromeFont(win_util::GetWindowTitleFont());
+ title_font_ = new gfx::Font(win_util::GetWindowTitleFont());
initialized = true;
}
}
diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.h b/chrome/browser/views/frame/opaque_browser_frame_view.h
index 08aee7e..6d16a2f 100644
--- a/chrome/browser/views/frame/opaque_browser_frame_view.h
+++ b/chrome/browser/views/frame/opaque_browser_frame_view.h
@@ -11,7 +11,9 @@
#include "views/window/non_client_view.h"
class BrowserView;
-class ChromeFont;
+namespace gfx {
+class Font;
+}
class TabContents;
class TabStrip;
namespace views {
@@ -150,7 +152,7 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView,
static void InitClass();
static void InitAppWindowResources();
static SkBitmap* distributor_logo_;
- static ChromeFont* title_font_;
+ static gfx::Font* title_font_;
DISALLOW_EVIL_CONSTRUCTORS(OpaqueBrowserFrameView);
};
diff --git a/chrome/browser/views/location_bar_view.cc b/chrome/browser/views/location_bar_view.cc
index 2f22fd2..3014dfc 100644
--- a/chrome/browser/views/location_bar_view.cc
+++ b/chrome/browser/views/location_bar_view.cc
@@ -672,7 +672,7 @@ LocationBarView::SelectedKeywordView::SelectedKeywordView(Profile* profile)
LocationBarView::SelectedKeywordView::~SelectedKeywordView() {
}
-void LocationBarView::SelectedKeywordView::SetFont(const ChromeFont& font) {
+void LocationBarView::SelectedKeywordView::SetFont(const gfx::Font& font) {
full_label_.SetFont(font);
partial_label_.SetFont(font);
}
@@ -763,7 +763,7 @@ LocationBarView::KeywordHintView::~KeywordHintView() {
RemoveChildView(&trailing_label_);
}
-void LocationBarView::KeywordHintView::SetFont(const ChromeFont& font) {
+void LocationBarView::KeywordHintView::SetFont(const gfx::Font& font) {
leading_label_.SetFont(font);
trailing_label_.SetFont(font);
}
diff --git a/chrome/browser/views/location_bar_view.h b/chrome/browser/views/location_bar_view.h
index 4c30b4b..c0b2a9e 100644
--- a/chrome/browser/views/location_bar_view.h
+++ b/chrome/browser/views/location_bar_view.h
@@ -147,7 +147,7 @@ class LocationBarView : public LocationBar,
explicit SelectedKeywordView(Profile* profile);
virtual ~SelectedKeywordView();
- void SetFont(const ChromeFont& font);
+ void SetFont(const gfx::Font& font);
virtual void Paint(ChromeCanvas* canvas);
@@ -197,7 +197,7 @@ class LocationBarView : public LocationBar,
explicit KeywordHintView(Profile* profile);
virtual ~KeywordHintView();
- void SetFont(const ChromeFont& font);
+ void SetFont(const gfx::Font& font);
void SetColor(const SkColor& color);
@@ -444,7 +444,7 @@ class LocationBarView : public LocationBar,
PageTransition::Type transition_;
// Font used by edit and some of the hints.
- ChromeFont font_;
+ gfx::Font font_;
// Location_entry view wrapper
views::HWNDView* location_entry_view_;
diff --git a/chrome/browser/views/options/advanced_contents_view.cc b/chrome/browser/views/options/advanced_contents_view.cc
index 3bbf9a6..587bd71 100644
--- a/chrome/browser/views/options/advanced_contents_view.cc
+++ b/chrome/browser/views/options/advanced_contents_view.cc
@@ -144,8 +144,8 @@ AdvancedSection::AdvancedSection(Profile* profile,
title_label_(new views::Label(title)),
OptionsPageView(profile) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- ChromeFont title_font =
- rb.GetFont(ResourceBundle::BaseFont).DeriveFont(0, ChromeFont::BOLD);
+ gfx::Font title_font =
+ rb.GetFont(ResourceBundle::BaseFont).DeriveFont(0, gfx::Font::BOLD);
title_label_->SetFont(title_font);
SkColor title_color = gfx::NativeTheme::instance()->GetThemeColorWithDefault(
diff --git a/chrome/browser/views/options/fonts_page_view.cc b/chrome/browser/views/options/fonts_page_view.cc
index 27d710a..41cb561 100644
--- a/chrome/browser/views/options/fonts_page_view.cc
+++ b/chrome/browser/views/options/fonts_page_view.cc
@@ -107,7 +107,7 @@ class FontDisplayView : public views::View {
void SetFontType(const std::wstring& font_name,
int font_size);
- void SetFontType(ChromeFont font);
+ void SetFontType(gfx::Font font);
std::wstring font_name() { return font_name_; }
int font_size() { return font_size_; }
@@ -138,7 +138,7 @@ FontDisplayView::FontDisplayView()
FontDisplayView::~FontDisplayView() {
}
-void FontDisplayView::SetFontType(ChromeFont font) {
+void FontDisplayView::SetFontType(gfx::Font font) {
if (font.FontName().empty())
return;
@@ -170,7 +170,7 @@ void FontDisplayView::SetFontType(const std::wstring& font_name,
displayed_text += UTF8ToWide(::StringPrintf("%d", font_size_));
HDC hdc = GetDC(NULL);
int font_size_point = MulDiv(font_size, 72, GetDeviceCaps(hdc, LOGPIXELSY));
- ChromeFont font = ChromeFont::CreateFont(font_name, font_size_point);
+ gfx::Font font = gfx::Font::CreateFont(font_name, font_size_point);
font_text_label_->SetFont(font);
font_text_label_->SetText(displayed_text);
}
@@ -190,7 +190,7 @@ void FontDisplayView::Layout() {
gfx::Size FontDisplayView::GetPreferredSize() {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- ChromeFont font = rb.GetFont(ResourceBundle::BaseFont);
+ gfx::Font font = rb.GetFont(ResourceBundle::BaseFont);
return gfx::Size(font.GetExpectedTextWidth(kFontDisplayMaxWidthChars),
font.height() * kFontDisplayMaxHeightChars
+ 2 * kFontDisplayLabelPadding);
@@ -198,8 +198,8 @@ gfx::Size FontDisplayView::GetPreferredSize() {
void EmbellishTitle(views::Label* title_label) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- ChromeFont title_font =
- rb.GetFont(ResourceBundle::BaseFont).DeriveFont(0, ChromeFont::BOLD);
+ gfx::Font title_font =
+ rb.GetFont(ResourceBundle::BaseFont).DeriveFont(0, gfx::Font::BOLD);
title_label->SetFont(title_font);
SkColor title_color =
gfx::NativeTheme::instance()->GetThemeColorWithDefault(
@@ -286,11 +286,11 @@ void FontsPageView::ItemChanged(views::ComboBox* combo_box,
}
}
-void FontsPageView::FontSelected(const ChromeFont& const_font, void* params) {
- ChromeFont font(const_font);
- if (ChromeFont(font).FontName().empty())
+void FontsPageView::FontSelected(const gfx::Font& const_font, void* params) {
+ gfx::Font font(const_font);
+ if (gfx::Font(font).FontName().empty())
return;
- int font_size = ChromeFont(font).FontSize();
+ int font_size = gfx::Font(font).FontSize();
// Currently we do not have separate font sizes for Serif and Sans Serif.
// Therefore, when Serif font size is changed, Sans-Serif font size changes,
// and vice versa.
@@ -443,7 +443,7 @@ void FontsPageView::InitFontLayout() {
const int triple_column_view_set_id = 0;
ColumnSet* column_set = layout->AddColumnSet(triple_column_view_set_id);
- int label_width = ChromeFont().GetExpectedTextWidth(
+ int label_width = gfx::Font().GetExpectedTextWidth(
_wtoi(l10n_util::GetString(IDS_FONTSLANG_LABEL_WIDTH).c_str()));
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0,
GridLayout::FIXED, label_width, 0);
diff --git a/chrome/browser/views/options/fonts_page_view.h b/chrome/browser/views/options/fonts_page_view.h
index 0b54c18..1a83919 100644
--- a/chrome/browser/views/options/fonts_page_view.h
+++ b/chrome/browser/views/options/fonts_page_view.h
@@ -44,7 +44,7 @@ class FontsPageView : public OptionsPageView,
int new_index);
// SelectFontDialog::Listener implementation:
- virtual void FontSelected(const ChromeFont& font, void* params);
+ virtual void FontSelected(const gfx::Font& font, void* params);
// Save Changes made to relevent pref members associated with this tab.
// This is public since it is called by FontsLanguageWindowView in its
diff --git a/chrome/browser/views/options/languages_page_view.cc b/chrome/browser/views/options/languages_page_view.cc
index ef26566..c65474e 100644
--- a/chrome/browser/views/options/languages_page_view.cc
+++ b/chrome/browser/views/options/languages_page_view.cc
@@ -271,7 +271,7 @@ void AddLanguageWindowView::Layout() {
gfx::Size AddLanguageWindowView::GetPreferredSize() {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- ChromeFont font = rb.GetFont(ResourceBundle::BaseFont);
+ gfx::Font font = rb.GetFont(ResourceBundle::BaseFont);
return gfx::Size(font.ave_char_width() * kDefaultWindowWidthChars,
font.height() * kDefaultWindowHeightLines);
}
diff --git a/chrome/browser/views/options/options_group_view.cc b/chrome/browser/views/options/options_group_view.cc
index 91a617f..a8697ba 100644
--- a/chrome/browser/views/options/options_group_view.cc
+++ b/chrome/browser/views/options/options_group_view.cc
@@ -36,8 +36,8 @@ OptionsGroupView::OptionsGroupView(views::View* contents,
show_separator_(show_separator),
highlighted_(false) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- ChromeFont title_font =
- rb.GetFont(ResourceBundle::BaseFont).DeriveFont(0, ChromeFont::BOLD);
+ gfx::Font title_font =
+ rb.GetFont(ResourceBundle::BaseFont).DeriveFont(0, gfx::Font::BOLD);
title_label_->SetFont(title_font);
SkColor title_color = gfx::NativeTheme::instance()->GetThemeColorWithDefault(
gfx::NativeTheme::BUTTON, BP_GROUPBOX, GBS_NORMAL, TMT_TEXTCOLOR,
@@ -92,7 +92,7 @@ void OptionsGroupView::Init() {
SetLayoutManager(layout);
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- ChromeFont font = rb.GetFont(ResourceBundle::BaseFont);
+ gfx::Font font = rb.GetFont(ResourceBundle::BaseFont);
std::wstring left_column_chars =
l10n_util::GetString(IDS_OPTIONS_DIALOG_LEFT_COLUMN_WIDTH_CHARS);
int left_column_width =
diff --git a/chrome/browser/views/page_info_window.cc b/chrome/browser/views/page_info_window.cc
index 1e72a6e..c92325b 100644
--- a/chrome/browser/views/page_info_window.cc
+++ b/chrome/browser/views/page_info_window.cc
@@ -158,7 +158,7 @@ SecurityTabView::Section::Section(const std::wstring& title, bool state,
head_line_label_ = new views::Label(head_line);
head_line_label_->SetFont(
- head_line_label_->GetFont().DeriveFont(0, ChromeFont::BOLD));
+ head_line_label_->GetFont().DeriveFont(0, gfx::Font::BOLD));
head_line_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
AddChildView(head_line_label_);
diff --git a/chrome/browser/views/sad_tab_view.cc b/chrome/browser/views/sad_tab_view.cc
index 71313cc..61a9e57 100644
--- a/chrome/browser/views/sad_tab_view.cc
+++ b/chrome/browser/views/sad_tab_view.cc
@@ -25,8 +25,8 @@ static const SkColor kBackgroundEndColor = SkColorSetRGB(35, 48, 64);
// static
SkBitmap* SadTabView::sad_tab_bitmap_ = NULL;
-ChromeFont* SadTabView::title_font_ = NULL;
-ChromeFont* SadTabView::message_font_ = NULL;
+gfx::Font* SadTabView::title_font_ = NULL;
+gfx::Font* SadTabView::message_font_ = NULL;
std::wstring SadTabView::title_;
std::wstring SadTabView::message_;
int SadTabView::title_width_;
@@ -85,9 +85,9 @@ void SadTabView::InitClass() {
static bool initialized = false;
if (!initialized) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- title_font_ = new ChromeFont(
- rb.GetFont(ResourceBundle::BaseFont).DeriveFont(2, ChromeFont::BOLD));
- message_font_ = new ChromeFont(
+ title_font_ = new gfx::Font(
+ rb.GetFont(ResourceBundle::BaseFont).DeriveFont(2, gfx::Font::BOLD));
+ message_font_ = new gfx::Font(
rb.GetFont(ResourceBundle::BaseFont).DeriveFont(1));
sad_tab_bitmap_ = rb.GetBitmapNamed(IDR_SAD_TAB);
diff --git a/chrome/browser/views/sad_tab_view.h b/chrome/browser/views/sad_tab_view.h
index 2053fba..1a279b6 100644
--- a/chrome/browser/views/sad_tab_view.h
+++ b/chrome/browser/views/sad_tab_view.h
@@ -40,8 +40,8 @@ class SadTabView : public views::View {
// Assorted resources for display.
static SkBitmap* sad_tab_bitmap_;
- static ChromeFont* title_font_;
- static ChromeFont* message_font_;
+ static gfx::Font* title_font_;
+ static gfx::Font* message_font_;
static std::wstring title_;
static std::wstring message_;
static int title_width_;
diff --git a/chrome/browser/views/shelf_item_dialog.cc b/chrome/browser/views/shelf_item_dialog.cc
index b609ad4..80c5776 100644
--- a/chrome/browser/views/shelf_item_dialog.cc
+++ b/chrome/browser/views/shelf_item_dialog.cc
@@ -330,7 +330,7 @@ ShelfItemDialog::ShelfItemDialog(ShelfItemDialogDelegate* delegate,
description_label->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
description_label->SetText(l10n_util::GetString(IDS_ASI_DESCRIPTION));
description_label->SetFont(
- description_label->GetFont().DeriveFont(0, ChromeFont::BOLD));
+ description_label->GetFont().DeriveFont(0, gfx::Font::BOLD));
layout->AddView(description_label);
layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
diff --git a/chrome/browser/views/shell_dialogs_win.cc b/chrome/browser/views/shell_dialogs_win.cc
index c211660..bd5d51f 100644
--- a/chrome/browser/views/shell_dialogs_win.cc
+++ b/chrome/browser/views/shell_dialogs_win.cc
@@ -712,7 +712,7 @@ void SelectFontDialogImpl::FontSelected(LOGFONT logfont,
if (listener_) {
HFONT font = CreateFontIndirect(&logfont);
if (font) {
- listener_->FontSelected(ChromeFont::CreateFont(font), params);
+ listener_->FontSelected(gfx::Font::CreateFont(font), params);
DeleteObject(font);
} else {
listener_->FontSelectionCanceled(params);
diff --git a/chrome/browser/views/status_bubble_views.cc b/chrome/browser/views/status_bubble_views.cc
index 3e4d7c4..a0c687e 100644
--- a/chrome/browser/views/status_bubble_views.cc
+++ b/chrome/browser/views/status_bubble_views.cc
@@ -79,7 +79,7 @@ class StatusBubbleViews::StatusView : public views::Label,
opacity_start_(0),
opacity_end_(0) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- ChromeFont font(rb.GetFont(ResourceBundle::BaseFont));
+ gfx::Font font(rb.GetFont(ResourceBundle::BaseFont));
SetFont(font);
}
diff --git a/chrome/browser/views/tabs/tab.cc b/chrome/browser/views/tabs/tab.cc
index cb7504c..bf606d5 100644
--- a/chrome/browser/views/tabs/tab.cc
+++ b/chrome/browser/views/tabs/tab.cc
@@ -199,7 +199,7 @@ bool Tab::GetTooltipText(int x, int y, std::wstring* tooltip) {
std::wstring title = GetTitle();
if (!title.empty()) {
// Only show the tooltip if the title is truncated.
- ChromeFont font;
+ gfx::Font font;
if (font.GetStringWidth(title) > title_bounds().width()) {
*tooltip = title;
return true;
@@ -209,7 +209,7 @@ bool Tab::GetTooltipText(int x, int y, std::wstring* tooltip) {
}
bool Tab::GetTooltipTextOrigin(int x, int y, gfx::Point* origin) {
- ChromeFont font;
+ gfx::Font font;
origin->set_x(title_bounds().x() + 10);
origin->set_y(-views::TooltipManager::GetTooltipHeight() - 4);
return true;
diff --git a/chrome/browser/views/tabs/tab_renderer.cc b/chrome/browser/views/tabs/tab_renderer.cc
index 96bdd918..6954055 100644
--- a/chrome/browser/views/tabs/tab_renderer.cc
+++ b/chrome/browser/views/tabs/tab_renderer.cc
@@ -46,7 +46,7 @@ static const int kPulseDurationMs = 200;
static const double kHoverOpacity = 0.33;
// TODO(beng): (Cleanup) This stuff should move onto the class.
-static ChromeFont* title_font = NULL;
+static gfx::Font* title_font = NULL;
static int title_font_height = 0;
static SkBitmap* close_button_n = NULL;
static SkBitmap* close_button_h = NULL;
@@ -75,7 +75,7 @@ void InitResources() {
if (!initialized) {
// TODO(glen): Allow theming of these.
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- title_font = new ChromeFont(rb.GetFont(ResourceBundle::BaseFont));
+ title_font = new gfx::Font(rb.GetFont(ResourceBundle::BaseFont));
title_font_height = title_font->height();
close_button_n = rb.GetBitmapNamed(IDR_TAB_CLOSE);
diff --git a/views/controls/button/native_button.h b/views/controls/button/native_button.h
index 52946d7..8b3fbcf 100644
--- a/views/controls/button/native_button.h
+++ b/views/controls/button/native_button.h
@@ -9,7 +9,9 @@
#include "views/controls/button/button.h"
#include "views/controls/button/native_button_wrapper.h"
-class ChromeFont;
+namespace gfx {
+class Font;
+}
namespace views {
@@ -27,8 +29,8 @@ class NativeButton : public Button {
std::wstring label() const { return label_; }
// Sets the font to be used when displaying the button's label.
- void set_font(const ChromeFont& font) { font_ = font; }
- const ChromeFont& font() const { return font_; }
+ void set_font(const gfx::Font& font) { font_ = font; }
+ const gfx::Font& font() const { return font_; }
// Sets/Gets whether or not the button appears and behaves as the default
// button in its current context.
@@ -80,7 +82,7 @@ class NativeButton : public Button {
bool is_default_;
// The font used to render the button label.
- ChromeFont font_;
+ gfx::Font font_;
// True if the button should ignore the minimum size for the platform. Default
// is false. Set to true to create narrower buttons.
diff --git a/views/controls/button/native_button_wrapper.h b/views/controls/button/native_button_wrapper.h
index a4cbbc8..4ae939c 100644
--- a/views/controls/button/native_button_wrapper.h
+++ b/views/controls/button/native_button_wrapper.h
@@ -5,8 +5,6 @@
#ifndef VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON_WRAPPER_H_
#define VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON_WRAPPER_H_
-class ChromeFont;
-
namespace views {
class Checkbox;
diff --git a/views/controls/button/text_button.h b/views/controls/button/text_button.h
index aeb2b72..e0e547c 100644
--- a/views/controls/button/text_button.h
+++ b/views/controls/button/text_button.h
@@ -118,7 +118,7 @@ class TextButton : public CustomButton {
TextAlignment alignment_;
// The font used to paint the text.
- ChromeFont font_;
+ gfx::Font font_;
// Text color.
SkColor color_;
diff --git a/views/controls/combo_box.cc b/views/controls/combo_box.cc
index eb079f7..1469c32 100644
--- a/views/controls/combo_box.cc
+++ b/views/controls/combo_box.cc
@@ -115,7 +115,7 @@ LRESULT ComboBox::OnNotify(int w_param, LPNMHDR l_param) {
void ComboBox::UpdateComboBoxFromModel(HWND hwnd) {
::SendMessage(hwnd, CB_RESETCONTENT, 0, 0);
- ChromeFont font = ResourceBundle::GetSharedInstance().GetFont(
+ gfx::Font font = ResourceBundle::GetSharedInstance().GetFont(
ResourceBundle::BaseFont);
int max_width = 0;
int num_items = model_->GetItemCount(this);
diff --git a/views/controls/label.cc b/views/controls/label.cc
index fde9a9e..aed16b9 100644
--- a/views/controls/label.cc
+++ b/views/controls/label.cc
@@ -32,11 +32,11 @@ Label::Label(const std::wstring& text) {
Init(text, GetDefaultFont());
}
-Label::Label(const std::wstring& text, const ChromeFont& font) {
+Label::Label(const std::wstring& text, const gfx::Font& font) {
Init(text, font);
}
-void Label::Init(const std::wstring& text, const ChromeFont& font) {
+void Label::Init(const std::wstring& text, const gfx::Font& font) {
contains_mouse_ = false;
font_ = font;
text_size_valid_ = false;
@@ -184,13 +184,13 @@ void Label::PaintBackground(ChromeCanvas* canvas) {
bg->Paint(canvas, this);
}
-void Label::SetFont(const ChromeFont& font) {
+void Label::SetFont(const gfx::Font& font) {
font_ = font;
text_size_valid_ = false;
SchedulePaint();
}
-ChromeFont Label::GetFont() const {
+gfx::Font Label::GetFont() const {
return font_;
}
@@ -363,7 +363,7 @@ gfx::Insets Label::GetInsets() const {
}
// static
-ChromeFont Label::GetDefaultFont() {
+gfx::Font Label::GetDefaultFont() {
return ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont);
}
diff --git a/views/controls/label.h b/views/controls/label.h
index d5f246e..e9ace3f 100644
--- a/views/controls/label.h
+++ b/views/controls/label.h
@@ -51,7 +51,7 @@ class Label : public View {
// Create a new label with a default font
explicit Label(const std::wstring& text);
- Label(const std::wstring& text, const ChromeFont& font);
+ Label(const std::wstring& text, const gfx::Font& font);
virtual ~Label();
@@ -74,10 +74,10 @@ class Label : public View {
virtual void PaintBackground(ChromeCanvas* canvas);
// Set the font.
- void SetFont(const ChromeFont& font);
+ void SetFont(const gfx::Font& font);
// Return the font used by this label
- ChromeFont GetFont() const;
+ gfx::Font GetFont() const;
// Set the label text.
void SetText(const std::wstring& text);
@@ -192,7 +192,7 @@ class Label : public View {
FRIEND_TEST(LabelTest, DrawSingleLineString);
FRIEND_TEST(LabelTest, DrawMultiLineString);
- static ChromeFont GetDefaultFont();
+ static gfx::Font GetDefaultFont();
// Returns parameters to be used for the DrawString call.
void CalculateDrawStringParams(std::wstring* paint_text,
@@ -213,10 +213,10 @@ class Label : public View {
int ComputeMultiLineFlags();
gfx::Size GetTextSize();
- void Init(const std::wstring& text, const ChromeFont& font);
+ void Init(const std::wstring& text, const gfx::Font& font);
std::wstring text_;
GURL url_;
- ChromeFont font_;
+ gfx::Font font_;
SkColor color_;
gfx::Size text_size_;
bool text_size_valid_;
diff --git a/views/controls/label_unittest.cc b/views/controls/label_unittest.cc
index 1ac74b1..54ee5ca 100644
--- a/views/controls/label_unittest.cc
+++ b/views/controls/label_unittest.cc
@@ -17,9 +17,9 @@ const int kMinTextDimension = 4;
TEST(LabelTest, FontProperty) {
Label label;
std::wstring font_name(L"courier");
- ChromeFont font = ChromeFont::CreateFont(font_name, 30);
+ gfx::Font font = gfx::Font::CreateFont(font_name, 30);
label.SetFont(font);
- ChromeFont font_used = label.GetFont();
+ gfx::Font font_used = label.GetFont();
EXPECT_STREQ(font_name.c_str(), font_used.FontName().c_str());
EXPECT_EQ(30, font_used.FontSize());
}
diff --git a/views/controls/link.cc b/views/controls/link.cc
index aae254503..d89ce4d 100644
--- a/views/controls/link.cc
+++ b/views/controls/link.cc
@@ -131,17 +131,17 @@ void Link::SetHighlighted(bool f) {
}
void Link::ValidateStyle() {
- ChromeFont font = GetFont();
+ gfx::Font font = GetFont();
if (enabled_) {
- if ((font.style() & ChromeFont::UNDERLINED) == 0) {
+ if ((font.style() & gfx::Font::UNDERLINED) == 0) {
Label::SetFont(font.DeriveFont(0, font.style() |
- ChromeFont::UNDERLINED));
+ gfx::Font::UNDERLINED));
}
} else {
- if ((font.style() & ChromeFont::UNDERLINED) != 0) {
+ if ((font.style() & gfx::Font::UNDERLINED) != 0) {
Label::SetFont(font.DeriveFont(0, font.style() &
- ~ChromeFont::UNDERLINED));
+ ~gfx::Font::UNDERLINED));
}
}
@@ -156,7 +156,7 @@ void Link::ValidateStyle() {
}
}
-void Link::SetFont(const ChromeFont& font) {
+void Link::SetFont(const gfx::Font& font) {
Label::SetFont(font);
ValidateStyle();
}
diff --git a/views/controls/link.h b/views/controls/link.h
index 6da6aa3..4464f28 100644
--- a/views/controls/link.h
+++ b/views/controls/link.h
@@ -49,7 +49,7 @@ class Link : public Label {
virtual bool OnKeyPressed(const KeyEvent& e);
virtual bool OverrideAccelerator(const Accelerator& accelerator);
- virtual void SetFont(const ChromeFont& font);
+ virtual void SetFont(const gfx::Font& font);
// Set whether the link is enabled.
virtual void SetEnabled(bool f);
diff --git a/views/controls/menu/chrome_menu.cc b/views/controls/menu/chrome_menu.cc
index a1a6809..f0cf28b 100644
--- a/views/controls/menu/chrome_menu.cc
+++ b/views/controls/menu/chrome_menu.cc
@@ -126,14 +126,14 @@ namespace views {
namespace {
// Returns the font menus are to use.
-ChromeFont GetMenuFont() {
+gfx::Font GetMenuFont() {
NONCLIENTMETRICS metrics;
win_util::GetNonClientMetrics(&metrics);
l10n_util::AdjustUIFont(&(metrics.lfMenuFont));
HFONT font = CreateFontIndirect(&metrics.lfMenuFont);
DLOG_ASSERT(font);
- return ChromeFont::CreateFont(font);
+ return gfx::Font::CreateFont(font);
}
// Calculates all sizes that we can from the OS.
@@ -1215,7 +1215,7 @@ void MenuItemView::Paint(ChromeCanvas* canvas) {
}
gfx::Size MenuItemView::GetPreferredSize() {
- ChromeFont& font = GetRootMenuItem()->font_;
+ gfx::Font& font = GetRootMenuItem()->font_;
return gfx::Size(
font.GetStringWidth(title_) + label_start + item_right_margin,
font.height() + GetBottomMargin() + GetTopMargin());
@@ -1487,7 +1487,7 @@ void MenuItemView::Paint(ChromeCanvas* canvas, bool for_drag) {
NativeTheme::MENU, MENU_POPUPITEM, state, TMT_TEXTCOLOR,
default_sys_color);
int width = this->width() - item_right_margin - label_start;
- ChromeFont& font = GetRootMenuItem()->font_;
+ gfx::Font& font = GetRootMenuItem()->font_;
gfx::Rect text_bounds(label_start, top_margin, width, font.height());
text_bounds.set_x(MirroredLeftPointForRect(text_bounds));
if (for_drag) {
diff --git a/views/controls/menu/chrome_menu.h b/views/controls/menu/chrome_menu.h
index 6bb25c7..6622cbd 100644
--- a/views/controls/menu/chrome_menu.h
+++ b/views/controls/menu/chrome_menu.h
@@ -319,7 +319,7 @@ class MenuItemView : public View {
MenuItemView* GetParentMenuItem() const { return parent_menu_item_; }
// Sets the font.
- void SetFont(const ChromeFont& font) { font_ = font; }
+ void SetFont(const gfx::Font& font) { font_ = font; }
// Sets the title
void SetTitle(const std::wstring& title) {
@@ -460,7 +460,7 @@ class MenuItemView : public View {
SubmenuView* submenu_;
// Font.
- ChromeFont font_;
+ gfx::Font font_;
// Title.
std::wstring title_;
diff --git a/views/controls/menu/menu_win.cc b/views/controls/menu/menu_win.cc
index 9c85b54..b10d8dc 100644
--- a/views/controls/menu/menu_win.cc
+++ b/views/controls/menu/menu_win.cc
@@ -107,7 +107,7 @@ class MenuHostWindow : public CWindowImpl<MenuHostWindow, CWindow,
MenuWin::ItemData* data =
reinterpret_cast<MenuWin::ItemData*>(lpmis->itemData);
if (data != NULL) {
- ChromeFont font;
+ gfx::Font font;
lpmis->itemWidth = font.GetStringWidth(data->label) + kIconWidth +
kItemLeftMargin + kItemRightMargin -
GetSystemMetrics(SM_CXMENUCHECK);
@@ -161,7 +161,7 @@ class MenuHostWindow : public CWindowImpl<MenuHostWindow, CWindow,
SystemParametersInfo(SPI_GETKEYBOARDCUES, 0, &underline_mnemonics, 0);
if (!underline_mnemonics)
format |= DT_HIDEPREFIX;
- ChromeFont font;
+ gfx::Font font;
HGDIOBJ old_font = static_cast<HFONT>(SelectObject(hDC, font.hfont()));
int fontsize = font.FontSize();
diff --git a/views/controls/text_field.cc b/views/controls/text_field.cc
index 62762f4..76732a1 100644
--- a/views/controls/text_field.cc
+++ b/views/controls/text_field.cc
@@ -1117,13 +1117,13 @@ void TextField::SetDefaultBackgroundColor() {
UpdateEditBackgroundColor();
}
-void TextField::SetFont(const ChromeFont& font) {
+void TextField::SetFont(const gfx::Font& font) {
font_ = font;
if (edit_)
edit_->SetFont(font.hfont());
}
-ChromeFont TextField::GetFont() const {
+gfx::Font TextField::GetFont() const {
return font_;
}
diff --git a/views/controls/text_field.h b/views/controls/text_field.h
index 6dda5db..c49c7d7 100644
--- a/views/controls/text_field.h
+++ b/views/controls/text_field.h
@@ -121,10 +121,10 @@ class TextField : public View {
void SetDefaultBackgroundColor();
// Set the font.
- void SetFont(const ChromeFont& font);
+ void SetFont(const gfx::Font& font);
// Return the font used by this TextField.
- ChromeFont GetFont() const;
+ gfx::Font GetFont() const;
// Sets the left and right margin (in pixels) within the text box. On Windows
// this is accomplished by packing the left and right margin into a single
@@ -173,7 +173,7 @@ class TextField : public View {
StyleFlags style_;
- ChromeFont font_;
+ gfx::Font font_;
// NOTE: this is temporary until we rewrite TextField to always work whether
// there is an HWND or not.
diff --git a/views/drag_utils.cc b/views/drag_utils.cc
index f312b14..85498b7 100644
--- a/views/drag_utils.cc
+++ b/views/drag_utils.cc
@@ -118,7 +118,7 @@ void CreateDragImageForFile(const std::wstring& file_name,
// Set up our text portion
const std::wstring& name = file_util::GetFilenameFromPath(file_name);
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- ChromeFont font = rb.GetFont(ResourceBundle::BaseFont);
+ gfx::Font font = rb.GetFont(ResourceBundle::BaseFont);
const int width = kFileDragImageMaxWidth;
// Add +2 here to allow room for the halo.
diff --git a/views/widget/tooltip_manager.cc b/views/widget/tooltip_manager.cc
index c082040..9ef9ff9 100644
--- a/views/widget/tooltip_manager.cc
+++ b/views/widget/tooltip_manager.cc
@@ -52,21 +52,21 @@ int TooltipManager::GetTooltipHeight() {
return tooltip_height_;
}
-static ChromeFont DetermineDefaultFont() {
+static gfx::Font DetermineDefaultFont() {
HWND window = CreateWindowEx(
WS_EX_TRANSPARENT | l10n_util::GetExtendedTooltipStyles(),
TOOLTIPS_CLASS, NULL, 0 , 0, 0, 0, 0, NULL, NULL, NULL, NULL);
HFONT hfont = reinterpret_cast<HFONT>(SendMessage(window, WM_GETFONT, 0, 0));
- ChromeFont font = hfont ? ChromeFont::CreateFont(hfont) : ChromeFont();
+ gfx::Font font = hfont ? gfx::Font::CreateFont(hfont) : gfx::Font();
DestroyWindow(window);
return font;
}
// static
-ChromeFont TooltipManager::GetDefaultFont() {
- static ChromeFont* font = NULL;
+gfx::Font TooltipManager::GetDefaultFont() {
+ static gfx::Font* font = NULL;
if (!font)
- font = new ChromeFont(DetermineDefaultFont());
+ font = new gfx::Font(DetermineDefaultFont());
return *font;
}
@@ -264,9 +264,9 @@ int TooltipManager::CalcTooltipHeight() {
SetMapMode(dc, last_map_mode);
ReleaseDC(NULL, dc);
} else {
- // Tooltip is using the system font. Use ChromeFont, which should pick
+ // Tooltip is using the system font. Use gfx::Font, which should pick
// up the system font.
- height = ChromeFont().height();
+ height = gfx::Font().height();
}
// Get the margins from the tooltip
RECT tooltip_margin;
@@ -309,7 +309,7 @@ void TooltipManager::TrimTooltipToFit(std::wstring* text,
*line_count = static_cast<int>(lines.size());
// Format each line to fit.
- ChromeFont font = GetDefaultFont();
+ gfx::Font font = GetDefaultFont();
std::wstring result;
for (std::vector<std::wstring>::iterator i = lines.begin(); i != lines.end();
++i) {
diff --git a/views/widget/tooltip_manager.h b/views/widget/tooltip_manager.h
index 3d5620d..5cfe2bf 100644
--- a/views/widget/tooltip_manager.h
+++ b/views/widget/tooltip_manager.h
@@ -12,7 +12,9 @@
#include "base/basictypes.h"
#include "base/task.h"
-class ChromeFont;
+namespace gfx {
+class Font;
+}
namespace views {
@@ -55,7 +57,7 @@ class TooltipManager {
static int GetTooltipHeight();
// Returns the default font used by tooltips.
- static ChromeFont GetDefaultFont();
+ static gfx::Font GetDefaultFont();
// Returns the separator for lines of text in a tooltip.
static const std::wstring& GetLineSeparator();
diff --git a/views/window/custom_frame_view.cc b/views/window/custom_frame_view.cc
index 19ce2fb..f7f9ab3 100644
--- a/views/window/custom_frame_view.cc
+++ b/views/window/custom_frame_view.cc
@@ -23,7 +23,7 @@
namespace views {
// static
-ChromeFont* CustomFrameView::title_font_ = NULL;
+gfx::Font* CustomFrameView::title_font_ = NULL;
namespace {
// The frame border is only visible in restored mode and is hardcoded to 4 px on
@@ -585,10 +585,10 @@ void CustomFrameView::InitClass() {
static bool initialized = false;
if (!initialized) {
#if defined(OS_WIN)
- title_font_ = new ChromeFont(win_util::GetWindowTitleFont());
+ title_font_ = new gfx::Font(win_util::GetWindowTitleFont());
#elif defined(OS_LINUX)
// TODO: need to resolve what font this is.
- title_font_ = new ChromeFont();
+ title_font_ = new gfx::Font();
#endif
initialized = true;
}
diff --git a/views/window/custom_frame_view.h b/views/window/custom_frame_view.h
index ac0b114..0c41009 100644
--- a/views/window/custom_frame_view.h
+++ b/views/window/custom_frame_view.h
@@ -11,12 +11,12 @@
#include "views/window/window_resources.h"
namespace gfx{
+class Font;
class Size;
class Path;
class Point;
}
class ChromeCanvas;
-class ChromeFont;
namespace views {
@@ -104,7 +104,7 @@ class CustomFrameView : public NonClientFrameView,
// Initialize various static resources.
static void InitClass();
- static ChromeFont* title_font_;
+ static gfx::Font* title_font_;
DISALLOW_EVIL_CONSTRUCTORS(CustomFrameView);
};
diff --git a/views/window/dialog_client_view.cc b/views/window/dialog_client_view.cc
index 28c721c..9e25462 100644
--- a/views/window/dialog_client_view.cc
+++ b/views/window/dialog_client_view.cc
@@ -77,7 +77,7 @@ class DialogButton : public NativeButton {
} // namespace
// static
-ChromeFont* DialogClientView::dialog_button_font_ = NULL;
+gfx::Font* DialogClientView::dialog_button_font_ = NULL;
static const int kDialogMinButtonWidth = 75;
static const int kDialogButtonLabelSpacing = 16;
static const int kDialogButtonContentSpacing = 5;
@@ -454,7 +454,7 @@ void DialogClientView::InitClass() {
static bool initialized = false;
if (!initialized) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- dialog_button_font_ = new ChromeFont(rb.GetFont(ResourceBundle::BaseFont));
+ dialog_button_font_ = new gfx::Font(rb.GetFont(ResourceBundle::BaseFont));
initialized = true;
}
}
diff --git a/views/window/dialog_client_view.h b/views/window/dialog_client_view.h
index 347b61c..c1e6ed8 100644
--- a/views/window/dialog_client_view.h
+++ b/views/window/dialog_client_view.h
@@ -113,7 +113,7 @@ class DialogClientView : public ClientView,
// Static resource initialization
static void InitClass();
- static ChromeFont* dialog_button_font_;
+ static gfx::Font* dialog_button_font_;
DISALLOW_COPY_AND_ASSIGN(DialogClientView);
};
diff --git a/views/window/window_win.cc b/views/window/window_win.cc
index c5c92c7..9c06e21 100644
--- a/views/window/window_win.cc
+++ b/views/window/window_win.cc
@@ -186,7 +186,7 @@ void WindowWin::PopForceHidden() {
int Window::GetLocalizedContentsWidth(int col_resource_id) {
double chars = _wtof(l10n_util::GetString(col_resource_id).c_str());
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- ChromeFont font = rb.GetFont(ResourceBundle::BaseFont);
+ gfx::Font font = rb.GetFont(ResourceBundle::BaseFont);
int width = font.GetExpectedTextWidth(static_cast<int>(chars));
DCHECK(width > 0);
return width;
@@ -196,7 +196,7 @@ int Window::GetLocalizedContentsWidth(int col_resource_id) {
int Window::GetLocalizedContentsHeight(int row_resource_id) {
double lines = _wtof(l10n_util::GetString(row_resource_id).c_str());
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- ChromeFont font = rb.GetFont(ResourceBundle::BaseFont);
+ gfx::Font font = rb.GetFont(ResourceBundle::BaseFont);
int height = static_cast<int>(font.height() * lines);
DCHECK(height > 0);
return height;