OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "content/browser/renderer_host/input/synthetic_gesture_target_base.h" | |
6 | |
7 #include "content/browser/renderer_host/render_widget_host_impl.h" | |
8 #include "content/browser/renderer_host/ui_events_helper.h" | |
9 #include "content/common/input/input_event.h" | |
10 #include "ui/events/event.h" | |
11 #include "ui/events/latency_info.h" | |
12 | |
13 using WebKit::WebInputEvent; | |
14 using WebKit::WebTouchEvent; | |
15 using WebKit::WebMouseEvent; | |
16 using WebKit::WebMouseWheelEvent; | |
17 | |
18 namespace content { | |
19 | |
20 namespace { | |
21 | |
22 // How many milliseconds apart synthetic scroll messages should be sent. | |
23 const int kSyntheticGestureMessageIntervalMs = 16; | |
24 | |
25 } // namespace | |
26 | |
27 SyntheticGestureTargetBase::SyntheticGestureTargetBase( | |
28 RenderWidgetHostImpl* host) | |
29 : host_(host) { | |
30 } | |
31 | |
32 SyntheticGestureTargetBase::~SyntheticGestureTargetBase() { | |
33 } | |
34 | |
35 void SyntheticGestureTargetBase::QueueInputEventToPlatform( | |
36 const InputEvent& event) { | |
37 const WebInputEvent* web_event = event.web_event.get(); | |
38 if (WebInputEvent::isTouchEventType(web_event->type)) { | |
39 DCHECK(SupportsSyntheticGestureSourceType( | |
40 SyntheticGestureParams::TOUCH_INPUT)); | |
41 | |
42 const WebTouchEvent* web_touch = | |
43 static_cast<const WebTouchEvent*>(web_event); | |
44 QueueWebTouchEventToPlatform(*web_touch, event.latency_info); | |
45 } else if (web_event->type == WebInputEvent::MouseWheel) { | |
46 DCHECK(SupportsSyntheticGestureSourceType( | |
47 SyntheticGestureParams::MOUSE_INPUT)); | |
48 | |
49 const WebMouseWheelEvent* web_wheel = | |
50 static_cast<const WebMouseWheelEvent*>(web_event); | |
51 QueueWebMouseWheelEventToPlatform(*web_wheel, event.latency_info); | |
52 } else if (WebInputEvent::isMouseEventType(web_event->type)) { | |
53 DCHECK(SupportsSyntheticGestureSourceType( | |
54 SyntheticGestureParams::MOUSE_INPUT)); | |
55 | |
56 const WebMouseEvent* web_mouse = | |
57 static_cast<const WebMouseEvent*>(web_event); | |
58 QueueWebMouseEventToPlatform(*web_mouse, event.latency_info); | |
59 } else | |
60 NOTREACHED(); | |
sadrul
2013/11/05 17:53:25
Add {}
kouhei (in TOK)
2013/11/06 03:24:22
Done.
| |
61 } | |
62 | |
63 void SyntheticGestureTargetBase::QueueWebTouchEventToPlatform( | |
64 const WebKit::WebTouchEvent& web_touch, | |
65 const ui::LatencyInfo& latency_info) { | |
66 host_->ForwardTouchEventWithLatencyInfo(web_touch, latency_info); | |
67 } | |
68 | |
69 void SyntheticGestureTargetBase::QueueWebMouseWheelEventToPlatform( | |
70 const WebKit::WebMouseWheelEvent& web_wheel, | |
71 const ui::LatencyInfo& latency_info) { | |
72 host_->ForwardWheelEventWithLatencyInfo( | |
73 MouseWheelEventWithLatencyInfo(web_wheel, latency_info)); | |
74 } | |
75 | |
76 void SyntheticGestureTargetBase::QueueWebMouseEventToPlatform( | |
77 const WebKit::WebMouseEvent& web_mouse, | |
78 const ui::LatencyInfo& latency_info) { | |
79 host_->ForwardMouseEventWithLatencyInfo( | |
80 MouseEventWithLatencyInfo(web_mouse, latency_info)); | |
81 } | |
82 | |
83 void SyntheticGestureTargetBase::OnSyntheticGestureCompleted( | |
84 SyntheticGestureNew::Result result) { | |
85 } | |
86 | |
87 base::TimeDelta | |
88 SyntheticGestureTargetBase::GetSyntheticGestureUpdateRate() const { | |
89 return base::TimeDelta::FromMilliseconds(kSyntheticGestureMessageIntervalMs); | |
90 } | |
91 | |
92 SyntheticGestureParams::GestureSourceType | |
93 SyntheticGestureTargetBase::GetDefaultSyntheticGestureSourceType() const { | |
94 return SyntheticGestureParams::MOUSE_INPUT; | |
95 } | |
96 | |
97 bool SyntheticGestureTargetBase::SupportsSyntheticGestureSourceType( | |
98 SyntheticGestureParams::GestureSourceType gesture_source_type) const { | |
99 return gesture_source_type == SyntheticGestureParams::MOUSE_INPUT || | |
100 gesture_source_type == SyntheticGestureParams::TOUCH_INPUT; | |
101 } | |
102 | |
103 } // namespace content | |
OLD | NEW |