Backdrop Filter should not be visible if element has visibility:hidden
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Apr 2016 01:48:41 +0000 (01:48 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Apr 2016 01:48:41 +0000 (01:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=149318
<rdar://problem/22749780>

Reviewed by Simon Fraser.

Source/WebCore:

Make sure that backdrop filter layers take note of when
the contents are visible or not.

Tests: css3/filters/backdrop/backdrop-with-visibility-hidden-changing.html
       css3/filters/backdrop/backdrop-with-visibility-hidden.html
       css3/filters/backdrop/backdrop-with-visibility-hidden-2.html

* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::updateContentsVisibility): Tell the backdrop layer about the
change if there is one.
(WebCore::GraphicsLayerCA::updateBackdropFilters): When we update filters, make
sure to check the contents visibility.
(WebCore::dumpInnerLayer): Output "hidden" if the layer is set as such.
* platform/graphics/ca/PlatformCALayer.h: Add an isHidden method.
* platform/graphics/ca/cocoa/PlatformCALayerCocoa.h:
* platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:
(PlatformCALayerCocoa::isHidden): Call into CALayer isHidden.

Source/WebKit2:

Add the isHidden method to PlatformCALayerRemote.

* WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
(WebKit::PlatformCALayerRemote::isHidden):
* WebProcess/WebPage/mac/PlatformCALayerRemote.h:

LayoutTests:

Three tests that check if a backdrop filter should be visible when
its owning element is visibility hidden.

* css3/filters/backdrop/backdrop-with-visibility-hidden-changing-expected.txt: Added.
* css3/filters/backdrop/backdrop-with-visibility-hidden-changing.html: Added.
* css3/filters/backdrop/backdrop-with-visibility-hidden-expected.txt: Added.
* css3/filters/backdrop/backdrop-with-visibility-hidden.html: Added.
* css3/filters/backdrop/backdrop-with-visibility-hidden-2.html: Added.
* css3/filters/backdrop/backdrop-with-visibility-hidden-2-expected.html: Added.

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

15 files changed:
LayoutTests/ChangeLog
LayoutTests/css3/filters/backdrop/backdrop-with-visibility-hidden-2-expected.html [new file with mode: 0644]
LayoutTests/css3/filters/backdrop/backdrop-with-visibility-hidden-2.html [new file with mode: 0644]
LayoutTests/css3/filters/backdrop/backdrop-with-visibility-hidden-changing-expected.txt [new file with mode: 0644]
LayoutTests/css3/filters/backdrop/backdrop-with-visibility-hidden-changing.html [new file with mode: 0644]
LayoutTests/css3/filters/backdrop/backdrop-with-visibility-hidden-expected.txt [new file with mode: 0644]
LayoutTests/css3/filters/backdrop/backdrop-with-visibility-hidden.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
Source/WebCore/platform/graphics/ca/PlatformCALayer.h
Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.h
Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp
Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h

index 0fd3f47..72a414d 100644 (file)
@@ -1,3 +1,21 @@
+2016-04-21  Dean Jackson  <dino@apple.com>
+
+        Backdrop Filter should not be visible if element has visibility:hidden
+        https://bugs.webkit.org/show_bug.cgi?id=149318
+        <rdar://problem/22749780>
+
+        Reviewed by Simon Fraser.
+
+        Three tests that check if a backdrop filter should be visible when
+        its owning element is visibility hidden.
+
+        * css3/filters/backdrop/backdrop-with-visibility-hidden-changing-expected.txt: Added.
+        * css3/filters/backdrop/backdrop-with-visibility-hidden-changing.html: Added.
+        * css3/filters/backdrop/backdrop-with-visibility-hidden-expected.txt: Added.
+        * css3/filters/backdrop/backdrop-with-visibility-hidden.html: Added.
+        * css3/filters/backdrop/backdrop-with-visibility-hidden-2.html: Added.
+        * css3/filters/backdrop/backdrop-with-visibility-hidden-2-expected.html: Added.
+
 2016-04-21  Brady Eidson  <beidson@apple.com>
 
         Modern IDB (Workers): Get the IDBConnectionProxy from the Document to the WorkerGlobalScope.
diff --git a/LayoutTests/css3/filters/backdrop/backdrop-with-visibility-hidden-2-expected.html b/LayoutTests/css3/filters/backdrop/backdrop-with-visibility-hidden-2-expected.html
new file mode 100644 (file)
index 0000000..59871e7
--- /dev/null
@@ -0,0 +1,20 @@
+<title>This tests that an element with visibility hidden does not show its backdrop filter.</title>
+<style>
+.container {
+    width: 200px;
+    height: 200px;
+    background: blue;
+    margin: 50px;
+}
+.top {
+    width: 400px;
+    height: 50px;
+    position: absolute;
+    left: 0;
+    top: 150px;
+    border: 1px solid red;
+    visibility: hidden;
+}
+</style>
+<body>
+<div class="container"><div class="top"></div></div>
diff --git a/LayoutTests/css3/filters/backdrop/backdrop-with-visibility-hidden-2.html b/LayoutTests/css3/filters/backdrop/backdrop-with-visibility-hidden-2.html
new file mode 100644 (file)
index 0000000..799e50f
--- /dev/null
@@ -0,0 +1,21 @@
+<title>This tests that an element with visibility hidden does not show its backdrop filter.</title>
+<style>
+.container {
+    width: 200px;
+    height: 200px;
+    background: blue;
+    margin: 50px;
+}
+.top {
+    width: 400px;
+    height: 50px;
+    position: absolute;
+    left: 0;
+    top: 150px;
+    border: 1px solid red;
+    -webkit-backdrop-filter: blur(50px);
+    visibility: hidden;
+}
+</style>
+<body>
+<div class="container"><div class="top"></div></div>
diff --git a/LayoutTests/css3/filters/backdrop/backdrop-with-visibility-hidden-changing-expected.txt b/LayoutTests/css3/filters/backdrop/backdrop-with-visibility-hidden-changing-expected.txt
new file mode 100644 (file)
index 0000000..32d7be5
--- /dev/null
@@ -0,0 +1,61 @@
+Dump when filter is visible:
+(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 0.00 150.00)
+          (bounds 402.00 52.00)
+          (drawsContent 1)
+          (structural layer 201.00, 176.00 402.00 x 52.00)
+          (backdrop layer 0.00, 0.00 402.00 x 52.00)
+        )
+      )
+    )
+  )
+)
+Dump when filter is hidden:
+(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 0.00 150.00)
+          (bounds 402.00 52.00)
+          (contentsVisible 0)
+          (structural layer 201.00, 176.00 402.00 x 52.00)
+          (backdrop layer 0.00, 0.00 402.00 x 52.00 hidden)
+        )
+      )
+    )
+  )
+)
+Dump when filter is visible again:
+(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 0.00 150.00)
+          (bounds 402.00 52.00)
+          (drawsContent 1)
+          (structural layer 201.00, 176.00 402.00 x 52.00)
+          (backdrop layer 0.00, 0.00 402.00 x 52.00)
+        )
+      )
+    )
+  )
+)
+
diff --git a/LayoutTests/css3/filters/backdrop/backdrop-with-visibility-hidden-changing.html b/LayoutTests/css3/filters/backdrop/backdrop-with-visibility-hidden-changing.html
new file mode 100644 (file)
index 0000000..f9eda59
--- /dev/null
@@ -0,0 +1,64 @@
+<title>This tests that an element with visibility hidden does not show its backdrop filter.</title>
+<style>
+.container {
+    width: 200px;
+    height: 200px;
+    background: blue;
+    margin: 50px;
+}
+.top {
+    width: 400px;
+    height: 50px;
+    position: absolute;
+    left: 0;
+    top: 150px;
+    border: 1px solid red;
+    -webkit-backdrop-filter: blur(50px);
+}
+</style>
+<script>
+    var dump1, dump2, dump3;
+
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+    }
+
+    function getLayerDump() {
+        if (window.internals)
+            return internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_CONTENT_LAYERS);
+        return "";
+    }
+
+    function step1() {
+        dump1 = getLayerDump();
+        var topElement = document.querySelector(".top");
+        topElement.style.visibility = "hidden";
+        setTimeout(step2, 0);
+    }
+
+    function step2() {
+        dump2 = getLayerDump();
+        var topElement = document.querySelector(".top");
+        topElement.style.visibility = "visible";
+        setTimeout(step3, 0);
+    }
+
+    function step3() {
+        dump3 = getLayerDump();
+        document.getElementById("result1").innerText = "Dump when filter is visible:\n" + dump1;
+        document.getElementById("result2").innerText = "Dump when filter is hidden:\n" + dump2;
+        document.getElementById("result3").innerText = "Dump when filter is visible again:\n" + dump3;
+        if (window.testRunner)
+            testRunner.notifyDone();
+    }
+
+
+    window.addEventListener("load", step1, false);
+</script>
+</head>
+<body>
+<div class="container"><div class="top"></div></div>
+<pre id="result1"></pre>
+<pre id="result2"></pre>
+<pre id="result3"></pre>
diff --git a/LayoutTests/css3/filters/backdrop/backdrop-with-visibility-hidden-expected.txt b/LayoutTests/css3/filters/backdrop/backdrop-with-visibility-hidden-expected.txt
new file mode 100644 (file)
index 0000000..0629a5a
--- /dev/null
@@ -0,0 +1,20 @@
+(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 0.00 150.00)
+          (bounds 402.00 52.00)
+          (contentsVisible 0)
+          (structural layer 201.00, 176.00 402.00 x 52.00)
+          (backdrop layer 0.00, 0.00 402.00 x 52.00 hidden)
+        )
+      )
+    )
+  )
+)
+
diff --git a/LayoutTests/css3/filters/backdrop/backdrop-with-visibility-hidden.html b/LayoutTests/css3/filters/backdrop/backdrop-with-visibility-hidden.html
new file mode 100644 (file)
index 0000000..e0eda58
--- /dev/null
@@ -0,0 +1,33 @@
+<title>This tests that an element with visibility hidden does not show its backdrop filter.</title>
+<style>
+.container {
+    width: 200px;
+    height: 200px;
+    background: blue;
+    margin: 50px;
+}
+.top {
+    width: 400px;
+    height: 50px;
+    position: absolute;
+    left: 0;
+    top: 150px;
+    border: 1px solid red;
+    -webkit-backdrop-filter: blur(50px);
+    visibility: hidden;
+}
+</style>
+<script>
+    if (window.testRunner)
+        testRunner.dumpAsText();
+
+    function dumpLayers() {
+        if (window.internals)
+            document.getElementById("result").innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_CONTENT_LAYERS)
+    }
+    window.addEventListener("load", dumpLayers, false);
+</script>
+</head>
+<body>
+<div class="container"><div class="top"></div></div>
+<pre id="result"></pre>
index cf631d9..3194a18 100644 (file)
@@ -1,3 +1,29 @@
+2016-04-21  Dean Jackson  <dino@apple.com>
+
+        Backdrop Filter should not be visible if element has visibility:hidden
+        https://bugs.webkit.org/show_bug.cgi?id=149318
+        <rdar://problem/22749780>
+
+        Reviewed by Simon Fraser.
+
+        Make sure that backdrop filter layers take note of when
+        the contents are visible or not.
+
+        Tests: css3/filters/backdrop/backdrop-with-visibility-hidden-changing.html
+               css3/filters/backdrop/backdrop-with-visibility-hidden.html
+               css3/filters/backdrop/backdrop-with-visibility-hidden-2.html
+
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::updateContentsVisibility): Tell the backdrop layer about the
+        change if there is one.
+        (WebCore::GraphicsLayerCA::updateBackdropFilters): When we update filters, make
+        sure to check the contents visibility.
+        (WebCore::dumpInnerLayer): Output "hidden" if the layer is set as such.
+        * platform/graphics/ca/PlatformCALayer.h: Add an isHidden method.
+        * platform/graphics/ca/cocoa/PlatformCALayerCocoa.h:
+        * platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:
+        (PlatformCALayerCocoa::isHidden): Call into CALayer isHidden.
+
 2016-04-21  Zalan Bujtas  <zalan@apple.com>
 
         RenderVideo should always update the intrinsic size before layout.
