ScrollingCoordinatorCoordinatedGraphics.cpp [plain text]
#include "config.h"
#include "ScrollingCoordinatorCoordinatedGraphics.h"
#if ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS)
#include "ScrollingThread.h"
#include "ScrollingTreeCoordinatedGraphics.h"
namespace WebCore {
Ref<ScrollingCoordinator> ScrollingCoordinator::create(Page* page)
{
return adoptRef(*new ScrollingCoordinatorCoordinatedGraphics(page));
}
ScrollingCoordinatorCoordinatedGraphics::ScrollingCoordinatorCoordinatedGraphics(Page* page)
: AsyncScrollingCoordinator(page)
, m_scrollingStateTreeCommitterTimer(RunLoop::main(), this, &ScrollingCoordinatorCoordinatedGraphics::commitTreeState)
{
setScrollingTree(ScrollingTreeCoordinatedGraphics::create(*this));
}
ScrollingCoordinatorCoordinatedGraphics::~ScrollingCoordinatorCoordinatedGraphics()
{
ASSERT(!scrollingTree());
}
void ScrollingCoordinatorCoordinatedGraphics::pageDestroyed()
{
AsyncScrollingCoordinator::pageDestroyed();
m_scrollingStateTreeCommitterTimer.stop();
releaseScrollingTree();
}
void ScrollingCoordinatorCoordinatedGraphics::commitTreeStateIfNeeded()
{
commitTreeState();
m_scrollingStateTreeCommitterTimer.stop();
}
bool ScrollingCoordinatorCoordinatedGraphics::handleWheelEvent(FrameView&, const PlatformWheelEvent&)
{
return false;
}
void ScrollingCoordinatorCoordinatedGraphics::scheduleTreeStateCommit()
{
if (!m_scrollingStateTreeCommitterTimer.isActive())
m_scrollingStateTreeCommitterTimer.startOneShot(0_s);
}
void ScrollingCoordinatorCoordinatedGraphics::commitTreeState()
{
if (!scrollingStateTree()->hasChangedProperties())
return;
RefPtr<ThreadedScrollingTree> threadedScrollingTree = downcast<ThreadedScrollingTree>(scrollingTree());
auto treeState = scrollingStateTree()->commit(LayerRepresentation::PlatformLayerRepresentation);
ScrollingThread::dispatch([threadedScrollingTree, treeState = WTFMove(treeState)]() mutable {
threadedScrollingTree->commitTreeState(WTFMove(treeState));
});
}
}
#endif // ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS)