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

Side by Side Diff: chrome/browser/ui/views/location_bar/location_bar_view.cc

Issue 59873002: Center the font height instead of cap height when cap height is not supported. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 // y offset >= 0 139 // y offset >= 0
140 // space at bottom >= 0 140 // space at bottom >= 0
141 // (i.e. Entire font must be visible inside the box.) 141 // (i.e. Entire font must be visible inside the box.)
142 gfx::FontList GetLargestFontListWithHeightBound( 142 gfx::FontList GetLargestFontListWithHeightBound(
143 const gfx::FontList& base_font_list, 143 const gfx::FontList& base_font_list,
144 int height) { 144 int height) {
145 gfx::FontList font_list = base_font_list; 145 gfx::FontList font_list = base_font_list;
146 for (int font_size = font_list.GetFontSize(); font_size > 1; --font_size) { 146 for (int font_size = font_list.GetFontSize(); font_size > 1; --font_size) {
147 const int internal_leading = 147 const int internal_leading =
148 font_list.GetBaseline() - font_list.GetCapHeight(); 148 font_list.GetBaseline() - font_list.GetCapHeight();
149 const int space = height - font_list.GetCapHeight(); 149 // If cap height is supported (i.e. internal_leading != 0), we have the cap
150 // height centered. If not, we have the font height centered.
Peter Kasting 2013/11/05 22:18:01 Nit: How about this: Some platforms don't support
Yuki 2013/11/06 02:38:42 Done.
151 const int space =
152 height - ((internal_leading != 0) ?
153 font_list.GetCapHeight() : font_list.GetHeight());
150 const int y_offset = space / 2 - internal_leading; 154 const int y_offset = space / 2 - internal_leading;
151 const int space_at_bottom = height - (y_offset + font_list.GetHeight()); 155 const int space_at_bottom = height - (y_offset + font_list.GetHeight());
152 if ((y_offset >= 0) && (space_at_bottom >= 0)) 156 if ((y_offset >= 0) && (space_at_bottom >= 0))
153 break; 157 break;
154 font_list = font_list.DeriveFontListWithSizeDelta(-1); 158 font_list = font_list.DeriveFontListWithSizeDelta(-1);
155 } 159 }
156 return font_list; 160 return font_list;
157 } 161 }
158 162
159 } // namespace 163 } // namespace
(...skipping 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1531 bounds.Inset(-(horizontal_padding + 1) / 2, 0); 1535 bounds.Inset(-(horizontal_padding + 1) / 2, 0);
1532 location_bar_util::PaintExtensionActionBackground( 1536 location_bar_util::PaintExtensionActionBackground(
1533 *(*page_action_view)->image_view()->page_action(), 1537 *(*page_action_view)->image_view()->page_action(),
1534 tab_id, canvas, bounds, text_color, background_color); 1538 tab_id, canvas, bounds, text_color, background_color);
1535 } 1539 }
1536 } 1540 }
1537 1541
1538 void LocationBarView::AccessibilitySetValue(const string16& new_value) { 1542 void LocationBarView::AccessibilitySetValue(const string16& new_value) {
1539 location_entry_->SetUserText(new_value); 1543 location_entry_->SetUserText(new_value);
1540 } 1544 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698