| 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 } | 258 } |
| 259 | 259 |
| 260 void Coalesce(const WebGestureEvent& event_to_coalesce, | 260 void Coalesce(const WebGestureEvent& event_to_coalesce, |
| 261 WebGestureEvent* event) { | 261 WebGestureEvent* event) { |
| 262 DCHECK(CanCoalesce(event_to_coalesce, *event)); | 262 DCHECK(CanCoalesce(event_to_coalesce, *event)); |
| 263 if (event->type == WebInputEvent::GestureScrollUpdate) { | 263 if (event->type == WebInputEvent::GestureScrollUpdate) { |
| 264 event->data.scrollUpdate.deltaX += | 264 event->data.scrollUpdate.deltaX += |
| 265 event_to_coalesce.data.scrollUpdate.deltaX; | 265 event_to_coalesce.data.scrollUpdate.deltaX; |
| 266 event->data.scrollUpdate.deltaY += | 266 event->data.scrollUpdate.deltaY += |
| 267 event_to_coalesce.data.scrollUpdate.deltaY; | 267 event_to_coalesce.data.scrollUpdate.deltaY; |
| 268 DCHECK_EQ( |
| 269 event->data.scrollUpdate.previousUpdateInSequencePrevented, |
| 270 event_to_coalesce.data.scrollUpdate.previousUpdateInSequencePrevented); |
| 268 } else if (event->type == WebInputEvent::GesturePinchUpdate) { | 271 } else if (event->type == WebInputEvent::GesturePinchUpdate) { |
| 269 event->data.pinchUpdate.scale *= event_to_coalesce.data.pinchUpdate.scale; | 272 event->data.pinchUpdate.scale *= event_to_coalesce.data.pinchUpdate.scale; |
| 270 // Ensure the scale remains bounded above 0 and below Infinity so that | 273 // Ensure the scale remains bounded above 0 and below Infinity so that |
| 271 // we can reliably perform operations like log on the values. | 274 // we can reliably perform operations like log on the values. |
| 272 if (event->data.pinchUpdate.scale < numeric_limits<float>::min()) | 275 if (event->data.pinchUpdate.scale < numeric_limits<float>::min()) |
| 273 event->data.pinchUpdate.scale = numeric_limits<float>::min(); | 276 event->data.pinchUpdate.scale = numeric_limits<float>::min(); |
| 274 else if (event->data.pinchUpdate.scale > numeric_limits<float>::max()) | 277 else if (event->data.pinchUpdate.scale > numeric_limits<float>::max()) |
| 275 event->data.pinchUpdate.scale = numeric_limits<float>::max(); | 278 event->data.pinchUpdate.scale = numeric_limits<float>::max(); |
| 276 } | 279 } |
| 277 } | 280 } |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 case WebInputEvent::TouchStart: | 476 case WebInputEvent::TouchStart: |
| 474 case WebInputEvent::TouchMove: | 477 case WebInputEvent::TouchMove: |
| 475 case WebInputEvent::TouchEnd: | 478 case WebInputEvent::TouchEnd: |
| 476 return !static_cast<const WebTouchEvent&>(event).cancelable; | 479 return !static_cast<const WebTouchEvent&>(event).cancelable; |
| 477 default: | 480 default: |
| 478 return false; | 481 return false; |
| 479 } | 482 } |
| 480 } | 483 } |
| 481 | 484 |
| 482 } // namespace content | 485 } // namespace content |
| OLD | NEW |