COMMIT_MESSAGE

 1Bug 172914 - Add ParentRelativeScrollableRect to ScrollingCoordinator::ScrollingGeometry
 2

LayoutTests/ChangeLog

 12017-09-12 Frederic Wang <fwang@igalia.com>
 2
 3 Add ParentRelativeScrollableRect to ScrollingCoordinator::ScrollingGeometry
 4 https://bugs.webkit.org/show_bug.cgi?id=172914
 5
 6 This commit updates the test expectations to take into account the new parameter in the
 7 scrolling tree. Also, scrolling-tree-includes-frame.html is adjusted a bit to be sure that
 8 we verified this "offset in parent" parameter.
 9
 10 Reviewed by NOBODY (OOPS!).
 11
 12 * fast/scrolling/ios/remove-scrolling-role-expected.txt:
 13 * fast/scrolling/scrolling-tree-iframe-parent-relative-scrollable-rect-expected.txt: Added.
 14 * fast/scrolling/scrolling-tree-iframe-parent-relative-scrollable-rect.html: Added.
 15 * fast/scrolling/scrolling-tree-includes-frame-expected.txt:
 16 * fast/scrolling/scrolling-tree-includes-frame.html:
 17 * platform/ios-wk2/fast/scrolling/scrolling-tree-iframe-parent-relative-scrollable-rect-expected.txt:
 18 * platform/ios-wk2/fast/scrolling/scrolling-tree-includes-frame-expected.txt:
 19 * platform/ios/fast/scrolling/scrolling-tree-iframe-parent-relative-scrollable-rect-expected.txt:
 20 * platform/ios/fast/scrolling/scrolling-tree-includes-frame-expected.txt:
 21 * platform/mac-wk1/fast/scrolling/scrolling-tree-iframe-parent-relative-scrollable-rect-expected.txt: Added.
 22 * tiled-drawing/scrolling/frames/coordinated-frame-expected.txt:
 23 * tiled-drawing/scrolling/frames/coordinated-frame-gain-scrolling-ancestor-expected.txt:
 24 * tiled-drawing/scrolling/frames/coordinated-frame-in-fixed-expected.txt:
 25 * tiled-drawing/scrolling/frames/coordinated-frame-lose-scrolling-ancestor-expected.txt:
 26 * tiled-drawing/scrolling/frames/fixed-inside-frame-expected.txt:
 27
1282017-09-25 Devin Rousso <webkit@devinrousso.com>
229
330 Web Inspector: move Console.addInspectedNode to DOM.setInspectedNode

LayoutTests/fast/scrolling/ios/remove-scrolling-role-expected.txt

