OLD | NEW |
---|---|
(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 class CORE_EXPORT ScrollManager { | |
bokan
2016/05/31 19:39:14
Please add a class-level comment describing this c
Navid Zolghadr
2016/06/01 17:36:43
Done.
| |
34 WTF_MAKE_NONCOPYABLE(ScrollManager); | |
35 DISALLOW_NEW(); | |
36 public: | |
37 explicit ScrollManager(LocalFrame*); | |
38 ~ScrollManager(); | |
39 DECLARE_TRACE(); | |
40 | |
41 void clear(); | |
42 | |
43 bool panScrollInProgress() const; | |
44 AutoscrollController* autoscrollController() const; | |
45 void stopAutoscroll(); | |
46 | |
47 // Performs a chaining scroll, within a *single* frame, starting from a | |
48 // given node and optionally stopping on a given node. | |
49 // granularity - The units that the scroll delta parameter is in. | |
50 // delta - The delta to scroll by, in the units of the granularity param | |
51 // (e.g. pixels, lines, pages, etc.). These are in a physical | |
52 // direction. i.e. Positive is down and right. | |
53 // position - Where the scroll originated from (e.g. touch location). | |
54 // velocity - The velocity of the scroll in the case of fling gestures. | |
55 // startNode - The node to start the scroll chaining from. | |
56 // stopNode - On input, if non-null, the node at which we should stop | |
57 // chaining. On output, if provided and a node was scrolled, | |
58 // stopNode will point to that node. | |
59 // consumed - [OUT] Whether the scroll was consumed. This is different than | |
60 // ScrollResult.didScroll since we might not have scrolled but | |
61 // have reached the stopNode and thus don't want to continue | |
62 // chaining the scroll. | |
63 ScrollResult physicalScroll( | |
64 ScrollGranularity, | |
65 const FloatSize& delta, | |
66 const FloatPoint& position, | |
67 const FloatSize& velocity, | |
68 Node* startNode, | |
69 Node** stopNode, | |
70 bool* consumed); | |
71 | |
72 // Performs a chaining logical scroll, within a *single* frame, starting | |
73 // from either a provided starting node or a default based on the focused or | |
74 // most recently clicked node, falling back to the frame. | |
75 // Returns true if the scroll was consumed. | |
76 // direction - The logical direction to scroll in. This will be converted to | |
77 // a physical direction for each LayoutBox we try to scroll | |
78 // based on that box's writing mode. | |
79 // granularity - The units that the scroll delta parameter is in. | |
80 // startNode - Optional. If provided, start chaining from the given node. | |
81 // If not, use the current focus or last clicked node. | |
82 bool logicalScroll(ScrollDirection, ScrollGranularity, Node* startNode, Node * mousePressNode); | |
83 | |
84 // Performs a logical scroll that chains, crossing frames, starting from | |
85 // the given node or a reasonable default (focus/last clicked). | |
86 bool bubblingScroll(ScrollDirection, ScrollGranularity, Node* startingNode, Node* mousePressNode); | |
87 | |
88 void setFrameWasScrolledByUser(); | |
89 | |
90 // Handle the provided scroll gesture event, propagating down to child frame s as necessary. | |
91 WebInputEventResult handleGestureScrollEvent(const PlatformGestureEvent&); | |
92 | |
93 WebInputEventResult handleGestureScrollEnd(const PlatformGestureEvent&); | |
94 | |
95 bool isScrollbarHandlingGestures() const; | |
96 | |
97 // Returns true if the gesture event should be handled in ScrollManager. | |
98 bool canHandleGestureEvent(const GestureEventWithHitTestResults&); | |
99 | |
100 // These functions are related to |m_resizeScrollableArea|. | |
101 bool inResizeMode() const; | |
102 void resize(const PlatformEvent&); | |
103 // Clears |m_resizeScrollableArea|. if |shouldNotBeNull| is true this | |
104 // function DCHECKs to make sure that variable is indeed not null. | |
105 void clearResizeScrollableArea(bool shouldNotBeNull); | |
106 void setResizeScrollableArea(PaintLayer*, IntPoint); | |
107 | |
108 private: | |
109 | |
110 WebInputEventResult handleGestureScrollUpdate(const PlatformGestureEvent&); | |
111 WebInputEventResult handleGestureScrollBegin(const PlatformGestureEvent&); | |
112 | |
113 WebInputEventResult passScrollGestureEventToWidget(const PlatformGestureEven t&, LayoutObject*); | |
114 | |
115 void clearGestureScrollState(); | |
116 | |
117 void customizedScroll(const Node& startNode, ScrollState&); | |
118 | |
119 ScrollResult scrollBox( | |
120 LayoutBox*, | |
121 ScrollGranularity, | |
122 const FloatSize& delta, | |
123 const FloatPoint& position, | |
124 const FloatSize& velocity, | |
125 bool* wasRootScroller); | |
126 | |
127 FrameHost* frameHost() const; | |
128 | |
129 bool isRootScroller(const Node&) const; | |
130 | |
131 bool handleScrollGestureOnResizer(Node*, const PlatformGestureEvent&); | |
132 | |
133 | |
134 // NOTE: If adding a new field to this class please ensure that it is | |
135 // cleared in |ScrollManager::clear()|. | |
136 | |
137 const Member<LocalFrame> m_frame; | |
138 | |
139 // Only used with the ScrollCustomization runtime enabled feature. | |
140 std::deque<int> m_currentScrollChain; | |
141 | |
142 Member<Node> m_scrollGestureHandlingNode; | |
143 | |
144 bool m_lastGestureScrollOverWidget; | |
145 | |
146 // The most recent element to scroll natively during this scroll | |
147 // sequence. Null if no native element has scrolled this scroll | |
148 // sequence, or if the most recent element to scroll used scroll | |
149 // customization. | |
150 Member<Node> m_previousGestureScrolledNode; | |
151 | |
152 // True iff some of the delta has been consumed for the current | |
153 // scroll sequence in this frame, or any child frames. Only used | |
154 // with ScrollCustomization. If some delta has been consumed, a | |
155 // scroll which shouldn't propagate can't cause any element to | |
156 // scroll other than the |m_previousGestureScrolledNode|. | |
157 bool m_deltaConsumedForScrollSequence; | |
158 | |
159 Member<Scrollbar> m_scrollbarHandlingScrollGesture; | |
160 | |
161 Member<PaintLayerScrollableArea> m_resizeScrollableArea; | |
162 | |
163 LayoutSize m_offsetFromResizeCorner; // In the coords of m_resizeScrollableA rea. | |
164 | |
165 }; | |
166 | |
167 } // namespace blink | |
168 | |
169 #endif // ScrollManager_h | |
OLD | NEW |