ScrollingTreeIOS.cpp [plain text]
#include "config.h"
#include "ScrollingTreeIOS.h"
#if ENABLE(ASYNC_SCROLLING)
#include "AsyncScrollingCoordinator.h"
#include "PlatformWheelEvent.h"
#include "ScrollingThread.h"
#include "ScrollingTreeFixedNode.h"
#include "ScrollingTreeFrameScrollingNodeIOS.h"
#include "ScrollingTreeNode.h"
#include "ScrollingTreeScrollingNode.h"
#include "ScrollingTreeStickyNode.h"
#include <wtf/MainThread.h>
namespace WebCore {
Ref<ScrollingTreeIOS> ScrollingTreeIOS::create(AsyncScrollingCoordinator& scrollingCoordinator)
{
return adoptRef(*new ScrollingTreeIOS(scrollingCoordinator));
}
ScrollingTreeIOS::ScrollingTreeIOS(AsyncScrollingCoordinator& scrollingCoordinator)
: m_scrollingCoordinator(&scrollingCoordinator)
{
}
ScrollingTreeIOS::~ScrollingTreeIOS()
{
ASSERT(!m_scrollingCoordinator);
}
void ScrollingTreeIOS::invalidate()
{
ASSERT(ScrollingThread::isCurrentThread());
callOnMainThread([scrollingCoordinator = WTFMove(m_scrollingCoordinator)] {
});
}
void ScrollingTreeIOS::scrollingTreeNodeDidScroll(ScrollingNodeID nodeID, const FloatPoint& scrollPosition, const std::optional<FloatPoint>& layoutViewportOrigin, ScrollingLayerPositionAction scrollingLayerPositionAction)
{
if (!m_scrollingCoordinator)
return;
if (nodeID == rootNode()->scrollingNodeID())
setMainFrameScrollPosition(scrollPosition);
callOnMainThread([scrollingCoordinator = m_scrollingCoordinator, nodeID, scrollPosition, layoutViewportOrigin, localIsHandlingProgrammaticScroll = isHandlingProgrammaticScroll(), scrollingLayerPositionAction] {
scrollingCoordinator->scheduleUpdateScrollPositionAfterAsyncScroll(nodeID, scrollPosition, layoutViewportOrigin, localIsHandlingProgrammaticScroll, scrollingLayerPositionAction);
});
}
Ref<ScrollingTreeNode> ScrollingTreeIOS::createScrollingTreeNode(ScrollingNodeType nodeType, ScrollingNodeID nodeID)
{
switch (nodeType) {
case FrameScrollingNode:
return ScrollingTreeFrameScrollingNodeIOS::create(*this, nodeID);
case OverflowScrollingNode:
ASSERT_NOT_REACHED();
break;
case FixedNode:
return ScrollingTreeFixedNode::create(*this, nodeID);
case StickyNode:
return ScrollingTreeStickyNode::create(*this, nodeID);
}
ASSERT_NOT_REACHED();
return ScrollingTreeFixedNode::create(*this, nodeID);
}
FloatRect ScrollingTreeIOS::fixedPositionRect()
{
ASSERT_NOT_REACHED();
return FloatRect();
}
void ScrollingTreeIOS::currentSnapPointIndicesDidChange(WebCore::ScrollingNodeID nodeID, unsigned horizontal, unsigned vertical)
{
if (!m_scrollingCoordinator)
return;
callOnMainThread([scrollingCoordinator = m_scrollingCoordinator, nodeID, horizontal, vertical] {
scrollingCoordinator->setActiveScrollSnapIndices(nodeID, horizontal, vertical);
});
}
}
#endif // ENABLE(ASYNC_SCROLLING)