Title: [294294] branches/safari-613-branch
Revision
294294
Author
alanc...@apple.com
Date
2022-05-16 23:10:28 -0700 (Mon, 16 May 2022)

Log Message

Cherry-pick r293126. rdar://problem/90483049

    REGRESSION (r281913): Map toolbar flickers when dragging the map on https://gis.ee/
    https://bugs.webkit.org/show_bug.cgi?id=238589
    <rdar://90483049>

    Reviewed by Alan Bujtas.
    Source/WebCore:

    If a layer has negative z-order descendants, and one of those descendants becomes
    composited, then that layer also has to composite, because its foreground needs to render in
    front of those descendants. But this is tricky, because the compositing toggle is
    out-of-order; we only know that the layer has to get composited after processing
    descendants.

    In particular, this created a problem with the overlap map, which tracks sets of rectangles
    in "compositing scopes" via LayerOverlapMap. The delayed compositing toggle of the layer
    with negative z-order descendants meant that any layers processed up to that point had their
    bounds added in the wrong overlap scope. This resulted in subsequent bad overlap testing,
    and a failure to make later layers composited.

    The previous fix in this area (r281913) was incorrect. Revert it, and do a better fix, which
    is to speculatively push an overlap map entry for the layer with negative z-order
    descendants, if necessary. If this layer ends up not getting composited, we unwind the
    speculative push, which will merge that scope with its parent scope.

    In addition give OverlapMapContainer (an "overlap scope") a RenderLayer& which we can use
    for logging, and to assert on correct behavior; it is not otherwise used in release builds.

    Tests: compositing/layer-creation/overlap-with-negative-z-layers.html
           compositing/layer-creation/subtree-div-overlaps-multiple-negative-z-divs.html

    * rendering/LayerOverlapMap.cpp:
    (WebCore::OverlapMapContainer::OverlapMapContainer):
    (WebCore::OverlapMapContainer::scopeLayer const):
    (WebCore::OverlapMapContainer::dump const):
    (WebCore::LayerOverlapMap::LayerOverlapMap):
    (WebCore::LayerOverlapMap::add):
    (WebCore::LayerOverlapMap::pushCompositingContainer):
    (WebCore::LayerOverlapMap::popCompositingContainer):
    * rendering/LayerOverlapMap.h:
    * rendering/RenderLayerCompositor.cpp:
    (WebCore::RenderLayerCompositor::computeCompositingRequirements):
    (WebCore::RenderLayerCompositor::traverseUnchangedSubtree):
    (WebCore::RenderLayerCompositor::updateOverlapMap const):

    LayoutTests:

    Move subtree-div-overlaps-multiple-negative-z-divs.html into the layer-creation directory.
    Add a new test.

    * compositing/layer-creation/overlap-with-negative-z-layers-expected.html: Added.
    * compositing/layer-creation/overlap-with-negative-z-layers.html: Added.
    * compositing/layer-creation/subtree-div-overlaps-multiple-negative-z-divs-expected.html: Renamed from LayoutTests/compositing/subtree-div-overlaps-multiple-negative-z-divs-expected.html.
    * compositing/layer-creation/subtree-div-overlaps-multiple-negative-z-divs.html: Renamed from LayoutTests/compositing/subtree-div-overlaps-multiple-negative-z-divs.html.
    * fast/harness/render-tree-as-text-options-expected.txt: Test progressed; update results.

    Canonical link: https://commits.webkit.org/249828@main
    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@293126 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Added Paths

Removed Paths

Diff

Modified: branches/safari-613-branch/LayoutTests/ChangeLog (294293 => 294294)


--- branches/safari-613-branch/LayoutTests/ChangeLog	2022-05-17 06:10:23 UTC (rev 294293)
+++ branches/safari-613-branch/LayoutTests/ChangeLog	2022-05-17 06:10:28 UTC (rev 294294)
@@ -1,5 +1,84 @@
 2022-05-16  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r293126. rdar://problem/90483049
