| 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/renderer/input/input_handler_proxy.h" | 5 #include "content/renderer/input/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/input/input_handler_proxy_client.h" | 10 #include "content/renderer/input/input_handler_proxy_client.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 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 using blink::WebTouchPoint; |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 // Validate provided event timestamps that interact with animation timestamps. | 28 // Validate provided event timestamps that interact with animation timestamps. |
| 29 const double kBadTimestampDeltaFromNowInS = 60. * 60. * 24. * 7.; | 29 const double kBadTimestampDeltaFromNowInS = 60. * 60. * 24. * 7.; |
| 30 | 30 |
| 31 double InSecondsF(const base::TimeTicks& time) { | |
| 32 return (time - base::TimeTicks()).InSecondsF(); | |
| 33 } | |
| 34 | |
| 35 void SendScrollLatencyUma(const WebInputEvent& event, | 31 void SendScrollLatencyUma(const WebInputEvent& event, |
| 36 const ui::LatencyInfo& latency_info) { | 32 const ui::LatencyInfo& latency_info) { |
| 37 if (!(event.type == WebInputEvent::GestureScrollBegin || | 33 if (!(event.type == WebInputEvent::GestureScrollBegin || |
| 38 event.type == WebInputEvent::GestureScrollUpdate || | 34 event.type == WebInputEvent::GestureScrollUpdate || |
| 39 event.type == WebInputEvent::GestureScrollUpdateWithoutPropagation)) | 35 event.type == WebInputEvent::GestureScrollUpdateWithoutPropagation)) |
| 40 return; | 36 return; |
| 41 | 37 |
| 42 ui::LatencyInfo::LatencyMap::const_iterator it = | 38 ui::LatencyInfo::LatencyMap::const_iterator it = |
| 43 latency_info.latency_components.find(std::make_pair( | 39 latency_info.latency_components.find(std::make_pair( |
| 44 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0)); | 40 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0)); |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 disallow_horizontal_fling_scroll_ = | 273 disallow_horizontal_fling_scroll_ = |
| 278 !gesture_event.data.flingStart.velocityX; | 274 !gesture_event.data.flingStart.velocityX; |
| 279 disallow_vertical_fling_scroll_ = | 275 disallow_vertical_fling_scroll_ = |
| 280 !gesture_event.data.flingStart.velocityY; | 276 !gesture_event.data.flingStart.velocityY; |
| 281 TRACE_EVENT_ASYNC_BEGIN0( | 277 TRACE_EVENT_ASYNC_BEGIN0( |
| 282 "renderer", | 278 "renderer", |
| 283 "InputHandlerProxy::HandleGestureFling::started", | 279 "InputHandlerProxy::HandleGestureFling::started", |
| 284 this); | 280 this); |
| 285 if (gesture_event.timeStampSeconds) { | 281 if (gesture_event.timeStampSeconds) { |
| 286 fling_parameters_.startTime = gesture_event.timeStampSeconds; | 282 fling_parameters_.startTime = gesture_event.timeStampSeconds; |
| 287 DCHECK_LT(fling_parameters_.startTime - | 283 DCHECK_LT( |
| 288 InSecondsF(gfx::FrameTime::Now()), | 284 fling_parameters_.startTime - gfx::FrameTime::Now().ToWebKit(), |
| 289 kBadTimestampDeltaFromNowInS); | 285 kBadTimestampDeltaFromNowInS); |
| 290 } | 286 } |
| 291 fling_parameters_.delta = | 287 fling_parameters_.delta = |
| 292 WebFloatPoint(gesture_event.data.flingStart.velocityX, | 288 WebFloatPoint(gesture_event.data.flingStart.velocityX, |
| 293 gesture_event.data.flingStart.velocityY); | 289 gesture_event.data.flingStart.velocityY); |
| 294 fling_parameters_.point = WebPoint(gesture_event.x, gesture_event.y); | 290 fling_parameters_.point = WebPoint(gesture_event.x, gesture_event.y); |
| 295 fling_parameters_.globalPoint = | 291 fling_parameters_.globalPoint = |
| 296 WebPoint(gesture_event.globalX, gesture_event.globalY); | 292 WebPoint(gesture_event.globalX, gesture_event.globalY); |
| 297 fling_parameters_.modifiers = gesture_event.modifiers; | 293 fling_parameters_.modifiers = gesture_event.modifiers; |
| 298 fling_parameters_.sourceDevice = gesture_event.sourceDevice; | 294 fling_parameters_.sourceDevice = gesture_event.sourceDevice; |
| 299 input_handler_->ScheduleAnimation(); | 295 input_handler_->ScheduleAnimation(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 321 return DROP_EVENT; | 317 return DROP_EVENT; |
| 322 } | 318 } |
| 323 } | 319 } |
| 324 return DID_NOT_HANDLE; | 320 return DID_NOT_HANDLE; |
| 325 } | 321 } |
| 326 | 322 |
| 327 void InputHandlerProxy::Animate(base::TimeTicks time) { | 323 void InputHandlerProxy::Animate(base::TimeTicks time) { |
| 328 if (!fling_curve_) | 324 if (!fling_curve_) |
| 329 return; | 325 return; |
| 330 | 326 |
| 331 double monotonic_time_sec = InSecondsF(time); | 327 double monotonic_time_sec = time.ToWebKit(); |
| 332 if (!fling_parameters_.startTime) { | 328 if (!fling_parameters_.startTime) { |
| 333 fling_parameters_.startTime = monotonic_time_sec; | 329 fling_parameters_.startTime = monotonic_time_sec; |
| 334 input_handler_->ScheduleAnimation(); | 330 input_handler_->ScheduleAnimation(); |
| 335 return; | 331 return; |
| 336 } | 332 } |
| 337 | 333 |
| 338 bool fling_is_active = | 334 bool fling_is_active = |
| 339 fling_curve_->apply(monotonic_time_sec - fling_parameters_.startTime, | 335 fling_curve_->apply(monotonic_time_sec - fling_parameters_.startTime, |
| 340 this); | 336 this); |
| 341 | 337 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 TRACE_EVENT2("renderer", | 477 TRACE_EVENT2("renderer", |
| 482 "InputHandlerProxy::notifyCurrentFlingVelocity", | 478 "InputHandlerProxy::notifyCurrentFlingVelocity", |
| 483 "vx", | 479 "vx", |
| 484 velocity.width, | 480 velocity.width, |
| 485 "vy", | 481 "vy", |
| 486 velocity.height); | 482 velocity.height); |
| 487 input_handler_->NotifyCurrentFlingVelocity(ToClientScrollIncrement(velocity)); | 483 input_handler_->NotifyCurrentFlingVelocity(ToClientScrollIncrement(velocity)); |
| 488 } | 484 } |
| 489 | 485 |
| 490 } // namespace content | 486 } // namespace content |
| OLD | NEW |