WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-202100-20190923122328.patch (text/plain), 24.85 KB, created by
Zan Dobersek
on 2019-09-23 03:23:29 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Zan Dobersek
Created:
2019-09-23 03:23:29 PDT
Size:
24.85 KB
patch
obsolete
>Subversion Revision: 250201 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 678e4dffd433c0548b91f5ce009bc1cf68f79009..fbc67f5e6494ccc2f47fbc8653e3a6989a3a7289 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,41 @@ >+2019-09-23 Zan Dobersek <zdobersek@igalia.com> >+ >+ [Nicosia] Add implementations for fixed, positioned, sticky ScrollingTreeNodes >+ https://bugs.webkit.org/show_bug.cgi?id=202100 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Fill in the Nicosia implementations for the ScrollingTreeFixedNode, >+ ScrollingTreePositionedNode and ScrollingTreeStickyNode classes. >+ >+ The implementations in majority repeat what the Cocoa implementations >+ do, with the main difference being the Nicosia-specific layer state >+ application. Sharing more of this logic should be investigated in the >+ future. >+ >+ * PlatformPlayStation.cmake: Add ScrollingTreePositionedNode to build. >+ * SourcesGTK.txt: Ditto. >+ * SourcesWPE.txt: Ditto. >+ * page/scrolling/nicosia/ScrollingTreeFixedNode.cpp: >+ (WebCore::ScrollingTreeFixedNode::commitStateBeforeChildren): >+ (WebCore::ScrollingTreeFixedNode::applyLayerPositions): >+ (WebCore::ScrollingTreeFixedNode::dumpProperties const): >+ * page/scrolling/nicosia/ScrollingTreeFixedNode.h: >+ * page/scrolling/nicosia/ScrollingTreePositionedNode.cpp: Added. >+ (WebCore::ScrollingTreePositionedNode::create): >+ (WebCore::ScrollingTreePositionedNode::ScrollingTreePositionedNode): >+ (WebCore::ScrollingTreePositionedNode::commitStateBeforeChildren): >+ (WebCore::ScrollingTreePositionedNode::applyLayerPositions): >+ (WebCore::ScrollingTreePositionedNode::dumpProperties const): >+ * page/scrolling/nicosia/ScrollingTreePositionedNode.h: Added. >+ (WebCore::ScrollingTreePositionedNode::relatedOverflowScrollingNodes const): >+ * page/scrolling/nicosia/ScrollingTreeStickyNode.cpp: >+ (WebCore::ScrollingTreeStickyNode::commitStateBeforeChildren): >+ (WebCore::ScrollingTreeStickyNode::applyLayerPositions): >+ (WebCore::ScrollingTreeStickyNode::dumpProperties const): >+ (WebCore::ScrollingTreeStickyNode::computeLayerPosition const): >+ * page/scrolling/nicosia/ScrollingTreeStickyNode.h: >+ > 2019-09-22 David Kilzer <ddkilzer@apple.com> > > clang-tidy: Fix unnecessary copy/ref churn of for loop variables in WebCore >diff --git a/Source/WebCore/PlatformPlayStation.cmake b/Source/WebCore/PlatformPlayStation.cmake >index 7193bc5ae10b24726ef89ef97e039d6e40f8c65d..d968e6c64e2bf921c0ee3f10912b06df35fbe759 100644 >--- a/Source/WebCore/PlatformPlayStation.cmake >+++ b/Source/WebCore/PlatformPlayStation.cmake >@@ -21,6 +21,7 @@ list(APPEND WebCore_SOURCES > page/scrolling/nicosia/ScrollingTreeFixedNode.cpp > page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.cpp > page/scrolling/nicosia/ScrollingTreeNicosia.cpp >+ page/scrolling/nicosia/ScrollingTreePositionedNode.cpp > page/scrolling/nicosia/ScrollingTreeStickyNode.cpp > > page/scrolling/generic/ScrollingThreadGeneric.cpp >diff --git a/Source/WebCore/SourcesGTK.txt b/Source/WebCore/SourcesGTK.txt >index 04ebbfc02b2f9509b057858617dc8416338d0d0c..d44da171bfaa2c2b583007a8b1298aef0e3bc345 100644 >--- a/Source/WebCore/SourcesGTK.txt >+++ b/Source/WebCore/SourcesGTK.txt >@@ -55,6 +55,7 @@ page/scrolling/nicosia/ScrollingStateNodeNicosia.cpp > page/scrolling/nicosia/ScrollingTreeFixedNode.cpp > page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.cpp > page/scrolling/nicosia/ScrollingTreeNicosia.cpp >+page/scrolling/nicosia/ScrollingTreePositionedNode.cpp > page/scrolling/nicosia/ScrollingTreeStickyNode.cpp > > page/scrolling/generic/ScrollingThreadGeneric.cpp >diff --git a/Source/WebCore/SourcesWPE.txt b/Source/WebCore/SourcesWPE.txt >index 2f98ffebf023f8dce7e6611ab8e2ae4761f4f4e6..9998b76ae8b66358ae79d9beb7663a42d4381127 100644 >--- a/Source/WebCore/SourcesWPE.txt >+++ b/Source/WebCore/SourcesWPE.txt >@@ -52,6 +52,7 @@ page/scrolling/nicosia/ScrollingStateNodeNicosia.cpp > page/scrolling/nicosia/ScrollingTreeFixedNode.cpp > page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.cpp > page/scrolling/nicosia/ScrollingTreeNicosia.cpp >+page/scrolling/nicosia/ScrollingTreePositionedNode.cpp > page/scrolling/nicosia/ScrollingTreeStickyNode.cpp > > page/scrolling/generic/ScrollingThreadGeneric.cpp >diff --git a/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.cpp b/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.cpp >index c90dbf81e28ad4b7764a498bd57bb9cb82074099..672d9c2c5add14b5ada0427031309db7faeeec3b 100644 >--- a/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.cpp >+++ b/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.cpp >@@ -1,5 +1,6 @@ > /* >- * Copyright (C) 2018 Igalia S.L. >+ * Copyright (C) 2012 Apple Inc. All rights reserved. >+ * Copyright (C) 2019 Igalia S.L. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -30,7 +31,12 @@ > > #if ENABLE(ASYNC_SCROLLING) && USE(NICOSIA) > >+#include "Logging.h" >+#include "NicosiaPlatformLayer.h" >+#include "ScrollingStateFixedNode.h" > #include "ScrollingTree.h" >+#include "ScrollingTreeOverflowScrollingNode.h" >+#include <wtf/text/TextStream.h> > > namespace WebCore { > >@@ -50,12 +56,74 @@ ScrollingTreeFixedNode::~ScrollingTreeFixedNode() > scrollingTree().fixedOrStickyNodeRemoved(); > } > >-void ScrollingTreeFixedNode::commitStateBeforeChildren(const ScrollingStateNode&) >+void ScrollingTreeFixedNode::commitStateBeforeChildren(const ScrollingStateNode& stateNode) > { >+ auto& fixedStateNode = downcast<ScrollingStateFixedNode>(stateNode); >+ >+ if (fixedStateNode.hasChangedProperty(ScrollingStateNode::Layer)) { >+ Nicosia::PlatformLayer* layer = fixedStateNode.layer(); >+ m_layer = downcast<Nicosia::CompositionLayer>(layer); >+ } >+ >+ if (fixedStateNode.hasChangedProperty(ScrollingStateFixedNode::ViewportConstraints)) >+ m_constraints = fixedStateNode.viewportConstraints(); > } > > void ScrollingTreeFixedNode::applyLayerPositions() > { >+ auto computeLayerPosition = [&] { >+ FloatSize overflowScrollDelta; >+ // FIXME: This code is wrong in complex cases where the fixed element is inside a positioned node as >+ // the scroll container order does not match the scrolling tree ancestor order. >+ for (auto* node = parent(); node; node = node->parent()) { >+ if (is<ScrollingTreeFrameScrollingNode>(*node)) { >+ // Fixed nodes are positioned relative to the containing frame scrolling node. >+ // We bail out after finding one. >+ auto layoutViewport = downcast<ScrollingTreeFrameScrollingNode>(*node).layoutViewport(); >+ return m_constraints.layerPositionForViewportRect(layoutViewport) - overflowScrollDelta; >+ } >+ >+ if (is<ScrollingTreeOverflowScrollingNode>(*node)) { >+ // To keep the layer still during async scrolling we adjust by how much the position has changed since layout. >+ auto& overflowNode = downcast<ScrollingTreeOverflowScrollingNode>(*node); >+ auto localDelta = overflowNode.lastCommittedScrollPosition() - overflowNode.currentScrollPosition(); >+ overflowScrollDelta += localDelta; >+ } >+ } >+ ASSERT_NOT_REACHED(); >+ return FloatPoint(); >+ }; >+ >+ auto layerPosition = computeLayerPosition(); >+ >+ LOG_WITH_STREAM(Scrolling, stream << "ScrollingTreeFixedNode " << scrollingNodeID() << " relatedNodeScrollPositionDidChange: viewportRectAtLastLayout " << m_constraints.viewportRectAtLastLayout() << " last layer pos " << m_constraints.layerPositionAtLastLayout() << " layerPosition " << layerPosition); >+ >+ ASSERT(m_layer); >+ m_layer->accessStaging( >+ [&layerPosition](Nicosia::CompositionLayer::LayerState& state) >+ { >+ state.position = layerPosition; >+ state.delta.positionChanged = true; >+ }); >+} >+ >+void ScrollingTreeFixedNode::dumpProperties(TextStream& ts, ScrollingStateTreeAsTextBehavior behavior) const >+{ >+ ts << "fixed node"; >+ ScrollingTreeNode::dumpProperties(ts, behavior); >+ ts.dumpProperty("fixed constraints", m_constraints); >+ >+ if (behavior & ScrollingStateTreeAsTextBehaviorIncludeLayerPositions) { >+ FloatPoint layerTopLeft; >+ ASSERT(m_layer); >+ m_layer->accessCommitted( >+ [this, &layerTopLeft](Nicosia::CompositionLayer::LayerState& state) >+ { >+ layerTopLeft = state.position - toFloatSize(state.anchorPoint.xy()) * state.size + m_constraints.alignmentOffset(); >+ }); >+ >+ ts.dumpProperty("layer top left", layerTopLeft); >+ } > } > > } // namespace WebCore >diff --git a/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.h b/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.h >index 9f8e1e251be22bed3b5b8ec0b2f9ff68621449d1..1b69714ef4faa6c7194d8e46ec491c7fd485a34e 100644 >--- a/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.h >+++ b/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.h >@@ -1,5 +1,6 @@ > /* >- * Copyright (C) 2018 Igalia S.L. >+ * Copyright (C) 2012 Apple Inc. All rights reserved. >+ * Copyright (C) 2019 Igalia S.L. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -29,7 +30,13 @@ > > #if ENABLE(ASYNC_SCROLLING) && USE(NICOSIA) > >+#include "ScrollingConstraints.h" > #include "ScrollingTreeNode.h" >+#include <wtf/RefPtr.h> >+ >+namespace Nicosia { >+class CompositionLayer; >+} > > namespace WebCore { > >@@ -43,8 +50,15 @@ private: > > void commitStateBeforeChildren(const ScrollingStateNode&) override; > void applyLayerPositions() override; >+ >+ void dumpProperties(WTF::TextStream&, ScrollingStateTreeAsTextBehavior) const override; >+ >+ FixedPositionViewportConstraints m_constraints; >+ RefPtr<Nicosia::CompositionLayer> m_layer; > }; > > } // namespace WebCore > >+SPECIALIZE_TYPE_TRAITS_SCROLLING_NODE(ScrollingTreeFixedNode, isFixedNode()) >+ > #endif // ENABLE(ASYNC_SCROLLING) && USE(NICOSIA) >diff --git a/Source/WebCore/page/scrolling/nicosia/ScrollingTreePositionedNode.cpp b/Source/WebCore/page/scrolling/nicosia/ScrollingTreePositionedNode.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..bd7ba1197ad1ac60aa09e4885a7a4e2508fcd7ca >--- /dev/null >+++ b/Source/WebCore/page/scrolling/nicosia/ScrollingTreePositionedNode.cpp >@@ -0,0 +1,124 @@ >+/* >+ * Copyright (C) 2012 Apple Inc. All rights reserved. >+ * Copyright (C) 2019 Igalia S.L. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above >+ * copyright notice, this list of conditions and the following >+ * disclaimer in the documentation and/or other materials provided >+ * with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT >+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "ScrollingTreePositionedNode.h" >+ >+#if ENABLE(ASYNC_SCROLLING) && USE(NICOSIA) >+ >+#include "Logging.h" >+#include "NicosiaPlatformLayer.h" >+#include "ScrollingStatePositionedNode.h" >+#include "ScrollingTree.h" >+#include "ScrollingTreeOverflowScrollingNode.h" >+#include <wtf/text/TextStream.h> >+ >+namespace WebCore { >+ >+Ref<ScrollingTreePositionedNode> ScrollingTreePositionedNode::create(ScrollingTree& scrollingTree, ScrollingNodeID nodeID) >+{ >+ return adoptRef(*new ScrollingTreePositionedNode(scrollingTree, nodeID)); >+} >+ >+ScrollingTreePositionedNode::ScrollingTreePositionedNode(ScrollingTree& scrollingTree, ScrollingNodeID nodeID) >+ : ScrollingTreeNode(scrollingTree, ScrollingNodeType::Positioned, nodeID) >+{ >+} >+ >+ScrollingTreePositionedNode::~ScrollingTreePositionedNode() = default; >+ >+void ScrollingTreePositionedNode::commitStateBeforeChildren(const ScrollingStateNode& stateNode) >+{ >+ const ScrollingStatePositionedNode& positionedStateNode = downcast<ScrollingStatePositionedNode>(stateNode); >+ >+ if (positionedStateNode.hasChangedProperty(ScrollingStateNode::Layer)) { >+ Nicosia::PlatformLayer* layer = positionedStateNode.layer(); >+ m_layer = downcast<Nicosia::CompositionLayer>(layer); >+ } >+ >+ if (positionedStateNode.hasChangedProperty(ScrollingStatePositionedNode::RelatedOverflowScrollingNodes)) >+ m_relatedOverflowScrollingNodes = positionedStateNode.relatedOverflowScrollingNodes(); >+ >+ if (positionedStateNode.hasChangedProperty(ScrollingStatePositionedNode::LayoutConstraintData)) >+ m_constraints = positionedStateNode.layoutConstraints(); >+ >+ if (!m_relatedOverflowScrollingNodes.isEmpty()) >+ scrollingTree().activePositionedNodes().add(*this); >+} >+ >+void ScrollingTreePositionedNode::applyLayerPositions() >+{ >+ auto delta = >+ [this] { >+ FloatSize delta; >+ for (auto nodeID : m_relatedOverflowScrollingNodes) { >+ if (auto* node = scrollingTree().nodeForID(nodeID)) { >+ if (is<ScrollingTreeOverflowScrollingNode>(node)) { >+ auto& overflowNode = downcast<ScrollingTreeOverflowScrollingNode>(*node); >+ delta += overflowNode.scrollDeltaSinceLastCommit(); >+ } >+ } >+ } >+ return -delta; >+ }(); >+ FloatPoint layerPosition = m_constraints.layerPositionAtLastLayout() - delta; >+ >+ LOG_WITH_STREAM(Scrolling, stream << "ScrollingTreePositionedNode " << scrollingNodeID() << " applyLayerPositions: overflow delta " << scrollOffsetSinceLastCommit << " moving layer to " << layerPosition); >+ >+ layerPosition -= m_constraints.alignmentOffset(); >+ >+ ASSERT(m_layer); >+ m_layer->accessStaging( >+ [&layerPosition](Nicosia::CompositionLayer::LayerState& state) >+ { >+ state.position = layerPosition; >+ state.delta.positionChanged = true; >+ }); >+} >+ >+void ScrollingTreePositionedNode::dumpProperties(TextStream& ts, ScrollingStateTreeAsTextBehavior behavior) const >+{ >+ ts << "positioned node"; >+ ScrollingTreeNode::dumpProperties(ts, behavior); >+ >+ ts.dumpProperty("layout constraints", m_constraints); >+ ts.dumpProperty("related overflow nodes", m_relatedOverflowScrollingNodes.size()); >+ >+ if (behavior & ScrollingStateTreeAsTextBehaviorIncludeNodeIDs) { >+ if (!m_relatedOverflowScrollingNodes.isEmpty()) { >+ TextStream::GroupScope scope(ts); >+ ts << "overflow nodes"; >+ for (auto nodeID : m_relatedOverflowScrollingNodes) >+ ts << "\n" << indent << "nodeID " << nodeID; >+ } >+ } >+} >+ >+} // namespace WebCore >+ >+#endif // ENABLE(ASYNC_SCROLLING) && USE(NICOSIA) >diff --git a/Source/WebCore/page/scrolling/nicosia/ScrollingTreePositionedNode.h b/Source/WebCore/page/scrolling/nicosia/ScrollingTreePositionedNode.h >new file mode 100644 >index 0000000000000000000000000000000000000000..a86000e12c40f3d4b103e0835461f4fe886cb22c >--- /dev/null >+++ b/Source/WebCore/page/scrolling/nicosia/ScrollingTreePositionedNode.h >@@ -0,0 +1,67 @@ >+/* >+ * Copyright (C) 2012 Apple Inc. All rights reserved. >+ * Copyright (C) 2019 Igalia S.L. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above >+ * copyright notice, this list of conditions and the following >+ * disclaimer in the documentation and/or other materials provided >+ * with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT >+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(ASYNC_SCROLLING) && USE(NICOSIA) >+ >+#include "ScrollingConstraints.h" >+#include "ScrollingTreeNode.h" >+#include <wtf/RefPtr.h> >+ >+namespace Nicosia { >+class CompositionLayer; >+} >+ >+namespace WebCore { >+ >+class ScrollingTreePositionedNode : public ScrollingTreeNode { >+public: >+ static Ref<ScrollingTreePositionedNode> create(ScrollingTree&, ScrollingNodeID); >+ virtual ~ScrollingTreePositionedNode(); >+ >+ const Vector<ScrollingNodeID>& relatedOverflowScrollingNodes() const { return m_relatedOverflowScrollingNodes; } >+ >+private: >+ ScrollingTreePositionedNode(ScrollingTree&, ScrollingNodeID); >+ >+ void commitStateBeforeChildren(const ScrollingStateNode&) override; >+ void applyLayerPositions() override; >+ >+ void dumpProperties(WTF::TextStream&, ScrollingStateTreeAsTextBehavior) const override; >+ >+ Vector<ScrollingNodeID> m_relatedOverflowScrollingNodes; >+ AbsolutePositionConstraints m_constraints; >+ RefPtr<Nicosia::CompositionLayer> m_layer; >+}; >+ >+} // namespace WebCore >+ >+SPECIALIZE_TYPE_TRAITS_SCROLLING_NODE(ScrollingTreePositionedNode, isPositionedNode()) >+ >+#endif // ENABLE(ASYNC_SCROLLING) && USE(NICOSIA) >diff --git a/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.cpp b/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.cpp >index d63eaaecf2c0f35158491544bf6decaeb5a31eb3..6b3d7d9174a3bc8c85f0bc73f70cda6eb94d760c 100644 >--- a/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.cpp >+++ b/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.cpp >@@ -1,5 +1,6 @@ > /* >- * Copyright (C) 2018 Igalia S.L. >+ * Copyright (C) 2012 Apple Inc. All rights reserved. >+ * Copyright (C) 2019 Igalia S.L. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -30,7 +31,14 @@ > > #if ENABLE(ASYNC_SCROLLING) && USE(NICOSIA) > >+#include "Logging.h" >+#include "NicosiaPlatformLayer.h" >+#include "ScrollingStateStickyNode.h" > #include "ScrollingTree.h" >+#include "ScrollingTreeFixedNode.h" >+#include "ScrollingTreeFrameScrollingNode.h" >+#include "ScrollingTreeOverflowScrollingNode.h" >+#include <wtf/text/TextStream.h> > > namespace WebCore { > >@@ -50,12 +58,90 @@ ScrollingTreeStickyNode::~ScrollingTreeStickyNode() > scrollingTree().fixedOrStickyNodeRemoved(); > } > >-void ScrollingTreeStickyNode::commitStateBeforeChildren(const ScrollingStateNode&) >+void ScrollingTreeStickyNode::commitStateBeforeChildren(const ScrollingStateNode& stateNode) > { >+ auto& stickyStateNode = downcast<ScrollingStateStickyNode>(stateNode); >+ >+ if (stickyStateNode.hasChangedProperty(ScrollingStateNode::Layer)) { >+ Nicosia::PlatformLayer* layer = stickyStateNode.layer(); >+ m_layer = downcast<Nicosia::CompositionLayer>(layer); >+ } >+ >+ if (stickyStateNode.hasChangedProperty(ScrollingStateStickyNode::ViewportConstraints)) >+ m_constraints = stickyStateNode.viewportConstraints(); > } > > void ScrollingTreeStickyNode::applyLayerPositions() > { >+ auto layerPosition = computeLayerPosition(); >+ >+ LOG_WITH_STREAM(Scrolling, stream << "ScrollingTreeStickyNode " << scrollingNodeID() << " constrainingRectAtLastLayout " << m_constraints.constrainingRectAtLastLayout() << " last layer pos " << m_constraints.layerPositionAtLastLayout() << " layerPosition " << layerPosition); >+ >+ layerPosition -= m_constraints.alignmentOffset(); >+ >+ ASSERT(m_layer); >+ m_layer->accessStaging( >+ [&layerPosition](Nicosia::CompositionLayer::LayerState& state) >+ { >+ state.position = layerPosition; >+ state.delta.positionChanged = true; >+ }); >+} >+ >+void ScrollingTreeStickyNode::dumpProperties(TextStream& ts, ScrollingStateTreeAsTextBehavior behavior) const >+{ >+ ts << "sticky node"; >+ >+ ScrollingTreeNode::dumpProperties(ts, behavior); >+ ts.dumpProperty("sticky constraints", m_constraints); >+ >+ if (behavior & ScrollingStateTreeAsTextBehaviorIncludeLayerPositions) { >+ FloatPoint layerTopLeft; >+ ASSERT(m_layer); >+ m_layer->accessCommitted( >+ [this, &layerTopLeft](Nicosia::CompositionLayer::LayerState& state) >+ { >+ layerTopLeft = state.position - toFloatSize(state.anchorPoint.xy()) * state.size + m_constraints.alignmentOffset(); >+ }); >+ >+ ts.dumpProperty("layer top left", layerTopLeft); >+ } >+} >+ >+FloatPoint ScrollingTreeStickyNode::computeLayerPosition() const >+{ >+ auto computeLayerPositionForScrollingNode = [&](ScrollingTreeNode& scrollingNode) { >+ FloatRect constrainingRect; >+ if (is<ScrollingTreeFrameScrollingNode>(scrollingNode)) { >+ auto& frameScrollingNode = downcast<ScrollingTreeFrameScrollingNode>(scrollingNode); >+ constrainingRect = frameScrollingNode.layoutViewport(); >+ } else { >+ auto& overflowScrollingNode = downcast<ScrollingTreeOverflowScrollingNode>(scrollingNode); >+ constrainingRect = FloatRect(overflowScrollingNode.currentScrollPosition(), m_constraints.constrainingRectAtLastLayout().size()); >+ } >+ return m_constraints.layerPositionForConstrainingRect(constrainingRect); >+ }; >+ >+ for (auto* ancestor = parent(); ancestor; ancestor = ancestor->parent()) { >+ if (is<ScrollingTreeOverflowScrollProxyNode>(*ancestor)) { >+ auto& overflowProxyNode = downcast<ScrollingTreeOverflowScrollProxyNode>(*ancestor); >+ auto overflowNode = scrollingTree().nodeForID(overflowProxyNode.overflowScrollingNodeID()); >+ if (!overflowNode) >+ break; >+ >+ return computeLayerPositionForScrollingNode(*overflowNode); >+ } >+ >+ if (is<ScrollingTreeScrollingNode>(*ancestor)) >+ return computeLayerPositionForScrollingNode(*ancestor); >+ >+ if (is<ScrollingTreeFixedNode>(*ancestor) || is<ScrollingTreeStickyNode>(*ancestor)) { >+ // FIXME: Do we need scrolling tree nodes at all for nested cases? >+ return m_constraints.layerPositionAtLastLayout(); >+ } >+ } >+ ASSERT_NOT_REACHED(); >+ return m_constraints.layerPositionAtLastLayout(); > } > > } // namespace WebCore >diff --git a/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.h b/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.h >index a3d191ea9b9f7581c848e1d9a9bfc5ee53b593fa..0a422a014e791616e8e8635b7bf51a7f2a074820 100644 >--- a/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.h >+++ b/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.h >@@ -1,5 +1,6 @@ > /* >- * Copyright (C) 2018 Igalia S.L. >+ * Copyright (C) 2012 Apple Inc. All rights reserved. >+ * Copyright (C) 2019 Igalia S.L. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -29,7 +30,13 @@ > > #if ENABLE(ASYNC_SCROLLING) && USE(NICOSIA) > >+#include "ScrollingConstraints.h" > #include "ScrollingTreeNode.h" >+#include <wtf/RefPtr.h> >+ >+namespace Nicosia { >+class CompositionLayer; >+} > > namespace WebCore { > >@@ -44,8 +51,16 @@ private: > void commitStateBeforeChildren(const ScrollingStateNode&) override; > void applyLayerPositions() override; > >+ void dumpProperties(WTF::TextStream&, ScrollingStateTreeAsTextBehavior) const override; >+ >+ FloatPoint computeLayerPosition() const; >+ >+ StickyPositionViewportConstraints m_constraints; >+ RefPtr<Nicosia::CompositionLayer> m_layer; > }; > > } // namespace WebCore > >+SPECIALIZE_TYPE_TRAITS_SCROLLING_NODE(ScrollingTreeStickyNode, isStickyNode()) >+ > #endif // ENABLE(ASYNC_SCROLLING) && USE(NICOSIA)
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 202100
:
379363
|
379533