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