| 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" |
| 11 | 11 |
| 12 namespace ui { | 12 namespace ui { |
| 13 struct LatencyInfo; | 13 struct LatencyInfo; |
| 14 } | 14 } |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 class MockRenderWidgetHost; | 18 class RenderWidgetHostViewAuraOverscrollTest; |
| 19 class OverscrollControllerDelegate; | 19 class OverscrollControllerDelegate; |
| 20 | 20 |
| 21 // Indicates the direction that the scroll is heading in relative to the screen, | 21 // Indicates the direction that the scroll is heading in relative to the screen, |
| 22 // with the top being NORTH. | 22 // with the top being NORTH. |
| 23 enum OverscrollMode { | 23 enum OverscrollMode { |
| 24 OVERSCROLL_NONE, | 24 OVERSCROLL_NONE, |
| 25 OVERSCROLL_NORTH, | 25 OVERSCROLL_NORTH, |
| 26 OVERSCROLL_SOUTH, | 26 OVERSCROLL_SOUTH, |
| 27 OVERSCROLL_WEST, | 27 OVERSCROLL_WEST, |
| 28 OVERSCROLL_EAST, | 28 OVERSCROLL_EAST, |
| (...skipping 12 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_QUEUE | 46 SHOULD_FORWARD_TO_GESTURE_QUEUE |
| 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 blink::WebInputEvent& event, | 51 Disposition DispatchEvent(const blink::WebInputEvent& event); |
| 52 const ui::LatencyInfo& latency_info); | |
| 53 | 52 |
| 54 // This must be called when the ACK for any event comes in. This updates the | 53 // This must be called when the ACK for any event comes in. This updates the |
| 55 // overscroll gesture status as appropriate. | 54 // overscroll gesture status as appropriate. |
| 56 void ReceivedEventACK(const blink::WebInputEvent& event, bool processed); | 55 void ReceivedEventACK(const blink::WebInputEvent& event, bool processed); |
| 57 | 56 |
| 58 // This must be called when a gesture event is filtered out and not sent to | 57 // This must be called when a gesture event is filtered out and not sent to |
| 59 // the renderer. | 58 // the renderer. |
| 60 void DiscardingGestureEvent(const blink::WebGestureEvent& event); | 59 void DiscardingGestureEvent(const blink::WebGestureEvent& event); |
| 61 | 60 |
| 62 OverscrollMode overscroll_mode() const { return overscroll_mode_; } | 61 OverscrollMode overscroll_mode() const { return overscroll_mode_; } |
| 63 | 62 |
| 64 void set_delegate(OverscrollControllerDelegate* delegate) { | 63 void set_delegate(OverscrollControllerDelegate* delegate) { |
| 65 delegate_ = delegate; | 64 delegate_ = delegate; |
| 66 } | 65 } |
| 67 | 66 |
| 68 // Resets internal states. | 67 // Resets internal states. |
| 69 void Reset(); | 68 void Reset(); |
| 70 | 69 |
| 71 // Cancels any in-progress overscroll (and calls OnOverscrollModeChange on the | 70 // Cancels any in-progress overscroll (and calls OnOverscrollModeChange on the |
| 72 // delegate if necessary), and resets internal states. | 71 // delegate if necessary), and resets internal states. |
| 73 void Cancel(); | 72 void Cancel(); |
| 74 | 73 |
| 75 private: | 74 private: |
| 76 friend class MockRenderWidgetHost; | 75 friend class RenderWidgetHostViewAuraOverscrollTest; |
| 77 | 76 |
| 78 // Different scrolling states. | 77 // Different scrolling states. |
| 79 enum ScrollState { | 78 enum ScrollState { |
| 80 STATE_UNKNOWN, | 79 STATE_UNKNOWN, |
| 81 STATE_PENDING, | 80 STATE_PENDING, |
| 82 STATE_CONTENT_SCROLLING, | 81 STATE_CONTENT_SCROLLING, |
| 83 STATE_OVERSCROLLING, | 82 STATE_OVERSCROLLING, |
| 84 }; | 83 }; |
| 85 | 84 |
| 86 // Returns true if the event indicates that the in-progress overscroll gesture | 85 // Returns true if the event indicates that the in-progress overscroll gesture |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 // The delegate that receives the overscroll updates. The delegate is not | 127 // The delegate that receives the overscroll updates. The delegate is not |
| 129 // owned by this controller. | 128 // owned by this controller. |
| 130 OverscrollControllerDelegate* delegate_; | 129 OverscrollControllerDelegate* delegate_; |
| 131 | 130 |
| 132 DISALLOW_COPY_AND_ASSIGN(OverscrollController); | 131 DISALLOW_COPY_AND_ASSIGN(OverscrollController); |
| 133 }; | 132 }; |
| 134 | 133 |
| 135 } // namespace content | 134 } // namespace content |
| 136 | 135 |
| 137 #endif // CONTENT_BROWSER_RENDERER_HOST_OVERSCROLL_CONTROLLER_H_ | 136 #endif // CONTENT_BROWSER_RENDERER_HOST_OVERSCROLL_CONTROLLER_H_ |
| OLD | NEW |