Chromium Code Reviews| 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 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1243 state->selection_start = entry_start; | 1243 state->selection_start = entry_start; |
| 1244 state->selection_end = entry_end; | 1244 state->selection_end = entry_end; |
| 1245 } | 1245 } |
| 1246 | 1246 |
| 1247 bool LocationBarView::HasFocus() const { | 1247 bool LocationBarView::HasFocus() const { |
| 1248 return location_entry_->model()->has_focus(); | 1248 return location_entry_->model()->has_focus(); |
| 1249 } | 1249 } |
| 1250 | 1250 |
| 1251 void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 1251 void LocationBarView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| 1252 if (browser_ && browser_->instant_controller() && parent()) { | 1252 if (browser_ && browser_->instant_controller() && parent()) { |
| 1253 // Pass the side margins of the location bar to the Instant Controller. | 1253 // Pass the start margin and width of the location bar to the Instant |
| 1254 // Controller. | |
| 1254 const gfx::Rect bounds = GetBoundsInScreen(); | 1255 const gfx::Rect bounds = GetBoundsInScreen(); |
| 1255 const gfx::Rect parent_bounds = parent()->GetBoundsInScreen(); | 1256 const gfx::Rect parent_bounds = parent()->GetBoundsInScreen(); |
| 1256 int start = bounds.x() - parent_bounds.x(); | 1257 const int margin = base::i18n::IsRTL() ? |
| 1257 int end = parent_bounds.right() - bounds.right(); | 1258 parent_bounds.right() - bounds.right() : bounds.x() - parent_bounds.x(); |
|
Peter Kasting
2013/02/26 22:07:19
Accessing the parent bounds at all, let alone usin
melevin
2013/02/26 23:43:52
Ah you're right, this code simplified down to just
| |
| 1258 if (base::i18n::IsRTL()) | 1259 const int width = bounds.width(); |
| 1259 std::swap(start, end); | 1260 browser_->instant_controller()->SetStartMarginAndWidth(margin, width); |
| 1260 browser_->instant_controller()->SetMarginSize(start, end); | |
| 1261 } | 1261 } |
| 1262 } | 1262 } |
| 1263 | 1263 |
| 1264 void LocationBarView::WriteDragDataForView(views::View* sender, | 1264 void LocationBarView::WriteDragDataForView(views::View* sender, |
| 1265 const gfx::Point& press_pt, | 1265 const gfx::Point& press_pt, |
| 1266 OSExchangeData* data) { | 1266 OSExchangeData* data) { |
| 1267 DCHECK_NE(GetDragOperationsForView(sender, press_pt), | 1267 DCHECK_NE(GetDragOperationsForView(sender, press_pt), |
| 1268 ui::DragDropTypes::DRAG_NONE); | 1268 ui::DragDropTypes::DRAG_NONE); |
| 1269 | 1269 |
| 1270 WebContents* web_contents = GetWebContents(); | 1270 WebContents* web_contents = GetWebContents(); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1453 int LocationBarView::GetInternalHeight(bool use_preferred_size) { | 1453 int LocationBarView::GetInternalHeight(bool use_preferred_size) { |
| 1454 int total_height = | 1454 int total_height = |
| 1455 use_preferred_size ? GetPreferredSize().height() : height(); | 1455 use_preferred_size ? GetPreferredSize().height() : height(); |
| 1456 return std::max(total_height - (kVerticalEdgeThickness * 2), 0); | 1456 return std::max(total_height - (kVerticalEdgeThickness * 2), 0); |
| 1457 } | 1457 } |
| 1458 | 1458 |
| 1459 bool LocationBarView::HasValidSuggestText() const { | 1459 bool LocationBarView::HasValidSuggestText() const { |
| 1460 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && | 1460 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && |
| 1461 !suggested_text_view_->text().empty(); | 1461 !suggested_text_view_->text().empty(); |
| 1462 } | 1462 } |
| OLD | NEW |