Title: [246017] trunk
Revision
246017
Author
[email protected]
Date
2019-06-01 14:40:04 -0700 (Sat, 01 Jun 2019)

Log Message

Non-composited negative z-order children should not trigger creation of a foreground layer
https://bugs.webkit.org/show_bug.cgi?id=198455

Reviewed by Sam Weinig.
Source/WebCore:

The existing code triggered creation of a foreground layer on RenderLayerBacking when
the negative z-order list was non-empty. This isn't necessary; we can paint the negative
z-order children just fine.

We only need a foreground layer when the negative z-order layers are composited or
have composited descendants.

This will reduce backing store memory use in some cases.

Test: compositing/layer-creation/composited-negative-z-subtree.html

* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::computeCompositingRequirements):
(WebCore::RenderLayerCompositor::updateBackingAndHierarchy):
(WebCore::RenderLayerCompositor::needsContentsCompositingLayer const):

LayoutTests:

Change existing tests that use negative z-order layers to trigger foreground layer
creation to use compositing on those negative z-order layers.

* compositing/geometry/bounds-ignores-hidden-dynamic-negzindex-expected.txt:
* compositing/geometry/bounds-ignores-hidden-dynamic-negzindex.html:
* compositing/geometry/bounds-ignores-hidden-expected.txt:
* compositing/geometry/bounds-ignores-hidden.html:
* compositing/layer-creation/composited-negative-z-subtree-expected.txt: Added.
* compositing/layer-creation/composited-negative-z-subtree.html: Added.
* compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt:
* compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases.html:
* platform/ios-wk2/compositing/geometry/bounds-ignores-hidden-dynamic-negzindex-expected.txt:
* platform/ios-wk2/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt:
* platform/mac-wk1/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (246016 => 246017)


--- trunk/LayoutTests/ChangeLog	2019-06-01 21:37:49 UTC (rev 246016)
+++ trunk/LayoutTests/ChangeLog	2019-06-01 21:40:04 UTC (rev 246017)
@@ -1,3 +1,25 @@
+2019-06-01  Simon Fraser  <[email protected]>
+
+        Non-composited negative z-order children should not trigger creation of a foreground layer
+        https://bugs.webkit.org/show_bug.cgi?id=198455
+
+        Reviewed by Sam Weinig.
+        
+        Change existing tests that use negative z-order layers to trigger foreground layer
+        creation to use compositing on those negative z-order layers.
+
+        * compositing/geometry/bounds-ignores-hidden-dynamic-negzindex-expected.txt:
+        * compositing/geometry/bounds-ignores-hidden-dynamic-negzindex.html:
+        * compositing/geometry/bounds-ignores-hidden-expected.txt:
+        * compositing/geometry/bounds-ignores-hidden.html:
+        * compositing/layer-creation/composited-negative-z-subtree-expected.txt: Added.
+        * compositing/layer-creation/composited-negative-z-subtree.html: Added.
+        * compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt:
+        * compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases.html:
+        * platform/ios-wk2/compositing/geometry/bounds-ignores-hidden-dynamic-negzindex-expected.txt:
+        * platform/ios-wk2/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt:
+        * platform/mac-wk1/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt:
+
 2019-06-01  Devin Rousso  <[email protected]>
 
         Web Inspector: Canvas: split recording tests into separate files so they don't timeout

Modified: trunk/LayoutTests/compositing/geometry/bounds-ignores-hidden-dynamic-negzindex-expected.txt (246016 => 246017)


--- trunk/LayoutTests/compositing/geometry/bounds-ignores-hidden-dynamic-negzindex-expected.txt	2019-06-01 21:37:49 UTC (rev 246016)
+++ trunk/LayoutTests/compositing/geometry/bounds-ignores-hidden-dynamic-negzindex-expected.txt	2019-06-01 21:40:04 UTC (rev 246017)
@@ -12,8 +12,14 @@
           (anchor 0.10 0.20)
           (bounds 500.00 250.00)
           (drawsContent 1)
