| 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 "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 int current_height_delta = static_cast<int>( | 115 int current_height_delta = static_cast<int>( |
| 116 size_animation_.GetCurrentValue() * total_height_delta - 0.5); | 116 size_animation_.GetCurrentValue() * total_height_delta - 0.5); |
| 117 current_frame_bounds.set_height( | 117 current_frame_bounds.set_height( |
| 118 current_frame_bounds.height() + current_height_delta); | 118 current_frame_bounds.height() + current_height_delta); |
| 119 return current_frame_bounds; | 119 return current_frame_bounds; |
| 120 } | 120 } |
| 121 | 121 |
| 122 void OmniboxPopupContentsView::LayoutChildren() { | 122 void OmniboxPopupContentsView::LayoutChildren() { |
| 123 gfx::Rect contents_rect = GetContentsBounds(); | 123 gfx::Rect contents_rect = GetContentsBounds(); |
| 124 contents_rect.Inset(GetLayoutInsets(OMNIBOX_DROPDOWN)); | 124 contents_rect.Inset(GetLayoutInsets(OMNIBOX_DROPDOWN)); |
| 125 contents_rect.Inset(0, views::NonClientFrameView::kClientEdgeThickness, 0, 0); | 125 contents_rect.Inset(start_margin_, |
| 126 | 126 views::NonClientFrameView::kClientEdgeThickness, |
| 127 // In the non-material dropdown, the colored/clickable regions within the | 127 end_margin_, 0); |
| 128 // dropdown are only as wide as the location bar. In the material version, | |
| 129 // these are full width, and OmniboxResultView instead insets the icons/text | |
| 130 // inside to be aligned with the location bar. | |
| 131 if (!ui::MaterialDesignController::IsModeMaterial()) | |
| 132 contents_rect.Inset(start_margin_, 0, end_margin_, 0); | |
| 133 | 128 |
| 134 int top = contents_rect.y(); | 129 int top = contents_rect.y(); |
| 135 for (size_t i = 0; i < AutocompleteResult::kMaxMatches; ++i) { | 130 for (size_t i = 0; i < AutocompleteResult::kMaxMatches; ++i) { |
| 136 View* v = child_at(i); | 131 View* v = child_at(i); |
| 137 if (v->visible()) { | 132 if (v->visible()) { |
| 138 v->SetBounds(contents_rect.x(), top, contents_rect.width(), | 133 v->SetBounds(contents_rect.x(), top, contents_rect.width(), |
| 139 v->GetPreferredSize().height()); | 134 v->GetPreferredSize().height()); |
| 140 top = v->bounds().bottom(); | 135 top = v->bounds().bottom(); |
| 141 } | 136 } |
| 142 } | 137 } |
| 143 } | 138 } |
| 144 | 139 |
| 145 //////////////////////////////////////////////////////////////////////////////// | 140 //////////////////////////////////////////////////////////////////////////////// |
| 146 // OmniboxPopupContentsView, OmniboxPopupView overrides: | 141 // OmniboxPopupContentsView, OmniboxPopupView overrides: |
| 147 | 142 |
| 148 bool OmniboxPopupContentsView::IsOpen() const { | 143 bool OmniboxPopupContentsView::IsOpen() const { |
| 149 return popup_ != NULL; | 144 return popup_ != NULL; |
| 150 } | 145 } |
| 151 | 146 |
| 152 void OmniboxPopupContentsView::InvalidateLine(size_t line) { | 147 void OmniboxPopupContentsView::InvalidateLine(size_t line) { |
| 153 OmniboxResultView* result = result_view_at(line); | 148 OmniboxResultView* result = result_view_at(line); |
| 154 result->Invalidate(); | 149 result->Invalidate(); |
| 150 result->SchedulePaint(); |
| 155 | 151 |
| 156 if (HasMatchAt(line) && GetMatchAtIndex(line).associated_keyword.get()) { | 152 if (HasMatchAt(line) && GetMatchAtIndex(line).associated_keyword.get()) { |
| 157 result->ShowKeyword(IsSelectedIndex(line) && | 153 result->ShowKeyword(IsSelectedIndex(line) && |
| 158 model_->selected_line_state() == OmniboxPopupModel::KEYWORD); | 154 model_->selected_line_state() == OmniboxPopupModel::KEYWORD); |
| 159 } | 155 } |
| 160 } | 156 } |
| 161 | 157 |
| 162 void OmniboxPopupContentsView::OnLineSelected(size_t line) { | 158 void OmniboxPopupContentsView::OnLineSelected(size_t line) { |
| 163 result_view_at(line)->OnSelected(); | 159 result_view_at(line)->OnSelected(); |
| 164 } | 160 } |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 size_t index = GetIndexForPoint(event.location()); | 524 size_t index = GetIndexForPoint(event.location()); |
| 529 if (!HasMatchAt(index)) | 525 if (!HasMatchAt(index)) |
| 530 return; | 526 return; |
| 531 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition, | 527 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition, |
| 532 GURL(), base::string16(), index); | 528 GURL(), base::string16(), index); |
| 533 } | 529 } |
| 534 | 530 |
| 535 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) { | 531 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) { |
| 536 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i))); | 532 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i))); |
| 537 } | 533 } |
| OLD | NEW |