Chromium Code Reviews| 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::WebMouseEvent; | |
| 17 using WebKit::WebMouseWheelEvent; | |
| 18 | |
| 19 namespace content { | |
| 20 | |
| 21 namespace { | |
| 22 | |
| 23 // How many milliseconds apart synthetic scroll messages should be sent. | |
| 24 const int kSyntheticGestureMessageIntervalMs = 16; | |
| 25 | |
| 26 } // namespace | |
| 27 | |
| 28 SyntheticGestureTargetBase::SyntheticGestureTargetBase( | |
| 29 RenderWidgetHostView* render_view) | |
| 30 : render_view_(render_view) { | |
| 31 } | |
| 32 | |
| 33 void SyntheticGestureTargetBase::QueueInputEventToPlatform( | |
| 34 const InputEvent& event) { | |
| 35 const WebInputEvent* web_event = event.web_event.get(); | |
| 36 if (WebInputEvent::isTouchEventType(web_event->type)) { | |
| 37 DCHECK(SupportsSyntheticGestureSourceType( | |
| 38 SyntheticGestureParams::TOUCH_INPUT)); | |
| 39 | |
| 40 const WebTouchEvent* web_touch = | |
| 41 static_cast<const WebTouchEvent*>(web_event); | |
| 42 QueueWebTouchEventToPlatform(*web_touch, event.latency_info); | |
| 43 } else if (web_event->type == WebInputEvent::MouseWheel) { | |
| 44 DCHECK(SupportsSyntheticGestureSourceType( | |
| 45 SyntheticGestureParams::MOUSE_INPUT)); | |
| 46 | |
| 47 const WebMouseWheelEvent* web_wheel = | |
| 48 static_cast<const WebMouseWheelEvent*>(web_event); | |
| 49 QueueWebMouseWheelEventToPlatform(*web_wheel, event.latency_info); | |
| 50 } else if (WebInputEvent::isMouseEventType(web_event->type)) { | |
| 51 DCHECK(SupportsSyntheticGestureSourceType( | |
| 52 SyntheticGestureParams::MOUSE_INPUT)); | |
| 53 | |
| 54 const WebMouseEvent* web_mouse = | |
| 55 static_cast<const WebMouseEvent*>(web_event); | |
| 56 QueueWebMouseEventToPlatform(*web_mouse, event.latency_info); | |
| 57 } else | |
| 58 NOTREACHED(); | |
| 59 } | |
| 60 | |
| 61 void SyntheticGestureTargetBase::QueueWebTouchEventToPlatform( | |
|
aelias_OOO_until_Jul13
2013/10/31 01:47:48
Are these default implementations ever going to be
kouhei (in TOK)
2013/10/31 04:26:36
These will be used on non-Android/aura platforms a
| |
| 62 const WebKit::WebTouchEvent& web_touch, | |
| 63 const ui::LatencyInfo& latency_info) { | |
| 64 RenderWidgetHostImpl* host = RenderWidgetHostImpl::From( | |
| 65 render_view_->GetRenderWidgetHost()); | |
| 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 RenderWidgetHostImpl* host = RenderWidgetHostImpl::From( | |
| 73 render_view_->GetRenderWidgetHost()); | |
| 74 host->ForwardWheelEventWithLatencyInfo( | |
| 75 MouseWheelEventWithLatencyInfo(web_wheel, latency_info)); | |
| 76 } | |
| 77 | |
| 78 void SyntheticGestureTargetBase::QueueWebMouseEventToPlatform( | |
| 79 const WebKit::WebMouseEvent& web_mouse, | |
| 80 const ui::LatencyInfo& latency_info) { | |
| 81 RenderWidgetHostImpl* host = RenderWidgetHostImpl::From( | |
| 82 render_view_->GetRenderWidgetHost()); | |
| 83 host->ForwardMouseEventWithLatencyInfo( | |
| 84 MouseEventWithLatencyInfo(web_mouse, latency_info)); | |
| 85 } | |
| 86 | |
| 87 void SyntheticGestureTargetBase::OnSyntheticGestureCompleted( | |
| 88 SyntheticGestureNew::Result result) { | |
|
jdduke (slow)
2013/10/30 19:02:43
Did we need to do something here? Send an ack to t
Dominik Grewe
2013/10/30 19:11:59
Yes, we don't have the message types yet. We'll ad
| |
| 89 } | |
| 90 | |
| 91 base::TimeDelta | |
| 92 SyntheticGestureTargetBase::GetSyntheticGestureUpdateRate() const { | |
| 93 return base::TimeDelta::FromMilliseconds(kSyntheticGestureMessageIntervalMs); | |
| 94 } | |
| 95 | |
| 96 SyntheticGestureParams::GestureSourceType | |
| 97 SyntheticGestureTargetBase::GetDefaultSyntheticGestureSourceType() const { | |
| 98 return SyntheticGestureParams::MOUSE_INPUT; | |
| 99 } | |
| 100 | |
| 101 bool SyntheticGestureTargetBase::SupportsSyntheticGestureSourceType( | |
| 102 SyntheticGestureParams::GestureSourceType gesture_source_type) const { | |
| 103 return gesture_source_type == SyntheticGestureParams::MOUSE_INPUT || | |
| 104 gesture_source_type == SyntheticGestureParams::TOUCH_INPUT; | |
| 105 } | |
| 106 | |
| 107 } // namespace content | |
| OLD | NEW |