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/renderer/gpu/input_handler_proxy.h" | 5 #include "content/renderer/gpu/input_handler_proxy.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "content/renderer/gpu/input_handler_proxy_client.h" | 10 #include "content/renderer/gpu/input_handler_proxy_client.h" |
11 #include "third_party/WebKit/public/platform/Platform.h" | 11 #include "third_party/WebKit/public/platform/Platform.h" |
12 #include "third_party/WebKit/public/web/WebInputEvent.h" | 12 #include "third_party/WebKit/public/web/WebInputEvent.h" |
13 #include "ui/events/latency_info.h" | 13 #include "ui/events/latency_info.h" |
14 #include "ui/gfx/frame_time.h" | 14 #include "ui/gfx/frame_time.h" |
15 | 15 |
16 using blink::WebFloatPoint; | 16 using blink::WebFloatPoint; |
17 using blink::WebFloatSize; | 17 using blink::WebFloatSize; |
18 using blink::WebGestureEvent; | 18 using blink::WebGestureEvent; |
19 using blink::WebInputEvent; | 19 using blink::WebInputEvent; |
20 using blink::WebMouseEvent; | 20 using blink::WebMouseEvent; |
21 using blink::WebMouseWheelEvent; | 21 using blink::WebMouseWheelEvent; |
22 using blink::WebPoint; | 22 using blink::WebPoint; |
23 using blink::WebTouchEvent; | 23 using blink::WebTouchEvent; |
| 24 using blink::WebTouchPoint; |
24 | 25 |
25 namespace { | 26 namespace { |
26 | 27 |
27 // Validate provided event timestamps that interact with animation timestamps. | 28 // Validate provided event timestamps that interact with animation timestamps. |
28 const double kBadTimestampDeltaFromNowInS = 60. * 60. * 24. * 7.; | 29 const double kBadTimestampDeltaFromNowInS = 60. * 60. * 24. * 7.; |
29 | 30 |
30 double InSecondsF(const base::TimeTicks& time) { | 31 double InSecondsF(const base::TimeTicks& time) { |
31 return (time - base::TimeTicks()).InSecondsF(); | 32 return (time - base::TimeTicks()).InSecondsF(); |
32 } | 33 } |
33 | 34 |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 *static_cast<const WebGestureEvent*>(&event); | 221 *static_cast<const WebGestureEvent*>(&event); |
221 return HandleGestureFling(gesture_event); | 222 return HandleGestureFling(gesture_event); |
222 } else if (event.type == WebInputEvent::GestureFlingCancel) { | 223 } else if (event.type == WebInputEvent::GestureFlingCancel) { |
223 if (CancelCurrentFling()) | 224 if (CancelCurrentFling()) |
224 return DID_HANDLE; | 225 return DID_HANDLE; |
225 else if (!fling_may_be_active_on_main_thread_) | 226 else if (!fling_may_be_active_on_main_thread_) |
226 return DROP_EVENT; | 227 return DROP_EVENT; |
227 } else if (event.type == WebInputEvent::TouchStart) { | 228 } else if (event.type == WebInputEvent::TouchStart) { |
228 const WebTouchEvent& touch_event = | 229 const WebTouchEvent& touch_event = |
229 *static_cast<const WebTouchEvent*>(&event); | 230 *static_cast<const WebTouchEvent*>(&event); |
230 if (!input_handler_->HaveTouchEventHandlersAt(touch_event.touches[0] | 231 for (size_t i = 0; i < touch_event.touchesLength; ++i) { |
231 .position)) | 232 if (touch_event.touches[i].state != WebTouchPoint::StatePressed) |
232 return DROP_EVENT; | 233 continue; |
| 234 if (input_handler_->HaveTouchEventHandlersAt(touch_event.touches[i] |
| 235 .position)) |
| 236 return DID_NOT_HANDLE; |
| 237 } |
| 238 return DROP_EVENT; |
233 } else if (WebInputEvent::isKeyboardEventType(event.type)) { | 239 } else if (WebInputEvent::isKeyboardEventType(event.type)) { |
234 CancelCurrentFling(); | 240 CancelCurrentFling(); |
235 } else if (event.type == WebInputEvent::MouseMove) { | 241 } else if (event.type == WebInputEvent::MouseMove) { |
236 const WebMouseEvent& mouse_event = | 242 const WebMouseEvent& mouse_event = |
237 *static_cast<const WebMouseEvent*>(&event); | 243 *static_cast<const WebMouseEvent*>(&event); |
238 // TODO(tony): Ignore when mouse buttons are down? | 244 // TODO(tony): Ignore when mouse buttons are down? |
239 input_handler_->MouseMoveAt(gfx::Point(mouse_event.x, mouse_event.y)); | 245 input_handler_->MouseMoveAt(gfx::Point(mouse_event.x, mouse_event.y)); |
240 } | 246 } |
241 | 247 |
242 return DID_NOT_HANDLE; | 248 return DID_NOT_HANDLE; |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 TRACE_EVENT2("renderer", | 473 TRACE_EVENT2("renderer", |
468 "InputHandlerProxy::notifyCurrentFlingVelocity", | 474 "InputHandlerProxy::notifyCurrentFlingVelocity", |
469 "vx", | 475 "vx", |
470 velocity.width, | 476 velocity.width, |
471 "vy", | 477 "vy", |
472 velocity.height); | 478 velocity.height); |
473 input_handler_->NotifyCurrentFlingVelocity(ToClientScrollIncrement(velocity)); | 479 input_handler_->NotifyCurrentFlingVelocity(ToClientScrollIncrement(velocity)); |
474 } | 480 } |
475 | 481 |
476 } // namespace content | 482 } // namespace content |
OLD | NEW |