AsyncScrollingCoordinator.h [plain text]
#ifndef AsyncScrollingCoordinator_h
#define AsyncScrollingCoordinator_h
#if ENABLE(ASYNC_SCROLLING)
#include "ScrollingCoordinator.h"
#include "ScrollingTree.h"
#include "Timer.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefPtr.h>
namespace WebCore {
class Page;
class Scrollbar;
class ScrollingStateNode;
class ScrollingStateScrollingNode;
class ScrollingStateTree;
class AsyncScrollingCoordinator : public ScrollingCoordinator {
public:
static Ref<AsyncScrollingCoordinator> create(Page*);
WEBCORE_EXPORT virtual ~AsyncScrollingCoordinator();
ScrollingTree* scrollingTree() const { return m_scrollingTree.get(); }
void scrollingStateTreePropertiesChanged();
WEBCORE_EXPORT void scheduleUpdateScrollPositionAfterAsyncScroll(ScrollingNodeID, const FloatPoint&, bool programmaticScroll, SetOrSyncScrollingLayerPosition);
#if PLATFORM(COCOA)
WEBCORE_EXPORT void setActiveScrollSnapIndices(ScrollingNodeID, unsigned horizontalIndex, unsigned verticalIndex);
void deferTestsForReason(WheelEventTestTrigger::ScrollableAreaIdentifier, WheelEventTestTrigger::DeferTestTriggerReason) const;
void removeTestDeferralForReason(WheelEventTestTrigger::ScrollableAreaIdentifier, WheelEventTestTrigger::DeferTestTriggerReason) const;
#endif
protected:
WEBCORE_EXPORT AsyncScrollingCoordinator(Page*);
void setScrollingTree(PassRefPtr<ScrollingTree> scrollingTree) { m_scrollingTree = scrollingTree; }
ScrollingStateTree* scrollingStateTree() { return m_scrollingStateTree.get(); }
PassRefPtr<ScrollingTree> releaseScrollingTree() { return m_scrollingTree.release(); }
void updateScrollPositionAfterAsyncScroll(ScrollingNodeID, const FloatPoint&, bool programmaticScroll, SetOrSyncScrollingLayerPosition);
WEBCORE_EXPORT virtual String scrollingStateTreeAsText() const override;
WEBCORE_EXPORT virtual void willCommitTree() override;
bool nonFastScrollableRegionDirty() const { return m_nonFastScrollableRegionDirty; }
private:
virtual bool isAsyncScrollingCoordinator() const override { return true; }
virtual bool supportsFixedPositionLayers() const override { return true; }
virtual bool hasVisibleSlowRepaintViewportConstrainedObjects(const FrameView&) const override { return false; }
WEBCORE_EXPORT virtual void frameViewLayoutUpdated(FrameView&) override;
WEBCORE_EXPORT virtual void frameViewRootLayerDidChange(FrameView&) override;
WEBCORE_EXPORT virtual void frameViewNonFastScrollableRegionChanged(FrameView&) override;
WEBCORE_EXPORT virtual bool requestScrollPositionUpdate(FrameView&, const IntPoint&) override;
WEBCORE_EXPORT virtual ScrollingNodeID attachToStateTree(ScrollingNodeType, ScrollingNodeID newNodeID, ScrollingNodeID parentID) override;
WEBCORE_EXPORT virtual void detachFromStateTree(ScrollingNodeID) override;
WEBCORE_EXPORT virtual void clearStateTree() override;
WEBCORE_EXPORT virtual void updateViewportConstrainedNode(ScrollingNodeID, const ViewportConstraints&, GraphicsLayer*) override;
WEBCORE_EXPORT virtual void updateFrameScrollingNode(ScrollingNodeID, GraphicsLayer* scrollLayer, GraphicsLayer* scrolledContentsLayer, GraphicsLayer* counterScrollingLayer, GraphicsLayer* insetClipLayer, const ScrollingGeometry* = nullptr) override;
WEBCORE_EXPORT virtual void updateOverflowScrollingNode(ScrollingNodeID, GraphicsLayer* scrollLayer, GraphicsLayer* scrolledContentsLayer, const ScrollingGeometry* = nullptr) override;
virtual bool isRubberBandInProgress() const override;
virtual void setScrollPinningBehavior(ScrollPinningBehavior) override;
#if ENABLE(CSS_SCROLL_SNAP)
bool isScrollSnapInProgress() const override;
#endif
WEBCORE_EXPORT virtual void syncChildPositions(const LayoutRect& viewportRect) override;
WEBCORE_EXPORT virtual void scrollableAreaScrollbarLayerDidChange(ScrollableArea&, ScrollbarOrientation) override;
WEBCORE_EXPORT virtual void setSynchronousScrollingReasons(SynchronousScrollingReasons) override;
virtual void scheduleTreeStateCommit() = 0;
void ensureRootStateNodeForFrameView(FrameView&);
void updateMainFrameScrollLayerPosition();
void updateScrollPositionAfterAsyncScrollTimerFired();
void setNonFastScrollableRegionDirty();
void updateNonFastScrollableRegion();
FrameView* frameViewForScrollingNode(ScrollingNodeID) const;
Timer m_updateNodeScrollPositionTimer;
struct ScheduledScrollUpdate {
ScheduledScrollUpdate()
: nodeID(0)
, isProgrammaticScroll(false)
, updateLayerPositionAction(SyncScrollingLayerPosition)
{ }
ScheduledScrollUpdate(ScrollingNodeID scrollingNodeID, FloatPoint point, bool isProgrammatic, SetOrSyncScrollingLayerPosition udpateAction)
: nodeID(scrollingNodeID)
, scrollPosition(point)
, isProgrammaticScroll(isProgrammatic)
, updateLayerPositionAction(udpateAction)
{ }
ScrollingNodeID nodeID;
FloatPoint scrollPosition;
bool isProgrammaticScroll;
SetOrSyncScrollingLayerPosition updateLayerPositionAction;
bool matchesUpdateType(const ScheduledScrollUpdate& other) const
{
return nodeID == other.nodeID
&& isProgrammaticScroll == other.isProgrammaticScroll
&& updateLayerPositionAction == other.updateLayerPositionAction;
}
};
ScheduledScrollUpdate m_scheduledScrollUpdate;
std::unique_ptr<ScrollingStateTree> m_scrollingStateTree;
RefPtr<ScrollingTree> m_scrollingTree;
bool m_nonFastScrollableRegionDirty { false };
};
}
SPECIALIZE_TYPE_TRAITS_SCROLLING_COORDINATOR(WebCore::AsyncScrollingCoordinator, isAsyncScrollingCoordinator());
#endif // ENABLE(ASYNC_SCROLLING)
#endif // AsyncScrollingCoordinator_h