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

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

Issue 2742473002: gpu benchmarking swipe for touchpad
Patch Set: swipe direction fixed Created 3 years, 9 months 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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/input/synthetic_gesture_target_aura.h" 5 #include "content/browser/renderer_host/input/synthetic_gesture_target_aura.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "content/browser/renderer_host/render_widget_host_impl.h" 9 #include "content/browser/renderer_host/render_widget_host_impl.h"
10 #include "content/browser/renderer_host/render_widget_host_view_aura.h" 10 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
11 #include "content/browser/renderer_host/ui_events_helper.h" 11 #include "content/browser/renderer_host/ui_events_helper.h"
12 #include "ui/aura/window.h" 12 #include "ui/aura/window.h"
13 #include "ui/aura/window_tree_host.h" 13 #include "ui/aura/window_tree_host.h"
14 #include "ui/events/event_processor.h" 14 #include "ui/events/event_processor.h"
15 #include "ui/events/event_utils.h" 15 #include "ui/events/event_utils.h"
16 #include "ui/events/gesture_detection/gesture_configuration.h" 16 #include "ui/events/gesture_detection/gesture_configuration.h"
17 17
18 using blink::WebTouchEvent; 18 using blink::WebTouchEvent;
19 using blink::WebMouseWheelEvent; 19 using blink::WebMouseWheelEvent;
20 using blink::WebGestureEvent;
20 21
21 namespace content { 22 namespace content {
22 23
23 SyntheticGestureTargetAura::SyntheticGestureTargetAura( 24 SyntheticGestureTargetAura::SyntheticGestureTargetAura(
24 RenderWidgetHostImpl* host) 25 RenderWidgetHostImpl* host)
25 : SyntheticGestureTargetBase(host) { 26 : SyntheticGestureTargetBase(host) {
26 ScreenInfo screen_info; 27 ScreenInfo screen_info;
27 host->GetScreenInfo(&screen_info); 28 host->GetScreenInfo(&screen_info);
28 device_scale_factor_ = screen_info.device_scale_factor; 29 device_scale_factor_ = screen_info.device_scale_factor;
29 } 30 }
(...skipping 28 matching lines...) Expand all
58 ui::EventDispatchDetails details = 59 ui::EventDispatchDetails details =
59 host->event_processor()->OnEventFromSource(*iter); 60 host->event_processor()->OnEventFromSource(*iter);
60 if (details.dispatcher_destroyed) 61 if (details.dispatcher_destroyed)
61 break; 62 break;
62 } 63 }
63 } 64 }
64 65
65 void SyntheticGestureTargetAura::DispatchWebMouseWheelEventToPlatform( 66 void SyntheticGestureTargetAura::DispatchWebMouseWheelEventToPlatform(
66 const blink::WebMouseWheelEvent& web_wheel, 67 const blink::WebMouseWheelEvent& web_wheel,
67 const ui::LatencyInfo&) { 68 const ui::LatencyInfo&) {
69 base::TimeTicks timestamp =
70 ui::EventTimeStampFromSeconds(web_wheel.timeStampSeconds());
68 ui::MouseWheelEvent wheel_event( 71 ui::MouseWheelEvent wheel_event(
69 gfx::Vector2d(web_wheel.deltaX, web_wheel.deltaY), gfx::Point(), 72 gfx::Vector2d(web_wheel.deltaX, web_wheel.deltaY), gfx::Point(),
70 gfx::Point(), ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); 73 gfx::Point(), timestamp, ui::EF_NONE, ui::EF_NONE);
71 gfx::PointF location(web_wheel.x * device_scale_factor_, 74 gfx::PointF location(web_wheel.x * device_scale_factor_,
72 web_wheel.y * device_scale_factor_); 75 web_wheel.y * device_scale_factor_);
73 wheel_event.set_location_f(location); 76 wheel_event.set_location_f(location);
74 wheel_event.set_root_location_f(location); 77 wheel_event.set_root_location_f(location);
75 78
76 aura::Window* window = GetWindow(); 79 aura::Window* window = GetWindow();
77 wheel_event.ConvertLocationToTarget(window, window->GetRootWindow()); 80 wheel_event.ConvertLocationToTarget(window, window->GetRootWindow());
78 ui::EventDispatchDetails details = 81 ui::EventDispatchDetails details =
79 window->GetHost()->event_processor()->OnEventFromSource(&wheel_event); 82 window->GetHost()->event_processor()->OnEventFromSource(&wheel_event);
80 if (details.dispatcher_destroyed) 83 if (details.dispatcher_destroyed)
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 mouse_event.set_pointer_details(pointer_details); 158 mouse_event.set_pointer_details(pointer_details);
156 159
157 aura::Window* window = GetWindow(); 160 aura::Window* window = GetWindow();
158 mouse_event.ConvertLocationToTarget(window, window->GetRootWindow()); 161 mouse_event.ConvertLocationToTarget(window, window->GetRootWindow());
159 ui::EventDispatchDetails details = 162 ui::EventDispatchDetails details =
160 window->GetHost()->event_processor()->OnEventFromSource(&mouse_event); 163 window->GetHost()->event_processor()->OnEventFromSource(&mouse_event);
161 if (details.dispatcher_destroyed) 164 if (details.dispatcher_destroyed)
162 return; 165 return;
163 } 166 }
164 167
168 void SyntheticGestureTargetAura::DispatchTouchpadGestureFlingStartToPlatform(
tdresser 2017/03/21 19:20:02 Comment that this aligns with the Chrome OS model
sahel 2017/03/22 14:43:24 Done.
169 const blink::WebGestureEvent& web_gesture,
170 const ui::LatencyInfo& latency_info) {
171 DCHECK_EQ(web_gesture.type(), blink::WebInputEvent::GestureFlingStart);
172
173 float velocity_x = web_gesture.data.flingStart.velocityX;
174 float velocity_y = web_gesture.data.flingStart.velocityY;
175 DCHECK(velocity_x || velocity_y);
176
177 base::TimeTicks timestamp =
178 ui::EventTimeStampFromSeconds(web_gesture.timeStampSeconds());
179 ui::ScrollEvent fling_event(ui::ET_SCROLL_FLING_START, gfx::Point(),
180 timestamp, ui::EF_NONE, velocity_x, velocity_y,
181 velocity_x, velocity_y,
182 2); // finger_count
183 gfx::PointF location(web_gesture.x * device_scale_factor_,
184 web_gesture.y * device_scale_factor_);
185 fling_event.set_location_f(location);
186 fling_event.set_root_location_f(location);
187
188 aura::Window* window = GetWindow();
189 fling_event.ConvertLocationToTarget(window, window->GetRootWindow());
190 ui::EventDispatchDetails details =
191 window->GetHost()->event_processor()->OnEventFromSource(&fling_event);
192 if (details.dispatcher_destroyed)
193 return;
194 }
195
165 SyntheticGestureParams::GestureSourceType 196 SyntheticGestureParams::GestureSourceType
166 SyntheticGestureTargetAura::GetDefaultSyntheticGestureSourceType() const { 197 SyntheticGestureTargetAura::GetDefaultSyntheticGestureSourceType() const {
167 return SyntheticGestureParams::TOUCH_INPUT; 198 return SyntheticGestureParams::TOUCH_INPUT;
168 } 199 }
169 200
170 float SyntheticGestureTargetAura::GetTouchSlopInDips() const { 201 float SyntheticGestureTargetAura::GetTouchSlopInDips() const {
171 // - 1 because Aura considers a pointer to be moving if it has moved at least 202 // - 1 because Aura considers a pointer to be moving if it has moved at least
172 // 'max_touch_move_in_pixels_for_click' pixels. 203 // 'max_touch_move_in_pixels_for_click' pixels.
173 return ui::GestureConfiguration::GetInstance() 204 return ui::GestureConfiguration::GetInstance()
174 ->max_touch_move_in_pixels_for_click() - 205 ->max_touch_move_in_pixels_for_click() -
175 1; 206 1;
176 } 207 }
177 208
178 float SyntheticGestureTargetAura::GetMinScalingSpanInDips() const { 209 float SyntheticGestureTargetAura::GetMinScalingSpanInDips() const {
179 return ui::GestureConfiguration::GetInstance() 210 return ui::GestureConfiguration::GetInstance()
180 ->min_distance_for_pinch_scroll_in_pixels(); 211 ->min_distance_for_pinch_scroll_in_pixels();
181 } 212 }
182 213
183 aura::Window* SyntheticGestureTargetAura::GetWindow() const { 214 aura::Window* SyntheticGestureTargetAura::GetWindow() const {
184 aura::Window* window = render_widget_host()->GetView()->GetNativeView(); 215 aura::Window* window = render_widget_host()->GetView()->GetNativeView();
185 DCHECK(window); 216 DCHECK(window);
186 return window; 217 return window;
187 } 218 }
188 219
189 } // namespace content 220 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698