OLD | NEW |
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 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 } | 145 } |
146 } | 146 } |
147 | 147 |
148 bool CanCoalesce(const WebGestureEvent& event_to_coalesce, | 148 bool CanCoalesce(const WebGestureEvent& event_to_coalesce, |
149 const WebGestureEvent& event) { | 149 const WebGestureEvent& event) { |
150 if (event.type != event_to_coalesce.type || | 150 if (event.type != event_to_coalesce.type || |
151 event.sourceDevice != event_to_coalesce.sourceDevice || | 151 event.sourceDevice != event_to_coalesce.sourceDevice || |
152 event.modifiers != event_to_coalesce.modifiers) | 152 event.modifiers != event_to_coalesce.modifiers) |
153 return false; | 153 return false; |
154 | 154 |
155 if (event.type == WebInputEvent::GestureScrollUpdate) | 155 if (event.type == WebInputEvent::GestureScrollUpdate || |
| 156 event.type == WebInputEvent::GestureScrollUpdateWithoutPropagation) |
156 return true; | 157 return true; |
157 | 158 |
158 // GesturePinchUpdate scales can be combined only if they share a focal point, | 159 // GesturePinchUpdate scales can be combined only if they share a focal point, |
159 // e.g., with double-tap drag zoom. | 160 // e.g., with double-tap drag zoom. |
160 if (event.type == WebInputEvent::GesturePinchUpdate && | 161 if (event.type == WebInputEvent::GesturePinchUpdate && |
161 event.x == event_to_coalesce.x && | 162 event.x == event_to_coalesce.x && |
162 event.y == event_to_coalesce.y) | 163 event.y == event_to_coalesce.y) |
163 return true; | 164 return true; |
164 | 165 |
165 return false; | 166 return false; |
166 } | 167 } |
167 | 168 |
168 void Coalesce(const WebGestureEvent& event_to_coalesce, | 169 void Coalesce(const WebGestureEvent& event_to_coalesce, |
169 WebGestureEvent* event) { | 170 WebGestureEvent* event) { |
170 DCHECK(CanCoalesce(event_to_coalesce, *event)); | 171 DCHECK(CanCoalesce(event_to_coalesce, *event)); |
171 if (event->type == WebInputEvent::GestureScrollUpdate) { | 172 if (event->type == WebInputEvent::GestureScrollUpdate || |
| 173 event->type == WebInputEvent::GestureScrollUpdateWithoutPropagation) { |
172 event->data.scrollUpdate.deltaX += | 174 event->data.scrollUpdate.deltaX += |
173 event_to_coalesce.data.scrollUpdate.deltaX; | 175 event_to_coalesce.data.scrollUpdate.deltaX; |
174 event->data.scrollUpdate.deltaY += | 176 event->data.scrollUpdate.deltaY += |
175 event_to_coalesce.data.scrollUpdate.deltaY; | 177 event_to_coalesce.data.scrollUpdate.deltaY; |
176 } else if (event->type == WebInputEvent::GesturePinchUpdate) { | 178 } else if (event->type == WebInputEvent::GesturePinchUpdate) { |
177 event->data.pinchUpdate.scale *= event_to_coalesce.data.pinchUpdate.scale; | 179 event->data.pinchUpdate.scale *= event_to_coalesce.data.pinchUpdate.scale; |
178 // Ensure the scale remains bounded above 0 and below Infinity so that | 180 // Ensure the scale remains bounded above 0 and below Infinity so that |
179 // we can reliably perform operations like log on the values. | 181 // we can reliably perform operations like log on the values. |
180 if (event->data.pinchUpdate.scale < numeric_limits<float>::min()) | 182 if (event->data.pinchUpdate.scale < numeric_limits<float>::min()) |
181 event->data.pinchUpdate.scale = numeric_limits<float>::min(); | 183 event->data.pinchUpdate.scale = numeric_limits<float>::min(); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 CASE_TYPE(MouseLeave); | 272 CASE_TYPE(MouseLeave); |
271 CASE_TYPE(ContextMenu); | 273 CASE_TYPE(ContextMenu); |
272 CASE_TYPE(MouseWheel); | 274 CASE_TYPE(MouseWheel); |
273 CASE_TYPE(RawKeyDown); | 275 CASE_TYPE(RawKeyDown); |
274 CASE_TYPE(KeyDown); | 276 CASE_TYPE(KeyDown); |
275 CASE_TYPE(KeyUp); | 277 CASE_TYPE(KeyUp); |
276 CASE_TYPE(Char); | 278 CASE_TYPE(Char); |
277 CASE_TYPE(GestureScrollBegin); | 279 CASE_TYPE(GestureScrollBegin); |
278 CASE_TYPE(GestureScrollEnd); | 280 CASE_TYPE(GestureScrollEnd); |
279 CASE_TYPE(GestureScrollUpdate); | 281 CASE_TYPE(GestureScrollUpdate); |
| 282 CASE_TYPE(GestureScrollUpdateWithoutPropagation); |
280 CASE_TYPE(GestureFlingStart); | 283 CASE_TYPE(GestureFlingStart); |
281 CASE_TYPE(GestureFlingCancel); | 284 CASE_TYPE(GestureFlingCancel); |
282 CASE_TYPE(GestureShowPress); | 285 CASE_TYPE(GestureShowPress); |
283 CASE_TYPE(GestureTap); | 286 CASE_TYPE(GestureTap); |
284 CASE_TYPE(GestureTapUnconfirmed); | 287 CASE_TYPE(GestureTapUnconfirmed); |
285 CASE_TYPE(GestureTapDown); | 288 CASE_TYPE(GestureTapDown); |
286 CASE_TYPE(GestureTapCancel); | 289 CASE_TYPE(GestureTapCancel); |
287 CASE_TYPE(GestureDoubleTap); | 290 CASE_TYPE(GestureDoubleTap); |
288 CASE_TYPE(GestureTwoFingerTap); | 291 CASE_TYPE(GestureTwoFingerTap); |
289 CASE_TYPE(GestureLongPress); | 292 CASE_TYPE(GestureLongPress); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 case WebInputEvent::TouchStart: | 365 case WebInputEvent::TouchStart: |
363 case WebInputEvent::TouchMove: | 366 case WebInputEvent::TouchMove: |
364 case WebInputEvent::TouchEnd: | 367 case WebInputEvent::TouchEnd: |
365 return !static_cast<const WebTouchEvent&>(event).cancelable; | 368 return !static_cast<const WebTouchEvent&>(event).cancelable; |
366 default: | 369 default: |
367 return false; | 370 return false; |
368 } | 371 } |
369 } | 372 } |
370 | 373 |
371 } // namespace content | 374 } // namespace content |
OLD | NEW |