<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[244215] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/244215">244215</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2019-04-12 07:54:12 -0700 (Fri, 12 Apr 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>[iOS WK2] Wrong scrolling behavior for nested absolute position elements inside overflow scroll
https://bugs.webkit.org/show_bug.cgi?id=196146

Reviewed by Antti Koivisto.

Source/WebCore:

computeCoordinatedPositioningForLayer() failed to handle nested positions elements
inside overflow scroll, because it only walked up to the first containing block of
a nested position:absolute. We need to walk all the way up the ancestor layer chain,
looking at containing block, scroller and composited ancestor relationships.

Make this code easier to understand by writing it in terms of "is foo scrolled by bar", rather than
trying to collapse all the logic into a single ancestor walk, which was really hard. This is a few
more ancestor traversals, but we now only run this code if there's composited scrolling
in the ancestor chain.

Tests: scrollingcoordinator/scrolling-tree/nested-absolute-in-absolute-overflow.html
       scrollingcoordinator/scrolling-tree/nested-absolute-in-overflow.html
       scrollingcoordinator/scrolling-tree/nested-absolute-in-relative-in-overflow.html
       scrollingcoordinator/scrolling-tree/nested-absolute-in-sc-overflow.html

* rendering/RenderLayerCompositor.cpp:
(WebCore::enclosingCompositedScrollingLayer):
(WebCore::isScrolledByOverflowScrollLayer):
(WebCore::isNonScrolledLayerInsideScrolledCompositedAncestor):
(WebCore::RenderLayerCompositor::layerContainingBlockCrossesCoordinatedScrollingBoundary):
(WebCore::collectStationaryLayerRelatedOverflowNodes):
(WebCore::RenderLayerCompositor::computeCoordinatedPositioningForLayer const):
(WebCore::collectRelatedCoordinatedScrollingNodes):
(WebCore::layerParentedAcrossCoordinatedScrollingBoundary): Deleted.

LayoutTests:

Dump the scrolling tree for various configurations of positioned, overflow and stacking context
elements.

