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

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: Scale the position later Created 4 years, 3 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/TestExpectations » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 16 matching lines...) Expand all
27 blink::WebScreenInfo screenInfo; 27 blink::WebScreenInfo screenInfo;
28 host->GetWebScreenInfo(&screenInfo); 28 host->GetWebScreenInfo(&screenInfo);
29 device_scale_factor_ = screenInfo.deviceScaleFactor; 29 device_scale_factor_ = screenInfo.deviceScaleFactor;
30 } 30 }
31 31
32 void SyntheticGestureTargetAura::DispatchWebTouchEventToPlatform( 32 void SyntheticGestureTargetAura::DispatchWebTouchEventToPlatform(
33 const WebTouchEvent& web_touch, 33 const WebTouchEvent& web_touch,
34 const ui::LatencyInfo& latency_info) { 34 const ui::LatencyInfo& latency_info) {
35 TouchEventWithLatencyInfo touch_with_latency(web_touch, latency_info); 35 TouchEventWithLatencyInfo touch_with_latency(web_touch, latency_info);
36 for (size_t i = 0; i < touch_with_latency.event.touchesLength; i++) { 36 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.y *= device_scale_factor_;
39 touch_with_latency.event.touches[i].radiusX *= device_scale_factor_; 37 touch_with_latency.event.touches[i].radiusX *= device_scale_factor_;
40 touch_with_latency.event.touches[i].radiusY *= device_scale_factor_; 38 touch_with_latency.event.touches[i].radiusY *= device_scale_factor_;
41 } 39 }
42 ScopedVector<ui::TouchEvent> events; 40 ScopedVector<ui::TouchEvent> events;
43 bool conversion_success = MakeUITouchEventsFromWebTouchEvents( 41 bool conversion_success = MakeUITouchEventsFromWebTouchEvents(
44 touch_with_latency, &events, LOCAL_COORDINATES); 42 touch_with_latency, &events, LOCAL_COORDINATES);
45 DCHECK(conversion_success); 43 DCHECK(conversion_success);
46 44
47 aura::Window* window = GetWindow(); 45 aura::Window* window = GetWindow();
48 aura::WindowTreeHost* host = window->GetHost(); 46 aura::WindowTreeHost* host = window->GetHost();
49 for (ScopedVector<ui::TouchEvent>::iterator iter = events.begin(), 47 for (ScopedVector<ui::TouchEvent>::iterator iter = events.begin(),
50 end = events.end(); iter != end; ++iter) { 48 end = events.end(); iter != end; ++iter) {
51 (*iter)->ConvertLocationToTarget(window, host->window()); 49 (*iter)->ConvertLocationToTarget(window, host->window());
50
51 // Apply the screen scale factor to the event location after it has been
52 // transformed to the target.
53 gfx::PointF device_location =
54 gfx::ScalePoint((*iter)->location_f(), device_scale_factor_);
55 gfx::PointF device_root_location =
56 gfx::ScalePoint((*iter)->root_location_f(), device_scale_factor_);
57 (*iter)->set_location_f(device_location);
58 (*iter)->set_root_location_f(device_root_location);
52 ui::EventDispatchDetails details = 59 ui::EventDispatchDetails details =
53 host->event_processor()->OnEventFromSource(*iter); 60 host->event_processor()->OnEventFromSource(*iter);
54 if (details.dispatcher_destroyed) 61 if (details.dispatcher_destroyed)
55 break; 62 break;
56 } 63 }
57 } 64 }
58 65
59 void SyntheticGestureTargetAura::DispatchWebMouseWheelEventToPlatform( 66 void SyntheticGestureTargetAura::DispatchWebMouseWheelEventToPlatform(
60 const blink::WebMouseWheelEvent& web_wheel, 67 const blink::WebMouseWheelEvent& web_wheel,
61 const ui::LatencyInfo&) { 68 const ui::LatencyInfo&) {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 ->min_distance_for_pinch_scroll_in_pixels(); 172 ->min_distance_for_pinch_scroll_in_pixels();
166 } 173 }
167 174
168 aura::Window* SyntheticGestureTargetAura::GetWindow() const { 175 aura::Window* SyntheticGestureTargetAura::GetWindow() const {
169 aura::Window* window = render_widget_host()->GetView()->GetNativeView(); 176 aura::Window* window = render_widget_host()->GetView()->GetNativeView();
170 DCHECK(window); 177 DCHECK(window);
171 return window; 178 return window;
172 } 179 }
173 180
174 } // namespace content 181 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/TestExpectations » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698