Diff
Modified: trunk/Source/WebCore/ChangeLog (284919 => 284920)
--- trunk/Source/WebCore/ChangeLog 2021-10-27 11:32:38 UTC (rev 284919)
+++ trunk/Source/WebCore/ChangeLog 2021-10-27 11:47:29 UTC (rev 284920)
@@ -1,3 +1,58 @@
+2021-10-27 Martin Robinson <[email protected]>
+
+ Eliminate duplicated platform-specific code in ScrollingTreeStickyNode
+ https://bugs.webkit.org/show_bug.cgi?id=231571
+
+ Reviewed by Simon Fraser.
+
+ Abstract code from the Nicosia and Cooca version of ScrollingTreeStickyNode,
+ so that it can be shared by both ports.
+
+ No new tests. This should not change any behavior.
+
+ * Headers.cmake:
+ * PlatformMac.cmake:
+ * PlatformPlayStation.cmake:
+ * Sources.txt:
+ * SourcesCocoa.txt:
+ * SourcesGTK.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * page/scrolling/ScrollingTreeStickyNode.cpp: Renamed from Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.cpp.
+ (WebCore::ScrollingTreeStickyNode::commitStateBeforeChildren):
+ (WebCore::ScrollingTreeStickyNode::dumpProperties const):
+ * page/scrolling/ScrollingTreeStickyNode.h: Copied from Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.h.
+ * page/scrolling/cocoa/ScrollingTreeFixedNode.mm:
+ (WebCore::ScrollingTreeFixedNode::applyLayerPositions):
+ * page/scrolling/cocoa/ScrollingTreeStickyNode.mm: Removed.
+ (WebCore::ScrollingTreeStickyNode::create): Deleted.
+ (WebCore::ScrollingTreeStickyNode::ScrollingTreeStickyNode): Deleted.
+ (WebCore::ScrollingTreeStickyNode::~ScrollingTreeStickyNode): Deleted.
+ (WebCore::ScrollingTreeStickyNode::commitStateBeforeChildren): Deleted.
+ (WebCore::ScrollingTreeStickyNode::computeLayerPosition const): Deleted.
+ (WebCore::ScrollingTreeStickyNode::applyLayerPositions): Deleted.
+ (WebCore::ScrollingTreeStickyNode::scrollDeltaSinceLastCommit const): Deleted.
+ (WebCore::ScrollingTreeStickyNode::dumpProperties const): Deleted.
+ * page/scrolling/cocoa/ScrollingTreeStickyNodeCocoa.h: Renamed from Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNode.h.
+ * page/scrolling/cocoa/ScrollingTreeStickyNodeCocoa.mm: Added.
+ (WebCore::ScrollingTreeStickyNodeCocoa::create):
+ (WebCore::ScrollingTreeStickyNodeCocoa::ScrollingTreeStickyNodeCocoa):
+ (WebCore::ScrollingTreeStickyNodeCocoa::commitStateBeforeChildren):
+ (WebCore::ScrollingTreeStickyNodeCocoa::applyLayerPositions):
+ (WebCore::ScrollingTreeStickyNodeCocoa::layerTopLeft const):
+ * page/scrolling/mac/ScrollingCoordinatorMac.mm:
+ * page/scrolling/mac/ScrollingTreeMac.mm:
+ (ScrollingTreeMac::createScrollingTreeNode):
+ * page/scrolling/nicosia/ScrollingTreeNicosia.cpp:
+ (WebCore::ScrollingTreeNicosia::createScrollingTreeNode):
+ * page/scrolling/nicosia/ScrollingTreeStickyNodeNicosia.cpp: Added.
+ (WebCore::ScrollingTreeStickyNodeNicosia::create):
+ (WebCore::ScrollingTreeStickyNodeNicosia::ScrollingTreeStickyNodeNicosia):
+ (WebCore::ScrollingTreeStickyNodeNicosia::commitStateBeforeChildren):
+ (WebCore::ScrollingTreeStickyNodeNicosia::applyLayerPositions):
+ (WebCore::ScrollingTreeStickyNodeNicosia::layerTopLeft const):
+ * page/scrolling/nicosia/ScrollingTreeStickyNodeNicosia.h: Renamed from Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.h.
+ * platform/TextureMapper.cmake:
+
2021-10-26 Tim Horton <[email protected]>
[GPU Process] `DisplayList::Recorder::getCTM` should include the device scale factor
Modified: trunk/Source/WebCore/Headers.cmake (284919 => 284920)
--- trunk/Source/WebCore/Headers.cmake 2021-10-27 11:32:38 UTC (rev 284919)
+++ trunk/Source/WebCore/Headers.cmake 2021-10-27 11:47:29 UTC (rev 284920)
@@ -1058,6 +1058,7 @@
page/scrolling/ScrollingTreeOverflowScrollingNode.h
page/scrolling/ScrollingTreeScrollingNode.h
page/scrolling/ScrollingTreeScrollingNodeDelegate.h
+ page/scrolling/ScrollingTreeStickyNode.h
page/scrolling/ThreadedScrollingTree.h
platform/AbortableTaskQueue.h
Modified: trunk/Source/WebCore/PlatformMac.cmake (284919 => 284920)
--- trunk/Source/WebCore/PlatformMac.cmake 2021-10-27 11:32:38 UTC (rev 284919)
+++ trunk/Source/WebCore/PlatformMac.cmake 2021-10-27 11:47:29 UTC (rev 284920)
@@ -552,7 +552,7 @@
page/scrolling/cocoa/ScrollingTreeFixedNode.h
page/scrolling/cocoa/ScrollingTreeOverflowScrollProxyNode.h
page/scrolling/cocoa/ScrollingTreePositionedNode.h
- page/scrolling/cocoa/ScrollingTreeStickyNode.h
+ page/scrolling/cocoa/ScrollingTreeStickyNodeCocoa.h
page/scrolling/mac/ScrollingCoordinatorMac.h
page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.h
Modified: trunk/Source/WebCore/PlatformPlayStation.cmake (284919 => 284920)
--- trunk/Source/WebCore/PlatformPlayStation.cmake 2021-10-27 11:32:38 UTC (rev 284919)
+++ trunk/Source/WebCore/PlatformPlayStation.cmake 2021-10-27 11:47:29 UTC (rev 284920)
@@ -29,7 +29,7 @@
page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.cpp
page/scrolling/nicosia/ScrollingTreePositionedNode.cpp
page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.cpp
- page/scrolling/nicosia/ScrollingTreeStickyNode.cpp
+ page/scrolling/nicosia/ScrollingTreeStickyNodeNicosia.cpp
platform/ScrollAnimationKinetic.cpp
platform/ScrollAnimationSmooth.cpp
Modified: trunk/Source/WebCore/Sources.txt (284919 => 284920)
--- trunk/Source/WebCore/Sources.txt 2021-10-27 11:32:38 UTC (rev 284919)
+++ trunk/Source/WebCore/Sources.txt 2021-10-27 11:47:29 UTC (rev 284920)
@@ -1799,6 +1799,7 @@
page/scrolling/ScrollingTreeOverflowScrollingNode.cpp
page/scrolling/ScrollingTreeScrollingNode.cpp
page/scrolling/ScrollingTreeScrollingNodeDelegate.cpp
+page/scrolling/ScrollingTreeStickyNode.cpp
page/scrolling/ThreadedScrollingTree.cpp
platform/ContentType.cpp
platform/ContextMenu.cpp
Modified: trunk/Source/WebCore/SourcesCocoa.txt (284919 => 284920)
--- trunk/Source/WebCore/SourcesCocoa.txt 2021-10-27 11:32:38 UTC (rev 284919)
+++ trunk/Source/WebCore/SourcesCocoa.txt 2021-10-27 11:47:29 UTC (rev 284920)
@@ -208,7 +208,7 @@
page/scrolling/cocoa/ScrollingTreeFixedNode.mm
page/scrolling/cocoa/ScrollingTreeOverflowScrollProxyNode.mm
page/scrolling/cocoa/ScrollingTreePositionedNode.mm
-page/scrolling/cocoa/ScrollingTreeStickyNode.mm
+page/scrolling/cocoa/ScrollingTreeStickyNodeCocoa.mm
page/scrolling/mac/ScrollingCoordinatorMac.mm
page/scrolling/mac/ScrollingStateScrollingNodeMac.mm
page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm
Modified: trunk/Source/WebCore/SourcesGTK.txt (284919 => 284920)
--- trunk/Source/WebCore/SourcesGTK.txt 2021-10-27 11:32:38 UTC (rev 284919)
+++ trunk/Source/WebCore/SourcesGTK.txt 2021-10-27 11:47:29 UTC (rev 284920)
@@ -71,7 +71,7 @@
page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.cpp
page/scrolling/nicosia/ScrollingTreePositionedNode.cpp
page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.cpp
-page/scrolling/nicosia/ScrollingTreeStickyNode.cpp
+page/scrolling/nicosia/ScrollingTreeStickyNodeNicosia.cpp
platform/UserAgentQuirks.cpp
Modified: trunk/Source/WebCore/SourcesWPE.txt (284919 => 284920)
--- trunk/Source/WebCore/SourcesWPE.txt 2021-10-27 11:32:38 UTC (rev 284919)
+++ trunk/Source/WebCore/SourcesWPE.txt 2021-10-27 11:47:29 UTC (rev 284920)
@@ -56,7 +56,7 @@
page/scrolling/nicosia/ScrollingTreeOverflowScrollingNodeNicosia.cpp
page/scrolling/nicosia/ScrollingTreePositionedNode.cpp
page/scrolling/nicosia/ScrollingTreeScrollingNodeDelegateNicosia.cpp
-page/scrolling/nicosia/ScrollingTreeStickyNode.cpp
+page/scrolling/nicosia/ScrollingTreeStickyNodeNicosia.cpp
platform/UserAgentQuirks.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (284919 => 284920)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-10-27 11:32:38 UTC (rev 284919)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-10-27 11:47:29 UTC (rev 284920)
@@ -340,7 +340,7 @@
0F8B45721DC3FBA300443C3F /* IntersectionObserverCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F8B45711DC3FBA300443C3F /* IntersectionObserverCallback.h */; };
0F8B45761DC41DBA00443C3F /* JSIntersectionObserverCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F8B45741DC41DBA00443C3F /* JSIntersectionObserverCallback.h */; };
0F94B6472208FE3600157014 /* ScrollingTreeFixedNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F94B6422208F70100157014 /* ScrollingTreeFixedNode.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 0F94B6492208FE3B00157014 /* ScrollingTreeStickyNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F94B6432208F70200157014 /* ScrollingTreeStickyNode.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 0F94B6492208FE3B00157014 /* ScrollingTreeStickyNodeCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F94B6432208F70200157014 /* ScrollingTreeStickyNodeCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F94B6522209150600157014 /* ScrollingStatePositionedNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F94B651220914FF00157014 /* ScrollingStatePositionedNode.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F94B655220931E400157014 /* ScrollingTreePositionedNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F94B6532209156C00157014 /* ScrollingTreePositionedNode.h */; settings = {ATTRIBUTES = (Private, ); }; };
0F94F37E23661626003AA5C7 /* StyleRuleType.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F94F37C23661131003AA5C7 /* StyleRuleType.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -2028,6 +2028,7 @@
5B30695E18B3D3450099D5E8 /* WebGLDrawBuffers.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B30695B18B3D3450099D5E8 /* WebGLDrawBuffers.h */; };
5B46656325D14C0A000CFE14 /* ScrollingEffectsController.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B46655F25D14C09000CFE14 /* ScrollingEffectsController.h */; settings = {ATTRIBUTES = (Private, ); }; };
5B46656425D14C0A000CFE14 /* ScrollSnapAnimatorState.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B46656025D14C0A000CFE14 /* ScrollSnapAnimatorState.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 5B92C42D2716E28A00A37CC0 /* ScrollingTreeStickyNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B92C42B2716E23300A37CC0 /* ScrollingTreeStickyNode.h */; settings = {ATTRIBUTES = (Private, ); }; };
5C1B1D3F26F3978000882DA2 /* ResourceLoaderIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C1B1D3D26F3977F00882DA2 /* ResourceLoaderIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
5C2B1AEC22397EBC00B91CF7 /* ResourceResponseCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = A1F78D0B1C25422C00245446 /* ResourceResponseCocoa.mm */; };
5C4304B1191AC908000E2BC0 /* EXTShaderTextureLOD.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C4304AE191AC908000E2BC0 /* EXTShaderTextureLOD.h */; };
@@ -6345,9 +6346,9 @@
0F94722D2534BA7300F153C8 /* DisplayFillLayerImageGeometry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayFillLayerImageGeometry.h; sourceTree = "<group>"; };
0F94A3951EF1B10500FBAFFB /* JSDOMQuadCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMQuadCustom.cpp; sourceTree = "<group>"; };
0F94B6422208F70100157014 /* ScrollingTreeFixedNode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ScrollingTreeFixedNode.h; path = page/scrolling/cocoa/ScrollingTreeFixedNode.h; sourceTree = SOURCE_ROOT; };
- 0F94B6432208F70200157014 /* ScrollingTreeStickyNode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ScrollingTreeStickyNode.h; path = page/scrolling/cocoa/ScrollingTreeStickyNode.h; sourceTree = SOURCE_ROOT; };
+ 0F94B6432208F70200157014 /* ScrollingTreeStickyNodeCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScrollingTreeStickyNodeCocoa.h; sourceTree = "<group>"; };
0F94B6442208F70200157014 /* ScrollingTreeFixedNode.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = ScrollingTreeFixedNode.mm; path = page/scrolling/cocoa/ScrollingTreeFixedNode.mm; sourceTree = SOURCE_ROOT; };
- 0F94B6452208F70300157014 /* ScrollingTreeStickyNode.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = ScrollingTreeStickyNode.mm; path = page/scrolling/cocoa/ScrollingTreeStickyNode.mm; sourceTree = SOURCE_ROOT; };
+ 0F94B6452208F70300157014 /* ScrollingTreeStickyNodeCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollingTreeStickyNodeCocoa.mm; sourceTree = "<group>"; };
0F94B64F220914FE00157014 /* ScrollingStatePositionedNode.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollingStatePositionedNode.cpp; sourceTree = "<group>"; };
0F94B651220914FF00157014 /* ScrollingStatePositionedNode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScrollingStatePositionedNode.h; sourceTree = "<group>"; };
0F94B6532209156C00157014 /* ScrollingTreePositionedNode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScrollingTreePositionedNode.h; sourceTree = "<group>"; };
@@ -9865,6 +9866,8 @@
5B46655F25D14C09000CFE14 /* ScrollingEffectsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollingEffectsController.h; sourceTree = "<group>"; };
5B46656025D14C0A000CFE14 /* ScrollSnapAnimatorState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollSnapAnimatorState.h; sourceTree = "<group>"; };
5B7AB9F62567DB7E006592D0 /* ScrollSnapOffsetsInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollSnapOffsetsInfo.cpp; sourceTree = "<group>"; };
+ 5B92C4292716E23300A37CC0 /* ScrollingTreeStickyNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollingTreeStickyNode.cpp; sourceTree = "<group>"; };
+ 5B92C42B2716E23300A37CC0 /* ScrollingTreeStickyNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollingTreeStickyNode.h; sourceTree = "<group>"; };
5C001521250011000094AA93 /* TextCodecSingleByte.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextCodecSingleByte.cpp; sourceTree = "<group>"; };
5C001523250011010094AA93 /* TextCodecSingleByte.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextCodecSingleByte.h; sourceTree = "<group>"; };
5C1B1D1E26F15B1900882DA2 /* SharedWorkerGlobalScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedWorkerGlobalScope.cpp; sourceTree = "<group>"; };
@@ -19088,6 +19091,8 @@
9391A99B1629D70000297330 /* ScrollingTreeScrollingNode.h */,
A6D5A99A1629D6FF00297330 /* ScrollingTreeScrollingNodeDelegate.cpp */,
A6D5A99B1629D70000297330 /* ScrollingTreeScrollingNodeDelegate.h */,
+ 5B92C4292716E23300A37CC0 /* ScrollingTreeStickyNode.cpp */,
+ 5B92C42B2716E23300A37CC0 /* ScrollingTreeStickyNode.h */,
0F9510F224F4769C001F52DC /* ScrollLatchingController.cpp */,
0F9510F024F4769C001F52DC /* ScrollLatchingController.h */,
5B7AB9F62567DB7E006592D0 /* ScrollSnapOffsetsInfo.cpp */,
@@ -24373,8 +24378,8 @@
0FC4B00522B9A02D00CF3B1E /* ScrollingTreeOverflowScrollProxyNode.mm */,
0F94B6532209156C00157014 /* ScrollingTreePositionedNode.h */,
0F94B6542209156C00157014 /* ScrollingTreePositionedNode.mm */,
- 0F94B6432208F70200157014 /* ScrollingTreeStickyNode.h */,
- 0F94B6452208F70300157014 /* ScrollingTreeStickyNode.mm */,
+ 0F94B6432208F70200157014 /* ScrollingTreeStickyNodeCocoa.h */,
+ 0F94B6452208F70300157014 /* ScrollingTreeStickyNodeCocoa.mm */,
);
path = cocoa;
sourceTree = "<group>";
@@ -35362,7 +35367,8 @@
9391A99D1629D70000297330 /* ScrollingTreeScrollingNode.h in Headers */,
A6D5A99D1629D70000297330 /* ScrollingTreeScrollingNodeDelegate.h in Headers */,
0F37F0852202BF9800A89C0B /* ScrollingTreeScrollingNodeDelegateMac.h in Headers */,
- 0F94B6492208FE3B00157014 /* ScrollingTreeStickyNode.h in Headers */,
+ 5B92C42D2716E28A00A37CC0 /* ScrollingTreeStickyNode.h in Headers */,
+ 0F94B6492208FE3B00157014 /* ScrollingTreeStickyNodeCocoa.h in Headers */,
83C5795D1DA5C301006F9C97 /* ScrollIntoViewOptions.h in Headers */,
83C5795D1DA5C301006F9C86 /* ScrollLogicalPosition.h in Headers */,
83C5795D1DA5C301006FAC97 /* ScrollOptions.h in Headers */,
Copied: trunk/Source/WebCore/page/scrolling/ScrollingTreeStickyNode.cpp (from rev 284919, trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.cpp) (0 => 284920)
--- trunk/Source/WebCore/page/scrolling/ScrollingTreeStickyNode.cpp (rev 0)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeStickyNode.cpp 2021-10-27 11:47:29 UTC (rev 284920)
@@ -0,0 +1,123 @@
+/*
+ * 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 "ScrollingTreeStickyNode.h"
+
+#if ENABLE(ASYNC_SCROLLING)
+
+#include "Logging.h"
+#include "ScrollingStateStickyNode.h"
+#include "ScrollingTree.h"
+#include "ScrollingTreeFixedNode.h"
+#include "ScrollingTreeFrameScrollingNode.h"
+#include "ScrollingTreeOverflowScrollProxyNode.h"
+#include "ScrollingTreeOverflowScrollingNode.h"
+#include <wtf/text/TextStream.h>
+
+namespace WebCore {
+
+ScrollingTreeStickyNode::ScrollingTreeStickyNode(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
+ : ScrollingTreeNode(scrollingTree, ScrollingNodeType::Sticky, nodeID)
+{
+ scrollingTree.fixedOrStickyNodeAdded();
+}
+
+ScrollingTreeStickyNode::~ScrollingTreeStickyNode()
+{
+ scrollingTree().fixedOrStickyNodeRemoved();
+}
+
+void ScrollingTreeStickyNode::commitStateBeforeChildren(const ScrollingStateNode& stateNode)
+{
+ auto& stickyStateNode = downcast<ScrollingStateStickyNode>(stateNode);
+
+ if (stickyStateNode.hasChangedProperty(ScrollingStateNode::Property::ViewportConstraints))
+ m_constraints = stickyStateNode.viewportConstraints();
+}
+
+void ScrollingTreeStickyNode::dumpProperties(TextStream& ts, OptionSet<ScrollingStateTreeAsTextBehavior> behavior) const
+{
+ ts << "sticky node";
+ ScrollingTreeNode::dumpProperties(ts, behavior);
+ ts.dumpProperty("sticky constraints", m_constraints);
+ if (behavior & ScrollingStateTreeAsTextBehavior::IncludeLayerPositions)
+ ts.dumpProperty("layer top left", layerTopLeft());
+}
+
+FloatPoint ScrollingTreeStickyNode::computeLayerPosition() const
+{
+ FloatSize offsetFromStickyAncestors;
+ 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 = m_constraints.constrainingRectAtLastLayout();
+ constrainingRect.move(overflowScrollingNode.scrollDeltaSinceLastCommit());
+ }
+ constrainingRect.move(-offsetFromStickyAncestors);
+ 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<ScrollingTreeStickyNode>(*ancestor))
+ offsetFromStickyAncestors += downcast<ScrollingTreeStickyNode>(*ancestor).scrollDeltaSinceLastCommit();
+
+ if (is<ScrollingTreeFixedNode>(*ancestor)) {
+ // FIXME: Do we need scrolling tree nodes at all for nested cases?
+ return m_constraints.layerPositionAtLastLayout();
+ }
+ }
+ ASSERT_NOT_REACHED();
+ return m_constraints.layerPositionAtLastLayout();
+}
+
+FloatSize ScrollingTreeStickyNode::scrollDeltaSinceLastCommit() const
+{
+ auto layerPosition = computeLayerPosition();
+ return layerPosition - m_constraints.layerPositionAtLastLayout();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(ASYNC_SCROLLING) && USE(NICOSIA)
Copied: trunk/Source/WebCore/page/scrolling/ScrollingTreeStickyNode.h (from rev 284919, trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.h) (0 => 284920)
--- trunk/Source/WebCore/page/scrolling/ScrollingTreeStickyNode.h (rev 0)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeStickyNode.h 2021-10-27 11:47:29 UTC (rev 284920)
@@ -0,0 +1,61 @@
+/*
+ * 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)
+
+#include "ScrollingConstraints.h"
+#include "ScrollingTreeNode.h"
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class ScrollingTreeStickyNode : public ScrollingTreeNode {
+public:
+ virtual ~ScrollingTreeStickyNode();
+
+ FloatSize scrollDeltaSinceLastCommit() const;
+
+protected:
+ ScrollingTreeStickyNode(ScrollingTree&, ScrollingNodeID);
+
+ void commitStateBeforeChildren(const ScrollingStateNode&) override;
+ FloatPoint computeLayerPosition() const;
+ void dumpProperties(WTF::TextStream&, OptionSet<ScrollingStateTreeAsTextBehavior>) const override;
+
+ virtual FloatPoint layerTopLeft() const = 0;
+
+ StickyPositionViewportConstraints m_constraints;
+};
+
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_SCROLLING_NODE(ScrollingTreeStickyNode, isStickyNode())
+
+#endif // ENABLE(ASYNC_SCROLLING)
Modified: trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeFixedNode.mm (284919 => 284920)
--- trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeFixedNode.mm 2021-10-27 11:32:38 UTC (rev 284919)
+++ trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeFixedNode.mm 2021-10-27 11:47:29 UTC (rev 284920)
@@ -35,7 +35,7 @@
#import "ScrollingTreeOverflowScrollProxyNode.h"
#import "ScrollingTreeOverflowScrollingNode.h"
#import "ScrollingTreePositionedNode.h"
-#import "ScrollingTreeStickyNode.h"
+#import "ScrollingTreeStickyNodeCocoa.h"
#import "WebCoreCALayerExtras.h"
#import <wtf/text/TextStream.h>
@@ -72,7 +72,7 @@
{
auto computeLayerPosition = [&] {
FloatSize overflowScrollDelta;
- ScrollingTreeStickyNode* lastStickyNode = nullptr;
+ ScrollingTreeStickyNodeCocoa* lastStickyNode = nullptr;
for (auto* ancestor = parent(); ancestor; ancestor = ancestor->parent()) {
if (is<ScrollingTreeFrameScrollingNode>(*ancestor)) {
// Fixed nodes are positioned relative to the containing frame scrolling node.
@@ -107,7 +107,7 @@
}
if (is<ScrollingTreeStickyNode>(*ancestor)) {
- auto& stickyNode = downcast<ScrollingTreeStickyNode>(*ancestor);
+ auto& stickyNode = downcast<ScrollingTreeStickyNodeCocoa>(*ancestor);
overflowScrollDelta += stickyNode.scrollDeltaSinceLastCommit();
lastStickyNode = &stickyNode;
continue;
Deleted: trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNode.h (284919 => 284920)
--- trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNode.h 2021-10-27 11:32:38 UTC (rev 284919)
+++ trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNode.h 2021-10-27 11:47:29 UTC (rev 284920)
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#if ENABLE(ASYNC_SCROLLING)
-
-#include "ScrollingConstraints.h"
-#include "ScrollingTreeNode.h"
-#include <wtf/RetainPtr.h>
-
-OBJC_CLASS CALayer;
-
-namespace WebCore {
-
-class ScrollingTreeStickyNode : public ScrollingTreeNode {
-public:
- WEBCORE_EXPORT static Ref<ScrollingTreeStickyNode> create(ScrollingTree&, ScrollingNodeID);
-
- virtual ~ScrollingTreeStickyNode();
-
- FloatSize scrollDeltaSinceLastCommit() const;
-
- CALayer *layer() { return m_layer.get(); }
-
-private:
- ScrollingTreeStickyNode(ScrollingTree&, ScrollingNodeID);
-
- void commitStateBeforeChildren(const ScrollingStateNode&) override;
- void applyLayerPositions() override;
-
- FloatPoint computeLayerPosition() const;
-
- void dumpProperties(WTF::TextStream&, OptionSet<ScrollingStateTreeAsTextBehavior>) const override;
-
- StickyPositionViewportConstraints m_constraints;
- RetainPtr<CALayer> m_layer;
-};
-
-} // namespace WebCore
-
-SPECIALIZE_TYPE_TRAITS_SCROLLING_NODE(ScrollingTreeStickyNode, isStickyNode())
-
-#endif // ENABLE(ASYNC_SCROLLING)
Deleted: trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNode.mm (284919 => 284920)
--- trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNode.mm 2021-10-27 11:32:38 UTC (rev 284919)
+++ trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNode.mm 2021-10-27 11:47:29 UTC (rev 284920)
@@ -1,145 +0,0 @@
-/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "ScrollingTreeStickyNode.h"
-
-#if ENABLE(ASYNC_SCROLLING)
-
-#import "Logging.h"
-#import "ScrollingStateStickyNode.h"
-#import "ScrollingTree.h"
-#import "ScrollingTreeFixedNode.h"
-#import "ScrollingTreeFrameScrollingNode.h"
-#import "ScrollingTreeOverflowScrollProxyNode.h"
-#import "ScrollingTreeOverflowScrollingNode.h"
-#import "WebCoreCALayerExtras.h"
-#import <wtf/text/TextStream.h>
-
-namespace WebCore {
-
-Ref<ScrollingTreeStickyNode> ScrollingTreeStickyNode::create(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
-{
- return adoptRef(*new ScrollingTreeStickyNode(scrollingTree, nodeID));
-}
-
-ScrollingTreeStickyNode::ScrollingTreeStickyNode(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
- : ScrollingTreeNode(scrollingTree, ScrollingNodeType::Sticky, nodeID)
-{
- scrollingTree.fixedOrStickyNodeAdded();
-}
-
-ScrollingTreeStickyNode::~ScrollingTreeStickyNode()
-{
- scrollingTree().fixedOrStickyNodeRemoved();
-}
-
-void ScrollingTreeStickyNode::commitStateBeforeChildren(const ScrollingStateNode& stateNode)
-{
- const ScrollingStateStickyNode& stickyStateNode = downcast<ScrollingStateStickyNode>(stateNode);
-
- if (stickyStateNode.hasChangedProperty(ScrollingStateNode::Property::Layer))
- m_layer = static_cast<CALayer*>(stickyStateNode.layer());
-
- if (stateNode.hasChangedProperty(ScrollingStateNode::Property::ViewportConstraints))
- m_constraints = stickyStateNode.viewportConstraints();
-}
-
-FloatPoint ScrollingTreeStickyNode::computeLayerPosition() const
-{
- FloatSize offsetFromStickyAncestors;
- 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 = m_constraints.constrainingRectAtLastLayout();
- constrainingRect.move(overflowScrollingNode.scrollDeltaSinceLastCommit());
- }
- constrainingRect.move(-offsetFromStickyAncestors);
- 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<ScrollingTreeStickyNode>(*ancestor))
- offsetFromStickyAncestors += downcast<ScrollingTreeStickyNode>(*ancestor).scrollDeltaSinceLastCommit();
-
- if (is<ScrollingTreeFixedNode>(*ancestor)) {
- // FIXME: Do we need scrolling tree nodes at all for nested cases?
- return m_constraints.layerPositionAtLastLayout();
- }
- }
- ASSERT_NOT_REACHED();
- return m_constraints.layerPositionAtLastLayout();
-}
-
-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);
-
- [m_layer _web_setLayerTopLeftPosition:layerPosition - m_constraints.alignmentOffset()];
-}
-
-FloatSize ScrollingTreeStickyNode::scrollDeltaSinceLastCommit() const
-{
- auto layerPosition = computeLayerPosition();
- return layerPosition - m_constraints.layerPositionAtLastLayout();
-}
-
-void ScrollingTreeStickyNode::dumpProperties(TextStream& ts, OptionSet<ScrollingStateTreeAsTextBehavior> behavior) const
-{
- ts << "sticky node";
-
- ScrollingTreeNode::dumpProperties(ts, behavior);
- ts.dumpProperty("sticky constraints", m_constraints);
-
- if (behavior & ScrollingStateTreeAsTextBehavior::IncludeLayerPositions) {
- FloatRect layerBounds = [m_layer bounds];
- FloatPoint anchorPoint = [m_layer anchorPoint];
- FloatPoint position = [m_layer position];
- FloatPoint layerTopLeft = position - toFloatSize(anchorPoint) * layerBounds.size() + m_constraints.alignmentOffset();
- ts.dumpProperty("layer top left", layerTopLeft);
- }
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(ASYNC_SCROLLING)
Copied: trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNodeCocoa.h (from rev 284919, trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNode.h) (0 => 284920)
--- trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNodeCocoa.h (rev 0)
+++ trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNodeCocoa.h 2021-10-27 11:47:29 UTC (rev 284920)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(ASYNC_SCROLLING)
+
+#include "ScrollingConstraints.h"
+#include "ScrollingTreeStickyNode.h"
+#include <wtf/RetainPtr.h>
+
+OBJC_CLASS CALayer;
+
+namespace WebCore {
+
+class ScrollingTreeStickyNodeCocoa : public ScrollingTreeStickyNode {
+public:
+ WEBCORE_EXPORT static Ref<ScrollingTreeStickyNodeCocoa> create(ScrollingTree&, ScrollingNodeID);
+
+ virtual ~ScrollingTreeStickyNodeCocoa() = default;
+
+ CALayer *layer() { return m_layer.get(); }
+
+private:
+ ScrollingTreeStickyNodeCocoa(ScrollingTree&, ScrollingNodeID);
+
+ void commitStateBeforeChildren(const ScrollingStateNode&) override;
+ void applyLayerPositions() override;
+ FloatPoint layerTopLeft() const override;
+
+ RetainPtr<CALayer> m_layer;
+};
+
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_SCROLLING_NODE(ScrollingTreeStickyNodeCocoa, isStickyNode())
+
+#endif // ENABLE(ASYNC_SCROLLING)
Added: trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNodeCocoa.mm (0 => 284920)
--- trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNodeCocoa.mm (rev 0)
+++ trunk/Source/WebCore/page/scrolling/cocoa/ScrollingTreeStickyNodeCocoa.mm 2021-10-27 11:47:29 UTC (rev 284920)
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "ScrollingTreeStickyNodeCocoa.h"
+
+#if ENABLE(ASYNC_SCROLLING)
+
+#import "Logging.h"
+#import "ScrollingStateStickyNode.h"
+#import "ScrollingTree.h"
+#import "WebCoreCALayerExtras.h"
+#import <wtf/text/TextStream.h>
+
+namespace WebCore {
+
+Ref<ScrollingTreeStickyNodeCocoa> ScrollingTreeStickyNodeCocoa::create(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
+{
+ return adoptRef(*new ScrollingTreeStickyNodeCocoa(scrollingTree, nodeID));
+}
+
+ScrollingTreeStickyNodeCocoa::ScrollingTreeStickyNodeCocoa(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
+ : ScrollingTreeStickyNode(scrollingTree, nodeID)
+{
+}
+
+void ScrollingTreeStickyNodeCocoa::commitStateBeforeChildren(const ScrollingStateNode& stateNode)
+{
+ const ScrollingStateStickyNode& stickyStateNode = downcast<ScrollingStateStickyNode>(stateNode);
+
+ if (stickyStateNode.hasChangedProperty(ScrollingStateNode::Property::Layer))
+ m_layer = static_cast<CALayer*>(stickyStateNode.layer());
+
+ ScrollingTreeStickyNode::commitStateBeforeChildren(stateNode);
+}
+
+void ScrollingTreeStickyNodeCocoa::applyLayerPositions()
+{
+ auto layerPosition = computeLayerPosition();
+
+ LOG_WITH_STREAM(Scrolling, stream << "ScrollingTreeStickyNodeCocoa " << scrollingNodeID() << " constrainingRectAtLastLayout " << m_constraints.constrainingRectAtLastLayout() << " last layer pos " << m_constraints.layerPositionAtLastLayout() << " layerPosition " << layerPosition);
+
+ [m_layer _web_setLayerTopLeftPosition:layerPosition - m_constraints.alignmentOffset()];
+}
+
+FloatPoint ScrollingTreeStickyNodeCocoa::layerTopLeft() const
+{
+ FloatRect layerBounds = [m_layer bounds];
+ FloatPoint anchorPoint = [m_layer anchorPoint];
+ FloatPoint position = [m_layer position];
+ return position - toFloatSize(anchorPoint) * layerBounds.size() + m_constraints.alignmentOffset();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(ASYNC_SCROLLING)
Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm (284919 => 284920)
--- trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm 2021-10-27 11:32:38 UTC (rev 284919)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm 2021-10-27 11:47:29 UTC (rev 284920)
@@ -40,7 +40,7 @@
#import "ScrollingTreeFixedNode.h"
#import "ScrollingTreeFrameScrollingNodeMac.h"
#import "ScrollingTreeMac.h"
-#import "ScrollingTreeStickyNode.h"
+#import "ScrollingTreeStickyNodeCocoa.h"
#import "TiledBacking.h"
#import <wtf/MainThread.h>
Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeMac.mm (284919 => 284920)
--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeMac.mm 2021-10-27 11:32:38 UTC (rev 284919)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeMac.mm 2021-10-27 11:47:29 UTC (rev 284920)
@@ -34,7 +34,7 @@
#import "ScrollingTreeOverflowScrollProxyNode.h"
#import "ScrollingTreeOverflowScrollingNodeMac.h"
#import "ScrollingTreePositionedNode.h"
-#import "ScrollingTreeStickyNode.h"
+#import "ScrollingTreeStickyNodeCocoa.h"
#import "WebCoreCALayerExtras.h"
#import "WebLayer.h"
#import "WheelEventTestMonitor.h"
@@ -69,7 +69,7 @@
case ScrollingNodeType::Fixed:
return ScrollingTreeFixedNode::create(*this, nodeID);
case ScrollingNodeType::Sticky:
- return ScrollingTreeStickyNode::create(*this, nodeID);
+ return ScrollingTreeStickyNodeCocoa::create(*this, nodeID);
case ScrollingNodeType::Positioned:
return ScrollingTreePositionedNode::create(*this, nodeID);
}
Modified: trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeNicosia.cpp (284919 => 284920)
--- trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeNicosia.cpp 2021-10-27 11:32:38 UTC (rev 284919)
+++ trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeNicosia.cpp 2021-10-27 11:47:29 UTC (rev 284920)
@@ -38,7 +38,7 @@
#include "ScrollingTreeOverflowScrollProxyNode.h"
#include "ScrollingTreeOverflowScrollingNodeNicosia.h"
#include "ScrollingTreePositionedNode.h"
-#include "ScrollingTreeStickyNode.h"
+#include "ScrollingTreeStickyNodeNicosia.h"
namespace WebCore {
@@ -67,7 +67,7 @@
case ScrollingNodeType::Fixed:
return ScrollingTreeFixedNode::create(*this, nodeID);
case ScrollingNodeType::Sticky:
- return ScrollingTreeStickyNode::create(*this, nodeID);
+ return ScrollingTreeStickyNodeNicosia::create(*this, nodeID);
case ScrollingNodeType::Positioned:
return ScrollingTreePositionedNode::create(*this, nodeID);
}
Deleted: trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.cpp (284919 => 284920)
--- trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.cpp 2021-10-27 11:32:38 UTC (rev 284919)
+++ trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.cpp 2021-10-27 11:47:29 UTC (rev 284920)
@@ -1,162 +0,0 @@
-/*
- * 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 "ScrollingTreeStickyNode.h"
-
-#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 "ScrollingTreeOverflowScrollProxyNode.h"
-#include "ScrollingTreeOverflowScrollingNode.h"
-#include <wtf/text/TextStream.h>
-
-namespace WebCore {
-
-Ref<ScrollingTreeStickyNode> ScrollingTreeStickyNode::create(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
-{
- return adoptRef(*new ScrollingTreeStickyNode(scrollingTree, nodeID));
-}
-
-ScrollingTreeStickyNode::ScrollingTreeStickyNode(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
- : ScrollingTreeNode(scrollingTree, ScrollingNodeType::Sticky, nodeID)
-{
- scrollingTree.fixedOrStickyNodeAdded();
-}
-
-ScrollingTreeStickyNode::~ScrollingTreeStickyNode()
-{
- scrollingTree().fixedOrStickyNodeRemoved();
-}
-
-void ScrollingTreeStickyNode::commitStateBeforeChildren(const ScrollingStateNode& stateNode)
-{
- auto& stickyStateNode = downcast<ScrollingStateStickyNode>(stateNode);
-
- if (stickyStateNode.hasChangedProperty(ScrollingStateNode::Property::Layer)) {
- auto* layer = static_cast<Nicosia::PlatformLayer*>(stickyStateNode.layer());
- m_layer = downcast<Nicosia::CompositionLayer>(layer);
- }
-
- if (stickyStateNode.hasChangedProperty(ScrollingStateNode::Property::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->updateState(
- [&layerPosition](Nicosia::CompositionLayer::LayerState& state)
- {
- state.position = layerPosition;
- state.delta.positionChanged = true;
- });
-}
-
-void ScrollingTreeStickyNode::dumpProperties(TextStream& ts, OptionSet<ScrollingStateTreeAsTextBehavior> behavior) const
-{
- ts << "sticky node";
-
- ScrollingTreeNode::dumpProperties(ts, behavior);
- ts.dumpProperty("sticky constraints", m_constraints);
-
- if (behavior & ScrollingStateTreeAsTextBehavior::IncludeLayerPositions) {
- 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
-{
- FloatSize offsetFromStickyAncestors;
- 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 = m_constraints.constrainingRectAtLastLayout();
- constrainingRect.move(overflowScrollingNode.scrollDeltaSinceLastCommit());
- }
- constrainingRect.move(-offsetFromStickyAncestors);
- 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<ScrollingTreeStickyNode>(*ancestor))
- offsetFromStickyAncestors += downcast<ScrollingTreeStickyNode>(*ancestor).scrollDeltaSinceLastCommit();
-
- if (is<ScrollingTreeFixedNode>(*ancestor)) {
- // FIXME: Do we need scrolling tree nodes at all for nested cases?
- return m_constraints.layerPositionAtLastLayout();
- }
- }
- ASSERT_NOT_REACHED();
- return m_constraints.layerPositionAtLastLayout();
-}
-
-FloatSize ScrollingTreeStickyNode::scrollDeltaSinceLastCommit() const
-{
- auto layerPosition = computeLayerPosition();
- return layerPosition - m_constraints.layerPositionAtLastLayout();
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(ASYNC_SCROLLING) && USE(NICOSIA)
Deleted: trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.h (284919 => 284920)
--- trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.h 2021-10-27 11:32:38 UTC (rev 284919)
+++ trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.h 2021-10-27 11:47:29 UTC (rev 284920)
@@ -1,67 +0,0 @@
-/*
- * 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 ScrollingTreeStickyNode final : public ScrollingTreeNode {
-public:
- static Ref<ScrollingTreeStickyNode> create(ScrollingTree&, ScrollingNodeID);
- virtual ~ScrollingTreeStickyNode();
-
-private:
- ScrollingTreeStickyNode(ScrollingTree&, ScrollingNodeID);
-
- void commitStateBeforeChildren(const ScrollingStateNode&) override;
- void applyLayerPositions() override;
-
- void dumpProperties(WTF::TextStream&, OptionSet<ScrollingStateTreeAsTextBehavior>) const override;
-
- FloatPoint computeLayerPosition() const;
- FloatSize scrollDeltaSinceLastCommit() const;
-
- StickyPositionViewportConstraints m_constraints;
- RefPtr<Nicosia::CompositionLayer> m_layer;
-};
-
-} // namespace WebCore
-
-SPECIALIZE_TYPE_TRAITS_SCROLLING_NODE(ScrollingTreeStickyNode, isStickyNode())
-
-#endif // ENABLE(ASYNC_SCROLLING) && USE(NICOSIA)
Added: trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNodeNicosia.cpp (0 => 284920)
--- trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNodeNicosia.cpp (rev 0)
+++ trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNodeNicosia.cpp 2021-10-27 11:47:29 UTC (rev 284920)
@@ -0,0 +1,98 @@
+/*
+ * 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 "ScrollingTreeStickyNodeNicosia.h"
+
+#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 "ScrollingTreeOverflowScrollProxyNode.h"
+#include "ScrollingTreeOverflowScrollingNode.h"
+#include <wtf/text/TextStream.h>
+
+namespace WebCore {
+
+Ref<ScrollingTreeStickyNodeNicosia> ScrollingTreeStickyNodeNicosia::create(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
+{
+ return adoptRef(*new ScrollingTreeStickyNodeNicosia(scrollingTree, nodeID));
+}
+
+ScrollingTreeStickyNodeNicosia::ScrollingTreeStickyNodeNicosia(ScrollingTree& scrollingTree, ScrollingNodeID nodeID)
+ : ScrollingTreeStickyNode(scrollingTree, nodeID)
+{
+}
+
+void ScrollingTreeStickyNodeNicosia::commitStateBeforeChildren(const ScrollingStateNode& stateNode)
+{
+ auto& stickyStateNode = downcast<ScrollingStateStickyNode>(stateNode);
+ if (stickyStateNode.hasChangedProperty(ScrollingStateNode::Property::Layer)) {
+ auto* layer = static_cast<Nicosia::PlatformLayer*>(stickyStateNode.layer());
+ m_layer = downcast<Nicosia::CompositionLayer>(layer);
+ }
+
+ ScrollingTreeStickyNode::commitStateBeforeChildren(stateNode);
+}
+
+void ScrollingTreeStickyNodeNicosia::applyLayerPositions()
+{
+ auto layerPosition = computeLayerPosition();
+
+ LOG_WITH_STREAM(Scrolling, stream << "ScrollingTreeStickyNodeNicosia " << scrollingNodeID() << " constrainingRectAtLastLayout " << m_constraints.constrainingRectAtLastLayout() << " last layer pos " << m_constraints.layerPositionAtLastLayout() << " layerPosition " << layerPosition);
+
+ layerPosition -= m_constraints.alignmentOffset();
+
+ ASSERT(m_layer);
+ m_layer->updateState(
+ [&layerPosition](Nicosia::CompositionLayer::LayerState& state)
+ {
+ state.position = layerPosition;
+ state.delta.positionChanged = true;
+ });
+}
+
+FloatPoint ScrollingTreeStickyNodeNicosia::layerTopLeft() const
+{
+ 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();
+ });
+ return layerTopLeft;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(ASYNC_SCROLLING) && USE(NICOSIA)
Copied: trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNodeNicosia.h (from rev 284919, trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.h) (0 => 284920)
--- trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNodeNicosia.h (rev 0)
+++ trunk/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNodeNicosia.h 2021-10-27 11:47:29 UTC (rev 284920)
@@ -0,0 +1,62 @@
+/*
+ * 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 "ScrollingTreeStickyNode.h"
+#include <wtf/RefPtr.h>
+
+namespace Nicosia {
+class CompositionLayer;
+}
+
+namespace WebCore {
+
+class ScrollingTreeStickyNodeNicosia final : public ScrollingTreeStickyNode {
+public:
+ static Ref<ScrollingTreeStickyNodeNicosia> create(ScrollingTree&, ScrollingNodeID);
+ virtual ~ScrollingTreeStickyNodeNicosia() = default;
+
+private:
+ ScrollingTreeStickyNodeNicosia(ScrollingTree&, ScrollingNodeID);
+
+ void commitStateBeforeChildren(const ScrollingStateNode&) override;
+ void applyLayerPositions() override;
+ FloatPoint layerTopLeft() const override;
+
+ RefPtr<Nicosia::CompositionLayer> m_layer;
+};
+
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_SCROLLING_NODE(ScrollingTreeStickyNodeNicosia, isStickyNode())
+
+#endif // ENABLE(ASYNC_SCROLLING) && USE(NICOSIA)
Modified: trunk/Source/WebCore/platform/TextureMapper.cmake (284919 => 284920)
--- trunk/Source/WebCore/platform/TextureMapper.cmake 2021-10-27 11:32:38 UTC (rev 284919)
+++ trunk/Source/WebCore/platform/TextureMapper.cmake 2021-10-27 11:47:29 UTC (rev 284920)
@@ -100,7 +100,7 @@
)
list(APPEND WebCore_PRIVATE_FRAMEWORK_HEADERS
page/scrolling/nicosia/ScrollingTreeFixedNode.h
- page/scrolling/nicosia/ScrollingTreeStickyNode.h
+ page/scrolling/nicosia/ScrollingTreeStickyNodeNicosia.h
platform/graphics/nicosia/NicosiaAnimatedBackingStoreClient.h
platform/graphics/nicosia/NicosiaBuffer.h
Modified: trunk/Source/WebKit/ChangeLog (284919 => 284920)
--- trunk/Source/WebKit/ChangeLog 2021-10-27 11:32:38 UTC (rev 284919)
+++ trunk/Source/WebKit/ChangeLog 2021-10-27 11:47:29 UTC (rev 284920)
@@ -1,3 +1,17 @@
+2021-10-27 Martin Robinson <[email protected]>
+
+ Eliminate duplicated platform-specific code in ScrollingTreeStickyNode
+ https://bugs.webkit.org/show_bug.cgi?id=231571
+
+ Reviewed by Simon Fraser.
+
+ Abstract code from the Nicosia and Cooca version of ScrollingTreeStickyNode,
+ so that it can be shared by both ports.
+
+ * UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp:
+ (WebKit::RemoteScrollingTree::createScrollingTreeNode):
+ * WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.mm:
+
2021-10-26 Alex Christensen <[email protected]>
Remove properties set by NSURLProtocol on NSURLRequest before serializing
Modified: trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp (284919 => 284920)
--- trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp 2021-10-27 11:32:38 UTC (rev 284919)
+++ trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteScrollingTree.cpp 2021-10-27 11:47:29 UTC (rev 284920)
@@ -34,7 +34,7 @@
#include <WebCore/ScrollingTreeFrameHostingNode.h>
#include <WebCore/ScrollingTreeOverflowScrollProxyNode.h>
#include <WebCore/ScrollingTreePositionedNode.h>
-#include <WebCore/ScrollingTreeStickyNode.h>
+#include <WebCore/ScrollingTreeStickyNodeCocoa.h>
#if PLATFORM(IOS_FAMILY)
#include "ScrollingTreeFrameScrollingNodeRemoteIOS.h"
@@ -127,7 +127,7 @@
case ScrollingNodeType::Fixed:
return ScrollingTreeFixedNode::create(*this, nodeID);
case ScrollingNodeType::Sticky:
- return ScrollingTreeStickyNode::create(*this, nodeID);
+ return ScrollingTreeStickyNodeCocoa::create(*this, nodeID);
case ScrollingNodeType::Positioned:
return ScrollingTreePositionedNode::create(*this, nodeID);
}
Modified: trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.mm (284919 => 284920)
--- trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.mm 2021-10-27 11:32:38 UTC (rev 284919)
+++ trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.mm 2021-10-27 11:47:29 UTC (rev 284920)
@@ -43,7 +43,7 @@
#import <WebCore/RenderLayerCompositor.h>
#import <WebCore/RenderView.h>
#import <WebCore/ScrollingTreeFixedNode.h>
-#import <WebCore/ScrollingTreeStickyNode.h>
+#import <WebCore/ScrollingTreeStickyNodeCocoa.h>
namespace WebKit {