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

Side by Side Diff: content/common/input/web_input_event_traits.cc

Issue 200623003: Adopt "QuickScale" double-tap drag zoom code in the GestureProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment Created 6 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/common/input/web_input_event_traits.h" 5 #include "content/common/input/web_input_event_traits.h"
6 6
7 #include <bitset> 7 #include <bitset>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 *event = event_to_coalesce; 138 *event = event_to_coalesce;
139 for (unsigned i = 0; i < event->touchesLength; ++i) { 139 for (unsigned i = 0; i < event->touchesLength; ++i) {
140 int i_old = GetIndexOfTouchID(old_event, event->touches[i].id); 140 int i_old = GetIndexOfTouchID(old_event, event->touches[i].id);
141 if (old_event.touches[i_old].state == blink::WebTouchPoint::StateMoved) 141 if (old_event.touches[i_old].state == blink::WebTouchPoint::StateMoved)
142 event->touches[i].state = blink::WebTouchPoint::StateMoved; 142 event->touches[i].state = blink::WebTouchPoint::StateMoved;
143 } 143 }
144 } 144 }
145 145
146 bool CanCoalesce(const WebGestureEvent& event_to_coalesce, 146 bool CanCoalesce(const WebGestureEvent& event_to_coalesce,
147 const WebGestureEvent& event) { 147 const WebGestureEvent& event) {
148 return event.type == event_to_coalesce.type && 148 if (event.type != event_to_coalesce.type ||
149 event.type == WebInputEvent::GestureScrollUpdate && 149 event.sourceDevice != event_to_coalesce.sourceDevice ||
150 event.sourceDevice == event_to_coalesce.sourceDevice && 150 event.modifiers != event_to_coalesce.modifiers)
151 event.modifiers == event_to_coalesce.modifiers; 151 return false;
152
153 if (event.type == WebInputEvent::GestureScrollUpdate)
154 return true;
155
156 if (event.type == WebInputEvent::GesturePinchUpdate &&
tdresser 2014/04/03 17:53:30 Can you add a comment explaining why the co-ordina
jdduke (slow) 2014/04/03 19:28:01 Done.
157 event.x == event_to_coalesce.x &&
158 event.y == event_to_coalesce.y)
159 return true;
160
161 return false;
152 } 162 }
153 163
154 void Coalesce(const WebGestureEvent& event_to_coalesce, 164 void Coalesce(const WebGestureEvent& event_to_coalesce,
155 WebGestureEvent* event) { 165 WebGestureEvent* event) {
156 DCHECK(CanCoalesce(event_to_coalesce, *event)); 166 DCHECK(CanCoalesce(event_to_coalesce, *event));
157 event->data.scrollUpdate.deltaX += event_to_coalesce.data.scrollUpdate.deltaX; 167 if (event->type == WebInputEvent::GestureScrollUpdate) {
158 event->data.scrollUpdate.deltaY += event_to_coalesce.data.scrollUpdate.deltaY; 168 event->data.scrollUpdate.deltaX +=
169 event_to_coalesce.data.scrollUpdate.deltaX;
170 event->data.scrollUpdate.deltaY +=
171 event_to_coalesce.data.scrollUpdate.deltaY;
172 } else if (event->type == WebInputEvent::GesturePinchUpdate) {
173 event->data.pinchUpdate.scale *= event_to_coalesce.data.pinchUpdate.scale;
174 }
159 } 175 }
160 176
161 struct WebInputEventSize { 177 struct WebInputEventSize {
162 template <class EventType> 178 template <class EventType>
163 bool Execute(WebInputEvent::Type /* type */, size_t* type_size) const { 179 bool Execute(WebInputEvent::Type /* type */, size_t* type_size) const {
164 *type_size = sizeof(EventType); 180 *type_size = sizeof(EventType);
165 return true; 181 return true;
166 } 182 }
167 }; 183 };
168 184
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 case WebInputEvent::MouseLeave: 350 case WebInputEvent::MouseLeave:
335 case WebInputEvent::ContextMenu: 351 case WebInputEvent::ContextMenu:
336 return true; 352 return true;
337 default: 353 default:
338 break; 354 break;
339 } 355 }
340 return false; 356 return false;
341 } 357 }
342 358
343 } // namespace content 359 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698