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

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

Issue 2269483002: Set the coordinates of the synthetic touch event correctly in SyntheticGestureTargetAura (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add test Created 4 years, 4 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 "third_party/WebKit/public/platform/WebScreenInfo.h" 12 #include "third_party/WebKit/public/platform/WebScreenInfo.h"
13 #include "ui/aura/window.h" 13 #include "ui/aura/window.h"
14 #include "ui/aura/window_event_dispatcher.h"
14 #include "ui/aura/window_tree_host.h" 15 #include "ui/aura/window_tree_host.h"
15 #include "ui/events/event_processor.h" 16 #include "ui/events/event_processor.h"
16 #include "ui/events/event_utils.h" 17 #include "ui/events/event_utils.h"
17 #include "ui/events/gesture_detection/gesture_configuration.h" 18 #include "ui/events/gesture_detection/gesture_configuration.h"
18 19
19 using blink::WebTouchEvent; 20 using blink::WebTouchEvent;
20 using blink::WebMouseWheelEvent; 21 using blink::WebMouseWheelEvent;
21 22
22 namespace content { 23 namespace content {
23 24
24 SyntheticGestureTargetAura::SyntheticGestureTargetAura( 25 SyntheticGestureTargetAura::SyntheticGestureTargetAura(
25 RenderWidgetHostImpl* host) 26 RenderWidgetHostImpl* host)
26 : SyntheticGestureTargetBase(host) { 27 : SyntheticGestureTargetBase(host) {
27 blink::WebScreenInfo screenInfo; 28 blink::WebScreenInfo screenInfo;
28 host->GetWebScreenInfo(&screenInfo); 29 host->GetWebScreenInfo(&screenInfo);
29 device_scale_factor_ = screenInfo.deviceScaleFactor; 30 device_scale_factor_ = screenInfo.deviceScaleFactor;
30 } 31 }
31 32
32 void SyntheticGestureTargetAura::DispatchWebTouchEventToPlatform( 33 void SyntheticGestureTargetAura::DispatchWebTouchEventToPlatform(
33 const WebTouchEvent& web_touch, 34 const WebTouchEvent& web_touch,
34 const ui::LatencyInfo& latency_info) { 35 const ui::LatencyInfo& latency_info) {
35 TouchEventWithLatencyInfo touch_with_latency(web_touch, latency_info); 36 TouchEventWithLatencyInfo touch_with_latency(web_touch, latency_info);
36 for (size_t i = 0; i < touch_with_latency.event.touchesLength; i++) { 37 for (size_t i = 0; i < touch_with_latency.event.touchesLength; i++) {
37 touch_with_latency.event.touches[i].position.x *= device_scale_factor_; 38 touch_with_latency.event.touches[i].position.x *= device_scale_factor_;
38 touch_with_latency.event.touches[i].position.y *= device_scale_factor_; 39 touch_with_latency.event.touches[i].position.y *= device_scale_factor_;
39 touch_with_latency.event.touches[i].radiusX *= device_scale_factor_; 40 touch_with_latency.event.touches[i].radiusX *= device_scale_factor_;
40 touch_with_latency.event.touches[i].radiusY *= device_scale_factor_; 41 touch_with_latency.event.touches[i].radiusY *= device_scale_factor_;;
tdresser 2016/08/24 12:27:48 Remove extra ;
lanwei 2016/08/25 02:28:55 Done.
41 } 42 }
42 ScopedVector<ui::TouchEvent> events; 43 ScopedVector<ui::TouchEvent> events;
43 bool conversion_success = MakeUITouchEventsFromWebTouchEvents( 44 bool conversion_success = MakeUITouchEventsFromWebTouchEvents(
44 touch_with_latency, &events, LOCAL_COORDINATES); 45 touch_with_latency, &events, SCREEN_COORDINATES);
bokan 2016/08/24 15:56:57 Why is this change needed? The call below to Conve
lanwei 2016/08/25 02:28:55 Actually for SyntheticTouchEvents, the screen posi
bokan 2016/08/25 12:36:51 Ugh, it looks like the synthetic gestures don't re
45 DCHECK(conversion_success); 46 DCHECK(conversion_success);
46 47
47 aura::Window* window = GetWindow(); 48 aura::Window* window = GetWindow();
48 aura::WindowTreeHost* host = window->GetHost(); 49 aura::WindowTreeHost* host = window->GetHost();
50
51 // Synthetic touch events will be transformed here before send to
tdresser 2016/08/24 12:27:48 before being sent to the EventProcessor
lanwei 2016/08/25 02:28:55 Done.
52 // EventProcessor, so it should not be transformed again later in
tdresser 2016/08/24 12:27:49 so they should not be transformed again later
lanwei 2016/08/25 02:28:55 Done.
53 // WindowEventDispatcher.
54 host->dispatcher()->set_transform_events(false);
49 for (ScopedVector<ui::TouchEvent>::iterator iter = events.begin(), 55 for (ScopedVector<ui::TouchEvent>::iterator iter = events.begin(),
50 end = events.end(); iter != end; ++iter) { 56 end = events.end(); iter != end; ++iter) {
51 (*iter)->ConvertLocationToTarget(window, host->window()); 57 (*iter)->ConvertLocationToTarget(window, host->window());
52 ui::EventDispatchDetails details = 58 ui::EventDispatchDetails details =
53 host->event_processor()->OnEventFromSource(*iter); 59 host->event_processor()->OnEventFromSource(*iter);
54 if (details.dispatcher_destroyed) 60 if (details.dispatcher_destroyed)
55 break; 61 break;
56 } 62 }
57 } 63 }
58 64
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 ->min_distance_for_pinch_scroll_in_pixels(); 171 ->min_distance_for_pinch_scroll_in_pixels();
166 } 172 }
167 173
168 aura::Window* SyntheticGestureTargetAura::GetWindow() const { 174 aura::Window* SyntheticGestureTargetAura::GetWindow() const {
169 aura::Window* window = render_widget_host()->GetView()->GetNativeView(); 175 aura::Window* window = render_widget_host()->GetView()->GetNativeView();
170 DCHECK(window); 176 DCHECK(window);
171 return window; 177 return window;
172 } 178 }
173 179
174 } // namespace content 180 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/TestExpectations » ('j') | third_party/WebKit/LayoutTests/TestExpectations » ('J')

Powered by Google App Engine
This is Rietveld 408576698