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/omnibox/omnibox_popup_contents_view.h" | 5 #include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "chrome/browser/search/search.h" | 9 #include "chrome/browser/search/search.h" |
| 10 #include "chrome/browser/themes/theme_properties.h" | 10 #include "chrome/browser/themes/theme_properties.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 return current_frame_bounds; | 110 return current_frame_bounds; |
| 111 } | 111 } |
| 112 | 112 |
| 113 void OmniboxPopupContentsView::LayoutChildren() { | 113 void OmniboxPopupContentsView::LayoutChildren() { |
| 114 ui::ThemeProvider* theme_provider = location_bar_view_->GetThemeProvider(); | 114 ui::ThemeProvider* theme_provider = location_bar_view_->GetThemeProvider(); |
| 115 const int min_vertical_padding = theme_provider->GetDisplayProperty( | 115 const int min_vertical_padding = theme_provider->GetDisplayProperty( |
| 116 ThemeProperties::PROPERTY_OMNIBOX_DROPDOWN_MIN_TEXT_VERTICAL_PADDING); | 116 ThemeProperties::PROPERTY_OMNIBOX_DROPDOWN_MIN_TEXT_VERTICAL_PADDING); |
| 117 | 117 |
| 118 gfx::Rect contents_rect = GetContentsBounds(); | 118 gfx::Rect contents_rect = GetContentsBounds(); |
| 119 | 119 |
| 120 // In the material design version of the omnibox dropdown, the | |
| 121 // selected/hovered background color and the click/touch regions for each | |
| 122 // result should extend to the entire width of the dropdown. Icons and | |
| 123 // text remain aligned with the location bar; this is done by modifying | |
| 124 // the layout using LeftOffset() and RightOffset() in OmniboxResultView. | |
| 120 contents_rect.Inset( | 125 contents_rect.Inset( |
| 121 left_margin_, | 126 ui::MaterialDesignController::IsModeMaterial() ? 0 : left_margin_, |
| 122 views::NonClientFrameView::kClientEdgeThickness + min_vertical_padding, | 127 views::NonClientFrameView::kClientEdgeThickness + min_vertical_padding, |
| 123 right_margin_, | 128 ui::MaterialDesignController::IsModeMaterial() ? 0 : right_margin_, |
| 124 min_vertical_padding); | 129 min_vertical_padding); |
|
Peter Kasting
2015/08/18 19:55:37
Nit: This code is the same length, but might be sl
tdanderson
2015/08/19 17:22:35
Agreed, that is much nicer. Changed.
| |
| 125 int top = contents_rect.y(); | 130 int top = contents_rect.y(); |
| 126 for (size_t i = 0; i < AutocompleteResult::kMaxMatches; ++i) { | 131 for (size_t i = 0; i < AutocompleteResult::kMaxMatches; ++i) { |
| 127 View* v = child_at(i); | 132 View* v = child_at(i); |
| 128 if (v->visible()) { | 133 if (v->visible()) { |
| 129 v->SetBounds(contents_rect.x(), top, contents_rect.width(), | 134 v->SetBounds(contents_rect.x(), top, contents_rect.width(), |
| 130 v->GetPreferredSize().height()); | 135 v->GetPreferredSize().height()); |
| 131 top = v->bounds().bottom(); | 136 top = v->bounds().bottom(); |
| 132 } | 137 } |
| 133 } | 138 } |
| 134 } | 139 } |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 506 size_t index = GetIndexForPoint(event.location()); | 511 size_t index = GetIndexForPoint(event.location()); |
| 507 if (!HasMatchAt(index)) | 512 if (!HasMatchAt(index)) |
| 508 return; | 513 return; |
| 509 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition, | 514 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition, |
| 510 GURL(), base::string16(), index); | 515 GURL(), base::string16(), index); |
| 511 } | 516 } |
| 512 | 517 |
| 513 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) { | 518 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) { |
| 514 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i))); | 519 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i))); |
| 515 } | 520 } |
| OLD | NEW |