index 43a6dea..6a62827 100644 (file)
@@ -1863,6 +1863,9 @@ void GraphicsLayerCA::updateContentsVisibility()
     if (m_contentsVisible) {
         if (m_drawsContent)
             m_layer->setNeedsDisplay();
+
+        if (m_backdropLayer)
+            m_backdropLayer->setHidden(false);
     } else {
         m_layer->setContents(nullptr);
 
@@ -1870,6 +1873,9 @@ void GraphicsLayerCA::updateContentsVisibility()
             for (auto& layer : layerCloneMap->values())
                 layer->setContents(nullptr);
         }
+
+        if (m_backdropLayer)
+            m_backdropLayer->setHidden(true);
     }
 }
 
@@ -1939,6 +1945,8 @@ void GraphicsLayerCA::updateBackdropFilters()
         m_backdropLayer->setAnchorPoint(FloatPoint3D());
         m_backdropLayer->setMasksToBounds(true);
     }
+
+    m_backdropLayer->setHidden(!m_contentsVisible);
     m_backdropLayer->setFilters(m_backdropFilters);
 }
 
@@ -3353,7 +3361,10 @@ static void dumpInnerLayer(TextStream& textStream, String label, PlatformCALayer
     if (behavior & LayerTreeAsTextDebug)
         textStream << "id=" << layer->layerID() << " ";
     textStream << layer->position().x() << ", " << layer->position().y()
-        << " " << layer->bounds().width() << " x " << layer->bounds().height() << ")\n";
+        << " " << layer->bounds().width() << " x " << layer->bounds().height();
+    if (layer->isHidden())
+        textStream << " hidden";
+    textStream << ")\n";
 }
 
 void GraphicsLayerCA::dumpAdditionalProperties(TextStream& textStream, int indent, LayerTreeAsTextBehavior behavior) const
