OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser/renderer_host/input/gesture_event_queue.h" | 5 #include "content/browser/renderer_host/input/gesture_event_queue.h" |
6 | 6 |
7 #include "base/trace_event/trace_event.h" | 7 #include "base/trace_event/trace_event.h" |
8 #include "content/browser/renderer_host/input/touchpad_tap_suppression_controlle
r.h" | 8 #include "content/browser/renderer_host/input/touchpad_tap_suppression_controlle
r.h" |
9 #include "content/browser/renderer_host/input/touchscreen_tap_suppression_contro
ller.h" | 9 #include "content/browser/renderer_host/input/touchscreen_tap_suppression_contro
ller.h" |
10 #include "content/common/input/web_input_event_traits.h" | 10 #include "ui/events/blink/web_input_event_traits.h" |
11 | 11 |
12 using blink::WebGestureEvent; | 12 using blink::WebGestureEvent; |
13 using blink::WebInputEvent; | 13 using blink::WebInputEvent; |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 namespace { | 16 namespace { |
17 | 17 |
18 // Whether |event_in_queue| is GesturePinchUpdate or GestureScrollUpdate and | 18 // Whether |event_in_queue| is GesturePinchUpdate or GestureScrollUpdate and |
19 // has the same modifiers/source as the new scroll/pinch event. Compatible | 19 // has the same modifiers/source as the new scroll/pinch event. Compatible |
20 // scroll and pinch event pairs can be logically coalesced. | 20 // scroll and pinch event pairs can be logically coalesced. |
21 bool IsCompatibleScrollorPinch( | 21 bool IsCompatibleScrollorPinch( |
22 const GestureEventWithLatencyInfo& new_event, | 22 const GestureEventWithLatencyInfo& new_event, |
23 const GestureEventWithLatencyInfo& event_in_queue) { | 23 const GestureEventWithLatencyInfo& event_in_queue) { |
24 DCHECK(new_event.event.type == WebInputEvent::GestureScrollUpdate || | 24 DCHECK(new_event.event.type == WebInputEvent::GestureScrollUpdate || |
25 new_event.event.type == WebInputEvent::GesturePinchUpdate) | 25 new_event.event.type == WebInputEvent::GesturePinchUpdate) |
26 << "Invalid event type for pinch/scroll coalescing: " | 26 << "Invalid event type for pinch/scroll coalescing: " |
27 << WebInputEventTraits::GetName(new_event.event.type); | 27 << ui::WebInputEventTraits::GetName(new_event.event.type); |
28 DLOG_IF(WARNING, new_event.event.timeStampSeconds < | 28 DLOG_IF(WARNING, new_event.event.timeStampSeconds < |
29 event_in_queue.event.timeStampSeconds) | 29 event_in_queue.event.timeStampSeconds) |
30 << "Event time not monotonic?\n"; | 30 << "Event time not monotonic?\n"; |
31 return (event_in_queue.event.type == WebInputEvent::GestureScrollUpdate || | 31 return (event_in_queue.event.type == WebInputEvent::GestureScrollUpdate || |
32 event_in_queue.event.type == WebInputEvent::GesturePinchUpdate) && | 32 event_in_queue.event.type == WebInputEvent::GesturePinchUpdate) && |
33 event_in_queue.event.modifiers == new_event.event.modifiers && | 33 event_in_queue.event.modifiers == new_event.event.modifiers && |
34 event_in_queue.event.sourceDevice == new_event.event.sourceDevice; | 34 event_in_queue.event.sourceDevice == new_event.event.sourceDevice; |
35 } | 35 } |
36 | 36 |
37 // Returns the transform matrix corresponding to the gesture event. | 37 // Returns the transform matrix corresponding to the gesture event. |
38 gfx::Transform GetTransformForEvent( | 38 gfx::Transform GetTransformForEvent( |
39 const GestureEventWithLatencyInfo& gesture_event) { | 39 const GestureEventWithLatencyInfo& gesture_event) { |
40 gfx::Transform gesture_transform; | 40 gfx::Transform gesture_transform; |
41 if (gesture_event.event.type == WebInputEvent::GestureScrollUpdate) { | 41 if (gesture_event.event.type == WebInputEvent::GestureScrollUpdate) { |
42 gesture_transform.Translate(gesture_event.event.data.scrollUpdate.deltaX, | 42 gesture_transform.Translate(gesture_event.event.data.scrollUpdate.deltaX, |
43 gesture_event.event.data.scrollUpdate.deltaY); | 43 gesture_event.event.data.scrollUpdate.deltaY); |
44 } else if (gesture_event.event.type == WebInputEvent::GesturePinchUpdate) { | 44 } else if (gesture_event.event.type == WebInputEvent::GesturePinchUpdate) { |
45 float scale = gesture_event.event.data.pinchUpdate.scale; | 45 float scale = gesture_event.event.data.pinchUpdate.scale; |
46 gesture_transform.Translate(-gesture_event.event.x, -gesture_event.event.y); | 46 gesture_transform.Translate(-gesture_event.event.x, -gesture_event.event.y); |
47 gesture_transform.Scale(scale, scale); | 47 gesture_transform.Scale(scale, scale); |
48 gesture_transform.Translate(gesture_event.event.x, gesture_event.event.y); | 48 gesture_transform.Translate(gesture_event.event.x, gesture_event.event.y); |
49 } else { | 49 } else { |
50 NOTREACHED() << "Invalid event type for transform retrieval: " | 50 NOTREACHED() << "Invalid event type for transform retrieval: " |
51 << WebInputEventTraits::GetName(gesture_event.event.type); | 51 << ui::WebInputEventTraits::GetName(gesture_event.event.type); |
52 } | 52 } |
53 return gesture_transform; | 53 return gesture_transform; |
54 } | 54 } |
55 | 55 |
56 } // namespace | 56 } // namespace |
57 | 57 |
58 GestureEventQueue::Config::Config() { | 58 GestureEventQueue::Config::Config() { |
59 } | 59 } |
60 | 60 |
61 GestureEventQueue::GestureEventQueue( | 61 GestureEventQueue::GestureEventQueue( |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 return 0; | 411 return 0; |
412 | 412 |
413 if (!ignore_next_ack_) | 413 if (!ignore_next_ack_) |
414 return 1; | 414 return 1; |
415 | 415 |
416 DCHECK_GT(coalesced_gesture_events_.size(), 1U); | 416 DCHECK_GT(coalesced_gesture_events_.size(), 1U); |
417 return 2; | 417 return 2; |
418 } | 418 } |
419 | 419 |
420 } // namespace content | 420 } // namespace content |
OLD | NEW |