+
+    REGRESSION (r281913): Map toolbar flickers when dragging the map on https://gis.ee/
+    https://bugs.webkit.org/show_bug.cgi?id=238589
+    <rdar://90483049>
+    
+    Reviewed by Alan Bujtas.
+    Source/WebCore:
+    
+    If a layer has negative z-order descendants, and one of those descendants becomes
+    composited, then that layer also has to composite, because its foreground needs to render in
+    front of those descendants. But this is tricky, because the compositing toggle is
+    out-of-order; we only know that the layer has to get composited after processing
+    descendants.
+    
+    In particular, this created a problem with the overlap map, which tracks sets of rectangles
+    in "compositing scopes" via LayerOverlapMap. The delayed compositing toggle of the layer
+    with negative z-order descendants meant that any layers processed up to that point had their
+    bounds added in the wrong overlap scope. This resulted in subsequent bad overlap testing,
+    and a failure to make later layers composited.
+    
+    The previous fix in this area (r281913) was incorrect. Revert it, and do a better fix, which
+    is to speculatively push an overlap map entry for the layer with negative z-order
+    descendants, if necessary. If this layer ends up not getting composited, we unwind the
+    speculative push, which will merge that scope with its parent scope.
+    
+    In addition give OverlapMapContainer (an "overlap scope") a RenderLayer& which we can use
+    for logging, and to assert on correct behavior; it is not otherwise used in release builds.
+    
+    Tests: compositing/layer-creation/overlap-with-negative-z-layers.html
+           compositing/layer-creation/subtree-div-overlaps-multiple-negative-z-divs.html
+    
+    * rendering/LayerOverlapMap.cpp:
+    (WebCore::OverlapMapContainer::OverlapMapContainer):
+    (WebCore::OverlapMapContainer::scopeLayer const):
+    (WebCore::OverlapMapContainer::dump const):
+    (WebCore::LayerOverlapMap::LayerOverlapMap):
+    (WebCore::LayerOverlapMap::add):
+    (WebCore::LayerOverlapMap::pushCompositingContainer):
+    (WebCore::LayerOverlapMap::popCompositingContainer):
+    * rendering/LayerOverlapMap.h:
+    * rendering/RenderLayerCompositor.cpp:
+    (WebCore::RenderLayerCompositor::computeCompositingRequirements):
+    (WebCore::RenderLayerCompositor::traverseUnchangedSubtree):
+    (WebCore::RenderLayerCompositor::updateOverlapMap const):
+    
+    LayoutTests:
+    
+    Move subtree-div-overlaps-multiple-negative-z-divs.html into the layer-creation directory.
+    Add a new test.
+    
+    * compositing/layer-creation/overlap-with-negative-z-layers-expected.html: Added.
+    * compositing/layer-creation/overlap-with-negative-z-layers.html: Added.
+    * compositing/layer-creation/subtree-div-overlaps-multiple-negative-z-divs-expected.html: Renamed from LayoutTests/compositing/subtree-div-overlaps-multiple-negative-z-divs-expected.html.
+    * compositing/layer-creation/subtree-div-overlaps-multiple-negative-z-divs.html: Renamed from LayoutTests/compositing/subtree-div-overlaps-multiple-negative-z-divs.html.
+    * fast/harness/render-tree-as-text-options-expected.txt: Test progressed; update results.
+    
+    Canonical link: https://commits.webkit.org/249828@main
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@293126 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-04-20  Simon Fraser  <simon.fra...@apple.com>
+
+            REGRESSION (r281913): Map toolbar flickers when dragging the map on https://gis.ee/
+            https://bugs.webkit.org/show_bug.cgi?id=238589
+            <rdar://90483049>
+
+            Reviewed by Alan Bujtas.
+
+            Move subtree-div-overlaps-multiple-negative-z-divs.html into the layer-creation directory.
+            Add a new test.
+
+            * compositing/layer-creation/overlap-with-negative-z-layers-expected.html: Added.
+            * compositing/layer-creation/overlap-with-negative-z-layers.html: Added.
+            * compositing/layer-creation/subtree-div-overlaps-multiple-negative-z-divs-expected.html: Renamed from LayoutTests/compositing/subtree-div-overlaps-multiple-negative-z-divs-expected.html.
+            * compositing/layer-creation/subtree-div-overlaps-multiple-negative-z-divs.html: Renamed from LayoutTests/compositing/subtree-div-overlaps-multiple-negative-z-divs.html.
+            * fast/harness/render-tree-as-text-options-expected.txt: Test progressed; update results.
+
+2022-05-16  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r292350. rdar://problem/90589355
 
     intersectsWithAncestor should take fragmented boxes into account.

Added: branches/safari-613-branch/LayoutTests/compositing/layer-creation/overlap-with-negative-z-layers-expected.html (0 => 294294)


