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

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

Issue 44543002: Enable touch for autofill popup view (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Improved comments Created 7 years, 1 month 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
« no previous file with comments | « chrome/browser/ui/views/autofill/autofill_popup_view_views.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/autofill/autofill_popup_view_views.h" 5 #include "chrome/browser/ui/views/autofill/autofill_popup_view_views.h"
6 6
7 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" 7 #include "chrome/browser/ui/autofill/autofill_popup_controller.h"
8 #include "grit/ui_resources.h" 8 #include "grit/ui_resources.h"
9 #include "third_party/WebKit/public/web/WebAutofillClient.h" 9 #include "third_party/WebKit/public/web/WebAutofillClient.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 WebAutofillClient::MenuItemIDSeparator) { 82 WebAutofillClient::MenuItemIDSeparator) {
83 canvas->DrawRect(line_rect, kItemTextColor); 83 canvas->DrawRect(line_rect, kItemTextColor);
84 } else { 84 } else {
85 DrawAutofillEntry(canvas, i, line_rect); 85 DrawAutofillEntry(canvas, i, line_rect);
86 } 86 }
87 } 87 }
88 } 88 }
89 89
90 void AutofillPopupViewViews::OnMouseCaptureLost() { 90 void AutofillPopupViewViews::OnMouseCaptureLost() {
91 if (controller_) 91 if (controller_)
92 controller_->MouseExitedPopup(); 92 controller_->SelectionCleared();
93 } 93 }
94 94
95 bool AutofillPopupViewViews::OnMouseDragged(const ui::MouseEvent& event) { 95 bool AutofillPopupViewViews::OnMouseDragged(const ui::MouseEvent& event) {
96 if (!controller_) 96 if (!controller_)
97 return false; 97 return false;
98 98
99 if (HitTestPoint(event.location())) { 99 if (HitTestPoint(event.location())) {
100 controller_->MouseHovered(event.x(), event.y()); 100 controller_->LineSelectedAtPoint(event.x(), event.y());
101 101
102 // We must return true in order to get future OnMouseDragged and 102 // We must return true in order to get future OnMouseDragged and
103 // OnMouseReleased events. 103 // OnMouseReleased events.
104 return true; 104 return true;
105 } 105 }
106 106
107 // If we move off of the popup, we lose the selection. 107 // If we move off of the popup, we lose the selection.
108 controller_->MouseExitedPopup(); 108 controller_->SelectionCleared();
109 return false; 109 return false;
110 } 110 }
111 111
112 void AutofillPopupViewViews::OnMouseExited(const ui::MouseEvent& event) { 112 void AutofillPopupViewViews::OnMouseExited(const ui::MouseEvent& event) {
113 if (controller_) 113 if (controller_)
114 controller_->MouseExitedPopup(); 114 controller_->SelectionCleared();
115 } 115 }
116 116
117 void AutofillPopupViewViews::OnMouseMoved(const ui::MouseEvent& event) { 117 void AutofillPopupViewViews::OnMouseMoved(const ui::MouseEvent& event) {
118 if (!controller_) 118 if (!controller_)
119 return; 119 return;
120 120
121 if (HitTestPoint(event.location())) 121 if (HitTestPoint(event.location()))
122 controller_->MouseHovered(event.x(), event.y()); 122 controller_->LineSelectedAtPoint(event.x(), event.y());
123 else 123 else
124 controller_->MouseExitedPopup(); 124 controller_->SelectionCleared();
125 } 125 }
126 126
127 bool AutofillPopupViewViews::OnMousePressed(const ui::MouseEvent& event) { 127 bool AutofillPopupViewViews::OnMousePressed(const ui::MouseEvent& event) {
128 if (HitTestPoint(event.location())) 128 if (HitTestPoint(event.location()))
129 return true; 129 return true;
130 130
131 if (controller_->hide_on_outside_click()) { 131 if (controller_->hide_on_outside_click()) {
132 GetWidget()->ReleaseCapture(); 132 GetWidget()->ReleaseCapture();
133 133
134 gfx::Point screen_loc = event.location(); 134 gfx::Point screen_loc = event.location();
(...skipping 21 matching lines...) Expand all
156 return; 156 return;
157 157
158 // Because this view can can be shown in response to a mouse press, it can 158 // Because this view can can be shown in response to a mouse press, it can
159 // receive an OnMouseReleased event just after showing. This breaks the mouse 159 // receive an OnMouseReleased event just after showing. This breaks the mouse
160 // capture, so restart capturing here. 160 // capture, so restart capturing here.
161 if (controller_->hide_on_outside_click() && GetWidget()) 161 if (controller_->hide_on_outside_click() && GetWidget())
162 GetWidget()->SetCapture(this); 162 GetWidget()->SetCapture(this);
163 163
164 // We only care about the left click. 164 // We only care about the left click.
165 if (event.IsOnlyLeftMouseButton() && HitTestPoint(event.location())) 165 if (event.IsOnlyLeftMouseButton() && HitTestPoint(event.location()))
166 controller_->MouseClicked(event.x(), event.y()); 166 controller_->LineAcceptedAtPoint(event.x(), event.y());
167 }
168
169 void AutofillPopupViewViews::OnGestureEvent(ui::GestureEvent* event) {
170 if (!controller_)
171 return;
172
173 switch (event->type()) {
174 case ui::ET_GESTURE_TAP_DOWN:
175 case ui::ET_GESTURE_SCROLL_BEGIN:
176 case ui::ET_GESTURE_SCROLL_UPDATE:
177 if (HitTestPoint(event->location()))
178 controller_->LineSelectedAtPoint(event->x(), event->y());
179 else
180 controller_->SelectionCleared();
181 break;
182 case ui::ET_GESTURE_TAP:
183 case ui::ET_GESTURE_SCROLL_END:
184 if (HitTestPoint(event->location()))
185 controller_->LineAcceptedAtPoint(event->x(), event->y());
186 else
187 controller_->SelectionCleared();
188 break;
189 case ui::ET_GESTURE_TAP_CANCEL:
190 case ui::ET_SCROLL_FLING_START:
191 controller_->SelectionCleared();
192 break;
193 default:
194 return;
195 }
196 event->SetHandled();
167 } 197 }
168 198
169 void AutofillPopupViewViews::OnWidgetBoundsChanged( 199 void AutofillPopupViewViews::OnWidgetBoundsChanged(
170 views::Widget* widget, 200 views::Widget* widget,
171 const gfx::Rect& new_bounds) { 201 const gfx::Rect& new_bounds) {
172 DCHECK_EQ(widget, observing_widget_); 202 DCHECK_EQ(widget, observing_widget_);
173 controller_->Hide(); 203 controller_->Hide();
174 } 204 }
175 205
176 void AutofillPopupViewViews::Show() { 206 void AutofillPopupViewViews::Show() {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 312
283 // If the top level widget can't be found, cancel the popup since we can't 313 // If the top level widget can't be found, cancel the popup since we can't
284 // fully set it up. 314 // fully set it up.
285 if (!observing_widget) 315 if (!observing_widget)
286 return NULL; 316 return NULL;
287 317
288 return new AutofillPopupViewViews(controller, observing_widget); 318 return new AutofillPopupViewViews(controller, observing_widget);
289 } 319 }
290 320
291 } // namespace autofill 321 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/autofill/autofill_popup_view_views.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698