OLD | NEW |
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 Loading... |
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 // Some platforms don't support getting the cap height, and simply return |
| 150 // the entire font ascent from GetCapHeight(). Centering the ascent makes |
| 151 // the font look too low, so if GetCapHeight() returns the ascent, center |
| 152 // the entire font height instead. |
| 153 const int space = |
| 154 height - ((internal_leading != 0) ? |
| 155 font_list.GetCapHeight() : font_list.GetHeight()); |
150 const int y_offset = space / 2 - internal_leading; | 156 const int y_offset = space / 2 - internal_leading; |
151 const int space_at_bottom = height - (y_offset + font_list.GetHeight()); | 157 const int space_at_bottom = height - (y_offset + font_list.GetHeight()); |
152 if ((y_offset >= 0) && (space_at_bottom >= 0)) | 158 if ((y_offset >= 0) && (space_at_bottom >= 0)) |
153 break; | 159 break; |
154 font_list = font_list.DeriveFontListWithSizeDelta(-1); | 160 font_list = font_list.DeriveFontListWithSizeDelta(-1); |
155 } | 161 } |
156 return font_list; | 162 return font_list; |
157 } | 163 } |
158 | 164 |
159 } // namespace | 165 } // namespace |
(...skipping 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1531 bounds.Inset(-(horizontal_padding + 1) / 2, 0); | 1537 bounds.Inset(-(horizontal_padding + 1) / 2, 0); |
1532 location_bar_util::PaintExtensionActionBackground( | 1538 location_bar_util::PaintExtensionActionBackground( |
1533 *(*page_action_view)->image_view()->page_action(), | 1539 *(*page_action_view)->image_view()->page_action(), |
1534 tab_id, canvas, bounds, text_color, background_color); | 1540 tab_id, canvas, bounds, text_color, background_color); |
1535 } | 1541 } |
1536 } | 1542 } |
1537 | 1543 |
1538 void LocationBarView::AccessibilitySetValue(const string16& new_value) { | 1544 void LocationBarView::AccessibilitySetValue(const string16& new_value) { |
1539 location_entry_->SetUserText(new_value); | 1545 location_entry_->SetUserText(new_value); |
1540 } | 1546 } |
OLD | NEW |