-          (children 1
+          (children 2
             (GraphicsLayer
+              (position 50.00 50.00)
+              (bounds 100.00 100.00)
+              (contentsOpaque 1)
+              (drawsContent 1)
+            )
+            (GraphicsLayer
               (bounds 500.00 250.00)
               (drawsContent 1)
             )
@@ -21,14 +27,19 @@
         )
         (GraphicsLayer
           (position 0.00 250.00)
-          (anchor 0.33 0.33)
-          (bounds 150.00 150.00)
+          (bounds 100.00 100.00)
           (drawsContent 1)
-          (children 1
+          (children 2
             (GraphicsLayer
-              (bounds 150.00 150.00)
+              (position 50.00 50.00)
+              (bounds 100.00 100.00)
+              (contentsOpaque 1)
               (drawsContent 1)
             )
+            (GraphicsLayer
+              (bounds 100.00 100.00)
+              (drawsContent 1)
+            )
           )
         )
         (GraphicsLayer

Modified: trunk/LayoutTests/compositing/geometry/bounds-ignores-hidden-dynamic-negzindex.html (246016 => 246017)


--- trunk/LayoutTests/compositing/geometry/bounds-ignores-hidden-dynamic-negzindex.html	2019-06-01 21:37:49 UTC (rev 246016)
+++ trunk/LayoutTests/compositing/geometry/bounds-ignores-hidden-dynamic-negzindex.html	2019-06-01 21:40:04 UTC (rev 246017)
@@ -3,7 +3,7 @@
         overflow: hidden;
     }
     .composited {
-        -webkit-transform: translateZ(0);
+        transform: translateZ(0);
     }
 
     .box {
@@ -79,13 +79,13 @@
 
     <div style="position: absolute; left: 0px; top: 0px; z-index: 0; " class="composited">
         <div class="inline"></div>
-        <img style="position: absolute; left: 50px; top: 50px; z-index: -1;">
+        <img class="composited" style="position: absolute; left: 50px; top: 50px; z-index: -1;">
         <img style="position: absolute; left: 400px; top: 150px; z-index: 0;" class="to-visible">
     </div>
 
     <div style="position: absolute; left: 0px; top: 250px; z-index: 0; " class="composited">
         <div class="inline"></div>
-        <img style="position: absolute; left: 50px; top: 50px; z-index: -1;">
+        <img class="composited" style="position: absolute; left: 50px; top: 50px; z-index: -1;">
         <img style="position: absolute; left: 400px; top: 150px; z-index: 0;" class="to-hidden">
     </div>
 

Modified: trunk/LayoutTests/compositing/geometry/bounds-ignores-hidden-expected.txt (246016 => 246017)


--- trunk/LayoutTests/compositing/geometry/bounds-ignores-hidden-expected.txt	2019-06-01 21:37:49 UTC (rev 246016)
+++ trunk/LayoutTests/compositing/geometry/bounds-ignores-hidden-expected.txt	2019-06-01 21:40:04 UTC (rev 246017)
@@ -8,18 +8,15 @@
       (contentsOpaque 1)
       (children 1
         (GraphicsLayer
-          (offsetFromRenderer width=10 height=10)
-          (position 10.00 10.00)
-          (anchor -0.20 -0.20)
-          (bounds 50.00 50.00)
-          (contentsOpaque 1)
-          (drawsContent 1)
-          (children 1
+          (children 2
             (GraphicsLayer
-              (offsetFromRenderer width=10 height=10)
+              (position 10.00 10.00)
               (bounds 50.00 50.00)
+              (contentsOpaque 1)
               (drawsContent 1)
             )
+            (GraphicsLayer
+            )
           )
         )
       )

Modified: trunk/LayoutTests/compositing/geometry/bounds-ignores-hidden.html (246016 => 246017)


--- trunk/LayoutTests/compositing/geometry/bounds-ignores-hidden.html	2019-06-01 21:37:49 UTC (rev 246016)
+++ trunk/LayoutTests/compositing/geometry/bounds-ignores-hidden.html	2019-06-01 21:40:04 UTC (rev 246017)
@@ -1,6 +1,6 @@
 <style>
   .composited {
-    -webkit-transform: translateZ(0);
+    transform: translateZ(0);
   }
   
   img {
@@ -23,7 +23,7 @@
 </script>
 <body>
     <div style="position: absolute; left: 0px; top: 0px; z-index: 106; " class="composited">
-        <img style="position: absolute; left: 10px; top: 10px; z-index: -2;">
+        <img class="composited" style="position: absolute; left: 10px; top: 10px; z-index: -2;">
         <img style="position: absolute; left: 44940px; top: 15013px; z-index: 0; visibility: hidden;">
     </div>
 <pre id="layers">Layer tree goes here in DRT</pre>

Added: trunk/LayoutTests/compositing/layer-creation/composited-negative-z-subtree-expected.txt (0 => 246017)


--- trunk/LayoutTests/compositing/layer-creation/composited-negative-z-subtree-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/compositing/layer-creation/composited-negative-z-subtree-expected.txt	2019-06-01 21:40:04 UTC (rev 246017)
@@ -0,0 +1,29 @@
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (children 1
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 302.00 302.00)
+          (drawsContent 1)
+          (children 2
+            (GraphicsLayer
+              (position 23.00 23.00)
+              (bounds 100.00 100.00)
+              (contentsOpaque 1)
+            )
+            (GraphicsLayer
+              (bounds 302.00 302.00)
+              (drawsContent 1)
+            )
+          )
+        )
+      )
+    )
+  )
+)
+

