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

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

Issue 12047107: Change the SearchBox API from using the start/end margins of the location bar to using the start ma… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 state->selection_start = entry_start; 1248 state->selection_start = entry_start;
1249 state->selection_end = entry_end; 1249 state->selection_end = entry_end;
1250 } 1250 }
1251 1251
1252 bool LocationBarView::HasFocus() const { 1252 bool LocationBarView::HasFocus() const {
1253 return location_entry_->model()->has_focus(); 1253 return location_entry_->model()->has_focus();
1254 } 1254 }
1255 1255
1256 void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) { 1256 void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
1257 if (browser_ && browser_->instant_controller() && parent()) { 1257 if (browser_ && browser_->instant_controller() && parent()) {
1258 // Pass the side margins of the location bar to the Instant Controller. 1258 // Pass the start margin and width of the location bar to the Instant
1259 // Controller.
1259 const gfx::Rect bounds = GetBoundsInScreen(); 1260 const gfx::Rect bounds = GetBoundsInScreen();
1260 const gfx::Rect parent_bounds = parent()->GetBoundsInScreen(); 1261 const gfx::Rect parent_bounds = parent()->GetBoundsInScreen();
1261 int start = bounds.x() - parent_bounds.x(); 1262 const int margin = base::i18n::IsRTL() ?
1262 int end = parent_bounds.right() - bounds.right(); 1263 parent_bounds.right() - bounds.right() : bounds.x() - parent_bounds.x();
1263 if (base::i18n::IsRTL()) 1264 const int width = bounds.width();
1264 std::swap(start, end); 1265 browser_->instant_controller()->SetStartMarginAndWidth(margin, width);
1265 browser_->instant_controller()->SetMarginSize(start, end);
1266 } 1266 }
1267 } 1267 }
1268 1268
1269 void LocationBarView::WriteDragDataForView(views::View* sender, 1269 void LocationBarView::WriteDragDataForView(views::View* sender,
1270 const gfx::Point& press_pt, 1270 const gfx::Point& press_pt,
1271 OSExchangeData* data) { 1271 OSExchangeData* data) {
1272 DCHECK_NE(GetDragOperationsForView(sender, press_pt), 1272 DCHECK_NE(GetDragOperationsForView(sender, press_pt),
1273 ui::DragDropTypes::DRAG_NONE); 1273 ui::DragDropTypes::DRAG_NONE);
1274 1274
1275 WebContents* web_contents = GetWebContents(); 1275 WebContents* web_contents = GetWebContents();
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 int LocationBarView::GetInternalHeight(bool use_preferred_size) { 1458 int LocationBarView::GetInternalHeight(bool use_preferred_size) {
1459 int total_height = 1459 int total_height =
1460 use_preferred_size ? GetPreferredSize().height() : height(); 1460 use_preferred_size ? GetPreferredSize().height() : height();
1461 return std::max(total_height - (kVerticalEdgeThickness * 2), 0); 1461 return std::max(total_height - (kVerticalEdgeThickness * 2), 0);
1462 } 1462 }
1463 1463
1464 bool LocationBarView::HasValidSuggestText() const { 1464 bool LocationBarView::HasValidSuggestText() const {
1465 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && 1465 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() &&
1466 !suggested_text_view_->text().empty(); 1466 !suggested_text_view_->text().empty();
1467 } 1467 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698