Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4888)

Unified Diff: chrome/browser/ui/views/omnibox/omnibox_view_win.cc

Issue 9985012: Adjust location of text in omnibox edit control for Metro. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments. Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..c89896a52855be98b42cfb03a3ce0813e03f35cb 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc
@@ -496,17 +496,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.
+ font_y_adjustment_ = (parent_view->GetHeight() - cap_height) / 2 -
+ tm.tmInternalLeading;
// Get the number of twips per pixel, which we need below to offset our text
// by the desired number of pixels.

Powered by Google App Engine
This is Rietveld 408576698