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

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: Add pinch coalesce test 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 // GesturePinchUpdate scales can be cominbed only if they share a focal point,
tdresser 2014/04/03 19:33:48 cominbed.
157 // e.g., with double-tap drag zoom.
158 if (event.type == WebInputEvent::GesturePinchUpdate &&
159 event.x == event_to_coalesce.x &&
160 event.y == event_to_coalesce.y)
161 return true;
162
163 return false;
152 } 164 }
153 165
154 void Coalesce(const WebGestureEvent& event_to_coalesce, 166 void Coalesce(const WebGestureEvent& event_to_coalesce,
155 WebGestureEvent* event) { 167 WebGestureEvent* event) {
156 DCHECK(CanCoalesce(event_to_coalesce, *event)); 168 DCHECK(CanCoalesce(event_to_coalesce, *event));
157 event->data.scrollUpdate.deltaX += event_to_coalesce.data.scrollUpdate.deltaX; 169 if (event->type == WebInputEvent::GestureScrollUpdate) {
158 event->data.scrollUpdate.deltaY += event_to_coalesce.data.scrollUpdate.deltaY; 170 event->data.scrollUpdate.deltaX +=
171 event_to_coalesce.data.scrollUpdate.deltaX;
172 event->data.scrollUpdate.deltaY +=
173 event_to_coalesce.data.scrollUpdate.deltaY;
174 } else if (event->type == WebInputEvent::GesturePinchUpdate) {
175 event->data.pinchUpdate.scale *= event_to_coalesce.data.pinchUpdate.scale;
176 }
159 } 177 }
160 178
161 struct WebInputEventSize { 179 struct WebInputEventSize {
162 template <class EventType> 180 template <class EventType>
163 bool Execute(WebInputEvent::Type /* type */, size_t* type_size) const { 181 bool Execute(WebInputEvent::Type /* type */, size_t* type_size) const {
164 *type_size = sizeof(EventType); 182 *type_size = sizeof(EventType);
165 return true; 183 return true;
166 } 184 }
167 }; 185 };
168 186
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 case WebInputEvent::MouseLeave: 352 case WebInputEvent::MouseLeave:
335 case WebInputEvent::ContextMenu: 353 case WebInputEvent::ContextMenu:
336 return true; 354 return true;
337 default: 355 default:
338 break; 356 break;
339 } 357 }
340 return false; 358 return false;
341 } 359 }
342 360
343 } // namespace content 361 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/input/gesture_event_queue.cc ('k') | content/common/input/web_input_event_traits_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698