OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/renderer_host/touch_smooth_scroll_gesture_aura.h" | 5 #include "content/browser/renderer_host/touch_smooth_scroll_gesture_aura.h" |
6 | 6 |
7 #include "content/browser/renderer_host/render_widget_host_impl.h" | 7 #include "content/browser/renderer_host/render_widget_host_impl.h" |
8 #include "ui/aura/root_window.h" | 8 #include "ui/aura/root_window.h" |
9 #include "ui/events/event.h" | 9 #include "ui/events/event.h" |
10 #include "ui/events/event_utils.h" | 10 #include "ui/events/event_utils.h" |
11 #include "ui/gfx/transform.h" | 11 #include "ui/gfx/transform.h" |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 void InjectTouchEvent(const gfx::Point& location, | 15 void InjectTouchEvent(const gfx::Point& location, |
16 ui::EventType type, | 16 ui::EventType type, |
17 aura::Window* window) { | 17 aura::Window* window) { |
18 gfx::Point screen_location = location; | 18 gfx::Point screen_location = location; |
| 19 aura::Window* root_window = window->GetRootWindow(); |
19 // First convert the location from Window to RootWindow. | 20 // First convert the location from Window to RootWindow. |
20 aura::RootWindow* root_window = window->GetRootWindow(); | |
21 aura::Window::ConvertPointToTarget(window, root_window, &screen_location); | 21 aura::Window::ConvertPointToTarget(window, root_window, &screen_location); |
22 // Then convert the location from RootWindow to screen. | 22 // Then convert the location from RootWindow to screen. |
23 root_window->ConvertPointToHost(&screen_location); | 23 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); |
| 24 dispatcher->ConvertPointToHost(&screen_location); |
24 ui::TouchEvent touch(type, screen_location, 0, 0, ui::EventTimeForNow(), | 25 ui::TouchEvent touch(type, screen_location, 0, 0, ui::EventTimeForNow(), |
25 1.0f, 1.0f, 1.0f, 1.0f); | 26 1.0f, 1.0f, 1.0f, 1.0f); |
26 aura::RootWindowHostDelegate* root_window_host_delegate = | 27 dispatcher->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch); |
27 root_window->AsRootWindowHostDelegate(); | |
28 root_window_host_delegate->OnHostTouchEvent(&touch); | |
29 } | 28 } |
30 | 29 |
31 } // namespace | 30 } // namespace |
32 | 31 |
33 namespace content { | 32 namespace content { |
34 | 33 |
35 TouchSmoothScrollGestureAura::TouchSmoothScrollGestureAura(bool scroll_down, | 34 TouchSmoothScrollGestureAura::TouchSmoothScrollGestureAura(bool scroll_down, |
36 int pixels_to_scroll, | 35 int pixels_to_scroll, |
37 int mouse_event_x, | 36 int mouse_event_x, |
38 int mouse_event_y, | 37 int mouse_event_y, |
(...skipping 27 matching lines...) Expand all Loading... |
66 pixels_scrolled_ += abs(position_delta); | 65 pixels_scrolled_ += abs(position_delta); |
67 | 66 |
68 if (pixels_scrolled_ >= pixels_to_scroll_) { | 67 if (pixels_scrolled_ >= pixels_to_scroll_) { |
69 InjectTouchEvent(location_, ui::ET_TOUCH_RELEASED, window_); | 68 InjectTouchEvent(location_, ui::ET_TOUCH_RELEASED, window_); |
70 } | 69 } |
71 | 70 |
72 return true; | 71 return true; |
73 } | 72 } |
74 | 73 |
75 } // namespace content | 74 } // namespace content |
OLD | NEW |