summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/views
diff options
context:
space:
mode:
authorxji@chromium.org <xji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-24 06:14:07 +0000
committerxji@chromium.org <xji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-24 06:14:07 +0000
commitfdf481ba49097edcfe9ace5888a263ab2fb437d6 (patch)
treece98020146bd69b6f7271ed37c3ad09ff8af1010 /chrome/browser/ui/views
parent9cde7cbcd0052d7bf33d7ef4e6386360d53a83c0 (diff)
downloadchromium_src-fdf481ba49097edcfe9ace5888a263ab2fb437d6.zip
chromium_src-fdf481ba49097edcfe9ace5888a263ab2fb437d6.tar.gz
chromium_src-fdf481ba49097edcfe9ace5888a263ab2fb437d6.tar.bz2
Aura: apply UI font list to cros.
- change IDS_UI_FONT_FAMILY_CROS back to 12px in default. - GetDefaultFont() in platform_font_pango.cc returns IDS_UI_FONT_FAMILY_CROS for Aura Chrome OS. - views::NativeTextfieldViews::UpdateFont() applies the size from the passed-in font on Chrome OS - OmniboxViewViews requests a larger font size. - Correspondingly, decrease OmniboxViewViews's vertical margin so that the display area has greater height to accommodate larger font size. BUG=103860, 109961 TEST=visual on omnibox and popup, bookmark bubble, findbar, and omnibox in popup. Review URL: http://codereview.chromium.org/9192018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118802 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/views')
-rw-r--r--chrome/browser/ui/views/omnibox/omnibox_view_views.cc54
-rw-r--r--chrome/browser/ui/views/omnibox/omnibox_view_views.h10
2 files changed, 40 insertions, 24 deletions
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
index 4854676..81f1e12 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
@@ -132,8 +132,6 @@ void ApplyURLStyle(views::Textfield* textfield,
textfield->ApplyStyleRange(style);
}
-const int kAutocompleteVerticalMargin = 4;
-
// TODO(oshima): I'm currently using slightly different color than
// gtk/win omnibox so that I can tell which one is used from its color.
// Fix this once we finish all features.
@@ -142,6 +140,21 @@ const SkColor kNormalTextColor = SK_ColorBLACK;
const SkColor kSecureSchemeColor = SK_ColorGREEN;
const SkColor kSecurityErrorSchemeColor = SK_ColorRED;
+// The following 2 const values are the same as in browser_defaults.
+const int kAutocompleteEditFontPixelSize = 15;
+const int kAutocompleteEditFontPixelSizeInPopup = 10;
+
+// The following 2 values are based on kAutocompleteEditFontPixelSize and
+// kAutocompleteEditFontPixelSizeInPopup. They should be changed accordingly
+// if font size for autocomplete edit (in popup) change.
+const int kAutocompleteVerticalMargin = 1;
+const int kAutocompleteVerticalMarginInPopup = 2;
+
+int GetEditFontPixelSize(bool popup_window_mode) {
+ return popup_window_mode ? kAutocompleteEditFontPixelSizeInPopup :
+ kAutocompleteEditFontPixelSize;
+}
+
} // namespace
// static
@@ -154,23 +167,16 @@ OmniboxViewViews::OmniboxViewViews(AutocompleteEditController* controller,
CommandUpdater* command_updater,
bool popup_window_mode,
LocationBarView* location_bar)
- : model_(new AutocompleteEditModel(this, controller, profile)),
- popup_view_(CreatePopupView(location_bar)),
+ : popup_window_mode_(popup_window_mode),
+ model_(new AutocompleteEditModel(this, controller, profile)),
controller_(controller),
toolbar_model_(toolbar_model),
command_updater_(command_updater),
- popup_window_mode_(popup_window_mode),
security_level_(ToolbarModel::NONE),
ime_composing_before_change_(false),
delete_at_end_pressed_(false),
location_bar_view_(location_bar),
ime_candidate_window_open_(false) {
- set_border(views::Border::CreateEmptyBorder(kAutocompleteVerticalMargin, 0,
- kAutocompleteVerticalMargin, 0));
-#if defined(OS_CHROMEOS)
- chromeos::input_method::InputMethodManager::GetInstance()->
- AddCandidateWindowObserver(this);
-#endif
}
OmniboxViewViews::~OmniboxViewViews() {
@@ -199,6 +205,25 @@ void OmniboxViewViews::Init() {
if (popup_window_mode_)
textfield_->SetReadOnly(true);
+ const int font_size = GetEditFontPixelSize(popup_window_mode_);
+ const int old_size = textfield_->font().GetFontSize();
+ if (font_size != old_size)
+ textfield_->SetFont(textfield_->font().DeriveFont(font_size - old_size));
+
+ // Create popup view using the same font as |textfield_|'s.
+ popup_view_.reset(
+ new AutocompletePopupContentsView(
+ textfield_->font(), this, model_.get(), location_bar_view_));
+
+ const int vertical_margin = !popup_window_mode_ ?
+ kAutocompleteVerticalMargin : kAutocompleteVerticalMarginInPopup;
+ set_border(views::Border::CreateEmptyBorder(vertical_margin, 0,
+ vertical_margin, 0));
+#if defined(OS_CHROMEOS)
+ chromeos::input_method::InputMethodManager::GetInstance()->
+ AddCandidateWindowObserver(this);
+#endif
+
// Manually invoke SetBaseColor() because TOOLKIT_VIEWS doesn't observe
// themes.
SetBaseColor();
@@ -808,13 +833,6 @@ string16 OmniboxViewViews::GetSelectedText() const {
return textfield_->GetSelectedText();
}
-AutocompletePopupView* OmniboxViewViews::CreatePopupView(
- View* location_bar) {
- typedef AutocompletePopupContentsView AutocompleteContentsView;
- return new AutocompleteContentsView(gfx::Font(), this, model_.get(),
- location_bar);
-}
-
#if defined(USE_AURA)
// static
OmniboxView* OmniboxView::CreateOmniboxView(
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.h b/chrome/browser/ui/views/omnibox/omnibox_view_views.h
index 53b0699..e4a9b18 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_views.h
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.h
@@ -187,10 +187,12 @@ class OmniboxViewViews
// Returns the selected text.
string16 GetSelectedText() const;
- AutocompletePopupView* CreatePopupView(View* location_bar);
-
views::Textfield* textfield_;
+ // When true, the location bar view is read only and also is has a slightly
+ // different presentation (smaller font size). This is used for popups.
+ bool popup_window_mode_;
+
scoped_ptr<AutocompleteEditModel> model_;
scoped_ptr<AutocompletePopupView> popup_view_;
AutocompleteEditController* controller_;
@@ -200,10 +202,6 @@ class OmniboxViewViews
// edit, such as invoking the keyword editor.
CommandUpdater* command_updater_;
- // When true, the location bar view is read only and also is has a slightly
- // different presentation (smaller font size). This is used for popups.
- bool popup_window_mode_;
-
ToolbarModel::SecurityLevel security_level_;
// Selection at the point where the user started using the