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/aura/window.h" | 9 #include "ui/aura/window.h" |
10 #include "ui/events/event.h" | 10 #include "ui/events/event.h" |
11 #include "ui/events/event_utils.h" | 11 #include "ui/events/event_utils.h" |
12 #include "ui/gfx/transform.h" | 12 #include "ui/gfx/transform.h" |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 void InjectTouchEvent(const gfx::Point& location, | 16 void InjectTouchEvent(const gfx::Point& location, |
17 ui::EventType type, | 17 ui::EventType type, |
18 aura::Window* window) { | 18 aura::Window* window) { |
19 gfx::Point screen_location = location; | 19 gfx::Point screen_location = location; |
20 aura::Window* root_window = window->GetRootWindow(); | 20 aura::Window* root_window = window->GetRootWindow(); |
21 // First convert the location from Window to RootWindow. | 21 // First convert the location from Window to RootWindow. |
22 aura::Window::ConvertPointToTarget(window, root_window, &screen_location); | 22 aura::Window::ConvertPointToTarget(window, root_window, &screen_location); |
23 // Then convert the location from RootWindow to screen. | 23 // Then convert the location from RootWindow to screen. |
24 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); | 24 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); |
25 dispatcher->host()->ConvertPointToHost(&screen_location); | 25 dispatcher->host()->ConvertPointToHost(&screen_location); |
26 ui::TouchEvent touch(type, screen_location, 0, 0, ui::EventTimeForNow(), | 26 ui::TouchEvent touch(type, screen_location, 0, 0, ui::EventTimeForNow(), |
27 1.0f, 1.0f, 1.0f, 1.0f); | 27 1.0f, 1.0f, 1.0f, 1.0f); |
28 dispatcher->AsWindowTreeHostDelegate()->OnHostTouchEvent(&touch); | 28 dispatcher->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch); |
29 } | 29 } |
30 | 30 |
31 } // namespace | 31 } // namespace |
32 | 32 |
33 namespace content { | 33 namespace content { |
34 | 34 |
35 TouchSmoothScrollGestureAura::TouchSmoothScrollGestureAura(bool scroll_down, | 35 TouchSmoothScrollGestureAura::TouchSmoothScrollGestureAura(bool scroll_down, |
36 int pixels_to_scroll, | 36 int pixels_to_scroll, |
37 int mouse_event_x, | 37 int mouse_event_x, |
38 int mouse_event_y, | 38 int mouse_event_y, |
(...skipping 27 matching lines...) Expand all Loading... |
66 pixels_scrolled_ += abs(position_delta); | 66 pixels_scrolled_ += abs(position_delta); |
67 | 67 |
68 if (pixels_scrolled_ >= pixels_to_scroll_) { | 68 if (pixels_scrolled_ >= pixels_to_scroll_) { |
69 InjectTouchEvent(location_, ui::ET_TOUCH_RELEASED, window_); | 69 InjectTouchEvent(location_, ui::ET_TOUCH_RELEASED, window_); |
70 } | 70 } |
71 | 71 |
72 return true; | 72 return true; |
73 } | 73 } |
74 | 74 |
75 } // namespace content | 75 } // namespace content |
OLD | NEW |