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

Side by Side Diff: chrome/browser/ui/views/location_bar/location_bar_view.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 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 void LocationBarView::Init() { 171 void LocationBarView::Init() {
172 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 172 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
173 if (mode_ == POPUP) { 173 if (mode_ == POPUP) {
174 font_ = rb.GetFont(ui::ResourceBundle::BaseFont); 174 font_ = rb.GetFont(ui::ResourceBundle::BaseFont);
175 } else { 175 } else {
176 // Use a larger version of the system font. 176 // Use a larger version of the system font.
177 font_ = rb.GetFont(ui::ResourceBundle::MediumFont); 177 font_ = rb.GetFont(ui::ResourceBundle::MediumFont);
178 } 178 }
179 179
180 // If this makes the font too big, try to make it smaller so it will fit. 180 // If this makes the font too big, try to make it smaller so it will fit.
181 const int height = 181 const int height = GetHeight();
182 std::max(GetPreferredSize().height() - (kVerticalEdgeThickness * 2), 0);
183 while ((font_.GetHeight() > height) && (font_.GetFontSize() > 1)) 182 while ((font_.GetHeight() > height) && (font_.GetFontSize() > 1))
184 font_ = font_.DeriveFont(-1); 183 font_ = font_.DeriveFont(-1);
185 184
186 location_icon_view_ = new LocationIconView(this); 185 location_icon_view_ = new LocationIconView(this);
187 AddChildView(location_icon_view_); 186 AddChildView(location_icon_view_);
188 location_icon_view_->SetVisible(true); 187 location_icon_view_->SetVisible(true);
189 location_icon_view_->set_drag_controller(this); 188 location_icon_view_->set_drag_controller(this);
190 189
191 ev_bubble_view_ = 190 ev_bubble_view_ =
192 new EVBubbleView(kEVBubbleBackgroundImages, IDR_OMNIBOX_HTTPS_VALID, 191 new EVBubbleView(kEVBubbleBackgroundImages, IDR_OMNIBOX_HTTPS_VALID,
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 512
514 // TODO(jhawkins): Remove once crbug.com/101994 is fixed. 513 // TODO(jhawkins): Remove once crbug.com/101994 is fixed.
515 CHECK(location_icon_view_); 514 CHECK(location_icon_view_);
516 515
517 // TODO(sky): baseline layout. 516 // TODO(sky): baseline layout.
518 int location_y = kVerticalEdgeThickness; 517 int location_y = kVerticalEdgeThickness;
519 // In some cases (e.g. fullscreen mode) we may have 0 height. We still want 518 // 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 519 // 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 520 // positioned relative to them (e.g. the "bookmark added" bubble if the user
522 // hits ctrl-d). 521 // hits ctrl-d).
523 int location_height = std::max(height() - (kVerticalEdgeThickness * 2), 0); 522 int location_height = std::max(height() - (kVerticalEdgeThickness * 2), 0);
Peter Kasting 2012/05/17 01:09:06 Nit: Should this call GetHeight() too, maybe if yo
524 523
525 // The edge stroke is 1 px thick. In popup mode, the edges are drawn by the 524 // 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. 525 // omnibox' parent, so there isn't any edge to account for at all.
527 const int kEdgeThickness = (mode_ == NORMAL) ? 526 const int kEdgeThickness = (mode_ == NORMAL) ?
528 kNormalHorizontalEdgeThickness : 0; 527 kNormalHorizontalEdgeThickness : 0;
529 // The edit has 1 px of horizontal whitespace inside it before the text. 528 // The edit has 1 px of horizontal whitespace inside it before the text.
530 const int kEditInternalSpace = 1; 529 const int kEditInternalSpace = 1;
531 // The space between an item and the edit is the normal item space, minus the 530 // 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). 531 // edit's built-in space (so the apparent space will be the same).
533 const int kItemEditPadding = GetItemPadding() - kEditInternalSpace; 532 const int kItemEditPadding = GetItemPadding() - kEditInternalSpace;
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 void LocationBarView::Observe(int type, 1268 void LocationBarView::Observe(int type,
1270 const content::NotificationSource& source, 1269 const content::NotificationSource& source,
1271 const content::NotificationDetails& details) { 1270 const content::NotificationDetails& details) {
1272 if (type == chrome::NOTIFICATION_PREF_CHANGED) { 1271 if (type == chrome::NOTIFICATION_PREF_CHANGED) {
1273 std::string* name = content::Details<std::string>(details).ptr(); 1272 std::string* name = content::Details<std::string>(details).ptr();
1274 if (*name == prefs::kEditBookmarksEnabled) 1273 if (*name == prefs::kEditBookmarksEnabled)
1275 Update(NULL); 1274 Update(NULL);
1276 } 1275 }
1277 } 1276 }
1278 1277
1278 int LocationBarView::GetHeight() {
1279 return std::max(
1280 GetPreferredSize().height() - (kVerticalEdgeThickness * 2), 0);
1281 }
1282
1279 #if defined(OS_WIN) || defined(USE_AURA) 1283 #if defined(OS_WIN) || defined(USE_AURA)
1280 bool LocationBarView::HasValidSuggestText() const { 1284 bool LocationBarView::HasValidSuggestText() const {
1281 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && 1285 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() &&
1282 !suggested_text_view_->text().empty(); 1286 !suggested_text_view_->text().empty();
1283 } 1287 }
1284 1288
1285 #if !defined(USE_AURA) 1289 #if !defined(USE_AURA)
1286 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { 1290 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() {
1287 return static_cast<OmniboxViewWin*>(location_entry_.get()); 1291 return static_cast<OmniboxViewWin*>(location_entry_.get());
1288 } 1292 }
1289 #endif 1293 #endif
1290 #endif 1294 #endif
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/location_bar/location_bar_view.h ('k') | chrome/browser/ui/views/omnibox/omnibox_view_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698