Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.cc

Issue 381323002: [rough WIP] Make View::GetEventHandlerForRect() non-virtual (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "grit/ui_resources.h" 14 #include "grit/ui_resources.h"
15 #include "ui/base/theme_provider.h" 15 #include "ui/base/theme_provider.h"
16 #include "ui/gfx/canvas.h" 16 #include "ui/gfx/canvas.h"
17 #include "ui/gfx/image/image.h" 17 #include "ui/gfx/image/image.h"
18 #include "ui/gfx/path.h" 18 #include "ui/gfx/path.h"
19 #include "ui/views/controls/image_view.h" 19 #include "ui/views/controls/image_view.h"
20 #include "ui/views/view_targeter.h"
20 #include "ui/views/widget/widget.h" 21 #include "ui/views/widget/widget.h"
21 #include "ui/views/window/non_client_view.h" 22 #include "ui/views/window/non_client_view.h"
22 #include "ui/wm/core/window_animations.h" 23 #include "ui/wm/core/window_animations.h"
23 24
24 // This is the number of pixels in the border image interior to the actual 25 // This is the number of pixels in the border image interior to the actual
25 // border. 26 // border.
26 const int kBorderInterior = 6; 27 const int kBorderInterior = 6;
27 28
28 class OmniboxPopupContentsView::AutocompletePopupWidget 29 class OmniboxPopupContentsView::AutocompletePopupWidget
29 : public views::Widget, 30 : public views::Widget,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 ignore_mouse_drag_(false), 64 ignore_mouse_drag_(false),
64 size_animation_(this), 65 size_animation_(this),
65 left_margin_(0), 66 left_margin_(0),
66 right_margin_(0), 67 right_margin_(0),
67 outside_vertical_padding_(0) { 68 outside_vertical_padding_(0) {
68 // The contents is owned by the LocationBarView. 69 // The contents is owned by the LocationBarView.
69 set_owned_by_client(); 70 set_owned_by_client();
70 71
71 ui::ThemeProvider* theme = location_bar_view_->GetThemeProvider(); 72 ui::ThemeProvider* theme = location_bar_view_->GetThemeProvider();
72 bottom_shadow_ = theme->GetImageSkiaNamed(IDR_BUBBLE_B); 73 bottom_shadow_ = theme->GetImageSkiaNamed(IDR_BUBBLE_B);
74
75 SetEventTargeter(
76 scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(this)));
73 } 77 }
74 78
75 void OmniboxPopupContentsView::Init() { 79 void OmniboxPopupContentsView::Init() {
76 // This can't be done in the constructor as at that point we aren't 80 // This can't be done in the constructor as at that point we aren't
77 // necessarily our final class yet, and we may have subclasses 81 // necessarily our final class yet, and we may have subclasses
78 // overriding CreateResultView. 82 // overriding CreateResultView.
79 for (size_t i = 0; i < AutocompleteResult::kMaxMatches; ++i) { 83 for (size_t i = 0; i < AutocompleteResult::kMaxMatches; ++i) {
80 OmniboxResultView* result_view = CreateResultView(i, font_list_); 84 OmniboxResultView* result_view = CreateResultView(i, font_list_);
81 result_view->SetVisible(false); 85 result_view->SetVisible(false);
82 AddChildViewAt(result_view, static_cast<int>(i)); 86 AddChildViewAt(result_view, static_cast<int>(i));
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 286
283 void OmniboxPopupContentsView::Layout() { 287 void OmniboxPopupContentsView::Layout() {
284 // Size our children to the available content area. 288 // Size our children to the available content area.
285 LayoutChildren(); 289 LayoutChildren();
286 290
287 // We need to manually schedule a paint here since we are a layered window and 291 // We need to manually schedule a paint here since we are a layered window and
288 // won't implicitly require painting until we ask for one. 292 // won't implicitly require painting until we ask for one.
289 SchedulePaint(); 293 SchedulePaint();
290 } 294 }
291 295
292 views::View* OmniboxPopupContentsView::GetEventHandlerForRect(
293 const gfx::Rect& rect) {
294 return this;
295 }
296
297 views::View* OmniboxPopupContentsView::GetTooltipHandlerForPoint( 296 views::View* OmniboxPopupContentsView::GetTooltipHandlerForPoint(
298 const gfx::Point& point) { 297 const gfx::Point& point) {
299 return NULL; 298 return NULL;
300 } 299 }
301 300
302 bool OmniboxPopupContentsView::OnMousePressed( 301 bool OmniboxPopupContentsView::OnMousePressed(
303 const ui::MouseEvent& event) { 302 const ui::MouseEvent& event) {
304 ignore_mouse_drag_ = false; // See comment on |ignore_mouse_drag_| in header. 303 ignore_mouse_drag_ = false; // See comment on |ignore_mouse_drag_| in header.
305 if (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) 304 if (event.IsLeftMouseButton() || event.IsMiddleMouseButton())
306 UpdateLineEvent(event, event.IsLeftMouseButton()); 305 UpdateLineEvent(event, event.IsLeftMouseButton());
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 } 432 }
434 433
435 void OmniboxPopupContentsView::PaintChildren(gfx::Canvas* canvas, 434 void OmniboxPopupContentsView::PaintChildren(gfx::Canvas* canvas,
436 const views::CullSet& cull_set) { 435 const views::CullSet& cull_set) {
437 // We paint our children inside OnPaint(). 436 // We paint our children inside OnPaint().
438 } 437 }
439 438
440 //////////////////////////////////////////////////////////////////////////////// 439 ////////////////////////////////////////////////////////////////////////////////
441 // OmniboxPopupContentsView, private: 440 // OmniboxPopupContentsView, private:
442 441
442 views::View* OmniboxPopupContentsView::TargetForRect(
443 views::View* root,
444 const gfx::Rect& rect) {
445 CHECK_EQ(root, this);
446 return this;
447 }
448
443 bool OmniboxPopupContentsView::HasMatchAt(size_t index) const { 449 bool OmniboxPopupContentsView::HasMatchAt(size_t index) const {
444 return index < model_->result().size(); 450 return index < model_->result().size();
445 } 451 }
446 452
447 const AutocompleteMatch& OmniboxPopupContentsView::GetMatchAtIndex( 453 const AutocompleteMatch& OmniboxPopupContentsView::GetMatchAtIndex(
448 size_t index) const { 454 size_t index) const {
449 return model_->result().match_at(index); 455 return model_->result().match_at(index);
450 } 456 }
451 457
452 void OmniboxPopupContentsView::MakeContentsPath( 458 void OmniboxPopupContentsView::MakeContentsPath(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 size_t index = GetIndexForPoint(event.location()); 498 size_t index = GetIndexForPoint(event.location());
493 if (!HasMatchAt(index)) 499 if (!HasMatchAt(index))
494 return; 500 return;
495 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition, 501 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition,
496 GURL(), base::string16(), index); 502 GURL(), base::string16(), index);
497 } 503 }
498 504
499 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) { 505 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) {
500 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i))); 506 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i)));
501 } 507 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698