diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-26 17:42:53 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-26 17:42:53 +0000 |
commit | 4d76a5ce981e3e5440f05ed227824af3a6f6ed00 (patch) | |
tree | 714069c5e98d0cd7b311feca8ed638269363f390 | |
parent | 5aa747ec53f4d1d3ac22c9aed46dca27124af89a (diff) | |
download | chromium_src-4d76a5ce981e3e5440f05ed227824af3a6f6ed00.zip chromium_src-4d76a5ce981e3e5440f05ed227824af3a6f6ed00.tar.gz chromium_src-4d76a5ce981e3e5440f05ed227824af3a6f6ed00.tar.bz2 |
Use some built-in methods on the Font object to avoid storing so many data members on the AutocompleteEdit.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/2182002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48287 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_win.cc | 14 | ||||
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_win.h | 2 |
2 files changed, 6 insertions, 10 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc index 513f68a..6a17f80 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc @@ -437,19 +437,17 @@ AutocompleteEditViewWin::AutocompleteEditViewWin( SelectObject(dc, font_.hfont()); TEXTMETRIC tm = {0}; GetTextMetrics(dc, &tm); - font_ascent_ = tm.tmAscent; 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_ascent_ - + font_x_height_ = static_cast<int>((static_cast<float>(font_.baseline() - 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_ascent_; - font_descent_ = tm.tmDescent; + font_y_adjustment_ = kTextBaseline - font_.baseline(); // Get the number of twips per pixel, which we need below to offset our text // by the desired number of pixels. @@ -2131,10 +2129,10 @@ void AutocompleteEditViewWin::DrawSlashForInsecureScheme( const int kAdditionalSpaceOutsideFont = static_cast<int>(ceil(kStrokeWidthPixels * 1.5f)); const CRect scheme_rect(PosFromChar(insecure_scheme_component_.begin).x, - font_top + font_ascent_ - font_x_height_ - + font_top + font_.baseline() - font_x_height_ - kAdditionalSpaceOutsideFont, PosFromChar(insecure_scheme_component_.end()).x, - font_top + font_ascent_ + + font_top + font_.baseline() + kAdditionalSpaceOutsideFont); // Clip to the portion we care about and translate to canvas coordinates @@ -2215,7 +2213,7 @@ void AutocompleteEditViewWin::DrawDropHighlight( const CRect highlight_rect(highlight_x, highlight_y, highlight_x + 1, - highlight_y + font_ascent_ + font_descent_); + highlight_y + font_.height()); // Clip the highlight to the region being painted. CRect clip_rect; @@ -2409,7 +2407,7 @@ void AutocompleteEditViewWin::RepaintDropHighlight(int position) { if ((position != -1) && (position <= GetTextLength())) { const POINT min_loc(PosFromChar(position)); const RECT highlight_bounds = {min_loc.x - 1, font_y_adjustment_, - min_loc.x + 2, font_ascent_ + font_descent_ + font_y_adjustment_}; + min_loc.x + 2, font_.height() + font_y_adjustment_}; InvalidateRect(&highlight_bounds, false); } } diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.h b/chrome/browser/autocomplete/autocomplete_edit_view_win.h index 33af6a7..4f3e51e 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_win.h +++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.h @@ -457,8 +457,6 @@ class AutocompleteEditViewWin // every time we paint. |font_y_adjustment_| is the number of pixels we need // to shift the font vertically in order to make its baseline be at our // desired baseline in the edit. - int font_ascent_; - int font_descent_; int font_x_height_; int font_y_adjustment_; |