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/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 void set_delegate(OverscrollControllerDelegate* delegate) { | 55 void set_delegate(OverscrollControllerDelegate* delegate) { |
56 delegate_ = delegate; | 56 delegate_ = delegate; |
57 } | 57 } |
58 | 58 |
59 // Resets internal states. | 59 // Resets internal states. |
60 void Reset(); | 60 void Reset(); |
61 | 61 |
62 private: | 62 private: |
63 friend class MockRenderWidgetHost; | 63 friend class MockRenderWidgetHost; |
64 | 64 |
| 65 // Different scrolling states. |
| 66 enum ScrollState { |
| 67 STATE_UNKNOWN, |
| 68 STATE_PENDING, |
| 69 STATE_CONTENT_SCROLLING, |
| 70 STATE_OVERSCROLLING, |
| 71 }; |
| 72 |
65 // Returns true if the event indicates that the in-progress overscroll gesture | 73 // Returns true if the event indicates that the in-progress overscroll gesture |
66 // can now be completed. | 74 // can now be completed. |
67 bool DispatchEventCompletesAction( | 75 bool DispatchEventCompletesAction( |
68 const WebKit::WebInputEvent& event) const; | 76 const WebKit::WebInputEvent& event) const; |
69 | 77 |
70 // Returns true to indicate that dispatching the event should reset the | 78 // Returns true to indicate that dispatching the event should reset the |
71 // overscroll gesture status. | 79 // overscroll gesture status. |
72 bool DispatchEventResetsState(const WebKit::WebInputEvent& event) const; | 80 bool DispatchEventResetsState(const WebKit::WebInputEvent& event) const; |
73 | 81 |
74 // Processes an event and updates internal state for overscroll. | 82 // Processes an event and updates internal state for overscroll. |
(...skipping 14 matching lines...) Expand all Loading... |
89 // Returns whether the input event should be forwarded to the | 97 // Returns whether the input event should be forwarded to the |
90 // GestureEventFilter. | 98 // GestureEventFilter. |
91 bool ShouldForwardToGestureFilter(const WebKit::WebInputEvent& event) const; | 99 bool ShouldForwardToGestureFilter(const WebKit::WebInputEvent& event) const; |
92 | 100 |
93 // The RenderWidgetHost that owns this overscroll controller. | 101 // The RenderWidgetHost that owns this overscroll controller. |
94 RenderWidgetHostImpl* render_widget_host_; | 102 RenderWidgetHostImpl* render_widget_host_; |
95 | 103 |
96 // The current state of overscroll gesture. | 104 // The current state of overscroll gesture. |
97 OverscrollMode overscroll_mode_; | 105 OverscrollMode overscroll_mode_; |
98 | 106 |
| 107 // Used to keep track of the scrolling state. |
| 108 // 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 |
| 110 // process any of the subsequent scroll events for generating overscroll |
| 111 // gestures. |
| 112 ScrollState scroll_state_; |
| 113 |
99 // The amount of overscroll in progress. These values are invalid when | 114 // The amount of overscroll in progress. These values are invalid when |
100 // |overscroll_mode_| is set to OVERSCROLL_NONE. | 115 // |overscroll_mode_| is set to OVERSCROLL_NONE. |
101 float overscroll_delta_x_; | 116 float overscroll_delta_x_; |
102 float overscroll_delta_y_; | 117 float overscroll_delta_y_; |
103 | 118 |
104 // The delegate that receives the overscroll updates. The delegate is not | 119 // The delegate that receives the overscroll updates. The delegate is not |
105 // owned by this controller. | 120 // owned by this controller. |
106 OverscrollControllerDelegate* delegate_; | 121 OverscrollControllerDelegate* delegate_; |
107 | 122 |
108 DISALLOW_COPY_AND_ASSIGN(OverscrollController); | 123 DISALLOW_COPY_AND_ASSIGN(OverscrollController); |
109 }; | 124 }; |
110 | 125 |
111 } // namespace content | 126 } // namespace content |
112 | 127 |
113 #endif // CONTENT_BROWSER_RENDERER_HOST_OVERSCROLL_CONTROLLER_H_ | 128 #endif // CONTENT_BROWSER_RENDERER_HOST_OVERSCROLL_CONTROLLER_H_ |
OLD | NEW |