ScrollingTreeScrollingNode.h [plain text]
#pragma once
#if ENABLE(ASYNC_SCROLLING)
#include "IntRect.h"
#include "ScrollSnapOffsetsInfo.h"
#include "ScrollTypes.h"
#include "ScrollingCoordinator.h"
#include "ScrollingTreeNode.h"
#if PLATFORM(IOS)
class ScrollingTreeScrollingNodeDelegate;
#endif
namespace WebCore {
class ScrollingTree;
class ScrollingStateScrollingNode;
class ScrollingTreeScrollingNode : public ScrollingTreeNode {
#if PLATFORM(IOS)
friend class ScrollingTreeScrollingNodeDelegate;
#endif
public:
virtual ~ScrollingTreeScrollingNode();
WEBCORE_EXPORT void commitStateBeforeChildren(const ScrollingStateNode&) override;
WEBCORE_EXPORT void commitStateAfterChildren(const ScrollingStateNode&) override;
WEBCORE_EXPORT void updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& fixedPositionRect, const FloatSize& cumulativeDelta) override;
virtual void handleWheelEvent(const PlatformWheelEvent&) = 0;
WEBCORE_EXPORT virtual void setScrollPosition(const FloatPoint&);
WEBCORE_EXPORT virtual void setScrollPositionWithoutContentEdgeConstraints(const FloatPoint&);
virtual void updateLayersAfterViewportChange(const FloatRect& fixedPositionRect, double scale) = 0;
virtual void updateLayersAfterDelegatedScroll(const FloatPoint&) { }
virtual FloatPoint scrollPosition() const = 0;
#if ENABLE(CSS_SCROLL_SNAP)
const Vector<float>& horizontalSnapOffsets() const { return m_snapOffsetsInfo.horizontalSnapOffsets; }
const Vector<float>& verticalSnapOffsets() const { return m_snapOffsetsInfo.verticalSnapOffsets; }
const Vector<ScrollOffsetRange<float>>& horizontalSnapOffsetRanges() const { return m_snapOffsetsInfo.horizontalSnapOffsetRanges; }
const Vector<ScrollOffsetRange<float>>& verticalSnapOffsetRanges() const { return m_snapOffsetsInfo.verticalSnapOffsetRanges; }
unsigned currentHorizontalSnapPointIndex() const { return m_currentHorizontalSnapPointIndex; }
unsigned currentVerticalSnapPointIndex() const { return m_currentVerticalSnapPointIndex; }
void setCurrentHorizontalSnapPointIndex(unsigned index) { m_currentHorizontalSnapPointIndex = index; }
void setCurrentVerticalSnapPointIndex(unsigned index) { m_currentVerticalSnapPointIndex = index; }
#endif
protected:
ScrollingTreeScrollingNode(ScrollingTree&, ScrollingNodeType, ScrollingNodeID);
WEBCORE_EXPORT virtual FloatPoint minimumScrollPosition() const;
WEBCORE_EXPORT virtual FloatPoint maximumScrollPosition() const;
virtual void setScrollLayerPosition(const FloatPoint&, const FloatRect& layoutViewport) = 0;
FloatPoint lastCommittedScrollPosition() const { return m_lastCommittedScrollPosition; }
const FloatSize& scrollableAreaSize() const { return m_scrollableAreaSize; }
const FloatSize& totalContentsSize() const { return m_totalContentsSize; }
const FloatSize& reachableContentsSize() const { return m_reachableContentsSize; }
const IntPoint& scrollOrigin() const { return m_scrollOrigin; }
const FloatSize& totalContentsSizeForRubberBand() const { return m_totalContentsSizeForRubberBand; }
void setTotalContentsSizeForRubberBand(const FloatSize& totalContentsSizeForRubberBand) { m_totalContentsSizeForRubberBand = totalContentsSizeForRubberBand; }
ScrollElasticity horizontalScrollElasticity() const { return m_scrollableAreaParameters.horizontalScrollElasticity; }
ScrollElasticity verticalScrollElasticity() const { return m_scrollableAreaParameters.verticalScrollElasticity; }
bool hasEnabledHorizontalScrollbar() const { return m_scrollableAreaParameters.hasEnabledHorizontalScrollbar; }
bool hasEnabledVerticalScrollbar() const { return m_scrollableAreaParameters.hasEnabledVerticalScrollbar; }
bool canHaveScrollbars() const { return m_scrollableAreaParameters.horizontalScrollbarMode != ScrollbarAlwaysOff || m_scrollableAreaParameters.verticalScrollbarMode != ScrollbarAlwaysOff; }
WEBCORE_EXPORT void dumpProperties(WTF::TextStream&, ScrollingStateTreeAsTextBehavior) const override;
private:
FloatSize m_scrollableAreaSize;
FloatSize m_totalContentsSize;
FloatSize m_totalContentsSizeForRubberBand;
FloatSize m_reachableContentsSize;
FloatPoint m_lastCommittedScrollPosition;
IntPoint m_scrollOrigin;
#if ENABLE(CSS_SCROLL_SNAP)
ScrollSnapOffsetsInfo<float> m_snapOffsetsInfo;
unsigned m_currentHorizontalSnapPointIndex { 0 };
unsigned m_currentVerticalSnapPointIndex { 0 };
#endif
ScrollableAreaParameters m_scrollableAreaParameters;
};
}
SPECIALIZE_TYPE_TRAITS_SCROLLING_NODE(ScrollingTreeScrollingNode, isScrollingNode())
#endif // ENABLE(ASYNC_SCROLLING)