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" |
| 11 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 11 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
| 12 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 12 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 13 #include "chrome/browser/ui/views/omnibox/omnibox_result_view.h" | 13 #include "chrome/browser/ui/views/omnibox/omnibox_result_view.h" |
| 14 #include "components/omnibox/omnibox_field_trial.h" | |
| 14 #include "ui/base/theme_provider.h" | 15 #include "ui/base/theme_provider.h" |
| 15 #include "ui/gfx/canvas.h" | 16 #include "ui/gfx/canvas.h" |
| 16 #include "ui/gfx/image/image.h" | 17 #include "ui/gfx/image/image.h" |
| 17 #include "ui/gfx/path.h" | 18 #include "ui/gfx/path.h" |
| 18 #include "ui/resources/grit/ui_resources.h" | 19 #include "ui/resources/grit/ui_resources.h" |
| 19 #include "ui/views/controls/image_view.h" | 20 #include "ui/views/controls/image_view.h" |
| 20 #include "ui/views/view_targeter.h" | 21 #include "ui/views/view_targeter.h" |
| 21 #include "ui/views/widget/widget.h" | 22 #include "ui/views/widget/widget.h" |
| 22 #include "ui/views/window/non_client_view.h" | 23 #include "ui/views/window/non_client_view.h" |
| 23 | 24 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 OmniboxEditModel* edit_model, | 62 OmniboxEditModel* edit_model, |
| 62 LocationBarView* location_bar_view) | 63 LocationBarView* location_bar_view) |
| 63 : model_(new OmniboxPopupModel(this, edit_model)), | 64 : model_(new OmniboxPopupModel(this, edit_model)), |
| 64 omnibox_view_(omnibox_view), | 65 omnibox_view_(omnibox_view), |
| 65 location_bar_view_(location_bar_view), | 66 location_bar_view_(location_bar_view), |
| 66 font_list_(font_list), | 67 font_list_(font_list), |
| 67 ignore_mouse_drag_(false), | 68 ignore_mouse_drag_(false), |
| 68 size_animation_(this), | 69 size_animation_(this), |
| 69 left_margin_(0), | 70 left_margin_(0), |
| 70 right_margin_(0), | 71 right_margin_(0), |
| 71 outside_vertical_padding_(0) { | 72 outside_vertical_padding_(0) { |
|
Peter Kasting
2015/03/17 23:18:06
I meant for you to entirely remove this member var
dschuyler
2015/03/18 00:13:36
Sorry, I hurried.
Done.
| |
| 72 // The contents is owned by the LocationBarView. | 73 // The contents is owned by the LocationBarView. |
| 73 set_owned_by_client(); | 74 set_owned_by_client(); |
| 74 | 75 |
| 75 ui::ThemeProvider* theme = location_bar_view_->GetThemeProvider(); | 76 ui::ThemeProvider* theme = location_bar_view_->GetThemeProvider(); |
| 76 bottom_shadow_ = theme->GetImageSkiaNamed(IDR_BUBBLE_B); | 77 bottom_shadow_ = theme->GetImageSkiaNamed(IDR_BUBBLE_B); |
| 77 | 78 |
| 78 SetEventTargeter( | 79 SetEventTargeter( |
| 79 scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(this))); | 80 scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(this))); |
| 80 } | 81 } |
| 81 | 82 |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 381 DCHECK_GE(static_cast<size_t>(child_count()), model_->result().size()); | 382 DCHECK_GE(static_cast<size_t>(child_count()), model_->result().size()); |
| 382 int popup_height = 0; | 383 int popup_height = 0; |
| 383 for (size_t i = model_->result().ShouldHideTopMatch() ? 1 : 0; | 384 for (size_t i = model_->result().ShouldHideTopMatch() ? 1 : 0; |
| 384 i < model_->result().size(); ++i) | 385 i < model_->result().size(); ++i) |
| 385 popup_height += child_at(i)->GetPreferredSize().height(); | 386 popup_height += child_at(i)->GetPreferredSize().height(); |
| 386 | 387 |
| 387 // Add enough space on the top and bottom so it looks like there is the same | 388 // Add enough space on the top and bottom so it looks like there is the same |
| 388 // amount of space between the text and the popup border as there is in the | 389 // amount of space between the text and the popup border as there is in the |
| 389 // interior between each row of text. | 390 // interior between each row of text. |
| 390 // | 391 // |
| 391 // Discovering the exact amount of leading and padding around the font is | 392 // The * 2 accounts for vertical padding used at the top and bottom. |
| 392 // a bit tricky and platform-specific, but this computation seems to work in | |
| 393 // practice. | |
| 394 OmniboxResultView* result_view = result_view_at(0); | |
| 395 outside_vertical_padding_ = | |
| 396 (result_view->GetPreferredSize().height() - | |
| 397 result_view->GetTextHeight()); | |
| 398 | |
| 399 return popup_height + | 393 return popup_height + |
| 400 views::NonClientFrameView::kClientEdgeThickness + // Top border. | 394 views::NonClientFrameView::kClientEdgeThickness + // Top border. |
| 401 outside_vertical_padding_ * 2 + // Padding. | 395 OmniboxResultView::kMinimumTextVerticalPadding * 2 + // Padding. |
| 402 bottom_shadow_->height() - kBorderInterior; // Bottom border. | 396 bottom_shadow_->height() - kBorderInterior; // Bottom border. |
| 403 } | 397 } |
| 404 | 398 |
| 405 OmniboxResultView* OmniboxPopupContentsView::CreateResultView( | 399 OmniboxResultView* OmniboxPopupContentsView::CreateResultView( |
| 406 int model_index, | 400 int model_index, |
| 407 const gfx::FontList& font_list) { | 401 const gfx::FontList& font_list) { |
| 408 return new OmniboxResultView(this, model_index, location_bar_view_, | 402 return new OmniboxResultView(this, model_index, location_bar_view_, |
| 409 font_list); | 403 font_list); |
| 410 } | 404 } |
| 411 | 405 |
| 412 //////////////////////////////////////////////////////////////////////////////// | 406 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 507 size_t index = GetIndexForPoint(event.location()); | 501 size_t index = GetIndexForPoint(event.location()); |
| 508 if (!HasMatchAt(index)) | 502 if (!HasMatchAt(index)) |
| 509 return; | 503 return; |
| 510 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition, | 504 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition, |
| 511 GURL(), base::string16(), index); | 505 GURL(), base::string16(), index); |
| 512 } | 506 } |
| 513 | 507 |
| 514 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) { | 508 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) { |
| 515 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i))); | 509 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i))); |
| 516 } | 510 } |
| OLD | NEW |