* fast/scrolling/ios/overflow-scroll-overlap-6-expected.txt: Progressed results.
* platform/ios-wk2/scrollingcoordinator/scrolling-tree/nested-absolute-in-absolute-overflow-expected.txt: Added.
* platform/ios-wk2/scrollingcoordinator/scrolling-tree/nested-absolute-in-overflow-expected.txt: Added.
* platform/ios-wk2/scrollingcoordinator/scrolling-tree/nested-absolute-in-relative-in-overflow-expected.txt: Added.
* platform/ios-wk2/scrollingcoordinator/scrolling-tree/nested-absolute-in-sc-overflow-expected.txt: Added.
* scrollingcoordinator/scrolling-tree/nested-absolute-in-absolute-overflow-expected.txt: Added.
* scrollingcoordinator/scrolling-tree/nested-absolute-in-absolute-overflow.html: Added.
* scrollingcoordinator/scrolling-tree/nested-absolute-in-overflow-expected.txt: Added.
* scrollingcoordinator/scrolling-tree/nested-absolute-in-overflow.html: Added.
* scrollingcoordinator/scrolling-tree/nested-absolute-in-relative-in-overflow-expected.txt: Added.
* scrollingcoordinator/scrolling-tree/nested-absolute-in-relative-in-overflow.html: Added.
* scrollingcoordinator/scrolling-tree/nested-absolute-in-sc-overflow-expected.txt: Added.
* scrollingcoordinator/scrolling-tree/nested-absolute-in-sc-overflow.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastscrollingiosoverflowscrolloverlap6expectedtxt">trunk/LayoutTests/fast/scrolling/ios/overflow-scroll-overlap-6-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayerCompositorcpp">trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsplatformioswk2scrollingcoordinatorscrollingtreenestedabsoluteinabsoluteoverflowexpectedtxt">trunk/LayoutTests/platform/ios-wk2/scrollingcoordinator/scrolling-tree/nested-absolute-in-absolute-overflow-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformioswk2scrollingcoordinatorscrollingtreenestedabsoluteinoverflowexpectedtxt">trunk/LayoutTests/platform/ios-wk2/scrollingcoordinator/scrolling-tree/nested-absolute-in-overflow-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformioswk2scrollingcoordinatorscrollingtreenestedabsoluteinrelativeinoverflowexpectedtxt">trunk/LayoutTests/platform/ios-wk2/scrollingcoordinator/scrolling-tree/nested-absolute-in-relative-in-overflow-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformioswk2scrollingcoordinatorscrollingtreenestedabsoluteinscoverflowexpectedtxt">trunk/LayoutTests/platform/ios-wk2/scrollingcoordinator/scrolling-tree/nested-absolute-in-sc-overflow-expected.txt</a></li>
<li><a href="#trunkLayoutTestsscrollingcoordinatorscrollingtreenestedabsoluteinabsoluteoverflowexpectedtxt">trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-absolute-overflow-expected.txt</a></li>
<li><a href="#trunkLayoutTestsscrollingcoordinatorscrollingtreenestedabsoluteinabsoluteoverflowhtml">trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-absolute-overflow.html</a></li>
<li><a href="#trunkLayoutTestsscrollingcoordinatorscrollingtreenestedabsoluteinoverflowexpectedtxt">trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-overflow-expected.txt</a></li>
<li><a href="#trunkLayoutTestsscrollingcoordinatorscrollingtreenestedabsoluteinoverflowhtml">trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-overflow.html</a></li>
<li><a href="#trunkLayoutTestsscrollingcoordinatorscrollingtreenestedabsoluteinrelativeinoverflowexpectedtxt">trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-relative-in-overflow-expected.txt</a></li>
<li><a href="#trunkLayoutTestsscrollingcoordinatorscrollingtreenestedabsoluteinrelativeinoverflowhtml">trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-relative-in-overflow.html</a></li>
<li><a href="#trunkLayoutTestsscrollingcoordinatorscrollingtreenestedabsoluteinscoverflowexpectedtxt">trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-sc-overflow-expected.txt</a></li>
<li><a href="#trunkLayoutTestsscrollingcoordinatorscrollingtreenestedabsoluteinscoverflowhtml">trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-sc-overflow.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (244214 => 244215)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2019-04-12 13:29:42 UTC (rev 244214)
+++ trunk/LayoutTests/ChangeLog 2019-04-12 14:54:12 UTC (rev 244215)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2019-04-11  Simon Fraser  <simon.fraser@apple.com>
+
+        [iOS WK2] Wrong scrolling behavior for nested absolute position elements inside overflow scroll
+        https://bugs.webkit.org/show_bug.cgi?id=196146
+
+        Reviewed by Antti Koivisto.
+        
+        Dump the scrolling tree for various configurations of positioned, overflow and stacking context
+        elements.
+
+        * fast/scrolling/ios/overflow-scroll-overlap-6-expected.txt: Progressed results.
+        * platform/ios-wk2/scrollingcoordinator/scrolling-tree/nested-absolute-in-absolute-overflow-expected.txt: Added.
+        * platform/ios-wk2/scrollingcoordinator/scrolling-tree/nested-absolute-in-overflow-expected.txt: Added.
+        * platform/ios-wk2/scrollingcoordinator/scrolling-tree/nested-absolute-in-relative-in-overflow-expected.txt: Added.
+        * platform/ios-wk2/scrollingcoordinator/scrolling-tree/nested-absolute-in-sc-overflow-expected.txt: Added.
+        * scrollingcoordinator/scrolling-tree/nested-absolute-in-absolute-overflow-expected.txt: Added.
+        * scrollingcoordinator/scrolling-tree/nested-absolute-in-absolute-overflow.html: Added.
+        * scrollingcoordinator/scrolling-tree/nested-absolute-in-overflow-expected.txt: Added.
+        * scrollingcoordinator/scrolling-tree/nested-absolute-in-overflow.html: Added.
+        * scrollingcoordinator/scrolling-tree/nested-absolute-in-relative-in-overflow-expected.txt: Added.
+        * scrollingcoordinator/scrolling-tree/nested-absolute-in-relative-in-overflow.html: Added.
+        * scrollingcoordinator/scrolling-tree/nested-absolute-in-sc-overflow-expected.txt: Added.
+        * scrollingcoordinator/scrolling-tree/nested-absolute-in-sc-overflow.html: Added.
+
</ins><span class="cx"> 2019-04-12  Manuel Rego Casasnovas  <rego@igalia.com>
</span><span class="cx"> 
</span><span class="cx">         [css-flex][css-grid] Fix synthesized baseline
</span></span></pre></div>
<a id="trunkLayoutTestsfastscrollingiosoverflowscrolloverlap6expectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/scrolling/ios/overflow-scroll-overlap-6-expected.txt (244214 => 244215)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/scrolling/ios/overflow-scroll-overlap-6-expected.txt      2019-04-12 13:29:42 UTC (rev 244214)
+++ trunk/LayoutTests/fast/scrolling/ios/overflow-scroll-overlap-6-expected.txt 2019-04-12 14:54:12 UTC (rev 244215)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> Test that absolute positioned layer inside stacking-context overflow:scroll is correctly hit tested.
</span><span class="cx"> 
</span><span class="cx"> case 1: 
</span><del>-case 2: Scrollable 2 
-case 3: Scrollable 3 
</del><ins>+case 2: 
+case 3: 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsplatformioswk2scrollingcoordinatorscrollingtreenestedabsoluteinabsoluteoverflowexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/ios-wk2/scrollingcoordinator/scrolling-tree/nested-absolute-in-absolute-overflow-expected.txt (0 => 244215)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-wk2/scrollingcoordinator/scrolling-tree/nested-absolute-in-absolute-overflow-expected.txt                         (rev 0)
+++ trunk/LayoutTests/platform/ios-wk2/scrollingcoordinator/scrolling-tree/nested-absolute-in-absolute-overflow-expected.txt    2019-04-12 14:54:12 UTC (rev 244215)
</span><span class="lines">@@ -0,0 +1,43 @@
</span><ins>+absabs
+
+(Frame scrolling node
+  (scrollable area size 800 600)
+  (contents size 800 600)
+  (parent relative scrollable rect at (0,0) size 800x600)
+  (scrollable area parameters 
+    (horizontal scroll elasticity 1)
+    (vertical scroll elasticity 1)
+    (horizontal scrollbar mode 0)
+    (vertical scrollbar mode 0))
+  (layout viewport at (0,0) size 800x600)
+  (min layout viewport origin (0,0))
+  (max layout viewport origin (0,0))
+  (behavior for fixed 0)
+  (children 3
+    (Overflow scrolling node
+      (scrollable area size 300 300)
+      (contents size 381 500)
+      (parent relative scrollable rect at (30,35) size 300x300)
+      (scrollable area parameters 
+        (horizontal scroll elasticity 1)
+        (vertical scroll elasticity 1)
+        (horizontal scrollbar mode 0)
+        (vertical scrollbar mode 0)
+        (has enabled horizontal scrollbar 1)
+        (has enabled vertical scrollbar 1))
+    )
+    (Positioned node
+      (layout constraints 
+        (layer-position-at-last-layout (50,50))
+        (positioning-behavior moves))
+      (related overflow nodes 1)
+    )
+    (Positioned node
+      (layout constraints 
+        (layer-position-at-last-layout (77,77))
+        (positioning-behavior moves))
+      (related overflow nodes 1)
+    )
+  )
+)
+
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformioswk2scrollingcoordinatorscrollingtreenestedabsoluteinoverflowexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/ios-wk2/scrollingcoordinator/scrolling-tree/nested-absolute-in-overflow-expected.txt (0 => 244215)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-wk2/scrollingcoordinator/scrolling-tree/nested-absolute-in-overflow-expected.txt                          (rev 0)
+++ trunk/LayoutTests/platform/ios-wk2/scrollingcoordinator/scrolling-tree/nested-absolute-in-overflow-expected.txt     2019-04-12 14:54:12 UTC (rev 244215)
</span><span class="lines">@@ -0,0 +1,30 @@
</span><ins>+absabs
+
+(Frame scrolling node
+  (scrollable area size 800 600)
+  (contents size 800 600)
+  (parent relative scrollable rect at (0,0) size 800x600)
+  (scrollable area parameters 
+    (horizontal scroll elasticity 1)
+    (vertical scroll elasticity 1)
+    (horizontal scrollbar mode 0)
+    (vertical scrollbar mode 0))
+  (layout viewport at (0,0) size 800x600)
+  (min layout viewport origin (0,0))
+  (max layout viewport origin (0,0))
+  (behavior for fixed 0)
+  (children 1
+    (Overflow scrolling node
+      (scrollable area size 300 300)
+      (contents size 300 500)
+      (parent relative scrollable rect at (30,22) size 300x300)
+      (scrollable area parameters 
+        (horizontal scroll elasticity 1)
+        (vertical scroll elasticity 1)
+        (horizontal scrollbar mode 0)
+        (vertical scrollbar mode 0)
+        (has enabled vertical scrollbar 1))
+    )
+  )
+)
+
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformioswk2scrollingcoordinatorscrollingtreenestedabsoluteinrelativeinoverflowexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/ios-wk2/scrollingcoordinator/scrolling-tree/nested-absolute-in-relative-in-overflow-expected.txt (0 => 244215)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-wk2/scrollingcoordinator/scrolling-tree/nested-absolute-in-relative-in-overflow-expected.txt                              (rev 0)
+++ trunk/LayoutTests/platform/ios-wk2/scrollingcoordinator/scrolling-tree/nested-absolute-in-relative-in-overflow-expected.txt 2019-04-12 14:54:12 UTC (rev 244215)
</span><span class="lines">@@ -0,0 +1,48 @@
</span><ins>+absabs
+
+(Frame scrolling node
+  (scrollable area size 800 600)
+  (contents size 800 600)
+  (parent relative scrollable rect at (0,0) size 800x600)
+  (scrollable area parameters 
+    (horizontal scroll elasticity 1)
+    (vertical scroll elasticity 1)
+    (horizontal scrollbar mode 0)
+    (vertical scrollbar mode 0))
+  (layout viewport at (0,0) size 800x600)
+  (min layout viewport origin (0,0))
+  (max layout viewport origin (0,0))
+  (behavior for fixed 0)
+  (children 4
+    (Overflow scrolling node
+      (scrollable area size 300 300)
+      (contents size 300 526)
+      (parent relative scrollable rect at (30,22) size 300x300)
+      (scrollable area parameters 
+        (horizontal scroll elasticity 1)
+        (vertical scroll elasticity 1)
+        (horizontal scrollbar mode 0)
+        (vertical scrollbar mode 0)
+        (has enabled vertical scrollbar 1))
+    )
+    (Positioned node
+      (layout constraints 
+        (layer-position-at-last-layout (0,0))
+        (positioning-behavior moves))
+      (related overflow nodes 1)
+    )
+    (Positioned node
+      (layout constraints 
+        (layer-position-at-last-layout (53,53))
+        (positioning-behavior moves))
+      (related overflow nodes 1)
+    )
+    (Positioned node
+      (layout constraints 
+        (layer-position-at-last-layout (80,80))
+        (positioning-behavior moves))
+      (related overflow nodes 1)
+    )
+  )
+)
+
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformioswk2scrollingcoordinatorscrollingtreenestedabsoluteinscoverflowexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/ios-wk2/scrollingcoordinator/scrolling-tree/nested-absolute-in-sc-overflow-expected.txt (0 => 244215)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-wk2/scrollingcoordinator/scrolling-tree/nested-absolute-in-sc-overflow-expected.txt                               (rev 0)
+++ trunk/LayoutTests/platform/ios-wk2/scrollingcoordinator/scrolling-tree/nested-absolute-in-sc-overflow-expected.txt  2019-04-12 14:54:12 UTC (rev 244215)
</span><span class="lines">@@ -0,0 +1,44 @@
</span><ins>+absabs
+
+(Frame scrolling node
+  (scrollable area size 800 600)
+  (contents size 800 600)
+  (parent relative scrollable rect at (0,0) size 800x600)
+  (scrollable area parameters 
+    (horizontal scroll elasticity 1)
+    (vertical scroll elasticity 1)
+    (horizontal scrollbar mode 0)
+    (vertical scrollbar mode 0))
+  (layout viewport at (0,0) size 800x600)
+  (min layout viewport origin (0,0))
+  (max layout viewport origin (0,0))
+  (behavior for fixed 0)
+  (children 1
+    (Overflow scrolling node
+      (scrollable area size 300 300)
+      (contents size 300 500)
+      (parent relative scrollable rect at (30,22) size 300x300)
+      (scrollable area parameters 
+        (horizontal scroll elasticity 1)
+        (vertical scroll elasticity 1)
+        (horizontal scrollbar mode 0)
+        (vertical scrollbar mode 0)
+        (has enabled vertical scrollbar 1))
+      (children 2
+        (Positioned node
+          (layout constraints 
+            (layer-position-at-last-layout (20,28))
+            (positioning-behavior stationary))
+          (related overflow nodes 1)
+        )
+        (Positioned node
+          (layout constraints 
+            (layer-position-at-last-layout (47,55))
+            (positioning-behavior stationary))
+          (related overflow nodes 1)
+        )
+      )
+    )
+  )
+)
+
</ins></span></pre></div>
<a id="trunkLayoutTestsscrollingcoordinatorscrollingtreenestedabsoluteinabsoluteoverflowexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-absolute-overflow-expected.txt (0 => 244215)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-absolute-overflow-expected.txt                          (rev 0)
+++ trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-absolute-overflow-expected.txt     2019-04-12 14:54:12 UTC (rev 244215)
</span><span class="lines">@@ -0,0 +1,43 @@
</span><ins>+absabs
+
+(Frame scrolling node
+  (scrollable area size 800 600)
+  (contents size 800 600)
+  (parent relative scrollable rect at (0,0) size 800x600)
+  (scrollable area parameters 
+    (horizontal scroll elasticity 2)
+    (vertical scroll elasticity 2)
+    (horizontal scrollbar mode 0)
+    (vertical scrollbar mode 0))
+  (layout viewport at (0,0) size 800x600)
+  (min layout viewport origin (0,0))
+  (max layout viewport origin (0,0))
+  (behavior for fixed 0)
+  (children 3
+    (Overflow scrolling node
+      (scrollable area size 285 285)
+      (contents size 381 500)
+      (parent relative scrollable rect at (30,35) size 285x285)
+      (scrollable area parameters 
+        (horizontal scroll elasticity 0)
+        (vertical scroll elasticity 0)
+        (horizontal scrollbar mode 0)
+        (vertical scrollbar mode 0)
+        (has enabled horizontal scrollbar 1)
+        (has enabled vertical scrollbar 1))
+    )
+    (Positioned node
+      (layout constraints 
+        (layer-position-at-last-layout (50,50))
+        (positioning-behavior moves))
+      (related overflow nodes 1)
+    )
+    (Positioned node
+      (layout constraints 
+        (layer-position-at-last-layout (77,77))
+        (positioning-behavior moves))
+      (related overflow nodes 1)
+    )
+  )
+)
+
</ins></span></pre></div>
<a id="trunkLayoutTestsscrollingcoordinatorscrollingtreenestedabsoluteinabsoluteoverflowhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-absolute-overflow.html (0 => 244215)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-absolute-overflow.html                          (rev 0)
+++ trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-absolute-overflow.html     2019-04-12 14:54:12 UTC (rev 244215)
</span><span class="lines">@@ -0,0 +1,58 @@
</span><ins>+<!DOCTYPE html> <!-- webkit-test-runner [ internal:AsyncOverflowScrollingEnabled=true ] -->
+<html>
+<head>
+    <title>Nested absolutes move with the overflow but are not stacking descendants: need two 'move' nodes</title>
+    <style>
+        .scrollcontent {
+            height: 500px;
+        }
+        .scroller {
+            position:absolute;
+            margin: 20px;
+            overflow: scroll;
+            height: 300px;
+            width: 300px;
+            border: 2px solid black;
+        }
+    
+        .absolute {
+            position:absolute;
+            left: 50px;
+            top: 50px;
+            width: 100px;
+            height: 100px;
+            background: gray;
+            border: 2px solid green;
+        }
+    
+        .inner {
+            left:25px;
+            top:25px;
+            width: 300px;
+        }
+
+        .scrollcontent {
+            height: 500px;
+            background-image: repeating-linear-gradient(white, silver 200px);
+        }
+    </style>
+    <script>
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        window.addEventListener('load', () => {
+            if (window.internals)
+                document.getElementById('tree').innerText = internals.scrollingStateTreeAsText();
+        }, false);
+    </script>
+</head>
+<body>
+    <div class="scroller">
+        <div class="absolute">abs
+            <div class="inner absolute">abs</div>
+        </div>
+        <div class="scrollcontent"></div>
+    </div>
+<pre id="tree"></pre>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsscrollingcoordinatorscrollingtreenestedabsoluteinoverflowexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-overflow-expected.txt (0 => 244215)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-overflow-expected.txt                           (rev 0)
+++ trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-overflow-expected.txt      2019-04-12 14:54:12 UTC (rev 244215)
</span><span class="lines">@@ -0,0 +1,30 @@
</span><ins>+absabs
+
+(Frame scrolling node
+  (scrollable area size 800 600)
+  (contents size 800 600)
+  (parent relative scrollable rect at (0,0) size 800x600)
+  (scrollable area parameters 
+    (horizontal scroll elasticity 2)
+    (vertical scroll elasticity 2)
+    (horizontal scrollbar mode 0)
+    (vertical scrollbar mode 0))
+  (layout viewport at (0,0) size 800x600)
+  (min layout viewport origin (0,0))
+  (max layout viewport origin (0,0))
+  (behavior for fixed 0)
+  (children 1
+    (Overflow scrolling node
+      (scrollable area size 285 285)
+      (contents size 285 500)
+      (parent relative scrollable rect at (30,22) size 285x285)
+      (scrollable area parameters 
+        (horizontal scroll elasticity 0)
+        (vertical scroll elasticity 0)
+        (horizontal scrollbar mode 0)
+        (vertical scrollbar mode 0)
+        (has enabled vertical scrollbar 1))
+    )
+  )
+)
+
</ins></span></pre></div>
<a id="trunkLayoutTestsscrollingcoordinatorscrollingtreenestedabsoluteinoverflowhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-overflow.html (0 => 244215)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-overflow.html                           (rev 0)
+++ trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-overflow.html      2019-04-12 14:54:12 UTC (rev 244215)
</span><span class="lines">@@ -0,0 +1,57 @@
</span><ins>+<!DOCTYPE html> <!-- webkit-test-runner [ internal:AsyncOverflowScrollingEnabled=true ] -->
+<html>
+<head>
+    <title>Nested absolutes don't with the overflow and are not stacking descendants: there should be no positioning nodes</title>
+    <style>
+        .scrollcontent {
+            height: 500px;
+        }
+        .scroller {
+            margin: 20px;
+            overflow: scroll;
+            height: 300px;
+            width: 300px;
+            border: 2px solid black;
+        }
+    
+        .absolute {
+            position:absolute;
+            left: 50px;
+            top: 50px;
+            width: 100px;
+            height: 100px;
+            background: gray;
+            border: 2px solid green;
+        }
+    
+        .inner {
+            left:25px;
+            top:25px;
+            width: 300px;
+        }
+
+        .scrollcontent {
+            height: 500px;
+            background-image: repeating-linear-gradient(white, silver 200px);
+        }
+    </style>
+    <script>
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        window.addEventListener('load', () => {
+            if (window.internals)
+                document.getElementById('tree').innerText = internals.scrollingStateTreeAsText();
+        }, false);
+    </script>
+</head>
+<body>
+    <div class="scroller">
+        <div class="absolute">abs
+            <div class="inner absolute">abs</div>
+        </div>
+        <div class="scrollcontent"></div>
+    </div>
+<pre id="tree"></pre>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsscrollingcoordinatorscrollingtreenestedabsoluteinrelativeinoverflowexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-relative-in-overflow-expected.txt (0 => 244215)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-relative-in-overflow-expected.txt                               (rev 0)
+++ trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-relative-in-overflow-expected.txt  2019-04-12 14:54:12 UTC (rev 244215)
</span><span class="lines">@@ -0,0 +1,48 @@
</span><ins>+absabs
+
+(Frame scrolling node
+  (scrollable area size 800 600)
+  (contents size 800 600)
+  (parent relative scrollable rect at (0,0) size 800x600)
+  (scrollable area parameters 
+    (horizontal scroll elasticity 2)
+    (vertical scroll elasticity 2)
+    (horizontal scrollbar mode 0)
+    (vertical scrollbar mode 0))
+  (layout viewport at (0,0) size 800x600)
+  (min layout viewport origin (0,0))
+  (max layout viewport origin (0,0))
+  (behavior for fixed 0)
+  (children 4
+    (Overflow scrolling node
+      (scrollable area size 285 285)
+      (contents size 285 526)
+      (parent relative scrollable rect at (30,22) size 285x285)
+      (scrollable area parameters 
+        (horizontal scroll elasticity 0)
+        (vertical scroll elasticity 0)
+        (horizontal scrollbar mode 0)
+        (vertical scrollbar mode 0)
+        (has enabled vertical scrollbar 1))
+    )
+    (Positioned node
+      (layout constraints 
+        (layer-position-at-last-layout (0,0))
+        (positioning-behavior moves))
+      (related overflow nodes 1)
+    )
+    (Positioned node
+      (layout constraints 
+        (layer-position-at-last-layout (53,53))
+        (positioning-behavior moves))
+      (related overflow nodes 1)
+    )
+    (Positioned node
+      (layout constraints 
+        (layer-position-at-last-layout (80,80))
+        (positioning-behavior moves))
+      (related overflow nodes 1)
+    )
+  )
+)
+
</ins></span></pre></div>
<a id="trunkLayoutTestsscrollingcoordinatorscrollingtreenestedabsoluteinrelativeinoverflowhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-relative-in-overflow.html (0 => 244215)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-relative-in-overflow.html                               (rev 0)
+++ trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-relative-in-overflow.html  2019-04-12 14:54:12 UTC (rev 244215)
</span><span class="lines">@@ -0,0 +1,66 @@
</span><ins>+<!DOCTYPE html> <!-- webkit-test-runner [ internal:AsyncOverflowScrollingEnabled=true ] -->
+<html>
+<head>
+    <title>Absolutes in relative in overflow move with it but are not stacking descendants: need 3 'move' nodes</title>
+    <style>
+        .scrollcontent {
+            height: 500px;
+        }
+        .scroller {
+            margin: 20px;
+            overflow: scroll;
+            height: 300px;
+            width: 300px;
+            border: 2px solid black;
+        }
+    
+        .relative {
+            position: relative;
+            border: 3px solid orange;
+            height: 20px;
+        }
+
+        .absolute {
+            position:absolute;
+            left: 50px;
+            top: 50px;
+            width: 100px;
+            height: 100px;
+            background: gray;
+            border: 2px solid green;
+        }
+    
+        .inner {
+            left:25px;
+            top:25px;
+            width: 200px;
+        }
+
+        .scrollcontent {
+            height: 500px;
+            background-image: repeating-linear-gradient(white, silver 200px);
+        }
+    </style>
+    <script>
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        window.addEventListener('load', () => {
+            if (window.internals)
+                document.getElementById('tree').innerText = internals.scrollingStateTreeAsText();
+        }, false);
+    </script>
+</head>
+<body>
+
+    <div class="scroller">
+        <div class="relative">
+            <div class="absolute">abs
+                <div class="inner absolute">abs</div>
+            </div>
+        </div>
+        <div class="scrollcontent"></div>
+    </div>
+<pre id="tree"></pre>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsscrollingcoordinatorscrollingtreenestedabsoluteinscoverflowexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-sc-overflow-expected.txt (0 => 244215)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-sc-overflow-expected.txt                                (rev 0)
+++ trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-sc-overflow-expected.txt   2019-04-12 14:54:12 UTC (rev 244215)
</span><span class="lines">@@ -0,0 +1,44 @@
</span><ins>+absabs
+
+(Frame scrolling node
+  (scrollable area size 800 600)
+  (contents size 800 600)
+  (parent relative scrollable rect at (0,0) size 800x600)
+  (scrollable area parameters 
+    (horizontal scroll elasticity 2)
+    (vertical scroll elasticity 2)
+    (horizontal scrollbar mode 0)
+    (vertical scrollbar mode 0))
+  (layout viewport at (0,0) size 800x600)
+  (min layout viewport origin (0,0))
+  (max layout viewport origin (0,0))
+  (behavior for fixed 0)
+  (children 1
+    (Overflow scrolling node
+      (scrollable area size 285 285)
+      (contents size 285 500)
+      (parent relative scrollable rect at (30,22) size 285x285)
+      (scrollable area parameters 
+        (horizontal scroll elasticity 0)
+        (vertical scroll elasticity 0)
+        (horizontal scrollbar mode 0)
+        (vertical scrollbar mode 0)
+        (has enabled vertical scrollbar 1))
+      (children 2
+        (Positioned node
+          (layout constraints 
+            (layer-position-at-last-layout (20,28))
+            (positioning-behavior stationary))
+          (related overflow nodes 1)
+        )
+        (Positioned node
+          (layout constraints 
+            (layer-position-at-last-layout (47,55))
+            (positioning-behavior stationary))
+          (related overflow nodes 1)
+        )
+      )
+    )
+  )
+)
+
</ins></span></pre></div>
<a id="trunkLayoutTestsscrollingcoordinatorscrollingtreenestedabsoluteinscoverflowhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-sc-overflow.html (0 => 244215)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-sc-overflow.html                                (rev 0)
+++ trunk/LayoutTests/scrollingcoordinator/scrolling-tree/nested-absolute-in-sc-overflow.html   2019-04-12 14:54:12 UTC (rev 244215)
</span><span class="lines">@@ -0,0 +1,58 @@
</span><ins>+<!DOCTYPE html> <!-- webkit-test-runner [ internal:AsyncOverflowScrollingEnabled=true ] -->
+<html>
+<head>
+    <title>Nested absolutes in stacking-context overflow: need two 'stationary' nodes</title>
+    <style>
+        .scrollcontent {
+            height: 500px;
+        }
+        .scroller {
+            margin: 20px;
+            overflow: scroll;
+            height: 300px;
+            width: 300px;
+            border: 2px solid black;
+            opacity: 0.9;
+        }
+
+        .absolute {
+            position:absolute;
+            left: 50px;
+            top: 50px;
+            width: 100px;
+            height: 100px;
+            background: gray;
+            border: 2px solid green;
+        }
+    
+        .inner {
+            left: 25px;
+            top: 25px;
+            width: 200px;
+        }
+
+        .scrollcontent {
+            height: 500px;
+            background-image: repeating-linear-gradient(white, silver 200px);
+        }
+    </style>
+    <script>
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        window.addEventListener('load', () => {
+            if (window.internals)
+                document.getElementById('tree').innerText = internals.scrollingStateTreeAsText();
+        }, false);
+    </script>
+</head>
+<body>
+    <div class="scroller">
+        <div class="absolute">abs
+            <div class="inner absolute">abs</div>
+        </div>
+        <div class="scrollcontent"></div>
+    </div>
+<pre id="tree"></pre>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (244214 => 244215)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2019-04-12 13:29:42 UTC (rev 244214)
+++ trunk/Source/WebCore/ChangeLog      2019-04-12 14:54:12 UTC (rev 244215)
</span><span class="lines">@@ -1,3 +1,35 @@
</span><ins>+2019-04-11  Simon Fraser  <simon.fraser@apple.com>
+
+        [iOS WK2] Wrong scrolling behavior for nested absolute position elements inside overflow scroll
+        https://bugs.webkit.org/show_bug.cgi?id=196146
+
+        Reviewed by Antti Koivisto.
+        
+        computeCoordinatedPositioningForLayer() failed to handle nested positions elements
+        inside overflow scroll, because it only walked up to the first containing block of
+        a nested position:absolute. We need to walk all the way up the ancestor layer chain,
+        looking at containing block, scroller and composited ancestor relationships.
+
+        Make this code easier to understand by writing it in terms of "is foo scrolled by bar", rather than
+        trying to collapse all the logic into a single ancestor walk, which was really hard. This is a few
+        more ancestor traversals, but we now only run this code if there's composited scrolling
+        in the ancestor chain.
+
+        Tests: scrollingcoordinator/scrolling-tree/nested-absolute-in-absolute-overflow.html
+               scrollingcoordinator/scrolling-tree/nested-absolute-in-overflow.html
+               scrollingcoordinator/scrolling-tree/nested-absolute-in-relative-in-overflow.html
+               scrollingcoordinator/scrolling-tree/nested-absolute-in-sc-overflow.html
+
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::enclosingCompositedScrollingLayer):
+        (WebCore::isScrolledByOverflowScrollLayer):
+        (WebCore::isNonScrolledLayerInsideScrolledCompositedAncestor):
+        (WebCore::RenderLayerCompositor::layerContainingBlockCrossesCoordinatedScrollingBoundary):
+        (WebCore::collectStationaryLayerRelatedOverflowNodes):
+        (WebCore::RenderLayerCompositor::computeCoordinatedPositioningForLayer const):
+        (WebCore::collectRelatedCoordinatedScrollingNodes):
+        (WebCore::layerParentedAcrossCoordinatedScrollingBoundary): Deleted.
+
</ins><span class="cx"> 2019-04-12  Manuel Rego Casasnovas  <rego@igalia.com>
</span><span class="cx"> 
</span><span class="cx">         [css-flex][css-grid] Fix synthesized baseline
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerCompositorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (244214 => 244215)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2019-04-12 13:29:42 UTC (rev 244214)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp    2019-04-12 14:54:12 UTC (rev 244215)
</span><span class="lines">@@ -2904,42 +2904,97 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// Is this layer's containingBlock an ancestor of scrollable overflow, and is the layer's compositing ancestor inside that overflow?
-bool RenderLayerCompositor::layerContainingBlockCrossesCoordinatedScrollingBoundary(const RenderLayer& layer, const RenderLayer& compositedAncestor)
</del><ins>+static RenderLayer* enclosingCompositedScrollingLayer(const RenderLayer& layer, const RenderLayer& intermediateLayer, bool& sawIntermediateLayer)
</ins><span class="cx"> {
</span><del>-    ASSERT(layer.renderer().isAbsolutelyPositioned());
</del><ins>+    const auto* currLayer = &layer;
+    while (currLayer) {
+        if (currLayer == &intermediateLayer)
+            sawIntermediateLayer = true;
</ins><span class="cx"> 
</span><del>-    bool sawCompositingAncestor = false;
</del><ins>+        if (currLayer->hasCompositedScrollableOverflow())
+            return const_cast<RenderLayer*>(currLayer);
+
+        currLayer = currLayer->parent();
+    }
+
+    return nullptr;
+}
+
+// Return true if overflowScrollLayer is in layer's containing block chain.
+static bool isScrolledByOverflowScrollLayer(const RenderLayer& layer, const RenderLayer& overflowScrollLayer)
+{
+    bool containingBlockCanSkipLayers = layer.renderer().isAbsolutelyPositioned();
+
</ins><span class="cx">     for (const auto* currLayer = layer.parent(); currLayer; currLayer = currLayer->parent()) {
</span><del>-        if (currLayer->renderer().canContainAbsolutelyPositionedObjects())
-            return false;
</del><ins>+        bool inContainingBlockChain = true;
+        if (containingBlockCanSkipLayers) {
+            inContainingBlockChain = currLayer->renderer().canContainAbsolutelyPositionedObjects();
+            if (inContainingBlockChain)
+                containingBlockCanSkipLayers = currLayer->renderer().isAbsolutelyPositioned();
+        }
</ins><span class="cx"> 
</span><del>-        if (currLayer == &compositedAncestor)
-            sawCompositingAncestor = true;
-
-        if (currLayer->hasCompositedScrollableOverflow())
-            return sawCompositingAncestor;
</del><ins>+        if (currLayer == &overflowScrollLayer)
+            return inContainingBlockChain;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// Is there scrollable overflow between this layer and its composited ancestor, and the containing block is the scroller or inside the scroller.
-static bool layerParentedAcrossCoordinatedScrollingBoundary(const RenderLayer& layer, const RenderLayer& compositedAncestor, bool checkContainingBlock, bool& containingBlockIsInsideOverflow)
</del><ins>+static bool isNonScrolledLayerInsideScrolledCompositedAncestor(const RenderLayer& layer, const RenderLayer& compositedAncestor, const RenderLayer& scrollingAncestor)
</ins><span class="cx"> {
</span><del>-    ASSERT(layer.isComposited());
</del><ins>+    bool ancestorMovedByScroller = &compositedAncestor == &scrollingAncestor || isScrolledByOverflowScrollLayer(compositedAncestor, scrollingAncestor);
+    bool layerMovedByScroller = isScrolledByOverflowScrollLayer(layer, scrollingAncestor);
</ins><span class="cx"> 
</span><del>-    for (const auto* currLayer = layer.parent(); currLayer != &compositedAncestor; currLayer = currLayer->parent()) {
-        if (checkContainingBlock && currLayer->renderer().canContainAbsolutelyPositionedObjects())
-            containingBlockIsInsideOverflow = true;
</del><ins>+    return ancestorMovedByScroller && !layerMovedByScroller;
+}
</ins><span class="cx"> 
</span><del>-        if (currLayer->hasCompositedScrollableOverflow())
-            return true;
</del><ins>+bool RenderLayerCompositor::layerContainingBlockCrossesCoordinatedScrollingBoundary(const RenderLayer& layer, const RenderLayer& compositedAncestor)
+{
+    bool compositedAncestorIsInsideScroller = false;
+    auto* scrollingAncestor = enclosingCompositedScrollingLayer(layer, compositedAncestor, compositedAncestorIsInsideScroller);
+    if (!scrollingAncestor) {
+        ASSERT_NOT_REACHED(); // layer.hasCompositedScrollingAncestor() should guarantee we have one.
+        return false;
</ins><span class="cx">     }
</span><ins>+    
+    if (!compositedAncestorIsInsideScroller)
+        return false;
</ins><span class="cx"> 
</span><del>-    return false;
</del><ins>+    return isNonScrolledLayerInsideScrolledCompositedAncestor(layer, compositedAncestor, *scrollingAncestor);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static void collectStationaryLayerRelatedOverflowNodes(const RenderLayer& layer, const RenderLayer& /*compositedAncestor*/, Vector<ScrollingNodeID>& scrollingNodes)
+{
+    ASSERT(layer.isComposited());
+    
+    auto appendOverflowLayerNodeID = [&scrollingNodes] (const RenderLayer& overflowLayer) {
+        ASSERT(overflowLayer.isComposited());
+        auto scrollingNodeID = overflowLayer.backing()->scrollingNodeIDForRole(ScrollCoordinationRole::Scrolling);
+        if (scrollingNodeID)
+            scrollingNodes.append(scrollingNodeID);
+        else
+            LOG(Scrolling, "Layer %p doesn't have scrolling node ID yet", &overflowLayer);
+    };
+
+    ASSERT(layer.renderer().isAbsolutelyPositioned());
+    bool containingBlockCanSkipLayers = true;
+
+    for (const auto* currLayer = layer.parent(); currLayer; currLayer = currLayer->parent()) {
+        bool inContainingBlockChain = true;
+        if (containingBlockCanSkipLayers) {
+            inContainingBlockChain = currLayer->renderer().canContainAbsolutelyPositionedObjects();
+            if (inContainingBlockChain)
+                containingBlockCanSkipLayers = currLayer->renderer().isAbsolutelyPositioned();
+        }
+
+        if (currLayer->hasCompositedScrollableOverflow()) {
+            appendOverflowLayerNodeID(*currLayer);
+            break;
+        }
+    }
+}
+
+
</ins><span class="cx"> ScrollPositioningBehavior RenderLayerCompositor::computeCoordinatedPositioningForLayer(const RenderLayer& layer) const
</span><span class="cx"> {
</span><span class="cx">     if (layer.isRenderViewLayer())
</span><span class="lines">@@ -2955,16 +3010,25 @@
</span><span class="cx">     if (!scrollingCoordinator)
</span><span class="cx">         return ScrollPositioningBehavior::None;
</span><span class="cx"> 
</span><ins>+    auto* compositedAncestor = layer.ancestorCompositingLayer();
+    if (!compositedAncestor) {
+        ASSERT_NOT_REACHED();
+        return ScrollPositioningBehavior::None;
+    }
+
+    bool compositedAncestorIsInsideScroller = false;
+    auto* scrollingAncestor = enclosingCompositedScrollingLayer(layer, *compositedAncestor, compositedAncestorIsInsideScroller);
+    if (!scrollingAncestor) {
+        ASSERT_NOT_REACHED(); // layer.hasCompositedScrollingAncestor() should guarantee we have one.
+        return ScrollPositioningBehavior::None;
+    }
+
</ins><span class="cx">     // There are two cases we have to deal with here:
</span><span class="cx">     // 1. There's a composited overflow:scroll in the parent chain between the renderer and its containing block, and the layer's
</span><span class="cx">     //    composited (z-order) ancestor is inside the scroller or is the scroller. In this case, we have to compensate for scroll position
</span><span class="cx">     //    changes to make the positioned layer stay in the same place. This only applies to position:absolute (since we handle fixed elsewhere).
</span><del>-    auto* compositedAncestor = layer.ancestorCompositingLayer();
-
-    auto& renderer = layer.renderer();
-    bool containingBlockCanSkipOverflow = renderer.isOutOfFlowPositioned() && renderer.style().position() == PositionType::Absolute;
-    if (containingBlockCanSkipOverflow) {
-        if (layerContainingBlockCrossesCoordinatedScrollingBoundary(layer, *compositedAncestor))
</del><ins>+    if (layer.renderer().isAbsolutelyPositioned()) {
+        if (compositedAncestorIsInsideScroller && isNonScrolledLayerInsideScrolledCompositedAncestor(layer, *compositedAncestor, *scrollingAncestor))
</ins><span class="cx">             return ScrollPositioningBehavior::Stationary;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -2971,8 +3035,7 @@
</span><span class="cx">     // 2. The layer's containing block is the overflow or inside the overflow:scroll, but its z-order ancestor is
</span><span class="cx">     //    outside the overflow:scroll. In that case, we have to move the layer via the scrolling tree to make
</span><span class="cx">     //    it move along with the overflow scrolling.
</span><del>-    bool containingBlockIsInsideOverflow = !containingBlockCanSkipOverflow;
-    if (layerParentedAcrossCoordinatedScrollingBoundary(layer, *compositedAncestor, containingBlockCanSkipOverflow, containingBlockIsInsideOverflow) && containingBlockIsInsideOverflow)
</del><ins>+    if (!compositedAncestorIsInsideScroller && isScrolledByOverflowScrollLayer(layer, *scrollingAncestor))
</ins><span class="cx">         return ScrollPositioningBehavior::Moves;
</span><span class="cx"> 
</span><span class="cx">     return ScrollPositioningBehavior::None;
</span><span class="lines">@@ -2998,21 +3061,12 @@
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     case ScrollPositioningBehavior::Stationary: {
</span><del>-        // Collect all the composited scrollers between this layer and its containing block.
-        ASSERT(layer.renderer().style().position() == PositionType::Absolute);
-        for (const auto* currLayer = layer.parent(); currLayer; currLayer = currLayer->parent()) {
-            if (currLayer->renderer().canContainAbsolutelyPositionedObjects())
-                break;
-
-            if (currLayer->hasCompositedScrollableOverflow()) {
-                auto scrollingNodeID = currLayer->backing()->scrollingNodeIDForRole(ScrollCoordinationRole::Scrolling);
-                if (scrollingNodeID)
-                    overflowNodeData.append(scrollingNodeID);
-                else
-                    LOG(Scrolling, "Layer %p doesn't have scrolling node ID yet", &layer);
-            }
-        }
-        // Don't need to do anything because the layer is a descendant of the overflow in stacking.
</del><ins>+        ASSERT(layer.renderer().isAbsolutelyPositioned());
+        // Collect all the composited scrollers between this layer and its composited ancestor.
+        auto* compositedAncestor = layer.ancestorCompositingLayer();
+        if (!compositedAncestor)
+            return overflowNodeData;
+        collectStationaryLayerRelatedOverflowNodes(layer, *compositedAncestor, overflowNodeData);
</ins><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     case ScrollPositioningBehavior::None:
</span></span></pre>
</div>
</div>

</body>
</html>