1 // Copyright (c) 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.
5 #ifndef CONTENT_RENDERER_GPU_INPUT_HANDLER_PROXY_H_
6 #define CONTENT_RENDERER_GPU_INPUT_HANDLER_PROXY_H_
8 #include "base/basictypes.h"
9 #include "base/containers/hash_tables.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "cc/input/input_handler.h"
12 #include "content/common/content_export.h"
13 #include "third_party/WebKit/public/web/WebActiveWheelFlingParameters.h"
14 #include "third_party/WebKit/public/web/WebInputEvent.h"
15 #include "third_party/WebKit/public/platform/WebGestureCurve.h"
16 #include "third_party/WebKit/public/platform/WebGestureCurveTarget.h"
20 class InputHandlerProxyClient;
22 // This class is a proxy between the content input event filtering and the
23 // compositor's input handling logic. InputHandlerProxy instances live entirely
24 // on the compositor thread. Each InputHandler instance handles input events
25 // intended for a specific WebWidget.
26 class CONTENT_EXPORT InputHandlerProxy
27 : public cc::InputHandlerClient,
28 public NON_EXPORTED_BASE(WebKit::WebGestureCurveTarget) {
30 explicit InputHandlerProxy(cc::InputHandler* input_handler);
31 virtual ~InputHandlerProxy();
33 void SetClient(InputHandlerProxyClient* client);
35 enum EventDisposition {
40 EventDisposition HandleInputEventWithLatencyInfo(
41 const WebKit::WebInputEvent& event,
42 const ui::LatencyInfo& latency_info);
43 EventDisposition HandleInputEvent(const WebKit::WebInputEvent& event);
45 // cc::InputHandlerClient implementation.
46 virtual void WillShutdown() OVERRIDE;
47 virtual void Animate(base::TimeTicks time) OVERRIDE;
48 virtual void MainThreadHasStoppedFlinging() OVERRIDE;
49 virtual void DidOverscroll(const cc::DidOverscrollParams& params) OVERRIDE;
51 // WebKit::WebGestureCurveTarget implementation.
52 virtual void scrollBy(const WebKit::WebFloatSize& offset);
53 virtual void notifyCurrentFlingVelocity(const WebKit::WebFloatSize& velocity);
55 bool gesture_scroll_on_impl_thread_for_testing() const {
56 return gesture_scroll_on_impl_thread_;
60 EventDisposition HandleGestureFling(const WebKit::WebGestureEvent& event);
62 // Returns true if we scrolled by the increment.
63 bool TouchpadFlingScroll(const WebKit::WebFloatSize& increment);
65 // Returns true if we actually had an active fling to cancel.
66 bool CancelCurrentFling();
68 scoped_ptr<WebKit::WebGestureCurve> fling_curve_;
69 // Parameters for the active fling animation, stored in case we need to
70 // transfer it out later.
71 WebKit::WebActiveWheelFlingParameters fling_parameters_;
73 InputHandlerProxyClient* client_;
74 cc::InputHandler* input_handler_;
77 bool expect_scroll_update_end_;
78 bool expect_pinch_update_end_;
80 bool gesture_scroll_on_impl_thread_;
81 bool gesture_pinch_on_impl_thread_;
82 // This is always false when there are no flings on the main thread, but
83 // conservative in the sense that we might not be actually flinging when it is
85 bool fling_may_be_active_on_main_thread_;
86 // The axes on which the current fling has overshot the bounds of the content.
87 bool fling_overscrolled_horizontally_;
88 bool fling_overscrolled_vertically_;
90 DISALLOW_COPY_AND_ASSIGN(InputHandlerProxy);
93 } // namespace content
95 #endif // CONTENT_RENDERER_GPU_INPUT_HANDLER_PROXY_H_