Chromium Code Reviews| Index: content/browser/renderer_host/input/synthetic_gesture_target_base.cc |
| diff --git a/content/browser/renderer_host/input/synthetic_gesture_target_base.cc b/content/browser/renderer_host/input/synthetic_gesture_target_base.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..92036f102c627b1d6ccd1921822b7117a2e8b91e |
| --- /dev/null |
| +++ b/content/browser/renderer_host/input/synthetic_gesture_target_base.cc |
| @@ -0,0 +1,107 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/browser/renderer_host/input/synthetic_gesture_target_base.h" |
| + |
| +#include "content/browser/renderer_host/render_widget_host_impl.h" |
| +#include "content/browser/renderer_host/ui_events_helper.h" |
| +#include "content/common/input/input_event.h" |
| +#include "content/public/browser/render_widget_host_view.h" |
| +#include "ui/events/event.h" |
| +#include "ui/events/latency_info.h" |
| + |
| +using WebKit::WebInputEvent; |
| +using WebKit::WebTouchEvent; |
| +using WebKit::WebMouseEvent; |
| +using WebKit::WebMouseWheelEvent; |
| + |
| +namespace content { |
| + |
| +namespace { |
| + |
| +// How many milliseconds apart synthetic scroll messages should be sent. |
| +const int kSyntheticGestureMessageIntervalMs = 16; |
| + |
| +} // namespace |
| + |
| +SyntheticGestureTargetBase::SyntheticGestureTargetBase( |
| + RenderWidgetHostView* render_view) |
| + : render_view_(render_view) { |
| +} |
| + |
| +void SyntheticGestureTargetBase::QueueInputEventToPlatform( |
| + const InputEvent& event) { |
| + const WebInputEvent* web_event = event.web_event.get(); |
| + if (WebInputEvent::isTouchEventType(web_event->type)) { |
| + DCHECK(SupportsSyntheticGestureSourceType( |
| + SyntheticGestureParams::TOUCH_INPUT)); |
| + |
| + const WebTouchEvent* web_touch = |
| + static_cast<const WebTouchEvent*>(web_event); |
| + QueueWebTouchEventToPlatform(*web_touch, event.latency_info); |
| + } else if (web_event->type == WebInputEvent::MouseWheel) { |
| + DCHECK(SupportsSyntheticGestureSourceType( |
| + SyntheticGestureParams::MOUSE_INPUT)); |
| + |
| + const WebMouseWheelEvent* web_wheel = |
| + static_cast<const WebMouseWheelEvent*>(web_event); |
| + QueueWebMouseWheelEventToPlatform(*web_wheel, event.latency_info); |
| + } else if (WebInputEvent::isMouseEventType(web_event->type)) { |
| + DCHECK(SupportsSyntheticGestureSourceType( |
| + SyntheticGestureParams::MOUSE_INPUT)); |
| + |
| + const WebMouseEvent* web_mouse = |
| + static_cast<const WebMouseEvent*>(web_event); |
| + QueueWebMouseEventToPlatform(*web_mouse, event.latency_info); |
| + } else |
| + NOTREACHED(); |
| +} |
| + |
| +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
|
| + const WebKit::WebTouchEvent& web_touch, |
| + const ui::LatencyInfo& latency_info) { |
| + RenderWidgetHostImpl* host = RenderWidgetHostImpl::From( |
| + render_view_->GetRenderWidgetHost()); |
| + host->ForwardTouchEventWithLatencyInfo(web_touch, latency_info); |
| +} |
| + |
| +void SyntheticGestureTargetBase::QueueWebMouseWheelEventToPlatform( |
| + const WebKit::WebMouseWheelEvent& web_wheel, |
| + const ui::LatencyInfo& latency_info) { |
| + RenderWidgetHostImpl* host = RenderWidgetHostImpl::From( |
| + render_view_->GetRenderWidgetHost()); |
| + host->ForwardWheelEventWithLatencyInfo( |
| + MouseWheelEventWithLatencyInfo(web_wheel, latency_info)); |
| +} |
| + |
| +void SyntheticGestureTargetBase::QueueWebMouseEventToPlatform( |
| + const WebKit::WebMouseEvent& web_mouse, |
| + const ui::LatencyInfo& latency_info) { |
| + RenderWidgetHostImpl* host = RenderWidgetHostImpl::From( |
| + render_view_->GetRenderWidgetHost()); |
| + host->ForwardMouseEventWithLatencyInfo( |
| + MouseEventWithLatencyInfo(web_mouse, latency_info)); |
| +} |
| + |
| +void SyntheticGestureTargetBase::OnSyntheticGestureCompleted( |
| + 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
|
| +} |
| + |
| +base::TimeDelta |
| +SyntheticGestureTargetBase::GetSyntheticGestureUpdateRate() const { |
| + return base::TimeDelta::FromMilliseconds(kSyntheticGestureMessageIntervalMs); |
| +} |
| + |
| +SyntheticGestureParams::GestureSourceType |
| +SyntheticGestureTargetBase::GetDefaultSyntheticGestureSourceType() const { |
| + return SyntheticGestureParams::MOUSE_INPUT; |
| +} |
| + |
| +bool SyntheticGestureTargetBase::SupportsSyntheticGestureSourceType( |
| + SyntheticGestureParams::GestureSourceType gesture_source_type) const { |
| + return gesture_source_type == SyntheticGestureParams::MOUSE_INPUT || |
| + gesture_source_type == SyntheticGestureParams::TOUCH_INPUT; |
| +} |
| + |
| +} // namespace content |