Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Side by Side Diff: content/browser/renderer_host/overscroll_controller.h

Issue 291003002: Move OverscrollController to RenderWidgetHostViewAura (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DCHECK_GE Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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,
29 OVERSCROLL_COUNT 29 OVERSCROLL_COUNT
30 }; 30 };
31 31
32 // When a page is scrolled beyond the scrollable region, it will trigger an 32 // When a page is scrolled beyond the scrollable region, it will trigger an
33 // overscroll gesture. This controller receives the events that are dispatched 33 // overscroll gesture. This controller receives the events that are dispatched
34 // to the renderer, and the ACKs of events, and updates the overscroll gesture 34 // to the renderer, and the ACKs of events, and updates the overscroll gesture
35 // status accordingly. 35 // status accordingly.
36 class OverscrollController { 36 class OverscrollController {
37 public: 37 public:
38 OverscrollController(); 38 OverscrollController();
39 virtual ~OverscrollController(); 39 virtual ~OverscrollController();
40 40
41 // The result of |DispatchEvent()|, indicating either how the event was
42 // handled, or how it should be handled by the caller.
43 enum Disposition {
44 CONSUMED,
45 SHOULD_FORWARD_TO_RENDERER,
46 SHOULD_FORWARD_TO_GESTURE_QUEUE
47 };
48 // This must be called when dispatching any event from the 41 // This must be called when dispatching any event from the
49 // RenderWidgetHostView so that the state of the overscroll gesture can be 42 // RenderWidgetHostView so that the state of the overscroll gesture can be
50 // updated properly. 43 // updated properly. Returns true if the event was handled, in which case
51 Disposition DispatchEvent(const blink::WebInputEvent& event, 44 // further processing should cease.
52 const ui::LatencyInfo& latency_info); 45 bool WillHandleEvent(const blink::WebInputEvent& event);
53 46
54 // This must be called when the ACK for any event comes in. This updates the 47 // This must be called when the ACK for any event comes in. This updates the
55 // overscroll gesture status as appropriate. 48 // overscroll gesture status as appropriate.
56 void ReceivedEventACK(const blink::WebInputEvent& event, bool processed); 49 void ReceivedEventACK(const blink::WebInputEvent& event, bool processed);
57 50
58 // This must be called when a gesture event is filtered out and not sent to 51 // This must be called when a gesture event is filtered out and not sent to
59 // the renderer. 52 // the renderer.
60 void DiscardingGestureEvent(const blink::WebGestureEvent& event); 53 void DiscardingGestureEvent(const blink::WebGestureEvent& event);
61 54
62 OverscrollMode overscroll_mode() const { return overscroll_mode_; } 55 OverscrollMode overscroll_mode() const { return overscroll_mode_; }
63 56
64 void set_delegate(OverscrollControllerDelegate* delegate) { 57 void set_delegate(OverscrollControllerDelegate* delegate) {
65 delegate_ = delegate; 58 delegate_ = delegate;
66 } 59 }
67 60
68 // Resets internal states. 61 // Resets internal states.
69 void Reset(); 62 void Reset();
70 63
71 // Cancels any in-progress overscroll (and calls OnOverscrollModeChange on the 64 // Cancels any in-progress overscroll (and calls OnOverscrollModeChange on the
72 // delegate if necessary), and resets internal states. 65 // delegate if necessary), and resets internal states.
73 void Cancel(); 66 void Cancel();
74 67
75 private: 68 private:
76 friend class MockRenderWidgetHost; 69 friend class RenderWidgetHostViewAuraOverscrollTest;
77 70
78 // Different scrolling states. 71 // Different scrolling states.
79 enum ScrollState { 72 enum ScrollState {
80 STATE_UNKNOWN, 73 STATE_UNKNOWN,
81 STATE_PENDING, 74 STATE_PENDING,
82 STATE_CONTENT_SCROLLING, 75 STATE_CONTENT_SCROLLING,
83 STATE_OVERSCROLLING, 76 STATE_OVERSCROLLING,
84 }; 77 };
85 78
86 // Returns true if the event indicates that the in-progress overscroll gesture 79 // Returns true if the event indicates that the in-progress overscroll gesture
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // The delegate that receives the overscroll updates. The delegate is not 121 // The delegate that receives the overscroll updates. The delegate is not
129 // owned by this controller. 122 // owned by this controller.
130 OverscrollControllerDelegate* delegate_; 123 OverscrollControllerDelegate* delegate_;
131 124
132 DISALLOW_COPY_AND_ASSIGN(OverscrollController); 125 DISALLOW_COPY_AND_ASSIGN(OverscrollController);
133 }; 126 };
134 127
135 } // namespace content 128 } // namespace content
136 129
137 #endif // CONTENT_BROWSER_RENDERER_HOST_OVERSCROLL_CONTROLLER_H_ 130 #endif // CONTENT_BROWSER_RENDERER_HOST_OVERSCROLL_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698