--- branches/safari-613-branch/LayoutTests/compositing/layer-creation/overlap-with-negative-z-layers-expected.html	                        (rev 0)
+++ branches/safari-613-branch/LayoutTests/compositing/layer-creation/overlap-with-negative-z-layers-expected.html	2022-05-17 06:10:28 UTC (rev 294294)
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <style>
+        .wrapper {
+            position: absolute;
+            height: 400px;
+            width: 400px;
+            border: 1px solid black;
+            z-index: 0;
+        }
+        
+        .container {
+            position: absolute;
+            left: 0;
+            top: 0;
+            z-index: 0;
+        }
+
+        .tile {
+            position: absolute;
+            width: 200px;
+            height: 200px;
+            left: 100px;
+            top: 100px;
+            background-color: orange;
+        }
+
+        .green {
+            position: relative;
+            width: 200px;
+            height: 200px;
+            margin: 10px;
+            background-color: green;
+        }
+    </style>
+</head>
+<body>
+    <p>The green box should be on top.</p>
+    <div class="wrapper">
+        <div class="container" style="transform: translate3d(0px, 0px, 0px);">
+            <div class="container">
+                <div class="tile"></div>
+            </div>
+        </div>
+        <div class="green"></div>
+    </div>
+</body>
+</html>

Added: branches/safari-613-branch/LayoutTests/compositing/layer-creation/overlap-with-negative-z-layers.html (0 => 294294)


--- branches/safari-613-branch/LayoutTests/compositing/layer-creation/overlap-with-negative-z-layers.html	                        (rev 0)
+++ branches/safari-613-branch/LayoutTests/compositing/layer-creation/overlap-with-negative-z-layers.html	2022-05-17 06:10:28 UTC (rev 294294)
@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <style>
+        .wrapper {
+            position: absolute;
+            height: 400px;
+            width: 400px;
+            border: 1px solid black;
+            z-index: 0;
+        }
+        
+        .container {
+            position: absolute;
+            left: 0;
+            top: 0;
+            z-index: 0;
+        }
+
+        .negative {
+            position: absolute;
+            width: 20px;
+            height: 20px;
+            background-color: darkred;
+        }
+
+        .tile {
+            position: absolute;
+            width: 200px;
+            height: 200px;
+            left: 100px;
+            top: 100px;
+            background-color: orange;
+        }
+
+        .green {
+            position: relative;
+            width: 200px;
+            height: 200px;
+            margin: 10px;
+            background-color: green;
+        }
+    </style>
+</head>
+<body>
+    <p>The green box should be on top.</p>
+    <div class="wrapper">
+        <div class="container" style="transform: translate3d(0px, 0px, 0px);">
+            <div class="container">
+                <div class="tile"></div>
+            </div>
+            <div class="container">
+                <div class="negative" style="transform: translate3d(50px, 50px, 0px); z-index: -3;"></div>
+                <div class="negative" style="transform: translate3d(50px, 100px, 0px); z-index: -2;"></div>
+                <div class="negative" style="transform: translate3d(50px, 150px, 0px); z-index: -1;"></div>
+            </div>
+        </div>
+        <div class="green"></div>
+    </div>
+</body>
+</html>

Copied: branches/safari-613-branch/LayoutTests/compositing/layer-creation/subtree-div-overlaps-multiple-negative-z-divs-expected.html (from rev 294293, branches/safari-613-branch/LayoutTests/compositing/subtree-div-overlaps-multiple-negative-z-divs-expected.html) (0 => 294294)


--- branches/safari-613-branch/LayoutTests/compositing/layer-creation/subtree-div-overlaps-multiple-negative-z-divs-expected.html	                        (rev 0)
+++ branches/safari-613-branch/LayoutTests/compositing/layer-creation/subtree-div-overlaps-multiple-negative-z-divs-expected.html	2022-05-17 06:10:28 UTC (rev 294294)
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<div style="background:green;width:100px;height:100px"></div>

Copied: branches/safari-613-branch/LayoutTests/compositing/layer-creation/subtree-div-overlaps-multiple-negative-z-divs.html (from rev 294293, branches/safari-613-branch/LayoutTests/compositing/subtree-div-overlaps-multiple-negative-z-divs.html) (0 => 294294)


