Chromium Code Reviews| Index: chrome/browser/ui/views/omnibox/omnibox_view_win.cc |
| diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc |
| index 01cee6dfa4831f24ae015261e42ea5b4448db177..1f4aba94ae430b1cf102dfef7220699e98e87481 100644 |
| --- a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc |
| +++ b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc |
| @@ -436,6 +436,7 @@ OmniboxViewWin::OmniboxViewWin(AutocompleteEditController* controller, |
| LocationBarView* parent_view, |
| CommandUpdater* command_updater, |
| bool popup_window_mode, |
| + int height, |
| views::View* location_bar) |
| : model_(new AutocompleteEditModel(this, controller, |
| parent_view->profile())), |
| @@ -496,17 +497,18 @@ OmniboxViewWin::OmniboxViewWin(AutocompleteEditController* controller, |
| HGDIOBJ old_font = SelectObject(hdc, font_.GetNativeFont()); |
| TEXTMETRIC tm = {0}; |
| GetTextMetrics(hdc, &tm); |
| - const float kXHeightRatio = 0.7f; // The ratio of a font's x-height to its |
| - // cap height. Sadly, Windows doesn't |
| - // provide a true value for a font's |
| - // x-height in its text metrics, so we |
| - // approximate. |
| - font_x_height_ = static_cast<int>((static_cast<float>(font_.GetBaseline() - |
| - tm.tmInternalLeading) * kXHeightRatio) + 0.5); |
| - // The distance from the top of the field to the desired baseline of the |
| - // rendered text. |
| - const int kTextBaseline = popup_window_mode_ ? 15 : 18; |
| - font_y_adjustment_ = kTextBaseline - font_.GetBaseline(); |
| + int cap_height = font_.GetBaseline() - tm.tmInternalLeading; |
| + // The ratio of a font's x-height to its cap height. Sadly, Windows |
| + // doesn't provide a true value for a font's x-height in its text |
| + // metrics, so we approximate. |
| + const float kXHeightRatio = 0.7f; |
| + font_x_height_ = static_cast<int>( |
| + (static_cast<float>(cap_height) * kXHeightRatio) + 0.5); |
| + |
| + // We set font_y_adjustment_ so that the ascender of the font gets |
| + // centered on the available height of the view. |
|
Peter Kasting
2012/05/16 23:19:50
You did check that this produces identical results
|
| + font_y_adjustment_ = |
| + (height - cap_height) / 2 + cap_height - font_.GetBaseline(); |
|
Peter Kasting
2012/05/16 23:19:50
Nit: Simpler:
font_y_adjustment_ = ((height - c
|
| // Get the number of twips per pixel, which we need below to offset our text |
| // by the desired number of pixels. |
| @@ -2682,12 +2684,14 @@ OmniboxView* OmniboxView::CreateOmniboxView( |
| Profile* profile, |
| CommandUpdater* command_updater, |
| bool popup_window_mode, |
| + int height, |
| LocationBarView* location_bar) { |
| return new OmniboxViewWin(controller, |
| toolbar_model, |
| location_bar, |
| command_updater, |
| popup_window_mode, |
| + height, |
| location_bar); |
| } |
| #endif |