Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Side by Side Diff: content/browser/renderer_host/input/synthetic_gesture_target_aura.cc

Issue 26664002: SyntheticGestureTarget implementation for injecting synthetic input events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove unused forward decl Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_aura.h"
6
7 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
8 #include "content/browser/renderer_host/ui_events_helper.h"
9 #include "content/common/input/input_event.h"
10 #include "ui/aura/root_window.h"
11 #include "ui/aura/window.h"
12
13 using WebKit::WebInputEvent;
14 using WebKit::WebTouchEvent;
15 using WebKit::WebMouseWheelEvent;
16
17 namespace content {
18
19 SyntheticGestureTargetAura::SyntheticGestureTargetAura(
20 RenderWidgetHostViewAura* render_view)
21 : SyntheticGestureTargetBase(render_view) {
22 }
23
24 void SyntheticGestureTargetAura::QueueWebTouchEventToPlatform(
25 const WebTouchEvent& web_touch,
26 const ui::LatencyInfo& latency_info) {
27 aura::Window* window = render_view_aura()->GetNativeView();
28 aura::RootWindow* root_window =
29 reinterpret_cast<aura::RootWindow*>(window->GetRootWindow());
30 if (!root_window)
31 return;
32
33 aura::RootWindowHostDelegate* root_window_host_delegate =
34 root_window->AsRootWindowHostDelegate();
35
36 TouchEventWithLatencyInfo touch_with_latency(web_touch, latency_info);
37
38 // SyntheticGesture may skip calculating screenPosition, so we will fill it
39 // in here. "screenPosition" is converted from "position".
40 const unsigned num_touches = touch_with_latency.event.touchesLength;
41 for (unsigned i = 0; i < num_touches; ++ i) {
42 WebKit::WebTouchPoint* point = &touch_with_latency.event.touches[i];
43 gfx::Point position(point->position.x, point->position.y);
44 aura::Window::ConvertPointToTarget(window, root_window, &position);
45 root_window->ConvertPointToHost(&position);
46 point->screenPosition.x = position.x();
47 point->screenPosition.y = position.y();
48 }
49
50 ScopedVector<ui::TouchEvent> events;
51 if (!MakeUITouchEventsFromWebTouchEvents(touch_with_latency, &events,
52 SCREEN_COORDINATES))
53 return;
54
55 for (ScopedVector<ui::TouchEvent>::iterator iter = events.begin(),
56 end = events.end(); iter != end; ++iter) {
57 root_window_host_delegate->OnHostTouchEvent(*iter);
58 }
59 }
60
61 SyntheticGestureParams::GestureSourceType
62 SyntheticGestureTargetAura::GetDefaultSyntheticGestureSourceType() const {
63 return SyntheticGestureParams::TOUCH_INPUT;
64 }
65
66 bool SyntheticGestureTargetAura::SupportsSyntheticGestureSourceType(
67 SyntheticGestureParams::GestureSourceType gesture_source_type) const {
68 return gesture_source_type == SyntheticGestureParams::TOUCH_INPUT
69 || gesture_source_type == SyntheticGestureParams::MOUSE_INPUT;
70 }
71
72 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698