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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 size_animation_(this), | 65 size_animation_(this), |
| 66 start_margin_(0), | 66 start_margin_(0), |
| 67 end_margin_(0) { | 67 end_margin_(0) { |
| 68 // The contents is owned by the LocationBarView. | 68 // The contents is owned by the LocationBarView. |
| 69 set_owned_by_client(); | 69 set_owned_by_client(); |
| 70 | 70 |
| 71 ui::ThemeProvider* theme = location_bar_view_->GetThemeProvider(); | 71 ui::ThemeProvider* theme = location_bar_view_->GetThemeProvider(); |
| 72 int bottom_shadow_asset = ui::MaterialDesignController::IsModeMaterial() ? | 72 int bottom_shadow_asset = ui::MaterialDesignController::IsModeMaterial() ? |
| 73 IDR_OMNIBOX_DROPDOWN_SHADOW_BOTTOM : IDR_BUBBLE_B; | 73 IDR_OMNIBOX_DROPDOWN_SHADOW_BOTTOM : IDR_BUBBLE_B; |
| 74 bottom_shadow_ = theme->GetImageSkiaNamed(bottom_shadow_asset); | 74 bottom_shadow_ = theme->GetImageSkiaNamed(bottom_shadow_asset); |
| 75 top_shadow_ = theme->GetImageSkiaNamed(IDR_OMNIBOX_DROPDOWN_SHADOW_TOP); | |
| 75 | 76 |
| 76 SetEventTargeter( | 77 SetEventTargeter( |
| 77 scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(this))); | 78 scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(this))); |
| 78 } | 79 } |
| 79 | 80 |
| 80 void OmniboxPopupContentsView::Init() { | 81 void OmniboxPopupContentsView::Init() { |
| 81 // This can't be done in the constructor as at that point we aren't | 82 // This can't be done in the constructor as at that point we aren't |
| 82 // necessarily our final class yet, and we may have subclasses | 83 // necessarily our final class yet, and we may have subclasses |
| 83 // overriding CreateResultView. | 84 // overriding CreateResultView. |
| 84 for (size_t i = 0; i < AutocompleteResult::kMaxMatches; ++i) { | 85 for (size_t i = 0; i < AutocompleteResult::kMaxMatches; ++i) { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 } | 188 } |
| 188 if (match.type == AutocompleteMatchType::SEARCH_SUGGEST_TAIL) { | 189 if (match.type == AutocompleteMatchType::SEARCH_SUGGEST_TAIL) { |
| 189 max_match_contents_width_ = std::max( | 190 max_match_contents_width_ = std::max( |
| 190 max_match_contents_width_, view->GetMatchContentsWidth()); | 191 max_match_contents_width_, view->GetMatchContentsWidth()); |
| 191 } | 192 } |
| 192 } | 193 } |
| 193 | 194 |
| 194 for (size_t i = result_size; i < AutocompleteResult::kMaxMatches; ++i) | 195 for (size_t i = result_size; i < AutocompleteResult::kMaxMatches; ++i) |
| 195 child_at(i)->SetVisible(false); | 196 child_at(i)->SetVisible(false); |
| 196 | 197 |
| 198 // The additional overlap is needed for material design so that the content | |
| 199 // separator beneath the toolbar is not visible underneath the transparent | |
| 200 // shadow asset. | |
| 201 int top_edge_overlap = views::NonClientFrameView::kClientEdgeThickness; | |
| 202 if (ui::MaterialDesignController::IsModeMaterial()) | |
| 203 top_edge_overlap += top_shadow_->height(); | |
|
Peter Kasting
2015/08/27 19:05:04
This looks wrong from the way you write the code;
tdanderson
2015/08/27 19:47:20
If the material value is just the top shadow heigh
Peter Kasting
2015/08/27 19:54:09
I looked at your screenshots and I can't see what
| |
| 204 | |
| 197 gfx::Point top_left_screen_coord; | 205 gfx::Point top_left_screen_coord; |
| 198 int width; | 206 int width; |
| 199 location_bar_view_->GetOmniboxPopupPositioningInfo( | 207 location_bar_view_->GetOmniboxPopupPositioningInfo( |
| 200 &top_left_screen_coord, &width, &start_margin_, &end_margin_); | 208 &top_left_screen_coord, &width, &start_margin_, |
| 209 &end_margin_, top_edge_overlap); | |
| 201 gfx::Rect new_target_bounds(top_left_screen_coord, | 210 gfx::Rect new_target_bounds(top_left_screen_coord, |
| 202 gfx::Size(width, CalculatePopupHeight())); | 211 gfx::Size(width, CalculatePopupHeight())); |
| 203 | 212 |
| 204 // If we're animating and our target height changes, reset the animation. | 213 // If we're animating and our target height changes, reset the animation. |
| 205 // NOTE: If we just reset blindly on _every_ update, then when the user types | 214 // NOTE: If we just reset blindly on _every_ update, then when the user types |
| 206 // rapidly we could get "stuck" trying repeatedly to animate shrinking by the | 215 // rapidly we could get "stuck" trying repeatedly to animate shrinking by the |
| 207 // last few pixels to get to one visible result. | 216 // last few pixels to get to one visible result. |
| 208 if (new_target_bounds.height() != target_bounds_.height()) | 217 if (new_target_bounds.height() != target_bounds_.height()) |
| 209 size_animation_.Reset(); | 218 size_animation_.Reset(); |
| 210 target_bounds_ = new_target_bounds; | 219 target_bounds_ = new_target_bounds; |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 424 | 433 |
| 425 //////////////////////////////////////////////////////////////////////////////// | 434 //////////////////////////////////////////////////////////////////////////////// |
| 426 // OmniboxPopupContentsView, views::View overrides, private: | 435 // OmniboxPopupContentsView, views::View overrides, private: |
| 427 | 436 |
| 428 const char* OmniboxPopupContentsView::GetClassName() const { | 437 const char* OmniboxPopupContentsView::GetClassName() const { |
| 429 return "OmniboxPopupContentsView"; | 438 return "OmniboxPopupContentsView"; |
| 430 } | 439 } |
| 431 | 440 |
| 432 void OmniboxPopupContentsView::OnPaint(gfx::Canvas* canvas) { | 441 void OmniboxPopupContentsView::OnPaint(gfx::Canvas* canvas) { |
| 433 // Top border. | 442 // Top border. |
| 434 canvas->FillRect( | 443 if (ui::MaterialDesignController::IsModeMaterial()) { |
| 435 gfx::Rect(0, 0, width(), views::NonClientFrameView::kClientEdgeThickness), | 444 canvas->TileImageInt(*top_shadow_, 0, 0, width(), top_shadow_->height()); |
| 436 ThemeProperties::GetDefaultColor( | 445 } else { |
| 437 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); | 446 canvas->FillRect( |
| 447 gfx::Rect(0, 0, width(), | |
| 448 views::NonClientFrameView::kClientEdgeThickness), | |
| 449 ThemeProperties::GetDefaultColor( | |
| 450 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); | |
| 451 } | |
| 438 | 452 |
| 439 // Bottom border. | 453 // Bottom border. |
| 440 canvas->TileImageInt(*bottom_shadow_, 0, height() - bottom_shadow_->height(), | 454 canvas->TileImageInt(*bottom_shadow_, 0, height() - bottom_shadow_->height(), |
| 441 width(), bottom_shadow_->height()); | 455 width(), bottom_shadow_->height()); |
| 442 } | 456 } |
| 443 | 457 |
| 444 void OmniboxPopupContentsView::PaintChildren(const ui::PaintContext& context) { | 458 void OmniboxPopupContentsView::PaintChildren(const ui::PaintContext& context) { |
| 445 gfx::Rect contents_bounds = GetContentsBounds(); | 459 gfx::Rect contents_bounds = GetContentsBounds(); |
| 446 ui::ThemeProvider* theme_provider = location_bar_view_->GetThemeProvider(); | 460 ui::ThemeProvider* theme_provider = location_bar_view_->GetThemeProvider(); |
| 447 const int border_interior = theme_provider->GetDisplayProperty( | 461 const int border_interior = theme_provider->GetDisplayProperty( |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 511 size_t index = GetIndexForPoint(event.location()); | 525 size_t index = GetIndexForPoint(event.location()); |
| 512 if (!HasMatchAt(index)) | 526 if (!HasMatchAt(index)) |
| 513 return; | 527 return; |
| 514 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition, | 528 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition, |
| 515 GURL(), base::string16(), index); | 529 GURL(), base::string16(), index); |
| 516 } | 530 } |
| 517 | 531 |
| 518 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) { | 532 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) { |
| 519 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i))); | 533 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i))); |
| 520 } | 534 } |
| OLD | NEW |