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

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

Issue 10399074: Cleanup: Rename GetHeight to more appropriate GetPreferredInternalHeight. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 void LocationBarView::Init() { 172 void LocationBarView::Init() {
173 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 173 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
174 if (mode_ == POPUP) { 174 if (mode_ == POPUP) {
175 font_ = rb.GetFont(ui::ResourceBundle::BaseFont); 175 font_ = rb.GetFont(ui::ResourceBundle::BaseFont);
176 } else { 176 } else {
177 // Use a larger version of the system font. 177 // Use a larger version of the system font.
178 font_ = rb.GetFont(ui::ResourceBundle::MediumFont); 178 font_ = rb.GetFont(ui::ResourceBundle::MediumFont);
179 } 179 }
180 180
181 // If this makes the font too big, try to make it smaller so it will fit. 181 // If this makes the font too big, try to make it smaller so it will fit.
182 const int height = GetHeight(); 182 const int height = GetPreferredInternalHeight();
183 while ((font_.GetHeight() > height) && (font_.GetFontSize() > 1)) 183 while ((font_.GetHeight() > height) && (font_.GetFontSize() > 1))
184 font_ = font_.DeriveFont(-1); 184 font_ = font_.DeriveFont(-1);
185 185
186 location_icon_view_ = new LocationIconView(this); 186 location_icon_view_ = new LocationIconView(this);
187 AddChildView(location_icon_view_); 187 AddChildView(location_icon_view_);
188 location_icon_view_->SetVisible(true); 188 location_icon_view_->SetVisible(true);
189 location_icon_view_->set_drag_controller(this); 189 location_icon_view_->set_drag_controller(this);
190 190
191 ev_bubble_view_ = 191 ev_bubble_view_ =
192 new EVBubbleView(kEVBubbleBackgroundImages, IDR_OMNIBOX_HTTPS_VALID, 192 new EVBubbleView(kEVBubbleBackgroundImages, IDR_OMNIBOX_HTTPS_VALID,
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 513
514 // TODO(jhawkins): Remove once crbug.com/101994 is fixed. 514 // TODO(jhawkins): Remove once crbug.com/101994 is fixed.
515 CHECK(location_icon_view_); 515 CHECK(location_icon_view_);
516 516
517 // TODO(sky): baseline layout. 517 // TODO(sky): baseline layout.
518 int location_y = kVerticalEdgeThickness; 518 int location_y = kVerticalEdgeThickness;
519 // In some cases (e.g. fullscreen mode) we may have 0 height. We still want 519 // In some cases (e.g. fullscreen mode) we may have 0 height. We still want
520 // to position our child views in this case, because other things may be 520 // to position our child views in this case, because other things may be
521 // positioned relative to them (e.g. the "bookmark added" bubble if the user 521 // positioned relative to them (e.g. the "bookmark added" bubble if the user
522 // hits ctrl-d). 522 // hits ctrl-d).
523 int location_height = std::max(height() - (kVerticalEdgeThickness * 2), 0); 523 int location_height = GetInternalHeightImpl(height());
524 524
525 // The edge stroke is 1 px thick. In popup mode, the edges are drawn by the 525 // The edge stroke is 1 px thick. In popup mode, the edges are drawn by the
526 // omnibox' parent, so there isn't any edge to account for at all. 526 // omnibox' parent, so there isn't any edge to account for at all.
527 const int kEdgeThickness = (mode_ == NORMAL) ? 527 const int kEdgeThickness = (mode_ == NORMAL) ?
528 kNormalHorizontalEdgeThickness : 0; 528 kNormalHorizontalEdgeThickness : 0;
529 // The edit has 1 px of horizontal whitespace inside it before the text. 529 // The edit has 1 px of horizontal whitespace inside it before the text.
530 const int kEditInternalSpace = 1; 530 const int kEditInternalSpace = 1;
531 // The space between an item and the edit is the normal item space, minus the 531 // The space between an item and the edit is the normal item space, minus the
532 // edit's built-in space (so the apparent space will be the same). 532 // edit's built-in space (so the apparent space will be the same).
533 const int kItemEditPadding = GetItemPadding() - kEditInternalSpace; 533 const int kItemEditPadding = GetItemPadding() - kEditInternalSpace;
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 void LocationBarView::Observe(int type, 1269 void LocationBarView::Observe(int type,
1270 const content::NotificationSource& source, 1270 const content::NotificationSource& source,
1271 const content::NotificationDetails& details) { 1271 const content::NotificationDetails& details) {
1272 if (type == chrome::NOTIFICATION_PREF_CHANGED) { 1272 if (type == chrome::NOTIFICATION_PREF_CHANGED) {
1273 std::string* name = content::Details<std::string>(details).ptr(); 1273 std::string* name = content::Details<std::string>(details).ptr();
1274 if (*name == prefs::kEditBookmarksEnabled) 1274 if (*name == prefs::kEditBookmarksEnabled)
1275 Update(NULL); 1275 Update(NULL);
1276 } 1276 }
1277 } 1277 }
1278 1278
1279 int LocationBarView::GetHeight() { 1279 int LocationBarView::GetPreferredInternalHeight() {
Peter Kasting 2012/05/18 22:45:40 Nit: Functions must be defined in the same order t
1280 return std::max( 1280 return GetInternalHeightImpl(GetPreferredSize().height());
1281 GetPreferredSize().height() - (kVerticalEdgeThickness * 2), 0); 1281 }
1282
1283 int LocationBarView::GetInternalHeightImpl(int total_height) {
1284 return std::max(total_height - (kVerticalEdgeThickness * 2), 0);
1282 } 1285 }
1283 1286
1284 #if defined(OS_WIN) || defined(USE_AURA) 1287 #if defined(OS_WIN) || defined(USE_AURA)
1285 bool LocationBarView::HasValidSuggestText() const { 1288 bool LocationBarView::HasValidSuggestText() const {
1286 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && 1289 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() &&
1287 !suggested_text_view_->text().empty(); 1290 !suggested_text_view_->text().empty();
1288 } 1291 }
1289 1292
1290 #if !defined(USE_AURA) 1293 #if !defined(USE_AURA)
1291 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { 1294 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() {
1292 return static_cast<OmniboxViewWin*>(location_entry_.get()); 1295 return static_cast<OmniboxViewWin*>(location_entry_.get());
1293 } 1296 }
1294 #endif 1297 #endif
1295 #endif 1298 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698