Added: trunk/LayoutTests/compositing/layer-creation/composited-negative-z-subtree.html (0 => 246017)


--- trunk/LayoutTests/compositing/layer-creation/composited-negative-z-subtree.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/layer-creation/composited-negative-z-subtree.html	2019-06-01 21:40:04 UTC (rev 246017)
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>Tests that a composited layer down in the subtree of a negative z-index child triggers a foreground layer</title>
+    <style>
+        .container {
+            width: 300px;
+            height: 300px;
+            border: 1px solid black;
+            position: relative;
+            z-index: 0;
+        }
+        
+        .composited {
+            transform: translateZ(0);
+            background-color: orange;
+            width: 100px;
+            height: 100px;
+        }
+        
+        .negativez {
+            position: relative;
+            z-index: -1;
+            padding: 10px;
+            margin: 10px;
+            border: 2px solid gray;
+        }
+        
+        .contents {
+            margin: -80px 22px;
+            background-color: green;
+            width: 100px;
+            height: 100px;
+        }
+    </style>
+    <script>
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        window.addEventListener('load', () => {
+            if (window.testRunner)
+                document.getElementById('layers').innerText = window.internals.layerTreeAsText(document);
+        }, false);
+    </script>
+</head>
+<body>
+    <div class="container">
+        <div class="negativez child">
+            <div class="composited child"></div>
+        </div>
+        <div class="contents"></div>
+    </div>
+<pre id="layers"></pre>
+</body>
+</html>

Modified: trunk/LayoutTests/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt (246016 => 246017)


--- trunk/LayoutTests/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt	2019-06-01 21:37:49 UTC (rev 246016)
+++ trunk/LayoutTests/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt	2019-06-01 21:40:04 UTC (rev 246017)
@@ -38,8 +38,17 @@
                     GraphicsLayerPaintOverflowContents
                     GraphicsLayerPaintCompositedScroll
                     )
