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_aura.h" | |
| 6 | |
| 7 #include "content/browser/renderer_host/render_widget_host_impl.h" | |
| 8 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | |
| 9 #include "content/browser/renderer_host/ui_events_helper.h" | |
| 10 #include "content/common/input/input_event.h" | |
| 11 #include "ui/aura/root_window.h" | |
| 12 #include "ui/aura/window.h" | |
| 13 using WebKit::WebTouchEvent; | |
|
sadrul
2013/11/04 19:26:42
a new line after the #include block
kouhei (in TOK)
2013/11/05 01:32:26
Done.
| |
| 14 using WebKit::WebMouseWheelEvent; | |
| 15 | |
| 16 namespace content { | |
| 17 | |
| 18 SyntheticGestureTargetAura::SyntheticGestureTargetAura( | |
| 19 RenderWidgetHostImpl* host) | |
| 20 : SyntheticGestureTargetBase(host) { | |
| 21 } | |
| 22 | |
| 23 void SyntheticGestureTargetAura::QueueWebTouchEventToPlatform( | |
| 24 const WebTouchEvent& web_touch, | |
| 25 const ui::LatencyInfo& latency_info) { | |
| 26 aura::Window* window = render_widget_host()->GetView()->GetNativeView(); | |
| 27 aura::RootWindow* root_window = | |
| 28 static_cast<aura::RootWindow*>(window->GetRootWindow()); | |
| 29 if (!root_window) | |
| 30 return; | |
| 31 | |
| 32 aura::RootWindowHostDelegate* root_window_host_delegate = | |
| 33 root_window->AsRootWindowHostDelegate(); | |
| 34 | |
| 35 TouchEventWithLatencyInfo touch_with_latency(web_touch, latency_info); | |
| 36 | |
| 37 // SyntheticGesture may skip calculating screenPosition, so we will fill it | |
| 38 // in here. "screenPosition" is converted from "position". | |
| 39 const size_t num_touches = touch_with_latency.event.touchesLength; | |
| 40 for (size_t i = 0; i < num_touches; ++ i) { | |
| 41 WebKit::WebTouchPoint* point = &touch_with_latency.event.touches[i]; | |
| 42 gfx::Point position(point->position.x, point->position.y); | |
| 43 aura::Window::ConvertPointToTarget(window, root_window, &position); | |
| 44 root_window->ConvertPointToHost(&position); | |
|
sadrul
2013/11/04 19:26:42
Use aura::client::ScreenPositionClient::ConvertPoi
kouhei (in TOK)
2013/11/05 01:32:26
Done.
| |
| 45 point->screenPosition.x = position.x(); | |
| 46 point->screenPosition.y = position.y(); | |
| 47 } | |
| 48 | |
| 49 ScopedVector<ui::TouchEvent> events; | |
| 50 bool conversionSucceed = MakeUITouchEventsFromWebTouchEvents( | |
|
sadrul
2013/11/04 19:26:42
conversion_success
kouhei (in TOK)
2013/11/05 01:32:26
Done.
| |
| 51 touch_with_latency, &events, SCREEN_COORDINATES); | |
| 52 DCHECK(conversionSucceed); | |
| 53 | |
| 54 for (ScopedVector<ui::TouchEvent>::iterator iter = events.begin(), | |
| 55 end = events.end(); iter != end; ++iter) { | |
| 56 root_window_host_delegate->OnHostTouchEvent(*iter); | |
|
sadrul
2013/11/04 19:26:42
If Queue*<> expects events to be dispatched asynch
kouhei (in TOK)
2013/11/05 01:32:26
IIUC, QueueWebTouchEventToPlatform can either asyn
Dominik Grewe
2013/11/05 10:32:48
Good question. Afaict synchronous dispatch is fine
sadrul
2013/11/05 17:53:25
OK. Perhaps 'Dispatch' would be a better name. 'Qu
kouhei (in TOK)
2013/11/06 03:24:22
To be addressed in the later CL.
| |
| 57 } | |
| 58 } | |
| 59 | |
| 60 SyntheticGestureParams::GestureSourceType | |
| 61 SyntheticGestureTargetAura::GetDefaultSyntheticGestureSourceType() const { | |
| 62 return SyntheticGestureParams::TOUCH_INPUT; | |
|
sadrul
2013/11/04 19:26:42
I am not so sure if TOUCH_ is the default for aura
kouhei (in TOK)
2013/11/05 01:32:26
Ack. I'll fix this in new CL once I have aura-nati
sadrul
2013/11/05 17:53:25
OK. Please add a TODO (and reference the bug# if t
kouhei (in TOK)
2013/11/06 03:24:22
Done.
| |
| 63 } | |
| 64 | |
| 65 bool SyntheticGestureTargetAura::SupportsSyntheticGestureSourceType( | |
| 66 SyntheticGestureParams::GestureSourceType gesture_source_type) const { | |
| 67 return gesture_source_type == SyntheticGestureParams::TOUCH_INPUT | |
|
sadrul
2013/11/04 19:26:42
|| at the end of the first line
kouhei (in TOK)
2013/11/05 01:32:26
Done.
| |
| 68 || gesture_source_type == SyntheticGestureParams::MOUSE_INPUT; | |
| 69 } | |
| 70 | |
| 71 } // namespace content | |
| OLD | NEW |