--- branches/safari-613-branch/LayoutTests/compositing/layer-creation/subtree-div-overlaps-multiple-negative-z-divs.html	                        (rev 0)
+++ branches/safari-613-branch/LayoutTests/compositing/layer-creation/subtree-div-overlaps-multiple-negative-z-divs.html	2022-05-17 06:10:28 UTC (rev 294294)
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<style>
+.negative {
+  z-index: -1;
+}
+.abs {
+  position: absolute;
+}
+.green {
+  width: 100px;
+  height: 100px;
+  background-color: green;
+}
+
+.red {
+  width: 100px;
+  height: 100px;
+  background-color: red;
+  will-change: transform;
+}
+</style>
+<body>
+<div class="negative abs">
+  <div class="red"></div>
+</div>
+<div class="negative abs green"></div>
+</body>

Deleted: branches/safari-613-branch/LayoutTests/compositing/subtree-div-overlaps-multiple-negative-z-divs-expected.html (294293 => 294294)


--- branches/safari-613-branch/LayoutTests/compositing/subtree-div-overlaps-multiple-negative-z-divs-expected.html	2022-05-17 06:10:23 UTC (rev 294293)
+++ branches/safari-613-branch/LayoutTests/compositing/subtree-div-overlaps-multiple-negative-z-divs-expected.html	2022-05-17 06:10:28 UTC (rev 294294)
@@ -1,2 +0,0 @@
-<!DOCTYPE html>
-<div style="background:green;width:100px;height:100px"></div>

Deleted: branches/safari-613-branch/LayoutTests/compositing/subtree-div-overlaps-multiple-negative-z-divs.html (294293 => 294294)


--- branches/safari-613-branch/LayoutTests/compositing/subtree-div-overlaps-multiple-negative-z-divs.html	2022-05-17 06:10:23 UTC (rev 294293)
+++ branches/safari-613-branch/LayoutTests/compositing/subtree-div-overlaps-multiple-negative-z-divs.html	2022-05-17 06:10:28 UTC (rev 294294)
@@ -1,27 +0,0 @@
-<!DOCTYPE html>
-<style>
-.negative {
-  z-index: -1;
-}
-.abs {
-  position: absolute;
-}
-.green {
-  width: 100px;
-  height: 100px;
-  background-color: green;
-}
-
-.red {
-  width: 100px;
-  height: 100px;
-  background-color: red;
-  will-change: transform;
-}
-</style>
-<body>
-<div class="negative abs">
-  <div class="red"></div>
-</div>
-<div class="negative abs green"></div>
-</body>

Modified: branches/safari-613-branch/LayoutTests/fast/harness/render-tree-as-text-options-expected.txt (294293 => 294294)


