OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MOUSE_WHEEL_PHASE_HANDLER_H_ |
| 6 #define MOUSE_WHEEL_PHASE_HANDLER_H_ |
| 7 |
| 8 #include "base/timer/timer.h" |
| 9 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
| 10 |
| 11 namespace content { |
| 12 class RenderWidgetHostImpl; |
| 13 class RenderWidgetHostViewBase; |
| 14 |
| 15 // The duration after which a synthetic wheel with zero deltas and |
| 16 // phase = |kPhaseEnded| will be sent after the last wheel event. |
| 17 const int64_t kDefaultMouseWheelLatchingTransactionMs = 100; |
| 18 |
| 19 class MouseWheelPhaseHandler { |
| 20 public: |
| 21 MouseWheelPhaseHandler(RenderWidgetHostImpl* const host, |
| 22 RenderWidgetHostViewBase* const host_view); |
| 23 ~MouseWheelPhaseHandler() {} |
| 24 |
| 25 void AddPhaseIfNeededAndScheduleEndEvent( |
| 26 blink::WebMouseWheelEvent& mouse_wheel_event, |
| 27 bool should_route_event); |
| 28 void DispatchPendingWheelEndEvent(); |
| 29 void IgnorePendingWheelEndEvent(); |
| 30 bool HasPendingWheelEndEvent() const { |
| 31 return mouse_wheel_end_dispatch_timer_.IsRunning(); |
| 32 } |
| 33 |
| 34 private: |
| 35 void SendSyntheticWheelEventWithPhaseEnded( |
| 36 blink::WebMouseWheelEvent last_mouse_wheel_event, |
| 37 bool should_route_event); |
| 38 void ScheduleMouseWheelEndDispatching(blink::WebMouseWheelEvent wheel_event, |
| 39 bool should_route_event); |
| 40 |
| 41 RenderWidgetHostImpl* const host_; |
| 42 RenderWidgetHostViewBase* const host_view_; |
| 43 base::OneShotTimer mouse_wheel_end_dispatch_timer_; |
| 44 |
| 45 DISALLOW_COPY_AND_ASSIGN(MouseWheelPhaseHandler); |
| 46 }; |
| 47 |
| 48 } // namespace content |
| 49 |
| 50 #endif // MOUSE_WHEEL_PHASE_HANDLER_H_ |
OLD | NEW |