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