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/public/web/WebInputEvent.h" | 10 #include "third_party/WebKit/public/web/WebInputEvent.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 // The result of |DispatchEvent()|, indicating either how the event was | 41 // The result of |DispatchEvent()|, indicating either how the event was |
42 // handled, or how it should be handled by the caller. | 42 // handled, or how it should be handled by the caller. |
43 enum Disposition { | 43 enum Disposition { |
44 CONSUMED, | 44 CONSUMED, |
45 SHOULD_FORWARD_TO_RENDERER, | 45 SHOULD_FORWARD_TO_RENDERER, |
46 SHOULD_FORWARD_TO_GESTURE_FILTER | 46 SHOULD_FORWARD_TO_GESTURE_FILTER |
47 }; | 47 }; |
48 // This must be called when dispatching any event from the | 48 // This must be called when dispatching any event from the |
49 // RenderWidgetHostView so that the state of the overscroll gesture can be | 49 // RenderWidgetHostView so that the state of the overscroll gesture can be |
50 // updated properly. | 50 // updated properly. |
51 Disposition DispatchEvent(const WebKit::WebInputEvent& event, | 51 Disposition DispatchEvent(const blink::WebInputEvent& event, |
52 const ui::LatencyInfo& latency_info); | 52 const ui::LatencyInfo& latency_info); |
53 | 53 |
54 // 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 |
55 // overscroll gesture status as appropriate. | 55 // overscroll gesture status as appropriate. |
56 void ReceivedEventACK(const WebKit::WebInputEvent& event, bool processed); | 56 void ReceivedEventACK(const blink::WebInputEvent& event, bool processed); |
57 | 57 |
58 // This must be called when a gesture event is filtered out and not sent to | 58 // This must be called when a gesture event is filtered out and not sent to |
59 // the renderer. | 59 // the renderer. |
60 void DiscardingGestureEvent(const WebKit::WebGestureEvent& event); | 60 void DiscardingGestureEvent(const blink::WebGestureEvent& event); |
61 | 61 |
62 OverscrollMode overscroll_mode() const { return overscroll_mode_; } | 62 OverscrollMode overscroll_mode() const { return overscroll_mode_; } |
63 | 63 |
64 void set_delegate(OverscrollControllerDelegate* delegate) { | 64 void set_delegate(OverscrollControllerDelegate* delegate) { |
65 delegate_ = delegate; | 65 delegate_ = delegate; |
66 } | 66 } |
67 | 67 |
68 // Resets internal states. | 68 // Resets internal states. |
69 void Reset(); | 69 void Reset(); |
70 | 70 |
71 // Cancels any in-progress overscroll (and calls OnOverscrollModeChange on the | 71 // Cancels any in-progress overscroll (and calls OnOverscrollModeChange on the |
72 // delegate if necessary), and resets internal states. | 72 // delegate if necessary), and resets internal states. |
73 void Cancel(); | 73 void Cancel(); |
74 | 74 |
75 private: | 75 private: |
76 friend class MockRenderWidgetHost; | 76 friend class MockRenderWidgetHost; |
77 | 77 |
78 // Different scrolling states. | 78 // Different scrolling states. |
79 enum ScrollState { | 79 enum ScrollState { |
80 STATE_UNKNOWN, | 80 STATE_UNKNOWN, |
81 STATE_PENDING, | 81 STATE_PENDING, |
82 STATE_CONTENT_SCROLLING, | 82 STATE_CONTENT_SCROLLING, |
83 STATE_OVERSCROLLING, | 83 STATE_OVERSCROLLING, |
84 }; | 84 }; |
85 | 85 |
86 // Returns true if the event indicates that the in-progress overscroll gesture | 86 // Returns true if the event indicates that the in-progress overscroll gesture |
87 // can now be completed. | 87 // can now be completed. |
88 bool DispatchEventCompletesAction( | 88 bool DispatchEventCompletesAction( |
89 const WebKit::WebInputEvent& event) const; | 89 const blink::WebInputEvent& event) const; |
90 | 90 |
91 // Returns true to indicate that dispatching the event should reset the | 91 // Returns true to indicate that dispatching the event should reset the |
92 // overscroll gesture status. | 92 // overscroll gesture status. |
93 bool DispatchEventResetsState(const WebKit::WebInputEvent& event) const; | 93 bool DispatchEventResetsState(const blink::WebInputEvent& event) const; |
94 | 94 |
95 // Processes an event to update the internal state for overscroll. Returns | 95 // Processes an event to update the internal state for overscroll. Returns |
96 // true if the state is updated, false otherwise. | 96 // true if the state is updated, false otherwise. |
97 bool ProcessEventForOverscroll(const WebKit::WebInputEvent& event); | 97 bool ProcessEventForOverscroll(const blink::WebInputEvent& event); |
98 | 98 |
99 // Processes horizontal overscroll. This can update both the overscroll mode | 99 // Processes horizontal overscroll. This can update both the overscroll mode |
100 // and the over scroll amount (i.e. |overscroll_mode_|, |overscroll_delta_x_| | 100 // and the over scroll amount (i.e. |overscroll_mode_|, |overscroll_delta_x_| |
101 // and |overscroll_delta_y_|). | 101 // and |overscroll_delta_y_|). |
102 void ProcessOverscroll(float delta_x, | 102 void ProcessOverscroll(float delta_x, |
103 float delta_y, | 103 float delta_y, |
104 WebKit::WebInputEvent::Type event_type); | 104 blink::WebInputEvent::Type event_type); |
105 | 105 |
106 // Completes the desired action from the current gesture. | 106 // Completes the desired action from the current gesture. |
107 void CompleteAction(); | 107 void CompleteAction(); |
108 | 108 |
109 // Sets the overscroll mode (and triggers callback in the delegate when | 109 // Sets the overscroll mode (and triggers callback in the delegate when |
110 // appropriate). | 110 // appropriate). |
111 void SetOverscrollMode(OverscrollMode new_mode); | 111 void SetOverscrollMode(OverscrollMode new_mode); |
112 | 112 |
113 // The current state of overscroll gesture. | 113 // The current state of overscroll gesture. |
114 OverscrollMode overscroll_mode_; | 114 OverscrollMode overscroll_mode_; |
(...skipping 13 matching lines...) Expand all Loading... |
128 // The delegate that receives the overscroll updates. The delegate is not | 128 // The delegate that receives the overscroll updates. The delegate is not |
129 // owned by this controller. | 129 // owned by this controller. |
130 OverscrollControllerDelegate* delegate_; | 130 OverscrollControllerDelegate* delegate_; |
131 | 131 |
132 DISALLOW_COPY_AND_ASSIGN(OverscrollController); | 132 DISALLOW_COPY_AND_ASSIGN(OverscrollController); |
133 }; | 133 }; |
134 | 134 |
135 } // namespace content | 135 } // namespace content |
136 | 136 |
137 #endif // CONTENT_BROWSER_RENDERER_HOST_OVERSCROLL_CONTROLLER_H_ | 137 #endif // CONTENT_BROWSER_RENDERER_HOST_OVERSCROLL_CONTROLLER_H_ |
OLD | NEW |