| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_OVERSCROLL_CONTROLLER_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_OVERSCROLL_CONTROLLER_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_OVERSCROLL_CONTROLLER_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_OVERSCROLL_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "content/common/content_export.h" |
| 10 #include "third_party/WebKit/public/platform/WebGestureEvent.h" | 11 #include "third_party/WebKit/public/platform/WebGestureEvent.h" |
| 11 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 12 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
| 12 | 13 |
| 13 namespace content { | 14 namespace content { |
| 14 | 15 |
| 15 class RenderWidgetHostViewAuraOverscrollTest; | 16 class RenderWidgetHostViewAuraOverscrollTest; |
| 16 class OverscrollControllerDelegate; | 17 class OverscrollControllerDelegate; |
| 17 | 18 |
| 18 // Indicates the direction that the scroll is heading in relative to the screen, | 19 // Indicates the direction that the scroll is heading in relative to the screen, |
| 19 // with the top being NORTH. | 20 // with the top being NORTH. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 31 TOUCHPAD, | 32 TOUCHPAD, |
| 32 TOUCHSCREEN, | 33 TOUCHSCREEN, |
| 33 }; | 34 }; |
| 34 | 35 |
| 35 // When a page is scrolled beyond the scrollable region, it will trigger an | 36 // When a page is scrolled beyond the scrollable region, it will trigger an |
| 36 // overscroll gesture. This controller receives the events that are dispatched | 37 // overscroll gesture. This controller receives the events that are dispatched |
| 37 // to the renderer, and the ACKs of events, and updates the overscroll gesture | 38 // to the renderer, and the ACKs of events, and updates the overscroll gesture |
| 38 // status accordingly. | 39 // status accordingly. |
| 39 class OverscrollController { | 40 class OverscrollController { |
| 40 public: | 41 public: |
| 41 OverscrollController(); | 42 // Exported for testing. |
| 42 virtual ~OverscrollController(); | 43 // TODO(mcnee): Tests needing CONTENT_EXPORT are BrowserPlugin specific. |
| 44 // Remove after removing BrowserPlugin (crbug.com/533069). |
| 45 CONTENT_EXPORT OverscrollController(); |
| 46 CONTENT_EXPORT virtual ~OverscrollController(); |
| 43 | 47 |
| 44 // This must be called when dispatching any event from the | 48 // This must be called when dispatching any event from the |
| 45 // RenderWidgetHostView so that the state of the overscroll gesture can be | 49 // RenderWidgetHostView so that the state of the overscroll gesture can be |
| 46 // updated properly. Returns true if the event was handled, in which case | 50 // updated properly. Returns true if the event was handled, in which case |
| 47 // further processing should cease. | 51 // further processing should cease. |
| 48 bool WillHandleEvent(const blink::WebInputEvent& event); | 52 bool WillHandleEvent(const blink::WebInputEvent& event); |
| 49 | 53 |
| 50 // This must be called when the ACK for any event comes in. This updates the | 54 // This must be called when the ACK for any event comes in. This updates the |
| 51 // overscroll gesture status as appropriate. | 55 // overscroll gesture status as appropriate. |
| 52 void ReceivedEventACK(const blink::WebInputEvent& event, bool processed); | 56 // Virtual and exported for testing. |
| 57 // TODO(mcnee): Tests needing CONTENT_EXPORT and virtual are BrowserPlugin |
| 58 // specific. Remove after removing BrowserPlugin (crbug.com/533069). |
| 59 CONTENT_EXPORT virtual void ReceivedEventACK( |
| 60 const blink::WebInputEvent& event, |
| 61 bool processed); |
| 53 | 62 |
| 54 // This must be called when a gesture event is filtered out and not sent to | 63 // This must be called when a gesture event is filtered out and not sent to |
| 55 // the renderer. | 64 // the renderer. |
| 56 void DiscardingGestureEvent(const blink::WebGestureEvent& event); | 65 void DiscardingGestureEvent(const blink::WebGestureEvent& event); |
| 57 | 66 |
| 58 OverscrollMode overscroll_mode() const { return overscroll_mode_; } | 67 OverscrollMode overscroll_mode() const { return overscroll_mode_; } |
| 59 | 68 |
| 60 void set_delegate(OverscrollControllerDelegate* delegate) { | 69 void set_delegate(OverscrollControllerDelegate* delegate) { |
| 61 delegate_ = delegate; | 70 delegate_ = delegate; |
| 62 } | 71 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 // The delegate that receives the overscroll updates. The delegate is not | 137 // The delegate that receives the overscroll updates. The delegate is not |
| 129 // owned by this controller. | 138 // owned by this controller. |
| 130 OverscrollControllerDelegate* delegate_; | 139 OverscrollControllerDelegate* delegate_; |
| 131 | 140 |
| 132 DISALLOW_COPY_AND_ASSIGN(OverscrollController); | 141 DISALLOW_COPY_AND_ASSIGN(OverscrollController); |
| 133 }; | 142 }; |
| 134 | 143 |
| 135 } // namespace content | 144 } // namespace content |
| 136 | 145 |
| 137 #endif // CONTENT_BROWSER_RENDERER_HOST_OVERSCROLL_CONTROLLER_H_ | 146 #endif // CONTENT_BROWSER_RENDERER_HOST_OVERSCROLL_CONTROLLER_H_ |
| OLD | NEW |