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 "content/public/browser/render_widget_host_view.h" | |
11 #include "ui/events/event.h" | |
12 #include "ui/events/latency_info.h" | |
13 | |
14 using WebKit::WebInputEvent; | |
15 using WebKit::WebTouchEvent; | |
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 = 7; | |
Dominik Grewe
2013/10/28 10:12:00
I think we should change this to 16, so we're roug
kouhei (in TOK)
2013/10/29 03:30:43
Done.
| |
24 | |
25 } // namespace | |
26 | |
27 SyntheticGestureTargetBase::SyntheticGestureTargetBase( | |
28 RenderWidgetHostView* render_view) | |
29 : render_view_(render_view) { | |
30 } | |
31 | |
32 void SyntheticGestureTargetBase::QueueInputEventToPlatform( | |
33 const InputEvent& event) { | |
34 const WebInputEvent* web_event = event.web_event.get(); | |
35 if (WebInputEvent::isTouchEventType(web_event->type)) { | |
36 DCHECK(SupportsSyntheticGestureSourceType( | |
37 SyntheticGestureParams::TOUCH_INPUT)); | |
38 | |
39 const WebTouchEvent* web_touch = | |
40 static_cast<const WebTouchEvent*>(web_event); | |
41 QueueWebTouchEventToPlatform(*web_touch, event.latency_info); | |
42 } else if (web_event->type == WebInputEvent::MouseWheel) { | |
43 DCHECK(SupportsSyntheticGestureSourceType( | |
44 SyntheticGestureParams::MOUSE_INPUT)); | |
45 | |
46 const WebMouseWheelEvent* web_wheel = | |
47 static_cast<const WebMouseWheelEvent*>(web_event); | |
48 QueueWebMouseWheelEventToPlatform(*web_wheel, event.latency_info); | |
Dominik Grewe
2013/10/28 10:12:00
MOUSE_INPUT isn't necessarily a WebMouseWheelEvent
kouhei (in TOK)
2013/10/29 03:30:43
Done.
| |
49 } | |
50 NOTREACHED(); | |
51 } | |
52 | |
53 void SyntheticGestureTargetBase::QueueWebTouchEventToPlatform( | |
54 const WebKit::WebTouchEvent& web_touch, | |
55 const ui::LatencyInfo& latency_info) { | |
56 RenderWidgetHostImpl* host = RenderWidgetHostImpl::From( | |
57 render_view_->GetRenderWidgetHost()); | |
58 host->ForwardTouchEventWithLatencyInfo(web_touch, latency_info); | |
59 } | |
60 | |
61 void SyntheticGestureTargetBase::QueueWebMouseWheelEventToPlatform( | |
62 const WebKit::WebMouseWheelEvent& web_wheel, | |
63 const ui::LatencyInfo& latency_info) { | |
64 RenderWidgetHostImpl* host = RenderWidgetHostImpl::From( | |
65 render_view_->GetRenderWidgetHost()); | |
66 host->ForwardWheelEventWithLatencyInfo( | |
67 MouseWheelEventWithLatencyInfo(web_wheel, latency_info)); | |
68 } | |
69 | |
70 void SyntheticGestureTargetBase::OnSyntheticGestureCompleted( | |
71 SyntheticGestureNew::Result result) { | |
72 } | |
73 | |
74 base::TimeDelta | |
75 SyntheticGestureTargetBase::GetSyntheticGestureUpdateRate() const { | |
76 return base::TimeDelta::FromMilliseconds(kSyntheticGestureMessageIntervalMs); | |
77 } | |
78 | |
79 SyntheticGestureParams::GestureSourceType | |
80 SyntheticGestureTargetBase::GetDefaultSyntheticGestureSourceType() const { | |
81 return SyntheticGestureParams::MOUSE_INPUT; | |
82 } | |
83 | |
84 bool SyntheticGestureTargetBase::SupportsSyntheticGestureSourceType( | |
85 SyntheticGestureParams::GestureSourceType gesture_source_type) const { | |
86 return gesture_source_type == SyntheticGestureParams::MOUSE_INPUT; | |
Dominik Grewe
2013/10/28 10:12:00
Base also supports touch.
kouhei (in TOK)
2013/10/29 03:30:43
Done.
| |
87 } | |
88 | |
89 } // namespace content | |
OLD | NEW |