--- branches/safari-613-branch/LayoutTests/fast/harness/render-tree-as-text-options-expected.txt	2022-05-17 06:10:23 UTC (rev 294293)
+++ branches/safari-613-branch/LayoutTests/fast/harness/render-tree-as-text-options-expected.txt	2022-05-17 06:10:28 UTC (rev 294294)
@@ -14,5 +14,5 @@
             RenderSVGRect {rect} at (18,278) size 100x100 [fill={[type=SOLID] [color=#0000FF]}] [x=10.00] [y=20.00] [width=100.00] [height=100.00]
           RenderText {#text} at (0,0) size 0x0
    positive z-order list (1)
-    layer at (8,8) size 200x400
+    layer at (8,8) size 200x400 (composited [overlap], bounds=at (0,0) size 200x400, drawsContent=0, paints into ancestor=0)
       RenderBlock (relative positioned) zI: 1 {DIV} at (0,0) size 200x400

Modified: branches/safari-613-branch/Source/WebCore/ChangeLog (294293 => 294294)


--- branches/safari-613-branch/Source/WebCore/ChangeLog	2022-05-17 06:10:23 UTC (rev 294293)
+++ branches/safari-613-branch/Source/WebCore/ChangeLog	2022-05-17 06:10:28 UTC (rev 294294)
@@ -1,5 +1,112 @@
 2022-05-16  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r293126. rdar://problem/90483049
+
+    REGRESSION (r281913): Map toolbar flickers when dragging the map on https://gis.ee/
+    https://bugs.webkit.org/show_bug.cgi?id=238589
+    <rdar://90483049>
+    
+    Reviewed by Alan Bujtas.
+    Source/WebCore:
+    
+    If a layer has negative z-order descendants, and one of those descendants becomes
+    composited, then that layer also has to composite, because its foreground needs to render in
+    front of those descendants. But this is tricky, because the compositing toggle is
+    out-of-order; we only know that the layer has to get composited after processing
+    descendants.
+    
+    In particular, this created a problem with the overlap map, which tracks sets of rectangles
+    in "compositing scopes" via LayerOverlapMap. The delayed compositing toggle of the layer
+    with negative z-order descendants meant that any layers processed up to that point had their
+    bounds added in the wrong overlap scope. This resulted in subsequent bad overlap testing,
+    and a failure to make later layers composited.
+    
+    The previous fix in this area (r281913) was incorrect. Revert it, and do a better fix, which
+    is to speculatively push an overlap map entry for the layer with negative z-order
+    descendants, if necessary. If this layer ends up not getting composited, we unwind the
+    speculative push, which will merge that scope with its parent scope.
+    
+    In addition give OverlapMapContainer (an "overlap scope") a RenderLayer& which we can use
+    for logging, and to assert on correct behavior; it is not otherwise used in release builds.
+    
+    Tests: compositing/layer-creation/overlap-with-negative-z-layers.html
+           compositing/layer-creation/subtree-div-overlaps-multiple-negative-z-divs.html
+    
+    * rendering/LayerOverlapMap.cpp:
+    (WebCore::OverlapMapContainer::OverlapMapContainer):
+    (WebCore::OverlapMapContainer::scopeLayer const):
+    (WebCore::OverlapMapContainer::dump const):
+    (WebCore::LayerOverlapMap::LayerOverlapMap):
+    (WebCore::LayerOverlapMap::add):
+    (WebCore::LayerOverlapMap::pushCompositingContainer):
+    (WebCore::LayerOverlapMap::popCompositingContainer):
+    * rendering/LayerOverlapMap.h:
+    * rendering/RenderLayerCompositor.cpp:
+    (WebCore::RenderLayerCompositor::computeCompositingRequirements):
+    (WebCore::RenderLayerCompositor::traverseUnchangedSubtree):
+    (WebCore::RenderLayerCompositor::updateOverlapMap const):
+    
+    LayoutTests:
+    
+    Move subtree-div-overlaps-multiple-negative-z-divs.html into the layer-creation directory.
+    Add a new test.
+    
+    * compositing/layer-creation/overlap-with-negative-z-layers-expected.html: Added.
+    * compositing/layer-creation/overlap-with-negative-z-layers.html: Added.
+    * compositing/layer-creation/subtree-div-overlaps-multiple-negative-z-divs-expected.html: Renamed from LayoutTests/compositing/subtree-div-overlaps-multiple-negative-z-divs-expected.html.
+    * compositing/layer-creation/subtree-div-overlaps-multiple-negative-z-divs.html: Renamed from LayoutTests/compositing/subtree-div-overlaps-multiple-negative-z-divs.html.
+    * fast/harness/render-tree-as-text-options-expected.txt: Test progressed; update results.
+    
+    Canonical link: https://commits.webkit.org/249828@main
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@293126 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-04-20  Simon Fraser  <simon.fra...@apple.com>
+
+            REGRESSION (r281913): Map toolbar flickers when dragging the map on https://gis.ee/
+            https://bugs.webkit.org/show_bug.cgi?id=238589
+            <rdar://90483049>
+
+            Reviewed by Alan Bujtas.
+
+            If a layer has negative z-order descendants, and one of those descendants becomes
+            composited, then that layer also has to composite, because its foreground needs to render in
+            front of those descendants. But this is tricky, because the compositing toggle is
+            out-of-order; we only know that the layer has to get composited after processing
+            descendants.
+
+            In particular, this created a problem with the overlap map, which tracks sets of rectangles
+            in "compositing scopes" via LayerOverlapMap. The delayed compositing toggle of the layer
+            with negative z-order descendants meant that any layers processed up to that point had their
+            bounds added in the wrong overlap scope. This resulted in subsequent bad overlap testing,
+            and a failure to make later layers composited.
+
+            The previous fix in this area (r281913) was incorrect. Revert it, and do a better fix, which
+            is to speculatively push an overlap map entry for the layer with negative z-order
+            descendants, if necessary. If this layer ends up not getting composited, we unwind the
+            speculative push, which will merge that scope with its parent scope.
+
+            In addition give OverlapMapContainer (an "overlap scope") a RenderLayer& which we can use
+            for logging, and to assert on correct behavior; it is not otherwise used in release builds.
+
+            Tests: compositing/layer-creation/overlap-with-negative-z-layers.html
+                   compositing/layer-creation/subtree-div-overlaps-multiple-negative-z-divs.html
+
+            * rendering/LayerOverlapMap.cpp:
+            (WebCore::OverlapMapContainer::OverlapMapContainer):
+            (WebCore::OverlapMapContainer::scopeLayer const):
+            (WebCore::OverlapMapContainer::dump const):
+            (WebCore::LayerOverlapMap::LayerOverlapMap):
+            (WebCore::LayerOverlapMap::add):
+            (WebCore::LayerOverlapMap::pushCompositingContainer):
+            (WebCore::LayerOverlapMap::popCompositingContainer):
+            * rendering/LayerOverlapMap.h:
+            * rendering/RenderLayerCompositor.cpp:
+            (WebCore::RenderLayerCompositor::computeCompositingRequirements):
+            (WebCore::RenderLayerCompositor::traverseUnchangedSubtree):
+            (WebCore::RenderLayerCompositor::updateOverlapMap const):
+
+2022-05-16  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r292350. rdar://problem/90589355
 
     intersectsWithAncestor should take fragmented boxes into account.

Modified: branches/safari-613-branch/Source/WebCore/rendering/LayerOverlapMap.cpp (294293 => 294294)


--- branches/safari-613-branch/Source/WebCore/rendering/LayerOverlapMap.cpp	2022-05-17 06:10:23 UTC (rev 294293)
+++ branches/safari-613-branch/Source/WebCore/rendering/LayerOverlapMap.cpp	2022-05-17 06:10:28 UTC (rev 294294)
@@ -25,6 +25,7 @@
 
 #include "config.h"
 #include "LayerOverlapMap.h"
+#include "Logging.h"
 #include "RenderLayer.h"
 #include <wtf/text/TextStream.h>
 
@@ -73,8 +74,9 @@
 class OverlapMapContainer {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    OverlapMapContainer(const RenderLayer& rootLayer)
+    OverlapMapContainer(const RenderLayer& rootLayer, const RenderLayer& scopeLayer)
         : m_rootScope(rootLayer)
+        , m_scopeLayer(scopeLayer)
     {
     }
 
@@ -84,6 +86,8 @@
     void append(std::unique_ptr<OverlapMapContainer>&&);
     
     String dump(unsigned) const;
+    
+    const RenderLayer& scopeLayer() const { return m_scopeLayer; }
 
 private:
     struct ClippingScope {
@@ -160,6 +164,7 @@
     ClippingScope& rootScope() { return m_rootScope; }
 
     ClippingScope m_rootScope;
+    const RenderLayer& m_scopeLayer;
 };
 
 void OverlapMapContainer::add(const RenderLayer&, const LayoutRect& bounds, const Vector<LayerOverlapMap::LayerAndBounds>& enclosingClippingLayers)
@@ -258,7 +263,7 @@
 {
     TextStream multilineStream;
     multilineStream.increaseIndent(indent);
-    multilineStream << "overlap container - root scope layer " <<  &m_rootScope.layer << " rects " << m_rootScope.rectList;
+    multilineStream << "overlap container - root layer " <<  &m_rootScope.layer << " scope layer " << &m_scopeLayer << " rects " << m_rootScope.rectList;
 
     for (auto& childScope : m_rootScope.children)
         recursiveOutputToStream(multilineStream, childScope, 1);
@@ -273,7 +278,7 @@
     // Begin assuming the root layer will be composited so that there is
     // something on the stack. The root layer should also never get an
     // popCompositingContainer call.
-    pushCompositingContainer();
+    pushCompositingContainer(rootLayer);
 }
 
 LayerOverlapMap::~LayerOverlapMap() = default;
@@ -284,8 +289,11 @@
     // contribute to overlap as soon as their composited ancestor has been
     // recursively processed and popped off the stack.
     ASSERT(m_overlapStack.size() >= 2);
-    m_overlapStack[m_overlapStack.size() - 2]->add(layer, bounds, enclosingClippingLayers);
-    
+    auto& container = m_overlapStack[m_overlapStack.size() - 2];
+    container->add(layer, bounds, enclosingClippingLayers);
+
+    LOG_WITH_STREAM(CompositingOverlap, stream << "layer " << &layer << " contributes to overlap in the scope of layer " << &container->scopeLayer() << ", added to map " << *this);
+
     m_isEmpty = false;
 }
 
@@ -294,13 +302,14 @@
     return m_overlapStack.last()->overlapsLayers(layer, bounds, enclosingClippingLayers);
 }
 
-void LayerOverlapMap::pushCompositingContainer()
+void LayerOverlapMap::pushCompositingContainer(const RenderLayer& layer)
 {
-    m_overlapStack.append(makeUnique<OverlapMapContainer>(m_rootLayer));
+    m_overlapStack.append(makeUnique<OverlapMapContainer>(m_rootLayer, layer));
 }
 
-void LayerOverlapMap::popCompositingContainer()
+void LayerOverlapMap::popCompositingContainer(const RenderLayer& layer)
 {
+    ASSERT_UNUSED(layer, &m_overlapStack.last()->scopeLayer() == &layer);
     m_overlapStack[m_overlapStack.size() - 2]->append(WTFMove(m_overlapStack.last()));
     m_overlapStack.removeLast();
 }

Modified: branches/safari-613-branch/Source/WebCore/rendering/LayerOverlapMap.h (294293 => 294294)


--- branches/safari-613-branch/Source/WebCore/rendering/LayerOverlapMap.h	2022-05-17 06:10:23 UTC (rev 294293)
+++ branches/safari-613-branch/Source/WebCore/rendering/LayerOverlapMap.h	2022-05-17 06:10:28 UTC (rev 294294)
@@ -53,8 +53,8 @@
     bool overlapsLayers(const RenderLayer&, const LayoutRect&, const Vector<LayerAndBounds>& enclosingClippingLayers) const;
     bool isEmpty() const { return m_isEmpty; }
 
-    void pushCompositingContainer();
-    void popCompositingContainer();
+    void pushCompositingContainer(const RenderLayer&);
+    void popCompositingContainer(const RenderLayer&);
 
     const RenderGeometryMap& geometryMap() const { return m_geometryMap; }
     RenderGeometryMap& geometryMap() { return m_geometryMap; }

Modified: branches/safari-613-branch/Source/WebCore/rendering/RenderLayerCompositor.cpp (294293 => 294294)


--- branches/safari-613-branch/Source/WebCore/rendering/RenderLayerCompositor.cpp	2022-05-17 06:10:23 UTC (rev 294293)
+++ branches/safari-613-branch/Source/WebCore/rendering/RenderLayerCompositor.cpp	2022-05-17 06:10:28 UTC (rev 294294)
@@ -1062,9 +1062,11 @@
             layer.setIndirectCompositingReason(IndirectCompositingReason::Overlap);
             LOG_WITH_STREAM(Compositing, stream << "layer " << &layer << " was sharing now will composite");
         } else {
-            overlapMap.pushCompositingContainer();
-            didPushOverlapContainer = true;
-            LOG_WITH_STREAM(CompositingOverlap, stream << "layer " << &layer << " will composite, pushed container " << overlapMap);
+            if (!didPushOverlapContainer) {
+                overlapMap.pushCompositingContainer(layer);
+                didPushOverlapContainer = true;
+                LOG_WITH_STREAM(CompositingOverlap, stream << "layer " << &layer << " will composite, pushed container " << overlapMap);
+            }
         }
 
         willBeComposited = true;
@@ -1085,7 +1087,7 @@
         layerExtent.animationCausesExtentUncertainty |= layerExtent.hasTransformAnimation && compositingState.ancestorHasTransformAnimation;
     } else if (layerPaintsIntoProvidedBacking) {
         currentState.backingSharingAncestor = &layer;
-        overlapMap.pushCompositingContainer();
+        overlapMap.pushCompositingContainer(layer);
         didPushOverlapContainer = true;
         LOG_WITH_STREAM(CompositingOverlap, stream << "layer " << &layer << " will share, pushed container " << overlapMap);
     }
@@ -1099,19 +1101,34 @@
     bool anyDescendantHas3DTransform = false;
     bool descendantsAddedToOverlap = currentState.hasNonRootCompositedAncestor();
 
-    unsigned newlyCompositedChildLayerCount = 0;
-    for (auto* childLayer : layer.negativeZOrderLayers()) {
-        computeCompositingRequirements(&layer, *childLayer, overlapMap, currentState, backingSharingState, anyDescendantHas3DTransform);
+    if (layer.hasNegativeZOrderLayers()) {
+        // Speculatively push this layer onto the overlap map.
+        bool didSpeculativelyPushOverlapContainer = false;
+        if (!didPushOverlapContainer) {
+            overlapMap.pushCompositingContainer(layer);
+            didPushOverlapContainer = true;
+            didSpeculativelyPushOverlapContainer = true;
+        }
 
-        // If we have to make a layer for this child, make one now so we can have a contents layer
-        // (since we need to ensure that the -ve z-order child renders underneath our contents).
-        if (!willBeComposited && currentState.subtreeIsCompositing)
-            ++newlyCompositedChildLayerCount;
+        bool compositeForNegativeZOrderDescendant = false;
+        
+        for (auto* childLayer : layer.negativeZOrderLayers()) {
+            computeCompositingRequirements(&layer, *childLayer, overlapMap, currentState, backingSharingState, anyDescendantHas3DTransform);
+
+            // If we have to make a layer for this child, make one now so we can have a contents layer
+            // (since we need to ensure that the -ve z-order child renders underneath our contents).
+            if (!willBeComposited && currentState.subtreeIsCompositing) {
+                layer.setIndirectCompositingReason(IndirectCompositingReason::BackgroundLayer);
+                layerWillComposite();
+                compositeForNegativeZOrderDescendant = true;
+            }
+        }
+
+        if (!compositeForNegativeZOrderDescendant && didSpeculativelyPushOverlapContainer) {
+            overlapMap.popCompositingContainer(layer);
+            didPushOverlapContainer = false;
+        }
     }
-    while (newlyCompositedChildLayerCount--) {
-        layer.setIndirectCompositingReason(IndirectCompositingReason::BackgroundLayer);
-        layerWillComposite();
-    }
 
     for (auto* childLayer : layer.normalFlowLayers())
         computeCompositingRequirements(&layer, *childLayer, overlapMap, currentState, backingSharingState, anyDescendantHas3DTransform);
@@ -1247,7 +1264,7 @@
         // This layer now acts as the ancestor for kids.
         currentState.compositingAncestor = &layer;
         currentState.backingSharingAncestor = nullptr;
-        overlapMap.pushCompositingContainer();
+        overlapMap.pushCompositingContainer(layer);
         didPushOverlapContainer = true;
         LOG_WITH_STREAM(CompositingOverlap, stream << "unchangedSubtree: layer " << &layer << " will composite, pushed container " << overlapMap);
 
@@ -1256,7 +1273,7 @@
         // Too hard to compute animated bounds if both us and some ancestor is animating transform.
         layerExtent.animationCausesExtentUncertainty |= layerExtent.hasTransformAnimation && compositingState.ancestorHasTransformAnimation;
     } else if (layerPaintsIntoProvidedBacking) {
-        overlapMap.pushCompositingContainer();
+        overlapMap.pushCompositingContainer(layer);
         currentState.backingSharingAncestor = &layer;
         didPushOverlapContainer = true;
         LOG_WITH_STREAM(CompositingOverlap, stream << "unchangedSubtree: layer " << &layer << " will share, pushed container " << overlapMap);
@@ -2142,10 +2159,8 @@
 
 void RenderLayerCompositor::updateOverlapMap(LayerOverlapMap& overlapMap, const RenderLayer& layer, OverlapExtent& layerExtent, bool didPushContainer, bool addLayerToOverlap, bool addDescendantsToOverlap) const
 {
-    if (addLayerToOverlap) {
+    if (addLayerToOverlap)
         addToOverlapMap(overlapMap, layer, layerExtent);
-        LOG_WITH_STREAM(CompositingOverlap, stream << "layer " << &layer << " contributes to overlap, added to map " << overlapMap);
-    }
 
     if (addDescendantsToOverlap) {
         // If this is the first non-root layer to composite, we need to add all the descendants we already traversed to the overlap map.
@@ -2154,7 +2169,7 @@
     }
 
     if (didPushContainer) {
-        overlapMap.popCompositingContainer();
+        overlapMap.popCompositingContainer(layer);
         LOG_WITH_STREAM(CompositingOverlap, stream << "layer " << &layer << " is composited or shared, popped container " << overlapMap);
     }
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to