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

Side by Side Diff: ui/views/controls/button/button_dropdown.cc

Issue 10827198: Change View::HitTest to View::HitTestRect (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 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
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 "ui/views/controls/button/button_dropdown.h" 5 #include "ui/views/controls/button/button_dropdown.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 return menu_showing_; 51 return menu_showing_;
52 } 52 }
53 53
54 //////////////////////////////////////////////////////////////////////////////// 54 ////////////////////////////////////////////////////////////////////////////////
55 // 55 //
56 // ButtonDropDown - Events 56 // ButtonDropDown - Events
57 // 57 //
58 //////////////////////////////////////////////////////////////////////////////// 58 ////////////////////////////////////////////////////////////////////////////////
59 59
60 bool ButtonDropDown::OnMousePressed(const MouseEvent& event) { 60 bool ButtonDropDown::OnMousePressed(const MouseEvent& event) {
61 if (enabled() && ShouldShowMenu() && 61 if (enabled() &&
62 IsTriggerableEvent(event) && HitTest(event.location())) { 62 ShouldShowMenu() &&
63 IsTriggerableEvent(event) &&
64 HitTest(gfx::Rect(event.location(), gfx::Size(0,0)))) {
63 // Store the y pos of the mouse coordinates so we can use them later to 65 // Store the y pos of the mouse coordinates so we can use them later to
64 // determine if the user dragged the mouse down (which should pop up the 66 // determine if the user dragged the mouse down (which should pop up the
65 // drag down menu immediately, instead of waiting for the timer) 67 // drag down menu immediately, instead of waiting for the timer)
66 y_position_on_lbuttondown_ = event.y(); 68 y_position_on_lbuttondown_ = event.y();
67 69
68 // Schedule a task that will show the menu. 70 // Schedule a task that will show the menu.
69 MessageLoop::current()->PostDelayedTask( 71 MessageLoop::current()->PostDelayedTask(
70 FROM_HERE, 72 FROM_HERE,
71 base::Bind(&ButtonDropDown::ShowDropDownMenu, 73 base::Bind(&ButtonDropDown::ShowDropDownMenu,
72 show_menu_factory_.GetWeakPtr()), 74 show_menu_factory_.GetWeakPtr()),
(...skipping 13 matching lines...) Expand all
86 show_menu_factory_.InvalidateWeakPtrs(); 88 show_menu_factory_.InvalidateWeakPtrs();
87 ShowDropDownMenu(); 89 ShowDropDownMenu();
88 } 90 }
89 } 91 }
90 92
91 return result; 93 return result;
92 } 94 }
93 95
94 void ButtonDropDown::OnMouseReleased(const MouseEvent& event) { 96 void ButtonDropDown::OnMouseReleased(const MouseEvent& event) {
95 if (IsTriggerableEvent(event) || 97 if (IsTriggerableEvent(event) ||
96 (event.IsRightMouseButton() && !HitTest(event.location()))) { 98 (event.IsRightMouseButton() &&
99 !HitTest(gfx::Rect(event.location(), gfx::Size(0, 0))))) {
97 ImageButton::OnMouseReleased(event); 100 ImageButton::OnMouseReleased(event);
98 } 101 }
99 102
100 if (IsTriggerableEvent(event)) 103 if (IsTriggerableEvent(event))
101 show_menu_factory_.InvalidateWeakPtrs(); 104 show_menu_factory_.InvalidateWeakPtrs();
102 105
103 if (enabled() && event.IsRightMouseButton() && HitTest(event.location())) { 106 if (enabled() &&
107 event.IsRightMouseButton() &&
108 HitTest(gfx::Rect(event.location(), gfx::Size(0, 0)))) {
104 show_menu_factory_.InvalidateWeakPtrs(); 109 show_menu_factory_.InvalidateWeakPtrs();
105 ShowDropDownMenu(); 110 ShowDropDownMenu();
106 } 111 }
107 } 112 }
108 113
109 std::string ButtonDropDown::GetClassName() const { 114 std::string ButtonDropDown::GetClassName() const {
110 return kViewClassName; 115 return kViewClassName;
111 } 116 }
112 117
113 void ButtonDropDown::OnMouseExited(const MouseEvent& event) { 118 void ButtonDropDown::OnMouseExited(const MouseEvent& event) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 SetState(BS_NORMAL); 216 SetState(BS_NORMAL);
212 } 217 }
213 218
214 //////////////////////////////////////////////////////////////////////////////// 219 ////////////////////////////////////////////////////////////////////////////////
215 // 220 //
216 // ButtonDropDown - Accessibility 221 // ButtonDropDown - Accessibility
217 // 222 //
218 //////////////////////////////////////////////////////////////////////////////// 223 ////////////////////////////////////////////////////////////////////////////////
219 224
220 } // namespace views 225 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698