Chromium Code Reviews| Index: third_party/WebKit/Source/core/input/ScrollManager.h |
| diff --git a/third_party/WebKit/Source/core/input/ScrollManager.h b/third_party/WebKit/Source/core/input/ScrollManager.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a277fbd8611f2aeb30078b8d1a7f402c27790e0c |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/core/input/ScrollManager.h |
| @@ -0,0 +1,161 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef ScrollManager_h |
| +#define ScrollManager_h |
| + |
| +#include "core/CoreExport.h" |
| +#include "core/page/EventWithHitTestResults.h" |
| +#include "platform/PlatformEvent.h" |
| +#include "platform/geometry/LayoutSize.h" |
| +#include "platform/heap/Handle.h" |
| +#include "platform/heap/Visitor.h" |
| +#include "platform/scroll/ScrollTypes.h" |
| +#include "public/platform/WebInputEventResult.h" |
| +#include "wtf/Allocator.h" |
| +#include <deque> |
| + |
| +namespace blink { |
| + |
| +class AutoscrollController; |
| +class FloatPoint; |
| +class FrameHost; |
| +class LayoutBox; |
| +class LayoutObject; |
| +class LocalFrame; |
| +class PaintLayer; |
| +class PaintLayerScrollableArea; |
| +class PlatformGestureEvent; |
| +class Scrollbar; |
| +class ScrollState; |
| + |
| +class CORE_EXPORT ScrollManager { |
| + DISALLOW_NEW(); |
| +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.
|
| + explicit ScrollManager(LocalFrame*); |
| + ~ScrollManager(); |
| + DECLARE_TRACE(); |
| + |
| + void clear(); |
| + |
| + bool panScrollInProgress() const; |
| + AutoscrollController* autoscrollController() const; |
| + void stopAutoscroll(); |
| + |
| + // Performs a chaining scroll, within a *single* frame, starting from a |
| + // given node and optionally stopping on a given node. |
| + // granularity - The units that the scroll delta parameter is in. |
| + // delta - The delta to scroll by, in the units of the granularity param |
| + // (e.g. pixels, lines, pages, etc.). These are in a physical |
| + // direction. i.e. Positive is down and right. |
| + // position - Where the scroll originated from (e.g. touch location). |
| + // velocity - The velocity of the scroll in the case of fling gestures. |
| + // startNode - The node to start the scroll chaining from. |
| + // stopNode - On input, if non-null, the node at which we should stop |
| + // chaining. On output, if provided and a node was scrolled, |
| + // stopNode will point to that node. |
| + // consumed - [OUT] Whether the scroll was consumed. This is different than |
| + // ScrollResult.didScroll since we might not have scrolled but |
| + // have reached the stopNode and thus don't want to continue |
| + // chaining the scroll. |
| + ScrollResult physicalScroll( |
| + ScrollGranularity, |
| + const FloatSize& delta, |
| + const FloatPoint& position, |
| + const FloatSize& velocity, |
| + Node* startNode, |
| + Node** stopNode, |
| + bool* consumed); |
| + |
| + // Performs a chaining logical scroll, within a *single* frame, starting |
| + // from either a provided starting node or a default based on the focused or |
| + // most recently clicked node, falling back to the frame. |
| + // Returns true if the scroll was consumed. |
| + // direction - The logical direction to scroll in. This will be converted to |
| + // a physical direction for each LayoutBox we try to scroll |
| + // based on that box's writing mode. |
| + // granularity - The units that the scroll delta parameter is in. |
| + // startNode - Optional. If provided, start chaining from the given node. |
| + // If not, use the current focus or last clicked node. |
| + bool logicalScroll(ScrollDirection, ScrollGranularity, Node* startNode = nullptr, 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.
|
| + |
| + void setFrameWasScrolledByUser(); |
| + |
| + // Handle the provided scroll gesture event, propagating down to child frames as necessary. |
| + WebInputEventResult handleGestureScrollEvent(const PlatformGestureEvent&); |
| + |
| + 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.
|
| + WebInputEventResult handleGestureScrollBegin(const PlatformGestureEvent&); |
| + WebInputEventResult handleGestureScrollEnd(const PlatformGestureEvent&); |
| + |
| + bool isScrollbarHandlingGestures() const; |
| + |
| + // Returns true if the gesture event should be handled in ScrollManager. |
| + bool canHandleGestureEvent(const GestureEventWithHitTestResults&); |
| + |
| + // These functions are related to |m_resizeScrollableArea|. |
| + bool inResizeMode() const; |
| + void resize(const PlatformEvent&); |
| + 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.
|
| + void setResizeScrollableArea(PaintLayer*, IntPoint); |
| + |
| +private: |
| + |
| + WebInputEventResult passScrollGestureEventToWidget(const PlatformGestureEvent&, LayoutObject*); |
| + |
| + void clearGestureScrollState(); |
| + |
| + void customizedScroll(const Node& startNode, ScrollState&); |
| + |
| + ScrollResult scrollBox( |
| + LayoutBox*, |
| + ScrollGranularity, |
| + const FloatSize& delta, |
| + const FloatPoint& position, |
| + const FloatSize& velocity, |
| + bool* wasRootScroller); |
| + |
| + FrameHost* frameHost() const; |
| + |
| + bool isRootScroller(const Node&) const; |
| + |
| + bool handleScrollGestureOnResizer(Node*, const PlatformGestureEvent&); |
| + |
| + |
| + // NOTE: If adding a new field to this class please ensure that it is |
| + // cleared in |ScrollManager::clear()|. |
| + |
| + const Member<LocalFrame> m_frame; |
| + |
| + // Only used with the ScrollCustomization runtime enabled feature. |
| + std::deque<int> m_currentScrollChain; |
| + |
| + Member<Node> m_scrollGestureHandlingNode; |
| + |
| + bool m_lastGestureScrollOverWidget; |
| + |
| + // The most recent element to scroll natively during this scroll |
| + // sequence. Null if no native element has scrolled this scroll |
| + // sequence, or if the most recent element to scroll used scroll |
| + // customization. |
| + Member<Node> m_previousGestureScrolledNode; |
| + |
| + // True iff some of the delta has been consumed for the current |
| + // scroll sequence in this frame, or any child frames. Only used |
| + // with ScrollCustomization. If some delta has been consumed, a |
| + // scroll which shouldn't propagate can't cause any element to |
| + // scroll other than the |m_previousGestureScrolledNode|. |
| + bool m_deltaConsumedForScrollSequence; |
| + |
| + Member<Scrollbar> m_scrollbarHandlingScrollGesture; |
| + |
| + Member<PaintLayerScrollableArea> m_resizeScrollableArea; |
| + |
| + LayoutSize m_offsetFromResizeCorner; // In the coords of m_resizeScrollableArea. |
| + |
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif // ScrollManager_h |