| OLD | NEW |
| 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/input_router_impl.h" | 5 #include "content/browser/renderer_host/input/input_router_impl.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 input_router_->SendMouseEvent(MouseEventWithLatencyInfo( | 225 input_router_->SendMouseEvent(MouseEventWithLatencyInfo( |
| 226 SyntheticWebMouseEventBuilder::Build(type, x, y, 0))); | 226 SyntheticWebMouseEventBuilder::Build(type, x, y, 0))); |
| 227 } | 227 } |
| 228 | 228 |
| 229 void SimulateWheelEventWithPhase(WebMouseWheelEvent::Phase phase) { | 229 void SimulateWheelEventWithPhase(WebMouseWheelEvent::Phase phase) { |
| 230 input_router_->SendWheelEvent(MouseWheelEventWithLatencyInfo( | 230 input_router_->SendWheelEvent(MouseWheelEventWithLatencyInfo( |
| 231 SyntheticWebMouseWheelEventBuilder::Build(phase))); | 231 SyntheticWebMouseWheelEventBuilder::Build(phase))); |
| 232 } | 232 } |
| 233 | 233 |
| 234 void SimulateGestureEvent(WebGestureEvent gesture) { | 234 void SimulateGestureEvent(WebGestureEvent gesture) { |
| 235 // Ensure non-zero touchscreen fling velocities, as the router will | 235 if (gesture.type() == WebInputEvent::GestureScrollBegin && |
| 236 // validate aganst such. | |
| 237 if (gesture.type() == WebInputEvent::GestureFlingStart && | |
| 238 gesture.sourceDevice == blink::WebGestureDeviceTouchscreen && | 236 gesture.sourceDevice == blink::WebGestureDeviceTouchscreen && |
| 239 !gesture.data.flingStart.velocityX && | 237 !gesture.data.scrollBegin.deltaXHint && |
| 240 !gesture.data.flingStart.velocityY) { | 238 !gesture.data.scrollBegin.deltaYHint) { |
| 239 // Ensure non-zero scroll-begin offset-hint to make the event sane, |
| 240 // prevents unexpected filtering at TouchActionFilter. |
| 241 gesture.data.scrollBegin.deltaYHint = 2.f; |
| 242 } else if (gesture.type() == WebInputEvent::GestureFlingStart && |
| 243 gesture.sourceDevice == blink::WebGestureDeviceTouchscreen && |
| 244 !gesture.data.flingStart.velocityX && |
| 245 !gesture.data.flingStart.velocityY) { |
| 246 // Ensure non-zero touchscreen fling velocities, as the router will |
| 247 // validate against such. |
| 241 gesture.data.flingStart.velocityX = 5.f; | 248 gesture.data.flingStart.velocityX = 5.f; |
| 242 } | 249 } |
| 243 | 250 |
| 244 input_router_->SendGestureEvent(GestureEventWithLatencyInfo(gesture)); | 251 input_router_->SendGestureEvent(GestureEventWithLatencyInfo(gesture)); |
| 245 } | 252 } |
| 246 | 253 |
| 247 void SimulateGestureEvent(WebInputEvent::Type type, | 254 void SimulateGestureEvent(WebInputEvent::Type type, |
| 248 WebGestureDevice source_device) { | 255 WebGestureDevice source_device) { |
| 249 SimulateGestureEvent( | 256 SimulateGestureEvent( |
| 250 SyntheticWebGestureEventBuilder::Build(type, source_device)); | 257 SyntheticWebGestureEventBuilder::Build(type, source_device)); |
| (...skipping 2187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2438 EXPECT_EQ(80, sent_event->data.flingStart.velocityY); | 2445 EXPECT_EQ(80, sent_event->data.flingStart.velocityY); |
| 2439 | 2446 |
| 2440 const WebGestureEvent* filter_event = | 2447 const WebGestureEvent* filter_event = |
| 2441 GetFilterWebInputEvent<WebGestureEvent>(); | 2448 GetFilterWebInputEvent<WebGestureEvent>(); |
| 2442 TestLocationInFilterEvent(filter_event, orig); | 2449 TestLocationInFilterEvent(filter_event, orig); |
| 2443 EXPECT_EQ(30, filter_event->data.flingStart.velocityX); | 2450 EXPECT_EQ(30, filter_event->data.flingStart.velocityX); |
| 2444 EXPECT_EQ(40, filter_event->data.flingStart.velocityY); | 2451 EXPECT_EQ(40, filter_event->data.flingStart.velocityY); |
| 2445 } | 2452 } |
| 2446 | 2453 |
| 2447 } // namespace content | 2454 } // namespace content |
| OLD | NEW |