WebKit Bugzilla
Attachment 360979 Details for
Bug 194193
: Merge AsyncScrollingCoordinator into ScrollingCoordinator
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
wip
merge-async-scrolling-coordinator-2.patch (text/plain), 120.31 KB, created by
Antti Koivisto
on 2019-02-02 07:51:52 PST
(
hide
)
Description:
wip
Filename:
MIME Type:
Creator:
Antti Koivisto
Created:
2019-02-02 07:51:52 PST
Size:
120.31 KB
patch
obsolete
>Index: Source/WebCore/Sources.txt >=================================================================== >--- Source/WebCore/Sources.txt (revision 240892) >+++ Source/WebCore/Sources.txt (working copy) >@@ -1574,7 +1574,6 @@ page/csp/ContentSecurityPolicySource.cpp > page/csp/ContentSecurityPolicySourceList.cpp > page/csp/ContentSecurityPolicySourceListDirective.cpp > >-page/scrolling/AsyncScrollingCoordinator.cpp > page/scrolling/AxisScrollSnapOffsets.cpp > page/scrolling/ScrollLatchingState.cpp > page/scrolling/ScrollingConstraints.cpp >Index: Source/WebCore/dom/Element.h >=================================================================== >--- Source/WebCore/dom/Element.h (revision 240892) >+++ Source/WebCore/dom/Element.h (working copy) >@@ -31,7 +31,6 @@ > #include "KeyframeAnimationOptions.h" > #include "ScrollToOptions.h" > #include "ScrollTypes.h" >-#include "ScrollingCoordinator.h" > #include "ShadowRootMode.h" > #include "SimulatedClickOptions.h" > #include "StyleChange.h" >Index: Source/WebCore/page/Frame.cpp >=================================================================== >--- Source/WebCore/page/Frame.cpp (revision 240892) >+++ Source/WebCore/page/Frame.cpp (working copy) >@@ -801,9 +801,6 @@ void Frame::willDetachPage() > if (page() && page()->focusController().focusedFrame() == this) > page()->focusController().setFocusedFrame(nullptr); > >- if (page() && page()->scrollingCoordinator() && m_view) >- page()->scrollingCoordinator()->willDestroyScrollableArea(*m_view); >- > #if PLATFORM(IOS_FAMILY) > if (WebThreadCountOfObservedDOMTimers() > 0 && m_page) { > LOG(ContentObservation, "Frame::willDetachPage: remove registered timers."); >Index: Source/WebCore/page/FrameView.cpp >=================================================================== >--- Source/WebCore/page/FrameView.cpp (revision 240892) >+++ Source/WebCore/page/FrameView.cpp (working copy) >@@ -365,11 +365,6 @@ void FrameView::prepareForDetach() > // When the view is no longer associated with a frame, it needs to be removed from the ax object cache > // right now, otherwise it won't be able to reach the topDocument()'s axObject cache later. > removeFromAXObjectCache(); >- >- if (frame().page()) { >- if (ScrollingCoordinator* scrollingCoordinator = frame().page()->scrollingCoordinator()) >- scrollingCoordinator->willDestroyScrollableArea(*this); >- } > } > > void FrameView::detachCustomScrollbars() >Index: Source/WebCore/page/Page.cpp >=================================================================== >--- Source/WebCore/page/Page.cpp (revision 240892) >+++ Source/WebCore/page/Page.cpp (working copy) >@@ -396,12 +396,13 @@ ViewportArguments Page::viewportArgument > > ScrollingCoordinator* Page::scrollingCoordinator() > { >+#if ENABLE(ASYNC_SCROLLING) > if (!m_scrollingCoordinator && m_settings->scrollingCoordinatorEnabled()) { > m_scrollingCoordinator = chrome().client().createScrollingCoordinator(*this); > if (!m_scrollingCoordinator) > m_scrollingCoordinator = ScrollingCoordinator::create(this); > } >- >+#endif > return m_scrollingCoordinator.get(); > } > >Index: Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp >=================================================================== >--- Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp (revision 240892) >+++ Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp (working copy) >@@ -1,786 +1 @@ >-/* >- * 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 "DebugPageOverlays.h" >-#include "Document.h" >-#include "EditorClient.h" >-#include "Frame.h" >-#include "FrameView.h" >-#include "GraphicsLayer.h" >-#include "Logging.h" >-#include "Page.h" >-#include "PerformanceLoggingClient.h" >-#include "ScrollAnimator.h" >-#include "ScrollingConstraints.h" >-#include "ScrollingStateFixedNode.h" >-#include "ScrollingStateFrameHostingNode.h" >-#include "ScrollingStateFrameScrollingNode.h" >-#include "ScrollingStateOverflowScrollingNode.h" >-#include "ScrollingStateStickyNode.h" >-#include "ScrollingStateTree.h" >-#include "Settings.h" >-#include "WheelEventTestTrigger.h" >-#include <wtf/ProcessID.h> >-#include <wtf/text/TextStream.h> >- >-namespace WebCore { >- >-AsyncScrollingCoordinator::AsyncScrollingCoordinator(Page* page) >- : ScrollingCoordinator(page) >- , m_updateNodeScrollPositionTimer(*this, &AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScrollTimerFired) >- , m_scrollingStateTree(std::make_unique<ScrollingStateTree>(this)) >-{ >-} >- >-AsyncScrollingCoordinator::~AsyncScrollingCoordinator() = default; >- >-void AsyncScrollingCoordinator::scrollingStateTreePropertiesChanged() >-{ >- scheduleTreeStateCommit(); >-} >- >-#if ENABLE(CSS_SCROLL_SNAP) >-static inline void setStateScrollingNodeSnapOffsetsAsFloat(ScrollingStateScrollingNode& node, ScrollEventAxis axis, const Vector<LayoutUnit>* snapOffsets, const Vector<ScrollOffsetRange<LayoutUnit>>* snapOffsetRanges, 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)); >- } >- >- Vector<ScrollOffsetRange<float>> snapOffsetRangesAsFloat; >- if (snapOffsetRanges) { >- snapOffsetRangesAsFloat.reserveInitialCapacity(snapOffsetRanges->size()); >- for (auto& range : *snapOffsetRanges) >- snapOffsetRangesAsFloat.uncheckedAppend({ roundToDevicePixel(range.start, deviceScaleFactor, false), roundToDevicePixel(range.end, deviceScaleFactor, false) }); >- } >- if (axis == ScrollEventAxis::Horizontal) { >- node.setHorizontalSnapOffsets(snapOffsetsAsFloat); >- node.setHorizontalSnapOffsetRanges(snapOffsetRangesAsFloat); >- } else { >- node.setVerticalSnapOffsets(snapOffsetsAsFloat); >- node.setVerticalSnapOffsetRanges(snapOffsetRangesAsFloat); >- } >-} >-#endif >- >-void AsyncScrollingCoordinator::setEventTrackingRegionsDirty() >-{ >- m_eventTrackingRegionsDirty = true; >- // We have to schedule a commit, but the computed non-fast region may not have actually changed. >- scheduleTreeStateCommit(); >-} >- >-void AsyncScrollingCoordinator::willCommitTree() >-{ >- updateEventTrackingRegions(); >-} >- >-void AsyncScrollingCoordinator::updateEventTrackingRegions() >-{ >- if (!m_eventTrackingRegionsDirty) >- return; >- >- if (!m_scrollingStateTree->rootStateNode()) >- return; >- >- m_scrollingStateTree->rootStateNode()->setEventTrackingRegions(absoluteEventTrackingRegions()); >- m_eventTrackingRegionsDirty = 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; >- >- setEventTrackingRegionsDirty(); >- if (!coordinatesScrollingForFrameView(frameView)) >- return; >- >- auto* node = m_scrollingStateTree->stateNodeForID(frameView.scrollingNodeID()); >- if (!node || !is<ScrollingStateFrameScrollingNode>(*node)) >- return; >- >- auto& frameScrollingNode = downcast<ScrollingStateFrameScrollingNode>(*node); >- >- auto* verticalScrollbar = frameView.verticalScrollbar(); >- auto* horizontalScrollbar = frameView.horizontalScrollbar(); >- frameScrollingNode.setScrollerImpsFromScrollbars(verticalScrollbar, horizontalScrollbar); >- >- frameScrollingNode.setFrameScaleFactor(frameView.frame().frameScaleFactor()); >- frameScrollingNode.setHeaderHeight(frameView.headerHeight()); >- frameScrollingNode.setFooterHeight(frameView.footerHeight()); >- frameScrollingNode.setTopContentInset(frameView.topContentInset()); >- >- frameScrollingNode.setVisualViewportEnabled(visualViewportEnabled()); >- frameScrollingNode.setLayoutViewport(frameView.layoutViewportRect()); >- frameScrollingNode.setAsyncFrameOrOverflowScrollingEnabled(asyncFrameOrOverflowScrollingEnabled()); >- >- frameScrollingNode.setMinLayoutViewportOrigin(frameView.minStableLayoutViewportOrigin()); >- frameScrollingNode.setMaxLayoutViewportOrigin(frameView.maxStableLayoutViewportOrigin()); >- >- frameScrollingNode.setScrollOrigin(frameView.scrollOrigin()); >- frameScrollingNode.setScrollableAreaSize(frameView.visibleContentRect().size()); >- frameScrollingNode.setTotalContentsSize(frameView.totalContentsSize()); >- frameScrollingNode.setReachableContentsSize(frameView.totalContentsSize()); >- frameScrollingNode.setFixedElementsLayoutRelativeToFrame(frameView.fixedElementsLayoutRelativeToFrame()); >- frameScrollingNode.setScrollBehaviorForFixedElements(frameView.scrollBehaviorForFixedElements()); >- >-#if ENABLE(CSS_SCROLL_SNAP) >- frameView.updateSnapOffsets(); >- updateScrollSnapPropertiesWithFrameView(frameView); >-#endif >- >-#if PLATFORM(COCOA) >- auto* page = frameView.frame().page(); >- if (page && page->expectsWheelEventTriggers()) { >- LOG(WheelEventTestTriggers, " AsyncScrollingCoordinator::frameViewLayoutUpdated: Expects wheel event test trigger=%d", page->expectsWheelEventTriggers()); >- frameScrollingNode.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(); >- scrollParameters.useDarkAppearanceForScrollbars = frameView.useDarkAppearanceForScrollbars(); >- >- frameScrollingNode.setScrollableAreaParameters(scrollParameters); >-} >- >-void AsyncScrollingCoordinator::updateExpectsWheelEventTestTriggerWithFrameView(const FrameView& frameView) >-{ >- auto* page = frameView.frame().page(); >- if (!page) >- return; >- >- auto* node = downcast<ScrollingStateFrameScrollingNode>(m_scrollingStateTree->stateNodeForID(frameView.scrollingNodeID())); >- if (!node) >- return; >- >- node->setExpectsWheelEventTestTrigger(page->expectsWheelEventTriggers()); >-} >- >-void AsyncScrollingCoordinator::frameViewEventTrackingRegionsChanged(FrameView& frameView) >-{ >- if (!m_scrollingStateTree->rootStateNode()) >- return; >- >- setEventTrackingRegionsDirty(); >- DebugPageOverlays::didChangeEventHandlers(frameView.frame()); >-} >- >-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.scrollingNodeID()) >- return; >- >- // If the root layer does not have a ScrollingStateNode, then we should create one. >- ensureRootStateNodeForFrameView(frameView); >- ASSERT(m_scrollingStateTree->stateNodeForID(frameView.scrollingNodeID())); >- >- ScrollingCoordinator::frameViewRootLayerDidChange(frameView); >- >- auto* node = downcast<ScrollingStateFrameScrollingNode>(m_scrollingStateTree->stateNodeForID(frameView.scrollingNodeID())); >- node->setScrolledContentsLayer(scrollLayerForFrameView(frameView)); >- node->setRootContentsLayer(rootContentsLayerForFrameView(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()); >- node->setVerticalScrollbarLayer(frameView.layerForVerticalScrollbar()); >- node->setHorizontalScrollbarLayer(frameView.layerForHorizontalScrollbar()); >-} >- >-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()->pageCacheState() != Document::NotInPageCache) >- updateScrollPositionAfterAsyncScroll(frameView.scrollingNodeID(), scrollPosition, WTF::nullopt, isProgrammaticScroll, ScrollingLayerPositionAction::Set); >- >- // 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()->pageCacheState() != Document::NotInPageCache) >- return true; >- >- auto* stateNode = downcast<ScrollingStateScrollingNode>(m_scrollingStateTree->stateNodeForID(frameView.scrollingNodeID())); >- if (!stateNode) >- return false; >- >- stateNode->setRequestedScrollPosition(scrollPosition, isProgrammaticScroll); >- return true; >-} >- >-void AsyncScrollingCoordinator::scheduleUpdateScrollPositionAfterAsyncScroll(ScrollingNodeID nodeID, const FloatPoint& scrollPosition, const Optional<FloatPoint>& layoutViewportOrigin, bool programmaticScroll, ScrollingLayerPositionAction scrollingLayerPositionAction) >-{ >- ScheduledScrollUpdate scrollUpdate(nodeID, scrollPosition, layoutViewportOrigin, 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; >- m_scheduledScrollUpdate.layoutViewportOrigin = layoutViewportOrigin; >- 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.layoutViewportOrigin, m_scheduledScrollUpdate.isProgrammaticScroll, m_scheduledScrollUpdate.updateLayerPositionAction); >- updateScrollPositionAfterAsyncScroll(nodeID, scrollPosition, layoutViewportOrigin, programmaticScroll, scrollingLayerPositionAction); >- return; >- } >- >- m_scheduledScrollUpdate = scrollUpdate; >- m_updateNodeScrollPositionTimer.startOneShot(0_s); >-} >- >-void AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScrollTimerFired() >-{ >- updateScrollPositionAfterAsyncScroll(m_scheduledScrollUpdate.nodeID, m_scheduledScrollUpdate.scrollPosition, m_scheduledScrollUpdate.layoutViewportOrigin, 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(); >- >- auto* stateNode = m_scrollingStateTree->stateNodeForID(scrollingNodeID); >- if (!stateNode) >- return nullptr; >- >- // Find the enclosing frame scrolling node. >- auto* parentNode = stateNode; >- while (parentNode && !parentNode->isFrameScrollingNode()) >- 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 (auto* view = frame->view()) { >- if (view->scrollingNodeID() == parentNode->scrollingNodeID()) >- return view; >- } >- } >- >- return nullptr; >-} >- >-void AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll(ScrollingNodeID scrollingNodeID, const FloatPoint& scrollPosition, Optional<FloatPoint> layoutViewportOrigin, bool programmaticScroll, ScrollingLayerPositionAction scrollingLayerPositionAction) >-{ >- ASSERT(isMainThread()); >- >- if (!m_page) >- return; >- >- auto* frameViewPtr = frameViewForScrollingNode(scrollingNodeID); >- if (!frameViewPtr) >- return; >- >- LOG_WITH_STREAM(Scrolling, stream << "AsyncScrollingCoordinator::updateScrollPositionAfterAsyncScroll node " << scrollingNodeID << " scrollPosition " << scrollPosition << " action " << scrollingLayerPositionAction); >- >- auto& frameView = *frameViewPtr; >- >- if (scrollingNodeID == frameView.scrollingNodeID()) { >- reconcileScrollingState(frameView, scrollPosition, layoutViewportOrigin, programmaticScroll, ViewportRectStability::Stable, scrollingLayerPositionAction); >- >-#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 (auto* scrollableArea = frameView.scrollableAreaForScrollLayerID(scrollingNodeID)) { >- scrollableArea->setIsUserScroll(scrollingLayerPositionAction == ScrollingLayerPositionAction::Sync); >- scrollableArea->scrollToOffsetWithoutAnimation(scrollPosition); >- scrollableArea->setIsUserScroll(false); >- if (scrollingLayerPositionAction == ScrollingLayerPositionAction::Set) >- 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::reconcileScrollingState(FrameView& frameView, const FloatPoint& scrollPosition, const LayoutViewportOriginOrOverrideRect& layoutViewportOriginOrOverrideRect, bool programmaticScroll, ViewportRectStability viewportRectStability, ScrollingLayerPositionAction scrollingLayerPositionAction) >-{ >- bool oldProgrammaticScroll = frameView.inProgrammaticScroll(); >- frameView.setInProgrammaticScroll(programmaticScroll); >- >- LOG_WITH_STREAM(Scrolling, stream << getCurrentProcessID() << " AsyncScrollingCoordinator " << this << " reconcileScrollingState scrollPosition " << scrollPosition << " programmaticScroll " << programmaticScroll << " stability " << viewportRectStability << " " << scrollingLayerPositionAction); >- >- Optional<FloatRect> layoutViewportRect; >- >- WTF::switchOn(layoutViewportOriginOrOverrideRect, >- [&frameView](Optional<FloatPoint> origin) { >- if (origin) >- frameView.setBaseLayoutViewportOrigin(LayoutPoint(origin.value()), FrameView::TriggerLayoutOrNot::No); >- }, [&frameView, &layoutViewportRect, viewportRectStability, visualViewportEnabled = visualViewportEnabled()](Optional<FloatRect> overrideRect) { >- if (!overrideRect) >- return; >- >- layoutViewportRect = overrideRect; >- if (visualViewportEnabled && viewportRectStability != ViewportRectStability::ChangingObscuredInsetsInteractively) >- frameView.setLayoutViewportOverrideRect(LayoutRect(overrideRect.value()), viewportRectStability == ViewportRectStability::Stable ? FrameView::TriggerLayoutOrNot::Yes : FrameView::TriggerLayoutOrNot::No); >-#if PLATFORM(IOS_FAMILY) >- else if (viewportRectStability == ViewportRectStability::Stable) >- frameView.setCustomFixedPositionLayoutRect(enclosingIntRect(overrideRect.value())); >-#endif >- } >- ); >- >- frameView.setConstrainsScrollingToContentEdge(false); >- frameView.notifyScrollPositionChanged(roundedIntPoint(scrollPosition)); >- frameView.setConstrainsScrollingToContentEdge(true); >- frameView.setInProgrammaticScroll(oldProgrammaticScroll); >- >- if (!programmaticScroll && scrollingLayerPositionAction != ScrollingLayerPositionAction::Set) { >- auto scrollingNodeID = frameView.scrollingNodeID(); >- if (viewportRectStability == ViewportRectStability::Stable) >- reconcileViewportConstrainedLayerPositions(scrollingNodeID, frameView.rectForFixedPositionLayout(), scrollingLayerPositionAction); >- else if (layoutViewportRect) >- reconcileViewportConstrainedLayerPositions(scrollingNodeID, LayoutRect(layoutViewportRect.value()), scrollingLayerPositionAction); >- } >- >- auto* scrollLayer = scrollLayerForFrameView(frameView); >- if (!scrollLayer) >- return; >- >- auto* counterScrollingLayer = counterScrollingLayerForFrameView(frameView); >- auto* insetClipLayer = insetClipLayerForFrameView(frameView); >- auto* contentShadowLayer = contentShadowLayerForFrameView(frameView); >- auto* rootContentsLayer = rootContentsLayerForFrameView(frameView); >- auto* headerLayer = headerLayerForFrameView(frameView); >- auto* footerLayer = footerLayerForFrameView(frameView); >- >- ASSERT(frameView.scrollPosition() == roundedIntPoint(scrollPosition)); >- LayoutPoint scrollPositionForFixed = frameView.scrollPositionForFixedPosition(); >- float topContentInset = frameView.topContentInset(); >- >- FloatPoint positionForInsetClipLayer; >- if (insetClipLayer) >- positionForInsetClipLayer = FloatPoint(insetClipLayer->position().x(), 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 == ScrollingLayerPositionAction::Set) { >- scrollLayer->setPosition(-frameView.scrollPosition()); >- if (counterScrollingLayer) >- counterScrollingLayer->setPosition(scrollPositionForFixed); >- if (insetClipLayer) >- insetClipLayer->setPosition(positionForInsetClipLayer); >- if (contentShadowLayer) >- contentShadowLayer->setPosition(positionForContentsLayer); >- if (rootContentsLayer) >- rootContentsLayer->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 (rootContentsLayer) >- rootContentsLayer->syncPosition(positionForContentsLayer); >- if (headerLayer) >- headerLayer->syncPosition(positionForHeaderLayer); >- if (footerLayer) >- footerLayer->syncPosition(positionForFooterLayer); >- } >-} >- >-void AsyncScrollingCoordinator::scrollableAreaScrollbarLayerDidChange(ScrollableArea& scrollableArea, ScrollbarOrientation orientation) >-{ >- ASSERT(isMainThread()); >- ASSERT(m_page); >- >- auto* node = m_scrollingStateTree->stateNodeForID(scrollableArea.scrollingNodeID()); >- if (is<ScrollingStateFrameScrollingNode>(node)) { >- auto& scrollingNode = downcast<ScrollingStateFrameScrollingNode>(*node); >- if (orientation == VerticalScrollbar) >- scrollingNode.setVerticalScrollbarLayer(scrollableArea.layerForVerticalScrollbar()); >- else >- scrollingNode.setHorizontalScrollbarLayer(scrollableArea.layerForHorizontalScrollbar()); >- >- } >- >- if (&scrollableArea == m_page->mainFrame().view()) { >- if (orientation == VerticalScrollbar) >- scrollableArea.verticalScrollbarLayerDidChange(); >- else >- scrollableArea.horizontalScrollbarLayerDidChange(); >- } >-} >- >-ScrollingNodeID AsyncScrollingCoordinator::createNode(ScrollingNodeType nodeType, ScrollingNodeID newNodeID) >-{ >- LOG_WITH_STREAM(Scrolling, stream << "AsyncScrollingCoordinator::createNode " << nodeType << " node " << newNodeID); >- return m_scrollingStateTree->createUnparentedNode(nodeType, newNodeID); >-} >- >-ScrollingNodeID AsyncScrollingCoordinator::insertNode(ScrollingNodeType nodeType, ScrollingNodeID newNodeID, ScrollingNodeID parentID, size_t childIndex) >-{ >- LOG_WITH_STREAM(Scrolling, stream << "AsyncScrollingCoordinator::insertNode " << nodeType << " node " << newNodeID << " parent " << parentID << " index " << childIndex); >- return m_scrollingStateTree->insertNode(nodeType, newNodeID, parentID, childIndex); >-} >- >-void AsyncScrollingCoordinator::unparentNode(ScrollingNodeID nodeID) >-{ >- m_scrollingStateTree->unparentNode(nodeID); >-} >- >-void AsyncScrollingCoordinator::unparentChildrenAndDestroyNode(ScrollingNodeID nodeID) >-{ >- m_scrollingStateTree->unparentChildrenAndDestroyNode(nodeID); >-} >- >-void AsyncScrollingCoordinator::detachAndDestroySubtree(ScrollingNodeID nodeID) >-{ >- m_scrollingStateTree->detachAndDestroySubtree(nodeID); >-} >- >-void AsyncScrollingCoordinator::clearAllNodes() >-{ >- m_scrollingStateTree->clear(); >-} >- >-ScrollingNodeID AsyncScrollingCoordinator::parentOfNode(ScrollingNodeID nodeID) const >-{ >- auto* scrollingNode = m_scrollingStateTree->stateNodeForID(nodeID); >- if (!scrollingNode) >- return 0; >- >- return scrollingNode->parentNodeID(); >-} >- >-Vector<ScrollingNodeID> AsyncScrollingCoordinator::childrenOfNode(ScrollingNodeID nodeID) const >-{ >- auto* scrollingNode = m_scrollingStateTree->stateNodeForID(nodeID); >- if (!scrollingNode) >- return { }; >- >- auto* children = scrollingNode->children(); >- if (!children || children->isEmpty()) >- return { }; >- >- Vector<ScrollingNodeID> childNodeIDs; >- childNodeIDs.reserveInitialCapacity(children->size()); >- for (const auto& childNode : *children) >- childNodeIDs.uncheckedAppend(childNode->scrollingNodeID()); >- >- return childNodeIDs; >-} >- >-void AsyncScrollingCoordinator::reconcileViewportConstrainedLayerPositions(ScrollingNodeID scrollingNodeID, const LayoutRect& viewportRect, ScrollingLayerPositionAction action) >-{ >- auto* scrollingNode = m_scrollingStateTree->stateNodeForID(scrollingNodeID); >- if (!scrollingNode) >- return; >- >- LOG_WITH_STREAM(Scrolling, stream << getCurrentProcessID() << " AsyncScrollingCoordinator::reconcileViewportConstrainedLayerPositions for viewport rect " << viewportRect << " and node " << scrollingNodeID); >- >- scrollingNode->reconcileLayerPositionForViewportRect(viewportRect, action); >-} >- >-void AsyncScrollingCoordinator::ensureRootStateNodeForFrameView(FrameView& frameView) >-{ >- ASSERT(frameView.scrollingNodeID()); >- if (m_scrollingStateTree->stateNodeForID(frameView.scrollingNodeID())) >- return; >- >- // For non-main frames, it is only possible to arrive in this function from >- // RenderLayerCompositor::updateBacking where the node has already been created. >- ASSERT(frameView.frame().isMainFrame()); >- insertNode(ScrollingNodeType::MainFrame, frameView.scrollingNodeID(), 0, 0); >-} >- >-void AsyncScrollingCoordinator::setNodeLayers(ScrollingNodeID nodeID, const NodeLayers& nodeLayers) >-{ >- auto* node = m_scrollingStateTree->stateNodeForID(nodeID); >- ASSERT(node); >- if (!node) >- return; >- >- node->setLayer(nodeLayers.layer); >- >- if (is<ScrollingStateScrollingNode>(node)) { >- auto& scrollingNode = downcast<ScrollingStateScrollingNode>(*node); >- scrollingNode.setScrollContainerLayer(nodeLayers.scrollContainerLayer); >- scrollingNode.setScrolledContentsLayer(nodeLayers.scrolledContentsLayer); >- >- if (is<ScrollingStateFrameScrollingNode>(node)) { >- auto& frameScrollingNode = downcast<ScrollingStateFrameScrollingNode>(*node); >- frameScrollingNode.setInsetClipLayer(nodeLayers.insetClipLayer); >- frameScrollingNode.setCounterScrollingLayer(nodeLayers.counterScrollingLayer); >- frameScrollingNode.setRootContentsLayer(nodeLayers.rootContentsLayer); >- } >- } >-} >- >-void AsyncScrollingCoordinator::setScrollingNodeGeometry(ScrollingNodeID nodeID, const ScrollingGeometry& scrollingGeometry) >-{ >- auto* stateNode = m_scrollingStateTree->stateNodeForID(nodeID); >- ASSERT(stateNode); >- if (!stateNode) >- return; >- >- if (stateNode->nodeType() == ScrollingNodeType::FrameHosting) { >- auto& frameHostingStateNode = downcast<ScrollingStateFrameHostingNode>(*stateNode); >- frameHostingStateNode.setParentRelativeScrollableRect(scrollingGeometry.parentRelativeScrollableRect); >- return; >- } >- >- auto& scrollingNode = downcast<ScrollingStateScrollingNode>(*stateNode); >- >- scrollingNode.setParentRelativeScrollableRect(scrollingGeometry.parentRelativeScrollableRect); >- scrollingNode.setScrollOrigin(scrollingGeometry.scrollOrigin); >- scrollingNode.setScrollPosition(scrollingGeometry.scrollPosition); >- scrollingNode.setTotalContentsSize(scrollingGeometry.contentSize); >- scrollingNode.setReachableContentsSize(scrollingGeometry.reachableContentSize); >- scrollingNode.setScrollableAreaSize(scrollingGeometry.scrollableAreaSize); >- >-#if ENABLE(CSS_SCROLL_SNAP) >- // updateScrollSnapPropertiesWithFrameView() sets these for frame scrolling nodes. FIXME: Why the difference? >- if (is<ScrollingStateOverflowScrollingNode>(scrollingNode)) { >- setStateScrollingNodeSnapOffsetsAsFloat(scrollingNode, ScrollEventAxis::Horizontal, &scrollingGeometry.horizontalSnapOffsets, &scrollingGeometry.horizontalSnapOffsetRanges, m_page->deviceScaleFactor()); >- setStateScrollingNodeSnapOffsetsAsFloat(scrollingNode, ScrollEventAxis::Vertical, &scrollingGeometry.verticalSnapOffsets, &scrollingGeometry.verticalSnapOffsetRanges, m_page->deviceScaleFactor()); >- scrollingNode.setCurrentHorizontalSnapPointIndex(scrollingGeometry.currentHorizontalSnapPointIndex); >- scrollingNode.setCurrentVerticalSnapPointIndex(scrollingGeometry.currentVerticalSnapPointIndex); >- } >-#endif >-} >- >-void AsyncScrollingCoordinator::setViewportConstraintedNodeGeometry(ScrollingNodeID nodeID, const ViewportConstraints& constraints) >-{ >- auto* node = m_scrollingStateTree->stateNodeForID(nodeID); >- if (!node) >- return; >- >- switch (constraints.constraintType()) { >- case ViewportConstraints::FixedPositionConstraint: { >- auto& fixedNode = downcast<ScrollingStateFixedNode>(*node); >- fixedNode.updateConstraints((const FixedPositionViewportConstraints&)constraints); >- break; >- } >- case ViewportConstraints::StickyPositionConstraint: { >- auto& stickyNode = downcast<ScrollingStateStickyNode>(*node); >- stickyNode.updateConstraints((const StickyPositionViewportConstraints&)constraints); >- break; >- } >- } >-} >- >-void AsyncScrollingCoordinator::setSynchronousScrollingReasons(FrameView& frameView, SynchronousScrollingReasons reasons) >-{ >- auto* scrollingStateNode = static_cast<ScrollingStateFrameScrollingNode*>(m_scrollingStateTree->stateNodeForID(frameView.scrollingNodeID())); >- if (!scrollingStateNode) >- 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) >- updateScrollLayerPosition(frameView); >- scrollingStateNode->setSynchronousScrollingReasons(reasons); >-} >- >-void AsyncScrollingCoordinator::updateScrollLayerPosition(FrameView& frameView) >-{ >- ASSERT(isMainThread()); >- if (auto* scrollLayer = scrollLayerForFrameView(frameView)) >- scrollLayer->setPosition(-frameView.scrollPosition()); >-} >- >-bool AsyncScrollingCoordinator::isRubberBandInProgress() const >-{ >- return scrollingTree()->isRubberBandInProgress(); >-} >- >-void AsyncScrollingCoordinator::setScrollPinningBehavior(ScrollPinningBehavior pinning) >-{ >- scrollingTree()->setScrollPinningBehavior(pinning); >-} >- >-bool AsyncScrollingCoordinator::visualViewportEnabled() const >-{ >- return m_page->mainFrame().settings().visualViewportEnabled(); >-} >- >-bool AsyncScrollingCoordinator::asyncFrameOrOverflowScrollingEnabled() const >-{ >- auto& settings = m_page->mainFrame().settings(); >- return settings.asyncFrameScrollingEnabled() || settings.asyncOverflowScrollingEnabled(); >-} >- >-String AsyncScrollingCoordinator::scrollingStateTreeAsText(ScrollingStateTreeAsTextBehavior behavior) const >-{ >- if (m_scrollingStateTree->rootStateNode()) { >- if (m_eventTrackingRegionsDirty) >- m_scrollingStateTree->rootStateNode()->setEventTrackingRegions(absoluteEventTrackingRegions()); >- return m_scrollingStateTree->rootStateNode()->scrollingStateTreeAsText(behavior); >- } >- >- return String(); >-} >- >-#if PLATFORM(COCOA) >-void AsyncScrollingCoordinator::setActiveScrollSnapIndices(ScrollingNodeID scrollingNodeID, unsigned horizontalIndex, unsigned verticalIndex) >-{ >- ASSERT(isMainThread()); >- >- if (!m_page) >- return; >- >- auto* frameView = frameViewForScrollingNode(scrollingNodeID); >- if (!frameView) >- return; >- >- if (scrollingNodeID == frameView->scrollingNodeID()) { >- frameView->setCurrentHorizontalSnapPointIndex(horizontalIndex); >- frameView->setCurrentVerticalSnapPointIndex(verticalIndex); >- return; >- } >- >- // Overflow-scroll area. >- if (auto* 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.scrollingNodeID()))) { >- setStateScrollingNodeSnapOffsetsAsFloat(*node, ScrollEventAxis::Horizontal, frameView.horizontalSnapOffsets(), frameView.horizontalSnapOffsetRanges(), m_page->deviceScaleFactor()); >- setStateScrollingNodeSnapOffsetsAsFloat(*node, ScrollEventAxis::Vertical, frameView.verticalSnapOffsets(), frameView.verticalSnapOffsetRanges(), m_page->deviceScaleFactor()); >- node->setCurrentHorizontalSnapPointIndex(frameView.currentHorizontalSnapPointIndex()); >- node->setCurrentVerticalSnapPointIndex(frameView.currentVerticalSnapPointIndex()); >- } >-} >-#endif >- >-void AsyncScrollingCoordinator::reportExposedUnfilledArea(MonotonicTime timestamp, unsigned unfilledArea) >-{ >- if (m_page && m_page->performanceLoggingClient()) >- m_page->performanceLoggingClient()->logScrollingEvent(PerformanceLoggingClient::ScrollingEvent::ExposedTilelessArea, timestamp, unfilledArea); >-} >- >-void AsyncScrollingCoordinator::reportSynchronousScrollingReasonsChanged(MonotonicTime timestamp, SynchronousScrollingReasons reasons) >-{ >- if (m_page && m_page->performanceLoggingClient()) >- m_page->performanceLoggingClient()->logScrollingEvent(PerformanceLoggingClient::ScrollingEvent::SwitchedScrollingMode, timestamp, reasons); >-} >- >-} // namespace WebCore >- >-#endif // ENABLE(ASYNC_SCROLLING) >Index: Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h >=================================================================== >--- Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h (revision 240892) >+++ Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h (working copy) >@@ -1,178 +1 @@ >-/* >- * 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. >- */ > >-#pragma once >- >-#if ENABLE(ASYNC_SCROLLING) >- >-#include "ScrollingCoordinator.h" >-#include "ScrollingTree.h" >-#include "Timer.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&, const Optional<FloatPoint>& layoutViewportOrigin, bool programmaticScroll, ScrollingLayerPositionAction); >- >-#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 >- >- WEBCORE_EXPORT void updateExpectsWheelEventTestTriggerWithFrameView(const FrameView&) override; >- >- void reportExposedUnfilledArea(MonotonicTime, unsigned unfilledArea); >- void reportSynchronousScrollingReasonsChanged(MonotonicTime, SynchronousScrollingReasons); >- >-protected: >- WEBCORE_EXPORT AsyncScrollingCoordinator(Page*); >- >- void setScrollingTree(Ref<ScrollingTree>&& scrollingTree) { m_scrollingTree = WTFMove(scrollingTree); } >- >- ScrollingStateTree* scrollingStateTree() { return m_scrollingStateTree.get(); } >- >- RefPtr<ScrollingTree> releaseScrollingTree() { return WTFMove(m_scrollingTree); } >- >- void updateScrollPositionAfterAsyncScroll(ScrollingNodeID, const FloatPoint&, Optional<FloatPoint> layoutViewportOrigin, bool programmaticScroll, ScrollingLayerPositionAction); >- >- WEBCORE_EXPORT String scrollingStateTreeAsText(ScrollingStateTreeAsTextBehavior = ScrollingStateTreeAsTextBehaviorNormal) const override; >- WEBCORE_EXPORT void willCommitTree() override; >- >- bool eventTrackingRegionsDirty() const { return m_eventTrackingRegionsDirty; } >- >-private: >- bool isAsyncScrollingCoordinator() const override { return true; } >- >- bool hasVisibleSlowRepaintViewportConstrainedObjects(const FrameView&) const override { return false; } >- >- bool visualViewportEnabled() const; >- bool asyncFrameOrOverflowScrollingEnabled() const; >- >- WEBCORE_EXPORT void frameViewLayoutUpdated(FrameView&) override; >- WEBCORE_EXPORT void frameViewRootLayerDidChange(FrameView&) override; >- WEBCORE_EXPORT void frameViewEventTrackingRegionsChanged(FrameView&) override; >- >- WEBCORE_EXPORT bool requestScrollPositionUpdate(FrameView&, const IntPoint&) override; >- >- WEBCORE_EXPORT ScrollingNodeID createNode(ScrollingNodeType, ScrollingNodeID newNodeID) override; >- WEBCORE_EXPORT ScrollingNodeID insertNode(ScrollingNodeType, ScrollingNodeID newNodeID, ScrollingNodeID parentID, size_t childIndex) override; >- WEBCORE_EXPORT void unparentNode(ScrollingNodeID) override; >- WEBCORE_EXPORT void unparentChildrenAndDestroyNode(ScrollingNodeID) override; >- WEBCORE_EXPORT void detachAndDestroySubtree(ScrollingNodeID) override; >- WEBCORE_EXPORT void clearAllNodes() override; >- >- WEBCORE_EXPORT ScrollingNodeID parentOfNode(ScrollingNodeID) const override; >- WEBCORE_EXPORT Vector<ScrollingNodeID> childrenOfNode(ScrollingNodeID) const override; >- >- WEBCORE_EXPORT void setNodeLayers(ScrollingNodeID, const NodeLayers&) override; >- WEBCORE_EXPORT void setScrollingNodeGeometry(ScrollingNodeID, const ScrollingGeometry&) override; >- WEBCORE_EXPORT void setViewportConstraintedNodeGeometry(ScrollingNodeID, const ViewportConstraints&) override; >- >- WEBCORE_EXPORT void reconcileScrollingState(FrameView&, const FloatPoint&, const LayoutViewportOriginOrOverrideRect&, bool programmaticScroll, ViewportRectStability, ScrollingLayerPositionAction) override; >- >- bool isRubberBandInProgress() const override; >- void setScrollPinningBehavior(ScrollPinningBehavior) override; >- >-#if ENABLE(CSS_SCROLL_SNAP) >- bool isScrollSnapInProgress() const override; >-#endif >- >- WEBCORE_EXPORT void reconcileViewportConstrainedLayerPositions(ScrollingNodeID, const LayoutRect& viewportRect, ScrollingLayerPositionAction) override; >- WEBCORE_EXPORT void scrollableAreaScrollbarLayerDidChange(ScrollableArea&, ScrollbarOrientation) override; >- >- WEBCORE_EXPORT void setSynchronousScrollingReasons(FrameView&, SynchronousScrollingReasons) final; >- >- virtual void scheduleTreeStateCommit() = 0; >- >- void ensureRootStateNodeForFrameView(FrameView&); >- void updateScrollLayerPosition(FrameView&); >- >- void updateScrollPositionAfterAsyncScrollTimerFired(); >- void setEventTrackingRegionsDirty(); >- void updateEventTrackingRegions(); >- >- FrameView* frameViewForScrollingNode(ScrollingNodeID) const; >- >- Timer m_updateNodeScrollPositionTimer; >- >- struct ScheduledScrollUpdate { >- ScheduledScrollUpdate() = default; >- ScheduledScrollUpdate(ScrollingNodeID scrollingNodeID, FloatPoint point, Optional<FloatPoint> viewportOrigin, bool isProgrammatic, ScrollingLayerPositionAction udpateAction) >- : nodeID(scrollingNodeID) >- , scrollPosition(point) >- , layoutViewportOrigin(viewportOrigin) >- , isProgrammaticScroll(isProgrammatic) >- , updateLayerPositionAction(udpateAction) >- { } >- >- ScrollingNodeID nodeID { 0 }; >- FloatPoint scrollPosition; >- Optional<FloatPoint> layoutViewportOrigin; >- bool isProgrammaticScroll { false }; >- ScrollingLayerPositionAction updateLayerPositionAction { ScrollingLayerPositionAction::Sync }; >- >- 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_eventTrackingRegionsDirty { false }; >-}; >- >-} // namespace WebCore >- >-SPECIALIZE_TYPE_TRAITS_SCROLLING_COORDINATOR(WebCore::AsyncScrollingCoordinator, isAsyncScrollingCoordinator()); >- >-#endif // ENABLE(ASYNC_SCROLLING) >Index: Source/WebCore/page/scrolling/ScrollingCoordinator.cpp >=================================================================== >--- Source/WebCore/page/scrolling/ScrollingCoordinator.cpp (revision 240892) >+++ Source/WebCore/page/scrolling/ScrollingCoordinator.cpp (working copy) >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2011 Apple Inc. All rights reserved. >+ * 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 >@@ -25,37 +25,43 @@ > > #include "config.h" > >+#if ENABLE(ASYNC_SCROLLING) > #include "ScrollingCoordinator.h" > >+#include "DebugPageOverlays.h" > #include "Document.h" >+#include "EditorClient.h" > #include "EventNames.h" > #include "Frame.h" > #include "FrameView.h" > #include "GraphicsLayer.h" >+#include "Logging.h" > #include "Page.h" >-#include "PlatformWheelEvent.h" >+#include "PerformanceLoggingClient.h" > #include "PluginViewBase.h" >-#include "Region.h" >+#include "RenderLayer.h" > #include "RenderLayerCompositor.h" > #include "RenderView.h" > #include "RuntimeEnabledFeatures.h" > #include "ScrollAnimator.h" >+#include "ScrollingConstraints.h" >+#include "ScrollingStateFixedNode.h" >+#include "ScrollingStateFrameHostingNode.h" >+#include "ScrollingStateFrameScrollingNode.h" >+#include "ScrollingStateOverflowScrollingNode.h" >+#include "ScrollingStateStickyNode.h" >+#include "ScrollingStateTree.h" > #include "Settings.h" >-#include <wtf/MainThread.h> >-#include <wtf/text/StringBuilder.h> >+#include "WheelEventTestTrigger.h" >+#include <wtf/ProcessID.h> > #include <wtf/text/TextStream.h> > > namespace WebCore { > >-#if !PLATFORM(COCOA) && !USE(COORDINATED_GRAPHICS) >-Ref<ScrollingCoordinator> ScrollingCoordinator::create(Page* page) >-{ >- return adoptRef(*new ScrollingCoordinator(page)); >-} >-#endif >- > ScrollingCoordinator::ScrollingCoordinator(Page* page) > : m_page(page) >+ , m_updateNodeScrollPositionTimer(*this, &ScrollingCoordinator::updateScrollPositionAfterAsyncScrollTimerFired) >+ , m_scrollingStateTree(std::make_unique<ScrollingStateTree>(this)) > { > } > >@@ -64,6 +70,11 @@ ScrollingCoordinator::~ScrollingCoordina > ASSERT(!m_page); > } > >+void ScrollingCoordinator::scrollingStateTreePropertiesChanged() >+{ >+ scheduleTreeStateCommit(); >+} >+ > void ScrollingCoordinator::pageDestroyed() > { > ASSERT(m_page); >@@ -162,7 +173,7 @@ EventTrackingRegions ScrollingCoordinato > continue; > nonFastScrollableRegion.unite(renderWidget->absoluteBoundingBoxRect()); > } >- >+ > EventTrackingRegions eventTrackingRegions; > > // FIXME: if we've already accounted for this subframe as a scrollable area, we can avoid recursing into it here. >@@ -187,7 +198,7 @@ EventTrackingRegions ScrollingCoordinato > LayoutRect inflatedWheelHandlerBounds = frameView->fixedScrollableAreaBoundsInflatedForScrolling(LayoutRect(wheelHandlerRegion.first.bounds())); > wheelHandlerRegion.first.unite(enclosingIntRect(inflatedWheelHandlerBounds)); > } >- >+ > nonFastScrollableRegion.unite(wheelHandlerRegion.first); > > // FIXME: If this is not the main frame, we could clip the region to the frame's bounds. >@@ -202,6 +213,40 @@ EventTrackingRegions ScrollingCoordinato > return absoluteEventTrackingRegionsForFrame(m_page->mainFrame()); > } > >+#if ENABLE(CSS_SCROLL_SNAP) >+static inline void setStateScrollingNodeSnapOffsetsAsFloat(ScrollingStateScrollingNode& node, ScrollEventAxis axis, const Vector<LayoutUnit>* snapOffsets, const Vector<ScrollOffsetRange<LayoutUnit>>* snapOffsetRanges, 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)); >+ } >+ >+ Vector<ScrollOffsetRange<float>> snapOffsetRangesAsFloat; >+ if (snapOffsetRanges) { >+ snapOffsetRangesAsFloat.reserveInitialCapacity(snapOffsetRanges->size()); >+ for (auto& range : *snapOffsetRanges) >+ snapOffsetRangesAsFloat.uncheckedAppend({ roundToDevicePixel(range.start, deviceScaleFactor, false), roundToDevicePixel(range.end, deviceScaleFactor, false) }); >+ } >+ if (axis == ScrollEventAxis::Horizontal) { >+ node.setHorizontalSnapOffsets(snapOffsetsAsFloat); >+ node.setHorizontalSnapOffsetRanges(snapOffsetRangesAsFloat); >+ } else { >+ node.setVerticalSnapOffsets(snapOffsetsAsFloat); >+ node.setVerticalSnapOffsetRanges(snapOffsetRangesAsFloat); >+ } >+} >+#endif >+ >+void ScrollingCoordinator::setEventTrackingRegionsDirty() >+{ >+ m_eventTrackingRegionsDirty = true; >+ // We have to schedule a commit, but the computed non-fast region may not have actually changed. >+ scheduleTreeStateCommit(); >+} >+ > void ScrollingCoordinator::frameViewHasSlowRepaintObjectsDidChange(FrameView& frameView) > { > ASSERT(isMainThread()); >@@ -274,7 +319,7 @@ GraphicsLayer* ScrollingCoordinator::con > #if ENABLE(RUBBER_BANDING) > if (auto* renderView = frameView.frame().contentRenderer()) > return renderView->compositor().layerForContentShadow(); >- >+ > return nullptr; > #else > UNUSED_PARAM(frameView); >@@ -289,18 +334,6 @@ GraphicsLayer* ScrollingCoordinator::roo > return nullptr; > } > >-void ScrollingCoordinator::frameViewRootLayerDidChange(FrameView& frameView) >-{ >- ASSERT(isMainThread()); >- ASSERT(m_page); >- >- if (!coordinatesScrollingForFrameView(frameView)) >- return; >- >- frameViewLayoutUpdated(frameView); >- updateSynchronousScrollingReasons(frameView); >-} >- > #if PLATFORM(COCOA) > void ScrollingCoordinator::handleWheelEventPhase(PlatformWheelEventPhase phase) > { >@@ -379,7 +412,7 @@ bool ScrollingCoordinator::shouldUpdateS > { > if (&frameView == m_page->mainFrame().view()) > return synchronousScrollingReasons(frameView); >- >+ > return true; > } > >@@ -389,11 +422,6 @@ ScrollingNodeID ScrollingCoordinator::un > return uniqueScrollingNodeID++; > } > >-String ScrollingCoordinator::scrollingStateTreeAsText(ScrollingStateTreeAsTextBehavior) const >-{ >- return String(); >-} >- > String ScrollingCoordinator::synchronousScrollingReasonsAsText(SynchronousScrollingReasons reasons) > { > StringBuilder stringBuilder; >@@ -422,6 +450,688 @@ String ScrollingCoordinator::synchronous > return String(); > } > >+void ScrollingCoordinator::willCommitTree() >+{ >+ updateEventTrackingRegions(); >+} >+ >+void ScrollingCoordinator::updateEventTrackingRegions() >+{ >+ if (!m_eventTrackingRegionsDirty) >+ return; >+ >+ if (!m_scrollingStateTree->rootStateNode()) >+ return; >+ >+ m_scrollingStateTree->rootStateNode()->setEventTrackingRegions(absoluteEventTrackingRegions()); >+ m_eventTrackingRegionsDirty = false; >+} >+ >+void ScrollingCoordinator::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; >+ >+ setEventTrackingRegionsDirty(); >+ if (!coordinatesScrollingForFrameView(frameView)) >+ return; >+ >+ auto* node = m_scrollingStateTree->stateNodeForID(frameView.scrollingNodeID()); >+ if (!node || !is<ScrollingStateFrameScrollingNode>(*node)) >+ return; >+ >+ auto& frameScrollingNode = downcast<ScrollingStateFrameScrollingNode>(*node); >+ >+ auto* verticalScrollbar = frameView.verticalScrollbar(); >+ auto* horizontalScrollbar = frameView.horizontalScrollbar(); >+ frameScrollingNode.setScrollerImpsFromScrollbars(verticalScrollbar, horizontalScrollbar); >+ >+ frameScrollingNode.setFrameScaleFactor(frameView.frame().frameScaleFactor()); >+ frameScrollingNode.setHeaderHeight(frameView.headerHeight()); >+ frameScrollingNode.setFooterHeight(frameView.footerHeight()); >+ frameScrollingNode.setTopContentInset(frameView.topContentInset()); >+ >+ frameScrollingNode.setVisualViewportEnabled(visualViewportEnabled()); >+ frameScrollingNode.setLayoutViewport(frameView.layoutViewportRect()); >+ frameScrollingNode.setAsyncFrameOrOverflowScrollingEnabled(asyncFrameOrOverflowScrollingEnabled()); >+ >+ frameScrollingNode.setMinLayoutViewportOrigin(frameView.minStableLayoutViewportOrigin()); >+ frameScrollingNode.setMaxLayoutViewportOrigin(frameView.maxStableLayoutViewportOrigin()); >+ >+ frameScrollingNode.setScrollOrigin(frameView.scrollOrigin()); >+ frameScrollingNode.setScrollableAreaSize(frameView.visibleContentRect().size()); >+ frameScrollingNode.setTotalContentsSize(frameView.totalContentsSize()); >+ frameScrollingNode.setReachableContentsSize(frameView.totalContentsSize()); >+ frameScrollingNode.setFixedElementsLayoutRelativeToFrame(frameView.fixedElementsLayoutRelativeToFrame()); >+ frameScrollingNode.setScrollBehaviorForFixedElements(frameView.scrollBehaviorForFixedElements()); >+ >+#if ENABLE(CSS_SCROLL_SNAP) >+ frameView.updateSnapOffsets(); >+ updateScrollSnapPropertiesWithFrameView(frameView); >+#endif >+ >+#if PLATFORM(COCOA) >+ auto* page = frameView.frame().page(); >+ if (page && page->expectsWheelEventTriggers()) { >+ LOG(WheelEventTestTriggers, " ScrollingCoordinator::frameViewLayoutUpdated: Expects wheel event test trigger=%d", page->expectsWheelEventTriggers()); >+ frameScrollingNode.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(); >+ scrollParameters.useDarkAppearanceForScrollbars = frameView.useDarkAppearanceForScrollbars(); >+ >+ frameScrollingNode.setScrollableAreaParameters(scrollParameters); >+} >+ >+void ScrollingCoordinator::updateExpectsWheelEventTestTriggerWithFrameView(const FrameView& frameView) >+{ >+ auto* page = frameView.frame().page(); >+ if (!page) >+ return; >+ >+ auto* node = downcast<ScrollingStateFrameScrollingNode>(m_scrollingStateTree->stateNodeForID(frameView.scrollingNodeID())); >+ if (!node) >+ return; >+ >+ node->setExpectsWheelEventTestTrigger(page->expectsWheelEventTriggers()); >+} >+ >+void ScrollingCoordinator::frameViewEventTrackingRegionsChanged(FrameView& frameView) >+{ >+ if (!m_scrollingStateTree->rootStateNode()) >+ return; >+ >+ setEventTrackingRegionsDirty(); >+ DebugPageOverlays::didChangeEventHandlers(frameView.frame()); >+} >+ >+void ScrollingCoordinator::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.scrollingNodeID()) >+ return; >+ >+ // If the root layer does not have a ScrollingStateNode, then we should create one. >+ ensureRootStateNodeForFrameView(frameView); >+ ASSERT(m_scrollingStateTree->stateNodeForID(frameView.scrollingNodeID())); >+ >+ frameViewLayoutUpdated(frameView); >+ updateSynchronousScrollingReasons(frameView); >+ >+ auto* node = downcast<ScrollingStateFrameScrollingNode>(m_scrollingStateTree->stateNodeForID(frameView.scrollingNodeID())); >+ node->setScrolledContentsLayer(scrollLayerForFrameView(frameView)); >+ node->setRootContentsLayer(rootContentsLayerForFrameView(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()); >+ node->setVerticalScrollbarLayer(frameView.layerForVerticalScrollbar()); >+ node->setHorizontalScrollbarLayer(frameView.layerForHorizontalScrollbar()); >+} >+ >+bool ScrollingCoordinator::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()->pageCacheState() != Document::NotInPageCache) >+ updateScrollPositionAfterAsyncScroll(frameView.scrollingNodeID(), scrollPosition, WTF::nullopt, isProgrammaticScroll, ScrollingLayerPositionAction::Set); >+ >+ // 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()->pageCacheState() != Document::NotInPageCache) >+ return true; >+ >+ auto* stateNode = downcast<ScrollingStateScrollingNode>(m_scrollingStateTree->stateNodeForID(frameView.scrollingNodeID())); >+ if (!stateNode) >+ return false; >+ >+ stateNode->setRequestedScrollPosition(scrollPosition, isProgrammaticScroll); >+ return true; >+} >+ >+void ScrollingCoordinator::scheduleUpdateScrollPositionAfterAsyncScroll(ScrollingNodeID nodeID, const FloatPoint& scrollPosition, const Optional<FloatPoint>& layoutViewportOrigin, bool programmaticScroll, ScrollingLayerPositionAction scrollingLayerPositionAction) >+{ >+ ScheduledScrollUpdate scrollUpdate { nodeID, scrollPosition, layoutViewportOrigin, 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; >+ m_scheduledScrollUpdate.layoutViewportOrigin = layoutViewportOrigin; >+ 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.layoutViewportOrigin, m_scheduledScrollUpdate.isProgrammaticScroll, m_scheduledScrollUpdate.updateLayerPositionAction); >+ updateScrollPositionAfterAsyncScroll(nodeID, scrollPosition, layoutViewportOrigin, programmaticScroll, scrollingLayerPositionAction); >+ return; >+ } >+ >+ m_scheduledScrollUpdate = scrollUpdate; >+ m_updateNodeScrollPositionTimer.startOneShot(0_s); >+} >+ >+void ScrollingCoordinator::updateScrollPositionAfterAsyncScrollTimerFired() >+{ >+ updateScrollPositionAfterAsyncScroll(m_scheduledScrollUpdate.nodeID, m_scheduledScrollUpdate.scrollPosition, m_scheduledScrollUpdate.layoutViewportOrigin, m_scheduledScrollUpdate.isProgrammaticScroll, m_scheduledScrollUpdate.updateLayerPositionAction); >+} >+ >+FrameView* ScrollingCoordinator::frameViewForScrollingNode(ScrollingNodeID scrollingNodeID) const >+{ >+ if (!m_scrollingStateTree->rootStateNode()) >+ return nullptr; >+ >+ if (scrollingNodeID == m_scrollingStateTree->rootStateNode()->scrollingNodeID()) >+ return m_page->mainFrame().view(); >+ >+ auto* stateNode = m_scrollingStateTree->stateNodeForID(scrollingNodeID); >+ if (!stateNode) >+ return nullptr; >+ >+ // Find the enclosing frame scrolling node. >+ auto* parentNode = stateNode; >+ while (parentNode && !parentNode->isFrameScrollingNode()) >+ 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 (auto* view = frame->view()) { >+ if (view->scrollingNodeID() == parentNode->scrollingNodeID()) >+ return view; >+ } >+ } >+ >+ return nullptr; >+} >+ >+void ScrollingCoordinator::updateScrollPositionAfterAsyncScroll(ScrollingNodeID scrollingNodeID, const FloatPoint& scrollPosition, Optional<FloatPoint> layoutViewportOrigin, bool programmaticScroll, ScrollingLayerPositionAction scrollingLayerPositionAction) >+{ >+ ASSERT(isMainThread()); >+ >+ if (!m_page) >+ return; >+ >+ auto* frameViewPtr = frameViewForScrollingNode(scrollingNodeID); >+ if (!frameViewPtr) >+ return; >+ >+ LOG_WITH_STREAM(Scrolling, stream << "ScrollingCoordinator::updateScrollPositionAfterAsyncScroll node " << scrollingNodeID << " scrollPosition " << scrollPosition << " action " << scrollingLayerPositionAction); >+ >+ auto& frameView = *frameViewPtr; >+ >+ if (scrollingNodeID == frameView.scrollingNodeID()) { >+ reconcileScrollingState(frameView, scrollPosition, layoutViewportOrigin, programmaticScroll, ViewportRectStability::Stable, scrollingLayerPositionAction); >+ >+#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 (auto* scrollableArea = frameView.scrollableAreaForScrollLayerID(scrollingNodeID)) { >+ scrollableArea->setIsUserScroll(scrollingLayerPositionAction == ScrollingLayerPositionAction::Sync); >+ scrollableArea->scrollToOffsetWithoutAnimation(scrollPosition); >+ scrollableArea->setIsUserScroll(false); >+ if (scrollingLayerPositionAction == ScrollingLayerPositionAction::Set) >+ 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 ScrollingCoordinator::reconcileScrollingState(FrameView& frameView, const FloatPoint& scrollPosition, const LayoutViewportOriginOrOverrideRect& layoutViewportOriginOrOverrideRect, bool programmaticScroll, ViewportRectStability viewportRectStability, ScrollingLayerPositionAction scrollingLayerPositionAction) >+{ >+ bool oldProgrammaticScroll = frameView.inProgrammaticScroll(); >+ frameView.setInProgrammaticScroll(programmaticScroll); >+ >+ LOG_WITH_STREAM(Scrolling, stream << getCurrentProcessID() << " ScrollingCoordinator " << this << " reconcileScrollingState scrollPosition " << scrollPosition << " programmaticScroll " << programmaticScroll << " stability " << viewportRectStability << " " << scrollingLayerPositionAction); >+ >+ Optional<FloatRect> layoutViewportRect; >+ >+ WTF::switchOn(layoutViewportOriginOrOverrideRect, >+ [&frameView](Optional<FloatPoint> origin) { >+ if (origin) >+ frameView.setBaseLayoutViewportOrigin(LayoutPoint(origin.value()), FrameView::TriggerLayoutOrNot::No); >+ }, [&frameView, &layoutViewportRect, viewportRectStability, visualViewportEnabled = visualViewportEnabled()](Optional<FloatRect> overrideRect) { >+ if (!overrideRect) >+ return; >+ >+ layoutViewportRect = overrideRect; >+ if (visualViewportEnabled && viewportRectStability != ViewportRectStability::ChangingObscuredInsetsInteractively) >+ frameView.setLayoutViewportOverrideRect(LayoutRect(overrideRect.value()), viewportRectStability == ViewportRectStability::Stable ? FrameView::TriggerLayoutOrNot::Yes : FrameView::TriggerLayoutOrNot::No); >+#if PLATFORM(IOS_FAMILY) >+ else if (viewportRectStability == ViewportRectStability::Stable) >+ frameView.setCustomFixedPositionLayoutRect(enclosingIntRect(overrideRect.value())); >+#endif >+ } >+ ); >+ >+ frameView.setConstrainsScrollingToContentEdge(false); >+ frameView.notifyScrollPositionChanged(roundedIntPoint(scrollPosition)); >+ frameView.setConstrainsScrollingToContentEdge(true); >+ frameView.setInProgrammaticScroll(oldProgrammaticScroll); >+ >+ if (!programmaticScroll && scrollingLayerPositionAction != ScrollingLayerPositionAction::Set) { >+ auto scrollingNodeID = frameView.scrollingNodeID(); >+ if (viewportRectStability == ViewportRectStability::Stable) >+ reconcileViewportConstrainedLayerPositions(scrollingNodeID, frameView.rectForFixedPositionLayout(), scrollingLayerPositionAction); >+ else if (layoutViewportRect) >+ reconcileViewportConstrainedLayerPositions(scrollingNodeID, LayoutRect(layoutViewportRect.value()), scrollingLayerPositionAction); >+ } >+ >+ auto* scrollLayer = scrollLayerForFrameView(frameView); >+ if (!scrollLayer) >+ return; >+ >+ auto* counterScrollingLayer = counterScrollingLayerForFrameView(frameView); >+ auto* insetClipLayer = insetClipLayerForFrameView(frameView); >+ auto* contentShadowLayer = contentShadowLayerForFrameView(frameView); >+ auto* rootContentsLayer = rootContentsLayerForFrameView(frameView); >+ auto* headerLayer = headerLayerForFrameView(frameView); >+ auto* footerLayer = footerLayerForFrameView(frameView); >+ >+ ASSERT(frameView.scrollPosition() == roundedIntPoint(scrollPosition)); >+ LayoutPoint scrollPositionForFixed = frameView.scrollPositionForFixedPosition(); >+ float topContentInset = frameView.topContentInset(); >+ >+ FloatPoint positionForInsetClipLayer; >+ if (insetClipLayer) >+ positionForInsetClipLayer = FloatPoint(insetClipLayer->position().x(), 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 == ScrollingLayerPositionAction::Set) { >+ scrollLayer->setPosition(-frameView.scrollPosition()); >+ if (counterScrollingLayer) >+ counterScrollingLayer->setPosition(scrollPositionForFixed); >+ if (insetClipLayer) >+ insetClipLayer->setPosition(positionForInsetClipLayer); >+ if (contentShadowLayer) >+ contentShadowLayer->setPosition(positionForContentsLayer); >+ if (rootContentsLayer) >+ rootContentsLayer->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 (rootContentsLayer) >+ rootContentsLayer->syncPosition(positionForContentsLayer); >+ if (headerLayer) >+ headerLayer->syncPosition(positionForHeaderLayer); >+ if (footerLayer) >+ footerLayer->syncPosition(positionForFooterLayer); >+ } >+} >+ >+void ScrollingCoordinator::scrollableAreaScrollbarLayerDidChange(ScrollableArea& scrollableArea, ScrollbarOrientation orientation) >+{ >+ ASSERT(isMainThread()); >+ ASSERT(m_page); >+ >+ auto* node = m_scrollingStateTree->stateNodeForID(scrollableArea.scrollingNodeID()); >+ if (is<ScrollingStateFrameScrollingNode>(node)) { >+ auto& scrollingNode = downcast<ScrollingStateFrameScrollingNode>(*node); >+ if (orientation == VerticalScrollbar) >+ scrollingNode.setVerticalScrollbarLayer(scrollableArea.layerForVerticalScrollbar()); >+ else >+ scrollingNode.setHorizontalScrollbarLayer(scrollableArea.layerForHorizontalScrollbar()); >+ >+ } >+ >+ if (&scrollableArea == m_page->mainFrame().view()) { >+ if (orientation == VerticalScrollbar) >+ scrollableArea.verticalScrollbarLayerDidChange(); >+ else >+ scrollableArea.horizontalScrollbarLayerDidChange(); >+ } >+} >+ >+ScrollingNodeID ScrollingCoordinator::createNode(ScrollingNodeType nodeType, ScrollingNodeID newNodeID) >+{ >+ LOG_WITH_STREAM(Scrolling, stream << "ScrollingCoordinator::createNode " << nodeType << " node " << newNodeID); >+ return m_scrollingStateTree->createUnparentedNode(nodeType, newNodeID); >+} >+ >+ScrollingNodeID ScrollingCoordinator::insertNode(ScrollingNodeType nodeType, ScrollingNodeID newNodeID, ScrollingNodeID parentID, size_t childIndex) >+{ >+ LOG_WITH_STREAM(Scrolling, stream << "ScrollingCoordinator::insertNode " << nodeType << " node " << newNodeID << " parent " << parentID << " index " << childIndex); >+ return m_scrollingStateTree->insertNode(nodeType, newNodeID, parentID, childIndex); >+} >+ >+void ScrollingCoordinator::unparentNode(ScrollingNodeID nodeID) >+{ >+ m_scrollingStateTree->unparentNode(nodeID); >+} >+ >+void ScrollingCoordinator::unparentChildrenAndDestroyNode(ScrollingNodeID nodeID) >+{ >+ m_scrollingStateTree->unparentChildrenAndDestroyNode(nodeID); >+} >+ >+void ScrollingCoordinator::detachAndDestroySubtree(ScrollingNodeID nodeID) >+{ >+ m_scrollingStateTree->detachAndDestroySubtree(nodeID); >+} >+ >+void ScrollingCoordinator::clearAllNodes() >+{ >+ m_scrollingStateTree->clear(); >+} >+ >+ScrollingNodeID ScrollingCoordinator::parentOfNode(ScrollingNodeID nodeID) const >+{ >+ auto* scrollingNode = m_scrollingStateTree->stateNodeForID(nodeID); >+ if (!scrollingNode) >+ return 0; >+ >+ return scrollingNode->parentNodeID(); >+} >+ >+Vector<ScrollingNodeID> ScrollingCoordinator::childrenOfNode(ScrollingNodeID nodeID) const >+{ >+ auto* scrollingNode = m_scrollingStateTree->stateNodeForID(nodeID); >+ if (!scrollingNode) >+ return { }; >+ >+ auto* children = scrollingNode->children(); >+ if (!children || children->isEmpty()) >+ return { }; >+ >+ Vector<ScrollingNodeID> childNodeIDs; >+ childNodeIDs.reserveInitialCapacity(children->size()); >+ for (const auto& childNode : *children) >+ childNodeIDs.uncheckedAppend(childNode->scrollingNodeID()); >+ >+ return childNodeIDs; >+} >+ >+void ScrollingCoordinator::reconcileViewportConstrainedLayerPositions(ScrollingNodeID scrollingNodeID, const LayoutRect& viewportRect, ScrollingLayerPositionAction action) >+{ >+ auto* scrollingNode = m_scrollingStateTree->stateNodeForID(scrollingNodeID); >+ if (!scrollingNode) >+ return; >+ >+ LOG_WITH_STREAM(Scrolling, stream << getCurrentProcessID() << " ScrollingCoordinator::reconcileViewportConstrainedLayerPositions for viewport rect " << viewportRect << " and node " << scrollingNodeID); >+ >+ scrollingNode->reconcileLayerPositionForViewportRect(viewportRect, action); >+} >+ >+void ScrollingCoordinator::ensureRootStateNodeForFrameView(FrameView& frameView) >+{ >+ ASSERT(frameView.scrollingNodeID()); >+ if (m_scrollingStateTree->stateNodeForID(frameView.scrollingNodeID())) >+ return; >+ >+ // For non-main frames, it is only possible to arrive in this function from >+ // RenderLayerCompositor::updateBacking where the node has already been created. >+ ASSERT(frameView.frame().isMainFrame()); >+ insertNode(ScrollingNodeType::MainFrame, frameView.scrollingNodeID(), 0, 0); >+} >+ >+void ScrollingCoordinator::setNodeLayers(ScrollingNodeID nodeID, const NodeLayers& nodeLayers) >+{ >+ auto* node = m_scrollingStateTree->stateNodeForID(nodeID); >+ ASSERT(node); >+ if (!node) >+ return; >+ >+ node->setLayer(nodeLayers.layer); >+ >+ if (is<ScrollingStateScrollingNode>(node)) { >+ auto& scrollingNode = downcast<ScrollingStateScrollingNode>(*node); >+ scrollingNode.setScrollContainerLayer(nodeLayers.scrollContainerLayer); >+ scrollingNode.setScrolledContentsLayer(nodeLayers.scrolledContentsLayer); >+ >+ if (is<ScrollingStateFrameScrollingNode>(node)) { >+ auto& frameScrollingNode = downcast<ScrollingStateFrameScrollingNode>(*node); >+ frameScrollingNode.setInsetClipLayer(nodeLayers.insetClipLayer); >+ frameScrollingNode.setCounterScrollingLayer(nodeLayers.counterScrollingLayer); >+ frameScrollingNode.setRootContentsLayer(nodeLayers.rootContentsLayer); >+ } >+ } >+} >+ >+void ScrollingCoordinator::setScrollingNodeGeometry(ScrollingNodeID nodeID, const ScrollingGeometry& scrollingGeometry) >+{ >+ auto* stateNode = m_scrollingStateTree->stateNodeForID(nodeID); >+ ASSERT(stateNode); >+ if (!stateNode) >+ return; >+ >+ if (stateNode->nodeType() == ScrollingNodeType::FrameHosting) { >+ auto& frameHostingStateNode = downcast<ScrollingStateFrameHostingNode>(*stateNode); >+ frameHostingStateNode.setParentRelativeScrollableRect(scrollingGeometry.parentRelativeScrollableRect); >+ return; >+ } >+ >+ auto& scrollingNode = downcast<ScrollingStateScrollingNode>(*stateNode); >+ >+ scrollingNode.setParentRelativeScrollableRect(scrollingGeometry.parentRelativeScrollableRect); >+ scrollingNode.setScrollOrigin(scrollingGeometry.scrollOrigin); >+ scrollingNode.setScrollPosition(scrollingGeometry.scrollPosition); >+ scrollingNode.setTotalContentsSize(scrollingGeometry.contentSize); >+ scrollingNode.setReachableContentsSize(scrollingGeometry.reachableContentSize); >+ scrollingNode.setScrollableAreaSize(scrollingGeometry.scrollableAreaSize); >+ >+#if ENABLE(CSS_SCROLL_SNAP) >+ // updateScrollSnapPropertiesWithFrameView() sets these for frame scrolling nodes. FIXME: Why the difference? >+ if (is<ScrollingStateOverflowScrollingNode>(scrollingNode)) { >+ setStateScrollingNodeSnapOffsetsAsFloat(scrollingNode, ScrollEventAxis::Horizontal, &scrollingGeometry.horizontalSnapOffsets, &scrollingGeometry.horizontalSnapOffsetRanges, m_page->deviceScaleFactor()); >+ setStateScrollingNodeSnapOffsetsAsFloat(scrollingNode, ScrollEventAxis::Vertical, &scrollingGeometry.verticalSnapOffsets, &scrollingGeometry.verticalSnapOffsetRanges, m_page->deviceScaleFactor()); >+ scrollingNode.setCurrentHorizontalSnapPointIndex(scrollingGeometry.currentHorizontalSnapPointIndex); >+ scrollingNode.setCurrentVerticalSnapPointIndex(scrollingGeometry.currentVerticalSnapPointIndex); >+ } >+#endif >+} >+ >+void ScrollingCoordinator::setViewportConstraintedNodeGeometry(ScrollingNodeID nodeID, const ViewportConstraints& constraints) >+{ >+ auto* node = m_scrollingStateTree->stateNodeForID(nodeID); >+ if (!node) >+ return; >+ >+ switch (constraints.constraintType()) { >+ case ViewportConstraints::FixedPositionConstraint: { >+ auto& fixedNode = downcast<ScrollingStateFixedNode>(*node); >+ fixedNode.updateConstraints((const FixedPositionViewportConstraints&)constraints); >+ break; >+ } >+ case ViewportConstraints::StickyPositionConstraint: { >+ auto& stickyNode = downcast<ScrollingStateStickyNode>(*node); >+ stickyNode.updateConstraints((const StickyPositionViewportConstraints&)constraints); >+ break; >+ } >+ } >+} >+ >+void ScrollingCoordinator::setSynchronousScrollingReasons(FrameView& frameView, SynchronousScrollingReasons reasons) >+{ >+ auto* scrollingStateNode = static_cast<ScrollingStateFrameScrollingNode*>(m_scrollingStateTree->stateNodeForID(frameView.scrollingNodeID())); >+ if (!scrollingStateNode) >+ 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) >+ updateScrollLayerPosition(frameView); >+ scrollingStateNode->setSynchronousScrollingReasons(reasons); >+} >+ >+void ScrollingCoordinator::updateScrollLayerPosition(FrameView& frameView) >+{ >+ ASSERT(isMainThread()); >+ if (auto* scrollLayer = scrollLayerForFrameView(frameView)) >+ scrollLayer->setPosition(-frameView.scrollPosition()); >+} >+ >+bool ScrollingCoordinator::isRubberBandInProgress() const >+{ >+ return scrollingTree()->isRubberBandInProgress(); >+} >+ >+void ScrollingCoordinator::setScrollPinningBehavior(ScrollPinningBehavior pinning) >+{ >+ scrollingTree()->setScrollPinningBehavior(pinning); >+} >+ >+bool ScrollingCoordinator::visualViewportEnabled() const >+{ >+ return m_page->mainFrame().settings().visualViewportEnabled(); >+} >+ >+bool ScrollingCoordinator::asyncFrameOrOverflowScrollingEnabled() const >+{ >+ auto& settings = m_page->mainFrame().settings(); >+ return settings.asyncFrameScrollingEnabled() || settings.asyncOverflowScrollingEnabled(); >+} >+ >+String ScrollingCoordinator::scrollingStateTreeAsText(ScrollingStateTreeAsTextBehavior behavior) const >+{ >+ if (m_scrollingStateTree->rootStateNode()) { >+ if (m_eventTrackingRegionsDirty) >+ m_scrollingStateTree->rootStateNode()->setEventTrackingRegions(absoluteEventTrackingRegions()); >+ return m_scrollingStateTree->rootStateNode()->scrollingStateTreeAsText(behavior); >+ } >+ >+ return String(); >+} >+ >+#if PLATFORM(COCOA) >+void ScrollingCoordinator::setActiveScrollSnapIndices(ScrollingNodeID scrollingNodeID, unsigned horizontalIndex, unsigned verticalIndex) >+{ >+ ASSERT(isMainThread()); >+ >+ if (!m_page) >+ return; >+ >+ auto* frameView = frameViewForScrollingNode(scrollingNodeID); >+ if (!frameView) >+ return; >+ >+ if (scrollingNodeID == frameView->scrollingNodeID()) { >+ frameView->setCurrentHorizontalSnapPointIndex(horizontalIndex); >+ frameView->setCurrentVerticalSnapPointIndex(verticalIndex); >+ return; >+ } >+ >+ // Overflow-scroll area. >+ if (auto* scrollableArea = frameView->scrollableAreaForScrollLayerID(scrollingNodeID)) { >+ scrollableArea->setCurrentHorizontalSnapPointIndex(horizontalIndex); >+ scrollableArea->setCurrentVerticalSnapPointIndex(verticalIndex); >+ } >+} >+ >+void ScrollingCoordinator::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, " (!) ScrollingCoordinator::deferTestsForReason: Deferring %p for reason %d.", identifier, reason); >+ trigger->deferTestsForReason(identifier, reason); >+ } >+} >+ >+void ScrollingCoordinator::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, " (!) ScrollingCoordinator::removeTestDeferralForReason: Deferring %p for reason %d.", identifier, reason); >+ trigger->removeTestDeferralForReason(identifier, reason); >+ } >+} >+#endif >+ >+#if ENABLE(CSS_SCROLL_SNAP) >+bool ScrollingCoordinator::isScrollSnapInProgress() const >+{ >+ return scrollingTree()->isScrollSnapInProgress(); >+} >+ >+void ScrollingCoordinator::updateScrollSnapPropertiesWithFrameView(const FrameView& frameView) >+{ >+ if (auto node = downcast<ScrollingStateFrameScrollingNode>(m_scrollingStateTree->stateNodeForID(frameView.scrollingNodeID()))) { >+ setStateScrollingNodeSnapOffsetsAsFloat(*node, ScrollEventAxis::Horizontal, frameView.horizontalSnapOffsets(), frameView.horizontalSnapOffsetRanges(), m_page->deviceScaleFactor()); >+ setStateScrollingNodeSnapOffsetsAsFloat(*node, ScrollEventAxis::Vertical, frameView.verticalSnapOffsets(), frameView.verticalSnapOffsetRanges(), m_page->deviceScaleFactor()); >+ node->setCurrentHorizontalSnapPointIndex(frameView.currentHorizontalSnapPointIndex()); >+ node->setCurrentVerticalSnapPointIndex(frameView.currentVerticalSnapPointIndex()); >+ } >+} >+#endif >+ >+void ScrollingCoordinator::reportExposedUnfilledArea(MonotonicTime timestamp, unsigned unfilledArea) >+{ >+ if (m_page && m_page->performanceLoggingClient()) >+ m_page->performanceLoggingClient()->logScrollingEvent(PerformanceLoggingClient::ScrollingEvent::ExposedTilelessArea, timestamp, unfilledArea); >+} >+ >+void ScrollingCoordinator::reportSynchronousScrollingReasonsChanged(MonotonicTime timestamp, SynchronousScrollingReasons reasons) >+{ >+ if (m_page && m_page->performanceLoggingClient()) >+ m_page->performanceLoggingClient()->logScrollingEvent(PerformanceLoggingClient::ScrollingEvent::SwitchedScrollingMode, timestamp, reasons); >+} >+ > TextStream& operator<<(TextStream& ts, ScrollableAreaParameters scrollableAreaParameters) > { > ts.dumpProperty("horizontal scroll elasticity", scrollableAreaParameters.horizontalScrollElasticity); >@@ -494,3 +1204,5 @@ TextStream& operator<<(TextStream& ts, V > } > > } // namespace WebCore >+ >+#endif // ENABLE(ASYNC_SCROLLING) >Index: Source/WebCore/page/scrolling/ScrollingCoordinator.h >=================================================================== >--- Source/WebCore/page/scrolling/ScrollingCoordinator.h (revision 240892) >+++ Source/WebCore/page/scrolling/ScrollingCoordinator.h (working copy) >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2011, 2015 Apple Inc. All rights reserved. >+ * Copyright (C) 2014-2019 Apple Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -36,19 +36,17 @@ > #include <wtf/TypeCasts.h> > #include <wtf/Variant.h> > >-#if ENABLE(ASYNC_SCROLLING) > #include <wtf/HashMap.h> > #include <wtf/ThreadSafeRefCounted.h> > #include <wtf/Threading.h> >-#endif > > #if ENABLE(CSS_SCROLL_SNAP) > #include "AxisScrollSnapOffsets.h" > #endif > >-namespace WTF { >-class TextStream; >-} >+#include "ScrollingTree.h" >+#include "Timer.h" >+#include <wtf/RefPtr.h> > > namespace WebCore { > >@@ -57,36 +55,35 @@ class Frame; > class FrameView; > class GraphicsLayer; > class Page; >-class Region; > class RenderLayer; > class ScrollableArea; >+class Scrollbar; >+class ScrollingStateNode; >+class ScrollingStateScrollingNode; >+class ScrollingStateTree; > class ViewportConstraints; > >-#if ENABLE(ASYNC_SCROLLING) >-class ScrollingTree; >-#endif >- > class ScrollingCoordinator : public ThreadSafeRefCounted<ScrollingCoordinator> { > public: > static Ref<ScrollingCoordinator> create(Page*); >- virtual ~ScrollingCoordinator(); >+ WEBCORE_EXPORT virtual ~ScrollingCoordinator(); > >- WEBCORE_EXPORT virtual void pageDestroyed(); >- >- virtual bool isAsyncScrollingCoordinator() const { return false; } > virtual bool isRemoteScrollingCoordinator() const { return false; } > >+ WEBCORE_EXPORT virtual void pageDestroyed(); >+ >+ virtual void commitTreeStateIfNeeded() { } >+ virtual ScrollingEventResult handleWheelEvent(FrameView&, const PlatformWheelEvent&) { return ScrollingEventResult::DidNotHandleEvent; } >+ >+ ScrollingTree* scrollingTree() const { return m_scrollingTree.get(); } >+ > // Return whether this scrolling coordinator handles scrolling for the given frame view. > WEBCORE_EXPORT virtual bool coordinatesScrollingForFrameView(const FrameView&) const; > > // Return whether this scrolling coordinator handles scrolling for the given overflow scroll layer. > WEBCORE_EXPORT virtual bool coordinatesScrollingForOverflowLayer(const RenderLayer&) const; > >- // Should be called whenever the given frame view has been laid out. >- virtual void frameViewLayoutUpdated(FrameView&) { } >- > using LayoutViewportOriginOrOverrideRect = WTF::Variant<Optional<FloatPoint>, Optional<FloatRect>>; >- virtual void reconcileScrollingState(FrameView&, const FloatPoint&, const LayoutViewportOriginOrOverrideRect&, bool /* programmaticScroll */, ViewportRectStability, ScrollingLayerPositionAction) { } > > // Should be called whenever the slow repaint objects counter changes between zero and one. > void frameViewHasSlowRepaintObjectsDidChange(FrameView&); >@@ -94,12 +91,6 @@ public: > // 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 frameViewEventTrackingRegionsChanged(FrameView&) { } >- >- // Should be called whenever the root layer for the given frame view changes. >- virtual void frameViewRootLayerDidChange(FrameView&); >- > #if PLATFORM(COCOA) > // Dispatched by the scrolling tree during handleWheelEvent. This is required as long as scrollbars are painted on the main thread. > void handleWheelEventPhase(PlatformWheelEventPhase); >@@ -108,26 +99,21 @@ public: > // Force all scroll layer position updates to happen on the main thread. > WEBCORE_EXPORT void setForceSynchronousScrollLayerPositionUpdates(bool); > >- // These virtual functions are currently unique to the threaded scrolling architecture. >- virtual void commitTreeStateIfNeeded() { } >- virtual bool requestScrollPositionUpdate(FrameView&, const IntPoint&) { return false; } >- virtual ScrollingEventResult handleWheelEvent(FrameView&, const PlatformWheelEvent&) { return ScrollingEventResult::DidNotHandleEvent; } >+ WEBCORE_EXPORT void frameViewLayoutUpdated(FrameView&); >+ WEBCORE_EXPORT void frameViewRootLayerDidChange(FrameView&); >+ WEBCORE_EXPORT void frameViewEventTrackingRegionsChanged(FrameView&); >+ >+ WEBCORE_EXPORT bool requestScrollPositionUpdate(FrameView&, const IntPoint&); >+ >+ WEBCORE_EXPORT ScrollingNodeID createNode(ScrollingNodeType, ScrollingNodeID newNodeID); >+ WEBCORE_EXPORT ScrollingNodeID insertNode(ScrollingNodeType, ScrollingNodeID newNodeID, ScrollingNodeID parentID, size_t childIndex); >+ WEBCORE_EXPORT void unparentNode(ScrollingNodeID); >+ WEBCORE_EXPORT void unparentChildrenAndDestroyNode(ScrollingNodeID); >+ WEBCORE_EXPORT void detachAndDestroySubtree(ScrollingNodeID); >+ WEBCORE_EXPORT void clearAllNodes(); > >- // Create an unparented node. >- virtual ScrollingNodeID createNode(ScrollingNodeType, ScrollingNodeID newNodeID) { return newNodeID; } >- // Parent a node in the scrolling tree. This may return a new nodeID if the node type changed. parentID = 0 sets the root node. >- virtual ScrollingNodeID insertNode(ScrollingNodeType, ScrollingNodeID newNodeID, ScrollingNodeID /*parentID*/, size_t /*childIndex*/ = notFound) { return newNodeID; } >- // Node will be unparented, but not destroyed. It's the client's responsibility to either re-parent or destroy this node. >- virtual void unparentNode(ScrollingNodeID) { } >- // Node will be destroyed, and its children left unparented. >- virtual void unparentChildrenAndDestroyNode(ScrollingNodeID) { } >- // Node will be unparented, and it and its children destroyed. >- virtual void detachAndDestroySubtree(ScrollingNodeID) { } >- // Destroy the tree, including both parented and unparented nodes. >- virtual void clearAllNodes() { } >- >- virtual ScrollingNodeID parentOfNode(ScrollingNodeID) const { return 0; } >- virtual Vector<ScrollingNodeID> childrenOfNode(ScrollingNodeID) const { return { }; } >+ WEBCORE_EXPORT ScrollingNodeID parentOfNode(ScrollingNodeID) const; >+ WEBCORE_EXPORT Vector<ScrollingNodeID> childrenOfNode(ScrollingNodeID) const; > > struct NodeLayers { > GraphicsLayer* layer { nullptr }; >@@ -137,7 +123,7 @@ public: > GraphicsLayer* insetClipLayer { nullptr }; > GraphicsLayer* rootContentsLayer { nullptr }; > }; >- virtual void setNodeLayers(ScrollingNodeID, const NodeLayers&) { } >+ WEBCORE_EXPORT void setNodeLayers(ScrollingNodeID, const NodeLayers&); > > struct ScrollingGeometry { > LayoutRect parentRelativeScrollableRect; >@@ -155,16 +141,18 @@ public: > unsigned currentVerticalSnapPointIndex; > #endif > }; >+ WEBCORE_EXPORT void setScrollingNodeGeometry(ScrollingNodeID, const ScrollingGeometry&); >+ WEBCORE_EXPORT void setViewportConstraintedNodeGeometry(ScrollingNodeID, const ViewportConstraints&); >+ >+ WEBCORE_EXPORT void reconcileScrollingState(FrameView&, const FloatPoint&, const LayoutViewportOriginOrOverrideRect&, bool programmaticScroll, ViewportRectStability, ScrollingLayerPositionAction); > >- virtual void setScrollingNodeGeometry(ScrollingNodeID, const ScrollingGeometry&) { } >- virtual void setViewportConstraintedNodeGeometry(ScrollingNodeID, const ViewportConstraints&) { } >+ WEBCORE_EXPORT void reconcileViewportConstrainedLayerPositions(ScrollingNodeID, const LayoutRect& viewportRect, ScrollingLayerPositionAction); >+ WEBCORE_EXPORT void scrollableAreaScrollbarLayerDidChange(ScrollableArea&, ScrollbarOrientation); > >- virtual void reconcileViewportConstrainedLayerPositions(ScrollingNodeID, const LayoutRect&, ScrollingLayerPositionAction) { } >- virtual String scrollingStateTreeAsText(ScrollingStateTreeAsTextBehavior = ScrollingStateTreeAsTextBehaviorNormal) const; >- virtual bool isRubberBandInProgress() const { return false; } >- virtual bool isScrollSnapInProgress() const { return false; } >- virtual void updateScrollSnapPropertiesWithFrameView(const FrameView&) { } >- virtual void setScrollPinningBehavior(ScrollPinningBehavior) { } >+ WEBCORE_EXPORT void setSynchronousScrollingReasons(FrameView&, SynchronousScrollingReasons); >+ >+ WEBCORE_EXPORT String scrollingStateTreeAsText(ScrollingStateTreeAsTextBehavior = ScrollingStateTreeAsTextBehaviorNormal) const; >+ WEBCORE_EXPORT void willCommitTree(); > > // Generated a unique id for scrolling nodes. > ScrollingNodeID uniqueScrollingNodeID(); >@@ -180,17 +168,40 @@ public: > SynchronousScrollingReasons synchronousScrollingReasons(const FrameView&) const; > bool shouldUpdateScrollLayerPositionSynchronously(const FrameView&) const; > >- virtual void willDestroyScrollableArea(ScrollableArea&) { } >- virtual void scrollableAreaScrollbarLayerDidChange(ScrollableArea&, ScrollbarOrientation) { } >- > static String synchronousScrollingReasonsAsText(SynchronousScrollingReasons); > String synchronousScrollingReasonsAsText() const; > > EventTrackingRegions absoluteEventTrackingRegions() const; >- virtual void updateExpectsWheelEventTestTriggerWithFrameView(const FrameView&) { } >+ >+ void scrollingStateTreePropertiesChanged(); >+ >+ WEBCORE_EXPORT void scheduleUpdateScrollPositionAfterAsyncScroll(ScrollingNodeID, const FloatPoint&, const Optional<FloatPoint>& layoutViewportOrigin, bool programmaticScroll, ScrollingLayerPositionAction); >+ >+#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&); >+ virtual bool isScrollSnapInProgress() const; >+#endif >+ >+ virtual bool isRubberBandInProgress() const; >+ >+ bool visualViewportEnabled() const; >+ bool asyncFrameOrOverflowScrollingEnabled() const; >+ >+ virtual void setScrollPinningBehavior(ScrollPinningBehavior); >+ >+ WEBCORE_EXPORT void updateExpectsWheelEventTestTriggerWithFrameView(const FrameView&); >+ >+ void reportExposedUnfilledArea(MonotonicTime, unsigned unfilledArea); >+ void reportSynchronousScrollingReasonsChanged(MonotonicTime, SynchronousScrollingReasons); > > protected: >- explicit ScrollingCoordinator(Page*); >+ WEBCORE_EXPORT ScrollingCoordinator(Page*); > > GraphicsLayer* scrollLayerForFrameView(FrameView&); > GraphicsLayer* counterScrollingLayerForFrameView(FrameView&); >@@ -200,20 +211,63 @@ protected: > GraphicsLayer* headerLayerForFrameView(FrameView&); > GraphicsLayer* footerLayerForFrameView(FrameView&); > >- virtual void willCommitTree() { } >+ void setScrollingTree(Ref<ScrollingTree>&& scrollingTree) { m_scrollingTree = WTFMove(scrollingTree); } > >- Page* m_page; // FIXME: ideally this would be a reference but it gets nulled on async teardown. >+ ScrollingStateTree* scrollingStateTree() { return m_scrollingStateTree.get(); } > >-private: >- virtual void setSynchronousScrollingReasons(FrameView&, SynchronousScrollingReasons) { } >+ RefPtr<ScrollingTree> releaseScrollingTree() { return WTFMove(m_scrollingTree); } >+ >+ void updateScrollPositionAfterAsyncScroll(ScrollingNodeID, const FloatPoint&, Optional<FloatPoint> layoutViewportOrigin, bool programmaticScroll, ScrollingLayerPositionAction); >+ >+ bool eventTrackingRegionsDirty() const { return m_eventTrackingRegionsDirty; } > >- virtual bool hasVisibleSlowRepaintViewportConstrainedObjects(const FrameView&) const; >+private: > void updateSynchronousScrollingReasons(FrameView&); > void updateSynchronousScrollingReasonsForAllFrames(); > > EventTrackingRegions absoluteEventTrackingRegionsForFrame(const Frame&) const; > >+ bool hasVisibleSlowRepaintViewportConstrainedObjects(const FrameView&) const; >+ >+ virtual void scheduleTreeStateCommit() = 0; >+ >+ void ensureRootStateNodeForFrameView(FrameView&); >+ void updateScrollLayerPosition(FrameView&); >+ >+ void updateScrollPositionAfterAsyncScrollTimerFired(); >+ void setEventTrackingRegionsDirty(); >+ void updateEventTrackingRegions(); >+ >+ FrameView* frameViewForScrollingNode(ScrollingNodeID) const; >+ >+protected: >+ Page* m_page; // FIXME: ideally this would be a reference but it gets nulled on async teardown. >+ >+private: >+ Timer m_updateNodeScrollPositionTimer; >+ >+ struct ScheduledScrollUpdate { >+ ScrollingNodeID nodeID { 0 }; >+ FloatPoint scrollPosition; >+ Optional<FloatPoint> layoutViewportOrigin; >+ bool isProgrammaticScroll { false }; >+ ScrollingLayerPositionAction updateLayerPositionAction { ScrollingLayerPositionAction::Sync }; >+ >+ 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_forceSynchronousScrollLayerPositionUpdates { false }; >+ bool m_eventTrackingRegionsDirty { false }; > }; > > WEBCORE_EXPORT WTF::TextStream& operator<<(WTF::TextStream&, ScrollableAreaParameters); >Index: Source/WebCore/page/scrolling/ScrollingStateNode.h >=================================================================== >--- Source/WebCore/page/scrolling/ScrollingStateNode.h (revision 240892) >+++ Source/WebCore/page/scrolling/ScrollingStateNode.h (working copy) >@@ -25,8 +25,6 @@ > > #pragma once > >-#if ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS) >- > #include "GraphicsLayer.h" > #include "ScrollingCoordinator.h" > #include <stdint.h> >@@ -285,5 +283,3 @@ void ScrollingStateNode::setPropertyChan > SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToValueTypeName) \ > static bool isType(const WebCore::ScrollingStateNode& node) { return node.predicate; } \ > SPECIALIZE_TYPE_TRAITS_END() >- >-#endif // ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS) >Index: Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h >=================================================================== >--- Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h (revision 240892) >+++ Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h (working copy) >@@ -25,8 +25,6 @@ > > #pragma once > >-#if ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS) >- > #include "ScrollSnapOffsetsInfo.h" > #include "ScrollTypes.h" > #include "ScrollingCoordinator.h" >@@ -147,5 +145,3 @@ private: > } // namespace WebCore > > SPECIALIZE_TYPE_TRAITS_SCROLLING_STATE_NODE(ScrollingStateScrollingNode, isScrollingNode()) >- >-#endif // ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS) >Index: Source/WebCore/page/scrolling/ScrollingStateTree.cpp >=================================================================== >--- Source/WebCore/page/scrolling/ScrollingStateTree.cpp (revision 240892) >+++ Source/WebCore/page/scrolling/ScrollingStateTree.cpp (working copy) >@@ -28,8 +28,8 @@ > > #if ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS) > >-#include "AsyncScrollingCoordinator.h" > #include "Logging.h" >+#include "ScrollingCoordinator.h" > #include "ScrollingStateFixedNode.h" > #include "ScrollingStateFrameHostingNode.h" > #include "ScrollingStateFrameScrollingNode.h" >@@ -40,7 +40,7 @@ > > namespace WebCore { > >-ScrollingStateTree::ScrollingStateTree(AsyncScrollingCoordinator* scrollingCoordinator) >+ScrollingStateTree::ScrollingStateTree(ScrollingCoordinator* scrollingCoordinator) > : m_scrollingCoordinator(scrollingCoordinator) > { > } >Index: Source/WebCore/page/scrolling/ScrollingStateTree.h >=================================================================== >--- Source/WebCore/page/scrolling/ScrollingStateTree.h (revision 240892) >+++ Source/WebCore/page/scrolling/ScrollingStateTree.h (working copy) >@@ -33,7 +33,7 @@ > > namespace WebCore { > >-class AsyncScrollingCoordinator; >+class ScrollingCoordinator; > class ScrollingStateFrameScrollingNode; > > // The ScrollingStateTree is a tree that managed ScrollingStateNodes. The nodes keep track of the current >@@ -45,7 +45,7 @@ class ScrollingStateTree { > WTF_MAKE_FAST_ALLOCATED; > friend class ScrollingStateNode; > public: >- WEBCORE_EXPORT ScrollingStateTree(AsyncScrollingCoordinator* = nullptr); >+ WEBCORE_EXPORT ScrollingStateTree(ScrollingCoordinator* = nullptr); > WEBCORE_EXPORT ~ScrollingStateTree(); > > ScrollingStateFrameScrollingNode* rootStateNode() const { return m_rootStateNode.get(); } >@@ -90,7 +90,7 @@ private: > void recursiveNodeWillBeRemoved(ScrollingStateNode* currNode); > void willRemoveNode(ScrollingStateNode*); > >- AsyncScrollingCoordinator* m_scrollingCoordinator; >+ ScrollingCoordinator* m_scrollingCoordinator; > // Contains all the nodes we know about (those in the m_rootStateNode tree, and in m_unparentedNodes subtrees). > StateNodeMap m_stateNodeMap; > // Owns roots of unparented subtrees. >Index: Source/WebCore/page/scrolling/ScrollingTree.cpp >=================================================================== >--- Source/WebCore/page/scrolling/ScrollingTree.cpp (revision 240892) >+++ Source/WebCore/page/scrolling/ScrollingTree.cpp (working copy) >@@ -26,8 +26,6 @@ > #include "config.h" > #include "ScrollingTree.h" > >-#if ENABLE(ASYNC_SCROLLING) >- > #include "EventNames.h" > #include "Logging.h" > #include "PlatformWheelEvent.h" >@@ -465,5 +463,3 @@ Optional<TouchActionData> ScrollingTree: > #endif > > } // namespace WebCore >- >-#endif // ENABLE(ASYNC_SCROLLING) >Index: Source/WebCore/page/scrolling/ScrollingTree.h >=================================================================== >--- Source/WebCore/page/scrolling/ScrollingTree.h (revision 240892) >+++ Source/WebCore/page/scrolling/ScrollingTree.h (working copy) >@@ -25,8 +25,6 @@ > > #pragma once > >-#if ENABLE(ASYNC_SCROLLING) >- > #include "PlatformWheelEvent.h" > #include "Region.h" > #include "ScrollingCoordinator.h" >@@ -203,4 +201,3 @@ private: > SPECIALIZE_TYPE_TRAITS_BEGIN(ToValueTypeName) \ > static bool isType(const WebCore::ScrollingTree& tree) { return tree.predicate; } \ > SPECIALIZE_TYPE_TRAITS_END() >-#endif // ENABLE(ASYNC_SCROLLING) >Index: Source/WebCore/page/scrolling/ScrollingTreeNode.h >=================================================================== >--- Source/WebCore/page/scrolling/ScrollingTreeNode.h (revision 240892) >+++ Source/WebCore/page/scrolling/ScrollingTreeNode.h (working copy) >@@ -25,8 +25,6 @@ > > #pragma once > >-#if ENABLE(ASYNC_SCROLLING) >- > #include "IntRect.h" > #include "ScrollTypes.h" > #include "ScrollingCoordinator.h" >@@ -102,5 +100,3 @@ private: > SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToValueTypeName) \ > static bool isType(const WebCore::ScrollingTreeNode& node) { return node.predicate; } \ > SPECIALIZE_TYPE_TRAITS_END() >- >-#endif // ENABLE(ASYNC_SCROLLING) >Index: Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h >=================================================================== >--- Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h (revision 240892) >+++ Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h (working copy) >@@ -25,8 +25,6 @@ > > #pragma once > >-#if ENABLE(ASYNC_SCROLLING) >- > #include "IntRect.h" > #include "ScrollSnapOffsetsInfo.h" > #include "ScrollTypes.h" >@@ -146,5 +144,3 @@ private: > } // namespace WebCore > > SPECIALIZE_TYPE_TRAITS_SCROLLING_NODE(ScrollingTreeScrollingNode, isScrollingNode()) >- >-#endif // ENABLE(ASYNC_SCROLLING) >Index: Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp >=================================================================== >--- Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp (revision 240892) >+++ Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp (working copy) >@@ -28,8 +28,8 @@ > > #if ENABLE(ASYNC_SCROLLING) > >-#include "AsyncScrollingCoordinator.h" > #include "PlatformWheelEvent.h" >+#include "ScrollingCoordinator.h" > #include "ScrollingThread.h" > #include "ScrollingTreeNode.h" > #include "ScrollingTreeScrollingNode.h" >@@ -37,7 +37,7 @@ > > namespace WebCore { > >-ThreadedScrollingTree::ThreadedScrollingTree(AsyncScrollingCoordinator& scrollingCoordinator) >+ThreadedScrollingTree::ThreadedScrollingTree(ScrollingCoordinator& scrollingCoordinator) > : m_scrollingCoordinator(&scrollingCoordinator) > { > } >Index: Source/WebCore/page/scrolling/ThreadedScrollingTree.h >=================================================================== >--- Source/WebCore/page/scrolling/ThreadedScrollingTree.h (revision 240892) >+++ Source/WebCore/page/scrolling/ThreadedScrollingTree.h (working copy) >@@ -33,7 +33,7 @@ > > namespace WebCore { > >-class AsyncScrollingCoordinator; >+class ScrollingCoordinator; > > // 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 >@@ -55,7 +55,7 @@ public: > void invalidate() override; > > protected: >- explicit ThreadedScrollingTree(AsyncScrollingCoordinator&); >+ explicit ThreadedScrollingTree(ScrollingCoordinator&); > > void scrollingTreeNodeDidScroll(ScrollingNodeID, const FloatPoint& scrollPosition, const Optional<FloatPoint>& layoutViewportOrigin, ScrollingLayerPositionAction = ScrollingLayerPositionAction::Sync) override; > #if PLATFORM(MAC) >@@ -75,7 +75,7 @@ protected: > private: > bool isThreadedScrollingTree() const override { return true; } > >- RefPtr<AsyncScrollingCoordinator> m_scrollingCoordinator; >+ RefPtr<ScrollingCoordinator> m_scrollingCoordinator; > }; > > } // namespace WebCore >Index: Source/WebCore/page/scrolling/ios/ScrollingCoordinatorIOS.h >=================================================================== >--- Source/WebCore/page/scrolling/ios/ScrollingCoordinatorIOS.h (revision 240892) >+++ Source/WebCore/page/scrolling/ios/ScrollingCoordinatorIOS.h (working copy) >@@ -27,7 +27,7 @@ > > #if ENABLE(ASYNC_SCROLLING) && PLATFORM(IOS_FAMILY) > >-#include "AsyncScrollingCoordinator.h" >+#include "ScrollingCoordinator.h" > > namespace WebCore { > >@@ -37,7 +37,7 @@ class ScrollingStateScrollingNode; > class ScrollingStateTree; > class ThreadedScrollingTree; > >-class ScrollingCoordinatorIOS : public AsyncScrollingCoordinator { >+class ScrollingCoordinatorIOS : public ScrollingCoordinator { > public: > explicit ScrollingCoordinatorIOS(Page*); > virtual ~ScrollingCoordinatorIOS(); >Index: Source/WebCore/page/scrolling/ios/ScrollingCoordinatorIOS.mm >=================================================================== >--- Source/WebCore/page/scrolling/ios/ScrollingCoordinatorIOS.mm (revision 240892) >+++ Source/WebCore/page/scrolling/ios/ScrollingCoordinatorIOS.mm (working copy) >@@ -49,7 +49,7 @@ Ref<ScrollingCoordinator> ScrollingCoord > } > > ScrollingCoordinatorIOS::ScrollingCoordinatorIOS(Page* page) >- : AsyncScrollingCoordinator(page) >+ : ScrollingCoordinator(page) > , m_scrollingStateTreeCommitterTimer(*this, &ScrollingCoordinatorIOS::commitTreeState) > { > setScrollingTree(ScrollingTreeIOS::create(*this)); >@@ -62,7 +62,7 @@ ScrollingCoordinatorIOS::~ScrollingCoord > > void ScrollingCoordinatorIOS::pageDestroyed() > { >- AsyncScrollingCoordinator::pageDestroyed(); >+ ScrollingCoordinator::pageDestroyed(); > > m_scrollingStateTreeCommitterTimer.stop(); > >Index: Source/WebCore/page/scrolling/ios/ScrollingTreeIOS.cpp >=================================================================== >--- Source/WebCore/page/scrolling/ios/ScrollingTreeIOS.cpp (revision 240892) >+++ Source/WebCore/page/scrolling/ios/ScrollingTreeIOS.cpp (working copy) >@@ -28,8 +28,8 @@ > > #if ENABLE(ASYNC_SCROLLING) && PLATFORM(IOS_FAMILY) > >-#include "AsyncScrollingCoordinator.h" > #include "PlatformWheelEvent.h" >+#include "ScrollingCoordinator.h" > #include "ScrollingThread.h" > #include "ScrollingTreeFixedNode.h" > #include "ScrollingTreeFrameHostingNode.h" >@@ -41,12 +41,12 @@ > > namespace WebCore { > >-Ref<ScrollingTreeIOS> ScrollingTreeIOS::create(AsyncScrollingCoordinator& scrollingCoordinator) >+Ref<ScrollingTreeIOS> ScrollingTreeIOS::create(ScrollingCoordinator& scrollingCoordinator) > { > return adoptRef(*new ScrollingTreeIOS(scrollingCoordinator)); > } > >-ScrollingTreeIOS::ScrollingTreeIOS(AsyncScrollingCoordinator& scrollingCoordinator) >+ScrollingTreeIOS::ScrollingTreeIOS(ScrollingCoordinator& scrollingCoordinator) > : m_scrollingCoordinator(&scrollingCoordinator) > { > } >Index: Source/WebCore/page/scrolling/ios/ScrollingTreeIOS.h >=================================================================== >--- Source/WebCore/page/scrolling/ios/ScrollingTreeIOS.h (revision 240892) >+++ Source/WebCore/page/scrolling/ios/ScrollingTreeIOS.h (working copy) >@@ -32,15 +32,15 @@ > > namespace WebCore { > >-class AsyncScrollingCoordinator; >+class ScrollingCoordinator; > > class ScrollingTreeIOS final : public ScrollingTree { > public: >- static Ref<ScrollingTreeIOS> create(AsyncScrollingCoordinator&); >+ static Ref<ScrollingTreeIOS> create(ScrollingCoordinator&); > virtual ~ScrollingTreeIOS(); > > private: >- explicit ScrollingTreeIOS(AsyncScrollingCoordinator&); >+ explicit ScrollingTreeIOS(ScrollingCoordinator&); > > bool isScrollingTreeIOS() const final { return true; } > >@@ -55,7 +55,7 @@ private: > void currentSnapPointIndicesDidChange(WebCore::ScrollingNodeID, unsigned horizontal, unsigned vertical) final; > FloatRect fixedPositionRect() final; > >- RefPtr<AsyncScrollingCoordinator> m_scrollingCoordinator; >+ RefPtr<ScrollingCoordinator> m_scrollingCoordinator; > }; > > } // namespace WebCore >Index: Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.h >=================================================================== >--- Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.h (revision 240892) >+++ Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.h (working copy) >@@ -27,7 +27,7 @@ > > #if ENABLE(ASYNC_SCROLLING) && PLATFORM(MAC) > >-#include "AsyncScrollingCoordinator.h" >+#include "ScrollingCoordinator.h" > > namespace WebCore { > >@@ -37,7 +37,7 @@ class ScrollingStateScrollingNode; > class ScrollingStateTree; > class ThreadedScrollingTree; > >-class ScrollingCoordinatorMac : public AsyncScrollingCoordinator { >+class ScrollingCoordinatorMac : public ScrollingCoordinator { > public: > explicit ScrollingCoordinatorMac(Page*); > virtual ~ScrollingCoordinatorMac(); >Index: Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm >=================================================================== >--- Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm (revision 240892) >+++ Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm (working copy) >@@ -52,7 +52,7 @@ Ref<ScrollingCoordinator> ScrollingCoord > } > > ScrollingCoordinatorMac::ScrollingCoordinatorMac(Page* page) >- : AsyncScrollingCoordinator(page) >+ : ScrollingCoordinator(page) > , m_scrollingStateTreeCommitterTimer(*this, &ScrollingCoordinatorMac::commitTreeState) > { > setScrollingTree(ScrollingTreeMac::create(*this)); >@@ -65,7 +65,7 @@ ScrollingCoordinatorMac::~ScrollingCoord > > void ScrollingCoordinatorMac::pageDestroyed() > { >- AsyncScrollingCoordinator::pageDestroyed(); >+ ScrollingCoordinator::pageDestroyed(); > > m_scrollingStateTreeCommitterTimer.stop(); > >Index: Source/WebCore/page/scrolling/mac/ScrollingTreeMac.cpp >=================================================================== >--- Source/WebCore/page/scrolling/mac/ScrollingTreeMac.cpp (revision 240892) >+++ Source/WebCore/page/scrolling/mac/ScrollingTreeMac.cpp (working copy) >@@ -36,12 +36,12 @@ > > using namespace WebCore; > >-Ref<ScrollingTreeMac> ScrollingTreeMac::create(AsyncScrollingCoordinator& scrollingCoordinator) >+Ref<ScrollingTreeMac> ScrollingTreeMac::create(ScrollingCoordinator& scrollingCoordinator) > { > return adoptRef(*new ScrollingTreeMac(scrollingCoordinator)); > } > >-ScrollingTreeMac::ScrollingTreeMac(AsyncScrollingCoordinator& scrollingCoordinator) >+ScrollingTreeMac::ScrollingTreeMac(ScrollingCoordinator& scrollingCoordinator) > : ThreadedScrollingTree(scrollingCoordinator) > { > } >Index: Source/WebCore/page/scrolling/mac/ScrollingTreeMac.h >=================================================================== >--- Source/WebCore/page/scrolling/mac/ScrollingTreeMac.h (revision 240892) >+++ Source/WebCore/page/scrolling/mac/ScrollingTreeMac.h (working copy) >@@ -33,10 +33,10 @@ namespace WebCore { > > class ScrollingTreeMac final : public ThreadedScrollingTree { > public: >- static Ref<ScrollingTreeMac> create(AsyncScrollingCoordinator&); >+ static Ref<ScrollingTreeMac> create(ScrollingCoordinator&); > > private: >- explicit ScrollingTreeMac(AsyncScrollingCoordinator&); >+ explicit ScrollingTreeMac(ScrollingCoordinator&); > > Ref<ScrollingTreeNode> createScrollingTreeNode(ScrollingNodeType, ScrollingNodeID) final; > }; >Index: Source/WebCore/page/scrolling/nicosia/ScrollingCoordinatorNicosia.cpp >=================================================================== >--- Source/WebCore/page/scrolling/nicosia/ScrollingCoordinatorNicosia.cpp (revision 240892) >+++ Source/WebCore/page/scrolling/nicosia/ScrollingCoordinatorNicosia.cpp (working copy) >@@ -41,7 +41,7 @@ Ref<ScrollingCoordinator> ScrollingCoord > } > > ScrollingCoordinatorNicosia::ScrollingCoordinatorNicosia(Page* page) >- : AsyncScrollingCoordinator(page) >+ : ScrollingCoordinator(page) > , m_scrollingStateTreeCommitterTimer(RunLoop::main(), this, &ScrollingCoordinatorNicosia::commitTreeState) > { > setScrollingTree(ScrollingTreeNicosia::create(*this)); >@@ -54,7 +54,7 @@ ScrollingCoordinatorNicosia::~ScrollingC > > void ScrollingCoordinatorNicosia::pageDestroyed() > { >- AsyncScrollingCoordinator::pageDestroyed(); >+ ScrollingCoordinator::pageDestroyed(); > > m_scrollingStateTreeCommitterTimer.stop(); > >Index: Source/WebCore/page/scrolling/nicosia/ScrollingCoordinatorNicosia.h >=================================================================== >--- Source/WebCore/page/scrolling/nicosia/ScrollingCoordinatorNicosia.h (revision 240892) >+++ Source/WebCore/page/scrolling/nicosia/ScrollingCoordinatorNicosia.h (working copy) >@@ -29,13 +29,13 @@ > > #if ENABLE(ASYNC_SCROLLING) && USE(NICOSIA) > >-#include "AsyncScrollingCoordinator.h" >+#include "ScrollingCoordinator.h" > > #include <wtf/RunLoop.h> > > namespace WebCore { > >-class ScrollingCoordinatorNicosia final : public AsyncScrollingCoordinator { >+class ScrollingCoordinatorNicosia final : public ScrollingCoordinator { > public: > explicit ScrollingCoordinatorNicosia(Page*); > virtual ~ScrollingCoordinatorNicosia(); >Index: Source/WebCore/rendering/RenderLayer.cpp >=================================================================== >--- Source/WebCore/rendering/RenderLayer.cpp (revision 240892) >+++ Source/WebCore/rendering/RenderLayer.cpp (working copy) >@@ -356,9 +356,6 @@ RenderLayer::~RenderLayer() > destroyScrollbar(HorizontalScrollbar); > destroyScrollbar(VerticalScrollbar); > >- if (auto* scrollingCoordinator = renderer().page().scrollingCoordinator()) >- scrollingCoordinator->willDestroyScrollableArea(*this); >- > if (m_reflection) > removeReflection(); > >Index: Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp >=================================================================== >--- Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp (revision 240892) >+++ Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp (working copy) >@@ -38,7 +38,7 @@ > #include <wtf/RunLoop.h> > > #if ENABLE(ASYNC_SCROLLING) >-#include <WebCore/AsyncScrollingCoordinator.h> >+#include <WebCore/ScrollingCoordinator.h> > #include <WebCore/ScrollingThread.h> > #include <WebCore/ThreadedScrollingTree.h> > #endif >@@ -69,7 +69,7 @@ void EventDispatcher::addScrollingTreeFo > ASSERT(webPage->corePage()->scrollingCoordinator()); > ASSERT(!m_scrollingTrees.contains(webPage->pageID())); > >- AsyncScrollingCoordinator& scrollingCoordinator = downcast<AsyncScrollingCoordinator>(*webPage->corePage()->scrollingCoordinator()); >+ ScrollingCoordinator& scrollingCoordinator = *webPage->corePage()->scrollingCoordinator(); > m_scrollingTrees.set(webPage->pageID(), downcast<ThreadedScrollingTree>(scrollingCoordinator.scrollingTree())); > } > >Index: Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.h >=================================================================== >--- Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.h (revision 240892) >+++ Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.h (working copy) >@@ -28,9 +28,9 @@ > #if ENABLE(ASYNC_SCROLLING) > > #include "MessageReceiver.h" >-#include <WebCore/AsyncScrollingCoordinator.h> > #include <WebCore/ScrollTypes.h> > #include <WebCore/ScrollingConstraints.h> >+#include <WebCore/ScrollingCoordinator.h> > #include <WebCore/Timer.h> > > namespace IPC { >@@ -43,7 +43,7 @@ namespace WebKit { > class WebPage; > class RemoteScrollingCoordinatorTransaction; > >-class RemoteScrollingCoordinator : public WebCore::AsyncScrollingCoordinator, public IPC::MessageReceiver { >+class RemoteScrollingCoordinator : public WebCore::ScrollingCoordinator, public IPC::MessageReceiver { > public: > static Ref<RemoteScrollingCoordinator> create(WebPage* page) > { >Index: Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.mm >=================================================================== >--- Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.mm (revision 240892) >+++ Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.mm (working copy) >@@ -48,7 +48,7 @@ namespace WebKit { > using namespace WebCore; > > RemoteScrollingCoordinator::RemoteScrollingCoordinator(WebPage* page) >- : AsyncScrollingCoordinator(page->corePage()) >+ : ScrollingCoordinator(page->corePage()) > , m_webPage(page) > { > WebProcess::singleton().addMessageReceiver(Messages::RemoteScrollingCoordinator::messageReceiverName(), m_webPage->pageID(), *this); >Index: Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm >=================================================================== >--- Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm (revision 240892) >+++ Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm (working copy) >@@ -61,7 +61,7 @@ > #import <wtf/MainThread.h> > > #if ENABLE(ASYNC_SCROLLING) >-#import <WebCore/AsyncScrollingCoordinator.h> >+#import <WebCore/ScrollingCoordinator.h> > #import <WebCore/ScrollingThread.h> > #import <WebCore/ScrollingTree.h> > #endif >@@ -234,7 +234,7 @@ void TiledCoreAnimationDrawingArea::upda > Settings& settings = m_webPage.corePage()->settings(); > > #if ENABLE(ASYNC_SCROLLING) >- if (AsyncScrollingCoordinator* scrollingCoordinator = downcast<AsyncScrollingCoordinator>(m_webPage.corePage()->scrollingCoordinator())) { >+ if (ScrollingCoordinator* scrollingCoordinator = m_webPage.corePage()->scrollingCoordinator()) { > bool scrollingPerformanceLoggingEnabled = m_webPage.scrollingPerformanceLoggingEnabled(); > > RefPtr<ScrollingTree> scrollingTree = scrollingCoordinator->scrollingTree();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194193
: 360979