| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 current_frame_bounds.height() + current_height_delta); | 109 current_frame_bounds.height() + current_height_delta); |
| 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 contents_rect.Inset( |
| 120 0, views::NonClientFrameView::kClientEdgeThickness + min_vertical_padding, |
| 121 0, min_vertical_padding); |
| 119 | 122 |
| 120 contents_rect.Inset( | 123 // In the non-material dropdown, the colored/clickable regions within the |
| 121 left_margin_, | 124 // dropdown are only as wide as the location bar. In the material version, |
| 122 views::NonClientFrameView::kClientEdgeThickness + min_vertical_padding, | 125 // these are full width, and OmniboxResultView instead insets the icons/text |
| 123 right_margin_, | 126 // inside to be aligned with the location bar. |
| 124 min_vertical_padding); | 127 if (!ui::MaterialDesignController::IsModeMaterial()) |
| 128 contents_rect.Inset(left_margin_, 0, right_margin_, 0); |
| 129 |
| 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 |