| 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/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 InputHandlerProxy::EventDisposition disposition = HandleInputEvent(event); | 188 InputHandlerProxy::EventDisposition disposition = HandleInputEvent(event); |
| 189 return disposition; | 189 return disposition; |
| 190 } | 190 } |
| 191 | 191 |
| 192 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleInputEvent( | 192 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleInputEvent( |
| 193 const WebInputEvent& event) { | 193 const WebInputEvent& event) { |
| 194 DCHECK(input_handler_); | 194 DCHECK(input_handler_); |
| 195 TRACE_EVENT1("input", "InputHandlerProxy::HandleInputEvent", | 195 TRACE_EVENT1("input", "InputHandlerProxy::HandleInputEvent", |
| 196 "type", WebInputEventTraits::GetName(event.type)); | 196 "type", WebInputEventTraits::GetName(event.type)); |
| 197 | 197 |
| 198 client_->DidReceiveInputEvent(); | 198 client_->DidReceiveInputEvent(event.type); |
| 199 if (FilterInputEventForFlingBoosting(event)) | 199 if (FilterInputEventForFlingBoosting(event)) |
| 200 return DID_HANDLE; | 200 return DID_HANDLE; |
| 201 | 201 |
| 202 if (event.type == WebInputEvent::MouseWheel) { | 202 if (event.type == WebInputEvent::MouseWheel) { |
| 203 const WebMouseWheelEvent& wheel_event = | 203 const WebMouseWheelEvent& wheel_event = |
| 204 *static_cast<const WebMouseWheelEvent*>(&event); | 204 *static_cast<const WebMouseWheelEvent*>(&event); |
| 205 if (wheel_event.scrollByPage) { | 205 if (wheel_event.scrollByPage) { |
| 206 // TODO(jamesr): We don't properly handle scroll by page in the compositor | 206 // TODO(jamesr): We don't properly handle scroll by page in the compositor |
| 207 // thread, so punt it to the main thread. http://crbug.com/236639 | 207 // thread, so punt it to the main thread. http://crbug.com/236639 |
| 208 return DID_NOT_HANDLE; | 208 return DID_NOT_HANDLE; |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 return; | 602 return; |
| 603 | 603 |
| 604 double monotonic_time_sec = InSecondsF(time); | 604 double monotonic_time_sec = InSecondsF(time); |
| 605 | 605 |
| 606 if (deferred_fling_cancel_time_seconds_ && | 606 if (deferred_fling_cancel_time_seconds_ && |
| 607 monotonic_time_sec > deferred_fling_cancel_time_seconds_) { | 607 monotonic_time_sec > deferred_fling_cancel_time_seconds_) { |
| 608 CancelCurrentFling(); | 608 CancelCurrentFling(); |
| 609 return; | 609 return; |
| 610 } | 610 } |
| 611 | 611 |
| 612 client_->DidAnimateForInput(); |
| 613 |
| 612 if (!has_fling_animation_started_) { | 614 if (!has_fling_animation_started_) { |
| 613 has_fling_animation_started_ = true; | 615 has_fling_animation_started_ = true; |
| 614 // Guard against invalid, future or sufficiently stale start times, as there | 616 // Guard against invalid, future or sufficiently stale start times, as there |
| 615 // are no guarantees fling event and animation timestamps are compatible. | 617 // are no guarantees fling event and animation timestamps are compatible. |
| 616 if (!fling_parameters_.startTime || | 618 if (!fling_parameters_.startTime || |
| 617 monotonic_time_sec <= fling_parameters_.startTime || | 619 monotonic_time_sec <= fling_parameters_.startTime || |
| 618 monotonic_time_sec >= fling_parameters_.startTime + | 620 monotonic_time_sec >= fling_parameters_.startTime + |
| 619 kMaxSecondsFromFlingTimestampToFirstAnimate) { | 621 kMaxSecondsFromFlingTimestampToFirstAnimate) { |
| 620 fling_parameters_.startTime = monotonic_time_sec; | 622 fling_parameters_.startTime = monotonic_time_sec; |
| 621 input_handler_->SetNeedsAnimate(); | 623 input_handler_->SetNeedsAnimate(); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 // trigger a scroll, e.g., with a trivial time delta between fling updates. | 813 // trigger a scroll, e.g., with a trivial time delta between fling updates. |
| 812 // Return true in this case to prevent early fling termination. | 814 // Return true in this case to prevent early fling termination. |
| 813 if (std::abs(clipped_increment.width) < kScrollEpsilon && | 815 if (std::abs(clipped_increment.width) < kScrollEpsilon && |
| 814 std::abs(clipped_increment.height) < kScrollEpsilon) | 816 std::abs(clipped_increment.height) < kScrollEpsilon) |
| 815 return true; | 817 return true; |
| 816 | 818 |
| 817 return did_scroll; | 819 return did_scroll; |
| 818 } | 820 } |
| 819 | 821 |
| 820 } // namespace content | 822 } // namespace content |
| OLD | NEW |