Chromium Code Reviews| 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 "third_party/WebKit/public/platform/WebGestureEvent.h" | 10 #include "third_party/WebKit/public/platform/WebGestureEvent.h" | 
| 11 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 11 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 
| 12 | 12 | 
| 13 namespace content { | 13 namespace content { | 
| 14 | 14 | 
| 15 class RenderWidgetHostViewAuraOverscrollTest; | 15 class RenderWidgetHostViewAuraOverscrollTest; | 
| 16 class OverscrollControllerDelegate; | 16 class OverscrollControllerDelegate; | 
| 17 | 17 | 
| 18 // Indicates the direction that the scroll is heading in relative to the screen, | 18 // Indicates the direction that the scroll is heading in relative to the screen, | 
| 19 // with the top being NORTH. | 19 // with the top being NORTH. | 
| 20 enum OverscrollMode { | 20 enum OverscrollMode { | 
| 21 OVERSCROLL_NONE, | 21 OVERSCROLL_NONE, | 
| 22 OVERSCROLL_NORTH, | 22 OVERSCROLL_NORTH, | 
| 23 OVERSCROLL_SOUTH, | 23 OVERSCROLL_SOUTH, | 
| 24 OVERSCROLL_WEST, | 24 OVERSCROLL_WEST, | 
| 25 OVERSCROLL_EAST | 25 OVERSCROLL_EAST | 
| 26 }; | 26 }; | 
| 27 | 27 | 
| 28 // Indicates the source device that was used to trigger the overscroll gesture. | |
| 29 enum OverscrollSource { | |
| 
 
mohsen
2017/02/21 20:47:58
I believe it's preferred to use "enum class". Then
 
mfomitchev
2017/02/23 02:59:42
Done.
 
 | |
| 30 OVERSCROLL_SOURCE_NONE, | |
| 31 OVERSCROLL_TOUCHPAD, | |
| 32 OVERSCROLL_TOUCHSCREEN, | |
| 33 }; | |
| 34 | |
| 28 // When a page is scrolled beyond the scrollable region, it will trigger an | 35 // When a page is scrolled beyond the scrollable region, it will trigger an | 
| 29 // overscroll gesture. This controller receives the events that are dispatched | 36 // overscroll gesture. This controller receives the events that are dispatched | 
| 30 // to the renderer, and the ACKs of events, and updates the overscroll gesture | 37 // to the renderer, and the ACKs of events, and updates the overscroll gesture | 
| 31 // status accordingly. | 38 // status accordingly. | 
| 32 class OverscrollController { | 39 class OverscrollController { | 
| 33 public: | 40 public: | 
| 34 OverscrollController(); | 41 OverscrollController(); | 
| 35 virtual ~OverscrollController(); | 42 virtual ~OverscrollController(); | 
| 36 | 43 | 
| 37 // This must be called when dispatching any event from the | 44 // This must be called when dispatching any event from the | 
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 | 94 | 
| 88 // Processes horizontal overscroll. This can update both the overscroll mode | 95 // Processes horizontal overscroll. This can update both the overscroll mode | 
| 89 // and the over scroll amount (i.e. |overscroll_mode_|, |overscroll_delta_x_| | 96 // and the over scroll amount (i.e. |overscroll_mode_|, |overscroll_delta_x_| | 
| 90 // and |overscroll_delta_y_|). Returns true if overscroll was handled by the | 97 // and |overscroll_delta_y_|). Returns true if overscroll was handled by the | 
| 91 // delegate. | 98 // delegate. | 
| 92 bool ProcessOverscroll(float delta_x, float delta_y, bool is_touchpad); | 99 bool ProcessOverscroll(float delta_x, float delta_y, bool is_touchpad); | 
| 93 | 100 | 
| 94 // Completes the desired action from the current gesture. | 101 // Completes the desired action from the current gesture. | 
| 95 void CompleteAction(); | 102 void CompleteAction(); | 
| 96 | 103 | 
| 97 // Sets the overscroll mode (and triggers callback in the delegate when | 104 // Sets the overscroll mode and triggers callback in the delegate when | 
| 98 // appropriate). | 105 // appropriate. When a new overscroll is started (i.e. when |new_mode| is not | 
| 99 void SetOverscrollMode(OverscrollMode new_mode); | 106 // equal to OVERSCROLL_NONE), |source| will be set to the device that | 
| 107 // triggered the overscroll gesture. | |
| 108 void SetOverscrollMode(OverscrollMode new_mode, OverscrollSource source); | |
| 100 | 109 | 
| 101 // Whether this event should be processed or not handled by the controller. | 110 // Whether this event should be processed or not handled by the controller. | 
| 102 bool ShouldProcessEvent(const blink::WebInputEvent& event); | 111 bool ShouldProcessEvent(const blink::WebInputEvent& event); | 
| 103 | 112 | 
| 104 // The current state of overscroll gesture. | 113 // The current state of overscroll gesture. | 
| 105 OverscrollMode overscroll_mode_; | 114 OverscrollMode overscroll_mode_; | 
| 106 | 115 | 
| 107 // Used to keep track of the scrolling state. | 116 // Used to keep track of the scrolling state. | 
| 108 // If scrolling starts, and some scroll events are consumed at the beginning | 117 // If scrolling starts, and some scroll events are consumed at the beginning | 
| 109 // of the scroll (i.e. some content on the web-page was scrolled), then do not | 118 // of the scroll (i.e. some content on the web-page was scrolled), then do not | 
| 110 // process any of the subsequent scroll events for generating overscroll | 119 // process any of the subsequent scroll events for generating overscroll | 
| 111 // gestures. | 120 // gestures. | 
| 112 ScrollState scroll_state_; | 121 ScrollState scroll_state_; | 
| 113 | 122 | 
| 114 // The amount of overscroll in progress. These values are invalid when | 123 // The amount of overscroll in progress. These values are invalid when | 
| 115 // |overscroll_mode_| is set to OVERSCROLL_NONE. | 124 // |overscroll_mode_| is set to OVERSCROLL_NONE. | 
| 116 float overscroll_delta_x_; | 125 float overscroll_delta_x_; | 
| 117 float overscroll_delta_y_; | 126 float overscroll_delta_y_; | 
| 118 | 127 | 
| 119 // The delegate that receives the overscroll updates. The delegate is not | 128 // The delegate that receives the overscroll updates. The delegate is not | 
| 120 // owned by this controller. | 129 // owned by this controller. | 
| 121 OverscrollControllerDelegate* delegate_; | 130 OverscrollControllerDelegate* delegate_; | 
| 122 | 131 | 
| 123 DISALLOW_COPY_AND_ASSIGN(OverscrollController); | 132 DISALLOW_COPY_AND_ASSIGN(OverscrollController); | 
| 124 }; | 133 }; | 
| 125 | 134 | 
| 126 } // namespace content | 135 } // namespace content | 
| 127 | 136 | 
| 128 #endif // CONTENT_BROWSER_RENDERER_HOST_OVERSCROLL_CONTROLLER_H_ | 137 #endif // CONTENT_BROWSER_RENDERER_HOST_OVERSCROLL_CONTROLLER_H_ | 
| OLD | NEW |