| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_FLING_FLINGER_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_FLING_FLINGER_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/timer/timer.h" |
| 10 #include "content/browser/renderer_host/input/fling/fling_curve.h" |
| 11 #include "content/port/browser/event_with_latency_info.h" |
| 12 #include "content/port/common/input_event_ack_state.h" |
| 13 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 14 #include "ui/gfx/point.h" |
| 15 |
| 16 namespace content { |
| 17 class FlingerTest; |
| 18 class MockRenderWidgetHost; |
| 19 |
| 20 class FlingHelper { |
| 21 public: |
| 22 virtual ~FlingHelper() {} |
| 23 |
| 24 virtual void SendEventForFling(const WebKit::WebInputEvent& event) = 0; |
| 25 virtual void FlingFinished(WebKit::WebGestureEvent::SourceDevice source) = 0; |
| 26 }; |
| 27 |
| 28 // Handles fling gestures. |
| 29 class CONTENT_EXPORT Flinger : public FlingCurveTarget { |
| 30 public: |
| 31 explicit Flinger(FlingHelper* helper); |
| 32 virtual ~Flinger() {} |
| 33 |
| 34 // Filters for fling (and related) events. Returns true if this event should |
| 35 // not be processed any further. |
| 36 bool HandleGestureEvent(const GestureEventWithLatencyInfo& gesture_event); |
| 37 |
| 38 // Filters mouse events that may be just canceling an in-process fling. |
| 39 bool HandleMouseEvent(const MouseEventWithLatencyInfo& mouse_event); |
| 40 |
| 41 // Filters mouse events that may be just canceling an in-process fling. |
| 42 bool HandleWheelEvent(const MouseWheelEventWithLatencyInfo& wheel_event); |
| 43 |
| 44 // Filters key events that may be just canceling an in-process fling. |
| 45 bool HandleKeyboardEvent(); |
| 46 |
| 47 void ProcessEventAck(WebKit::WebInputEvent::Type type, |
| 48 InputEventAckState ack_result, |
| 49 const ui::LatencyInfo& latency); |
| 50 |
| 51 private: |
| 52 friend class FlingerTest; |
| 53 friend class MockRenderWidgetHost; |
| 54 |
| 55 // Overridden from FlingCurveTarget. |
| 56 virtual void ScrollBy(const gfx::PointF& delta) OVERRIDE; |
| 57 virtual void NotifyCurrentFlingVelocity(const gfx::PointF& velocity) OVERRIDE; |
| 58 |
| 59 void StartCurveTimer(); |
| 60 void CurveTimerFired(); |
| 61 |
| 62 void StopFlingAndCleanup(); |
| 63 |
| 64 FlingHelper* helper_; |
| 65 |
| 66 scoped_ptr<FlingCurve> fling_curve_; |
| 67 |
| 68 // Timer to send us ticks to send GSUs at during a fling. |
| 69 // TODO(varunjain): Use vsync instead of this timer. |
| 70 base::OneShotTimer<Flinger> curve_timer_; |
| 71 |
| 72 bool fling_in_progress_; |
| 73 bool ignore_next_tap_; |
| 74 bool ignore_next_click_; |
| 75 gfx::Point fling_start_position_; |
| 76 gfx::Point fling_start_global_position_; |
| 77 double fling_start_time_secs_; |
| 78 int fling_modifier_; |
| 79 WebKit::WebGestureEvent::SourceDevice fling_source_; |
| 80 |
| 81 DISALLOW_COPY_AND_ASSIGN(Flinger); |
| 82 }; |
| 83 |
| 84 } // namespace content |
| 85 |
| 86 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_FLING_FLINGER_H_ |
| OLD | NEW |