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

Side by Side Diff: chrome/browser/ui/views/autofill/autofill_popup_base_view.cc

Issue 139983009: ui::LocatedEvent location() returns gfx::PointF (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Undo accidental change. Created 6 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/autofill/autofill_popup_base_view.h" 5 #include "chrome/browser/ui/views/autofill/autofill_popup_base_view.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "chrome/browser/ui/autofill/popup_constants.h" 10 #include "chrome/browser/ui/autofill/popup_constants.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 const gfx::Rect& new_bounds) { 118 const gfx::Rect& new_bounds) {
119 DCHECK_EQ(widget, observing_widget_); 119 DCHECK_EQ(widget, observing_widget_);
120 HideController(); 120 HideController();
121 } 121 }
122 122
123 void AutofillPopupBaseView::OnMouseCaptureLost() { 123 void AutofillPopupBaseView::OnMouseCaptureLost() {
124 ClearSelection(); 124 ClearSelection();
125 } 125 }
126 126
127 bool AutofillPopupBaseView::OnMouseDragged(const ui::MouseEvent& event) { 127 bool AutofillPopupBaseView::OnMouseDragged(const ui::MouseEvent& event) {
128 if (HitTestPoint(event.location())) { 128 if (HitTestPoint(gfx::ToFlooredPoint(event.location()))) {
129 SetSelection(event.location()); 129 SetSelection(gfx::ToFlooredPoint(event.location()));
130 130
131 // We must return true in order to get future OnMouseDragged and 131 // We must return true in order to get future OnMouseDragged and
132 // OnMouseReleased events. 132 // OnMouseReleased events.
133 return true; 133 return true;
134 } 134 }
135 135
136 // If we move off of the popup, we lose the selection. 136 // If we move off of the popup, we lose the selection.
137 ClearSelection(); 137 ClearSelection();
138 return false; 138 return false;
139 } 139 }
140 140
141 void AutofillPopupBaseView::OnMouseExited(const ui::MouseEvent& event) { 141 void AutofillPopupBaseView::OnMouseExited(const ui::MouseEvent& event) {
142 // Pressing return causes the cursor to hide, which will generate an 142 // Pressing return causes the cursor to hide, which will generate an
143 // OnMouseExited event. Pressing return should activate the current selection 143 // OnMouseExited event. Pressing return should activate the current selection
144 // via AcceleratorPressed, so we need to let that run first. 144 // via AcceleratorPressed, so we need to let that run first.
145 base::MessageLoop::current()->PostTask( 145 base::MessageLoop::current()->PostTask(
146 FROM_HERE, 146 FROM_HERE,
147 base::Bind(&AutofillPopupBaseView::ClearSelection, 147 base::Bind(&AutofillPopupBaseView::ClearSelection,
148 weak_ptr_factory_.GetWeakPtr())); 148 weak_ptr_factory_.GetWeakPtr()));
149 } 149 }
150 150
151 void AutofillPopupBaseView::OnMouseMoved(const ui::MouseEvent& event) { 151 void AutofillPopupBaseView::OnMouseMoved(const ui::MouseEvent& event) {
152 if (HitTestPoint(event.location())) 152 if (HitTestPoint(gfx::ToFlooredPoint(event.location())))
153 SetSelection(event.location()); 153 SetSelection(gfx::ToFlooredPoint(event.location()));
154 else 154 else
155 ClearSelection(); 155 ClearSelection();
156 } 156 }
157 157
158 bool AutofillPopupBaseView::OnMousePressed(const ui::MouseEvent& event) { 158 bool AutofillPopupBaseView::OnMousePressed(const ui::MouseEvent& event) {
159 return true; 159 return true;
160 } 160 }
161 161
162 void AutofillPopupBaseView::OnMouseReleased(const ui::MouseEvent& event) { 162 void AutofillPopupBaseView::OnMouseReleased(const ui::MouseEvent& event) {
163 // We only care about the left click. 163 // We only care about the left click.
164 if (event.IsOnlyLeftMouseButton() && HitTestPoint(event.location())) 164 if (event.IsOnlyLeftMouseButton() &&
165 AcceptSelection(event.location()); 165 HitTestPoint(gfx::ToFlooredPoint(event.location())))
166 AcceptSelection(gfx::ToFlooredPoint(event.location()));
166 } 167 }
167 168
168 void AutofillPopupBaseView::OnGestureEvent(ui::GestureEvent* event) { 169 void AutofillPopupBaseView::OnGestureEvent(ui::GestureEvent* event) {
169 switch (event->type()) { 170 switch (event->type()) {
170 case ui::ET_GESTURE_TAP_DOWN: 171 case ui::ET_GESTURE_TAP_DOWN:
171 case ui::ET_GESTURE_SCROLL_BEGIN: 172 case ui::ET_GESTURE_SCROLL_BEGIN:
172 case ui::ET_GESTURE_SCROLL_UPDATE: 173 case ui::ET_GESTURE_SCROLL_UPDATE:
173 if (HitTestPoint(event->location())) 174 if (HitTestPoint(gfx::ToFlooredPoint(event->location())))
174 SetSelection(event->location()); 175 SetSelection(gfx::ToFlooredPoint(event->location()));
175 else 176 else
176 ClearSelection(); 177 ClearSelection();
177 break; 178 break;
178 case ui::ET_GESTURE_TAP: 179 case ui::ET_GESTURE_TAP:
179 case ui::ET_GESTURE_SCROLL_END: 180 case ui::ET_GESTURE_SCROLL_END:
180 if (HitTestPoint(event->location())) 181 if (HitTestPoint(gfx::ToFlooredPoint(event->location())))
181 AcceptSelection(event->location()); 182 AcceptSelection(gfx::ToFlooredPoint(event->location()));
182 else 183 else
183 ClearSelection(); 184 ClearSelection();
184 break; 185 break;
185 case ui::ET_GESTURE_TAP_CANCEL: 186 case ui::ET_GESTURE_TAP_CANCEL:
186 case ui::ET_SCROLL_FLING_START: 187 case ui::ET_SCROLL_FLING_START:
187 ClearSelection(); 188 ClearSelection();
188 break; 189 break;
189 default: 190 default:
190 return; 191 return;
191 } 192 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 if (delegate_) 231 if (delegate_)
231 delegate_->Hide(); 232 delegate_->Hide();
232 } 233 }
233 234
234 gfx::NativeView AutofillPopupBaseView::container_view() { 235 gfx::NativeView AutofillPopupBaseView::container_view() {
235 return delegate_->container_view(); 236 return delegate_->container_view();
236 } 237 }
237 238
238 239
239 } // namespace autofill 240 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698