-                  (children 1
+                  (children 2
                     (GraphicsLayer
+                      (position 30.00 50.00)
+                      (bounds 100.00 100.00)
+                      (contentsOpaque 1)
+                      (paintingPhases
+                        GraphicsLayerPaintBackground
+                        GraphicsLayerPaintForeground
+                        )
+                    )
+                    (GraphicsLayer
                       (offsetFromRenderer width=1 height=1)
                       (bounds 305.00 1020.00)
                       (drawsContent 1)

Modified: trunk/LayoutTests/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases.html (246016 => 246017)


--- trunk/LayoutTests/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases.html	2019-06-01 21:37:49 UTC (rev 246016)
+++ trunk/LayoutTests/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases.html	2019-06-01 21:40:04 UTC (rev 246017)
@@ -23,6 +23,7 @@
             width: 100px;
             height: 100px;
             background-color: blue;
+            transform: translateZ(0);
         }
     </style>
     <script>

Modified: trunk/LayoutTests/platform/ios-wk2/compositing/geometry/bounds-ignores-hidden-dynamic-negzindex-expected.txt (246016 => 246017)


--- trunk/LayoutTests/platform/ios-wk2/compositing/geometry/bounds-ignores-hidden-dynamic-negzindex-expected.txt	2019-06-01 21:37:49 UTC (rev 246016)
+++ trunk/LayoutTests/platform/ios-wk2/compositing/geometry/bounds-ignores-hidden-dynamic-negzindex-expected.txt	2019-06-01 21:40:04 UTC (rev 246017)
@@ -12,8 +12,14 @@
           (anchor 0.10 0.20)
           (bounds 500.00 250.00)
           (drawsContent 1)
-          (children 1
+          (children 2
             (GraphicsLayer
+              (position 50.00 50.00)
+              (bounds 100.00 100.00)
+              (contentsOpaque 1)
+              (drawsContent 1)
+            )
+            (GraphicsLayer
               (bounds 500.00 250.00)
               (drawsContent 1)
             )
@@ -21,14 +27,19 @@
         )
         (GraphicsLayer
           (position 0.00 250.00)
-          (anchor 0.33 0.33)
-          (bounds 150.00 150.00)
+          (bounds 100.00 100.00)
           (drawsContent 1)
-          (children 1
+          (children 2
             (GraphicsLayer
-              (bounds 150.00 150.00)
+              (position 50.00 50.00)
+              (bounds 100.00 100.00)
+              (contentsOpaque 1)
               (drawsContent 1)
             )
+            (GraphicsLayer
+              (bounds 100.00 100.00)
+              (drawsContent 1)
+            )
           )
         )
         (GraphicsLayer

Modified: trunk/LayoutTests/platform/ios-wk2/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt (246016 => 246017)


--- trunk/LayoutTests/platform/ios-wk2/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt	2019-06-01 21:37:49 UTC (rev 246016)
+++ trunk/LayoutTests/platform/ios-wk2/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt	2019-06-01 21:40:04 UTC (rev 246017)
@@ -38,8 +38,17 @@
                     GraphicsLayerPaintOverflowContents
                     GraphicsLayerPaintCompositedScroll
                     )
-                  (children 1
+                  (children 2
                     (GraphicsLayer
+                      (position 30.00 50.00)
+                      (bounds 100.00 100.00)
+                      (contentsOpaque 1)
+                      (paintingPhases
+                        GraphicsLayerPaintBackground
+                        GraphicsLayerPaintForeground
+                        )
+                    )
+                    (GraphicsLayer
                       (offsetFromRenderer width=1 height=1)
                       (bounds 320.00 1020.00)
                       (drawsContent 1)

Modified: trunk/LayoutTests/platform/mac-wk1/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt (246016 => 246017)


--- trunk/LayoutTests/platform/mac-wk1/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt	2019-06-01 21:37:49 UTC (rev 246016)
+++ trunk/LayoutTests/platform/mac-wk1/compositing/overflow/stacking-context-composited-scroller-with-foreground-paint-phases-expected.txt	2019-06-01 21:40:04 UTC (rev 246017)
@@ -1,2 +1,60 @@
 Scrolled contents
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (paintingPhases
+    GraphicsLayerPaintBackground
+    GraphicsLayerPaintForeground
+    )
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (paintingPhases
+        GraphicsLayerPaintBackground
+        GraphicsLayerPaintForeground
+        )
+      (children 1
+        (GraphicsLayer
+          (position 8.00 8.00)
+          (bounds 322.00 322.00)
+          (drawsContent 1)
+          (paintingPhases
+            GraphicsLayerPaintBackground
+            )
+          (children 1
+            (GraphicsLayer
+              (offsetFromRenderer width=1 height=1)
+              (position 1.00 1.00)
+              (bounds 305.00 305.00)
+              (paintingPhases
+                GraphicsLayerPaintBackground
+                GraphicsLayerPaintForeground
+                )
+              (children 2
+                (GraphicsLayer
+                  (position 30.00 50.00)
+                  (bounds 100.00 100.00)
+                  (contentsOpaque 1)
+                  (paintingPhases
+                    GraphicsLayerPaintBackground
+                    GraphicsLayerPaintForeground
+                    )
+                )
+                (GraphicsLayer
+                  (offsetFromRenderer width=1 height=1)
+                  (bounds 305.00 305.00)
+                  (drawsContent 1)
+                  (paintingPhases
+                    GraphicsLayerPaintForeground
+                    )
+                )
+              )
+            )
+          )
+        )
+      )
+    )
+  )
+)
 

Modified: trunk/Source/WebCore/ChangeLog (246016 => 246017)


--- trunk/Source/WebCore/ChangeLog	2019-06-01 21:37:49 UTC (rev 246016)
+++ trunk/Source/WebCore/ChangeLog	2019-06-01 21:40:04 UTC (rev 246017)
@@ -1,3 +1,26 @@
+2019-06-01  Simon Fraser  <[email protected]>
+
+        Non-composited negative z-order children should not trigger creation of a foreground layer
+        https://bugs.webkit.org/show_bug.cgi?id=198455
+
+        Reviewed by Sam Weinig.
+
+        The existing code triggered creation of a foreground layer on RenderLayerBacking when
+        the negative z-order list was non-empty. This isn't necessary; we can paint the negative
+        z-order children just fine.
+
+        We only need a foreground layer when the negative z-order layers are composited or
+        have composited descendants.
+
+        This will reduce backing store memory use in some cases.
+
+        Test: compositing/layer-creation/composited-negative-z-subtree.html
+
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::computeCompositingRequirements):
+        (WebCore::RenderLayerCompositor::updateBackingAndHierarchy):
+        (WebCore::RenderLayerCompositor::needsContentsCompositingLayer const):
+
 2019-06-01  Andy Estes  <[email protected]>
 
         [Apple Pay] Every PaymentCoordinator client should explicitly decide whether they support unrestricted Apple Pay

Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (246016 => 246017)


--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2019-06-01 21:37:49 UTC (rev 246016)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2019-06-01 21:40:04 UTC (rev 246017)
@@ -978,7 +978,6 @@
         // 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) {
-            // make layer compositing
             layer.setIndirectCompositingReason(IndirectCompositingReason::BackgroundLayer);
             layerWillComposite();
         }
@@ -1250,7 +1249,7 @@
 #if !ASSERT_DISABLED
     LayerListMutationDetector mutationChecker(layer);
 #endif
-    
+
     auto appendForegroundLayerIfNecessary = [&] {
         // If a negative z-order child is compositing, we get a foreground layer which needs to get parented.
         if (layer.negativeZOrderLayers().size()) {
@@ -3240,11 +3239,16 @@
     return renderer.animation().isRunningAnimationOnRenderer(renderer, CSSPropertyTransform);
 }
 
-// If an element has negative z-index children, those children render in front of the 
+// If an element has composited negative z-index children, those children render in front of the
 // layer background, so we need an extra 'contents' layer for the foreground of the layer object.
 bool RenderLayerCompositor::needsContentsCompositingLayer(const RenderLayer& layer) const
 {
-    return layer.hasNegativeZOrderLayers();
+    for (auto* layer : layer.negativeZOrderLayers()) {
+        if (layer->isComposited() || layer->hasCompositingDescendant())
+            return true;
+    }
+
+    return false;
 }
 
 bool RenderLayerCompositor::requiresScrollLayer(RootLayerAttachment attachment) const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to