REGRESSION (r183820): webkit.org/blog/ background painting issue on reload, when...
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 May 2015 00:39:35 +0000 (00:39 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 May 2015 00:39:35 +0000 (00:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=145420

Reviewed by Dean Jackson.
Source/WebCore:

After r183820, the media controls no longer had a wrapper that created CSS stacking context.
The media controls on Mac use mix-blend-mode, which causes the compositing code to look for
a stacking context ancestor and make it composited. After this change, it would walk up
to a layer outside of the media element (e.g. the document element's layer), and make
that composited. This triggered bugs with root background painting.

Prevent mix-blend-mode affecting content outside the media elements by having the media element's
layer act as a stacking context.

Test: media/controls-layers.html

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::RenderLayer):
* rendering/RenderLayer.h:

LayoutTests:

Test that dumps compositing layers in a document with media controls.

* media/controls-layers.html: Added.
* platform/mac/media/controls-layers-expected.txt: Added.
* platform/mac-mavericks/media/controls-layers-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@184932 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/media/controls-layers.html [new file with mode: 0644]
LayoutTests/platform/mac-mavericks/media/controls-layers-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/media/controls-layers-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayer.h

index b043c7c..b5577d5 100644 (file)
@@ -1,3 +1,16 @@
+2015-05-27  Simon Fraser  <simon.fraser@apple.com>
+
+        REGRESSION (r183820): webkit.org/blog/ background painting issue on reload, when the page contains videos
+        https://bugs.webkit.org/show_bug.cgi?id=145420
+
+        Reviewed by Dean Jackson.
+        
+        Test that dumps compositing layers in a document with media controls.
+
+        * media/controls-layers.html: Added.
+        * platform/mac/media/controls-layers-expected.txt: Added.
+        * platform/mac-mavericks/media/controls-layers-expected.txt: Added.
+
 2015-05-27  Alexey Proskuryakov  <ap@apple.com>
 
         Update Mac WebKit1 TestExpectations for platform/mac/fast/ruby/ruby-expansion-cjk-2.html
diff --git a/LayoutTests/media/controls-layers.html b/LayoutTests/media/controls-layers.html
new file mode 100644 (file)
index 0000000..b9fe2d5
--- /dev/null
@@ -0,0 +1,47 @@
+<html>
+<head>
+    <script src="media-file.js"></script>
+    <style>
+        body {
+            position: absolute;
+            background-image: linear-gradient(white, silver);
+        }
+    </style>
+    <script>
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        function doTest()
+        {
+            setSrcByTagName("audio", findMediaFile("audio", "content/test"));
+            setSrcByTagName("video", findMediaFile("video", "content/test"));
+
+            if (window.testRunner) {
+                testRunner.waitUntilDone();
+                setTimeout(function() { 
+                    document.body.appendChild(document.createTextNode('FAIL')); 
+                    if (window.testRunner)
+                            testRunner.notifyDone();
+                } , 8000);
+            }
+
+            var count = document.getElementsByTagName('audio').length + document.getElementsByTagName('video').length;
+            document.addEventListener("canplaythrough", function () {
+                if (!--count) {
+                    if (window.testRunner) {
+                        document.getElementById('layers').textContent = window.internals.layerTreeAsText(document);
+                        testRunner.notifyDone();
+                    }
+                }
+            }, true);
+        }
+
+        window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+<video controls></video>
+<audio controls></audio>
+<pre id="layers"></pre>
+</body>
+</html>
diff --git a/LayoutTests/platform/mac-mavericks/media/controls-layers-expected.txt b/LayoutTests/platform/mac-mavericks/media/controls-layers-expected.txt
new file mode 100644 (file)
index 0000000..21d8e5a
--- /dev/null
@@ -0,0 +1,124 @@
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (children 1
+        (GraphicsLayer
+          (bounds 800.00 600.00)
+          (drawsContent 1)
+          (children 4
+            (GraphicsLayer
+              (position 8.00 8.00)
+              (bounds 320.00 240.00)
+              (children 14
+                (GraphicsLayer
+                  (bounds 320.00 240.00)
+                )
+                (GraphicsLayer
+                  (position 0.00 195.00)
+                  (bounds 320.00 45.00)
+                )
+                (GraphicsLayer
+                  (position 0.00 195.00)
+                  (bounds 320.00 45.00)
+                  (drawsContent 1)
+                )
+                (GraphicsLayer
+                  (position 8.00 220.00)
+                  (anchor 0.50 0.53)
+                  (bounds 12.00 15.00)
+                  (blendMode plus-lighter)
+                  (drawsContent 1)
+                )
+                (GraphicsLayer
+                  (position 36.00 219.00)
+                  (anchor 0.50 0.56)
+                  (bounds 16.00 16.00)
+                  (blendMode plus-lighter)
+                  (drawsContent 1)
+                )
+                (GraphicsLayer
+                  (position 60.00 219.00)
+                  (bounds 201.00 17.00)
+                )
+                (GraphicsLayer
+                  (position 68.00 220.00)
+                  (bounds 32.00 14.00)
+                  (opacity 0.45)
+                  (blendMode plus-lighter)
+                  (drawsContent 1)
+                )
+                (GraphicsLayer
+                  (position 110.00 219.00)
+                  (bounds 96.00 17.00)
+                )
+                (GraphicsLayer
+                  (position 110.00 219.00)
+                  (bounds 96.00 17.00)
+                  (blendMode plus-lighter)
+                  (drawsContent 1)
+                )
+                (GraphicsLayer
+                  (position 216.00 220.00)
+                  (bounds 37.00 14.00)
+                  (opacity 0.45)
+                  (blendMode plus-lighter)
+                  (drawsContent 1)
+                )
+                (GraphicsLayer
+                  (position 269.00 215.00)
+                  (bounds 14.00 25.00)
+                )
+                (GraphicsLayer
+                  (position 244.00 235.00)
+                  (opacity 0.00)
+                  (drawsContent 1)
+                )
+                (GraphicsLayer
+                  (position 269.00 220.00)
+                  (anchor 0.50 0.53)
+                  (bounds 14.00 15.00)
+                  (blendMode plus-lighter)
+                  (drawsContent 1)
+                )
+                (GraphicsLayer
+                  (position 299.00 220.00)
+                  (anchor 0.50 0.53)
+                  (bounds 14.00 15.00)
+                  (blendMode plus-lighter)
+                  (drawsContent 1)
+                )
+              )
+            )
+            (GraphicsLayer
+              (position 340.00 228.00)
+              (anchor 0.50 0.53)
+              (bounds 12.00 15.00)
+              (blendMode plus-lighter)
+              (drawsContent 1)
+            )
+            (GraphicsLayer
+              (position 368.00 227.00)
+              (anchor 0.50 0.56)
+              (bounds 16.00 16.00)
+              (blendMode plus-lighter)
+              (drawsContent 1)
+            )
+            (GraphicsLayer
+              (position 510.00 228.00)
+              (anchor 0.50 0.53)
+              (bounds 14.00 15.00)
+              (blendMode plus-lighter)
+              (drawsContent 1)
+            )
+          )
+        )
+      )
+    )
+  )
+)
+
diff --git a/LayoutTests/platform/mac/media/controls-layers-expected.txt b/LayoutTests/platform/mac/media/controls-layers-expected.txt
new file mode 100644 (file)
index 0000000..7aca7de
--- /dev/null
@@ -0,0 +1,179 @@
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (children 1
+        (GraphicsLayer
+          (bounds 800.00 600.00)
+          (drawsContent 1)
+          (children 22
+            (GraphicsLayer
+              (position 8.00 8.00)
+              (bounds 320.00 240.00)
+            )
+            (GraphicsLayer
+              (position 8.00 8.00)
+              (bounds 320.00 240.00)
+            )
+            (GraphicsLayer
+              (position 8.00 203.00)
+              (bounds 320.00 45.00)
+            )
+            (GraphicsLayer
+              (position 8.00 203.00)
+              (bounds 320.00 45.00)
+              (children 2
+                (GraphicsLayer
+                  (bounds 320.00 45.00)
+                )
+                (GraphicsLayer
+                  (bounds 320.00 45.00)
+                  (blendMode lighten)
+                  (contentsOpaque 1)
+                )
+              )
+            )
+            (GraphicsLayer
+              (position 16.00 228.00)
+              (anchor 0.50 0.53)
+              (bounds 12.00 15.00)
+              (blendMode plus-lighter)
+              (drawsContent 1)
+            )
+            (GraphicsLayer
+              (position 44.00 227.00)
+              (anchor 0.50 0.56)
+              (bounds 16.00 16.00)
+              (blendMode plus-lighter)
+              (drawsContent 1)
+            )
+            (GraphicsLayer
+              (position 68.00 227.00)
+              (bounds 201.00 17.00)
+            )
+            (GraphicsLayer
+              (position 76.00 228.00)
+              (bounds 32.00 14.00)
+              (opacity 0.45)
+              (blendMode plus-lighter)
+              (drawsContent 1)
+            )
+            (GraphicsLayer
+              (position 118.00 227.00)
+              (bounds 96.00 17.00)
+            )
+            (GraphicsLayer
+              (position 118.00 227.00)
+              (bounds 96.00 17.00)
+              (blendMode plus-lighter)
+              (drawsContent 1)
+            )
+            (GraphicsLayer
+              (position 224.00 228.00)
+              (bounds 37.00 14.00)
+              (opacity 0.45)
+              (blendMode plus-lighter)
+              (drawsContent 1)
+            )
+            (GraphicsLayer
+              (position 277.00 223.00)
+              (bounds 14.00 25.00)
+            )
+            (GraphicsLayer
+              (position 252.00 243.00)
+              (opacity 0.00)
+              (drawsContent 1)
+              (children 1
+                (GraphicsLayer
+                  (bounds 63.00 0.00)
+                  (children 1
+                    (GraphicsLayer
+                      (drawsContent 1)
+                    )
+                  )
+                )
+              )
+            )
+            (GraphicsLayer
+              (position 277.00 228.00)
+              (anchor 0.50 0.53)
+              (bounds 14.00 15.00)
+              (blendMode plus-lighter)
+              (drawsContent 1)
+            )
+            (GraphicsLayer
+              (position 307.00 228.00)
+              (anchor 0.50 0.53)
+              (bounds 14.00 15.00)
+              (blendMode plus-lighter)
+              (drawsContent 1)
+            )
+            (GraphicsLayer
+              (position 332.00 203.00)
+              (bounds 200.00 45.00)
+              (children 2
+                (GraphicsLayer
+                  (bounds 200.00 45.00)
+                )
+                (GraphicsLayer
+                  (bounds 200.00 45.00)
+                  (blendMode lighten)
+                  (contentsOpaque 1)
+                )
+              )
+            )
+            (GraphicsLayer
+              (position 340.00 228.00)
+              (anchor 0.50 0.53)
+              (bounds 12.00 15.00)
+              (blendMode plus-lighter)
+              (drawsContent 1)
+            )
+            (GraphicsLayer
+              (position 368.00 227.00)
+              (anchor 0.50 0.56)
+              (bounds 16.00 16.00)
+              (blendMode plus-lighter)
+              (drawsContent 1)
+            )
+            (GraphicsLayer
+              (position 392.00 235.00)
+              (bounds 0.00 1.00)
+            )
+            (GraphicsLayer
+              (position 510.00 223.00)
+              (bounds 14.00 25.00)
+            )
+            (GraphicsLayer
+              (position 485.00 243.00)
+              (opacity 0.00)
+              (drawsContent 1)
+              (children 1
+                (GraphicsLayer
+                  (bounds 63.00 0.00)
+                  (children 1
+                    (GraphicsLayer
+                      (drawsContent 1)
+                    )
+                  )
+                )
+              )
+            )
+            (GraphicsLayer
+              (position 510.00 228.00)
+              (anchor 0.50 0.53)
+              (bounds 14.00 15.00)
+              (blendMode plus-lighter)
+              (drawsContent 1)
+            )
+          )
+        )
+      )
+    )
+  )
+)
+
index fc6257f..45bba2e 100644 (file)
@@ -1,3 +1,25 @@
+2015-05-27  Simon Fraser  <simon.fraser@apple.com>
+
+        REGRESSION (r183820): webkit.org/blog/ background painting issue on reload, when the page contains videos
+        https://bugs.webkit.org/show_bug.cgi?id=145420
+
+        Reviewed by Dean Jackson.
+
+        After r183820, the media controls no longer had a wrapper that created CSS stacking context.
+        The media controls on Mac use mix-blend-mode, which causes the compositing code to look for
+        a stacking context ancestor and make it composited. After this change, it would walk up
+        to a layer outside of the media element (e.g. the document element's layer), and make
+        that composited. This triggered bugs with root background painting.
+
+        Prevent mix-blend-mode affecting content outside the media elements by having the media element's
+        layer act as a stacking context.
+
+        Test: media/controls-layers.html
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::RenderLayer):
+        * rendering/RenderLayer.h:
+
 2015-05-27  Andreas Kling  <akling@apple.com>
 
         [WK2] Local storage areas should get torn down when they have no remaining references.