1616 (Overflow scrolling node
1717 (scrollable area size 300 400)
1818 (contents size 300 2000)
 19 (parent relative scrollable rect at (10,10) size 300x400)
1920 (scrollable area parameters
2021 (horizontal scroll elasticity 1)
2122 (vertical scroll elasticity 1)

LayoutTests/fast/scrolling/scrolling-tree-iframe-parent-relative-scrollable-rect-expected.txt

 1
 2
 3(Frame scrolling node
 4 (scrollable area size 800 600)
 5 (contents size 800 600)
 6 (scrollable area parameters
 7 (horizontal scroll elasticity 2)
 8 (vertical scroll elasticity 2)
 9 (horizontal scrollbar mode 0)
 10 (vertical scrollbar mode 0))
 11 (visual viewport enabled 1)
 12 (layout viewport at (0,0) size 800x600)
 13 (min layout viewport origin (0,0))
 14 (max layout viewport origin (0,0))
 15 (behavior for fixed 0)
 16 (children 1
 17 (Frame scrolling node
 18 (scrollable area size 85 185)
 19 (contents size 308 416)
 20 (parent relative scrollable rect at (135,145) size 100x200)
 21 (scrollable area parameters
 22 (horizontal scroll elasticity 0)
 23 (vertical scroll elasticity 0)
 24 (horizontal scrollbar mode 0)
 25 (vertical scrollbar mode 0)
 26 (has enabled horizontal scrollbar 1)
 27 (has enabled vertical scrollbar 1))
 28 (visual viewport enabled 1)
 29 (layout viewport at (0,0) size 85x185)
 30 (min layout viewport origin (0,0))
 31 (max layout viewport origin (223,231))
 32 (behavior for fixed 0)
 33 )
 34 )
 35)
 36
 37

LayoutTests/fast/scrolling/scrolling-tree-iframe-parent-relative-scrollable-rect.html

 1<!DOCTYPE html>
 2<html>
 3 <head>
 4 <title>Check the ParentRelativeScrollableRect of iframe in the scrolling tree</title>
 5 <script>
 6 if (window.testRunner) {
 7 testRunner.dumpAsText();
 8 testRunner.waitUntilDone();
 9 }
 10 if (window.internals)
 11 window.internals.settings.setAsyncFrameScrollingEnabled(true);
 12 function doTest()
 13 {
 14 if (window.internals)
 15 document.getElementById('scrollingTree').innerText = window.internals.scrollingStateTreeAsText() + "\n";
 16 if (window.testRunner)
 17 testRunner.notifyDone();
 18 }
 19 </script>
 20 <style>
 21 iframe {
 22 position: absolute;
 23 left: 60px;
 24 top: 70px;
 25 width: 100px;
 26 height: 200px;
 27 background: gray;
 28 overflow: scroll;
 29 margin: 15px;
 30 border: 10px solid blue;
 31 padding: 20px;
 32 }
 33 </style>
 34 </head>
 35 <body>
 36 <iframe onload="doTest()" srcdoc="
 37 <div style='width: 300px; height: 400px; background: white;'></div>
 38 ">
 39 </iframe>
 40 <pre id="scrollingTree"></pre>
 41 </body>
 42</html>

LayoutTests/fast/scrolling/scrolling-tree-includes-frame-expected.txt

1717 (Frame scrolling node
1818 (scrollable area size 85 185)
1919 (contents size 308 416)
 20 (parent relative scrollable rect at (60,70) size 100x200)
2021 (scrollable area parameters
2122 (horizontal scroll elasticity 0)
2223 (vertical scroll elasticity 0)

LayoutTests/fast/scrolling/scrolling-tree-includes-frame.html

33 <head>
44 <title>Check whether scrollable iframes are included in the scrolling tree when async frame scrolling is enabled</title>
55 <script>
6  if (window.testRunner)
 6 if (window.testRunner) {
77 testRunner.dumpAsText();
 8 testRunner.waitUntilDone();
 9 }
810 if (window.internals)
911 window.internals.settings.setAsyncFrameScrollingEnabled(true);
1012 function doTest()
1113 {
1214 if (window.internals)
1315 document.getElementById('scrollingTree').innerText = window.internals.scrollingStateTreeAsText() + "\n";
 16 if (window.testRunner)
 17 testRunner.notifyDone();
1418 }
15  window.addEventListener('load', doTest, false);
1619 </script>
 20 <style>
 21 iframe {
 22 position: absolute;
 23 left: 60px;
 24 top: 70px;
 25 width: 100px;
 26 height: 200px;
 27 margin: 0;
 28 border: 0;
 29 padding: 0;
 30 }
 31 </style>
1732 </head>
1833 <body>
19  <iframe id="frame" style="width: 100px; height: 200px; border: 1px solid black;" src="data:text/html,<div style='width: 300px; height: 400px; background: gray;'></div>"></iframe>
 34 <iframe onload="doTest()" srcdoc="
 35 <div style='width: 300px; height: 400px; background: gray;'></div>
 36 ">
 37 </iframe>
2038 <pre id="scrollingTree"></pre>
2139 </body>
2240</html>

LayoutTests/platform/ios-wk2/fast/scrolling/scrolling-tree-iframe-parent-relative-scrollable-rect-expected.txt

 1
 2
 3(Frame scrolling node
 4 (scrollable area size 800 600)
 5 (contents size 800 600)
 6 (scrollable area parameters
 7 (horizontal scroll elasticity 1)
 8 (vertical scroll elasticity 1)
 9 (horizontal scrollbar mode 0)
 10 (vertical scrollbar mode 0))
 11 (visual viewport enabled 1)
 12 (layout viewport at (0,0) size 800x600)
 13 (min layout viewport origin (0,0))
 14 (max layout viewport origin (0,0))
 15 (behavior for fixed 0)
 16 (children 1
 17 (Frame scrolling node
 18 (scrollable area size 100 200)
 19 (contents size 308 416)
 20 (parent relative scrollable rect at (105,115) size 100x200)
 21 (scrollable area parameters
 22 (horizontal scroll elasticity 1)
 23 (vertical scroll elasticity 1)
 24 (horizontal scrollbar mode 0)
 25 (vertical scrollbar mode 0))
 26 (visual viewport enabled 1)
 27 (layout viewport at (0,0) size 100x200)
 28 (min layout viewport origin (0,0))
 29 (max layout viewport origin (208,216))
 30 (behavior for fixed 0)
 31 )
 32 )
 33)
 34
 35

LayoutTests/platform/ios-wk2/fast/scrolling/scrolling-tree-includes-frame-expected.txt

1717 (Frame scrolling node
1818 (scrollable area size 100 200)
1919 (contents size 308 416)
 20 (parent relative scrollable rect at (60,70) size 100x200)
2021 (scrollable area parameters
2122 (horizontal scroll elasticity 1)
2223 (vertical scroll elasticity 1)

LayoutTests/platform/ios/fast/scrolling/scrolling-tree-iframe-parent-relative-scrollable-rect-expected.txt

 1
 2
 3(Frame scrolling node
 4 (scrollable area size 800 600)
 5 (contents size 800 600)
 6 (scrollable area parameters
 7 (horizontal scroll elasticity 1)
 8 (vertical scroll elasticity 1)
 9 (horizontal scrollbar mode 0)
 10 (vertical scrollbar mode 0))
 11 (visual viewport enabled 1)
 12 (layout viewport at (0,0) size 800x600)
 13 (min layout viewport origin (0,0))
 14 (max layout viewport origin (0,0))
 15 (synchronous event dispatch region for event wheel
 16 at (61,71) size 100x200)
 17 (behavior for fixed 0)
 18)
 19
 20

LayoutTests/platform/ios/fast/scrolling/scrolling-tree-includes-frame-expected.txt

1313 (min layout viewport origin (0,0))
1414 (max layout viewport origin (0,0))
1515 (synchronous event dispatch region for event wheel
16  at (9,9) size 100x200)
 16 at (61,71) size 100x200)
1717 (behavior for fixed 0)
1818)
1919

LayoutTests/platform/mac-wk1/fast/scrolling/scrolling-tree-iframe-parent-relative-scrollable-rect-expected.txt

 1
 2
 3

LayoutTests/tiled-drawing/scrolling/frames/coordinated-frame-expected.txt

1919 (Frame scrolling node
2020 (scrollable area size 485 300)
2121 (contents size 485 420)
 22 (parent relative scrollable rect at (42,44) size 500x300)
2223 (scrollable area parameters
2324 (horizontal scroll elasticity 0)
2425 (vertical scroll elasticity 0)

LayoutTests/tiled-drawing/scrolling/frames/coordinated-frame-gain-scrolling-ancestor-expected.txt

2424 (Frame scrolling node
2525 (scrollable area size 500 300)
2626 (contents size 500 420)
 27 (parent relative scrollable rect at (42,44) size 500x300)
2728 (scrollable area parameters
2829 (horizontal scroll elasticity 0)
2930 (vertical scroll elasticity 0)

LayoutTests/tiled-drawing/scrolling/frames/coordinated-frame-in-fixed-expected.txt

2424 (Frame scrolling node
2525 (scrollable area size 485 300)
2626 (contents size 485 420)
 27 (parent relative scrollable rect at (34,34) size 500x300)
2728 (scrollable area parameters
2829 (horizontal scroll elasticity 0)
2930 (vertical scroll elasticity 0)

LayoutTests/tiled-drawing/scrolling/frames/coordinated-frame-lose-scrolling-ancestor-expected.txt

1919 (Frame scrolling node
2020 (scrollable area size 500 300)
2121 (contents size 500 420)
 22 (reachable contents size width=500 height=300)
 23 (parent relative scrollable rect at (34,34) size 500x300)
2224 (scrollable area parameters
2325 (horizontal scroll elasticity 0)
2426 (vertical scroll elasticity 0)

LayoutTests/tiled-drawing/scrolling/frames/fixed-inside-frame-expected.txt

1818 (Frame scrolling node
1919 (scrollable area size 465 400)
2020 (contents size 465 1016)
 21 (reachable contents size width=465 height=400)
2122 (requested scroll position 0 120)
2223 (requested scroll position represents programmatic scroll 1)
 24 (parent relative scrollable rect at (112,112) size 480x400)
2325 (scrollable area parameters
2426 (horizontal scroll elasticity 0)
2527 (vertical scroll elasticity 0)

Source/WebCore/ChangeLog

 12017-09-12 Frederic Wang <fwang@igalia.com>
 2
 3 Add ParentRelativeScrollableRect to ScrollingCoordinator::ScrollingGeometry
 4 https://bugs.webkit.org/show_bug.cgi?id=172914
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 This patch introduce a new ParentRelativeScrollableRect parameter to the scrolling geometry. It is the
 9 target rectangle for mouse event with coordinates relative to the parent scrolling node. This
 10 will be used for iframes to implement hit testing in the scrolling tree.
 11
 12 Test: fast/scrolling/scrolling-tree-iframe-parent-relative-scrollable-rect.html
 13
 14 * page/scrolling/AsyncScrollingCoordinator.cpp: Take parentRelativeScrollableRect into account.
 15 (WebCore::AsyncScrollingCoordinator::updateFrameScrollingNode):
 16 (WebCore::AsyncScrollingCoordinator::updateOverflowScrollingNode):
 17 * page/scrolling/ScrollingCoordinator.h: Add parentRelativeScrollableRect.
 18 * page/scrolling/ScrollingStateScrollingNode.cpp: Ditto.
 19 (WebCore::ScrollingStateScrollingNode::ScrollingStateScrollingNode):
 20 (WebCore::ScrollingStateScrollingNode::setParentRelativeScrollableRect):
 21 (WebCore::ScrollingStateScrollingNode::dumpProperties const):
 22 * page/scrolling/ScrollingStateScrollingNode.h: Ditto.
 23 (WebCore::ScrollingStateScrollingNode::parentRelativeScrollableRect const):
 24 * page/scrolling/ScrollingTreeScrollingNode.cpp: Ditto.
 25 (WebCore::ScrollingTreeScrollingNode::commitStateBeforeChildren):
 26 (WebCore::ScrollingTreeScrollingNode::dumpProperties const):
 27 * page/scrolling/ScrollingTreeScrollingNode.h: Ditto.
 28 (WebCore::ScrollingTreeScrollingNode::parentRelativeScrollableRect const):
 29 * rendering/RenderLayerCompositor.cpp:
 30 (WebCore::RenderLayerCompositor::findEnclosingScrollingNode): This function is renamed from
 31 enclosingScrollingNodeID. It now returns an EnclosingNodeData containing the enclosing node
 32 id together with the target rect of the node relative to its enclosing node.
 33 (WebCore::RenderLayerCompositor::scrollCoordinatedAncestorInParentOfFrame): This function
 34 is generalized to return the EnclosingNodeData.
 35 (WebCore::RenderLayerCompositor::reattachSubframeScrollLayers): Use EnclosingNodeData.
 36 (WebCore::RenderLayerCompositor::scrollingGeometryFor): New helper function to retrieve the
 37 scrolling geometry associated to a layer.
 38 (WebCore::RenderLayerCompositor::updateScrollCoordinationForThisFrame): For non-main frames,
 39 this now properly sets the scrolling geometry.
 40 (WebCore::RenderLayerCompositor::updateScrollCoordinatedLayer): Use the new helper functions
 41 to calculate the enclosing node and scrolling geometry.
 42 * rendering/RenderLayerCompositor.h: Define an EnclosingNodeData, which contains data for the
 43 enclosing node (node id and offset from parent).
 44
1452017-09-25 Timothy Horton <timothy_horton@apple.com>
246
347 Fix the macOS WebCore CMake build

Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp

@@void AsyncScrollingCoordinator::updateFrameScrollingNode(ScrollingNodeID nodeID,
530530 node->setCounterScrollingLayer(counterScrollingLayer);
531531
532532 if (scrollingGeometry) {
 533 node->setParentRelativeScrollableRect(scrollingGeometry->parentRelativeScrollableRect);
533534 node->setScrollOrigin(scrollingGeometry->scrollOrigin);
534535 node->setScrollPosition(scrollingGeometry->scrollPosition);
535536 node->setTotalContentsSize(scrollingGeometry->contentSize);

@@void AsyncScrollingCoordinator::updateOverflowScrollingNode(ScrollingNodeID node
549550 node->setScrolledContentsLayer(scrolledContentsLayer);
550551
551552 if (scrollingGeometry) {
 553 node->setParentRelativeScrollableRect(scrollingGeometry->parentRelativeScrollableRect);
552554 node->setScrollOrigin(scrollingGeometry->scrollOrigin);
553555 node->setScrollPosition(scrollingGeometry->scrollPosition);
554556 node->setTotalContentsSize(scrollingGeometry->contentSize);

Source/WebCore/page/scrolling/ScrollingCoordinator.h

@@public:
173173 virtual void updateNodeViewportConstraints(ScrollingNodeID, const ViewportConstraints&) { }
174174
175175 struct ScrollingGeometry {
 176 LayoutRect parentRelativeScrollableRect;
176177 FloatSize scrollableAreaSize;
177178 FloatSize contentSize;
178179 FloatSize reachableContentSize; // Smaller than contentSize when overflow is hidden on one axis.

Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp

@@ScrollingStateScrollingNode::ScrollingStateScrollingNode(const ScrollingStateScr
4343 , m_scrollableAreaSize(stateNode.scrollableAreaSize())
4444 , m_totalContentsSize(stateNode.totalContentsSize())
4545 , m_reachableContentsSize(stateNode.reachableContentsSize())
 46 , m_parentRelativeScrollableRect(stateNode.parentRelativeScrollableRect())
4647 , m_scrollPosition(stateNode.scrollPosition())
4748 , m_requestedScrollPosition(stateNode.requestedScrollPosition())
4849 , m_scrollOrigin(stateNode.scrollOrigin())

@@void ScrollingStateScrollingNode::setReachableContentsSize(const FloatSize& reac
8889 setPropertyChanged(ReachableContentsSize);
8990}
9091
 92void ScrollingStateScrollingNode::setParentRelativeScrollableRect(const LayoutRect& parentRelativeScrollableRect)
 93{
 94 if (m_parentRelativeScrollableRect == parentRelativeScrollableRect)
 95 return;
 96
 97 m_parentRelativeScrollableRect = parentRelativeScrollableRect;
 98 setPropertyChanged(ParentRelativeScrollableRect);
 99}
 100
91101void ScrollingStateScrollingNode::setScrollPosition(const FloatPoint& scrollPosition)
92102{
93103 if (m_scrollPosition == scrollPosition)

@@void ScrollingStateScrollingNode::dumpProperties(TextStream& ts, ScrollingStateT
233243 if (m_requestedScrollPositionRepresentsProgrammaticScroll)
234244 ts.dumpProperty("requested scroll position represents programmatic scroll", m_requestedScrollPositionRepresentsProgrammaticScroll);
235245
 246 if (!m_parentRelativeScrollableRect.isEmpty())
 247 ts.dumpProperty("parent relative scrollable rect", m_parentRelativeScrollableRect);
 248
236249 if (m_scrollOrigin != IntPoint())
237250 ts.dumpProperty("scroll origin", m_scrollOrigin);
238251

Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h

@@public:
4242 ScrollableAreaSize = NumStateNodeBits,
4343 TotalContentsSize,
4444 ReachableContentsSize,
 45 ParentRelativeScrollableRect,
4546 ScrollPosition,
4647 ScrollOrigin,
4748 ScrollableAreaParams,

@@public:
6869 const FloatSize& reachableContentsSize() const { return m_reachableContentsSize; }
6970 WEBCORE_EXPORT void setReachableContentsSize(const FloatSize&);
7071
 72 const LayoutRect& parentRelativeScrollableRect() const { return m_parentRelativeScrollableRect; }
 73 WEBCORE_EXPORT void setParentRelativeScrollableRect(const LayoutRect&);
 74
7175 const FloatPoint& scrollPosition() const { return m_scrollPosition; }
7276 WEBCORE_EXPORT void setScrollPosition(const FloatPoint&);
7377

@@private:
118122 FloatSize m_scrollableAreaSize;
119123 FloatSize m_totalContentsSize;
120124 FloatSize m_reachableContentsSize;
 125 LayoutRect m_parentRelativeScrollableRect;
121126 FloatPoint m_scrollPosition;
122127 FloatPoint m_requestedScrollPosition;
123128 IntPoint m_scrollOrigin;

Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp

@@void ScrollingTreeScrollingNode::commitStateBeforeChildren(const ScrollingStateN
6565 if (state.hasChangedProperty(ScrollingStateScrollingNode::ScrollPosition))
6666 m_lastCommittedScrollPosition = state.scrollPosition();
6767
 68 if (state.hasChangedProperty(ScrollingStateScrollingNode::ParentRelativeScrollableRect))
 69 m_parentRelativeScrollableRect = state.parentRelativeScrollableRect();
 70
6871 if (state.hasChangedProperty(ScrollingStateScrollingNode::ScrollOrigin))
6972 m_scrollOrigin = state.scrollOrigin();
7073

@@void ScrollingTreeScrollingNode::dumpProperties(TextStream& ts, ScrollingStateTr
141144 if (m_reachableContentsSize != m_totalContentsSize)
142145 ts.dumpProperty("reachable content size", m_reachableContentsSize);
143146 ts.dumpProperty("last committed scroll position", m_lastCommittedScrollPosition);
 147
 148 if (!m_parentRelativeScrollableRect.isEmpty())
 149 ts.dumpProperty("parent relative scrollable rect", m_parentRelativeScrollableRect);
 150
144151 if (m_scrollOrigin != IntPoint())
145152 ts.dumpProperty("scroll origin", m_scrollOrigin);
146153

Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h

@@protected:
8787 const FloatSize& scrollableAreaSize() const { return m_scrollableAreaSize; }
8888 const FloatSize& totalContentsSize() const { return m_totalContentsSize; }
8989 const FloatSize& reachableContentsSize() const { return m_reachableContentsSize; }
 90 const LayoutRect& parentRelativeScrollableRect() const { return m_parentRelativeScrollableRect; }
9091 const IntPoint& scrollOrigin() const { return m_scrollOrigin; }
9192
9293 // If the totalContentsSize changes in the middle of a rubber-band, we still want to use the old totalContentsSize for the sake of

@@private:
111112 FloatSize m_totalContentsSizeForRubberBand;
112113 FloatSize m_reachableContentsSize;
113114 FloatPoint m_lastCommittedScrollPosition;
 115 LayoutRect m_parentRelativeScrollableRect;
114116 IntPoint m_scrollOrigin;
115117#if ENABLE(CSS_SCROLL_SNAP)
116118 ScrollSnapOffsetsInfo<float> m_snapOffsetsInfo;

Source/WebCore/rendering/RenderLayerCompositor.cpp

@@StickyPositionViewportConstraints RenderLayerCompositor::computeStickyViewportCo
36363636 return constraints;
36373637}
36383638
3639 static ScrollingNodeID enclosingScrollingNodeID(RenderLayer& layer, IncludeSelfOrNot includeSelf)
 3639RenderLayerCompositor::EnclosingNodeData RenderLayerCompositor::findEnclosingScrollingNode(RenderLayer& layer, IncludeSelfOrNot includeSelf)
36403640{
36413641 RenderLayer* currLayer = includeSelf == IncludeSelf ? &layer : layer.parent();
 3642 EnclosingNodeData result;
 3643
 3644 // FIXME: This does not take transforms into account:
 3645 // - Async scrolling should not be performed when there are non-axis-aligned transforms.
 3646 // - parentRelativeScrollableRect should be resized if there are scale transforms.
36423647 while (currLayer) {
36433648 if (RenderLayerBacking* backing = currLayer->backing()) {
3644  if (ScrollingNodeID nodeID = backing->scrollingNodeIDForChildren())
3645  return nodeID;
 3649 if (ScrollingNodeID nodeID = backing->scrollingNodeIDForChildren()) {
 3650 result.nodeID = nodeID;
 3651 if (RenderBox* box = layer.renderBox()) {
 3652 result.parentRelativeScrollableRect = box->contentBoxRect();
 3653 result.parentRelativeScrollableRect.moveBy(layer.convertToLayerCoords(currLayer, result.parentRelativeScrollableRect.location()));
 3654 }
 3655 return result;
 3656 }
36463657 }
36473658 currLayer = currLayer->parent();
36483659 }
36493660
3650  return 0;
 3661 return result;
36513662}
36523663
3653 static ScrollingNodeID scrollCoordinatedAncestorInParentOfFrame(Frame& frame)
 3664std::optional<RenderLayerCompositor::EnclosingNodeData> RenderLayerCompositor::scrollCoordinatedAncestorInParentOfFrame(Frame& frame)
36543665{
36553666 if (!frame.document() || !frame.view())
3656  return 0;
 3667 return std::nullopt;
36573668
36583669 // Find the frame's enclosing layer in our render tree.
36593670 HTMLFrameOwnerElement* ownerElement = frame.document()->ownerElement();
36603671 RenderElement* frameRenderer = ownerElement ? ownerElement->renderer() : nullptr;
36613672 if (!frameRenderer)
3662  return 0;
 3673 return std::nullopt;
36633674
36643675 RenderLayer* layerInParentDocument = frameRenderer->enclosingLayer();
36653676 if (!layerInParentDocument)
3666  return 0;
 3677 return std::nullopt;
36673678
3668  return enclosingScrollingNodeID(*layerInParentDocument, IncludeSelf);
 3679 return findEnclosingScrollingNode(*layerInParentDocument, IncludeSelf);
36693680}
36703681
36713682void RenderLayerCompositor::reattachSubframeScrollLayers()

@@void RenderLayerCompositor::reattachSubframeScrollLayers()
36873698 if (!frameScrollingNodeID)
36883699 continue;
36893700
3690  ScrollingNodeID parentNodeID = scrollCoordinatedAncestorInParentOfFrame(*child);
3691  if (!parentNodeID)
 3701 std::optional<EnclosingNodeData> parentNodeData = scrollCoordinatedAncestorInParentOfFrame(*child);
 3702 if (!parentNodeData)
36923703 continue;
36933704
3694  scrollingCoordinator->attachToStateTree(FrameScrollingNode, frameScrollingNodeID, parentNodeID);
 3705 scrollingCoordinator->attachToStateTree(FrameScrollingNode, frameScrollingNodeID, parentNodeData->nodeID);
36953706 }
36963707}
36973708

@@void RenderLayerCompositor::detachScrollCoordinatedLayer(RenderLayer& layer, Lay
37523763 backing->detachFromScrollingCoordinator(roles);
37533764}
37543765
3755 void RenderLayerCompositor::updateScrollCoordinationForThisFrame(ScrollingNodeID parentNodeID)
 3766ScrollingCoordinator::ScrollingGeometry RenderLayerCompositor::scrollingGeometryFor(const RenderLayer& layer, const EnclosingNodeData& enclosingNodeData)
 3767{
 3768 ScrollingCoordinator::ScrollingGeometry scrollingGeometry;
 3769 scrollingGeometry.parentRelativeScrollableRect = enclosingNodeData.parentRelativeScrollableRect;
 3770 scrollingGeometry.scrollOrigin = layer.scrollOrigin();
 3771 scrollingGeometry.scrollPosition = layer.scrollPosition();
 3772 scrollingGeometry.scrollableAreaSize = layer.visibleSize();
 3773 scrollingGeometry.contentSize = layer.contentsSize();
 3774 scrollingGeometry.reachableContentSize = layer.scrollableContentsSize();
 3775#if ENABLE(CSS_SCROLL_SNAP)
 3776 if (const Vector<LayoutUnit>* offsets = layer.horizontalSnapOffsets())
 3777 scrollingGeometry.horizontalSnapOffsets = *offsets;
 3778 if (const Vector<LayoutUnit>* offsets = layer.verticalSnapOffsets())
 3779 scrollingGeometry.verticalSnapOffsets = *offsets;
 3780 if (const Vector<ScrollOffsetRange<LayoutUnit>>* ranges = layer.horizontalSnapOffsetRanges())
 3781 scrollingGeometry.horizontalSnapOffsetRanges = *ranges;
 3782 if (const Vector<ScrollOffsetRange<LayoutUnit>>* ranges = layer.verticalSnapOffsetRanges())
 3783 scrollingGeometry.verticalSnapOffsetRanges = *ranges;
 3784 scrollingGeometry.currentHorizontalSnapPointIndex = layer.currentHorizontalSnapPointIndex();
 3785 scrollingGeometry.currentVerticalSnapPointIndex = layer.currentVerticalSnapPointIndex();
 3786#endif
 3787 return scrollingGeometry;
 3788}
 3789
 3790void RenderLayerCompositor::updateScrollCoordinationForThisFrame(const EnclosingNodeData& parentNodeData)
37563791{
37573792 ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator();
37583793 ASSERT(scrollingCoordinator->coordinatesScrollingForFrameView(m_renderView.frameView()));
37593794
3760  ScrollingNodeID nodeID = attachScrollingNode(*m_renderView.layer(), FrameScrollingNode, parentNodeID);
3761  scrollingCoordinator->updateFrameScrollingNode(nodeID, m_scrollLayer.get(), m_rootContentLayer.get(), fixedRootBackgroundLayer(), clipLayer());
 3795 ScrollingNodeID nodeID = attachScrollingNode(*m_renderView.layer(), FrameScrollingNode, parentNodeData.nodeID);
 3796 ScrollingCoordinator::ScrollingGeometry scrollingGeometry = scrollingGeometryFor(*m_renderView.layer(), parentNodeData);
 3797 scrollingCoordinator->updateFrameScrollingNode(nodeID, m_scrollLayer.get(), m_rootContentLayer.get(), fixedRootBackgroundLayer(), clipLayer(), parentNodeData.nodeID ? &scrollingGeometry : nullptr);
37623798}
37633799
37643800void RenderLayerCompositor::updateScrollCoordinatedLayer(RenderLayer& layer, LayerScrollCoordinationRoles reasons, OptionSet<ScrollingNodeChangeFlags> changes)

@@void RenderLayerCompositor::updateScrollCoordinatedLayer(RenderLayer& layer, Lay
37803816 return;
37813817
37823818 if (!m_renderView.frame().isMainFrame()) {
3783  ScrollingNodeID parentDocumentHostingNodeID = scrollCoordinatedAncestorInParentOfFrame(m_renderView.frame());
3784  if (!parentDocumentHostingNodeID)
 3819 std::optional<EnclosingNodeData> parentDocumentHostingNodeData = scrollCoordinatedAncestorInParentOfFrame(m_renderView.frame());
 3820 if (!parentDocumentHostingNodeData)
37853821 return;
37863822
3787  updateScrollCoordinationForThisFrame(parentDocumentHostingNodeID);
 3823 updateScrollCoordinationForThisFrame(*parentDocumentHostingNodeData);
37883824 if (!(reasons & ViewportConstrained) && isRenderViewLayer)
37893825 return;
37903826 }
37913827
3792  ScrollingNodeID parentNodeID = enclosingScrollingNodeID(layer, ExcludeSelf);
3793  if (!parentNodeID && !isRenderViewLayer)
 3828 EnclosingNodeData parentNodeData = findEnclosingScrollingNode(layer, ExcludeSelf);
 3829 if (!parentNodeData.nodeID && !isRenderViewLayer)
37943830 return;
37953831
37963832 // Always call this even if the backing is already attached because the parent may have changed.

@@void RenderLayerCompositor::updateScrollCoordinatedLayer(RenderLayer& layer, Lay
38043840 else
38053841 ASSERT_NOT_REACHED();
38063842
3807  ScrollingNodeID nodeID = attachScrollingNode(layer, nodeType, parentNodeID);
 3843 ScrollingNodeID nodeID = attachScrollingNode(layer, nodeType, parentNodeData.nodeID);
38083844 if (!nodeID)
38093845 return;
38103846
3811  LOG_WITH_STREAM(Compositing, stream << "Registering ViewportConstrained " << nodeType << " node " << nodeID << " (layer " << backing->graphicsLayer()->primaryLayerID() << ") as child of " << parentNodeID);
 3847 LOG_WITH_STREAM(Compositing, stream << "Registering ViewportConstrained " << nodeType << " node " << nodeID << " (layer " << backing->graphicsLayer()->primaryLayerID() << ") as child of " << parentNodeData.nodeID);
38123848
38133849 if (changes.contains(ScrollingNodeChangeFlags::Layer))
38143850 scrollingCoordinator->updateNodeLayer(nodeID, backing->graphicsLayer());

@@void RenderLayerCompositor::updateScrollCoordinatedLayer(RenderLayer& layer, Lay
38273863 }
38283864 }
38293865
3830  parentNodeID = nodeID;
 3866 parentNodeData.nodeID = nodeID;
38313867 } else
38323868 detachScrollCoordinatedLayer(layer, ViewportConstrained);
38333869
38343870 if (reasons & Scrolling) {
38353871 if (isRenderViewLayer)
3836  updateScrollCoordinationForThisFrame(parentNodeID);
 3872 updateScrollCoordinationForThisFrame(parentNodeData);
38373873 else {
38383874 ScrollingNodeType nodeType = OverflowScrollingNode;
3839  ScrollingNodeID nodeID = attachScrollingNode(layer, nodeType, parentNodeID);
 3875 ScrollingNodeID nodeID = attachScrollingNode(layer, nodeType, parentNodeData.nodeID);
38403876 if (!nodeID)
38413877 return;
38423878
3843  ScrollingCoordinator::ScrollingGeometry scrollingGeometry;
3844  scrollingGeometry.scrollOrigin = layer.scrollOrigin();
3845  scrollingGeometry.scrollPosition = layer.scrollPosition();
3846  scrollingGeometry.scrollableAreaSize = layer.visibleSize();
3847  scrollingGeometry.contentSize = layer.contentsSize();
3848  scrollingGeometry.reachableContentSize = layer.scrollableContentsSize();
3849 #if ENABLE(CSS_SCROLL_SNAP)
3850  if (const Vector<LayoutUnit>* offsets = layer.horizontalSnapOffsets())
3851  scrollingGeometry.horizontalSnapOffsets = *offsets;
3852  if (const Vector<LayoutUnit>* offsets = layer.verticalSnapOffsets())
3853  scrollingGeometry.verticalSnapOffsets = *offsets;
3854  if (const Vector<ScrollOffsetRange<LayoutUnit>>* ranges = layer.horizontalSnapOffsetRanges())
3855  scrollingGeometry.horizontalSnapOffsetRanges = *ranges;
3856  if (const Vector<ScrollOffsetRange<LayoutUnit>>* ranges = layer.verticalSnapOffsetRanges())
3857  scrollingGeometry.verticalSnapOffsetRanges = *ranges;
3858  scrollingGeometry.currentHorizontalSnapPointIndex = layer.currentHorizontalSnapPointIndex();
3859  scrollingGeometry.currentVerticalSnapPointIndex = layer.currentVerticalSnapPointIndex();
3860 #endif
 3879 ScrollingCoordinator::ScrollingGeometry scrollingGeometry = scrollingGeometryFor(layer, parentNodeData);
38613880
3862  LOG(Compositing, "Registering Scrolling scrolling node %" PRIu64 " (layer %" PRIu64 ") as child of %" PRIu64, nodeID, backing->graphicsLayer()->primaryLayerID(), parentNodeID);
 3881 LOG(Compositing, "Registering Scrolling scrolling node %" PRIu64 " (layer %" PRIu64 ") as child of %" PRIu64, nodeID, backing->graphicsLayer()->primaryLayerID(), parentNodeData.nodeID);
38633882
38643883 scrollingCoordinator->updateOverflowScrollingNode(nodeID, backing->scrollingLayer(), backing->scrollingContentsLayer(), &scrollingGeometry);
38653884 }

Source/WebCore/rendering/RenderLayerCompositor.h

2929#include "GraphicsLayerClient.h"
3030#include "GraphicsLayerUpdater.h"
3131#include "RenderLayer.h"
 32#include "ScrollingCoordinator.h"
3233#include <wtf/HashMap.h>
3334#include <wtf/OptionSet.h>
 35#include <wtf/Optional.h>
3436
3537namespace WebCore {
3638

@@class GraphicsLayerUpdater;
4042class RenderEmbeddedObject;
4143class RenderVideo;
4244class RenderWidget;
43 class ScrollingCoordinator;
4445class StickyPositionViewportConstraints;
4546class TiledBacking;
4647

@@private:
435436 void updateCustomLayersAfterFlush();
436437#endif
437438
438  void updateScrollCoordinationForThisFrame(ScrollingNodeID);
 439 struct EnclosingNodeData {
 440 ScrollingNodeID nodeID { 0 };
 441 LayoutRect parentRelativeScrollableRect;
 442 };
 443 EnclosingNodeData findEnclosingScrollingNode(RenderLayer&, IncludeSelfOrNot);
 444 std::optional<EnclosingNodeData> scrollCoordinatedAncestorInParentOfFrame(Frame&);
 445 ScrollingCoordinator::ScrollingGeometry scrollingGeometryFor(const RenderLayer&, const EnclosingNodeData&);
 446 void updateScrollCoordinationForThisFrame(const EnclosingNodeData&);
439447 ScrollingNodeID attachScrollingNode(RenderLayer&, ScrollingNodeType, ScrollingNodeID parentNodeID);
440448 void updateScrollCoordinatedLayer(RenderLayer&, LayerScrollCoordinationRoles, OptionSet<ScrollingNodeChangeFlags>);
441449 void detachScrollCoordinatedLayer(RenderLayer&, LayerScrollCoordinationRoles);