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

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: Simplified LocationBarView::OnBoundsChanged Created 7 years, 9 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 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 state->selection_start = entry_start; 1268 state->selection_start = entry_start;
1269 state->selection_end = entry_end; 1269 state->selection_end = entry_end;
1270 } 1270 }
1271 1271
1272 bool LocationBarView::HasFocus() const { 1272 bool LocationBarView::HasFocus() const {
1273 return location_entry_->model()->has_focus(); 1273 return location_entry_->model()->has_focus();
1274 } 1274 }
1275 1275
1276 void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) { 1276 void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
1277 if (browser_ && browser_->instant_controller() && parent()) { 1277 if (browser_ && browser_->instant_controller() && parent()) {
1278 // Pass the side margins of the location bar to the Instant Controller. 1278 // Pass the start margin and width of the location bar to the Instant
1279 const gfx::Rect bounds = GetBoundsInScreen(); 1279 // Controller.
1280 const gfx::Rect parent_bounds = parent()->GetBoundsInScreen(); 1280 const gfx::Rect bounds_rect = bounds();
1281 int start = bounds.x() - parent_bounds.x(); 1281 browser_->instant_controller()->SetStartMarginAndWidth(
1282 int end = parent_bounds.right() - bounds.right(); 1282 bounds_rect.x(), bounds_rect.width());
Peter Kasting 2013/02/26 23:46:26 Nit: Rather than using a margin and width pair her
1283 if (base::i18n::IsRTL())
1284 std::swap(start, end);
1285 browser_->instant_controller()->SetMarginSize(start, end);
1286 } 1283 }
1287 } 1284 }
1288 1285
1289 void LocationBarView::WriteDragDataForView(views::View* sender, 1286 void LocationBarView::WriteDragDataForView(views::View* sender,
1290 const gfx::Point& press_pt, 1287 const gfx::Point& press_pt,
1291 OSExchangeData* data) { 1288 OSExchangeData* data) {
1292 DCHECK_NE(GetDragOperationsForView(sender, press_pt), 1289 DCHECK_NE(GetDragOperationsForView(sender, press_pt),
1293 ui::DragDropTypes::DRAG_NONE); 1290 ui::DragDropTypes::DRAG_NONE);
1294 1291
1295 WebContents* web_contents = GetWebContents(); 1292 WebContents* web_contents = GetWebContents();
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 int LocationBarView::GetInternalHeight(bool use_preferred_size) { 1475 int LocationBarView::GetInternalHeight(bool use_preferred_size) {
1479 int total_height = 1476 int total_height =
1480 use_preferred_size ? GetPreferredSize().height() : height(); 1477 use_preferred_size ? GetPreferredSize().height() : height();
1481 return std::max(total_height - (kVerticalEdgeThickness * 2), 0); 1478 return std::max(total_height - (kVerticalEdgeThickness * 2), 0);
1482 } 1479 }
1483 1480
1484 bool LocationBarView::HasValidSuggestText() const { 1481 bool LocationBarView::HasValidSuggestText() const {
1485 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && 1482 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() &&
1486 !suggested_text_view_->text().empty(); 1483 !suggested_text_view_->text().empty();
1487 } 1484 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_instant_controller.cc ('k') | chrome/renderer/resources/extensions/searchbox_api.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698