index c47a1eb..cc6263d 100644 (file)
@@ -261,7 +261,9 @@ void makeMatrixRenderable(TransformationMatrix& matrix, bool has3DRendering)
 }
 
 RenderLayer::RenderLayer(RenderLayerModelObject& rendererLayerModelObject)
-    : m_inResizeMode(false)
+    : m_isRootLayer(rendererLayerModelObject.isRenderView())
+    , m_forcedStackingContext(rendererLayerModelObject.isMedia())
+    , m_inResizeMode(false)
     , m_scrollDimensionsDirty(true)
     , m_normalFlowListDirty(true)
     , m_hasSelfPaintingLayerDescendant(false)
@@ -270,7 +272,6 @@ RenderLayer::RenderLayer(RenderLayerModelObject& rendererLayerModelObject)
     , m_hasOutOfFlowPositionedDescendantDirty(true)
     , m_needsCompositedScrolling(false)
     , m_descendantsAreContiguousInStackingOrder(false)
-    , m_isRootLayer(rendererLayerModelObject.isRenderView())
     , m_usedTransparency(false)
     , m_paintingInsideReflection(false)
     , m_inOverflowRelayout(false)
index 6865322..f52118a 100644 (file)
@@ -702,7 +702,7 @@ private:
 
     // Non-auto z-index always implies stacking context here, because StyleResolver::adjustRenderStyle already adjusts z-index
     // based on positioning and other criteria.
-    bool isStackingContext(const RenderStyle* style) const { return !style->hasAutoZIndex() || isRootLayer(); }
+    bool isStackingContext(const RenderStyle* style) const { return !style->hasAutoZIndex() || isRootLayer() || m_forcedStackingContext; }
 
     bool isDirtyStackingContainer() const { return m_zOrderListsDirty && isStackingContainer(); }
 
@@ -991,6 +991,9 @@ private:
 private:
     // The bitfields are up here so they will fall into the padding from ScrollableArea on 64-bit.
 
+    const bool m_isRootLayer : 1;
+    const bool m_forcedStackingContext : 1;
+
     // Keeps track of whether the layer is currently resizing, so events can cause resizing to start and stop.
     bool m_inResizeMode : 1;
 
@@ -1019,8 +1022,6 @@ private:
     // able to safely become a stacking context.
     bool m_descendantsAreContiguousInStackingOrder : 1;
 
-    const bool m_isRootLayer : 1;
-
     bool m_usedTransparency : 1; // Tracks whether we need to close a transparent layer, i.e., whether
                                  // we ended up painting this layer or any descendants (and therefore need to
                                  // blend).