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>
#include <wtf/TemporaryChange.h>
namespace WebCore {
RefPtr<ScrollingTreeIOS> ScrollingTreeIOS::create(AsyncScrollingCoordinator* scrollingCoordinator)
{
return adoptRef(new ScrollingTreeIOS(scrollingCoordinator));
}
ScrollingTreeIOS::ScrollingTreeIOS(AsyncScrollingCoordinator* scrollingCoordinator)
: m_scrollingCoordinator(scrollingCoordinator)
{
}
ScrollingTreeIOS::~ScrollingTreeIOS()
{
ASSERT(!m_scrollingCoordinator);
}
static void derefScrollingCoordinator(ScrollingCoordinator* scrollingCoordinator)
{
ASSERT(isMainThread());
scrollingCoordinator->deref();
}
void ScrollingTreeIOS::invalidate()
{
ASSERT(ScrollingThread::isCurrentThread());
callOnMainThread(bind(derefScrollingCoordinator, m_scrollingCoordinator.release().leakRef()));
}
void ScrollingTreeIOS::commitNewTreeState(PassOwnPtr<ScrollingStateTree> scrollingStateTree)
{
ScrollingTree::commitNewTreeState(scrollingStateTree);
}
void ScrollingTreeIOS::scrollingTreeNodeDidScroll(ScrollingNodeID nodeID, const FloatPoint& scrollPosition, SetOrSyncScrollingLayerPosition scrollingLayerPositionAction)
{
if (!m_scrollingCoordinator)
return;
if (nodeID == rootNode()->scrollingNodeID())
setMainFrameScrollPosition(scrollPosition);
callOnMainThread(bind(&AsyncScrollingCoordinator::scheduleUpdateScrollPositionAfterAsyncScroll, m_scrollingCoordinator.get(), nodeID, scrollPosition, isHandlingProgrammaticScroll(), scrollingLayerPositionAction));
}
PassRefPtr<ScrollingTreeNode> ScrollingTreeIOS::createScrollingTreeNode(ScrollingNodeType nodeType, ScrollingNodeID nodeID)
{
switch (nodeType) {
case FrameScrollingNode:
return ScrollingTreeFrameScrollingNodeIOS::create(*this, nodeID);
case OverflowScrollingNode:
ASSERT_NOT_REACHED();
return nullptr;
case FixedNode:
return ScrollingTreeFixedNode::create(*this, nodeID);
case StickyNode:
return ScrollingTreeStickyNode::create(*this, nodeID);
}
return nullptr;
}
FloatRect ScrollingTreeIOS::fixedPositionRect()
{
ASSERT_NOT_REACHED();
return FloatRect();
}
}
#endif // ENABLE(ASYNC_SCROLLING)