OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_GPU_INPUT_HANDLER_PROXY_H_ |
| 6 #define CONTENT_RENDERER_GPU_INPUT_HANDLER_PROXY_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/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/Source/Platform/chromium/public/WebGestureCurve.h" |
| 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebGestureCurveTarg
et.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebActiveWheelFlingPa
rameters.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
| 17 |
| 18 namespace content { |
| 19 |
| 20 class InputHandlerProxyClient; |
| 21 |
| 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) { |
| 29 public: |
| 30 explicit InputHandlerProxy(cc::InputHandler* input_handler); |
| 31 virtual ~InputHandlerProxy(); |
| 32 |
| 33 void SetClient(InputHandlerProxyClient* client); |
| 34 void HandleInputEvent(const WebKit::WebInputEvent& event); |
| 35 |
| 36 // cc::InputHandlerClient implementation. |
| 37 virtual void WillShutdown() OVERRIDE; |
| 38 virtual void Animate(base::TimeTicks time) OVERRIDE; |
| 39 virtual void MainThreadHasStoppedFlinging() OVERRIDE; |
| 40 |
| 41 // WebKit::WebGestureCurveTarget implementation. |
| 42 virtual void scrollBy(const WebKit::WebFloatSize& offset); |
| 43 virtual void notifyCurrentFlingVelocity(const WebKit::WebFloatSize& velocity); |
| 44 |
| 45 bool gesture_scroll_on_impl_thread_for_testing() const { |
| 46 return gesture_scroll_on_impl_thread_; |
| 47 } |
| 48 |
| 49 private: |
| 50 enum EventDisposition { |
| 51 DidHandle, |
| 52 DidNotHandle, |
| 53 DropEvent |
| 54 }; |
| 55 // This function processes the input event and determines the disposition, but |
| 56 // does not make any calls out to the InputHandlerProxyClient. Some input |
| 57 // types defer to helpers. |
| 58 EventDisposition HandleInputEventInternal(const WebKit::WebInputEvent& event); |
| 59 |
| 60 EventDisposition HandleGestureFling(const WebKit::WebGestureEvent& event); |
| 61 |
| 62 // Returns true if we scrolled by the increment. |
| 63 bool TouchpadFlingScroll(const WebKit::WebFloatSize& increment); |
| 64 |
| 65 // Returns true if we actually had an active fling to cancel. |
| 66 bool CancelCurrentFling(); |
| 67 |
| 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_; |
| 72 |
| 73 InputHandlerProxyClient* client_; |
| 74 cc::InputHandler* input_handler_; |
| 75 |
| 76 #ifndef NDEBUG |
| 77 bool expect_scroll_update_end_; |
| 78 bool expect_pinch_update_end_; |
| 79 #endif |
| 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 |
| 84 // true. |
| 85 bool fling_may_be_active_on_main_thread_; |
| 86 |
| 87 DISALLOW_COPY_AND_ASSIGN(InputHandlerProxy); |
| 88 }; |
| 89 |
| 90 } // namespace content |
| 91 |
| 92 #endif // CONTENT_RENDERER_GPU_INPUT_HANDLER_PROXY_H_ |
OLD | NEW |