summaryrefslogtreecommitdiff
path: root/Source/WebCore/page/scrolling
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2016-04-10 09:28:39 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2016-04-10 09:28:39 +0000
commit32761a6cee1d0dee366b885b7b9c777e67885688 (patch)
treed6bec92bebfb216f4126356e55518842c2f476a1 /Source/WebCore/page/scrolling
parenta4e969f4965059196ca948db781e52f7cfebf19e (diff)
downloadWebKitGtk-tarball-32761a6cee1d0dee366b885b7b9c777e67885688.tar.gz
webkitgtk-2.4.11webkitgtk-2.4.11
Diffstat (limited to 'Source/WebCore/page/scrolling')
-rw-r--r--Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp631
-rw-r--r--Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h172
-rw-r--r--Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp205
-rw-r--r--Source/WebCore/page/scrolling/AxisScrollSnapOffsets.h89
-rw-r--r--Source/WebCore/page/scrolling/ScrollLatchingState.cpp73
-rw-r--r--Source/WebCore/page/scrolling/ScrollLatchingState.h73
-rw-r--r--Source/WebCore/page/scrolling/ScrollingConstraints.cpp18
-rw-r--r--Source/WebCore/page/scrolling/ScrollingConstraints.h12
-rw-r--r--Source/WebCore/page/scrolling/ScrollingCoordinator.cpp326
-rw-r--r--Source/WebCore/page/scrolling/ScrollingCoordinator.h126
-rw-r--r--Source/WebCore/page/scrolling/ScrollingStateFixedNode.cpp9
-rw-r--r--Source/WebCore/page/scrolling/ScrollingStateFixedNode.h10
-rw-r--r--Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.cpp259
-rw-r--r--Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.h158
-rw-r--r--Source/WebCore/page/scrolling/ScrollingStateNode.cpp56
-rw-r--r--Source/WebCore/page/scrolling/ScrollingStateNode.h87
-rw-r--r--Source/WebCore/page/scrolling/ScrollingStateOverflowScrollingNode.cpp85
-rw-r--r--Source/WebCore/page/scrolling/ScrollingStateOverflowScrollingNode.h66
-rw-r--r--Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp221
-rw-r--r--Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h156
-rw-r--r--Source/WebCore/page/scrolling/ScrollingStateStickyNode.cpp134
-rw-r--r--Source/WebCore/page/scrolling/ScrollingStateStickyNode.h72
-rw-r--r--Source/WebCore/page/scrolling/ScrollingStateTree.cpp168
-rw-r--r--Source/WebCore/page/scrolling/ScrollingStateTree.h52
-rw-r--r--Source/WebCore/page/scrolling/ScrollingThread.cpp120
-rw-r--r--Source/WebCore/page/scrolling/ScrollingThread.h95
-rw-r--r--Source/WebCore/page/scrolling/ScrollingTree.cpp376
-rw-r--r--Source/WebCore/page/scrolling/ScrollingTree.h196
-rw-r--r--Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp96
-rw-r--r--Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.h93
-rw-r--r--Source/WebCore/page/scrolling/ScrollingTreeNode.cpp77
-rw-r--r--Source/WebCore/page/scrolling/ScrollingTreeNode.h94
-rw-r--r--Source/WebCore/page/scrolling/ScrollingTreeOverflowScrollingNode.cpp47
-rw-r--r--Source/WebCore/page/scrolling/ScrollingTreeOverflowScrollingNode.h50
-rw-r--r--Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp130
-rw-r--r--Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h118
-rw-r--r--Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp174
-rw-r--r--Source/WebCore/page/scrolling/ThreadedScrollingTree.h83
-rw-r--r--Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp126
-rw-r--r--Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.h63
-rw-r--r--Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingStateNodeCoordinatedGraphics.cpp49
41 files changed, 568 insertions, 4677 deletions
diff --git a/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp b/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp
deleted file mode 100644
index 0291a4fd0..000000000
--- a/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp
+++ /dev/null
@@ -1,631 +0,0 @@
-/*
- * Copyright (C) 2014-2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(ASYNC_SCROLLING)
-#include "AsyncScrollingCoordinator.h"
-
-#include "EditorClient.h"
-#include "Frame.h"
-#include "FrameView.h"
-#include "GraphicsLayer.h"
-#include "Logging.h"
-#include "MainFrame.h"
-#include "Page.h"
-#include "ScrollAnimator.h"
-#include "ScrollingConstraints.h"
-#include "ScrollingStateFixedNode.h"
-#include "ScrollingStateFrameScrollingNode.h"
-#include "ScrollingStateOverflowScrollingNode.h"
-#include "ScrollingStateStickyNode.h"
-#include "ScrollingStateTree.h"
-#include "WheelEventTestTrigger.h"
-
-namespace WebCore {
-
-AsyncScrollingCoordinator::AsyncScrollingCoordinator(Page* page)
- : ScrollingCoordinator(page)
- , m_updateNodeScrollPositionTimer(*this, &AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScrollTimerFired)
- , m_scrollingStateTree(std::make_unique<ScrollingStateTree>(this))
-{
-}
-
-AsyncScrollingCoordinator::~AsyncScrollingCoordinator()
-{
-}
-
-void AsyncScrollingCoordinator::scrollingStateTreePropertiesChanged()
-{
- scheduleTreeStateCommit();
-}
-
-static inline void setStateScrollingNodeSnapOffsetsAsFloat(ScrollingStateScrollingNode& node, ScrollEventAxis axis, const Vector<LayoutUnit>* snapOffsets, float deviceScaleFactor)
-{
- // FIXME: Incorporate current page scale factor in snapping to device pixel. Perhaps we should just convert to float here and let UI process do the pixel snapping?
- Vector<float> snapOffsetsAsFloat;
- if (snapOffsets) {
- snapOffsetsAsFloat.reserveInitialCapacity(snapOffsets->size());
- for (auto& offset : *snapOffsets)
- snapOffsetsAsFloat.uncheckedAppend(roundToDevicePixel(offset, deviceScaleFactor, false));
- }
- if (axis == ScrollEventAxis::Horizontal)
- node.setHorizontalSnapOffsets(snapOffsetsAsFloat);
- else
- node.setVerticalSnapOffsets(snapOffsetsAsFloat);
-}
-
-void AsyncScrollingCoordinator::setNonFastScrollableRegionDirty()
-{
- m_nonFastScrollableRegionDirty = true;
- // We have to schedule a commit, but the computed non-fast region may not have actually changed.
- scheduleTreeStateCommit();
-}
-
-void AsyncScrollingCoordinator::willCommitTree()
-{
- updateNonFastScrollableRegion();
-}
-
-void AsyncScrollingCoordinator::updateNonFastScrollableRegion()
-{
- if (!m_nonFastScrollableRegionDirty)
- return;
-
- if (!m_scrollingStateTree->rootStateNode())
- return;
-
- m_scrollingStateTree->rootStateNode()->setNonFastScrollableRegion(absoluteNonFastScrollableRegion());
- m_nonFastScrollableRegionDirty = false;
-}
-
-void AsyncScrollingCoordinator::frameViewLayoutUpdated(FrameView& frameView)
-{
- ASSERT(isMainThread());
- ASSERT(m_page);
-
- // If there isn't a root node yet, don't do anything. We'll be called again after creating one.
- if (!m_scrollingStateTree->rootStateNode())
- return;
-
- // Compute the region of the page that we can't do fast scrolling for. This currently includes
- // all scrollable areas, such as subframes, overflow divs and list boxes. We need to do this even if the
- // frame view whose layout was updated is not the main frame.
- // In the future, we may want to have the ability to set non-fast scrolling regions for more than
- // just the root node. But right now, this concept only applies to the root.
- m_scrollingStateTree->rootStateNode()->setNonFastScrollableRegion(absoluteNonFastScrollableRegion());
- m_nonFastScrollableRegionDirty = false;
-
- if (!coordinatesScrollingForFrameView(frameView))
- return;
-
- ScrollingStateFrameScrollingNode* node = downcast<ScrollingStateFrameScrollingNode>(m_scrollingStateTree->stateNodeForID(frameView.scrollLayerID()));
- if (!node)
- return;
-
- Scrollbar* verticalScrollbar = frameView.verticalScrollbar();
- Scrollbar* horizontalScrollbar = frameView.horizontalScrollbar();
- node->setScrollbarPaintersFromScrollbars(verticalScrollbar, horizontalScrollbar);
-
- node->setFrameScaleFactor(frameView.frame().frameScaleFactor());
- node->setHeaderHeight(frameView.headerHeight());
- node->setFooterHeight(frameView.footerHeight());
- node->setTopContentInset(frameView.topContentInset());
-
- node->setScrollOrigin(frameView.scrollOrigin());
- node->setScrollableAreaSize(frameView.visibleContentRect().size());
- node->setTotalContentsSize(frameView.totalContentsSize());
- node->setReachableContentsSize(frameView.totalContentsSize());
- node->setFixedElementsLayoutRelativeToFrame(frameView.fixedElementsLayoutRelativeToFrame());
-
-#if ENABLE(CSS_SCROLL_SNAP)
- frameView.updateSnapOffsets();
- updateScrollSnapPropertiesWithFrameView(frameView);
-#endif
-
-#if PLATFORM(COCOA)
- Page* page = frameView.frame().page();
- if (page && page->expectsWheelEventTriggers()) {
- LOG(WheelEventTestTriggers, " AsyncScrollingCoordinator::frameViewLayoutUpdated: Expects wheel event test trigger=%d", page->expectsWheelEventTriggers());
- node->setExpectsWheelEventTestTrigger(page->expectsWheelEventTriggers());
- }
-#endif
-
- ScrollableAreaParameters scrollParameters;
- scrollParameters.horizontalScrollElasticity = frameView.horizontalScrollElasticity();
- scrollParameters.verticalScrollElasticity = frameView.verticalScrollElasticity();
- scrollParameters.hasEnabledHorizontalScrollbar = horizontalScrollbar && horizontalScrollbar->enabled();
- scrollParameters.hasEnabledVerticalScrollbar = verticalScrollbar && verticalScrollbar->enabled();
- scrollParameters.horizontalScrollbarMode = frameView.horizontalScrollbarMode();
- scrollParameters.verticalScrollbarMode = frameView.verticalScrollbarMode();
-
- node->setScrollableAreaParameters(scrollParameters);
-}
-
-void AsyncScrollingCoordinator::frameViewNonFastScrollableRegionChanged(FrameView&)
-{
- if (!m_scrollingStateTree->rootStateNode())
- return;
-
- setNonFastScrollableRegionDirty();
-}
-
-void AsyncScrollingCoordinator::frameViewRootLayerDidChange(FrameView& frameView)
-{
- ASSERT(isMainThread());
- ASSERT(m_page);
-
- if (!coordinatesScrollingForFrameView(frameView))
- return;
-
- // FIXME: In some navigation scenarios, the FrameView has no RenderView or that RenderView has not been composited.
- // This needs cleaning up: https://bugs.webkit.org/show_bug.cgi?id=132724
- if (!frameView.scrollLayerID())
- return;
-
- // If the root layer does not have a ScrollingStateNode, then we should create one.
- ensureRootStateNodeForFrameView(frameView);
- ASSERT(m_scrollingStateTree->rootStateNode());
-
- ScrollingCoordinator::frameViewRootLayerDidChange(frameView);
-
- ScrollingStateFrameScrollingNode* node = downcast<ScrollingStateFrameScrollingNode>(m_scrollingStateTree->stateNodeForID(frameView.scrollLayerID()));
- node->setLayer(scrollLayerForFrameView(frameView));
- node->setScrolledContentsLayer(rootContentLayerForFrameView(frameView));
- node->setCounterScrollingLayer(counterScrollingLayerForFrameView(frameView));
- node->setInsetClipLayer(insetClipLayerForFrameView(frameView));
- node->setContentShadowLayer(contentShadowLayerForFrameView(frameView));
- node->setHeaderLayer(headerLayerForFrameView(frameView));
- node->setFooterLayer(footerLayerForFrameView(frameView));
- node->setScrollBehaviorForFixedElements(frameView.scrollBehaviorForFixedElements());
-}
-
-bool AsyncScrollingCoordinator::requestScrollPositionUpdate(FrameView& frameView, const IntPoint& scrollPosition)
-{
- ASSERT(isMainThread());
- ASSERT(m_page);
-
- if (!coordinatesScrollingForFrameView(frameView))
- return false;
-
- bool isProgrammaticScroll = frameView.inProgrammaticScroll();
- if (isProgrammaticScroll || frameView.frame().document()->inPageCache())
- updateScrollPositionAfterAsyncScroll(frameView.scrollLayerID(), scrollPosition, isProgrammaticScroll, SetScrollingLayerPosition);
-
- // If this frame view's document is being put into the page cache, we don't want to update our
- // main frame scroll position. Just let the FrameView think that we did.
- if (frameView.frame().document()->inPageCache())
- return true;
-
- ScrollingStateScrollingNode* stateNode = downcast<ScrollingStateScrollingNode>(m_scrollingStateTree->stateNodeForID(frameView.scrollLayerID()));
- if (!stateNode)
- return false;
-
- stateNode->setRequestedScrollPosition(scrollPosition, isProgrammaticScroll);
- return true;
-}
-
-void AsyncScrollingCoordinator::scheduleUpdateScrollPositionAfterAsyncScroll(ScrollingNodeID nodeID, const FloatPoint& scrollPosition, bool programmaticScroll, SetOrSyncScrollingLayerPosition scrollingLayerPositionAction)
-{
- ScheduledScrollUpdate scrollUpdate(nodeID, scrollPosition, programmaticScroll, scrollingLayerPositionAction);
-
- // For programmatic scrolls, requestScrollPositionUpdate() has already called updateScrollPositionAfterAsyncScroll().
- if (programmaticScroll)
- return;
-
- if (m_updateNodeScrollPositionTimer.isActive()) {
- if (m_scheduledScrollUpdate.matchesUpdateType(scrollUpdate)) {
- m_scheduledScrollUpdate.scrollPosition = scrollPosition;
- return;
- }
-
- // If the parameters don't match what was previously scheduled, dispatch immediately.
- m_updateNodeScrollPositionTimer.stop();
- updateScrollPositionAfterAsyncScroll(m_scheduledScrollUpdate.nodeID, m_scheduledScrollUpdate.scrollPosition, m_scheduledScrollUpdate.isProgrammaticScroll, m_scheduledScrollUpdate.updateLayerPositionAction);
- updateScrollPositionAfterAsyncScroll(nodeID, scrollPosition, programmaticScroll, scrollingLayerPositionAction);
- return;
- }
-
- m_scheduledScrollUpdate = scrollUpdate;
- m_updateNodeScrollPositionTimer.startOneShot(0);
-}
-
-void AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScrollTimerFired()
-{
- updateScrollPositionAfterAsyncScroll(m_scheduledScrollUpdate.nodeID, m_scheduledScrollUpdate.scrollPosition, m_scheduledScrollUpdate.isProgrammaticScroll, m_scheduledScrollUpdate.updateLayerPositionAction);
-}
-
-FrameView* AsyncScrollingCoordinator::frameViewForScrollingNode(ScrollingNodeID scrollingNodeID) const
-{
- if (!m_scrollingStateTree->rootStateNode())
- return nullptr;
-
- if (scrollingNodeID == m_scrollingStateTree->rootStateNode()->scrollingNodeID())
- return m_page->mainFrame().view();
-
- ScrollingStateNode* stateNode = m_scrollingStateTree->stateNodeForID(scrollingNodeID);
- if (!stateNode)
- return nullptr;
-
- // Find the enclosing frame scrolling node.
- ScrollingStateNode* parentNode = stateNode;
- while (parentNode && parentNode->nodeType() != FrameScrollingNode)
- parentNode = parentNode->parent();
-
- if (!parentNode)
- return nullptr;
-
- // Walk the frame tree to find the matching FrameView. This is not ideal, but avoids back pointers to FrameViews
- // from ScrollingTreeStateNodes.
- for (Frame* frame = &m_page->mainFrame(); frame; frame = frame->tree().traverseNext()) {
- if (FrameView* view = frame->view()) {
- if (view->scrollLayerID() == parentNode->scrollingNodeID())
- return view;
- }
- }
-
- return nullptr;
-}
-
-void AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll(ScrollingNodeID scrollingNodeID, const FloatPoint& scrollPosition, bool programmaticScroll, SetOrSyncScrollingLayerPosition scrollingLayerPositionAction)
-{
- ASSERT(isMainThread());
-
- if (!m_page)
- return;
-
- FrameView* frameViewPtr = frameViewForScrollingNode(scrollingNodeID);
- if (!frameViewPtr)
- return;
-
- FrameView& frameView = *frameViewPtr;
-
- if (scrollingNodeID == frameView.scrollLayerID()) {
- bool oldProgrammaticScroll = frameView.inProgrammaticScroll();
- frameView.setInProgrammaticScroll(programmaticScroll);
-
- frameView.setConstrainsScrollingToContentEdge(false);
- frameView.notifyScrollPositionChanged(roundedIntPoint(scrollPosition));
- frameView.setConstrainsScrollingToContentEdge(true);
-
- frameView.setInProgrammaticScroll(oldProgrammaticScroll);
-
- if (GraphicsLayer* scrollLayer = scrollLayerForFrameView(frameView)) {
- GraphicsLayer* counterScrollingLayer = counterScrollingLayerForFrameView(frameView);
- GraphicsLayer* insetClipLayer = insetClipLayerForFrameView(frameView);
- GraphicsLayer* contentShadowLayer = contentShadowLayerForFrameView(frameView);
- GraphicsLayer* scrolledContentsLayer = rootContentLayerForFrameView(frameView);
- GraphicsLayer* headerLayer = headerLayerForFrameView(frameView);
- GraphicsLayer* footerLayer = footerLayerForFrameView(frameView);
- LayoutPoint scrollPositionForFixed = frameView.scrollPositionForFixedPosition();
-
- float topContentInset = frameView.topContentInset();
- FloatPoint positionForInsetClipLayer = FloatPoint(0, FrameView::yPositionForInsetClipLayer(scrollPosition, topContentInset));
- FloatPoint positionForContentsLayer = frameView.positionForRootContentLayer();
- FloatPoint positionForHeaderLayer = FloatPoint(scrollPositionForFixed.x(), FrameView::yPositionForHeaderLayer(scrollPosition, topContentInset));
- FloatPoint positionForFooterLayer = FloatPoint(scrollPositionForFixed.x(),
- FrameView::yPositionForFooterLayer(scrollPosition, topContentInset, frameView.totalContentsSize().height(), frameView.footerHeight()));
-
- if (programmaticScroll || scrollingLayerPositionAction == SetScrollingLayerPosition) {
- scrollLayer->setPosition(-frameView.scrollPosition());
- if (counterScrollingLayer)
- counterScrollingLayer->setPosition(scrollPositionForFixed);
- if (insetClipLayer)
- insetClipLayer->setPosition(positionForInsetClipLayer);
- if (contentShadowLayer)
- contentShadowLayer->setPosition(positionForContentsLayer);
- if (scrolledContentsLayer)
- scrolledContentsLayer->setPosition(positionForContentsLayer);
- if (headerLayer)
- headerLayer->setPosition(positionForHeaderLayer);
- if (footerLayer)
- footerLayer->setPosition(positionForFooterLayer);
- } else {
- scrollLayer->syncPosition(-frameView.scrollPosition());
- if (counterScrollingLayer)
- counterScrollingLayer->syncPosition(scrollPositionForFixed);
- if (insetClipLayer)
- insetClipLayer->syncPosition(positionForInsetClipLayer);
- if (contentShadowLayer)
- contentShadowLayer->syncPosition(positionForContentsLayer);
- if (scrolledContentsLayer)
- scrolledContentsLayer->syncPosition(positionForContentsLayer);
- if (headerLayer)
- headerLayer->syncPosition(positionForHeaderLayer);
- if (footerLayer)
- footerLayer->syncPosition(positionForFooterLayer);
-
- LayoutRect viewportRect = frameView.viewportConstrainedVisibleContentRect();
- syncChildPositions(viewportRect);
- }
- }
-
-#if PLATFORM(COCOA)
- if (m_page->expectsWheelEventTriggers()) {
- frameView.scrollAnimator().setWheelEventTestTrigger(m_page->testTrigger());
- if (const auto& trigger = m_page->testTrigger())
- trigger->removeTestDeferralForReason(reinterpret_cast<WheelEventTestTrigger::ScrollableAreaIdentifier>(scrollingNodeID), WheelEventTestTrigger::ScrollingThreadSyncNeeded);
- }
-#endif
-
- return;
- }
-
- // Overflow-scroll area.
- if (ScrollableArea* scrollableArea = frameView.scrollableAreaForScrollLayerID(scrollingNodeID)) {
- scrollableArea->setIsUserScroll(scrollingLayerPositionAction == SyncScrollingLayerPosition);
- scrollableArea->scrollToOffsetWithoutAnimation(scrollPosition);
- scrollableArea->setIsUserScroll(false);
- if (scrollingLayerPositionAction == SetScrollingLayerPosition)
- m_page->editorClient().overflowScrollPositionChanged();
-
-#if PLATFORM(COCOA)
- if (m_page->expectsWheelEventTriggers()) {
- frameView.scrollAnimator().setWheelEventTestTrigger(m_page->testTrigger());
- if (const auto& trigger = m_page->testTrigger())
- trigger->removeTestDeferralForReason(reinterpret_cast<WheelEventTestTrigger::ScrollableAreaIdentifier>(scrollingNodeID), WheelEventTestTrigger::ScrollingThreadSyncNeeded);
- }
-#endif
- }
-}
-
-void AsyncScrollingCoordinator::scrollableAreaScrollbarLayerDidChange(ScrollableArea& scrollableArea, ScrollbarOrientation orientation)
-{
- ASSERT(isMainThread());
- ASSERT(m_page);
-
- if (&scrollableArea != static_cast<ScrollableArea*>(m_page->mainFrame().view()))
- return;
-
- if (orientation == VerticalScrollbar)
- scrollableArea.verticalScrollbarLayerDidChange();
- else
- scrollableArea.horizontalScrollbarLayerDidChange();
-}
-
-ScrollingNodeID AsyncScrollingCoordinator::attachToStateTree(ScrollingNodeType nodeType, ScrollingNodeID newNodeID, ScrollingNodeID parentID)
-{
- return m_scrollingStateTree->attachNode(nodeType, newNodeID, parentID);
-}
-
-void AsyncScrollingCoordinator::detachFromStateTree(ScrollingNodeID nodeID)
-{
- m_scrollingStateTree->detachNode(nodeID);
-}
-
-void AsyncScrollingCoordinator::clearStateTree()
-{
- m_scrollingStateTree->clear();
-}
-
-void AsyncScrollingCoordinator::syncChildPositions(const LayoutRect& viewportRect)
-{
- if (!m_scrollingStateTree->rootStateNode())
- return;
-
- auto children = m_scrollingStateTree->rootStateNode()->children();
- if (!children)
- return;
-
- // FIXME: We'll have to traverse deeper into the tree at some point.
- for (auto& child : *children)
- child->syncLayerPositionForViewportRect(viewportRect);
-}
-
-void AsyncScrollingCoordinator::ensureRootStateNodeForFrameView(FrameView& frameView)
-{
- ASSERT(frameView.scrollLayerID());
- attachToStateTree(FrameScrollingNode, frameView.scrollLayerID(), 0);
-}
-
-void AsyncScrollingCoordinator::updateFrameScrollingNode(ScrollingNodeID nodeID, GraphicsLayer* layer, GraphicsLayer* scrolledContentsLayer, GraphicsLayer* counterScrollingLayer, GraphicsLayer* insetClipLayer, const ScrollingGeometry* scrollingGeometry)
-{
- ScrollingStateFrameScrollingNode* node = downcast<ScrollingStateFrameScrollingNode>(m_scrollingStateTree->stateNodeForID(nodeID));
- ASSERT(node);
- if (!node)
- return;
-
- node->setLayer(layer);
- node->setInsetClipLayer(insetClipLayer);
- node->setScrolledContentsLayer(scrolledContentsLayer);
- node->setCounterScrollingLayer(counterScrollingLayer);
-
- if (scrollingGeometry) {
- node->setScrollOrigin(scrollingGeometry->scrollOrigin);
- node->setScrollPosition(scrollingGeometry->scrollPosition);
- node->setTotalContentsSize(scrollingGeometry->contentSize);
- node->setReachableContentsSize(scrollingGeometry->reachableContentSize);
- node->setScrollableAreaSize(scrollingGeometry->scrollableAreaSize);
- }
-}
-
-void AsyncScrollingCoordinator::updateOverflowScrollingNode(ScrollingNodeID nodeID, GraphicsLayer* layer, GraphicsLayer* scrolledContentsLayer, const ScrollingGeometry* scrollingGeometry)
-{
- ScrollingStateOverflowScrollingNode* node = downcast<ScrollingStateOverflowScrollingNode>(m_scrollingStateTree->stateNodeForID(nodeID));
- ASSERT(node);
- if (!node)
- return;
-
- node->setLayer(layer);
- node->setScrolledContentsLayer(scrolledContentsLayer);
-
- if (scrollingGeometry) {
- node->setScrollOrigin(scrollingGeometry->scrollOrigin);
- node->setScrollPosition(scrollingGeometry->scrollPosition);
- node->setTotalContentsSize(scrollingGeometry->contentSize);
- node->setReachableContentsSize(scrollingGeometry->reachableContentSize);
- node->setScrollableAreaSize(scrollingGeometry->scrollableAreaSize);
-#if ENABLE(CSS_SCROLL_SNAP)
- setStateScrollingNodeSnapOffsetsAsFloat(*node, ScrollEventAxis::Horizontal, &scrollingGeometry->horizontalSnapOffsets, m_page->deviceScaleFactor());
- setStateScrollingNodeSnapOffsetsAsFloat(*node, ScrollEventAxis::Vertical, &scrollingGeometry->verticalSnapOffsets, m_page->deviceScaleFactor());
- node->setCurrentHorizontalSnapPointIndex(scrollingGeometry->currentHorizontalSnapPointIndex);
- node->setCurrentVerticalSnapPointIndex(scrollingGeometry->currentVerticalSnapPointIndex);
-#endif
- }
-}
-
-void AsyncScrollingCoordinator::updateViewportConstrainedNode(ScrollingNodeID nodeID, const ViewportConstraints& constraints, GraphicsLayer* graphicsLayer)
-{
- ASSERT(supportsFixedPositionLayers());
-
- ScrollingStateNode* node = m_scrollingStateTree->stateNodeForID(nodeID);
- if (!node)
- return;
-
- switch (constraints.constraintType()) {
- case ViewportConstraints::FixedPositionConstraint: {
- ScrollingStateFixedNode& fixedNode = downcast<ScrollingStateFixedNode>(*node);
- fixedNode.setLayer(graphicsLayer);
- fixedNode.updateConstraints((const FixedPositionViewportConstraints&)constraints);
- break;
- }
- case ViewportConstraints::StickyPositionConstraint: {
- ScrollingStateStickyNode& stickyNode = downcast<ScrollingStateStickyNode>(*node);
- stickyNode.setLayer(graphicsLayer);
- stickyNode.updateConstraints((const StickyPositionViewportConstraints&)constraints);
- break;
- }
- }
-}
-
-void AsyncScrollingCoordinator::setSynchronousScrollingReasons(SynchronousScrollingReasons reasons)
-{
- if (!m_scrollingStateTree->rootStateNode())
- return;
-
- // The FrameView's GraphicsLayer is likely to be out-of-synch with the PlatformLayer
- // at this point. So we'll update it before we switch back to main thread scrolling
- // in order to avoid layer positioning bugs.
- if (reasons)
- updateMainFrameScrollLayerPosition();
- m_scrollingStateTree->rootStateNode()->setSynchronousScrollingReasons(reasons);
-}
-
-void AsyncScrollingCoordinator::updateMainFrameScrollLayerPosition()
-{
- ASSERT(isMainThread());
-
- if (!m_page)
- return;
-
- FrameView* frameView = m_page->mainFrame().view();
- if (!frameView)
- return;
-
- if (GraphicsLayer* scrollLayer = scrollLayerForFrameView(*frameView))
- scrollLayer->setPosition(-frameView->scrollPosition());
-}
-
-bool AsyncScrollingCoordinator::isRubberBandInProgress() const
-{
- return scrollingTree()->isRubberBandInProgress();
-}
-
-void AsyncScrollingCoordinator::setScrollPinningBehavior(ScrollPinningBehavior pinning)
-{
- scrollingTree()->setScrollPinningBehavior(pinning);
-}
-
-String AsyncScrollingCoordinator::scrollingStateTreeAsText() const
-{
- if (m_scrollingStateTree->rootStateNode()) {
- if (m_nonFastScrollableRegionDirty)
- m_scrollingStateTree->rootStateNode()->setNonFastScrollableRegion(absoluteNonFastScrollableRegion());
- return m_scrollingStateTree->rootStateNode()->scrollingStateTreeAsText();
- }
-
- return String();
-}
-
-#if PLATFORM(COCOA)
-void AsyncScrollingCoordinator::setActiveScrollSnapIndices(ScrollingNodeID scrollingNodeID, unsigned horizontalIndex, unsigned verticalIndex)
-{
- ASSERT(isMainThread());
-
- if (!m_page)
- return;
-
- FrameView* frameView = frameViewForScrollingNode(scrollingNodeID);
- if (!frameView)
- return;
-
- if (scrollingNodeID == frameView->scrollLayerID()) {
- frameView->setCurrentHorizontalSnapPointIndex(horizontalIndex);
- frameView->setCurrentVerticalSnapPointIndex(verticalIndex);
- return;
- }
-
- // Overflow-scroll area.
- if (ScrollableArea* scrollableArea = frameView->scrollableAreaForScrollLayerID(scrollingNodeID)) {
- scrollableArea->setCurrentHorizontalSnapPointIndex(horizontalIndex);
- scrollableArea->setCurrentVerticalSnapPointIndex(verticalIndex);
- }
-}
-
-void AsyncScrollingCoordinator::deferTestsForReason(WheelEventTestTrigger::ScrollableAreaIdentifier identifier, WheelEventTestTrigger::DeferTestTriggerReason reason) const
-{
- ASSERT(isMainThread());
- if (!m_page || !m_page->expectsWheelEventTriggers())
- return;
-
- if (const auto& trigger = m_page->testTrigger()) {
- LOG(WheelEventTestTriggers, " (!) AsyncScrollingCoordinator::deferTestsForReason: Deferring %p for reason %d.", identifier, reason);
- trigger->deferTestsForReason(identifier, reason);
- }
-}
-
-void AsyncScrollingCoordinator::removeTestDeferralForReason(WheelEventTestTrigger::ScrollableAreaIdentifier identifier, WheelEventTestTrigger::DeferTestTriggerReason reason) const
-{
- ASSERT(isMainThread());
- if (!m_page || !m_page->expectsWheelEventTriggers())
- return;
-
- if (const auto& trigger = m_page->testTrigger()) {
- LOG(WheelEventTestTriggers, " (!) AsyncScrollingCoordinator::removeTestDeferralForReason: Deferring %p for reason %d.", identifier, reason);
- trigger->removeTestDeferralForReason(identifier, reason);
- }
-}
-#endif
-
-#if ENABLE(CSS_SCROLL_SNAP)
-bool AsyncScrollingCoordinator::isScrollSnapInProgress() const
-{
- return scrollingTree()->isScrollSnapInProgress();
-}
-
-void AsyncScrollingCoordinator::updateScrollSnapPropertiesWithFrameView(const FrameView& frameView)
-{
- if (auto node = downcast<ScrollingStateFrameScrollingNode>(m_scrollingStateTree->stateNodeForID(frameView.scrollLayerID()))) {
- setStateScrollingNodeSnapOffsetsAsFloat(*node, ScrollEventAxis::Horizontal, frameView.horizontalSnapOffsets(), m_page->deviceScaleFactor());
- setStateScrollingNodeSnapOffsetsAsFloat(*node, ScrollEventAxis::Vertical, frameView.verticalSnapOffsets(), m_page->deviceScaleFactor());
- node->setCurrentHorizontalSnapPointIndex(frameView.currentHorizontalSnapPointIndex());
- node->setCurrentVerticalSnapPointIndex(frameView.currentVerticalSnapPointIndex());
- }
-}
-#endif
-
-} // namespace WebCore
-
-#endif // ENABLE(ASYNC_SCROLLING)
diff --git a/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h b/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h
deleted file mode 100644
index db933d28f..000000000
--- a/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright (C) 2014-2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#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;
-
-// ScrollingCoordinator subclass that maintains a ScrollingStateTree and a ScrollingTree,
-// allowing asynchronous scrolling (in another thread or process).
-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
-
-#if ENABLE(CSS_SCROLL_SNAP)
- WEBCORE_EXPORT void updateScrollSnapPropertiesWithFrameView(const FrameView&) override;
-#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 };
-};
-
-} // namespace WebCore
-
-SPECIALIZE_TYPE_TRAITS_SCROLLING_COORDINATOR(WebCore::AsyncScrollingCoordinator, isAsyncScrollingCoordinator());
-
-#endif // ENABLE(ASYNC_SCROLLING)
-
-#endif // AsyncScrollingCoordinator_h
diff --git a/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp b/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp
deleted file mode 100644
index 12f06b2b9..000000000
--- a/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.cpp
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Copyright (C) 2014-2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "AxisScrollSnapOffsets.h"
-
-#include "ElementChildIterator.h"
-#include "HTMLCollection.h"
-#include "HTMLElement.h"
-#include "Length.h"
-#include "RenderBox.h"
-#include "RenderView.h"
-#include "ScrollableArea.h"
-#include "StyleScrollSnapPoints.h"
-
-#if ENABLE(CSS_SCROLL_SNAP)
-
-namespace WebCore {
-
-static void appendChildSnapOffsets(HTMLElement& parent, bool shouldAddHorizontalChildOffsets, Vector<LayoutUnit>& horizontalSnapOffsetSubsequence, bool shouldAddVerticalChildOffsets, Vector<LayoutUnit>& verticalSnapOffsetSubsequence)
-{
- RenderElement* scrollContainer = parent.renderer();
- ASSERT(scrollContainer);
-
- RenderView& renderView = scrollContainer->view();
-
- Vector<const RenderBox*> elements;
- for (auto& element : renderView.boxesWithScrollSnapCoordinates()) {
- if (element->findEnclosingScrollableContainer() != scrollContainer)
- continue;
-
- elements.append(element);
- }
-
- for (auto& box : elements) {
- auto& scrollSnapCoordinates = box->style().scrollSnapCoordinates();
- if (scrollSnapCoordinates.isEmpty())
- continue;
-
- LayoutRect viewSize = box->contentBoxRect();
- FloatPoint position = box->localToContainerPoint(FloatPoint(parent.renderBox()->scrollLeft(), parent.renderBox()->scrollTop()), parent.renderBox());
- for (auto& coordinate : scrollSnapCoordinates) {
- LayoutUnit lastPotentialSnapPositionX = position.x() + valueForLength(coordinate.width(), viewSize.width());
- if (shouldAddHorizontalChildOffsets && lastPotentialSnapPositionX > 0)
- horizontalSnapOffsetSubsequence.append(lastPotentialSnapPositionX);
-
- LayoutUnit lastPotentialSnapPositionY = position.y() + valueForLength(coordinate.height(), viewSize.height());
- if (shouldAddVerticalChildOffsets && lastPotentialSnapPositionY > 0)
- verticalSnapOffsetSubsequence.append(lastPotentialSnapPositionY);
- }
- }
-}
-
-static LayoutUnit destinationOffsetForViewSize(ScrollEventAxis axis, const LengthSize& destination, LayoutUnit viewSize)
-{
- const Length& dimension = (axis == ScrollEventAxis::Horizontal) ? destination.width() : destination.height();
- return valueForLength(dimension, viewSize);
-}
-
-static void updateFromStyle(Vector<LayoutUnit>& snapOffsets, const RenderStyle& style, ScrollEventAxis axis, LayoutUnit viewSize, LayoutUnit scrollSize, Vector<LayoutUnit>& snapOffsetSubsequence)
-{
- std::sort(snapOffsetSubsequence.begin(), snapOffsetSubsequence.end());
- if (snapOffsetSubsequence.isEmpty())
- snapOffsetSubsequence.append(0);
-
- auto* points = (axis == ScrollEventAxis::Horizontal) ? style.scrollSnapPointsX() : style.scrollSnapPointsY();
- bool hasRepeat = points ? points->hasRepeat : false;
- LayoutUnit repeatOffset = points ? valueForLength(points->repeatOffset, viewSize) : LayoutUnit::fromPixel(1);
- repeatOffset = std::max<LayoutUnit>(repeatOffset, LayoutUnit::fromPixel(1));
-
- LayoutUnit destinationOffset = destinationOffsetForViewSize(axis, style.scrollSnapDestination(), viewSize);
- LayoutUnit curSnapPositionShift = 0;
- LayoutUnit maxScrollOffset = scrollSize - viewSize;
- LayoutUnit lastSnapPosition = curSnapPositionShift;
- do {
- for (auto& snapPosition : snapOffsetSubsequence) {
- LayoutUnit potentialSnapPosition = curSnapPositionShift + snapPosition - destinationOffset;
- if (potentialSnapPosition < 0)
- continue;
-
- if (potentialSnapPosition >= maxScrollOffset)
- break;
-
- // Don't add another zero offset value.
- if (potentialSnapPosition)
- snapOffsets.append(potentialSnapPosition);
-
- lastSnapPosition = potentialSnapPosition + destinationOffset;
- }
- curSnapPositionShift = lastSnapPosition + repeatOffset;
- } while (hasRepeat && curSnapPositionShift < maxScrollOffset);
-
- if (snapOffsets.isEmpty())
- return;
-
- // Always put a snap point on the zero offset.
- if (snapOffsets.first())
- snapOffsets.insert(0, 0);
-
- // Always put a snap point on the maximum scroll offset.
- // Not a part of the spec, but necessary to prevent unreachable content when snapping.
- if (snapOffsets.last() != maxScrollOffset)
- snapOffsets.append(maxScrollOffset);
-}
-
-static bool styleUsesElements(ScrollEventAxis axis, const RenderStyle& style)
-{
- const ScrollSnapPoints* scrollSnapPoints = (axis == ScrollEventAxis::Horizontal) ? style.scrollSnapPointsX() : style.scrollSnapPointsY();
- if (scrollSnapPoints)
- return scrollSnapPoints->usesElements;
-
- const Length& destination = (axis == ScrollEventAxis::Horizontal) ? style.scrollSnapDestination().width() : style.scrollSnapDestination().height();
-
- return !destination.isUndefined();
-}
-
-void updateSnapOffsetsForScrollableArea(ScrollableArea& scrollableArea, HTMLElement& scrollingElement, const RenderBox& scrollingElementBox, const RenderStyle& scrollingElementStyle)
-{
- if (scrollingElementStyle.scrollSnapType() == ScrollSnapType::None) {
- scrollableArea.clearHorizontalSnapOffsets();
- scrollableArea.clearVerticalSnapOffsets();
- return;
- }
-
- LayoutRect viewSize = scrollingElementBox.contentBoxRect();
- LayoutUnit viewWidth = viewSize.width();
- LayoutUnit viewHeight = viewSize.height();
- LayoutUnit scrollWidth = scrollingElementBox.scrollWidth();
- LayoutUnit scrollHeight = scrollingElementBox.scrollHeight();
- bool canComputeHorizontalOffsets = scrollWidth > 0 && viewWidth > 0 && viewWidth < scrollWidth;
- bool canComputeVerticalOffsets = scrollHeight > 0 && viewHeight > 0 && viewHeight < scrollHeight;
-
- if (!canComputeHorizontalOffsets)
- scrollableArea.clearHorizontalSnapOffsets();
- if (!canComputeVerticalOffsets)
- scrollableArea.clearVerticalSnapOffsets();
-
- if (!canComputeHorizontalOffsets && !canComputeVerticalOffsets)
- return;
-
- Vector<LayoutUnit> horizontalSnapOffsetSubsequence;
- Vector<LayoutUnit> verticalSnapOffsetSubsequence;
-
- bool scrollSnapPointsXUsesElements = styleUsesElements(ScrollEventAxis::Horizontal, scrollingElementStyle);
- bool scrollSnapPointsYUsesElements = styleUsesElements(ScrollEventAxis::Vertical, scrollingElementStyle);
-
- if (scrollSnapPointsXUsesElements || scrollSnapPointsYUsesElements) {
- bool shouldAddHorizontalChildOffsets = scrollSnapPointsXUsesElements && canComputeHorizontalOffsets;
- bool shouldAddVerticalChildOffsets = scrollSnapPointsYUsesElements && canComputeVerticalOffsets;
- appendChildSnapOffsets(scrollingElement, shouldAddHorizontalChildOffsets, horizontalSnapOffsetSubsequence, shouldAddVerticalChildOffsets, verticalSnapOffsetSubsequence);
- }
-
- if (scrollingElementStyle.scrollSnapPointsX() && !scrollSnapPointsXUsesElements && canComputeHorizontalOffsets) {
- for (auto& snapLength : scrollingElementStyle.scrollSnapPointsX()->offsets)
- horizontalSnapOffsetSubsequence.append(valueForLength(snapLength, viewWidth));
- }
-
- if (scrollingElementStyle.scrollSnapPointsY() && !scrollSnapPointsYUsesElements && canComputeVerticalOffsets) {
- for (auto& snapLength : scrollingElementStyle.scrollSnapPointsY()->offsets)
- verticalSnapOffsetSubsequence.append(valueForLength(snapLength, viewHeight));
- }
-
- if (canComputeHorizontalOffsets) {
- auto horizontalSnapOffsets = std::make_unique<Vector<LayoutUnit>>();
- updateFromStyle(*horizontalSnapOffsets, scrollingElementStyle, ScrollEventAxis::Horizontal, viewWidth, scrollWidth, horizontalSnapOffsetSubsequence);
- if (horizontalSnapOffsets->isEmpty())
- scrollableArea.clearHorizontalSnapOffsets();
- else
- scrollableArea.setHorizontalSnapOffsets(WTFMove(horizontalSnapOffsets));
- }
- if (canComputeVerticalOffsets) {
- auto verticalSnapOffsets = std::make_unique<Vector<LayoutUnit>>();
- updateFromStyle(*verticalSnapOffsets, scrollingElementStyle, ScrollEventAxis::Vertical, viewHeight, scrollHeight, verticalSnapOffsetSubsequence);
- if (verticalSnapOffsets->isEmpty())
- scrollableArea.clearVerticalSnapOffsets();
- else
- scrollableArea.setVerticalSnapOffsets(WTFMove(verticalSnapOffsets));
- }
-}
-
-} // namespace WebCore
-
-#endif // CSS_SCROLL_SNAP
diff --git a/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.h b/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.h
deleted file mode 100644
index 8353cb509..000000000
--- a/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2014-2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef AxisScrollSnapOffsets_h
-#define AxisScrollSnapOffsets_h
-
-#if ENABLE(CSS_SCROLL_SNAP)
-
-#include "ScrollTypes.h"
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-class HTMLElement;
-class RenderBox;
-class RenderStyle;
-class ScrollableArea;
-
-void updateSnapOffsetsForScrollableArea(ScrollableArea&, HTMLElement& scrollingElement, const RenderBox& scrollingElementBox, const RenderStyle& scrollingElementStyle);
-
-// closestSnapOffset is a templated function that takes in a Vector representing snap offsets as LayoutTypes (e.g. LayoutUnit or float) and
-// as well as a VelocityType indicating the velocity (e.g. float, CGFloat, etc.) This function is templated because the UI process will now
-// use pixel snapped floats to represent snap offsets rather than LayoutUnits.
-template <typename LayoutType, typename VelocityType>
-LayoutType closestSnapOffset(const Vector<LayoutType>& snapOffsets, LayoutType scrollDestination, VelocityType velocity, unsigned& activeSnapIndex)
-{
- ASSERT(snapOffsets.size());
- activeSnapIndex = 0;
- if (scrollDestination <= snapOffsets.first())
- return snapOffsets.first();
-
- activeSnapIndex = snapOffsets.size() - 1;
- if (scrollDestination >= snapOffsets.last())
- return snapOffsets.last();
-
- size_t lowerIndex = 0;
- size_t upperIndex = snapOffsets.size() - 1;
- while (lowerIndex < upperIndex - 1) {
- size_t middleIndex = (lowerIndex + upperIndex) / 2;
- if (scrollDestination < snapOffsets[middleIndex])
- upperIndex = middleIndex;
- else if (scrollDestination > snapOffsets[middleIndex])
- lowerIndex = middleIndex;
- else {
- upperIndex = middleIndex;
- lowerIndex = middleIndex;
- break;
- }
- }
- LayoutType lowerSnapPosition = snapOffsets[lowerIndex];
- LayoutType upperSnapPosition = snapOffsets[upperIndex];
- // Nonzero velocity indicates a flick gesture. Even if another snap point is closer, snap to the one in the direction of the flick gesture.
- if (velocity) {
- activeSnapIndex = (velocity < 0) ? lowerIndex : upperIndex;
- return velocity < 0 ? lowerSnapPosition : upperSnapPosition;
- }
-
- bool isCloserToLowerSnapPosition = scrollDestination - lowerSnapPosition <= upperSnapPosition - scrollDestination;
- activeSnapIndex = isCloserToLowerSnapPosition ? lowerIndex : upperIndex;
- return isCloserToLowerSnapPosition ? lowerSnapPosition : upperSnapPosition;
-}
-
-} // namespace WebCore
-
-#endif // CSS_SCROLL_SNAP
-
-#endif // AxisScrollSnapOffsets_h
diff --git a/Source/WebCore/page/scrolling/ScrollLatchingState.cpp b/Source/WebCore/page/scrolling/ScrollLatchingState.cpp
deleted file mode 100644
index e39d99efb..000000000
--- a/Source/WebCore/page/scrolling/ScrollLatchingState.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ScrollLatchingState.h"
-
-#include "Element.h"
-
-namespace WebCore {
-
-ScrollLatchingState::ScrollLatchingState()
- : m_frame(nullptr)
- , m_widgetIsLatched(false)
- , m_startedGestureAtScrollLimit(false)
-{
-}
-
-ScrollLatchingState::~ScrollLatchingState()
-{
-}
-
-void ScrollLatchingState::clear()
-{
- m_wheelEventElement = nullptr;
- m_frame = nullptr;
- m_scrollableContainer = nullptr;
- m_widgetIsLatched = false;
- m_previousWheelScrolledElement = nullptr;
-}
-
-void ScrollLatchingState::setWheelEventElement(PassRefPtr<Element> element)
-{
- m_wheelEventElement = element;
-}
-
-void ScrollLatchingState::setWidgetIsLatched(bool isOverWidget)
-{
- m_widgetIsLatched = isOverWidget;
-}
-
-void ScrollLatchingState::setPreviousWheelScrolledElement(RefPtr<Element>&& element)
-{
- m_previousWheelScrolledElement = element;
-}
-
-void ScrollLatchingState::setScrollableContainer(PassRefPtr<ContainerNode> node)
-{
- m_scrollableContainer = node;
-}
-
-}
diff --git a/Source/WebCore/page/scrolling/ScrollLatchingState.h b/Source/WebCore/page/scrolling/ScrollLatchingState.h
deleted file mode 100644
index b1ddde5d7..000000000
--- a/Source/WebCore/page/scrolling/ScrollLatchingState.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScrollLatchingState_h
-#define ScrollLatchingState_h
-
-#include <wtf/RefPtr.h>
-
-namespace WebCore {
-
-class ContainerNode;
-class Element;
-class Frame;
-
-class ScrollLatchingState final {
-public:
- ScrollLatchingState();
- ~ScrollLatchingState();
-
- void clear();
-
- Element* wheelEventElement() { return m_wheelEventElement.get(); }
- void setWheelEventElement(PassRefPtr<Element>);
- Frame* frame() { return m_frame; }
- void setFrame(Frame* frame) { m_frame = frame; }
-
- bool widgetIsLatched() const { return m_widgetIsLatched; }
- void setWidgetIsLatched(bool isOverWidget);
-
- Element* previousWheelScrolledElement() { return m_previousWheelScrolledElement.get(); }
- void setPreviousWheelScrolledElement(RefPtr<Element>&&);
-
- ContainerNode* scrollableContainer() { return m_scrollableContainer.get(); }
- void setScrollableContainer(PassRefPtr<ContainerNode>);
- bool startedGestureAtScrollLimit() const { return m_startedGestureAtScrollLimit; }
- void setStartedGestureAtScrollLimit(bool startedAtLimit) { m_startedGestureAtScrollLimit = startedAtLimit; }
-
-private:
- RefPtr<Element> m_wheelEventElement;
- RefPtr<Element> m_previousWheelScrolledElement;
- RefPtr<ContainerNode> m_scrollableContainer;
-
- Frame* m_frame;
-
- bool m_widgetIsLatched;
- bool m_startedGestureAtScrollLimit;
-};
-
-}
-
-#endif
diff --git a/Source/WebCore/page/scrolling/ScrollingConstraints.cpp b/Source/WebCore/page/scrolling/ScrollingConstraints.cpp
index 00f101a34..4b3f4d68c 100644
--- a/Source/WebCore/page/scrolling/ScrollingConstraints.cpp
+++ b/Source/WebCore/page/scrolling/ScrollingConstraints.cpp
@@ -26,8 +26,6 @@
#include "config.h"
#include "ScrollingConstraints.h"
-#include "TextStream.h"
-
namespace WebCore {
FloatPoint FixedPositionViewportConstraints::layerPositionForViewportRect(const FloatRect& viewportRect) const
@@ -100,20 +98,4 @@ FloatPoint StickyPositionViewportConstraints::layerPositionForConstrainingRect(c
return m_layerPositionAtLastLayout + offset - m_stickyOffsetAtLastLayout;
}
-TextStream& operator<<(TextStream& ts, const FixedPositionViewportConstraints& constraints)
-{
- ts.dumpProperty("viewport-rect-at-last-layout", constraints.viewportRectAtLastLayout());
- ts.dumpProperty("layer-position-at-last-layout", constraints.layerPositionAtLastLayout());
-
- return ts;
-}
-
-TextStream& operator<<(TextStream& ts, const StickyPositionViewportConstraints& constraints)
-{
- ts.dumpProperty("sticky-position-at-last-layout", constraints.stickyOffsetAtLastLayout());
- ts.dumpProperty("layer-position-at-last-layout", constraints.layerPositionAtLastLayout());
-
- return ts;
-}
-
} // namespace WebCore
diff --git a/Source/WebCore/page/scrolling/ScrollingConstraints.h b/Source/WebCore/page/scrolling/ScrollingConstraints.h
index 23b05b8ab..d4c1dd461 100644
--- a/Source/WebCore/page/scrolling/ScrollingConstraints.h
+++ b/Source/WebCore/page/scrolling/ScrollingConstraints.h
@@ -33,7 +33,6 @@ namespace WebCore {
// ViewportConstraints classes encapsulate data and logic required to reposition elements whose layout
// depends on the viewport rect (positions fixed and sticky), when scrolling and zooming.
class ViewportConstraints {
- WTF_MAKE_FAST_ALLOCATED;
public:
enum ConstraintType {
FixedPositionConstraint,
@@ -86,7 +85,7 @@ public:
, m_layerPositionAtLastLayout(other.m_layerPositionAtLastLayout)
{ }
- WEBCORE_EXPORT FloatPoint layerPositionForViewportRect(const FloatRect& viewportRect) const;
+ FloatPoint layerPositionForViewportRect(const FloatRect& viewportRect) const;
const FloatRect& viewportRectAtLastLayout() const { return m_viewportRectAtLastLayout; }
void setViewportRectAtLastLayout(const FloatRect& rect) { m_viewportRectAtLastLayout = rect; }
@@ -138,7 +137,7 @@ public:
const FloatSize stickyOffsetAtLastLayout() const { return m_stickyOffsetAtLastLayout; }
void setStickyOffsetAtLastLayout(const FloatSize& offset) { m_stickyOffsetAtLastLayout = offset; }
- WEBCORE_EXPORT FloatPoint layerPositionForConstrainingRect(const FloatRect& constrainingRect) const;
+ FloatPoint layerPositionForConstrainingRect(const FloatRect& constrainingRect) const;
const FloatPoint& layerPositionAtLastLayout() const { return m_layerPositionAtLastLayout; }
void setLayerPositionAtLastLayout(const FloatPoint& point) { m_layerPositionAtLastLayout = point; }
@@ -168,9 +167,7 @@ public:
bool operator==(const StickyPositionViewportConstraints& other) const
{
- return m_alignmentOffset == other.m_alignmentOffset
- && m_anchorEdges == other.m_anchorEdges
- && m_leftOffset == other.m_leftOffset
+ return m_leftOffset == other.m_leftOffset
&& m_rightOffset == other.m_rightOffset
&& m_topOffset == other.m_topOffset
&& m_bottomOffset == other.m_bottomOffset
@@ -196,9 +193,6 @@ private:
FloatPoint m_layerPositionAtLastLayout;
};
-WEBCORE_EXPORT TextStream& operator<<(TextStream&, const FixedPositionViewportConstraints&);
-WEBCORE_EXPORT TextStream& operator<<(TextStream&, const StickyPositionViewportConstraints&);
-
} // namespace WebCore
#endif // ScrollingConstraints_h
diff --git a/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp b/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp
index 53b98c145..93dfb0cec 100644
--- a/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp
+++ b/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp
@@ -36,38 +36,35 @@
#include "PlatformWheelEvent.h"
#include "PluginViewBase.h"
#include "Region.h"
-#include "RenderLayerCompositor.h"
#include "RenderView.h"
#include "ScrollAnimator.h"
-#include "Settings.h"
-#include "TextStream.h"
#include <wtf/MainThread.h>
#include <wtf/text/StringBuilder.h>
-#if USE(COORDINATED_GRAPHICS)
-#include "ScrollingCoordinatorCoordinatedGraphics.h"
+#if USE(ACCELERATED_COMPOSITING)
+#include "RenderLayerCompositor.h"
#endif
-#if ENABLE(WEB_REPLAY)
-#include "ReplayController.h"
-#include <replay/InputCursor.h>
+#if USE(COORDINATED_GRAPHICS)
+#include "ScrollingCoordinatorCoordinatedGraphics.h"
#endif
namespace WebCore {
-#if !PLATFORM(COCOA)
-Ref<ScrollingCoordinator> ScrollingCoordinator::create(Page* page)
+#if !PLATFORM(MAC)
+PassRefPtr<ScrollingCoordinator> ScrollingCoordinator::create(Page* page)
{
#if USE(COORDINATED_GRAPHICS)
- return adoptRef(*new ScrollingCoordinatorCoordinatedGraphics(page));
+ return adoptRef(new ScrollingCoordinatorCoordinatedGraphics(page));
#endif
- return adoptRef(*new ScrollingCoordinator(page));
+ return adoptRef(new ScrollingCoordinator(page));
}
#endif
ScrollingCoordinator::ScrollingCoordinator(Page* page)
: m_page(page)
+ , m_forceSynchronousScrollLayerPositionUpdates(false)
{
}
@@ -79,115 +76,88 @@ ScrollingCoordinator::~ScrollingCoordinator()
void ScrollingCoordinator::pageDestroyed()
{
ASSERT(m_page);
- m_page = nullptr;
+ m_page = 0;
}
-bool ScrollingCoordinator::coordinatesScrollingForFrameView(const FrameView& frameView) const
+bool ScrollingCoordinator::coordinatesScrollingForFrameView(FrameView* frameView) const
{
ASSERT(isMainThread());
ASSERT(m_page);
- if (!frameView.frame().isMainFrame() && !m_page->settings().scrollingTreeIncludesFrames())
+ // We currently only handle the main frame.
+ if (!frameView->frame().isMainFrame())
return false;
+ // We currently only support composited mode.
+#if USE(ACCELERATED_COMPOSITING)
RenderView* renderView = m_page->mainFrame().contentRenderer();
if (!renderView)
return false;
return renderView->usesCompositing();
+#else
+ return false;
+#endif
}
-Region ScrollingCoordinator::absoluteNonFastScrollableRegionForFrame(const Frame& frame) const
+Region ScrollingCoordinator::computeNonFastScrollableRegion(const Frame* frame, const IntPoint& frameLocation) const
{
- RenderView* renderView = frame.contentRenderer();
- if (!renderView || renderView->documentBeingDestroyed())
- return Region();
-
-#if ENABLE(IOS_TOUCH_EVENTS)
- // On iOS, we use nonFastScrollableRegion to represent the region covered by elements with touch event handlers.
- ASSERT(frame.isMainFrame());
-
- Document* document = frame.document();
- if (!document)
- return Region();
-
- Vector<IntRect> touchRects;
- document->getTouchRects(touchRects);
-
- Region touchRegion;
- for (const auto& rect : touchRects)
- touchRegion.unite(rect);
-
- // FIXME: use absoluteRegionForEventTargets().
- return touchRegion;
-#else
Region nonFastScrollableRegion;
- FrameView* frameView = frame.view();
+ FrameView* frameView = frame->view();
if (!frameView)
return nonFastScrollableRegion;
- // FIXME: should ASSERT(!frameView->needsLayout()) here, but need to fix DebugPageOverlays
- // to not ask for regions at bad times.
+ IntPoint offset = frameLocation;
+ offset.moveBy(frameView->frameRect().location());
if (const FrameView::ScrollableAreaSet* scrollableAreas = frameView->scrollableAreas()) {
- for (auto& scrollableArea : *scrollableAreas) {
+ for (FrameView::ScrollableAreaSet::const_iterator it = scrollableAreas->begin(), end = scrollableAreas->end(); it != end; ++it) {
+ ScrollableArea* scrollableArea = *it;
+#if USE(ACCELERATED_COMPOSITING)
// Composited scrollable areas can be scrolled off the main thread.
- if (scrollableArea->usesAsyncScrolling())
+ if (scrollableArea->usesCompositedScrolling())
continue;
-
- bool isInsideFixed;
- IntRect box = scrollableArea->scrollableAreaBoundingBox(&isInsideFixed);
- if (isInsideFixed)
- box = IntRect(frameView->fixedScrollableAreaBoundsInflatedForScrolling(LayoutRect(box)));
-
+#endif
+ IntRect box = scrollableArea->scrollableAreaBoundingBox();
+ box.moveBy(offset);
nonFastScrollableRegion.unite(box);
}
}
- for (auto& widget : frameView->widgetsInRenderTree()) {
- RenderWidget* renderWidget = RenderWidget::find(widget);
- if (!renderWidget || !is<PluginViewBase>(*widget))
+ for (auto it = frameView->children().begin(), end = frameView->children().end(); it != end; ++it) {
+ if (!(*it)->isPluginViewBase())
continue;
-
- if (downcast<PluginViewBase>(*widget).wantsWheelEvents())
- nonFastScrollableRegion.unite(renderWidget->absoluteBoundingBoxRect());
+ PluginViewBase* pluginViewBase = toPluginViewBase((*it).get());
+ if (pluginViewBase->wantsWheelEvents())
+ nonFastScrollableRegion.unite(pluginViewBase->frameRect());
}
-
- // FIXME: if we've already accounted for this subframe as a scrollable area, we can avoid recursing into it here.
- for (Frame* subframe = frame.tree().firstChild(); subframe; subframe = subframe->tree().nextSibling()) {
- FrameView* subframeView = subframe->view();
- if (!subframeView)
- continue;
- Region subframeRegion = absoluteNonFastScrollableRegionForFrame(*subframe);
- // Map from the frame document to our document.
- IntPoint offset = subframeView->contentsToContainingViewContents(IntPoint());
+ for (Frame* subframe = frame->tree().firstChild(); subframe; subframe = subframe->tree().nextSibling())
+ nonFastScrollableRegion.unite(computeNonFastScrollableRegion(subframe, offset));
- // FIXME: this translation ignores non-trival transforms on the frame.
- subframeRegion.translate(toIntSize(offset));
- nonFastScrollableRegion.unite(subframeRegion);
- }
+ return nonFastScrollableRegion;
+}
- Document::RegionFixedPair wheelHandlerRegion = frame.document()->absoluteRegionForEventTargets(frame.document()->wheelEventTargets());
- bool wheelHandlerInFixedContent = wheelHandlerRegion.second;
- if (wheelHandlerInFixedContent) {
- // FIXME: need to handle position:sticky here too.
- LayoutRect inflatedWheelHandlerBounds = frameView->fixedScrollableAreaBoundsInflatedForScrolling(LayoutRect(wheelHandlerRegion.first.bounds()));
- wheelHandlerRegion.first.unite(enclosingIntRect(inflatedWheelHandlerBounds));
+unsigned ScrollingCoordinator::computeCurrentWheelEventHandlerCount()
+{
+ unsigned wheelEventHandlerCount = 0;
+
+ for (Frame* frame = &m_page->mainFrame(); frame; frame = frame->tree().traverseNext()) {
+ if (frame->document())
+ wheelEventHandlerCount += frame->document()->wheelEventHandlerCount();
}
-
- nonFastScrollableRegion.unite(wheelHandlerRegion.first);
- // FIXME: If this is not the main frame, we could clip the region to the frame's bounds.
- return nonFastScrollableRegion;
-#endif
+ return wheelEventHandlerCount;
}
-Region ScrollingCoordinator::absoluteNonFastScrollableRegion() const
+void ScrollingCoordinator::frameViewWheelEventHandlerCountChanged(FrameView* frameView)
{
- return absoluteNonFastScrollableRegionForFrame(m_page->mainFrame());
+ ASSERT(isMainThread());
+ ASSERT(m_page);
+
+ recomputeWheelEventHandlerCountForFrameView(frameView);
}
-void ScrollingCoordinator::frameViewHasSlowRepaintObjectsDidChange(FrameView& frameView)
+void ScrollingCoordinator::frameViewHasSlowRepaintObjectsDidChange(FrameView* frameView)
{
ASSERT(isMainThread());
ASSERT(m_page);
@@ -195,10 +165,10 @@ void ScrollingCoordinator::frameViewHasSlowRepaintObjectsDidChange(FrameView& fr
if (!coordinatesScrollingForFrameView(frameView))
return;
- updateSynchronousScrollingReasons(frameView);
+ updateSynchronousScrollingReasons();
}
-void ScrollingCoordinator::frameViewFixedObjectsDidChange(FrameView& frameView)
+void ScrollingCoordinator::frameViewFixedObjectsDidChange(FrameView* frameView)
{
ASSERT(isMainThread());
ASSERT(m_page);
@@ -206,80 +176,75 @@ void ScrollingCoordinator::frameViewFixedObjectsDidChange(FrameView& frameView)
if (!coordinatesScrollingForFrameView(frameView))
return;
- updateSynchronousScrollingReasons(frameView);
+ updateSynchronousScrollingReasons();
}
-GraphicsLayer* ScrollingCoordinator::scrollLayerForScrollableArea(ScrollableArea& scrollableArea)
+#if USE(ACCELERATED_COMPOSITING)
+GraphicsLayer* ScrollingCoordinator::scrollLayerForScrollableArea(ScrollableArea* scrollableArea)
{
- return scrollableArea.layerForScrolling();
+ return scrollableArea->layerForScrolling();
}
-GraphicsLayer* ScrollingCoordinator::scrollLayerForFrameView(FrameView& frameView)
+GraphicsLayer* ScrollingCoordinator::horizontalScrollbarLayerForScrollableArea(ScrollableArea* scrollableArea)
{
- if (RenderView* renderView = frameView.frame().contentRenderer())
- return renderView->compositor().scrollLayer();
- return nullptr;
+ return scrollableArea->layerForHorizontalScrollbar();
}
-GraphicsLayer* ScrollingCoordinator::headerLayerForFrameView(FrameView& frameView)
+GraphicsLayer* ScrollingCoordinator::verticalScrollbarLayerForScrollableArea(ScrollableArea* scrollableArea)
{
-#if ENABLE(RUBBER_BANDING)
- if (RenderView* renderView = frameView.frame().contentRenderer())
- return renderView->compositor().headerLayer();
- return nullptr;
-#else
- UNUSED_PARAM(frameView);
- return nullptr;
-#endif
+ return scrollableArea->layerForVerticalScrollbar();
}
+#endif
-GraphicsLayer* ScrollingCoordinator::footerLayerForFrameView(FrameView& frameView)
+GraphicsLayer* ScrollingCoordinator::scrollLayerForFrameView(FrameView* frameView)
{
-#if ENABLE(RUBBER_BANDING)
- if (RenderView* renderView = frameView.frame().contentRenderer())
- return renderView->compositor().footerLayer();
- return nullptr;
+#if USE(ACCELERATED_COMPOSITING)
+ if (RenderView* renderView = frameView->frame().contentRenderer())
+ return renderView->compositor().scrollLayer();
+ return 0;
#else
UNUSED_PARAM(frameView);
- return nullptr;
+ return 0;
#endif
}
-GraphicsLayer* ScrollingCoordinator::counterScrollingLayerForFrameView(FrameView& frameView)
+GraphicsLayer* ScrollingCoordinator::headerLayerForFrameView(FrameView* frameView)
{
- if (RenderView* renderView = frameView.frame().contentRenderer())
- return renderView->compositor().fixedRootBackgroundLayer();
- return nullptr;
-}
-
-GraphicsLayer* ScrollingCoordinator::insetClipLayerForFrameView(FrameView& frameView)
-{
- if (RenderView* renderView = frameView.frame().contentRenderer())
- return renderView->compositor().clipLayer();
- return nullptr;
+#if USE(ACCELERATED_COMPOSITING) && ENABLE(RUBBER_BANDING)
+ if (RenderView* renderView = frameView->frame().contentRenderer())
+ renderView->compositor().headerLayer();
+ return 0;
+#else
+ UNUSED_PARAM(frameView);
+ return 0;
+#endif
}
-GraphicsLayer* ScrollingCoordinator::contentShadowLayerForFrameView(FrameView& frameView)
+GraphicsLayer* ScrollingCoordinator::footerLayerForFrameView(FrameView* frameView)
{
-#if ENABLE(RUBBER_BANDING)
- if (RenderView* renderView = frameView.frame().contentRenderer())
- return renderView->compositor().layerForContentShadow();
-
- return nullptr;
+#if USE(ACCELERATED_COMPOSITING) && ENABLE(RUBBER_BANDING)
+ if (RenderView* renderView = frameView->frame().contentRenderer())
+ return renderView->compositor().footerLayer();
+ return 0;
#else
UNUSED_PARAM(frameView);
- return nullptr;
+ return 0;
#endif
}
-GraphicsLayer* ScrollingCoordinator::rootContentLayerForFrameView(FrameView& frameView)
+GraphicsLayer* ScrollingCoordinator::counterScrollingLayerForFrameView(FrameView* frameView)
{
- if (RenderView* renderView = frameView.frame().contentRenderer())
- return renderView->compositor().rootContentLayer();
- return nullptr;
+#if USE(ACCELERATED_COMPOSITING)
+ if (RenderView* renderView = frameView->frame().contentRenderer())
+ return renderView->compositor().fixedRootBackgroundLayer();
+ return 0;
+#else
+ UNUSED_PARAM(frameView);
+ return 0;
+#endif
}
-void ScrollingCoordinator::frameViewRootLayerDidChange(FrameView& frameView)
+void ScrollingCoordinator::frameViewRootLayerDidChange(FrameView* frameView)
{
ASSERT(isMainThread());
ASSERT(m_page);
@@ -288,10 +253,11 @@ void ScrollingCoordinator::frameViewRootLayerDidChange(FrameView& frameView)
return;
frameViewLayoutUpdated(frameView);
- updateSynchronousScrollingReasons(frameView);
+ recomputeWheelEventHandlerCountForFrameView(frameView);
+ updateSynchronousScrollingReasons();
}
-#if PLATFORM(COCOA)
+#if PLATFORM(MAC)
void ScrollingCoordinator::handleWheelEventPhase(PlatformWheelEventPhase phase)
{
ASSERT(isMainThread());
@@ -303,58 +269,57 @@ void ScrollingCoordinator::handleWheelEventPhase(PlatformWheelEventPhase phase)
if (!frameView)
return;
- frameView->scrollAnimator().handleWheelEventPhase(phase);
+ frameView->scrollAnimator()->handleWheelEventPhase(phase);
}
#endif
-bool ScrollingCoordinator::hasVisibleSlowRepaintViewportConstrainedObjects(const FrameView& frameView) const
+bool ScrollingCoordinator::hasVisibleSlowRepaintViewportConstrainedObjects(FrameView* frameView) const
{
- const FrameView::ViewportConstrainedObjectSet* viewportConstrainedObjects = frameView.viewportConstrainedObjects();
+ const FrameView::ViewportConstrainedObjectSet* viewportConstrainedObjects = frameView->viewportConstrainedObjects();
if (!viewportConstrainedObjects)
return false;
- for (auto& viewportConstrainedObject : *viewportConstrainedObjects) {
- if (!is<RenderBoxModelObject>(*viewportConstrainedObject) || !viewportConstrainedObject->hasLayer())
+#if USE(ACCELERATED_COMPOSITING)
+ for (FrameView::ViewportConstrainedObjectSet::const_iterator it = viewportConstrainedObjects->begin(), end = viewportConstrainedObjects->end(); it != end; ++it) {
+ RenderObject* viewportConstrainedObject = *it;
+ if (!viewportConstrainedObject->isBoxModelObject() || !viewportConstrainedObject->hasLayer())
return true;
- RenderLayer& layer = *downcast<RenderBoxModelObject>(*viewportConstrainedObject).layer();
+ RenderLayer* layer = toRenderBoxModelObject(viewportConstrainedObject)->layer();
// Any explicit reason that a fixed position element is not composited shouldn't cause slow scrolling.
- if (!layer.isComposited() && layer.viewportConstrainedNotCompositedReason() == RenderLayer::NoNotCompositedReason)
+ if (!layer->isComposited() && layer->viewportConstrainedNotCompositedReason() == RenderLayer::NoNotCompositedReason)
return true;
}
return false;
+#else
+ return viewportConstrainedObjects->size();
+#endif
}
-SynchronousScrollingReasons ScrollingCoordinator::synchronousScrollingReasons(const FrameView& frameView) const
+SynchronousScrollingReasons ScrollingCoordinator::synchronousScrollingReasons() const
{
+ FrameView* frameView = m_page->mainFrame().view();
+ if (!frameView)
+ return static_cast<SynchronousScrollingReasons>(0);
+
SynchronousScrollingReasons synchronousScrollingReasons = (SynchronousScrollingReasons)0;
if (m_forceSynchronousScrollLayerPositionUpdates)
synchronousScrollingReasons |= ForcedOnMainThread;
-#if ENABLE(WEB_REPLAY)
- InputCursor& cursor = m_page->replayController().activeInputCursor();
- if (cursor.isCapturing() || cursor.isReplaying())
- synchronousScrollingReasons |= ForcedOnMainThread;
-#endif
- if (frameView.hasSlowRepaintObjects())
+ if (frameView->hasSlowRepaintObjects())
synchronousScrollingReasons |= HasSlowRepaintObjects;
- if (!supportsFixedPositionLayers() && frameView.hasViewportConstrainedObjects())
+ if (!supportsFixedPositionLayers() && frameView->hasViewportConstrainedObjects())
synchronousScrollingReasons |= HasViewportConstrainedObjectsWithoutSupportingFixedLayers;
if (supportsFixedPositionLayers() && hasVisibleSlowRepaintViewportConstrainedObjects(frameView))
synchronousScrollingReasons |= HasNonLayerViewportConstrainedObjects;
- if (frameView.frame().mainFrame().document() && frameView.frame().document()->isImageDocument())
+ if (m_page->mainFrame().document() && m_page->mainFrame().document()->isImageDocument())
synchronousScrollingReasons |= IsImageDocument;
return synchronousScrollingReasons;
}
-void ScrollingCoordinator::updateSynchronousScrollingReasons(FrameView& frameView)
+void ScrollingCoordinator::updateSynchronousScrollingReasons()
{
- // FIXME: Once we support async scrolling of iframes, we'll have to track the synchronous scrolling
- // reasons per frame (maybe on scrolling tree nodes).
- if (!frameView.frame().isMainFrame())
- return;
-
- setSynchronousScrollingReasons(synchronousScrollingReasons(frameView));
+ setSynchronousScrollingReasons(synchronousScrollingReasons());
}
void ScrollingCoordinator::setForceSynchronousScrollLayerPositionUpdates(bool forceSynchronousScrollLayerPositionUpdates)
@@ -363,25 +328,8 @@ void ScrollingCoordinator::setForceSynchronousScrollLayerPositionUpdates(bool fo
return;
m_forceSynchronousScrollLayerPositionUpdates = forceSynchronousScrollLayerPositionUpdates;
- if (FrameView* frameView = m_page->mainFrame().view())
- updateSynchronousScrollingReasons(*frameView);
-}
-
-bool ScrollingCoordinator::shouldUpdateScrollLayerPositionSynchronously() const
-{
- if (FrameView* frameView = m_page->mainFrame().view())
- return synchronousScrollingReasons(*frameView);
- return true;
-}
-
-#if ENABLE(WEB_REPLAY)
-void ScrollingCoordinator::replaySessionStateDidChange()
-{
- // FIXME: Once we support async scrolling of iframes, this should go through all subframes.
- if (FrameView* frameView = m_page->mainFrame().view())
- updateSynchronousScrollingReasons(*frameView);
+ updateSynchronousScrollingReasons();
}
-#endif
ScrollingNodeID ScrollingCoordinator::uniqueScrollLayerID()
{
@@ -399,15 +347,15 @@ String ScrollingCoordinator::synchronousScrollingReasonsAsText(SynchronousScroll
StringBuilder stringBuilder;
if (reasons & ScrollingCoordinator::ForcedOnMainThread)
- stringBuilder.appendLiteral("Forced on main thread, ");
+ stringBuilder.append("Forced on main thread, ");
if (reasons & ScrollingCoordinator::HasSlowRepaintObjects)
- stringBuilder.appendLiteral("Has slow repaint objects, ");
+ stringBuilder.append("Has slow repaint objects, ");
if (reasons & ScrollingCoordinator::HasViewportConstrainedObjectsWithoutSupportingFixedLayers)
- stringBuilder.appendLiteral("Has viewport constrained objects without supporting fixed layers, ");
+ stringBuilder.append("Has viewport constrained objects without supporting fixed layers, ");
if (reasons & ScrollingCoordinator::HasNonLayerViewportConstrainedObjects)
- stringBuilder.appendLiteral("Has non-layer viewport-constrained objects, ");
+ stringBuilder.append("Has non-layer viewport-constrained objects, ");
if (reasons & ScrollingCoordinator::IsImageDocument)
- stringBuilder.appendLiteral("Is image document, ");
+ stringBuilder.append("Is image document, ");
if (stringBuilder.length())
stringBuilder.resize(stringBuilder.length() - 2);
@@ -416,29 +364,7 @@ String ScrollingCoordinator::synchronousScrollingReasonsAsText(SynchronousScroll
String ScrollingCoordinator::synchronousScrollingReasonsAsText() const
{
- if (FrameView* frameView = m_page->mainFrame().view())
- return synchronousScrollingReasonsAsText(synchronousScrollingReasons(*frameView));
-
- return String();
-}
-
-TextStream& operator<<(TextStream& ts, ScrollingNodeType nodeType)
-{
- switch (nodeType) {
- case FrameScrollingNode:
- ts << "frame-scrolling";
- break;
- case OverflowScrollingNode:
- ts << "overflow-scrolling";
- break;
- case FixedNode:
- ts << "fixed";
- break;
- case StickyNode:
- ts << "sticky";
- break;
- }
- return ts;
+ return synchronousScrollingReasonsAsText(synchronousScrollingReasons());
}
} // namespace WebCore
diff --git a/Source/WebCore/page/scrolling/ScrollingCoordinator.h b/Source/WebCore/page/scrolling/ScrollingCoordinator.h
index c91c32cd2..0e05d69fd 100644
--- a/Source/WebCore/page/scrolling/ScrollingCoordinator.h
+++ b/Source/WebCore/page/scrolling/ScrollingCoordinator.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -32,7 +32,6 @@
#include "RenderObject.h"
#include "ScrollTypes.h"
#include <wtf/Forward.h>
-#include <wtf/TypeCasts.h>
#if ENABLE(ASYNC_SCROLLING)
#include <wtf/HashMap.h>
@@ -40,20 +39,16 @@
#include <wtf/Threading.h>
#endif
-#if PLATFORM(COCOA)
+#if PLATFORM(MAC)
#include <wtf/RetainPtr.h>
#endif
-#if ENABLE(CSS_SCROLL_SNAP)
-#include "AxisScrollSnapOffsets.h"
-#endif
-
namespace WebCore {
typedef unsigned SynchronousScrollingReasons;
typedef uint64_t ScrollingNodeID;
-enum ScrollingNodeType { FrameScrollingNode, OverflowScrollingNode, FixedNode, StickyNode };
+enum ScrollingNodeType { ScrollingNode, FixedNode, StickyNode };
class Document;
class Frame;
@@ -62,7 +57,6 @@ class GraphicsLayer;
class Page;
class Region;
class ScrollableArea;
-class TextStream;
class ViewportConstraints;
#if ENABLE(ASYNC_SCROLLING)
@@ -107,140 +101,114 @@ struct ScrollableAreaParameters {
class ScrollingCoordinator : public ThreadSafeRefCounted<ScrollingCoordinator> {
public:
- static Ref<ScrollingCoordinator> create(Page*);
+ static PassRefPtr<ScrollingCoordinator> create(Page*);
virtual ~ScrollingCoordinator();
- WEBCORE_EXPORT virtual void pageDestroyed();
+ virtual void pageDestroyed();
virtual bool isAsyncScrollingCoordinator() const { return false; }
virtual bool isRemoteScrollingCoordinator() const { return false; }
// Return whether this scrolling coordinator handles scrolling for the given frame view.
- virtual bool coordinatesScrollingForFrameView(const FrameView&) const;
+ bool coordinatesScrollingForFrameView(FrameView*) const;
// Should be called whenever the given frame view has been laid out.
- virtual void frameViewLayoutUpdated(FrameView&) { }
+ virtual void frameViewLayoutUpdated(FrameView*) { }
+
+ // Should be called whenever a wheel event handler is added or removed in the
+ // frame view's underlying document.
+ void frameViewWheelEventHandlerCountChanged(FrameView*);
// Should be called whenever the slow repaint objects counter changes between zero and one.
- void frameViewHasSlowRepaintObjectsDidChange(FrameView&);
+ void frameViewHasSlowRepaintObjectsDidChange(FrameView*);
// Should be called whenever the set of fixed objects changes.
- void frameViewFixedObjectsDidChange(FrameView&);
-
- // Called whenever the non-fast scrollable region changes for reasons other than layout.
- virtual void frameViewNonFastScrollableRegionChanged(FrameView&) { }
+ void frameViewFixedObjectsDidChange(FrameView*);
// Should be called whenever the root layer for the given frame view changes.
- virtual void frameViewRootLayerDidChange(FrameView&);
+ virtual void frameViewRootLayerDidChange(FrameView*);
// Return whether this scrolling coordinator can keep fixed position layers fixed to their
// containers while scrolling.
virtual bool supportsFixedPositionLayers() const { return false; }
-#if PLATFORM(COCOA)
+#if PLATFORM(MAC)
// Dispatched by the scrolling tree during handleWheelEvent. This is required as long as scrollbars are painted on the main thread.
void handleWheelEventPhase(PlatformWheelEventPhase);
#endif
-#if ENABLE(WEB_REPLAY)
- // Called when the page transitions between executing normally and deterministically.
- void replaySessionStateDidChange();
-#endif
-
// Force all scroll layer position updates to happen on the main thread.
- WEBCORE_EXPORT void setForceSynchronousScrollLayerPositionUpdates(bool);
+ void setForceSynchronousScrollLayerPositionUpdates(bool);
// These virtual functions are currently unique to the threaded scrolling architecture.
// Their meaningful implementations are in ScrollingCoordinatorMac.
virtual void commitTreeStateIfNeeded() { }
- virtual bool requestScrollPositionUpdate(FrameView&, const IntPoint&) { return false; }
- virtual bool handleWheelEvent(FrameView&, const PlatformWheelEvent&) { return true; }
+ virtual bool requestScrollPositionUpdate(FrameView*, const IntPoint&) { return false; }
+ virtual bool handleWheelEvent(FrameView*, const PlatformWheelEvent&) { return true; }
virtual ScrollingNodeID attachToStateTree(ScrollingNodeType, ScrollingNodeID newNodeID, ScrollingNodeID /*parentID*/) { return newNodeID; }
virtual void detachFromStateTree(ScrollingNodeID) { }
virtual void clearStateTree() { }
virtual void updateViewportConstrainedNode(ScrollingNodeID, const ViewportConstraints&, GraphicsLayer*) { }
-
- struct ScrollingGeometry {
- FloatSize scrollableAreaSize;
- FloatSize contentSize;
- FloatSize reachableContentSize; // Smaller than contentSize when overflow is hidden on one axis.
- FloatPoint scrollPosition;
- IntPoint scrollOrigin;
-#if ENABLE(CSS_SCROLL_SNAP)
- Vector<LayoutUnit> horizontalSnapOffsets;
- Vector<LayoutUnit> verticalSnapOffsets;
- unsigned currentHorizontalSnapPointIndex;
- unsigned currentVerticalSnapPointIndex;
-#endif
- };
-
- virtual void updateFrameScrollingNode(ScrollingNodeID, GraphicsLayer* /*scrollLayer*/, GraphicsLayer* /*scrolledContentsLayer*/, GraphicsLayer* /*counterScrollingLayer*/, GraphicsLayer* /*insetClipLayer*/, const ScrollingGeometry* = nullptr) { }
- virtual void updateOverflowScrollingNode(ScrollingNodeID, GraphicsLayer* /*scrollLayer*/, GraphicsLayer* /*scrolledContentsLayer*/, const ScrollingGeometry* = nullptr) { }
+ virtual void updateScrollingNode(ScrollingNodeID, GraphicsLayer* /*scrollLayer*/, GraphicsLayer* /*counterScrollingLayer*/) { }
virtual void syncChildPositions(const LayoutRect&) { }
virtual String scrollingStateTreeAsText() const;
virtual bool isRubberBandInProgress() const { return false; }
- virtual bool isScrollSnapInProgress() const { return false; }
- virtual void updateScrollSnapPropertiesWithFrameView(const FrameView&) { }
virtual void setScrollPinningBehavior(ScrollPinningBehavior) { }
// Generated a unique id for scroll layers.
ScrollingNodeID uniqueScrollLayerID();
enum MainThreadScrollingReasonFlags {
- ForcedOnMainThread = 1 << 0,
- HasSlowRepaintObjects = 1 << 1,
- HasViewportConstrainedObjectsWithoutSupportingFixedLayers = 1 << 2,
- HasNonLayerViewportConstrainedObjects = 1 << 3,
- IsImageDocument = 1 << 4
+ ForcedOnMainThread = 1 << 0,
+ HasSlowRepaintObjects = 1 << 1,
+ HasViewportConstrainedObjectsWithoutSupportingFixedLayers = 1 << 2,
+ HasNonLayerViewportConstrainedObjects = 1 << 3,
+ IsImageDocument = 1 << 4
};
- SynchronousScrollingReasons synchronousScrollingReasons(const FrameView&) const;
- bool shouldUpdateScrollLayerPositionSynchronously() const;
+ SynchronousScrollingReasons synchronousScrollingReasons() const;
+ bool shouldUpdateScrollLayerPositionSynchronously() const { return synchronousScrollingReasons(); }
- virtual void willDestroyScrollableArea(ScrollableArea&) { }
- virtual void scrollableAreaScrollLayerDidChange(ScrollableArea&) { }
- virtual void scrollableAreaScrollbarLayerDidChange(ScrollableArea&, ScrollbarOrientation) { }
+ virtual void willDestroyScrollableArea(ScrollableArea*) { }
+ virtual void scrollableAreaScrollLayerDidChange(ScrollableArea*) { }
+ virtual void scrollableAreaScrollbarLayerDidChange(ScrollableArea*, ScrollbarOrientation) { }
+ virtual void setLayerIsContainerForFixedPositionLayers(GraphicsLayer*, bool) { }
static String synchronousScrollingReasonsAsText(SynchronousScrollingReasons);
String synchronousScrollingReasonsAsText() const;
- Region absoluteNonFastScrollableRegion() const;
+ Region computeNonFastScrollableRegion(const Frame*, const IntPoint& frameLocation) const;
protected:
explicit ScrollingCoordinator(Page*);
- static GraphicsLayer* scrollLayerForScrollableArea(ScrollableArea&);
-
- GraphicsLayer* scrollLayerForFrameView(FrameView&);
- GraphicsLayer* counterScrollingLayerForFrameView(FrameView&);
- GraphicsLayer* insetClipLayerForFrameView(FrameView&);
- GraphicsLayer* rootContentLayerForFrameView(FrameView&);
- GraphicsLayer* contentShadowLayerForFrameView(FrameView&);
- GraphicsLayer* headerLayerForFrameView(FrameView&);
- GraphicsLayer* footerLayerForFrameView(FrameView&);
+#if USE(ACCELERATED_COMPOSITING)
+ static GraphicsLayer* scrollLayerForScrollableArea(ScrollableArea*);
+ static GraphicsLayer* horizontalScrollbarLayerForScrollableArea(ScrollableArea*);
+ static GraphicsLayer* verticalScrollbarLayerForScrollableArea(ScrollableArea*);
+#endif
- virtual void willCommitTree() { }
+ unsigned computeCurrentWheelEventHandlerCount();
+ GraphicsLayer* scrollLayerForFrameView(FrameView*);
+ GraphicsLayer* counterScrollingLayerForFrameView(FrameView*);
+ GraphicsLayer* headerLayerForFrameView(FrameView*);
+ GraphicsLayer* footerLayerForFrameView(FrameView*);
Page* m_page; // FIXME: ideally this would be a reference but it gets nulled on async teardown.
private:
+ virtual void recomputeWheelEventHandlerCountForFrameView(FrameView*) { }
virtual void setSynchronousScrollingReasons(SynchronousScrollingReasons) { }
- virtual bool hasVisibleSlowRepaintViewportConstrainedObjects(const FrameView&) const;
- void updateSynchronousScrollingReasons(FrameView&);
-
- Region absoluteNonFastScrollableRegionForFrame(const Frame&) const;
+ virtual bool hasVisibleSlowRepaintViewportConstrainedObjects(FrameView*) const;
+ void updateSynchronousScrollingReasons();
- bool m_forceSynchronousScrollLayerPositionUpdates { false };
+ bool m_forceSynchronousScrollLayerPositionUpdates;
};
-WEBCORE_EXPORT TextStream& operator<<(TextStream&, ScrollingNodeType);
+#define SCROLLING_COORDINATOR_TYPE_CASTS(ToValueTypeName, predicate) \
+ TYPE_CASTS_BASE(ToValueTypeName, WebCore::ScrollingCoordinator, value, value->predicate, value.predicate)
} // namespace WebCore
-#define SPECIALIZE_TYPE_TRAITS_SCROLLING_COORDINATOR(ToValueTypeName, predicate) \
-SPECIALIZE_TYPE_TRAITS_BEGIN(ToValueTypeName) \
- static bool isType(const WebCore::ScrollingCoordinator& value) { return value.predicate; } \
-SPECIALIZE_TYPE_TRAITS_END()
-
#endif // ScrollingCoordinator_h
diff --git a/Source/WebCore/page/scrolling/ScrollingStateFixedNode.cpp b/Source/WebCore/page/scrolling/ScrollingStateFixedNode.cpp
index ccdc832a0..cce42eb7e 100644
--- a/Source/WebCore/page/scrolling/ScrollingStateFixedNode.cpp
+++ b/Source/WebCore/page/scrolling/ScrollingStateFixedNode.cpp
@@ -29,14 +29,15 @@
#include "GraphicsLayer.h"
#include "ScrollingStateTree.h"
#include "TextStream.h"
+#include <wtf/OwnPtr.h>
#if ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS)
namespace WebCore {
-Ref<ScrollingStateFixedNode> ScrollingStateFixedNode::create(ScrollingStateTree& stateTree, ScrollingNodeID nodeID)
+PassOwnPtr<ScrollingStateFixedNode> ScrollingStateFixedNode::create(ScrollingStateTree& stateTree, ScrollingNodeID nodeID)
{
- return adoptRef(*new ScrollingStateFixedNode(stateTree, nodeID));
+ return adoptPtr(new ScrollingStateFixedNode(stateTree, nodeID));
}
ScrollingStateFixedNode::ScrollingStateFixedNode(ScrollingStateTree& tree, ScrollingNodeID nodeID)
@@ -54,9 +55,9 @@ ScrollingStateFixedNode::~ScrollingStateFixedNode()
{
}
-Ref<ScrollingStateNode> ScrollingStateFixedNode::clone(ScrollingStateTree& adoptiveTree)
+PassOwnPtr<ScrollingStateNode> ScrollingStateFixedNode::clone(ScrollingStateTree& adoptiveTree)
{
- return adoptRef(*new ScrollingStateFixedNode(*this, adoptiveTree));
+ return adoptPtr(new ScrollingStateFixedNode(*this, adoptiveTree));
}
void ScrollingStateFixedNode::updateConstraints(const FixedPositionViewportConstraints& constraints)
diff --git a/Source/WebCore/page/scrolling/ScrollingStateFixedNode.h b/Source/WebCore/page/scrolling/ScrollingStateFixedNode.h
index 98cb0ca10..a52d7b6d0 100644
--- a/Source/WebCore/page/scrolling/ScrollingStateFixedNode.h
+++ b/Source/WebCore/page/scrolling/ScrollingStateFixedNode.h
@@ -39,9 +39,9 @@ class FixedPositionViewportConstraints;
class ScrollingStateFixedNode final : public ScrollingStateNode {
public:
- static Ref<ScrollingStateFixedNode> create(ScrollingStateTree&, ScrollingNodeID);
+ static PassOwnPtr<ScrollingStateFixedNode> create(ScrollingStateTree&, ScrollingNodeID);
- virtual Ref<ScrollingStateNode> clone(ScrollingStateTree&) override;
+ virtual PassOwnPtr<ScrollingStateNode> clone(ScrollingStateTree&);
virtual ~ScrollingStateFixedNode();
@@ -49,7 +49,7 @@ public:
ViewportConstraints = NumStateNodeBits
};
- WEBCORE_EXPORT void updateConstraints(const FixedPositionViewportConstraints&);
+ void updateConstraints(const FixedPositionViewportConstraints&);
const FixedPositionViewportConstraints& viewportConstraints() const { return m_constraints; }
private:
@@ -63,9 +63,9 @@ private:
FixedPositionViewportConstraints m_constraints;
};
-} // namespace WebCore
+SCROLLING_STATE_NODE_TYPE_CASTS(ScrollingStateFixedNode, nodeType() == FixedNode);
-SPECIALIZE_TYPE_TRAITS_SCROLLING_STATE_NODE(ScrollingStateFixedNode, isFixedNode())
+} // namespace WebCore
#endif // ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS)
diff --git a/Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.cpp b/Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.cpp
deleted file mode 100644
index 8503936a1..000000000
--- a/Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.cpp
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ScrollingStateFrameScrollingNode.h"
-
-#if ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS)
-
-#include "ScrollingStateTree.h"
-#include "TextStream.h"
-
-namespace WebCore {
-
-Ref<ScrollingStateFrameScrollingNode> ScrollingStateFrameScrollingNode::create(ScrollingStateTree& stateTree, ScrollingNodeID nodeID)
-{
- return adoptRef(*new ScrollingStateFrameScrollingNode(stateTree, nodeID));
-}
-
-ScrollingStateFrameScrollingNode::ScrollingStateFrameScrollingNode(ScrollingStateTree& stateTree, ScrollingNodeID nodeID)
- : ScrollingStateScrollingNode(stateTree, FrameScrollingNode, nodeID)
-{
-}
-
-ScrollingStateFrameScrollingNode::ScrollingStateFrameScrollingNode(const ScrollingStateFrameScrollingNode& stateNode, ScrollingStateTree& adoptiveTree)
- : ScrollingStateScrollingNode(stateNode, adoptiveTree)
-#if PLATFORM(MAC)
- , m_verticalScrollbarPainter(stateNode.verticalScrollbarPainter())
- , m_horizontalScrollbarPainter(stateNode.horizontalScrollbarPainter())
-#endif
- , m_nonFastScrollableRegion(stateNode.nonFastScrollableRegion())
- , m_requestedScrollPosition(stateNode.requestedScrollPosition())
- , m_frameScaleFactor(stateNode.frameScaleFactor())
- , m_topContentInset(stateNode.topContentInset())
- , m_headerHeight(stateNode.headerHeight())
- , m_footerHeight(stateNode.footerHeight())
- , m_synchronousScrollingReasons(stateNode.synchronousScrollingReasons())
- , m_behaviorForFixed(stateNode.scrollBehaviorForFixedElements())
- , m_requestedScrollPositionRepresentsProgrammaticScroll(stateNode.requestedScrollPositionRepresentsProgrammaticScroll())
- , m_fixedElementsLayoutRelativeToFrame(stateNode.fixedElementsLayoutRelativeToFrame())
-{
- if (hasChangedProperty(ScrolledContentsLayer))
- setScrolledContentsLayer(stateNode.scrolledContentsLayer().toRepresentation(adoptiveTree.preferredLayerRepresentation()));
-
- if (hasChangedProperty(CounterScrollingLayer))
- setCounterScrollingLayer(stateNode.counterScrollingLayer().toRepresentation(adoptiveTree.preferredLayerRepresentation()));
-
- if (hasChangedProperty(InsetClipLayer))
- setInsetClipLayer(stateNode.insetClipLayer().toRepresentation(adoptiveTree.preferredLayerRepresentation()));
-
- if (hasChangedProperty(ContentShadowLayer))
- setContentShadowLayer(stateNode.contentShadowLayer().toRepresentation(adoptiveTree.preferredLayerRepresentation()));
-
- if (hasChangedProperty(HeaderLayer))
- setHeaderLayer(stateNode.headerLayer().toRepresentation(adoptiveTree.preferredLayerRepresentation()));
-
- if (hasChangedProperty(FooterLayer))
- setFooterLayer(stateNode.footerLayer().toRepresentation(adoptiveTree.preferredLayerRepresentation()));
-}
-
-ScrollingStateFrameScrollingNode::~ScrollingStateFrameScrollingNode()
-{
-}
-
-Ref<ScrollingStateNode> ScrollingStateFrameScrollingNode::clone(ScrollingStateTree& adoptiveTree)
-{
- return adoptRef(*new ScrollingStateFrameScrollingNode(*this, adoptiveTree));
-}
-
-void ScrollingStateFrameScrollingNode::setFrameScaleFactor(float scaleFactor)
-{
- if (m_frameScaleFactor == scaleFactor)
- return;
-
- m_frameScaleFactor = scaleFactor;
-
- setPropertyChanged(FrameScaleFactor);
-}
-
-void ScrollingStateFrameScrollingNode::setNonFastScrollableRegion(const Region& nonFastScrollableRegion)
-{
- if (m_nonFastScrollableRegion == nonFastScrollableRegion)
- return;
-
- m_nonFastScrollableRegion = nonFastScrollableRegion;
- setPropertyChanged(NonFastScrollableRegion);
-}
-
-void ScrollingStateFrameScrollingNode::setSynchronousScrollingReasons(SynchronousScrollingReasons reasons)
-{
- if (m_synchronousScrollingReasons == reasons)
- return;
-
- m_synchronousScrollingReasons = reasons;
- setPropertyChanged(ReasonsForSynchronousScrolling);
-}
-
-void ScrollingStateFrameScrollingNode::setScrollBehaviorForFixedElements(ScrollBehaviorForFixedElements behaviorForFixed)
-{
- if (m_behaviorForFixed == behaviorForFixed)
- return;
-
- m_behaviorForFixed = behaviorForFixed;
- setPropertyChanged(BehaviorForFixedElements);
-}
-
-void ScrollingStateFrameScrollingNode::setHeaderHeight(int headerHeight)
-{
- if (m_headerHeight == headerHeight)
- return;
-
- m_headerHeight = headerHeight;
- setPropertyChanged(HeaderHeight);
-}
-
-void ScrollingStateFrameScrollingNode::setFooterHeight(int footerHeight)
-{
- if (m_footerHeight == footerHeight)
- return;
-
- m_footerHeight = footerHeight;
- setPropertyChanged(FooterHeight);
-}
-
-void ScrollingStateFrameScrollingNode::setTopContentInset(float topContentInset)
-{
- if (m_topContentInset == topContentInset)
- return;
-
- m_topContentInset = topContentInset;
- setPropertyChanged(TopContentInset);
-}
-
-void ScrollingStateFrameScrollingNode::setScrolledContentsLayer(const LayerRepresentation& layerRepresentation)
-{
- if (layerRepresentation == m_scrolledContentsLayer)
- return;
-
- m_scrolledContentsLayer = layerRepresentation;
- setPropertyChanged(ScrolledContentsLayer);
-}
-
-void ScrollingStateFrameScrollingNode::setCounterScrollingLayer(const LayerRepresentation& layerRepresentation)
-{
- if (layerRepresentation == m_counterScrollingLayer)
- return;
-
- m_counterScrollingLayer = layerRepresentation;
- setPropertyChanged(CounterScrollingLayer);
-}
-
-void ScrollingStateFrameScrollingNode::setInsetClipLayer(const LayerRepresentation& layerRepresentation)
-{
- if (layerRepresentation == m_insetClipLayer)
- return;
-
- m_insetClipLayer = layerRepresentation;
- setPropertyChanged(InsetClipLayer);
-}
-
-void ScrollingStateFrameScrollingNode::setContentShadowLayer(const LayerRepresentation& layerRepresentation)
-{
- if (layerRepresentation == m_contentShadowLayer)
- return;
-
- m_contentShadowLayer = layerRepresentation;
- setPropertyChanged(ContentShadowLayer);
-}
-
-void ScrollingStateFrameScrollingNode::setHeaderLayer(const LayerRepresentation& layerRepresentation)
-{
- if (layerRepresentation == m_headerLayer)
- return;
-
- m_headerLayer = layerRepresentation;
- setPropertyChanged(HeaderLayer);
-}
-
-void ScrollingStateFrameScrollingNode::setFooterLayer(const LayerRepresentation& layerRepresentation)
-{
- if (layerRepresentation == m_footerLayer)
- return;
-
- m_footerLayer = layerRepresentation;
- setPropertyChanged(FooterLayer);
-}
-
-void ScrollingStateFrameScrollingNode::setFixedElementsLayoutRelativeToFrame(bool fixedElementsLayoutRelativeToFrame)
-{
- if (fixedElementsLayoutRelativeToFrame == m_fixedElementsLayoutRelativeToFrame)
- return;
-
- m_fixedElementsLayoutRelativeToFrame = fixedElementsLayoutRelativeToFrame;
- setPropertyChanged(FixedElementsLayoutRelativeToFrame);
-}
-
-#if !PLATFORM(MAC)
-void ScrollingStateFrameScrollingNode::setScrollbarPaintersFromScrollbars(Scrollbar*, Scrollbar*)
-{
-}
-#endif
-
-void ScrollingStateFrameScrollingNode::dumpProperties(TextStream& ts, int indent) const
-{
- ts << "(Frame scrolling node" << "\n";
-
- ScrollingStateScrollingNode::dumpProperties(ts, indent);
-
- if (m_frameScaleFactor != 1) {
- writeIndent(ts, indent + 1);
- ts << "(frame scale factor " << m_frameScaleFactor << ")\n";
- }
-
- if (!m_nonFastScrollableRegion.isEmpty()) {
- ++indent;
- writeIndent(ts, indent);
- ts << "(non-fast-scrollable region";
- ++indent;
- for (auto rect : m_nonFastScrollableRegion.rects()) {
- ts << "\n";
- writeIndent(ts, indent);
- ts << rect;
- }
- ts << ")\n";
- indent -= 2;
- }
-
- if (m_synchronousScrollingReasons) {
- writeIndent(ts, indent + 1);
- ts << "(Scrolling on main thread because: " << ScrollingCoordinator::synchronousScrollingReasonsAsText(m_synchronousScrollingReasons) << ")\n";
- }
-
- // FIXME: dump more properties.
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS)
diff --git a/Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.h b/Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.h
deleted file mode 100644
index d57d1fd9f..000000000
--- a/Source/WebCore/page/scrolling/ScrollingStateFrameScrollingNode.h
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScrollingStateFrameScrollingNode_h
-#define ScrollingStateFrameScrollingNode_h
-
-#if ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS)
-
-#include "Region.h"
-#include "ScrollTypes.h"
-#include "ScrollbarThemeComposite.h"
-#include "ScrollingCoordinator.h"
-#include "ScrollingStateScrollingNode.h"
-
-namespace WebCore {
-
-class Scrollbar;
-
-class ScrollingStateFrameScrollingNode final : public ScrollingStateScrollingNode {
-public:
- static Ref<ScrollingStateFrameScrollingNode> create(ScrollingStateTree&, ScrollingNodeID);
-
- virtual Ref<ScrollingStateNode> clone(ScrollingStateTree&) override;
-
- virtual ~ScrollingStateFrameScrollingNode();
-
- enum ChangedProperty {
- FrameScaleFactor = NumScrollingStateNodeBits,
- NonFastScrollableRegion,
- ReasonsForSynchronousScrolling,
- ScrolledContentsLayer,
- CounterScrollingLayer,
- InsetClipLayer,
- ContentShadowLayer,
- HeaderHeight,
- FooterHeight,
- HeaderLayer,
- FooterLayer,
- PainterForScrollbar,
- BehaviorForFixedElements,
- TopContentInset,
- FixedElementsLayoutRelativeToFrame,
- };
-
- float frameScaleFactor() const { return m_frameScaleFactor; }
- WEBCORE_EXPORT void setFrameScaleFactor(float);
-
- const Region& nonFastScrollableRegion() const { return m_nonFastScrollableRegion; }
- WEBCORE_EXPORT void setNonFastScrollableRegion(const Region&);
-
- SynchronousScrollingReasons synchronousScrollingReasons() const { return m_synchronousScrollingReasons; }
- WEBCORE_EXPORT void setSynchronousScrollingReasons(SynchronousScrollingReasons);
-
- ScrollBehaviorForFixedElements scrollBehaviorForFixedElements() const { return m_behaviorForFixed; }
- WEBCORE_EXPORT void setScrollBehaviorForFixedElements(ScrollBehaviorForFixedElements);
-
- int headerHeight() const { return m_headerHeight; }
- WEBCORE_EXPORT void setHeaderHeight(int);
-
- int footerHeight() const { return m_footerHeight; }
- WEBCORE_EXPORT void setFooterHeight(int);
-
- float topContentInset() const { return m_topContentInset; }
- WEBCORE_EXPORT void setTopContentInset(float);
-
- const LayerRepresentation& scrolledContentsLayer() const { return m_scrolledContentsLayer; }
- WEBCORE_EXPORT void setScrolledContentsLayer(const LayerRepresentation&);
-
- // This is a layer moved in the opposite direction to scrolling, for example for background-attachment:fixed
- const LayerRepresentation& counterScrollingLayer() const { return m_counterScrollingLayer; }
- WEBCORE_EXPORT void setCounterScrollingLayer(const LayerRepresentation&);
-
- // This is a clipping layer that will scroll with the page for all y-delta scroll values between 0
- // and topContentInset(). Once the y-deltas get beyond the content inset point, this layer no longer
- // needs to move. If the topContentInset() is 0, this layer does not need to move at all. This is
- // only used on the Mac.
- const LayerRepresentation& insetClipLayer() const { return m_insetClipLayer; }
- WEBCORE_EXPORT void setInsetClipLayer(const LayerRepresentation&);
-
- const LayerRepresentation& contentShadowLayer() const { return m_contentShadowLayer; }
- WEBCORE_EXPORT void setContentShadowLayer(const LayerRepresentation&);
-
- // The header and footer layers scroll vertically with the page, they should remain fixed when scrolling horizontally.
- const LayerRepresentation& headerLayer() const { return m_headerLayer; }
- WEBCORE_EXPORT void setHeaderLayer(const LayerRepresentation&);
-
- // The header and footer layers scroll vertically with the page, they should remain fixed when scrolling horizontally.
- const LayerRepresentation& footerLayer() const { return m_footerLayer; }
- WEBCORE_EXPORT void setFooterLayer(const LayerRepresentation&);
-
- bool fixedElementsLayoutRelativeToFrame() const { return m_fixedElementsLayoutRelativeToFrame; }
- WEBCORE_EXPORT void setFixedElementsLayoutRelativeToFrame(bool);
-
-#if PLATFORM(MAC)
- ScrollbarPainter verticalScrollbarPainter() const { return m_verticalScrollbarPainter.get(); }
- ScrollbarPainter horizontalScrollbarPainter() const { return m_horizontalScrollbarPainter.get(); }
-#endif
- void setScrollbarPaintersFromScrollbars(Scrollbar* verticalScrollbar, Scrollbar* horizontalScrollbar);
-
- virtual void dumpProperties(TextStream&, int indent) const override;
-
-private:
- ScrollingStateFrameScrollingNode(ScrollingStateTree&, ScrollingNodeID);
- ScrollingStateFrameScrollingNode(const ScrollingStateFrameScrollingNode&, ScrollingStateTree&);
-
- LayerRepresentation m_counterScrollingLayer;
- LayerRepresentation m_insetClipLayer;
- LayerRepresentation m_scrolledContentsLayer;
- LayerRepresentation m_contentShadowLayer;
- LayerRepresentation m_headerLayer;
- LayerRepresentation m_footerLayer;
-
-#if PLATFORM(MAC)
- RetainPtr<ScrollbarPainter> m_verticalScrollbarPainter;
- RetainPtr<ScrollbarPainter> m_horizontalScrollbarPainter;
-#endif
-
- Region m_nonFastScrollableRegion;
- FloatPoint m_requestedScrollPosition;
- float m_frameScaleFactor { 1 };
- float m_topContentInset { 0 };
- int m_headerHeight { 0 };
- int m_footerHeight { 0 };
- SynchronousScrollingReasons m_synchronousScrollingReasons { 0 };
- ScrollBehaviorForFixedElements m_behaviorForFixed { StickToDocumentBounds };
- bool m_requestedScrollPositionRepresentsProgrammaticScroll { false };
- bool m_fixedElementsLayoutRelativeToFrame { false };
-};
-
-} // namespace WebCore
-
-SPECIALIZE_TYPE_TRAITS_SCROLLING_STATE_NODE(ScrollingStateFrameScrollingNode, isFrameScrollingNode())
-
-#endif // ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS)
-
-#endif // ScrollingStateFrameScrollingNode_h
diff --git a/Source/WebCore/page/scrolling/ScrollingStateNode.cpp b/Source/WebCore/page/scrolling/ScrollingStateNode.cpp
index d3e4f76fc..0b60c5acb 100644
--- a/Source/WebCore/page/scrolling/ScrollingStateNode.cpp
+++ b/Source/WebCore/page/scrolling/ScrollingStateNode.cpp
@@ -41,7 +41,7 @@ ScrollingStateNode::ScrollingStateNode(ScrollingNodeType nodeType, ScrollingStat
, m_nodeID(nodeID)
, m_changedProperties(0)
, m_scrollingStateTree(scrollingStateTree)
- , m_parent(nullptr)
+ , m_parent(0)
{
}
@@ -52,7 +52,7 @@ ScrollingStateNode::ScrollingStateNode(const ScrollingStateNode& stateNode, Scro
, m_nodeID(stateNode.scrollingNodeID())
, m_changedProperties(stateNode.changedProperties())
, m_scrollingStateTree(adoptiveTree)
- , m_parent(nullptr)
+ , m_parent(0)
{
if (hasChangedProperty(ScrollLayer))
setLayer(stateNode.layer().toRepresentation(adoptiveTree.preferredLayerRepresentation()));
@@ -72,9 +72,9 @@ void ScrollingStateNode::setPropertyChanged(unsigned propertyBit)
m_scrollingStateTree.setHasChangedProperties();
}
-PassRefPtr<ScrollingStateNode> ScrollingStateNode::cloneAndReset(ScrollingStateTree& adoptiveTree)
+PassOwnPtr<ScrollingStateNode> ScrollingStateNode::cloneAndReset(ScrollingStateTree& adoptiveTree)
{
- RefPtr<ScrollingStateNode> clone = this->clone(adoptiveTree);
+ OwnPtr<ScrollingStateNode> clone = this->clone(adoptiveTree);
// Now that this node is cloned, reset our change properties.
resetChangedProperties();
@@ -88,20 +88,53 @@ void ScrollingStateNode::cloneAndResetChildren(ScrollingStateNode& clone, Scroll
if (!m_children)
return;
- for (auto& child : *m_children)
- clone.appendChild(child->cloneAndReset(adoptiveTree));
+ size_t size = m_children->size();
+ for (size_t i = 0; i < size; ++i)
+ clone.appendChild(m_children->at(i)->cloneAndReset(adoptiveTree));
}
-void ScrollingStateNode::appendChild(PassRefPtr<ScrollingStateNode> childNode)
+void ScrollingStateNode::appendChild(PassOwnPtr<ScrollingStateNode> childNode)
{
childNode->setParent(this);
if (!m_children)
- m_children = std::make_unique<Vector<RefPtr<ScrollingStateNode>>>();
+ m_children = adoptPtr(new Vector<OwnPtr<ScrollingStateNode>>);
m_children->append(childNode);
}
+void ScrollingStateNode::removeChild(ScrollingStateNode* node)
+{
+ if (!m_children)
+ return;
+
+ size_t index = m_children->find(node);
+
+ // The index will be notFound if the node to remove is a deeper-than-1-level descendant or
+ // if node is the root state node.
+ if (index != notFound) {
+ node->willBeRemovedFromStateTree();
+ m_children->remove(index);
+ return;
+ }
+
+ size_t size = m_children->size();
+ for (size_t i = 0; i < size; ++i)
+ m_children->at(i)->removeChild(node);
+}
+
+void ScrollingStateNode::willBeRemovedFromStateTree()
+{
+ scrollingStateTree().didRemoveNode(scrollingNodeID());
+
+ if (!m_children)
+ return;
+
+ size_t size = m_children->size();
+ for (size_t i = 0; i < size; ++i)
+ m_children->at(i)->willBeRemovedFromStateTree();
+}
+
void ScrollingStateNode::setLayer(const LayerRepresentation& layerRepresentation)
{
if (layerRepresentation == m_layer)
@@ -119,10 +152,11 @@ void ScrollingStateNode::dump(TextStream& ts, int indent) const
if (m_children) {
writeIndent(ts, indent + 1);
- ts << "(children " << children()->size() << "\n";
+ size_t size = children()->size();
+ ts << "(children " << size << "\n";
- for (auto& child : *m_children)
- child->dump(ts, indent + 2);
+ for (size_t i = 0; i < size; i++)
+ m_children->at(i)->dump(ts, indent + 2);
writeIndent(ts, indent + 1);
ts << ")\n";
}
diff --git a/Source/WebCore/page/scrolling/ScrollingStateNode.h b/Source/WebCore/page/scrolling/ScrollingStateNode.h
index acb601c9e..ca705f3e2 100644
--- a/Source/WebCore/page/scrolling/ScrollingStateNode.h
+++ b/Source/WebCore/page/scrolling/ScrollingStateNode.h
@@ -30,10 +30,14 @@
#include "GraphicsLayer.h"
#include "ScrollingCoordinator.h"
-#include <wtf/RefCounted.h>
-#include <wtf/TypeCasts.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
#include <wtf/Vector.h>
+#if PLATFORM(MAC)
+#include <wtf/RetainPtr.h>
+#endif
+
namespace WebCore {
class GraphicsLayer;
@@ -71,32 +75,14 @@ public:
: m_platformLayer(platformLayer)
, m_layerID(0)
, m_representation(PlatformLayerRepresentation)
- {
- retainPlatformLayer(platformLayer);
- }
+ { }
LayerRepresentation(GraphicsLayer::PlatformLayerID layerID)
: m_graphicsLayer(nullptr)
, m_layerID(layerID)
, m_representation(PlatformLayerIDRepresentation)
- {
- }
-
- LayerRepresentation(const LayerRepresentation& other)
- : m_platformLayer(other.m_platformLayer)
- , m_layerID(other.m_layerID)
- , m_representation(other.m_representation)
- {
- if (m_representation == PlatformLayerRepresentation)
- retainPlatformLayer(m_platformLayer);
- }
-
- ~LayerRepresentation()
- {
- if (m_representation == PlatformLayerRepresentation)
- releasePlatformLayer(m_platformLayer);
- }
-
+ { }
+
operator GraphicsLayer*() const
{
ASSERT(m_representation == GraphicsLayerRepresentation);
@@ -108,31 +94,14 @@ public:
ASSERT(m_representation == PlatformLayerRepresentation);
return m_platformLayer;
}
-
- GraphicsLayer::PlatformLayerID layerID() const
- {
- return m_layerID;
- }
operator GraphicsLayer::PlatformLayerID() const
{
ASSERT(m_representation != PlatformLayerRepresentation);
return m_layerID;
}
-
- LayerRepresentation& operator=(const LayerRepresentation& other)
- {
- m_platformLayer = other.m_platformLayer;
- m_layerID = other.m_layerID;
- m_representation = other.m_representation;
-
- if (m_representation == PlatformLayerRepresentation)
- retainPlatformLayer(m_platformLayer);
-
- return *this;
- }
-
- bool operator==(const LayerRepresentation& other) const
+
+ bool operator ==(const LayerRepresentation& other) const
{
if (m_representation != other.m_representation)
return false;
@@ -171,9 +140,6 @@ public:
bool representsPlatformLayerID() const { return m_representation == PlatformLayerIDRepresentation; }
private:
- WEBCORE_EXPORT void retainPlatformLayer(PlatformLayer*);
- WEBCORE_EXPORT void releasePlatformLayer(PlatformLayer*);
-
union {
GraphicsLayer* m_graphicsLayer;
PlatformLayer *m_platformLayer;
@@ -183,22 +149,15 @@ private:
Type m_representation;
};
-class ScrollingStateNode : public RefCounted<ScrollingStateNode> {
- WTF_MAKE_FAST_ALLOCATED;
+class ScrollingStateNode {
public:
ScrollingStateNode(ScrollingNodeType, ScrollingStateTree&, ScrollingNodeID);
virtual ~ScrollingStateNode();
ScrollingNodeType nodeType() const { return m_nodeType; }
- bool isFixedNode() const { return m_nodeType == FixedNode; }
- bool isStickyNode() const { return m_nodeType == StickyNode; }
- bool isScrollingNode() const { return m_nodeType == FrameScrollingNode || m_nodeType == OverflowScrollingNode; }
- bool isFrameScrollingNode() const { return m_nodeType == FrameScrollingNode; }
- bool isOverflowScrollingNode() const { return m_nodeType == OverflowScrollingNode; }
-
- virtual Ref<ScrollingStateNode> clone(ScrollingStateTree& adoptiveTree) = 0;
- PassRefPtr<ScrollingStateNode> cloneAndReset(ScrollingStateTree& adoptiveTree);
+ virtual PassOwnPtr<ScrollingStateNode> clone(ScrollingStateTree& adoptiveTree) = 0;
+ PassOwnPtr<ScrollingStateNode> cloneAndReset(ScrollingStateTree& adoptiveTree);
void cloneAndResetChildren(ScrollingStateNode&, ScrollingStateTree& adoptiveTree);
enum {
@@ -218,7 +177,7 @@ public:
virtual void syncLayerPositionForViewportRect(const LayoutRect& /*viewportRect*/) { }
const LayerRepresentation& layer() const { return m_layer; }
- WEBCORE_EXPORT void setLayer(const LayerRepresentation&);
+ void setLayer(const LayerRepresentation&);
ScrollingStateTree& scrollingStateTree() const { return m_scrollingStateTree; }
@@ -228,9 +187,10 @@ public:
void setParent(ScrollingStateNode* parent) { m_parent = parent; }
ScrollingNodeID parentNodeID() const { return m_parent ? m_parent->scrollingNodeID() : 0; }
- Vector<RefPtr<ScrollingStateNode>>* children() const { return m_children.get(); }
+ Vector<OwnPtr<ScrollingStateNode>>* children() const { return m_children.get(); }
- void appendChild(PassRefPtr<ScrollingStateNode>);
+ void appendChild(PassOwnPtr<ScrollingStateNode>);
+ void removeChild(ScrollingStateNode*);
String scrollingStateTreeAsText() const;
@@ -241,6 +201,7 @@ private:
void dump(TextStream&, int indent) const;
virtual void dumpProperties(TextStream&, int indent) const = 0;
+ void willBeRemovedFromStateTree();
const ScrollingNodeType m_nodeType;
ScrollingNodeID m_nodeID;
@@ -249,17 +210,15 @@ private:
ScrollingStateTree& m_scrollingStateTree;
ScrollingStateNode* m_parent;
- std::unique_ptr<Vector<RefPtr<ScrollingStateNode>>> m_children;
+ OwnPtr<Vector<OwnPtr<ScrollingStateNode>>> m_children;
LayerRepresentation m_layer;
};
-} // namespace WebCore
+#define SCROLLING_STATE_NODE_TYPE_CASTS(ToValueTypeName, predicate) \
+ TYPE_CASTS_BASE(ToValueTypeName, ScrollingStateNode, value, value->predicate, value.predicate)
-#define SPECIALIZE_TYPE_TRAITS_SCROLLING_STATE_NODE(ToValueTypeName, predicate) \
-SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToValueTypeName) \
- static bool isType(const WebCore::ScrollingStateNode& node) { return node.predicate; } \
-SPECIALIZE_TYPE_TRAITS_END()
+} // namespace WebCore
#endif // ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS)
diff --git a/Source/WebCore/page/scrolling/ScrollingStateOverflowScrollingNode.cpp b/Source/WebCore/page/scrolling/ScrollingStateOverflowScrollingNode.cpp
deleted file mode 100644
index 84d25ef0b..000000000
--- a/Source/WebCore/page/scrolling/ScrollingStateOverflowScrollingNode.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ScrollingStateOverflowScrollingNode.h"
-
-#if ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS)
-
-#include "ScrollingStateTree.h"
-#include "TextStream.h"
-
-namespace WebCore {
-
-Ref<ScrollingStateOverflowScrollingNode> ScrollingStateOverflowScrollingNode::create(ScrollingStateTree& stateTree, ScrollingNodeID nodeID)
-{
- return adoptRef(*new ScrollingStateOverflowScrollingNode(stateTree, nodeID));
-}
-
-ScrollingStateOverflowScrollingNode::ScrollingStateOverflowScrollingNode(ScrollingStateTree& stateTree, ScrollingNodeID nodeID)
- : ScrollingStateScrollingNode(stateTree, OverflowScrollingNode, nodeID)
-{
-}
-
-ScrollingStateOverflowScrollingNode::ScrollingStateOverflowScrollingNode(const ScrollingStateOverflowScrollingNode& stateNode, ScrollingStateTree& adoptiveTree)
- : ScrollingStateScrollingNode(stateNode, adoptiveTree)
-{
- if (hasChangedProperty(ScrolledContentsLayer))
- setScrolledContentsLayer(stateNode.scrolledContentsLayer().toRepresentation(adoptiveTree.preferredLayerRepresentation()));
-}
-
-ScrollingStateOverflowScrollingNode::~ScrollingStateOverflowScrollingNode()
-{
-}
-
-Ref<ScrollingStateNode> ScrollingStateOverflowScrollingNode::clone(ScrollingStateTree& adoptiveTree)
-{
- return adoptRef(*new ScrollingStateOverflowScrollingNode(*this, adoptiveTree));
-}
-
-void ScrollingStateOverflowScrollingNode::setScrolledContentsLayer(const LayerRepresentation& layerRepresentation)
-{
- if (layerRepresentation == m_scrolledContentsLayer)
- return;
-
- m_scrolledContentsLayer = layerRepresentation;
- setPropertyChanged(ScrolledContentsLayer);
-}
-
-void ScrollingStateOverflowScrollingNode::dumpProperties(TextStream& ts, int indent) const
-{
- ts << "(" << "Overflow scrolling node" << "\n";
-
- ScrollingStateScrollingNode::dumpProperties(ts, indent);
-
- if (m_scrolledContentsLayer.layerID()) {
- writeIndent(ts, indent + 1);
- ts << "(scrolled contents layer " << m_scrolledContentsLayer.layerID() << ")\n";
- }
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS)
diff --git a/Source/WebCore/page/scrolling/ScrollingStateOverflowScrollingNode.h b/Source/WebCore/page/scrolling/ScrollingStateOverflowScrollingNode.h
deleted file mode 100644
index 73aaa3952..000000000
--- a/Source/WebCore/page/scrolling/ScrollingStateOverflowScrollingNode.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScrollingStateOverflowScrollingNode_h
-#define ScrollingStateOverflowScrollingNode_h
-
-#if ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS)
-
-#include "ScrollingStateScrollingNode.h"
-
-namespace WebCore {
-
-class ScrollingStateOverflowScrollingNode : public ScrollingStateScrollingNode {
-public:
- static Ref<ScrollingStateOverflowScrollingNode> create(ScrollingStateTree&, ScrollingNodeID);
-
- virtual Ref<ScrollingStateNode> clone(ScrollingStateTree&) override;
-
- virtual ~ScrollingStateOverflowScrollingNode();
-
- enum ChangedProperty {
- ScrolledContentsLayer = NumScrollingStateNodeBits
- };
-
- // This is a layer with the contents that move.
- const LayerRepresentation& scrolledContentsLayer() const { return m_scrolledContentsLayer; }
- WEBCORE_EXPORT void setScrolledContentsLayer(const LayerRepresentation&);
-
- virtual void dumpProperties(TextStream&, int indent) const override;
-
-private:
- ScrollingStateOverflowScrollingNode(ScrollingStateTree&, ScrollingNodeID);
- ScrollingStateOverflowScrollingNode(const ScrollingStateOverflowScrollingNode&, ScrollingStateTree&);
-
- LayerRepresentation m_scrolledContentsLayer;
-};
-
-} // namespace WebCore
-
-SPECIALIZE_TYPE_TRAITS_SCROLLING_STATE_NODE(ScrollingStateOverflowScrollingNode, isOverflowScrollingNode())
-
-#endif // ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS)
-
-#endif // ScrollingStateScrollingNode_h
diff --git a/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp b/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp
index c53b9b5ec..8ef8ff6a5 100644
--- a/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp
+++ b/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,46 +30,80 @@
#include "ScrollingStateTree.h"
#include "TextStream.h"
+#include <wtf/OwnPtr.h>
namespace WebCore {
-ScrollingStateScrollingNode::ScrollingStateScrollingNode(ScrollingStateTree& stateTree, ScrollingNodeType nodeType, ScrollingNodeID nodeID)
- : ScrollingStateNode(nodeType, stateTree, nodeID)
+PassOwnPtr<ScrollingStateScrollingNode> ScrollingStateScrollingNode::create(ScrollingStateTree& stateTree, ScrollingNodeID nodeID)
+{
+ return adoptPtr(new ScrollingStateScrollingNode(stateTree, nodeID));
+}
+
+ScrollingStateScrollingNode::ScrollingStateScrollingNode(ScrollingStateTree& stateTree, ScrollingNodeID nodeID)
+ : ScrollingStateNode(ScrollingNode, stateTree, nodeID)
+#if PLATFORM(MAC) && !PLATFORM(IOS)
+ , m_verticalScrollbarPainter(0)
+ , m_horizontalScrollbarPainter(0)
+#endif
+ , m_frameScaleFactor(1)
+ , m_wheelEventHandlerCount(0)
+ , m_synchronousScrollingReasons(0)
+ , m_behaviorForFixed(StickToDocumentBounds)
+ , m_headerHeight(0)
+ , m_footerHeight(0)
+ , m_requestedScrollPositionRepresentsProgrammaticScroll(false)
{
}
ScrollingStateScrollingNode::ScrollingStateScrollingNode(const ScrollingStateScrollingNode& stateNode, ScrollingStateTree& adoptiveTree)
: ScrollingStateNode(stateNode, adoptiveTree)
- , m_scrollableAreaSize(stateNode.scrollableAreaSize())
+#if PLATFORM(MAC) && !PLATFORM(IOS)
+ , m_verticalScrollbarPainter(stateNode.verticalScrollbarPainter())
+ , m_horizontalScrollbarPainter(stateNode.horizontalScrollbarPainter())
+#endif
+ , m_viewportRect(stateNode.viewportRect())
, m_totalContentsSize(stateNode.totalContentsSize())
- , m_reachableContentsSize(stateNode.reachableContentsSize())
- , m_scrollPosition(stateNode.scrollPosition())
- , m_requestedScrollPosition(stateNode.requestedScrollPosition())
, m_scrollOrigin(stateNode.scrollOrigin())
-#if ENABLE(CSS_SCROLL_SNAP)
- , m_horizontalSnapOffsets(stateNode.horizontalSnapOffsets())
- , m_verticalSnapOffsets(stateNode.verticalSnapOffsets())
-#endif
, m_scrollableAreaParameters(stateNode.scrollableAreaParameters())
+ , m_nonFastScrollableRegion(stateNode.nonFastScrollableRegion())
+ , m_frameScaleFactor(stateNode.frameScaleFactor())
+ , m_wheelEventHandlerCount(stateNode.wheelEventHandlerCount())
+ , m_synchronousScrollingReasons(stateNode.synchronousScrollingReasons())
+ , m_behaviorForFixed(stateNode.scrollBehaviorForFixedElements())
+ , m_headerHeight(stateNode.headerHeight())
+ , m_footerHeight(stateNode.footerHeight())
+ , m_requestedScrollPosition(stateNode.requestedScrollPosition())
, m_requestedScrollPositionRepresentsProgrammaticScroll(stateNode.requestedScrollPositionRepresentsProgrammaticScroll())
- , m_expectsWheelEventTestTrigger(stateNode.expectsWheelEventTestTrigger())
{
+ if (hasChangedProperty(CounterScrollingLayer))
+ setCounterScrollingLayer(stateNode.counterScrollingLayer().toRepresentation(adoptiveTree.preferredLayerRepresentation()));
+
+ if (hasChangedProperty(HeaderLayer))
+ setHeaderLayer(stateNode.headerLayer().toRepresentation(adoptiveTree.preferredLayerRepresentation()));
+
+ if (hasChangedProperty(FooterLayer))
+ setFooterLayer(stateNode.footerLayer().toRepresentation(adoptiveTree.preferredLayerRepresentation()));
}
ScrollingStateScrollingNode::~ScrollingStateScrollingNode()
{
}
-void ScrollingStateScrollingNode::setScrollableAreaSize(const FloatSize& size)
+PassOwnPtr<ScrollingStateNode> ScrollingStateScrollingNode::clone(ScrollingStateTree& adoptiveTree)
{
- if (m_scrollableAreaSize == size)
+ return adoptPtr(new ScrollingStateScrollingNode(*this, adoptiveTree));
+}
+
+void ScrollingStateScrollingNode::setViewportRect(const IntRect& viewportRect)
+{
+ if (m_viewportRect == viewportRect)
return;
- m_scrollableAreaSize = size;
- setPropertyChanged(ScrollableAreaSize);
+ m_viewportRect = viewportRect;
+ setPropertyChanged(ViewportRect);
}
-void ScrollingStateScrollingNode::setTotalContentsSize(const FloatSize& totalContentsSize)
+void ScrollingStateScrollingNode::setTotalContentsSize(const IntSize& totalContentsSize)
{
if (m_totalContentsSize == totalContentsSize)
return;
@@ -78,124 +112,159 @@ void ScrollingStateScrollingNode::setTotalContentsSize(const FloatSize& totalCon
setPropertyChanged(TotalContentsSize);
}
-void ScrollingStateScrollingNode::setReachableContentsSize(const FloatSize& reachableContentsSize)
+void ScrollingStateScrollingNode::setScrollOrigin(const IntPoint& scrollOrigin)
{
- if (m_reachableContentsSize == reachableContentsSize)
+ if (m_scrollOrigin == scrollOrigin)
return;
- m_reachableContentsSize = reachableContentsSize;
- setPropertyChanged(ReachableContentsSize);
+ m_scrollOrigin = scrollOrigin;
+ setPropertyChanged(ScrollOrigin);
}
-void ScrollingStateScrollingNode::setScrollPosition(const FloatPoint& scrollPosition)
+void ScrollingStateScrollingNode::setScrollableAreaParameters(const ScrollableAreaParameters& parameters)
{
- if (m_scrollPosition == scrollPosition)
+ if (m_scrollableAreaParameters == parameters)
return;
- m_scrollPosition = scrollPosition;
- setPropertyChanged(ScrollPosition);
+ m_scrollableAreaParameters = parameters;
+ setPropertyChanged(ScrollableAreaParams);
}
-void ScrollingStateScrollingNode::setScrollOrigin(const IntPoint& scrollOrigin)
+void ScrollingStateScrollingNode::setFrameScaleFactor(float scaleFactor)
{
- if (m_scrollOrigin == scrollOrigin)
+ if (m_frameScaleFactor == scaleFactor)
return;
- m_scrollOrigin = scrollOrigin;
- setPropertyChanged(ScrollOrigin);
+ m_frameScaleFactor = scaleFactor;
+
+ setPropertyChanged(FrameScaleFactor);
}
-#if ENABLE(CSS_SCROLL_SNAP)
-void ScrollingStateScrollingNode::setHorizontalSnapOffsets(const Vector<float>& snapOffsets)
+void ScrollingStateScrollingNode::setNonFastScrollableRegion(const Region& nonFastScrollableRegion)
{
- if (m_horizontalSnapOffsets == snapOffsets)
+ if (m_nonFastScrollableRegion == nonFastScrollableRegion)
return;
- m_horizontalSnapOffsets = snapOffsets;
- setPropertyChanged(HorizontalSnapOffsets);
+ m_nonFastScrollableRegion = nonFastScrollableRegion;
+ setPropertyChanged(NonFastScrollableRegion);
}
-void ScrollingStateScrollingNode::setVerticalSnapOffsets(const Vector<float>& snapOffsets)
+void ScrollingStateScrollingNode::setWheelEventHandlerCount(unsigned wheelEventHandlerCount)
{
- if (m_verticalSnapOffsets == snapOffsets)
+ if (m_wheelEventHandlerCount == wheelEventHandlerCount)
return;
- m_verticalSnapOffsets = snapOffsets;
- setPropertyChanged(VerticalSnapOffsets);
+ m_wheelEventHandlerCount = wheelEventHandlerCount;
+ setPropertyChanged(WheelEventHandlerCount);
}
-void ScrollingStateScrollingNode::setCurrentHorizontalSnapPointIndex(unsigned index)
+void ScrollingStateScrollingNode::setSynchronousScrollingReasons(SynchronousScrollingReasons reasons)
{
- if (m_currentHorizontalSnapPointIndex == index)
+ if (m_synchronousScrollingReasons == reasons)
return;
-
- m_currentHorizontalSnapPointIndex = index;
- setPropertyChanged(CurrentHorizontalSnapOffsetIndex);
-}
-void ScrollingStateScrollingNode::setCurrentVerticalSnapPointIndex(unsigned index)
-{
- if (m_currentVerticalSnapPointIndex == index)
- return;
-
- m_currentVerticalSnapPointIndex = index;
- setPropertyChanged(CurrentVerticalSnapOffsetIndex);
+ m_synchronousScrollingReasons = reasons;
+ setPropertyChanged(ReasonsForSynchronousScrolling);
}
-#endif
-void ScrollingStateScrollingNode::setScrollableAreaParameters(const ScrollableAreaParameters& parameters)
+void ScrollingStateScrollingNode::setScrollBehaviorForFixedElements(ScrollBehaviorForFixedElements behaviorForFixed)
{
- if (m_scrollableAreaParameters == parameters)
+ if (m_behaviorForFixed == behaviorForFixed)
return;
- m_scrollableAreaParameters = parameters;
- setPropertyChanged(ScrollableAreaParams);
+ m_behaviorForFixed = behaviorForFixed;
+ setPropertyChanged(BehaviorForFixedElements);
}
-void ScrollingStateScrollingNode::setRequestedScrollPosition(const FloatPoint& requestedScrollPosition, bool representsProgrammaticScroll)
+void ScrollingStateScrollingNode::setRequestedScrollPosition(const IntPoint& requestedScrollPosition, bool representsProgrammaticScroll)
{
m_requestedScrollPosition = requestedScrollPosition;
m_requestedScrollPositionRepresentsProgrammaticScroll = representsProgrammaticScroll;
setPropertyChanged(RequestedScrollPosition);
}
-void ScrollingStateScrollingNode::setExpectsWheelEventTestTrigger(bool expectsTestTrigger)
+void ScrollingStateScrollingNode::setHeaderHeight(int headerHeight)
+{
+ if (m_headerHeight == headerHeight)
+ return;
+
+ m_headerHeight = headerHeight;
+ setPropertyChanged(HeaderHeight);
+}
+
+void ScrollingStateScrollingNode::setFooterHeight(int footerHeight)
+{
+ if (m_footerHeight == footerHeight)
+ return;
+
+ m_footerHeight = footerHeight;
+ setPropertyChanged(FooterHeight);
+}
+
+void ScrollingStateScrollingNode::setCounterScrollingLayer(const LayerRepresentation& layerRepresentation)
{
- if (expectsTestTrigger == m_expectsWheelEventTestTrigger)
+ if (layerRepresentation == m_counterScrollingLayer)
return;
+
+ m_counterScrollingLayer = layerRepresentation;
+
+ setPropertyChanged(CounterScrollingLayer);
+}
+
+void ScrollingStateScrollingNode::setHeaderLayer(const LayerRepresentation& layerRepresentation)
+{
+ if (layerRepresentation == m_headerLayer)
+ return;
+
+ m_headerLayer = layerRepresentation;
- m_expectsWheelEventTestTrigger = expectsTestTrigger;
- setPropertyChanged(ExpectsWheelEventTestTrigger);
+ setPropertyChanged(HeaderLayer);
}
+
+void ScrollingStateScrollingNode::setFooterLayer(const LayerRepresentation& layerRepresentation)
+{
+ if (layerRepresentation == m_footerLayer)
+ return;
+
+ m_footerLayer = layerRepresentation;
+
+ setPropertyChanged(FooterLayer);
+}
+
+#if !(PLATFORM(MAC) && !PLATFORM(IOS))
+void ScrollingStateScrollingNode::setScrollbarPaintersFromScrollbars(Scrollbar*, Scrollbar*)
+{
+}
+#endif
+
void ScrollingStateScrollingNode::dumpProperties(TextStream& ts, int indent) const
{
- if (m_scrollPosition != FloatPoint()) {
+ ts << "(" << "Scrolling node" << "\n";
+
+ if (!m_viewportRect.isEmpty()) {
+ writeIndent(ts, indent + 1);
+ ts << "(viewport rect " << m_viewportRect.x() << " " << m_viewportRect.y() << " " << m_viewportRect.width() << " " << m_viewportRect.height() << ")\n";
+ }
+
+ if (!m_totalContentsSize.isEmpty()) {
writeIndent(ts, indent + 1);
- ts << "(scroll position "
- << TextStream::FormatNumberRespectingIntegers(m_scrollPosition.x()) << " "
- << TextStream::FormatNumberRespectingIntegers(m_scrollPosition.y()) << ")\n";
+ ts << "(contents size " << m_totalContentsSize.width() << " " << m_totalContentsSize.height() << ")\n";
}
- if (!m_scrollableAreaSize.isEmpty()) {
+ if (m_frameScaleFactor != 1) {
writeIndent(ts, indent + 1);
- ts << "(scrollable area size "
- << TextStream::FormatNumberRespectingIntegers(m_scrollableAreaSize.width()) << " "
- << TextStream::FormatNumberRespectingIntegers(m_scrollableAreaSize.height()) << ")\n";
+ ts << "(frame scale factor " << m_frameScaleFactor << ")\n";
}
- if (!m_totalContentsSize.isEmpty()) {
+ if (m_synchronousScrollingReasons) {
writeIndent(ts, indent + 1);
- ts << "(contents size "
- << TextStream::FormatNumberRespectingIntegers(m_totalContentsSize.width()) << " "
- << TextStream::FormatNumberRespectingIntegers(m_totalContentsSize.height()) << ")\n";
+ ts << "(Scrolling on main thread because: " << ScrollingCoordinator::synchronousScrollingReasonsAsText(m_synchronousScrollingReasons) << ")\n";
}
if (m_requestedScrollPosition != IntPoint()) {
writeIndent(ts, indent + 1);
- ts << "(requested scroll position "
- << TextStream::FormatNumberRespectingIntegers(m_requestedScrollPosition.x()) << " "
- << TextStream::FormatNumberRespectingIntegers(m_requestedScrollPosition.y()) << ")\n";
+ ts << "(requested scroll position " << m_requestedScrollPosition.x() << " " << m_requestedScrollPosition.y() << ")\n";
}
if (m_scrollOrigin != IntPoint()) {
diff --git a/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h b/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h
index 091efd1fa..14be04b97 100644
--- a/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h
+++ b/Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012, 2014-2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -28,100 +28,136 @@
#if ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS)
+#include "GraphicsLayer.h"
+#include "IntRect.h"
+#include "Region.h"
#include "ScrollTypes.h"
+#include "ScrollbarThemeComposite.h"
#include "ScrollingCoordinator.h"
#include "ScrollingStateNode.h"
+#include <wtf/PassOwnPtr.h>
namespace WebCore {
-class ScrollingStateScrollingNode : public ScrollingStateNode {
+class Scrollbar;
+
+class ScrollingStateScrollingNode final : public ScrollingStateNode {
public:
+ static PassOwnPtr<ScrollingStateScrollingNode> create(ScrollingStateTree&, ScrollingNodeID);
+
+ virtual PassOwnPtr<ScrollingStateNode> clone(ScrollingStateTree&);
+
virtual ~ScrollingStateScrollingNode();
enum ChangedProperty {
- ScrollableAreaSize = NumStateNodeBits,
+ ViewportRect = NumStateNodeBits,
TotalContentsSize,
- ReachableContentsSize,
- ScrollPosition,
ScrollOrigin,
ScrollableAreaParams,
+ FrameScaleFactor,
+ NonFastScrollableRegion,
+ WheelEventHandlerCount,
+ ReasonsForSynchronousScrolling,
RequestedScrollPosition,
- NumScrollingStateNodeBits,
-#if ENABLE(CSS_SCROLL_SNAP)
- HorizontalSnapOffsets,
- VerticalSnapOffsets,
- CurrentHorizontalSnapOffsetIndex,
- CurrentVerticalSnapOffsetIndex,
-#endif
- ExpectsWheelEventTestTrigger,
+ CounterScrollingLayer,
+ HeaderHeight,
+ FooterHeight,
+ HeaderLayer,
+ FooterLayer,
+ PainterForScrollbar,
+ BehaviorForFixedElements
};
- const FloatSize& scrollableAreaSize() const { return m_scrollableAreaSize; }
- WEBCORE_EXPORT void setScrollableAreaSize(const FloatSize&);
+ const IntRect& viewportRect() const { return m_viewportRect; }
+ void setViewportRect(const IntRect&);
- const FloatSize& totalContentsSize() const { return m_totalContentsSize; }
- WEBCORE_EXPORT void setTotalContentsSize(const FloatSize&);
-
- const FloatSize& reachableContentsSize() const { return m_reachableContentsSize; }
- WEBCORE_EXPORT void setReachableContentsSize(const FloatSize&);
-
- const FloatPoint& scrollPosition() const { return m_scrollPosition; }
- WEBCORE_EXPORT void setScrollPosition(const FloatPoint&);
+ const IntSize& totalContentsSize() const { return m_totalContentsSize; }
+ void setTotalContentsSize(const IntSize&);
const IntPoint& scrollOrigin() const { return m_scrollOrigin; }
- WEBCORE_EXPORT void setScrollOrigin(const IntPoint&);
+ void setScrollOrigin(const IntPoint&);
-#if ENABLE(CSS_SCROLL_SNAP)
- const Vector<float>& horizontalSnapOffsets() const { return m_horizontalSnapOffsets; }
- WEBCORE_EXPORT void setHorizontalSnapOffsets(const Vector<float>&);
+ float frameScaleFactor() const { return m_frameScaleFactor; }
+ void setFrameScaleFactor(float);
- const Vector<float>& verticalSnapOffsets() const { return m_verticalSnapOffsets; }
- WEBCORE_EXPORT void setVerticalSnapOffsets(const Vector<float>&);
+ const Region& nonFastScrollableRegion() const { return m_nonFastScrollableRegion; }
+ void setNonFastScrollableRegion(const Region&);
- unsigned currentHorizontalSnapPointIndex() const { return m_currentHorizontalSnapPointIndex; }
- WEBCORE_EXPORT void setCurrentHorizontalSnapPointIndex(unsigned);
+ unsigned wheelEventHandlerCount() const { return m_wheelEventHandlerCount; }
+ void setWheelEventHandlerCount(unsigned);
- unsigned currentVerticalSnapPointIndex() const { return m_currentVerticalSnapPointIndex; }
- WEBCORE_EXPORT void setCurrentVerticalSnapPointIndex(unsigned);
-#endif
+ SynchronousScrollingReasons synchronousScrollingReasons() const { return m_synchronousScrollingReasons; }
+ void setSynchronousScrollingReasons(SynchronousScrollingReasons);
const ScrollableAreaParameters& scrollableAreaParameters() const { return m_scrollableAreaParameters; }
- WEBCORE_EXPORT void setScrollableAreaParameters(const ScrollableAreaParameters& params);
+ void setScrollableAreaParameters(const ScrollableAreaParameters& params);
- const FloatPoint& requestedScrollPosition() const { return m_requestedScrollPosition; }
- bool requestedScrollPositionRepresentsProgrammaticScroll() const { return m_requestedScrollPositionRepresentsProgrammaticScroll; }
- WEBCORE_EXPORT void setRequestedScrollPosition(const FloatPoint&, bool representsProgrammaticScroll);
+ ScrollBehaviorForFixedElements scrollBehaviorForFixedElements() const { return m_behaviorForFixed; }
+ void setScrollBehaviorForFixedElements(ScrollBehaviorForFixedElements);
+
+ const IntPoint& requestedScrollPosition() const { return m_requestedScrollPosition; }
+ void setRequestedScrollPosition(const IntPoint&, bool representsProgrammaticScroll);
+
+ int headerHeight() const { return m_headerHeight; }
+ void setHeaderHeight(int);
+
+ int footerHeight() const { return m_footerHeight; }
+ void setFooterHeight(int);
+
+ // This is a layer moved in the opposite direction to scrolling, for example for background-attachment:fixed
+ const LayerRepresentation& counterScrollingLayer() const { return m_counterScrollingLayer; }
+ void setCounterScrollingLayer(const LayerRepresentation&);
+
+ // The header and footer layers scroll vertically with the page, they should remain fixed when scrolling horizontally.
+ const LayerRepresentation& headerLayer() const { return m_headerLayer; }
+ void setHeaderLayer(const LayerRepresentation&);
+
+ // The header and footer layers scroll vertically with the page, they should remain fixed when scrolling horizontally.
+ const LayerRepresentation& footerLayer() const { return m_footerLayer; }
+ void setFooterLayer(const LayerRepresentation&);
+
+#if PLATFORM(MAC) && !PLATFORM(IOS)
+ ScrollbarPainter verticalScrollbarPainter() const { return m_verticalScrollbarPainter.get(); }
+ ScrollbarPainter horizontalScrollbarPainter() const { return m_horizontalScrollbarPainter.get(); }
+#endif
+ void setScrollbarPaintersFromScrollbars(Scrollbar* verticalScrollbar, Scrollbar* horizontalScrollbar);
- bool expectsWheelEventTestTrigger() const { return m_expectsWheelEventTestTrigger; }
- WEBCORE_EXPORT void setExpectsWheelEventTestTrigger(bool);
+ bool requestedScrollPositionRepresentsProgrammaticScroll() const { return m_requestedScrollPositionRepresentsProgrammaticScroll; }
virtual void dumpProperties(TextStream&, int indent) const override;
-
-protected:
- ScrollingStateScrollingNode(ScrollingStateTree&, ScrollingNodeType, ScrollingNodeID);
- ScrollingStateScrollingNode(const ScrollingStateScrollingNode&, ScrollingStateTree&);
-
+
private:
- FloatSize m_scrollableAreaSize;
- FloatSize m_totalContentsSize;
- FloatSize m_reachableContentsSize;
- FloatPoint m_scrollPosition;
- FloatPoint m_requestedScrollPosition;
- IntPoint m_scrollOrigin;
-#if ENABLE(CSS_SCROLL_SNAP)
- Vector<float> m_horizontalSnapOffsets;
- Vector<float> m_verticalSnapOffsets;
- unsigned m_currentHorizontalSnapPointIndex { 0 };
- unsigned m_currentVerticalSnapPointIndex { 0 };
+ ScrollingStateScrollingNode(ScrollingStateTree&, ScrollingNodeID);
+ ScrollingStateScrollingNode(const ScrollingStateScrollingNode&, ScrollingStateTree&);
+
+ LayerRepresentation m_counterScrollingLayer;
+ LayerRepresentation m_headerLayer;
+ LayerRepresentation m_footerLayer;
+
+#if PLATFORM(MAC) && !PLATFORM(IOS)
+ RetainPtr<ScrollbarPainter> m_verticalScrollbarPainter;
+ RetainPtr<ScrollbarPainter> m_horizontalScrollbarPainter;
#endif
+
+ IntRect m_viewportRect;
+ IntSize m_totalContentsSize;
+ IntPoint m_scrollOrigin;
+
ScrollableAreaParameters m_scrollableAreaParameters;
- bool m_requestedScrollPositionRepresentsProgrammaticScroll { false };
- bool m_expectsWheelEventTestTrigger { false };
+ Region m_nonFastScrollableRegion;
+ float m_frameScaleFactor;
+ unsigned m_wheelEventHandlerCount;
+ SynchronousScrollingReasons m_synchronousScrollingReasons;
+ ScrollBehaviorForFixedElements m_behaviorForFixed;
+ int m_headerHeight;
+ int m_footerHeight;
+ IntPoint m_requestedScrollPosition;
+ bool m_requestedScrollPositionRepresentsProgrammaticScroll;
};
-} // namespace WebCore
+SCROLLING_STATE_NODE_TYPE_CASTS(ScrollingStateScrollingNode, nodeType() == ScrollingNode);
-SPECIALIZE_TYPE_TRAITS_SCROLLING_STATE_NODE(ScrollingStateScrollingNode, isScrollingNode())
+} // namespace WebCore
#endif // ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS)
diff --git a/Source/WebCore/page/scrolling/ScrollingStateStickyNode.cpp b/Source/WebCore/page/scrolling/ScrollingStateStickyNode.cpp
deleted file mode 100644
index cee476e4a..000000000
--- a/Source/WebCore/page/scrolling/ScrollingStateStickyNode.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ScrollingStateStickyNode.h"
-
-#if ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS)
-
-#include "GraphicsLayer.h"
-#include "ScrollingStateTree.h"
-#include "TextStream.h"
-
-namespace WebCore {
-
-Ref<ScrollingStateStickyNode> ScrollingStateStickyNode::create(ScrollingStateTree& stateTree, ScrollingNodeID nodeID)
-{
- return adoptRef(*new ScrollingStateStickyNode(stateTree, nodeID));
-}
-
-ScrollingStateStickyNode::ScrollingStateStickyNode(ScrollingStateTree& tree, ScrollingNodeID nodeID)
- : ScrollingStateNode(StickyNode, tree, nodeID)
-{
-}
-
-ScrollingStateStickyNode::ScrollingStateStickyNode(const ScrollingStateStickyNode& node, ScrollingStateTree& adoptiveTree)
- : ScrollingStateNode(node, adoptiveTree)
- , m_constraints(StickyPositionViewportConstraints(node.viewportConstraints()))
-{
-}
-
-ScrollingStateStickyNode::~ScrollingStateStickyNode()
-{
-}
-
-Ref<ScrollingStateNode> ScrollingStateStickyNode::clone(ScrollingStateTree& adoptiveTree)
-{
- return adoptRef(*new ScrollingStateStickyNode(*this, adoptiveTree));
-}
-
-void ScrollingStateStickyNode::updateConstraints(const StickyPositionViewportConstraints& constraints)
-{
- if (m_constraints == constraints)
- return;
-
- m_constraints = constraints;
- setPropertyChanged(ViewportConstraints);
-}
-
-void ScrollingStateStickyNode::syncLayerPositionForViewportRect(const LayoutRect& viewportRect)
-{
- FloatPoint position = m_constraints.layerPositionForConstrainingRect(viewportRect);
- if (layer().representsGraphicsLayer())
- static_cast<GraphicsLayer*>(layer())->syncPosition(position);
-}
-
-void ScrollingStateStickyNode::dumpProperties(TextStream& ts, int indent) const
-{
- ts << "(" << "Sticky node" << "\n";
-
- if (m_constraints.anchorEdges()) {
- writeIndent(ts, indent + 1);
- ts << "(anchor edges: ";
- if (m_constraints.hasAnchorEdge(ViewportConstraints::AnchorEdgeLeft))
- ts << "AnchorEdgeLeft ";
- if (m_constraints.hasAnchorEdge(ViewportConstraints::AnchorEdgeRight))
- ts << "AnchorEdgeRight ";
- if (m_constraints.hasAnchorEdge(ViewportConstraints::AnchorEdgeTop))
- ts << "AnchorEdgeTop ";
- if (m_constraints.hasAnchorEdge(ViewportConstraints::AnchorEdgeBottom))
- ts << "AnchorEdgeBottom";
- ts << ")\n";
- }
-
- if (m_constraints.hasAnchorEdge(ViewportConstraints::AnchorEdgeLeft)) {
- writeIndent(ts, indent + 1);
- ts << "(left offset " << m_constraints.leftOffset() << ")\n";
- }
- if (m_constraints.hasAnchorEdge(ViewportConstraints::AnchorEdgeRight)) {
- writeIndent(ts, indent + 1);
- ts << "(right offset " << m_constraints.rightOffset() << ")\n";
- }
- if (m_constraints.hasAnchorEdge(ViewportConstraints::AnchorEdgeTop)) {
- writeIndent(ts, indent + 1);
- ts << "(top offset " << m_constraints.topOffset() << ")\n";
- }
- if (m_constraints.hasAnchorEdge(ViewportConstraints::AnchorEdgeBottom)) {
- writeIndent(ts, indent + 1);
- ts << "(bottom offset " << m_constraints.bottomOffset() << ")\n";
- }
-
- writeIndent(ts, indent + 1);
- FloatRect r = m_constraints.containingBlockRect();
- ts << "(containing block rect " << r.x() << ", " << r.y() << " " << r.width() << " x " << r.height() << ")\n";
-
- writeIndent(ts, indent + 1);
- r = m_constraints.stickyBoxRect();
- ts << "(sticky box rect " << r.x() << " " << r.y() << " " << r.width() << " " << r.height() << ")\n";
-
- writeIndent(ts, indent + 1);
- r = m_constraints.constrainingRectAtLastLayout();
- ts << "(constraining rect " << r.x() << " " << r.y() << " " << r.width() << " " << r.height() << ")\n";
-
- writeIndent(ts, indent + 1);
- ts << "(sticky offset at last layout " << m_constraints.stickyOffsetAtLastLayout().width() << " " << m_constraints.stickyOffsetAtLastLayout().height() << ")\n";
-
- writeIndent(ts, indent + 1);
- ts << "(layer position at last layout " << m_constraints.layerPositionAtLastLayout().x() << " " << m_constraints.layerPositionAtLastLayout().y() << ")\n";
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS)
diff --git a/Source/WebCore/page/scrolling/ScrollingStateStickyNode.h b/Source/WebCore/page/scrolling/ScrollingStateStickyNode.h
deleted file mode 100644
index c9e7935a4..000000000
--- a/Source/WebCore/page/scrolling/ScrollingStateStickyNode.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScrollingStateStickyNode_h
-#define ScrollingStateStickyNode_h
-
-#if ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS)
-
-#include "ScrollingConstraints.h"
-#include "ScrollingStateNode.h"
-
-#include <wtf/Forward.h>
-
-namespace WebCore {
-
-class StickyPositionViewportConstraints;
-
-class ScrollingStateStickyNode final : public ScrollingStateNode {
-public:
- static Ref<ScrollingStateStickyNode> create(ScrollingStateTree&, ScrollingNodeID);
-
- virtual Ref<ScrollingStateNode> clone(ScrollingStateTree&) override;
-
- virtual ~ScrollingStateStickyNode();
-
- enum {
- ViewportConstraints = NumStateNodeBits
- };
-
- WEBCORE_EXPORT void updateConstraints(const StickyPositionViewportConstraints&);
- const StickyPositionViewportConstraints& viewportConstraints() const { return m_constraints; }
-
-private:
- ScrollingStateStickyNode(ScrollingStateTree&, ScrollingNodeID);
- ScrollingStateStickyNode(const ScrollingStateStickyNode&, ScrollingStateTree&);
-
- virtual void syncLayerPositionForViewportRect(const LayoutRect& viewportRect) override;
-
- virtual void dumpProperties(TextStream&, int indent) const override;
-
- StickyPositionViewportConstraints m_constraints;
-};
-
-} // namespace WebCore
-
-SPECIALIZE_TYPE_TRAITS_SCROLLING_STATE_NODE(ScrollingStateStickyNode, isStickyNode())
-
-#endif // ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS)
-
-#endif // ScrollingStateStickyNode_h
diff --git a/Source/WebCore/page/scrolling/ScrollingStateTree.cpp b/Source/WebCore/page/scrolling/ScrollingStateTree.cpp
index 3bec4360c..e06f22168 100644
--- a/Source/WebCore/page/scrolling/ScrollingStateTree.cpp
+++ b/Source/WebCore/page/scrolling/ScrollingStateTree.cpp
@@ -30,17 +30,16 @@
#include "AsyncScrollingCoordinator.h"
#include "ScrollingStateFixedNode.h"
-#include "ScrollingStateFrameScrollingNode.h"
-#include "ScrollingStateOverflowScrollingNode.h"
+#include "ScrollingStateScrollingNode.h"
#include "ScrollingStateStickyNode.h"
-#include <wtf/text/CString.h>
-
-#ifndef NDEBUG
-#include <stdio.h>
-#endif
namespace WebCore {
+PassOwnPtr<ScrollingStateTree> ScrollingStateTree::create(AsyncScrollingCoordinator* scrollingCoordinator)
+{
+ return adoptPtr(new ScrollingStateTree(scrollingCoordinator));
+}
+
ScrollingStateTree::ScrollingStateTree(AsyncScrollingCoordinator* scrollingCoordinator)
: m_scrollingCoordinator(scrollingCoordinator)
, m_hasChangedProperties(false)
@@ -67,46 +66,27 @@ void ScrollingStateTree::setHasChangedProperties(bool changedProperties)
#endif
}
-PassRefPtr<ScrollingStateNode> ScrollingStateTree::createNode(ScrollingNodeType nodeType, ScrollingNodeID nodeID)
-{
- switch (nodeType) {
- case FixedNode:
- return ScrollingStateFixedNode::create(*this, nodeID);
- case StickyNode:
- return ScrollingStateStickyNode::create(*this, nodeID);
- case FrameScrollingNode:
- return ScrollingStateFrameScrollingNode::create(*this, nodeID);
- case OverflowScrollingNode:
- return ScrollingStateOverflowScrollingNode::create(*this, nodeID);
- }
- ASSERT_NOT_REACHED();
- return nullptr;
-}
-
ScrollingNodeID ScrollingStateTree::attachNode(ScrollingNodeType nodeType, ScrollingNodeID newNodeID, ScrollingNodeID parentID)
{
ASSERT(newNodeID);
- if (ScrollingStateNode* node = stateNodeForID(newNodeID)) {
- if (!parentID)
- return newNodeID;
+ if (ScrollingStateNode* node = stateNodeForID(newNodeID)) {
ScrollingStateNode* parent = stateNodeForID(parentID);
if (!parent)
return newNodeID;
-
if (node->parent() == parent)
return newNodeID;
// The node is being re-parented. To do that, we'll remove it, and then re-create a new node.
- removeNodeAndAllDescendants(node, SubframeNodeRemoval::Orphan);
+ removeNode(node);
}
- ScrollingStateNode* newNode = nullptr;
+ ScrollingStateNode* newNode = 0;
if (!parentID) {
// If we're resetting the root node, we should clear the HashMap and destroy the current children.
clear();
- setRootStateNode(ScrollingStateFrameScrollingNode::create(*this, newNodeID));
+ setRootStateNode(ScrollingStateScrollingNode::create(*this, newNodeID));
newNode = rootStateNode();
m_hasNewRootStateNode = true;
} else {
@@ -114,22 +94,31 @@ ScrollingNodeID ScrollingStateTree::attachNode(ScrollingNodeType nodeType, Scrol
if (!parent)
return 0;
- if (nodeType == FrameScrollingNode && parentID) {
- if (RefPtr<ScrollingStateNode> orphanedNode = m_orphanedSubframeNodes.take(newNodeID)) {
- newNode = orphanedNode.get();
- parent->appendChild(orphanedNode.release());
- }
+ switch (nodeType) {
+ case FixedNode: {
+ OwnPtr<ScrollingStateFixedNode> fixedNode = ScrollingStateFixedNode::create(*this, newNodeID);
+ newNode = fixedNode.get();
+ parent->appendChild(fixedNode.release());
+ break;
+ }
+ case StickyNode: {
+ OwnPtr<ScrollingStateStickyNode> stickyNode = ScrollingStateStickyNode::create(*this, newNodeID);
+ newNode = stickyNode.get();
+ parent->appendChild(stickyNode.release());
+ break;
+ }
+ case ScrollingNode: {
+ // FIXME: We currently only support child nodes that are fixed.
+ ASSERT_NOT_REACHED();
+ OwnPtr<ScrollingStateScrollingNode> scrollingNode = ScrollingStateScrollingNode::create(*this, newNodeID);
+ newNode = scrollingNode.get();
+ parent->appendChild(scrollingNode.release());
+ break;
}
-
- if (!newNode) {
- RefPtr<ScrollingStateNode> stateNode = createNode(nodeType, newNodeID);
- newNode = stateNode.get();
- parent->appendChild(stateNode.release());
}
}
m_stateNodeMap.set(newNodeID, newNode);
- m_nodesRemovedSinceLastCommit.remove(newNodeID);
return newNodeID;
}
@@ -143,46 +132,35 @@ void ScrollingStateTree::detachNode(ScrollingNodeID nodeID)
if (!node)
return;
- removeNodeAndAllDescendants(node, SubframeNodeRemoval::Orphan);
+ removeNode(node);
}
void ScrollingStateTree::clear()
{
- if (rootStateNode())
- removeNodeAndAllDescendants(rootStateNode());
-
+ removeNode(rootStateNode());
m_stateNodeMap.clear();
- m_orphanedSubframeNodes.clear();
}
-std::unique_ptr<ScrollingStateTree> ScrollingStateTree::commit(LayerRepresentation::Type preferredLayerRepresentation)
+PassOwnPtr<ScrollingStateTree> ScrollingStateTree::commit(LayerRepresentation::Type preferredLayerRepresentation)
{
- if (!m_orphanedSubframeNodes.isEmpty()) {
- // If we still have orphaned subtrees, remove them from m_stateNodeMap since they will be deleted
- // when clearing m_orphanedSubframeNodes.
- for (auto& orphanNode : m_orphanedSubframeNodes.values())
- recursiveNodeWillBeRemoved(orphanNode.get(), SubframeNodeRemoval::Delete);
- m_orphanedSubframeNodes.clear();
- }
-
// This function clones and resets the current state tree, but leaves the tree structure intact.
- std::unique_ptr<ScrollingStateTree> treeStateClone = std::make_unique<ScrollingStateTree>();
+ OwnPtr<ScrollingStateTree> treeStateClone = ScrollingStateTree::create();
treeStateClone->setPreferredLayerRepresentation(preferredLayerRepresentation);
if (m_rootStateNode)
- treeStateClone->setRootStateNode(static_pointer_cast<ScrollingStateFrameScrollingNode>(m_rootStateNode->cloneAndReset(*treeStateClone)));
+ treeStateClone->setRootStateNode(static_pointer_cast<ScrollingStateScrollingNode>(m_rootStateNode->cloneAndReset(*treeStateClone)));
// Copy the IDs of the nodes that have been removed since the last commit into the clone.
treeStateClone->m_nodesRemovedSinceLastCommit.swap(m_nodesRemovedSinceLastCommit);
// Now the clone tree has changed properties, and the original tree does not.
- treeStateClone->m_hasChangedProperties = m_hasChangedProperties;
+ treeStateClone->m_hasChangedProperties = true;
m_hasChangedProperties = false;
treeStateClone->m_hasNewRootStateNode = m_hasNewRootStateNode;
m_hasNewRootStateNode = false;
- return treeStateClone;
+ return treeStateClone.release();
}
void ScrollingStateTree::addNode(ScrollingStateNode* node)
@@ -190,50 +168,36 @@ void ScrollingStateTree::addNode(ScrollingStateNode* node)
m_stateNodeMap.add(node->scrollingNodeID(), node);
}
-void ScrollingStateTree::removeNodeAndAllDescendants(ScrollingStateNode* node, SubframeNodeRemoval subframeNodeRemoval)
+void ScrollingStateTree::removeNode(ScrollingStateNode* node)
{
- ScrollingStateNode* parent = node->parent();
-
- recursiveNodeWillBeRemoved(node, subframeNodeRemoval);
+ if (!node)
+ return;
- if (node == m_rootStateNode)
+ if (node == m_rootStateNode) {
+ didRemoveNode(node->scrollingNodeID());
m_rootStateNode = nullptr;
- else if (parent) {
- ASSERT(parent->children() && parent->children()->find(node) != notFound);
- if (auto children = parent->children()) {
- size_t index = children->find(node);
- if (index != notFound)
- children->remove(index);
- }
- }
-}
-
-void ScrollingStateTree::recursiveNodeWillBeRemoved(ScrollingStateNode* currNode, SubframeNodeRemoval subframeNodeRemoval)
-{
- currNode->setParent(nullptr);
- if (subframeNodeRemoval == SubframeNodeRemoval::Orphan && currNode != m_rootStateNode && currNode->isFrameScrollingNode()) {
- m_orphanedSubframeNodes.add(currNode->scrollingNodeID(), currNode);
return;
}
- willRemoveNode(currNode);
+ ASSERT(m_rootStateNode);
+ m_rootStateNode->removeChild(node);
- if (auto children = currNode->children()) {
- for (auto& child : *children)
- recursiveNodeWillBeRemoved(child.get(), subframeNodeRemoval);
- }
+ // ScrollingStateTree::removeNode() will destroy children, so we have to make sure we remove those children
+ // from the HashMap.
+ size_t size = m_nodesRemovedSinceLastCommit.size();
+ for (size_t i = 0; i < size; ++i)
+ m_stateNodeMap.remove(m_nodesRemovedSinceLastCommit[i]);
}
-void ScrollingStateTree::willRemoveNode(ScrollingStateNode* node)
+void ScrollingStateTree::didRemoveNode(ScrollingNodeID nodeID)
{
- m_nodesRemovedSinceLastCommit.add(node->scrollingNodeID());
- m_stateNodeMap.remove(node->scrollingNodeID());
+ m_nodesRemovedSinceLastCommit.append(nodeID);
setHasChangedProperties();
}
-void ScrollingStateTree::setRemovedNodes(HashSet<ScrollingNodeID> nodes)
+void ScrollingStateTree::setRemovedNodes(Vector<ScrollingNodeID> nodes)
{
- m_nodesRemovedSinceLastCommit = WTFMove(nodes);
+ m_nodesRemovedSinceLastCommit = std::move(nodes);
}
ScrollingStateNode* ScrollingStateTree::stateNodeForID(ScrollingNodeID scrollLayerID)
@@ -251,30 +215,4 @@ ScrollingStateNode* ScrollingStateTree::stateNodeForID(ScrollingNodeID scrollLay
} // namespace WebCore
-#ifndef NDEBUG
-void showScrollingStateTree(const WebCore::ScrollingStateTree* tree)
-{
- if (!tree)
- return;
-
- auto rootNode = tree->rootStateNode();
- if (!rootNode) {
- fprintf(stderr, "Scrolling state tree %p with no root node\n", tree);
- return;
- }
-
- String output = rootNode->scrollingStateTreeAsText();
- fprintf(stderr, "%s\n", output.utf8().data());
-}
-
-void showScrollingStateTree(const WebCore::ScrollingStateNode* node)
-{
- if (!node)
- return;
-
- showScrollingStateTree(&node->scrollingStateTree());
-}
-
-#endif
-
#endif // ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS)
diff --git a/Source/WebCore/page/scrolling/ScrollingStateTree.h b/Source/WebCore/page/scrolling/ScrollingStateTree.h
index 79a65a5f4..59659e534 100644
--- a/Source/WebCore/page/scrolling/ScrollingStateTree.h
+++ b/Source/WebCore/page/scrolling/ScrollingStateTree.h
@@ -28,7 +28,9 @@
#if ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS)
-#include "ScrollingStateFrameScrollingNode.h"
+#include "ScrollingStateScrollingNode.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
#include <wtf/RefPtr.h>
namespace WebCore {
@@ -41,30 +43,29 @@ class AsyncScrollingCoordinator;
// the scrolling thread, avoiding locking.
class ScrollingStateTree {
- WTF_MAKE_FAST_ALLOCATED;
friend class ScrollingStateNode;
public:
- WEBCORE_EXPORT ScrollingStateTree(AsyncScrollingCoordinator* = nullptr);
- WEBCORE_EXPORT ~ScrollingStateTree();
+
+ static PassOwnPtr<ScrollingStateTree> create(AsyncScrollingCoordinator* = 0);
+ ~ScrollingStateTree();
- ScrollingStateFrameScrollingNode* rootStateNode() const { return m_rootStateNode.get(); }
- WEBCORE_EXPORT ScrollingStateNode* stateNodeForID(ScrollingNodeID);
+ ScrollingStateScrollingNode* rootStateNode() const { return m_rootStateNode.get(); }
+ ScrollingStateNode* stateNodeForID(ScrollingNodeID);
- WEBCORE_EXPORT ScrollingNodeID attachNode(ScrollingNodeType, ScrollingNodeID, ScrollingNodeID parentID);
+ ScrollingNodeID attachNode(ScrollingNodeType, ScrollingNodeID, ScrollingNodeID parentID);
void detachNode(ScrollingNodeID);
void clear();
- const HashSet<ScrollingNodeID>& removedNodes() const { return m_nodesRemovedSinceLastCommit; }
- WEBCORE_EXPORT void setRemovedNodes(HashSet<ScrollingNodeID>);
+ const Vector<ScrollingNodeID>& removedNodes() const { return m_nodesRemovedSinceLastCommit; }
+ void setRemovedNodes(Vector<ScrollingNodeID>);
// Copies the current tree state and clears the changed properties mask in the original.
- WEBCORE_EXPORT std::unique_ptr<ScrollingStateTree> commit(LayerRepresentation::Type preferredLayerRepresentation);
+ PassOwnPtr<ScrollingStateTree> commit(LayerRepresentation::Type preferredLayerRepresentation);
- WEBCORE_EXPORT void setHasChangedProperties(bool = true);
+ void setHasChangedProperties(bool = true);
bool hasChangedProperties() const { return m_hasChangedProperties; }
bool hasNewRootStateNode() const { return m_hasNewRootStateNode; }
- void setHasNewRootStateNode(bool hasNewRoot) { m_hasNewRootStateNode = hasNewRoot; }
int nodeCount() const { return m_stateNodeMap.size(); }
@@ -75,25 +76,17 @@ public:
void setPreferredLayerRepresentation(LayerRepresentation::Type representation) { m_preferredLayerRepresentation = representation; }
private:
- void setRootStateNode(PassRefPtr<ScrollingStateFrameScrollingNode> rootStateNode) { m_rootStateNode = rootStateNode; }
- void addNode(ScrollingStateNode*);
-
- PassRefPtr<ScrollingStateNode> createNode(ScrollingNodeType, ScrollingNodeID);
-
- enum class SubframeNodeRemoval {
- Delete,
- Orphan
- };
- void removeNodeAndAllDescendants(ScrollingStateNode*, SubframeNodeRemoval = SubframeNodeRemoval::Delete);
+ ScrollingStateTree(AsyncScrollingCoordinator*);
- void recursiveNodeWillBeRemoved(ScrollingStateNode* currNode, SubframeNodeRemoval);
- void willRemoveNode(ScrollingStateNode*);
+ void setRootStateNode(PassOwnPtr<ScrollingStateScrollingNode> rootStateNode) { m_rootStateNode = rootStateNode; }
+ void addNode(ScrollingStateNode*);
+ void removeNode(ScrollingStateNode*);
+ void didRemoveNode(ScrollingNodeID);
AsyncScrollingCoordinator* m_scrollingCoordinator;
StateNodeMap m_stateNodeMap;
- RefPtr<ScrollingStateFrameScrollingNode> m_rootStateNode;
- HashSet<ScrollingNodeID> m_nodesRemovedSinceLastCommit;
- HashMap<ScrollingNodeID, RefPtr<ScrollingStateNode>> m_orphanedSubframeNodes;
+ OwnPtr<ScrollingStateScrollingNode> m_rootStateNode;
+ Vector<ScrollingNodeID> m_nodesRemovedSinceLastCommit;
bool m_hasChangedProperties;
bool m_hasNewRootStateNode;
LayerRepresentation::Type m_preferredLayerRepresentation;
@@ -101,11 +94,6 @@ private:
} // namespace WebCore
-#ifndef NDEBUG
-void showScrollingStateTree(const WebCore::ScrollingStateTree*);
-void showScrollingStateTree(const WebCore::ScrollingStateNode*);
-#endif
-
#endif // ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS)
#endif // ScrollingStateTree_h
diff --git a/Source/WebCore/page/scrolling/ScrollingThread.cpp b/Source/WebCore/page/scrolling/ScrollingThread.cpp
deleted file mode 100644
index 4669a1992..000000000
--- a/Source/WebCore/page/scrolling/ScrollingThread.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2012, 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ScrollingThread.h"
-
-#if ENABLE(ASYNC_SCROLLING)
-
-#include <mutex>
-#include <wtf/MainThread.h>
-#include <wtf/NeverDestroyed.h>
-
-namespace WebCore {
-
-ScrollingThread::ScrollingThread()
- : m_threadIdentifier(0)
-{
-}
-
-bool ScrollingThread::isCurrentThread()
-{
- auto threadIdentifier = ScrollingThread::singleton().m_threadIdentifier;
- return threadIdentifier && currentThread() == threadIdentifier;
-}
-
-void ScrollingThread::dispatch(std::function<void ()> function)
-{
- auto& scrollingThread = ScrollingThread::singleton();
- scrollingThread.createThreadIfNeeded();
-
- {
- std::lock_guard<Lock> lock(scrollingThread.m_functionsMutex);
- scrollingThread.m_functions.append(function);
- }
-
- scrollingThread.wakeUpRunLoop();
-}
-
-void ScrollingThread::dispatchBarrier(std::function<void ()> function)
-{
- dispatch([function]() mutable {
- callOnMainThread(WTFMove(function));
- });
-}
-
-ScrollingThread& ScrollingThread::singleton()
-{
- static NeverDestroyed<ScrollingThread> scrollingThread;
-
- return scrollingThread;
-}
-
-void ScrollingThread::createThreadIfNeeded()
-{
- if (m_threadIdentifier)
- return;
-
- // Wait for the thread to initialize the run loop.
- {
- std::unique_lock<Lock> lock(m_initializeRunLoopMutex);
-
- m_threadIdentifier = createThread(threadCallback, this, "WebCore: Scrolling");
-
-#if PLATFORM(COCOA)
- m_initializeRunLoopConditionVariable.wait(lock, [this]{ return m_threadRunLoop; });
-#endif
- }
-}
-
-void ScrollingThread::threadCallback(void* scrollingThread)
-{
- WTF::setCurrentThreadIsUserInteractive();
- static_cast<ScrollingThread*>(scrollingThread)->threadBody();
-}
-
-void ScrollingThread::threadBody()
-{
- initializeRunLoop();
-}
-
-void ScrollingThread::dispatchFunctionsFromScrollingThread()
-{
- ASSERT(isCurrentThread());
-
- Vector<std::function<void ()>> functions;
-
- {
- std::lock_guard<Lock> lock(m_functionsMutex);
- functions = WTFMove(m_functions);
- }
-
- for (auto& function : functions)
- function();
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(ASYNC_SCROLLING)
diff --git a/Source/WebCore/page/scrolling/ScrollingThread.h b/Source/WebCore/page/scrolling/ScrollingThread.h
deleted file mode 100644
index a709ccd8e..000000000
--- a/Source/WebCore/page/scrolling/ScrollingThread.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2012, 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScrollingThread_h
-#define ScrollingThread_h
-
-#if ENABLE(ASYNC_SCROLLING)
-
-#include <functional>
-#include <wtf/Condition.h>
-#include <wtf/Forward.h>
-#include <wtf/Lock.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/Threading.h>
-#include <wtf/Vector.h>
-
-#if PLATFORM(COCOA)
-#include <wtf/RetainPtr.h>
-#endif
-
-namespace WebCore {
-
-class ScrollingThread {
- WTF_MAKE_NONCOPYABLE(ScrollingThread);
-
-public:
- static bool isCurrentThread();
- WEBCORE_EXPORT static void dispatch(std::function<void ()>);
-
- // Will dispatch the given function on the main thread once all pending functions
- // on the scrolling thread have finished executing. Used for synchronization purposes.
- WEBCORE_EXPORT static void dispatchBarrier(std::function<void ()>);
-
-private:
- friend NeverDestroyed<ScrollingThread>;
-
- ScrollingThread();
-
- static ScrollingThread& singleton();
-
- void createThreadIfNeeded();
- static void threadCallback(void* scrollingThread);
- void threadBody();
- void dispatchFunctionsFromScrollingThread();
-
- void initializeRunLoop();
- void wakeUpRunLoop();
-
-#if PLATFORM(COCOA)
- static void threadRunLoopSourceCallback(void* scrollingThread);
- void threadRunLoopSourceCallback();
-#endif
-
- ThreadIdentifier m_threadIdentifier;
-
- Condition m_initializeRunLoopConditionVariable;
- Lock m_initializeRunLoopMutex;
-
- Lock m_functionsMutex;
- Vector<std::function<void ()>> m_functions;
-
-#if PLATFORM(COCOA)
- // FIXME: We should use WebCore::RunLoop here.
- RetainPtr<CFRunLoopRef> m_threadRunLoop;
- RetainPtr<CFRunLoopSourceRef> m_threadRunLoopSource;
-#endif
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(ASYNC_SCROLLING)
-
-#endif // ScrollingThread_h
diff --git a/Source/WebCore/page/scrolling/ScrollingTree.cpp b/Source/WebCore/page/scrolling/ScrollingTree.cpp
deleted file mode 100644
index 476b4c271..000000000
--- a/Source/WebCore/page/scrolling/ScrollingTree.cpp
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- * Copyright (C) 2012-2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ScrollingTree.h"
-
-#if ENABLE(ASYNC_SCROLLING)
-
-#include "Logging.h"
-#include "PlatformWheelEvent.h"
-#include "ScrollingStateTree.h"
-#include "ScrollingTreeFrameScrollingNode.h"
-#include "ScrollingTreeNode.h"
-#include "ScrollingTreeOverflowScrollingNode.h"
-#include "ScrollingTreeScrollingNode.h"
-#include "TextStream.h"
-#include <wtf/TemporaryChange.h>
-
-namespace WebCore {
-
-ScrollingTree::ScrollingTree()
-{
-}
-
-ScrollingTree::~ScrollingTree()
-{
-}
-
-bool ScrollingTree::shouldHandleWheelEventSynchronously(const PlatformWheelEvent& wheelEvent)
-{
- // This method is invoked by the event handling thread
- LockHolder lock(m_mutex);
-
- bool shouldSetLatch = wheelEvent.shouldConsiderLatching();
-
- if (hasLatchedNode() && !shouldSetLatch)
- return false;
-
- if (shouldSetLatch)
- m_latchedNode = 0;
-
- if (!m_nonFastScrollableRegion.isEmpty() && m_rootNode) {
- ScrollingTreeFrameScrollingNode& frameScrollingNode = downcast<ScrollingTreeFrameScrollingNode>(*m_rootNode);
- FloatPoint position = wheelEvent.position();
- position.move(frameScrollingNode.viewToContentsOffset(m_mainFrameScrollPosition));
-
- LOG_WITH_STREAM(Scrolling, stream << "ScrollingTree::shouldHandleWheelEventSynchronously: wheelEvent at " << wheelEvent.position() << " mapped to content point " << position << ", in non-fast region " << m_nonFastScrollableRegion.contains(roundedIntPoint(position)));
-
- if (m_nonFastScrollableRegion.contains(roundedIntPoint(position)))
- return true;
- }
- return false;
-}
-
-void ScrollingTree::setOrClearLatchedNode(const PlatformWheelEvent& wheelEvent, ScrollingNodeID nodeID)
-{
- if (wheelEvent.shouldConsiderLatching())
- setLatchedNode(nodeID);
- else if (wheelEvent.shouldResetLatching())
- clearLatchedNode();
-}
-
-void ScrollingTree::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
-{
- if (m_rootNode)
- downcast<ScrollingTreeScrollingNode>(*m_rootNode).handleWheelEvent(wheelEvent);
-}
-
-void ScrollingTree::viewportChangedViaDelegatedScrolling(ScrollingNodeID nodeID, const WebCore::FloatRect& fixedPositionRect, double scale)
-{
- ScrollingTreeNode* node = nodeForID(nodeID);
- if (!is<ScrollingTreeScrollingNode>(node))
- return;
-
- downcast<ScrollingTreeScrollingNode>(*node).updateLayersAfterViewportChange(fixedPositionRect, scale);
-}
-
-void ScrollingTree::scrollPositionChangedViaDelegatedScrolling(ScrollingNodeID nodeID, const WebCore::FloatPoint& scrollPosition, bool inUserInteration)
-{
- ScrollingTreeNode* node = nodeForID(nodeID);
- if (!is<ScrollingTreeOverflowScrollingNode>(node))
- return;
-
- // Update descendant nodes
- downcast<ScrollingTreeOverflowScrollingNode>(*node).updateLayersAfterDelegatedScroll(scrollPosition);
-
- // Update GraphicsLayers and scroll state.
- scrollingTreeNodeDidScroll(nodeID, scrollPosition, inUserInteration ? SyncScrollingLayerPosition : SetScrollingLayerPosition);
-}
-
-void ScrollingTree::commitNewTreeState(std::unique_ptr<ScrollingStateTree> scrollingStateTree)
-{
- bool rootStateNodeChanged = scrollingStateTree->hasNewRootStateNode();
-
- ScrollingStateScrollingNode* rootNode = scrollingStateTree->rootStateNode();
- if (rootNode
- && (rootStateNodeChanged
- || rootNode->hasChangedProperty(ScrollingStateFrameScrollingNode::NonFastScrollableRegion)
- || rootNode->hasChangedProperty(ScrollingStateNode::ScrollLayer))) {
- LockHolder lock(m_mutex);
-
- if (rootStateNodeChanged || rootNode->hasChangedProperty(ScrollingStateNode::ScrollLayer))
- m_mainFrameScrollPosition = FloatPoint();
- if (rootStateNodeChanged || rootNode->hasChangedProperty(ScrollingStateFrameScrollingNode::NonFastScrollableRegion))
- m_nonFastScrollableRegion = scrollingStateTree->rootStateNode()->nonFastScrollableRegion();
- }
-
- bool scrollRequestIsProgammatic = rootNode ? rootNode->requestedScrollPositionRepresentsProgrammaticScroll() : false;
- TemporaryChange<bool> changeHandlingProgrammaticScroll(m_isHandlingProgrammaticScroll, scrollRequestIsProgammatic);
-
- removeDestroyedNodes(*scrollingStateTree);
-
- OrphanScrollingNodeMap orphanNodes;
- updateTreeFromStateNode(rootNode, orphanNodes);
-}
-
-void ScrollingTree::updateTreeFromStateNode(const ScrollingStateNode* stateNode, OrphanScrollingNodeMap& orphanNodes)
-{
- if (!stateNode) {
- m_nodeMap.clear();
- m_rootNode = nullptr;
- return;
- }
-
- ScrollingNodeID nodeID = stateNode->scrollingNodeID();
- ScrollingNodeID parentNodeID = stateNode->parentNodeID();
-
- auto it = m_nodeMap.find(nodeID);
-
- RefPtr<ScrollingTreeNode> node;
- if (it != m_nodeMap.end())
- node = it->value;
- else {
- node = createScrollingTreeNode(stateNode->nodeType(), nodeID);
- if (!parentNodeID) {
- // This is the root node. Clear the node map.
- ASSERT(stateNode->nodeType() == FrameScrollingNode);
- m_rootNode = node;
- m_nodeMap.clear();
- }
- m_nodeMap.set(nodeID, node.get());
- }
-
- if (parentNodeID) {
- auto parentIt = m_nodeMap.find(parentNodeID);
- ASSERT_WITH_SECURITY_IMPLICATION(parentIt != m_nodeMap.end());
- if (parentIt != m_nodeMap.end()) {
- ScrollingTreeNode* parent = parentIt->value;
- node->setParent(parent);
- parent->appendChild(node);
- }
- }
-
- node->updateBeforeChildren(*stateNode);
-
- // Move all children into the orphanNodes map. Live ones will get added back as we recurse over children.
- if (auto nodeChildren = node->children()) {
- for (auto& childScrollingNode : *nodeChildren) {
- childScrollingNode->setParent(nullptr);
- orphanNodes.add(childScrollingNode->scrollingNodeID(), childScrollingNode);
- }
- nodeChildren->clear();
- }
-
- // Now update the children if we have any.
- if (auto children = stateNode->children()) {
- for (auto& child : *children)
- updateTreeFromStateNode(child.get(), orphanNodes);
- }
-
- node->updateAfterChildren(*stateNode);
-}
-
-void ScrollingTree::removeDestroyedNodes(const ScrollingStateTree& stateTree)
-{
- for (const auto& removedNodeID : stateTree.removedNodes()) {
- m_nodeMap.remove(removedNodeID);
- if (removedNodeID == m_latchedNode)
- clearLatchedNode();
- }
-}
-
-ScrollingTreeNode* ScrollingTree::nodeForID(ScrollingNodeID nodeID) const
-{
- if (!nodeID)
- return nullptr;
-
- return m_nodeMap.get(nodeID);
-}
-
-void ScrollingTree::setMainFramePinState(bool pinnedToTheLeft, bool pinnedToTheRight, bool pinnedToTheTop, bool pinnedToTheBottom)
-{
- LockHolder locker(m_swipeStateMutex);
-
- m_mainFramePinnedToTheLeft = pinnedToTheLeft;
- m_mainFramePinnedToTheRight = pinnedToTheRight;
- m_mainFramePinnedToTheTop = pinnedToTheTop;
- m_mainFramePinnedToTheBottom = pinnedToTheBottom;
-}
-
-FloatPoint ScrollingTree::mainFrameScrollPosition()
-{
- LockHolder lock(m_mutex);
- return m_mainFrameScrollPosition;
-}
-
-void ScrollingTree::setMainFrameScrollPosition(FloatPoint position)
-{
- LockHolder lock(m_mutex);
- m_mainFrameScrollPosition = position;
-}
-
-bool ScrollingTree::isPointInNonFastScrollableRegion(IntPoint p)
-{
- LockHolder lock(m_mutex);
-
- return m_nonFastScrollableRegion.contains(p);
-}
-
-bool ScrollingTree::isRubberBandInProgress()
-{
- LockHolder lock(m_mutex);
-
- return m_mainFrameIsRubberBanding;
-}
-
-void ScrollingTree::setMainFrameIsRubberBanding(bool isRubberBanding)
-{
- LockHolder locker(m_mutex);
-
- m_mainFrameIsRubberBanding = isRubberBanding;
-}
-
-bool ScrollingTree::isScrollSnapInProgress()
-{
- LockHolder lock(m_mutex);
-
- return m_mainFrameIsScrollSnapping;
-}
-
-void ScrollingTree::setMainFrameIsScrollSnapping(bool isScrollSnapping)
-{
- LockHolder locker(m_mutex);
-
- m_mainFrameIsScrollSnapping = isScrollSnapping;
-}
-
-void ScrollingTree::setCanRubberBandState(bool canRubberBandAtLeft, bool canRubberBandAtRight, bool canRubberBandAtTop, bool canRubberBandAtBottom)
-{
- LockHolder locker(m_swipeStateMutex);
-
- m_rubberBandsAtLeft = canRubberBandAtLeft;
- m_rubberBandsAtRight = canRubberBandAtRight;
- m_rubberBandsAtTop = canRubberBandAtTop;
- m_rubberBandsAtBottom = canRubberBandAtBottom;
-}
-
-bool ScrollingTree::rubberBandsAtLeft()
-{
- LockHolder lock(m_swipeStateMutex);
-
- return m_rubberBandsAtLeft;
-}
-
-bool ScrollingTree::rubberBandsAtRight()
-{
- LockHolder lock(m_swipeStateMutex);
-
- return m_rubberBandsAtRight;
-}
-
-bool ScrollingTree::rubberBandsAtBottom()
-{
- LockHolder lock(m_swipeStateMutex);
-
- return m_rubberBandsAtBottom;
-}
-
-bool ScrollingTree::rubberBandsAtTop()
-{
- LockHolder lock(m_swipeStateMutex);
-
- return m_rubberBandsAtTop;
-}
-
-bool ScrollingTree::isHandlingProgrammaticScroll()
-{
- return m_isHandlingProgrammaticScroll;
-}
-
-void ScrollingTree::setScrollPinningBehavior(ScrollPinningBehavior pinning)
-{
- LockHolder locker(m_swipeStateMutex);
-
- m_scrollPinningBehavior = pinning;
-}
-
-ScrollPinningBehavior ScrollingTree::scrollPinningBehavior()
-{
- LockHolder lock(m_swipeStateMutex);
-
- return m_scrollPinningBehavior;
-}
-
-bool ScrollingTree::willWheelEventStartSwipeGesture(const PlatformWheelEvent& wheelEvent)
-{
- if (wheelEvent.phase() != PlatformWheelEventPhaseBegan)
- return false;
-
- LockHolder lock(m_swipeStateMutex);
-
- if (wheelEvent.deltaX() > 0 && m_mainFramePinnedToTheLeft && !m_rubberBandsAtLeft)
- return true;
- if (wheelEvent.deltaX() < 0 && m_mainFramePinnedToTheRight && !m_rubberBandsAtRight)
- return true;
- if (wheelEvent.deltaY() > 0 && m_mainFramePinnedToTheTop && !m_rubberBandsAtTop)
- return true;
- if (wheelEvent.deltaY() < 0 && m_mainFramePinnedToTheBottom && !m_rubberBandsAtBottom)
- return true;
-
- return false;
-}
-
-void ScrollingTree::setScrollingPerformanceLoggingEnabled(bool flag)
-{
- m_scrollingPerformanceLoggingEnabled = flag;
-}
-
-bool ScrollingTree::scrollingPerformanceLoggingEnabled()
-{
- return m_scrollingPerformanceLoggingEnabled;
-}
-
-ScrollingNodeID ScrollingTree::latchedNode()
-{
- LockHolder locker(m_mutex);
- return m_latchedNode;
-}
-
-void ScrollingTree::setLatchedNode(ScrollingNodeID node)
-{
- LockHolder locker(m_mutex);
- m_latchedNode = node;
-}
-
-void ScrollingTree::clearLatchedNode()
-{
- LockHolder locker(m_mutex);
- m_latchedNode = 0;
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(ASYNC_SCROLLING)
diff --git a/Source/WebCore/page/scrolling/ScrollingTree.h b/Source/WebCore/page/scrolling/ScrollingTree.h
deleted file mode 100644
index b97765b5c..000000000
--- a/Source/WebCore/page/scrolling/ScrollingTree.h
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Copyright (C) 2012-2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScrollingTree_h
-#define ScrollingTree_h
-
-#if ENABLE(ASYNC_SCROLLING)
-
-#include "PlatformWheelEvent.h"
-#include "Region.h"
-#include "ScrollingCoordinator.h"
-#include "WheelEventTestTrigger.h"
-#include <wtf/HashMap.h>
-#include <wtf/Lock.h>
-#include <wtf/ThreadSafeRefCounted.h>
-#include <wtf/TypeCasts.h>
-
-namespace WebCore {
-
-class IntPoint;
-class ScrollingStateTree;
-class ScrollingStateNode;
-class ScrollingTreeNode;
-class ScrollingTreeScrollingNode;
-
-class ScrollingTree : public ThreadSafeRefCounted<ScrollingTree> {
-public:
- WEBCORE_EXPORT ScrollingTree();
- WEBCORE_EXPORT virtual ~ScrollingTree();
-
- enum EventResult {
- DidNotHandleEvent,
- DidHandleEvent,
- SendToMainThread
- };
-
- virtual bool isThreadedScrollingTree() const { return false; }
- virtual bool isRemoteScrollingTree() const { return false; }
- virtual bool isScrollingTreeIOS() const { return false; }
-
- virtual EventResult tryToHandleWheelEvent(const PlatformWheelEvent&) = 0;
- WEBCORE_EXPORT bool shouldHandleWheelEventSynchronously(const PlatformWheelEvent&);
-
- void setMainFrameIsRubberBanding(bool);
- bool isRubberBandInProgress();
- void setMainFrameIsScrollSnapping(bool);
- bool isScrollSnapInProgress();
-
- virtual void invalidate() { }
- WEBCORE_EXPORT virtual void commitNewTreeState(std::unique_ptr<ScrollingStateTree>);
-
- void setMainFramePinState(bool pinnedToTheLeft, bool pinnedToTheRight, bool pinnedToTheTop, bool pinnedToTheBottom);
-
- virtual PassRefPtr<ScrollingTreeNode> createScrollingTreeNode(ScrollingNodeType, ScrollingNodeID) = 0;
-
- // Called after a scrolling tree node has handled a scroll and updated its layers.
- // Updates FrameView/RenderLayer scrolling state and GraphicsLayers.
- virtual void scrollingTreeNodeDidScroll(ScrollingNodeID, const FloatPoint& scrollPosition, SetOrSyncScrollingLayerPosition = SyncScrollingLayerPosition) = 0;
-
- // Called for requested scroll position updates.
- virtual void scrollingTreeNodeRequestsScroll(ScrollingNodeID, const FloatPoint& /*scrollPosition*/, bool /*representsProgrammaticScroll*/) { }
-
- // Delegated scrolling/zooming has caused the viewport to change, so update viewport-constrained layers
- // (but don't cause scroll events to be fired).
- WEBCORE_EXPORT virtual void viewportChangedViaDelegatedScrolling(ScrollingNodeID, const WebCore::FloatRect& fixedPositionRect, double scale);
-
- // Delegated scrolling has scrolled a node. Update layer positions on descendant tree nodes,
- // and call scrollingTreeNodeDidScroll().
- WEBCORE_EXPORT virtual void scrollPositionChangedViaDelegatedScrolling(ScrollingNodeID, const WebCore::FloatPoint& scrollPosition, bool inUserInteration);
-
- WEBCORE_EXPORT virtual void currentSnapPointIndicesDidChange(ScrollingNodeID, unsigned horizontal, unsigned vertical) = 0;
-
- FloatPoint mainFrameScrollPosition();
-
-#if PLATFORM(IOS)
- virtual FloatRect fixedPositionRect() = 0;
- virtual void scrollingTreeNodeWillStartPanGesture() { }
- virtual void scrollingTreeNodeWillStartScroll() { }
- virtual void scrollingTreeNodeDidEndScroll() { }
-#endif
-
- WEBCORE_EXPORT bool isPointInNonFastScrollableRegion(IntPoint);
-
-#if PLATFORM(MAC)
- virtual void handleWheelEventPhase(PlatformWheelEventPhase) = 0;
- virtual void setActiveScrollSnapIndices(ScrollingNodeID, unsigned /*horizontalIndex*/, unsigned /*verticalIndex*/) { }
- virtual void deferTestsForReason(WheelEventTestTrigger::ScrollableAreaIdentifier, WheelEventTestTrigger::DeferTestTriggerReason) { }
- virtual void removeTestDeferralForReason(WheelEventTestTrigger::ScrollableAreaIdentifier, WheelEventTestTrigger::DeferTestTriggerReason) { }
-#endif
-
- // Can be called from any thread. Will update what edges allow rubber-banding.
- WEBCORE_EXPORT void setCanRubberBandState(bool canRubberBandAtLeft, bool canRubberBandAtRight, bool canRubberBandAtTop, bool canRubberBandAtBottom);
-
- bool rubberBandsAtLeft();
- bool rubberBandsAtRight();
- bool rubberBandsAtTop();
- bool rubberBandsAtBottom();
- bool isHandlingProgrammaticScroll();
-
- void setScrollPinningBehavior(ScrollPinningBehavior);
- ScrollPinningBehavior scrollPinningBehavior();
-
- WEBCORE_EXPORT bool willWheelEventStartSwipeGesture(const PlatformWheelEvent&);
-
- WEBCORE_EXPORT void setScrollingPerformanceLoggingEnabled(bool flag);
- bool scrollingPerformanceLoggingEnabled();
-
- ScrollingTreeNode* rootNode() const { return m_rootNode.get(); }
-
- ScrollingNodeID latchedNode();
- void setLatchedNode(ScrollingNodeID);
- void clearLatchedNode();
-
- bool hasLatchedNode() const { return m_latchedNode; }
- void setOrClearLatchedNode(const PlatformWheelEvent&, ScrollingNodeID);
-
- bool hasFixedOrSticky() const { return !!m_fixedOrStickyNodeCount; }
- void fixedOrStickyNodeAdded() { ++m_fixedOrStickyNodeCount; }
- void fixedOrStickyNodeRemoved()
- {
- ASSERT(m_fixedOrStickyNodeCount);
- --m_fixedOrStickyNodeCount;
- }
-
-protected:
- void setMainFrameScrollPosition(FloatPoint);
- WEBCORE_EXPORT virtual void handleWheelEvent(const PlatformWheelEvent&);
-
-private:
- void removeDestroyedNodes(const ScrollingStateTree&);
-
- typedef HashMap<ScrollingNodeID, RefPtr<ScrollingTreeNode>> OrphanScrollingNodeMap;
- void updateTreeFromStateNode(const ScrollingStateNode*, OrphanScrollingNodeMap&);
-
- ScrollingTreeNode* nodeForID(ScrollingNodeID) const;
-
- RefPtr<ScrollingTreeNode> m_rootNode;
-
- typedef HashMap<ScrollingNodeID, ScrollingTreeNode*> ScrollingTreeNodeMap;
- ScrollingTreeNodeMap m_nodeMap;
-
- Lock m_mutex;
- Region m_nonFastScrollableRegion;
- FloatPoint m_mainFrameScrollPosition;
-
- Lock m_swipeStateMutex;
- ScrollPinningBehavior m_scrollPinningBehavior { DoNotPin };
- ScrollingNodeID m_latchedNode { 0 };
-
- unsigned m_fixedOrStickyNodeCount { 0 };
-
- bool m_rubberBandsAtLeft { true };
- bool m_rubberBandsAtRight { true };
- bool m_rubberBandsAtTop { true };
- bool m_rubberBandsAtBottom { true };
- bool m_mainFramePinnedToTheLeft { true };
- bool m_mainFramePinnedToTheRight { true };
- bool m_mainFramePinnedToTheTop { true };
- bool m_mainFramePinnedToTheBottom { true };
- bool m_mainFrameIsRubberBanding { false };
- bool m_mainFrameIsScrollSnapping { false };
- bool m_scrollingPerformanceLoggingEnabled { false };
- bool m_isHandlingProgrammaticScroll { false };
-};
-
-} // namespace WebCore
-
-#define SPECIALIZE_TYPE_TRAITS_SCROLLING_TREE(ToValueTypeName, predicate) \
-SPECIALIZE_TYPE_TRAITS_BEGIN(ToValueTypeName) \
- static bool isType(const WebCore::ScrollingTree& tree) { return tree.predicate; } \
-SPECIALIZE_TYPE_TRAITS_END()
-#endif // ENABLE(ASYNC_SCROLLING)
-
-#endif // ScrollingTree_h
diff --git a/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp b/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp
deleted file mode 100644
index ac3dba059..000000000
--- a/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ScrollingTreeFrameScrollingNode.h"
-
-#if ENABLE(ASYNC_SCROLLING)
-
-#include "ScrollingStateTree.h"
-#include "ScrollingTree.h"
-
-namespace WebCore {
-
-ScrollingTreeFrameScrollingNode::ScrollingTreeFrameScrollingNode(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
- : ScrollingTreeScrollingNode(scrollingTree, FrameScrollingNode, nodeID)
-{
-}
-
-ScrollingTreeFrameScrollingNode::~ScrollingTreeFrameScrollingNode()
-{
-}
-
-void ScrollingTreeFrameScrollingNode::updateBeforeChildren(const ScrollingStateNode& stateNode)
-{
- ScrollingTreeScrollingNode::updateBeforeChildren(stateNode);
-
- const ScrollingStateFrameScrollingNode& state = downcast<ScrollingStateFrameScrollingNode>(stateNode);
-
- if (state.hasChangedProperty(ScrollingStateFrameScrollingNode::FrameScaleFactor))
- m_frameScaleFactor = state.frameScaleFactor();
-
- if (state.hasChangedProperty(ScrollingStateFrameScrollingNode::ReasonsForSynchronousScrolling))
- m_synchronousScrollingReasons = state.synchronousScrollingReasons();
-
- if (state.hasChangedProperty(ScrollingStateFrameScrollingNode::HeaderHeight))
- m_headerHeight = state.headerHeight();
-
- if (state.hasChangedProperty(ScrollingStateFrameScrollingNode::FooterHeight))
- m_footerHeight = state.footerHeight();
-
- if (state.hasChangedProperty(ScrollingStateFrameScrollingNode::BehaviorForFixedElements))
- m_behaviorForFixed = state.scrollBehaviorForFixedElements();
-
- if (state.hasChangedProperty(ScrollingStateFrameScrollingNode::TopContentInset))
- m_topContentInset = state.topContentInset();
-
- if (state.hasChangedProperty(ScrollingStateFrameScrollingNode::FixedElementsLayoutRelativeToFrame))
- m_fixedElementsLayoutRelativeToFrame = state.fixedElementsLayoutRelativeToFrame();
-}
-
-void ScrollingTreeFrameScrollingNode::scrollBy(const FloatSize& delta)
-{
- setScrollPosition(scrollPosition() + delta);
-}
-
-void ScrollingTreeFrameScrollingNode::scrollByWithoutContentEdgeConstraints(const FloatSize& offset)
-{
- setScrollPositionWithoutContentEdgeConstraints(scrollPosition() + offset);
-}
-
-void ScrollingTreeFrameScrollingNode::setScrollPosition(const FloatPoint& scrollPosition)
-{
- FloatPoint newScrollPosition = scrollPosition.constrainedBetween(minimumScrollPosition(), maximumScrollPosition());
- setScrollPositionWithoutContentEdgeConstraints(newScrollPosition);
-}
-
-FloatSize ScrollingTreeFrameScrollingNode::viewToContentsOffset(const FloatPoint& scrollPosition) const
-{
- return toFloatSize(scrollPosition) - FloatSize(0, headerHeight() + topContentInset());
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(ASYNC_SCROLLING)
diff --git a/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.h b/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.h
deleted file mode 100644
index 92b01f017..000000000
--- a/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScrollingTreeFrameScrollingNode_h
-#define ScrollingTreeFrameScrollingNode_h
-
-#if ENABLE(ASYNC_SCROLLING)
-
-#include "ScrollingTreeScrollingNode.h"
-
-namespace WebCore {
-
-class PlatformWheelEvent;
-class ScrollingTree;
-class ScrollingStateScrollingNode;
-
-class ScrollingTreeFrameScrollingNode : public ScrollingTreeScrollingNode {
-public:
- virtual ~ScrollingTreeFrameScrollingNode();
-
- virtual void updateBeforeChildren(const ScrollingStateNode&) override;
-
- // FIXME: We should implement this when we support ScrollingTreeScrollingNodes as children.
- virtual void updateLayersAfterAncestorChange(const ScrollingTreeNode& /*changedNode*/, const FloatRect& /*fixedPositionRect*/, const FloatSize& /*cumulativeDelta*/) override { }
-
- virtual void handleWheelEvent(const PlatformWheelEvent&) override = 0;
- virtual void setScrollPosition(const FloatPoint&) override;
- virtual void setScrollPositionWithoutContentEdgeConstraints(const FloatPoint&) override = 0;
-
- virtual void updateLayersAfterViewportChange(const FloatRect& fixedPositionRect, double scale) override = 0;
- virtual void updateLayersAfterDelegatedScroll(const FloatPoint&) override { }
-
- SynchronousScrollingReasons synchronousScrollingReasons() const { return m_synchronousScrollingReasons; }
- bool shouldUpdateScrollLayerPositionSynchronously() const { return m_synchronousScrollingReasons; }
- bool fixedElementsLayoutRelativeToFrame() const { return m_fixedElementsLayoutRelativeToFrame; }
-
- FloatSize viewToContentsOffset(const FloatPoint& scrollPosition) const;
-
-protected:
- ScrollingTreeFrameScrollingNode(ScrollingTree&, ScrollingNodeID);
-
- void scrollBy(const FloatSize&);
- void scrollByWithoutContentEdgeConstraints(const FloatSize&);
-
- float frameScaleFactor() const { return m_frameScaleFactor; }
- int headerHeight() const { return m_headerHeight; }
- int footerHeight() const { return m_footerHeight; }
- float topContentInset() const { return m_topContentInset; }
-
- ScrollBehaviorForFixedElements scrollBehaviorForFixedElements() const { return m_behaviorForFixed; }
-
-private:
- float m_frameScaleFactor { 1 };
- float m_topContentInset { 0 };
-
- int m_headerHeight { 0 };
- int m_footerHeight { 0 };
-
- SynchronousScrollingReasons m_synchronousScrollingReasons { 0 };
- ScrollBehaviorForFixedElements m_behaviorForFixed { StickToDocumentBounds };
-
- bool m_fixedElementsLayoutRelativeToFrame { false };
-};
-
-} // namespace WebCore
-
-SPECIALIZE_TYPE_TRAITS_SCROLLING_NODE(ScrollingTreeFrameScrollingNode, isFrameScrollingNode())
-
-#endif // ENABLE(ASYNC_SCROLLING)
-
-#endif // ScrollingTreeScrollingNode_h
diff --git a/Source/WebCore/page/scrolling/ScrollingTreeNode.cpp b/Source/WebCore/page/scrolling/ScrollingTreeNode.cpp
deleted file mode 100644
index 8c4111822..000000000
--- a/Source/WebCore/page/scrolling/ScrollingTreeNode.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ScrollingTreeNode.h"
-
-#if ENABLE(ASYNC_SCROLLING)
-
-#include "ScrollingStateTree.h"
-
-namespace WebCore {
-
-ScrollingTreeNode::ScrollingTreeNode(ScrollingTree& scrollingTree, ScrollingNodeType nodeType, ScrollingNodeID nodeID)
- : m_scrollingTree(scrollingTree)
- , m_nodeType(nodeType)
- , m_nodeID(nodeID)
- , m_parent(nullptr)
-{
-}
-
-ScrollingTreeNode::~ScrollingTreeNode()
-{
-}
-
-void ScrollingTreeNode::appendChild(PassRefPtr<ScrollingTreeNode> childNode)
-{
- childNode->setParent(this);
-
- if (!m_children)
- m_children = std::make_unique<ScrollingTreeChildrenVector>();
-
- m_children->append(childNode);
-}
-
-void ScrollingTreeNode::removeChild(ScrollingTreeNode* node)
-{
- if (!m_children)
- return;
-
- size_t index = m_children->find(node);
-
- // The index will be notFound if the node to remove is a deeper-than-1-level descendant or
- // if node is the root state node.
- if (index != notFound) {
- m_children->remove(index);
- return;
- }
-
- for (auto& child : *m_children)
- child->removeChild(node);
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(ASYNC_SCROLLING)
diff --git a/Source/WebCore/page/scrolling/ScrollingTreeNode.h b/Source/WebCore/page/scrolling/ScrollingTreeNode.h
deleted file mode 100644
index dad214f22..000000000
--- a/Source/WebCore/page/scrolling/ScrollingTreeNode.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScrollingTreeNode_h
-#define ScrollingTreeNode_h
-
-#if ENABLE(ASYNC_SCROLLING)
-
-#include "IntRect.h"
-#include "ScrollTypes.h"
-#include "ScrollingCoordinator.h"
-#include <wtf/RefCounted.h>
-#include <wtf/TypeCasts.h>
-
-namespace WebCore {
-
-class ScrollingStateFixedNode;
-class ScrollingStateNode;
-class ScrollingStateScrollingNode;
-
-class ScrollingTreeNode : public RefCounted<ScrollingTreeNode> {
-public:
- virtual ~ScrollingTreeNode();
-
- ScrollingNodeType nodeType() const { return m_nodeType; }
- ScrollingNodeID scrollingNodeID() const { return m_nodeID; }
-
- bool isFixedNode() const { return nodeType() == FixedNode; }
- bool isStickyNode() const { return nodeType() == StickyNode; }
- bool isScrollingNode() const { return nodeType() == FrameScrollingNode || nodeType() == OverflowScrollingNode; }
- bool isFrameScrollingNode() const { return nodeType() == FrameScrollingNode; }
- bool isOverflowScrollingNode() const { return nodeType() == OverflowScrollingNode; }
-
- virtual void updateBeforeChildren(const ScrollingStateNode&) = 0;
- virtual void updateAfterChildren(const ScrollingStateNode&) { }
-
- virtual void updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& fixedPositionRect, const FloatSize& cumulativeDelta) = 0;
-
- ScrollingTreeNode* parent() const { return m_parent; }
- void setParent(ScrollingTreeNode* parent) { m_parent = parent; }
-
- typedef Vector<RefPtr<ScrollingTreeNode>> ScrollingTreeChildrenVector;
- ScrollingTreeChildrenVector* children() { return m_children.get(); }
-
- void appendChild(PassRefPtr<ScrollingTreeNode>);
- void removeChild(ScrollingTreeNode*);
-
-protected:
- ScrollingTreeNode(ScrollingTree&, ScrollingNodeType, ScrollingNodeID);
- ScrollingTree& scrollingTree() const { return m_scrollingTree; }
-
- std::unique_ptr<ScrollingTreeChildrenVector> m_children;
-
-private:
- ScrollingTree& m_scrollingTree;
-
- const ScrollingNodeType m_nodeType;
- const ScrollingNodeID m_nodeID;
-
- ScrollingTreeNode* m_parent;
-};
-
-} // namespace WebCore
-
-#define SPECIALIZE_TYPE_TRAITS_SCROLLING_NODE(ToValueTypeName, predicate) \
-SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToValueTypeName) \
- static bool isType(const WebCore::ScrollingTreeNode& node) { return node.predicate; } \
-SPECIALIZE_TYPE_TRAITS_END()
-
-#endif // ENABLE(ASYNC_SCROLLING)
-
-#endif // ScrollingTreeNode_h
diff --git a/Source/WebCore/page/scrolling/ScrollingTreeOverflowScrollingNode.cpp b/Source/WebCore/page/scrolling/ScrollingTreeOverflowScrollingNode.cpp
deleted file mode 100644
index 013e350e6..000000000
--- a/Source/WebCore/page/scrolling/ScrollingTreeOverflowScrollingNode.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ScrollingTreeOverflowScrollingNode.h"
-
-#if ENABLE(ASYNC_SCROLLING)
-
-#include "ScrollingStateTree.h"
-#include "ScrollingTree.h"
-
-namespace WebCore {
-
-ScrollingTreeOverflowScrollingNode::ScrollingTreeOverflowScrollingNode(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
- : ScrollingTreeScrollingNode(scrollingTree, OverflowScrollingNode, nodeID)
-{
-}
-
-ScrollingTreeOverflowScrollingNode::~ScrollingTreeOverflowScrollingNode()
-{
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(ASYNC_SCROLLING)
diff --git a/Source/WebCore/page/scrolling/ScrollingTreeOverflowScrollingNode.h b/Source/WebCore/page/scrolling/ScrollingTreeOverflowScrollingNode.h
deleted file mode 100644
index 42a4f4bbb..000000000
--- a/Source/WebCore/page/scrolling/ScrollingTreeOverflowScrollingNode.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScrollingTreeOverflowScrollingNode_h
-#define ScrollingTreeOverflowScrollingNode_h
-
-#if ENABLE(ASYNC_SCROLLING)
-
-#include "ScrollingTreeScrollingNode.h"
-
-namespace WebCore {
-
-class ScrollingTreeOverflowScrollingNode : public ScrollingTreeScrollingNode {
-public:
- WEBCORE_EXPORT virtual ~ScrollingTreeOverflowScrollingNode();
-
-
-protected:
- WEBCORE_EXPORT ScrollingTreeOverflowScrollingNode(ScrollingTree&, ScrollingNodeID);
-};
-
-} // namespace WebCore
-
-SPECIALIZE_TYPE_TRAITS_SCROLLING_NODE(ScrollingTreeOverflowScrollingNode, isOverflowScrollingNode())
-
-#endif // ENABLE(ASYNC_SCROLLING)
-
-#endif // ScrollingTreeOverflowScrollingNode_h
diff --git a/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp b/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp
deleted file mode 100644
index 8457e19c0..000000000
--- a/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ScrollingTreeScrollingNode.h"
-
-#if ENABLE(ASYNC_SCROLLING)
-
-#include "ScrollingStateTree.h"
-#include "ScrollingTree.h"
-
-namespace WebCore {
-
-ScrollingTreeScrollingNode::ScrollingTreeScrollingNode(ScrollingTree& scrollingTree, ScrollingNodeType nodeType, ScrollingNodeID nodeID)
- : ScrollingTreeNode(scrollingTree, nodeType, nodeID)
-{
-}
-
-ScrollingTreeScrollingNode::~ScrollingTreeScrollingNode()
-{
-}
-
-void ScrollingTreeScrollingNode::updateBeforeChildren(const ScrollingStateNode& stateNode)
-{
- const ScrollingStateScrollingNode& state = downcast<ScrollingStateScrollingNode>(stateNode);
-
- if (state.hasChangedProperty(ScrollingStateScrollingNode::ScrollableAreaSize))
- m_scrollableAreaSize = state.scrollableAreaSize();
-
- if (state.hasChangedProperty(ScrollingStateScrollingNode::TotalContentsSize)) {
- if (scrollingTree().isRubberBandInProgress())
- m_totalContentsSizeForRubberBand = m_totalContentsSize;
- else
- m_totalContentsSizeForRubberBand = state.totalContentsSize();
-
- m_totalContentsSize = state.totalContentsSize();
- }
-
- if (state.hasChangedProperty(ScrollingStateScrollingNode::ReachableContentsSize))
- m_reachableContentsSize = state.reachableContentsSize();
-
- if (state.hasChangedProperty(ScrollingStateScrollingNode::ScrollPosition))
- m_lastCommittedScrollPosition = state.scrollPosition();
-
- if (state.hasChangedProperty(ScrollingStateScrollingNode::ScrollOrigin))
- m_scrollOrigin = state.scrollOrigin();
-
-#if ENABLE(CSS_SCROLL_SNAP)
- if (state.hasChangedProperty(ScrollingStateScrollingNode::HorizontalSnapOffsets))
- m_horizontalSnapOffsets = state.horizontalSnapOffsets();
-
- if (state.hasChangedProperty(ScrollingStateScrollingNode::VerticalSnapOffsets))
- m_verticalSnapOffsets = state.verticalSnapOffsets();
-
- if (state.hasChangedProperty(ScrollingStateScrollingNode::CurrentHorizontalSnapOffsetIndex))
- m_currentHorizontalSnapPointIndex = state.currentHorizontalSnapPointIndex();
-
- if (state.hasChangedProperty(ScrollingStateScrollingNode::CurrentVerticalSnapOffsetIndex))
- m_currentVerticalSnapPointIndex = state.currentVerticalSnapPointIndex();
-#endif
-
- if (state.hasChangedProperty(ScrollingStateScrollingNode::ScrollableAreaParams))
- m_scrollableAreaParameters = state.scrollableAreaParameters();
-}
-
-void ScrollingTreeScrollingNode::updateAfterChildren(const ScrollingStateNode& stateNode)
-{
- const ScrollingStateScrollingNode& scrollingStateNode = downcast<ScrollingStateScrollingNode>(stateNode);
- if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::RequestedScrollPosition))
- scrollingTree().scrollingTreeNodeRequestsScroll(scrollingNodeID(), scrollingStateNode.requestedScrollPosition(), scrollingStateNode.requestedScrollPositionRepresentsProgrammaticScroll());
-}
-
-void ScrollingTreeScrollingNode::updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& fixedPositionRect, const FloatSize& cumulativeDelta)
-{
- if (!m_children)
- return;
-
- for (auto& child : *m_children)
- child->updateLayersAfterAncestorChange(changedNode, fixedPositionRect, cumulativeDelta);
-}
-
-void ScrollingTreeScrollingNode::setScrollPosition(const FloatPoint& scrollPosition)
-{
- FloatPoint newScrollPosition = scrollPosition.constrainedBetween(minimumScrollPosition(), maximumScrollPosition());
- setScrollPositionWithoutContentEdgeConstraints(newScrollPosition);
-}
-
-void ScrollingTreeScrollingNode::setScrollPositionWithoutContentEdgeConstraints(const FloatPoint& scrollPosition)
-{
- setScrollLayerPosition(scrollPosition);
- scrollingTree().scrollingTreeNodeDidScroll(scrollingNodeID(), scrollPosition);
-}
-
-FloatPoint ScrollingTreeScrollingNode::minimumScrollPosition() const
-{
- return FloatPoint();
-}
-
-FloatPoint ScrollingTreeScrollingNode::maximumScrollPosition() const
-{
- FloatPoint contentSizePoint(totalContentsSize());
- return FloatPoint(contentSizePoint - scrollableAreaSize()).expandedTo(FloatPoint());
-}
-
-
-} // namespace WebCore
-
-#endif // ENABLE(ASYNC_SCROLLING)
diff --git a/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h b/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h
deleted file mode 100644
index 07c896c80..000000000
--- a/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScrollingTreeScrollingNode_h
-#define ScrollingTreeScrollingNode_h
-
-#if ENABLE(ASYNC_SCROLLING)
-
-#include "IntRect.h"
-#include "ScrollTypes.h"
-#include "ScrollingCoordinator.h"
-#include "ScrollingTreeNode.h"
-
-namespace WebCore {
-
-class ScrollingTree;
-class ScrollingStateScrollingNode;
-
-class ScrollingTreeScrollingNode : public ScrollingTreeNode {
-public:
- virtual ~ScrollingTreeScrollingNode();
-
- WEBCORE_EXPORT virtual void updateBeforeChildren(const ScrollingStateNode&) override;
- WEBCORE_EXPORT virtual void updateAfterChildren(const ScrollingStateNode&) override;
-
- WEBCORE_EXPORT virtual 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_horizontalSnapOffsets; }
- const Vector<float>& verticalSnapOffsets() const { return m_verticalSnapOffsets; }
- 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&) = 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; }
-
- // If the totalContentsSize changes in the middle of a rubber-band, we still want to use the old totalContentsSize for the sake of
- // computing the stretchAmount(). Using the old value will keep the animation smooth. When there is no rubber-band in progress at
- // all, m_totalContentsSizeForRubberBand should be equivalent to m_totalContentsSize.
- 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; }
-
-private:
- FloatSize m_scrollableAreaSize;
- FloatSize m_totalContentsSize;
- FloatSize m_totalContentsSizeForRubberBand;
- FloatSize m_reachableContentsSize;
- FloatPoint m_lastCommittedScrollPosition;
- IntPoint m_scrollOrigin;
-#if ENABLE(CSS_SCROLL_SNAP)
- Vector<float> m_horizontalSnapOffsets;
- Vector<float> m_verticalSnapOffsets;
- unsigned m_currentHorizontalSnapPointIndex { 0 };
- unsigned m_currentVerticalSnapPointIndex { 0 };
-#endif
- ScrollableAreaParameters m_scrollableAreaParameters;
-};
-
-} // namespace WebCore
-
-SPECIALIZE_TYPE_TRAITS_SCROLLING_NODE(ScrollingTreeScrollingNode, isScrollingNode())
-
-#endif // ENABLE(ASYNC_SCROLLING)
-
-#endif // ScrollingTreeScrollingNode_h
diff --git a/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp b/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp
deleted file mode 100644
index 483986af5..000000000
--- a/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright (C) 2014-2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ThreadedScrollingTree.h"
-
-#if ENABLE(ASYNC_SCROLLING)
-
-#include "AsyncScrollingCoordinator.h"
-#include "PlatformWheelEvent.h"
-#include "ScrollingThread.h"
-#include "ScrollingTreeFixedNode.h"
-#include "ScrollingTreeNode.h"
-#include "ScrollingTreeScrollingNode.h"
-#include "ScrollingTreeStickyNode.h"
-#include <wtf/RunLoop.h>
-#include <wtf/TemporaryChange.h>
-
-namespace WebCore {
-
-ThreadedScrollingTree::ThreadedScrollingTree(AsyncScrollingCoordinator* scrollingCoordinator)
- : m_scrollingCoordinator(scrollingCoordinator)
-{
-}
-
-ThreadedScrollingTree::~ThreadedScrollingTree()
-{
- // invalidate() should have cleared m_scrollingCoordinator.
- ASSERT(!m_scrollingCoordinator);
-}
-
-ScrollingTree::EventResult ThreadedScrollingTree::tryToHandleWheelEvent(const PlatformWheelEvent& wheelEvent)
-{
- if (shouldHandleWheelEventSynchronously(wheelEvent))
- return SendToMainThread;
-
- if (willWheelEventStartSwipeGesture(wheelEvent))
- return DidNotHandleEvent;
-
- RefPtr<ThreadedScrollingTree> threadedScrollingTree(this);
- ScrollingThread::dispatch([threadedScrollingTree, wheelEvent] {
- threadedScrollingTree->handleWheelEvent(wheelEvent);
- });
-
- return DidHandleEvent;
-}
-
-void ThreadedScrollingTree::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
-{
- ASSERT(ScrollingThread::isCurrentThread());
- ScrollingTree::handleWheelEvent(wheelEvent);
-}
-
-void ThreadedScrollingTree::invalidate()
-{
- // Invalidate is dispatched by the ScrollingCoordinator class on the ScrollingThread
- // to break the reference cycle between ScrollingTree and ScrollingCoordinator when the
- // ScrollingCoordinator's page is destroyed.
- ASSERT(ScrollingThread::isCurrentThread());
-
- // Since this can potentially be the last reference to the scrolling coordinator,
- // we need to release it on the main thread since it has member variables (such as timers)
- // that expect to be destroyed from the main thread.
- ScrollingCoordinator* scrollingCoordinator = m_scrollingCoordinator.release().leakRef();
- RunLoop::main().dispatch([scrollingCoordinator] {
- scrollingCoordinator->deref();
- });
-}
-
-void ThreadedScrollingTree::commitNewTreeState(std::unique_ptr<ScrollingStateTree> scrollingStateTree)
-{
- ASSERT(ScrollingThread::isCurrentThread());
- ScrollingTree::commitNewTreeState(WTFMove(scrollingStateTree));
-}
-
-void ThreadedScrollingTree::scrollingTreeNodeDidScroll(ScrollingNodeID nodeID, const FloatPoint& scrollPosition, SetOrSyncScrollingLayerPosition scrollingLayerPositionAction)
-{
- if (!m_scrollingCoordinator)
- return;
-
- if (nodeID == rootNode()->scrollingNodeID())
- setMainFrameScrollPosition(scrollPosition);
-
- RefPtr<AsyncScrollingCoordinator> scrollingCoordinator = m_scrollingCoordinator;
- bool localIsHandlingProgrammaticScroll = isHandlingProgrammaticScroll();
-
- RunLoop::main().dispatch([scrollingCoordinator, nodeID, scrollPosition, localIsHandlingProgrammaticScroll, scrollingLayerPositionAction] {
- scrollingCoordinator->scheduleUpdateScrollPositionAfterAsyncScroll(nodeID, scrollPosition, localIsHandlingProgrammaticScroll, scrollingLayerPositionAction);
- });
-}
-
-void ThreadedScrollingTree::currentSnapPointIndicesDidChange(ScrollingNodeID nodeID, unsigned horizontal, unsigned vertical)
-{
- if (!m_scrollingCoordinator)
- return;
-
- RefPtr<AsyncScrollingCoordinator> scrollingCoordinator = m_scrollingCoordinator;
- RunLoop::main().dispatch([scrollingCoordinator, nodeID, horizontal, vertical] {
- scrollingCoordinator->setActiveScrollSnapIndices(nodeID, horizontal, vertical);
- });
-}
-
-#if PLATFORM(MAC)
-void ThreadedScrollingTree::handleWheelEventPhase(PlatformWheelEventPhase phase)
-{
- if (!m_scrollingCoordinator)
- return;
-
- RefPtr<AsyncScrollingCoordinator> scrollingCoordinator = m_scrollingCoordinator;
- RunLoop::main().dispatch([scrollingCoordinator, phase] {
- scrollingCoordinator->handleWheelEventPhase(phase);
- });
-}
-
-void ThreadedScrollingTree::setActiveScrollSnapIndices(ScrollingNodeID nodeID, unsigned horizontalIndex, unsigned verticalIndex)
-{
- if (!m_scrollingCoordinator)
- return;
-
- RefPtr<AsyncScrollingCoordinator> scrollingCoordinator = m_scrollingCoordinator;
- RunLoop::main().dispatch([scrollingCoordinator, nodeID, horizontalIndex, verticalIndex] {
- scrollingCoordinator->setActiveScrollSnapIndices(nodeID, horizontalIndex, verticalIndex);
- });
-}
-
-void ThreadedScrollingTree::deferTestsForReason(WheelEventTestTrigger::ScrollableAreaIdentifier identifier, WheelEventTestTrigger::DeferTestTriggerReason reason)
-{
- if (!m_scrollingCoordinator)
- return;
-
- RefPtr<AsyncScrollingCoordinator> scrollingCoordinator = m_scrollingCoordinator;
- RunLoop::main().dispatch([scrollingCoordinator, identifier, reason] {
- scrollingCoordinator->deferTestsForReason(identifier, reason);
- });
-}
-
-void ThreadedScrollingTree::removeTestDeferralForReason(WheelEventTestTrigger::ScrollableAreaIdentifier identifier, WheelEventTestTrigger::DeferTestTriggerReason reason)
-{
- if (!m_scrollingCoordinator)
- return;
-
- RefPtr<AsyncScrollingCoordinator> scrollingCoordinator = m_scrollingCoordinator;
- RunLoop::main().dispatch([scrollingCoordinator, identifier, reason] {
- scrollingCoordinator->removeTestDeferralForReason(identifier, reason);
- });
-}
-
-#endif
-
-} // namespace WebCore
-
-#endif // ENABLE(ASYNC_SCROLLING)
diff --git a/Source/WebCore/page/scrolling/ThreadedScrollingTree.h b/Source/WebCore/page/scrolling/ThreadedScrollingTree.h
deleted file mode 100644
index 6bc801b70..000000000
--- a/Source/WebCore/page/scrolling/ThreadedScrollingTree.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2014-2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ThreadedScrollingTree_h
-#define ThreadedScrollingTree_h
-
-#if ENABLE(ASYNC_SCROLLING)
-
-#include "ScrollingStateTree.h"
-#include "ScrollingTree.h"
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefPtr.h>
-
-namespace WebCore {
-
-class AsyncScrollingCoordinator;
-
-// The ThreadedScrollingTree class lives almost exclusively on the scrolling thread and manages the
-// hierarchy of scrollable regions on the page. It's also responsible for dispatching events
-// to the correct scrolling tree nodes or dispatching events back to the ScrollingCoordinator
-// object on the main thread if they can't be handled on the scrolling thread for various reasons.
-class ThreadedScrollingTree : public ScrollingTree {
-public:
- virtual ~ThreadedScrollingTree();
-
- virtual void commitNewTreeState(std::unique_ptr<ScrollingStateTree>) override;
-
- virtual void handleWheelEvent(const PlatformWheelEvent&) override;
-
- // Can be called from any thread. Will try to handle the wheel event on the scrolling thread.
- // Returns true if the wheel event can be handled on the scrolling thread and false if the
- // event must be sent again to the WebCore event handler.
- virtual EventResult tryToHandleWheelEvent(const PlatformWheelEvent&) override;
-
- virtual void invalidate() override;
-
-protected:
- explicit ThreadedScrollingTree(AsyncScrollingCoordinator*);
-
- virtual void scrollingTreeNodeDidScroll(ScrollingNodeID, const FloatPoint& scrollPosition, SetOrSyncScrollingLayerPosition = SyncScrollingLayerPosition) override;
- void currentSnapPointIndicesDidChange(ScrollingNodeID, unsigned horizontal, unsigned vertical) override;
-#if PLATFORM(MAC)
- void handleWheelEventPhase(PlatformWheelEventPhase) override;
- void setActiveScrollSnapIndices(ScrollingNodeID, unsigned horizontalIndex, unsigned verticalIndex) override;
- void deferTestsForReason(WheelEventTestTrigger::ScrollableAreaIdentifier, WheelEventTestTrigger::DeferTestTriggerReason) override;
- void removeTestDeferralForReason(WheelEventTestTrigger::ScrollableAreaIdentifier, WheelEventTestTrigger::DeferTestTriggerReason) override;
-#endif
-
-private:
- virtual bool isThreadedScrollingTree() const override { return true; }
-
- RefPtr<AsyncScrollingCoordinator> m_scrollingCoordinator;
-};
-
-} // namespace WebCore
-
-SPECIALIZE_TYPE_TRAITS_SCROLLING_TREE(WebCore::ThreadedScrollingTree, isThreadedScrollingTree())
-
-#endif // ENABLE(ASYNC_SCROLLING)
-
-#endif // ThreadedScrollingTree_h
diff --git a/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp b/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp
deleted file mode 100644
index 09d3fa5ee..000000000
--- a/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if USE(COORDINATED_GRAPHICS)
-
-#include "ScrollingCoordinatorCoordinatedGraphics.h"
-
-#include "CoordinatedGraphicsLayer.h"
-#include "FrameView.h"
-#include "HostWindow.h"
-#include "Page.h"
-#include "RenderLayer.h"
-#include "RenderLayerBacking.h"
-#include "ScrollingConstraints.h"
-#include "ScrollingStateFixedNode.h"
-#include "ScrollingStateScrollingNode.h"
-#include "ScrollingStateStickyNode.h"
-#include "ScrollingStateTree.h"
-#include "Settings.h"
-
-namespace WebCore {
-
-ScrollingCoordinatorCoordinatedGraphics::ScrollingCoordinatorCoordinatedGraphics(Page* page)
- : ScrollingCoordinator(page)
- , m_scrollingStateTree(std::make_unique<ScrollingStateTree>())
-{
-}
-
-ScrollingCoordinatorCoordinatedGraphics::~ScrollingCoordinatorCoordinatedGraphics()
-{
-}
-
-ScrollingNodeID ScrollingCoordinatorCoordinatedGraphics::attachToStateTree(ScrollingNodeType nodeType, ScrollingNodeID newNodeID, ScrollingNodeID parentID)
-{
- return m_scrollingStateTree->attachNode(nodeType, newNodeID, parentID);
-}
-
-void ScrollingCoordinatorCoordinatedGraphics::detachFromStateTree(ScrollingNodeID nodeID)
-{
- ScrollingStateNode* node = m_scrollingStateTree->stateNodeForID(nodeID);
- if (node && node->nodeType() == FixedNode)
- toCoordinatedGraphicsLayer(node->layer())->setFixedToViewport(false);
-
- m_scrollingStateTree->detachNode(nodeID);
-}
-
-void ScrollingCoordinatorCoordinatedGraphics::clearStateTree()
-{
- m_scrollingStateTree->clear();
-}
-
-void ScrollingCoordinatorCoordinatedGraphics::updateViewportConstrainedNode(ScrollingNodeID nodeID, const ViewportConstraints& constraints, GraphicsLayer* graphicsLayer)
-{
- ASSERT(supportsFixedPositionLayers());
-
- ScrollingStateNode* node = m_scrollingStateTree->stateNodeForID(nodeID);
- if (!node)
- return;
-
- switch (constraints.constraintType()) {
- case ViewportConstraints::FixedPositionConstraint: {
- toCoordinatedGraphicsLayer(graphicsLayer)->setFixedToViewport(true); // FIXME : Use constraints!
- downcast<ScrollingStateFixedNode>(*node).setLayer(graphicsLayer);
- break;
- }
- case ViewportConstraints::StickyPositionConstraint:
- break; // FIXME : Support sticky elements.
- default:
- ASSERT_NOT_REACHED();
- }
-}
-
-void ScrollingCoordinatorCoordinatedGraphics::scrollableAreaScrollLayerDidChange(ScrollableArea& scrollableArea)
-{
- CoordinatedGraphicsLayer* layer = toCoordinatedGraphicsLayer(scrollLayerForScrollableArea(scrollableArea));
- if (!layer)
- return;
-
- layer->setScrollableArea(&scrollableArea);
-}
-
-void ScrollingCoordinatorCoordinatedGraphics::willDestroyScrollableArea(ScrollableArea& scrollableArea)
-{
- CoordinatedGraphicsLayer* layer = toCoordinatedGraphicsLayer(scrollLayerForScrollableArea(scrollableArea));
- if (!layer)
- return;
-
- layer->setScrollableArea(nullptr);
-}
-
-bool ScrollingCoordinatorCoordinatedGraphics::requestScrollPositionUpdate(FrameView& frameView, const IntPoint& scrollPosition)
-{
- if (!frameView.delegatesScrolling())
- return false;
-
- frameView.hostWindow()->delegatedScrollRequested(scrollPosition);
- return true;
-}
-
-} // namespace WebCore
-
-#endif // USE(COORDINATED_GRAPHICS)
diff --git a/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.h b/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.h
deleted file mode 100644
index a1200725e..000000000
--- a/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScrollingCoordinatorCoordinatedGraphics_h
-#define ScrollingCoordinatorCoordinatedGraphics_h
-
-#if USE(COORDINATED_GRAPHICS)
-
-#include "ScrollingCoordinator.h"
-
-namespace WebCore {
-
-class ScrollingStateTree;
-
-class ScrollingCoordinatorCoordinatedGraphics : public ScrollingCoordinator {
-public:
- explicit ScrollingCoordinatorCoordinatedGraphics(Page*);
- virtual ~ScrollingCoordinatorCoordinatedGraphics();
-
- virtual bool supportsFixedPositionLayers() const override { return true; }
-
- virtual ScrollingNodeID attachToStateTree(ScrollingNodeType, ScrollingNodeID newNodeID, ScrollingNodeID parentID) override;
- virtual void detachFromStateTree(ScrollingNodeID) override;
- virtual void clearStateTree() override;
-
- virtual void updateViewportConstrainedNode(ScrollingNodeID, const ViewportConstraints&, GraphicsLayer*) override;
-
- virtual void scrollableAreaScrollLayerDidChange(ScrollableArea&) override;
- virtual void willDestroyScrollableArea(ScrollableArea&) override;
-
- virtual bool requestScrollPositionUpdate(FrameView&, const IntPoint&) override;
-
-private:
- std::unique_ptr<ScrollingStateTree> m_scrollingStateTree;
-};
-
-} // namespace WebCore
-
-#endif // USE(COORDINATED_GRAPHICS)
-
-#endif // ScrollingCoordinatorCoordinatedGraphics_h
diff --git a/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingStateNodeCoordinatedGraphics.cpp b/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingStateNodeCoordinatedGraphics.cpp
deleted file mode 100644
index aeb6223c1..000000000
--- a/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingStateNodeCoordinatedGraphics.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2013 Intel Corporation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ScrollingStateNode.h"
-
-#include "GraphicsLayer.h"
-#include "NotImplemented.h"
-#include "ScrollingStateTree.h"
-
-#if USE(COORDINATED_GRAPHICS)
-
-namespace WebCore {
-
-void LayerRepresentation::retainPlatformLayer(PlatformLayer*)
-{
- notImplemented();
-}
-
-void LayerRepresentation::releasePlatformLayer(PlatformLayer*)
-{
- notImplemented();
-}
-
-} // namespace WebCore
-
-#endif // USE(COORDINATED_GRAPHICS)