Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(794)

Unified Diff: content/browser/renderer_host/input/fling/flinger.h

Issue 41703006: Move fling implementation from renderer to browser: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/input/fling/flinger.h
diff --git a/content/browser/renderer_host/input/fling/flinger.h b/content/browser/renderer_host/input/fling/flinger.h
new file mode 100644
index 0000000000000000000000000000000000000000..3796bb53db2ad743e1a0250e9debc1d6a1af2149
--- /dev/null
+++ b/content/browser/renderer_host/input/fling/flinger.h
@@ -0,0 +1,84 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_FLING_FLINGER_H_
+#define CONTENT_BROWSER_RENDERER_HOST_INPUT_FLING_FLINGER_H_
+
+#include "base/basictypes.h"
+#include "base/timer/timer.h"
+#include "content/browser/renderer_host/input/fling/fling_curve.h"
+#include "content/port/browser/event_with_latency_info.h"
+#include "content/port/common/input_event_ack_state.h"
+#include "third_party/WebKit/public/web/WebInputEvent.h"
+#include "ui/gfx/point.h"
+
+namespace content {
+class FlingerTest;
+
+class FlingHelper {
+ public:
+ virtual ~FlingHelper() {}
+
+ virtual void SendEventForFling(const blink::WebInputEvent& event) = 0;
+ virtual void FlingFinished(blink::WebGestureEvent::SourceDevice source) = 0;
+};
+
+// Handles fling gestures.
+class CONTENT_EXPORT Flinger : public FlingCurveTarget {
+ public:
+ explicit Flinger(FlingHelper* helper);
+ virtual ~Flinger() {}
+
+ // Filters for fling (and related) events. Returns true if this event should
+ // not be processed any further.
+ bool HandleGestureEvent(const GestureEventWithLatencyInfo& gesture_event);
+
+ // Filters mouse events that may be just canceling an in-process fling.
+ bool HandleMouseEvent(const MouseEventWithLatencyInfo& mouse_event);
+
+ // Filters mouse events that may be just canceling an in-process fling.
+ bool HandleWheelEvent(const MouseWheelEventWithLatencyInfo& wheel_event);
+
+ // Filters key events that may be just canceling an in-process fling.
+ bool HandleKeyboardEvent();
+
+ void ProcessEventAck(blink::WebInputEvent::Type type,
+ InputEventAckState ack_result,
+ const ui::LatencyInfo& latency);
+
+ private:
+ friend class FlingerTest;
+
+ // Overridden from FlingCurveTarget.
+ virtual void ScrollBy(const gfx::PointF& delta) OVERRIDE;
+ virtual void NotifyCurrentFlingVelocity(const gfx::PointF& velocity) OVERRIDE;
+
+ void StartCurveTimer();
+ void CurveTimerFired();
+
+ void StopFlingAndCleanup();
+
+ FlingHelper* helper_;
+
+ scoped_ptr<FlingCurve> fling_curve_;
+
+ // Timer to send us ticks to send GSUs at during a fling.
+ // TODO(varunjain): Use vsync instead of this timer.
+ base::OneShotTimer<Flinger> curve_timer_;
+
+ bool fling_in_progress_;
+ bool ignore_next_tap_;
+ bool ignore_next_click_;
+ gfx::Point fling_start_position_;
+ gfx::Point fling_start_global_position_;
+ double fling_start_time_secs_;
+ int fling_modifier_;
+ blink::WebGestureEvent::SourceDevice fling_source_;
+
+ DISALLOW_COPY_AND_ASSIGN(Flinger);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_FLING_FLINGER_H_

Powered by Google App Engine
This is Rietveld 408576698