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

Side by Side Diff: third_party/WebKit/Source/core/input/ScrollManager.h

Issue 2010133003: Add ScrollManager class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding TODOs Created 4 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef ScrollManager_h
6 #define ScrollManager_h
7
8 #include "core/CoreExport.h"
9 #include "core/page/EventWithHitTestResults.h"
10 #include "platform/PlatformEvent.h"
11 #include "platform/geometry/LayoutSize.h"
12 #include "platform/heap/Handle.h"
13 #include "platform/heap/Visitor.h"
14 #include "platform/scroll/ScrollTypes.h"
15 #include "public/platform/WebInputEventResult.h"
16 #include "wtf/Allocator.h"
17 #include <deque>
18
19 namespace blink {
20
21 class AutoscrollController;
22 class FloatPoint;
23 class FrameHost;
24 class LayoutBox;
25 class LayoutObject;
26 class LocalFrame;
27 class PaintLayer;
28 class PaintLayerScrollableArea;
29 class PlatformGestureEvent;
30 class Scrollbar;
31 class ScrollState;
32
33 // This class takes care of scrolling and resizing and the related states. The
34 // user action that causes scrolling or resizing is determined in other *Manager
35 // classes and they call into this class for doing the work.
36 class CORE_EXPORT ScrollManager {
37 WTF_MAKE_NONCOPYABLE(ScrollManager);
38 DISALLOW_NEW();
39 public:
40 explicit ScrollManager(LocalFrame*);
41 ~ScrollManager();
42 DECLARE_TRACE();
43
44 void clear();
45
46 bool panScrollInProgress() const;
47 AutoscrollController* autoscrollController() const;
48 void stopAutoscroll();
49
50 // Performs a chaining scroll, within a *single* frame, starting from a
51 // given node and optionally stopping on a given node.
52 // granularity - The units that the scroll delta parameter is in.
53 // delta - The delta to scroll by, in the units of the granularity param
54 // (e.g. pixels, lines, pages, etc.). These are in a physical
55 // direction. i.e. Positive is down and right.
56 // position - Where the scroll originated from (e.g. touch location).
57 // velocity - The velocity of the scroll in the case of fling gestures.
58 // startNode - The node to start the scroll chaining from.
59 // stopNode - On input, if non-null, the node at which we should stop
60 // chaining. On output, if provided and a node was scrolled,
61 // stopNode will point to that node.
62 // consumed - [OUT] Whether the scroll was consumed. This is different than
63 // ScrollResult.didScroll since we might not have scrolled but
64 // have reached the stopNode and thus don't want to continue
65 // chaining the scroll.
66 ScrollResult physicalScroll(
67 ScrollGranularity,
68 const FloatSize& delta,
69 const FloatPoint& position,
70 const FloatSize& velocity,
71 Node* startNode,
72 Node** stopNode,
73 bool* consumed);
74
75 // Performs a chaining logical scroll, within a *single* frame, starting
76 // from either a provided starting node or a default based on the focused or
77 // most recently clicked node, falling back to the frame.
78 // Returns true if the scroll was consumed.
79 // direction - The logical direction to scroll in. This will be converted to
80 // a physical direction for each LayoutBox we try to scroll
81 // based on that box's writing mode.
82 // granularity - The units that the scroll delta parameter is in.
83 // startNode - Optional. If provided, start chaining from the given node.
84 // If not, use the current focus or last clicked node.
85 bool logicalScroll(ScrollDirection, ScrollGranularity, Node* startNode, Node * mousePressNode);
86
87 // Performs a logical scroll that chains, crossing frames, starting from
88 // the given node or a reasonable default (focus/last clicked).
89 bool bubblingScroll(ScrollDirection, ScrollGranularity, Node* startingNode, Node* mousePressNode);
90
91 void setFrameWasScrolledByUser();
92
93
94 // TODO(crbug.com/616491): Consider moving all gesture related functions to
95 // another class.
96
97 // Handle the provided scroll gesture event, propagating down to child frame s as necessary.
98 WebInputEventResult handleGestureScrollEvent(const PlatformGestureEvent&);
99
100 WebInputEventResult handleGestureScrollEnd(const PlatformGestureEvent&);
101
102 bool isScrollbarHandlingGestures() const;
103
104 // Returns true if the gesture event should be handled in ScrollManager.
105 bool canHandleGestureEvent(const GestureEventWithHitTestResults&);
106
107 // These functions are related to |m_resizeScrollableArea|.
108 bool inResizeMode() const;
109 void resize(const PlatformEvent&);
110 // Clears |m_resizeScrollableArea|. if |shouldNotBeNull| is true this
111 // function DCHECKs to make sure that variable is indeed not null.
112 void clearResizeScrollableArea(bool shouldNotBeNull);
113 void setResizeScrollableArea(PaintLayer*, IntPoint);
114
115 private:
116
117 WebInputEventResult handleGestureScrollUpdate(const PlatformGestureEvent&);
118 WebInputEventResult handleGestureScrollBegin(const PlatformGestureEvent&);
119
120 WebInputEventResult passScrollGestureEventToWidget(const PlatformGestureEven t&, LayoutObject*);
121
122 void clearGestureScrollState();
123
124 void customizedScroll(const Node& startNode, ScrollState&);
125
126 ScrollResult scrollBox(
127 LayoutBox*,
128 ScrollGranularity,
129 const FloatSize& delta,
130 const FloatPoint& position,
131 const FloatSize& velocity,
132 bool* wasRootScroller);
133
134 FrameHost* frameHost() const;
135
136 bool isRootScroller(const Node&) const;
137
138 bool handleScrollGestureOnResizer(Node*, const PlatformGestureEvent&);
139
140
141 // NOTE: If adding a new field to this class please ensure that it is
142 // cleared in |ScrollManager::clear()|.
143
144 const Member<LocalFrame> m_frame;
145
146 // Only used with the ScrollCustomization runtime enabled feature.
147 std::deque<int> m_currentScrollChain;
148
149 Member<Node> m_scrollGestureHandlingNode;
150
151 bool m_lastGestureScrollOverWidget;
152
153 // The most recent element to scroll natively during this scroll
154 // sequence. Null if no native element has scrolled this scroll
155 // sequence, or if the most recent element to scroll used scroll
156 // customization.
157 Member<Node> m_previousGestureScrolledNode;
158
159 // True iff some of the delta has been consumed for the current
160 // scroll sequence in this frame, or any child frames. Only used
161 // with ScrollCustomization. If some delta has been consumed, a
162 // scroll which shouldn't propagate can't cause any element to
163 // scroll other than the |m_previousGestureScrolledNode|.
164 bool m_deltaConsumedForScrollSequence;
165
166 Member<Scrollbar> m_scrollbarHandlingScrollGesture;
167
168 Member<PaintLayerScrollableArea> m_resizeScrollableArea;
169
170 LayoutSize m_offsetFromResizeCorner; // In the coords of m_resizeScrollableA rea.
171
172 };
173
174 } // namespace blink
175
176 #endif // ScrollManager_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/input/EventHandler.cpp ('k') | third_party/WebKit/Source/core/input/ScrollManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698