index 3de642d..970fc00 100644 (file)
@@ -155,6 +155,7 @@ public:
     virtual TransformationMatrix sublayerTransform() const = 0;
     virtual void setSublayerTransform(const TransformationMatrix&) = 0;
 
+    virtual bool isHidden() const = 0;
     virtual void setHidden(bool) = 0;
 
     virtual bool geometryFlipped() const = 0;
index 73a2818..c5ca0dd 100644 (file)
@@ -87,6 +87,7 @@ public:
     TransformationMatrix sublayerTransform() const override;
     void setSublayerTransform(const TransformationMatrix&) override;
 
+    bool isHidden() const override;
     void setHidden(bool) override;
 
     void setBackingStoreAttached(bool) override;
index 29238f3..a05f4d2 100644 (file)
@@ -604,6 +604,11 @@ void PlatformCALayerCocoa::setSublayerTransform(const TransformationMatrix& valu
     END_BLOCK_OBJC_EXCEPTIONS
 }
 
+bool PlatformCALayerCocoa::isHidden() const
+{
+    return [m_layer isHidden];
+}
+
 void PlatformCALayerCocoa::setHidden(bool value)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS
index e299ae5..d5449e5 100644 (file)
@@ -1,3 +1,17 @@
+2016-04-21  Dean Jackson  <dino@apple.com>
+
+        Backdrop Filter should not be visible if element has visibility:hidden
+        https://bugs.webkit.org/show_bug.cgi?id=149318
+        <rdar://problem/22749780>
+
+        Reviewed by Simon Fraser.
+
+        Add the isHidden method to PlatformCALayerRemote.
+
+        * WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
+        (WebKit::PlatformCALayerRemote::isHidden):
+        * WebProcess/WebPage/mac/PlatformCALayerRemote.h:
+
 2016-04-21  Anders Carlsson  <andersca@apple.com>
 
         WKWebView HTML5 AppCache not working
index 7821667..f4a87ba 100644 (file)
@@ -496,6 +496,11 @@ void PlatformCALayerRemote::setSublayerTransform(const TransformationMatrix& val
     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::SublayerTransformChanged);
 }
 
+bool PlatformCALayerRemote::isHidden() const
+{
+    return m_properties.hidden;
+}
+
 void PlatformCALayerRemote::setHidden(bool value)
 {
     m_properties.hidden = value;
index f165206..0a463ba 100644 (file)
@@ -91,6 +91,7 @@ public:
     WebCore::TransformationMatrix sublayerTransform() const override;
     void setSublayerTransform(const WebCore::TransformationMatrix&) override;
 
+    bool isHidden() const override;
     void setHidden(bool) override;
 
     void setBackingStoreAttached(bool) override;