Index: chrome/browser/ui/views/location_bar/location_bar_view.cc |
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc |
index 352f878c47eef91827d43f9ea6587e199e6c43d6..5acc25225d10fdcbd768e0e6e85829962b4b8e01 100644 |
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc |
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc |
@@ -114,11 +114,11 @@ Browser* GetBrowserFromDelegate(LocationBarView::Delegate* delegate) { |
return contents ? chrome::FindBrowserWithWebContents(contents) : NULL; |
} |
-// Given a containing |height| and a base |font|, shrinks the font until it will |
-// fit within |height| while having its cap height vertically centered. Returns |
-// the |font_y_offset| needed to produce this centering. |
+// Given a containing |height| and a base |font_list|, shrinks the fonts until |
+// it will fit within |height| while having its cap height vertically centered. |
+// Returns the |font_y_offset| needed to produce this centering. |
void CalculateFontAndOffsetForHeight(int height, |
- gfx::Font* font, |
+ gfx::FontList* font_list, |
int* font_y_offset) { |
#if defined(OS_WIN) |
base::win::ScopedGetDC screen_dc(NULL); |
@@ -128,21 +128,23 @@ void CalculateFontAndOffsetForHeight(int height, |
// TODO(pkasting): Expand the gfx::Font metrics (and underlying Skia |
// metrics) enough to expose the cap height directly. |
#if defined(OS_WIN) |
- base::win::ScopedSelectObject font_in_dc(screen_dc, font->GetNativeFont()); |
+ const gfx::Font& font = font_list->GetPrimaryFont(); |
+ base::win::ScopedSelectObject font_in_dc(screen_dc, font.GetNativeFont()); |
TEXTMETRIC tm = {0}; |
GetTextMetrics(screen_dc, &tm); |
- int cap_height = font->GetBaseline() - tm.tmInternalLeading; |
+ int cap_height = font.GetBaseline() - tm.tmInternalLeading; |
*font_y_offset = ((height - cap_height) / 2) - tm.tmInternalLeading; |
#else |
// Without cap height available, we fall back to centering the full height. |
- *font_y_offset = (height - font->GetHeight()) / 2; |
+ *font_y_offset = (height - font_list->GetHeight()) / 2; |
#endif |
if (((*font_y_offset >= 0) && |
- ((*font_y_offset + font->GetHeight()) <= height)) || |
- (font->GetFontSize() <= 1)) |
+ ((*font_y_offset + font_list->GetHeight()) <= height)) || |
+ (font_list->GetPrimaryFont().GetFontSize() <= 1)) |
return; |
- *font = font->DeriveFont(-1); |
+ *font_list = font_list->DeriveFontListWithSize( |
+ font_list->GetPrimaryFont().GetFontSize() - 1); |
msw
2013/07/23 19:51:54
Alexei, is it possible that this loop's terminal c
|
} |
} |
@@ -234,46 +236,52 @@ void LocationBarView::Init() { |
AddChildView(location_icon_view_); |
// Determine the main font. |
- gfx::Font font(ui::ResourceBundle::GetSharedInstance().GetFont( |
+#if defined(OS_CHROMEOS) |
msw
2013/07/23 19:51:54
All platforms should invoke the same codepath if p
Yuki
2013/07/24 09:17:05
Thanks. I specify BaseFont as the same as before.
|
+ // Uses the default fonts which is IDS_UI_FONT_FAMILY_CROS. |
+ gfx::FontList font_list; |
+#else |
+ gfx::FontList font_list(ui::ResourceBundle::GetSharedInstance().GetFont( |
ui::ResourceBundle::BaseFont)); |
- const int current_font_size = font.GetFontSize(); |
+#endif |
+ const int current_font_size = font_list.GetPrimaryFont().GetFontSize(); |
const int desired_font_size = browser_defaults::kOmniboxFontPixelSize; |
if (current_font_size < desired_font_size) |
- font = font.DeriveFont(desired_font_size - current_font_size); |
+ font_list = font_list.DeriveFontListWithSize(desired_font_size); |
// Shrink large fonts to make them fit. |
// TODO(pkasting): Stretch the location bar instead in this case. |
int location_height = GetInternalHeight(true); |
int font_y_offset; |
- CalculateFontAndOffsetForHeight(location_height, &font, &font_y_offset); |
+ CalculateFontAndOffsetForHeight(location_height, &font_list, &font_y_offset); |
// Determine the font for use inside the bubbles. |
- gfx::Font bubble_font(font); |
+ gfx::FontList bubble_font_list(font_list); |
int bubble_font_y_offset; |
// The bubble background images have 1 px thick edges, which we don't want to |
// overlap. |
const int kBubbleInteriorVerticalPadding = 1; |
CalculateFontAndOffsetForHeight( |
location_height - ((kBubblePadding + kBubbleInteriorVerticalPadding) * 2), |
- &bubble_font, &bubble_font_y_offset); |
+ &bubble_font_list, &bubble_font_y_offset); |
bubble_font_y_offset += kBubbleInteriorVerticalPadding; |
const SkColor background_color = |
GetColor(ToolbarModel::NONE, LocationBarView::BACKGROUND); |
ev_bubble_view_ = new EVBubbleView( |
msw
2013/07/23 19:51:54
Is it okay that EVBubbleView, views::Label, Select
Yuki
2013/07/24 09:17:05
In the ideal situation, we should NEVER use GetPri
|
- bubble_font, bubble_font_y_offset, |
+ bubble_font_list.GetPrimaryFont(), bubble_font_y_offset, |
GetColor(ToolbarModel::EV_SECURE, SECURITY_TEXT), background_color, this); |
ev_bubble_view_->set_drag_controller(this); |
AddChildView(ev_bubble_view_); |
// Initialize the Omnibox view. |
location_entry_.reset(CreateOmniboxView(this, model_, profile_, |
- command_updater_, is_popup_mode_, this, font, font_y_offset)); |
+ command_updater_, is_popup_mode_, this, font_list, font_y_offset)); |
SetLocationEntryFocusable(true); |
location_entry_view_ = location_entry_->AddToView(this); |
// Initialize the inline autocomplete view which is visible only when IME is |
// turned on. Use the same font with the omnibox and highlighted background. |
- ime_inline_autocomplete_view_ = new views::Label(string16(), font); |
+ ime_inline_autocomplete_view_ = new views::Label(string16(), |
+ font_list.GetPrimaryFont()); |
ime_inline_autocomplete_view_->set_border( |
views::Border::CreateEmptyBorder(font_y_offset, 0, 0, 0)); |
ime_inline_autocomplete_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
@@ -289,11 +297,12 @@ void LocationBarView::Init() { |
const SkColor text_color = GetColor(ToolbarModel::NONE, TEXT); |
selected_keyword_view_ = new SelectedKeywordView( |
- bubble_font, bubble_font_y_offset, text_color, background_color, |
- profile_); |
+ bubble_font_list.GetPrimaryFont(), bubble_font_y_offset, text_color, |
+ background_color, profile_); |
AddChildView(selected_keyword_view_); |
- suggested_text_view_ = new views::Label(string16(), font); |
+ suggested_text_view_ = new views::Label(string16(), |
+ font_list.GetPrimaryFont()); |
suggested_text_view_->set_border( |
views::Border::CreateEmptyBorder(font_y_offset, 0, 0, 0)); |
suggested_text_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
@@ -304,7 +313,7 @@ void LocationBarView::Init() { |
AddChildView(suggested_text_view_); |
keyword_hint_view_ = new KeywordHintView( |
- profile_, font, font_y_offset, |
+ profile_, font_list.GetPrimaryFont(), font_y_offset, |
GetColor(ToolbarModel::NONE, LocationBarView::DEEMPHASIZED_TEXT), |
background_color); |
AddChildView(keyword_hint_view_); |
@@ -316,8 +325,9 @@ void LocationBarView::Init() { |
for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
ContentSettingImageView* content_blocked_view = |
new ContentSettingImageView(static_cast<ContentSettingsType>(i), this, |
- bubble_font, bubble_font_y_offset, |
- text_color, background_color); |
+ bubble_font_list.GetPrimaryFont(), |
+ bubble_font_y_offset, text_color, |
+ background_color); |
content_setting_views_.push_back(content_blocked_view); |
content_blocked_view->SetVisible(false); |
AddChildView(content_blocked_view); |