Title: [185124] trunk
Revision
185124
Author
[email protected]
Date
2015-06-02 14:35:24 -0700 (Tue, 02 Jun 2015)

Log Message

Backdrop filter is pulling in content from behind the window.
https://bugs.webkit.org/show_bug.cgi?id=145561
rdar://problem/20909309

Reviewed by Simon Fraser.

This patch ensures that the backdrop filter layer is positioned and sized properly.

The backdrop filter layer should take its size and position from its renderer and not
directly from the composited layer.
In certain cases the composited layer's size is expanded to cover items like box shadow or an absolute positioned descendant.
In such cases, we ended up applying the backdrop filter to those areas as well.

Source/WebCore:

Tests: css3/filters/backdrop/backdrop-filter-does-not-size-properly-absolute.html
       css3/filters/backdrop/backdrop-filter-does-not-size-properly-border-and-padding.html

* platform/graphics/GraphicsLayer.h:
(WebCore::GraphicsLayer::setBackdropFiltersRect):
(WebCore::GraphicsLayer::backdropFiltersRect):
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::setBackdropFiltersRect):
(WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers):
(WebCore::GraphicsLayerCA::updateBackdropFilters):
(WebCore::GraphicsLayerCA::updateBackdropFiltersRect):
(WebCore::GraphicsLayerCA::updateContentsRects):
(WebCore::GraphicsLayerCA::updateGeometry): Deleted.
* platform/graphics/ca/GraphicsLayerCA.h:
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateBackdropFiltersGeometry):
(WebCore::RenderLayerBacking::updateGeometry):
* rendering/RenderLayerBacking.h:

LayoutTests:

* css3/filters/backdrop/backdrop-filter-does-not-size-properly-absolute-expected.txt: Added.
* css3/filters/backdrop/backdrop-filter-does-not-size-properly-absolute.html: Added.
* css3/filters/backdrop/backdrop-filter-does-not-size-properly-border-and-padding-expected.txt: Added.
* css3/filters/backdrop/backdrop-filter-does-not-size-properly-border-and-padding.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (185123 => 185124)


--- trunk/LayoutTests/ChangeLog	2015-06-02 21:30:27 UTC (rev 185123)
+++ trunk/LayoutTests/ChangeLog	2015-06-02 21:35:24 UTC (rev 185124)
@@ -1,3 +1,23 @@
+2015-06-02  Zalan Bujtas  <[email protected]>
+
+        Backdrop filter is pulling in content from behind the window.
+        https://bugs.webkit.org/show_bug.cgi?id=145561
+        rdar://problem/20909309
+
+        Reviewed by Simon Fraser.
+
+        This patch ensures that the backdrop filter layer is positioned and sized properly.
+
+        The backdrop filter layer should take its size and position from its renderer and not
+        directly from the composited layer.
+        In certain cases the composited layer's size is expanded to cover items like box shadow or an absolute positioned descendant.
+        In such cases, we ended up applying the backdrop filter to those areas as well.
+
+        * css3/filters/backdrop/backdrop-filter-does-not-size-properly-absolute-expected.txt: Added.
+        * css3/filters/backdrop/backdrop-filter-does-not-size-properly-absolute.html: Added.
+        * css3/filters/backdrop/backdrop-filter-does-not-size-properly-border-and-padding-expected.txt: Added.
+        * css3/filters/backdrop/backdrop-filter-does-not-size-properly-border-and-padding.html: Added.
+
 2015-06-02  Said Abou-Hallawa  <[email protected]>
 
         Fix Mac Mavericks layout test failure following <http://trac.webkit.org/changeset/185096>

Added: trunk/LayoutTests/css3/filters/backdrop/backdrop-filter-does-not-size-properly-absolute-expected.txt (0 => 185124)


--- trunk/LayoutTests/css3/filters/backdrop/backdrop-filter-does-not-size-properly-absolute-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/css3/filters/backdrop/backdrop-filter-does-not-size-properly-absolute-expected.txt	2015-06-02 21:35:24 UTC (rev 185124)
@@ -0,0 +1,21 @@
+foofoobar
+(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 342.00 318.00)
+          (drawsContent 1)
+          (structural layer 179.00, 167.00 342.00 x 318.00)
+          (backdrop layer 0.00, 0.00 100.00 x 200.00)
+        )
+      )
+    )
+  )
+)
+

Added: trunk/LayoutTests/css3/filters/backdrop/backdrop-filter-does-not-size-properly-absolute.html (0 => 185124)


--- trunk/LayoutTests/css3/filters/backdrop/backdrop-filter-does-not-size-properly-absolute.html	                        (rev 0)
+++ trunk/LayoutTests/css3/filters/backdrop/backdrop-filter-does-not-size-properly-absolute.html	2015-06-02 21:35:24 UTC (rev 185124)
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that backdrop filter is sized properly when the compositing layer bounds is different from its renderer's bounds.</title>
+<style>
+    .outer {
+        height: 100px;
+        width: 200px;
+        background-color: rgba(0, 0, 255, 1);
+    }
+
+    .container-background {
+        position: relative;
+        -webkit-backdrop-filter: invert(1);
+        height: 200px;
+        width: 100px;
+    }
+
+    .child {
+	    position: absolute;
+	    left: 300px;
+	    top: 300px;
+    }
+</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>
+<body>
+<div class=outer>
+  <div class=container-background>foo
+    <div class=child>foobar</div>
+  </div>
+</div>
+<pre id=result></pre>
+</body>

Added: trunk/LayoutTests/css3/filters/backdrop/backdrop-filter-does-not-size-properly-border-and-padding-expected.txt (0 => 185124)


--- trunk/LayoutTests/css3/filters/backdrop/backdrop-filter-does-not-size-properly-border-and-padding-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/css3/filters/backdrop/backdrop-filter-does-not-size-properly-border-and-padding-expected.txt	2015-06-02 21:35:24 UTC (rev 185124)
@@ -0,0 +1,21 @@
+foo
+(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 180.00 280.00)
+          (drawsContent 1)
+          (structural layer 98.00, 148.00 180.00 x 280.00)
+          (backdrop layer 40.00, 40.00 100.00 x 200.00)
+        )
+      )
+    )
+  )
+)
+

Added: trunk/LayoutTests/css3/filters/backdrop/backdrop-filter-does-not-size-properly-border-and-padding.html (0 => 185124)


--- trunk/LayoutTests/css3/filters/backdrop/backdrop-filter-does-not-size-properly-border-and-padding.html	                        (rev 0)
+++ trunk/LayoutTests/css3/filters/backdrop/backdrop-filter-does-not-size-properly-border-and-padding.html	2015-06-02 21:35:24 UTC (rev 185124)
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that backdrop filter is sized properly when the compositing layer bounds is different from its renderer's bounds.</title>
+<style>
+    .outer {
+        height: 100px;
+        width: 200px;
+        background-color: rgba(0, 0, 255, 1);
+    }
+
+    .container-background {
+        position: relative;
+        -webkit-backdrop-filter: invert(1);
+        height: 200px;
+        width: 100px;
+        border: 20px solid transparent;
+        padding: 20px;
+    }
+
+</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>
+<body>
+<div class=outer>
+  <div class=container-background>foo
+  </div>
+</div>
+<pre id=result></pre>
+</body>

Modified: trunk/Source/WebCore/ChangeLog (185123 => 185124)


--- trunk/Source/WebCore/ChangeLog	2015-06-02 21:30:27 UTC (rev 185123)
+++ trunk/Source/WebCore/ChangeLog	2015-06-02 21:35:24 UTC (rev 185124)
@@ -1,3 +1,37 @@
+2015-06-02  Zalan Bujtas  <[email protected]>
+
+        Backdrop filter is pulling in content from behind the window.
+        https://bugs.webkit.org/show_bug.cgi?id=145561
+        rdar://problem/20909309
+
+        Reviewed by Simon Fraser.
+
+        This patch ensures that the backdrop filter layer is positioned and sized properly.
+
+        The backdrop filter layer should take its size and position from its renderer and not
+        directly from the composited layer.
+        In certain cases the composited layer's size is expanded to cover items like box shadow or an absolute positioned descendant.
+        In such cases, we ended up applying the backdrop filter to those areas as well.
+
+        Tests: css3/filters/backdrop/backdrop-filter-does-not-size-properly-absolute.html
+               css3/filters/backdrop/backdrop-filter-does-not-size-properly-border-and-padding.html
+
+        * platform/graphics/GraphicsLayer.h:
+        (WebCore::GraphicsLayer::setBackdropFiltersRect):
+        (WebCore::GraphicsLayer::backdropFiltersRect):
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::setBackdropFiltersRect):
+        (WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers):
+        (WebCore::GraphicsLayerCA::updateBackdropFilters):
+        (WebCore::GraphicsLayerCA::updateBackdropFiltersRect):
+        (WebCore::GraphicsLayerCA::updateContentsRects):
+        (WebCore::GraphicsLayerCA::updateGeometry): Deleted.
+        * platform/graphics/ca/GraphicsLayerCA.h:
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::updateBackdropFiltersGeometry):
+        (WebCore::RenderLayerBacking::updateGeometry):
+        * rendering/RenderLayerBacking.h:
+
 2015-06-02  Eric Carlson  <[email protected]>
 
         [Mac] occasional crash in Document::playbackTargetAvailabilityDidChange

Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.h (185123 => 185124)


--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.h	2015-06-02 21:30:27 UTC (rev 185123)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.h	2015-06-02 21:35:24 UTC (rev 185124)
@@ -371,6 +371,9 @@
     const FilterOperations& backdropFilters() const { return m_backdropFilters; }
     virtual bool setBackdropFilters(const FilterOperations& filters) { m_backdropFilters = filters; return true; }
 
+    virtual void setBackdropFiltersRect(const FloatRect& backdropFiltersRect) { m_backdropFiltersRect = backdropFiltersRect; }
+    FloatRect backdropFiltersRect() const { return m_backdropFiltersRect; }
+
 #if ENABLE(CSS_COMPOSITING)
     BlendMode blendMode() const { return m_blendMode; }
     virtual void setBlendMode(BlendMode blendMode) { m_blendMode = blendMode; }
@@ -627,6 +630,7 @@
     FloatRoundedRect m_masksToBoundsRect;
     FloatSize m_contentsTilePhase;
     FloatSize m_contentsTileSize;
+    FloatRect m_backdropFiltersRect;
 
     int m_repaintCount;
     CustomAppearance m_customAppearance;

Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (185123 => 185124)


--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2015-06-02 21:30:27 UTC (rev 185123)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2015-06-02 21:35:24 UTC (rev 185124)
@@ -745,6 +745,15 @@
     return canCompositeFilters;
 }
 
+void GraphicsLayerCA::setBackdropFiltersRect(const FloatRect& backdropFiltersRect)
+{
+    if (backdropFiltersRect == m_backdropFiltersRect)
+        return;
+
+    GraphicsLayer::setBackdropFiltersRect(backdropFiltersRect);
+    noteLayerPropertyChanged(BackdropFiltersRectChanged);
+}
+
 #if ENABLE(CSS_COMPOSITING)
 void GraphicsLayerCA::setBlendMode(BlendMode blendMode)
 {
@@ -1518,6 +1527,9 @@
     if (m_uncommittedChanges & BackdropFiltersChanged)
         updateBackdropFilters();
 
+    if (m_uncommittedChanges & BackdropFiltersRectChanged)
+        updateBackdropFiltersRect();
+
 #if ENABLE(CSS_COMPOSITING)
     if (m_uncommittedChanges & BlendModeChanged)
         updateBlendMode();
@@ -1725,12 +1737,6 @@
     m_layer->setBounds(adjustedBounds);
     m_layer->setAnchorPoint(scaledAnchorPoint);
 
-    if (m_backdropLayer) {
-        m_backdropLayer->setPosition(adjustedPosition);
-        m_backdropLayer->setBounds(adjustedBounds);
-        m_backdropLayer->setAnchorPoint(scaledAnchorPoint);
-    }
-
     if (LayerMap* layerCloneMap = m_layerClones.get()) {
         for (auto& clone : *layerCloneMap) {
             PlatformCALayer* cloneLayer = clone.value.get();
@@ -1865,14 +1871,21 @@
 
     if (!m_backdropLayer) {
         m_backdropLayer = createPlatformCALayer(PlatformCALayer::LayerTypeBackdropLayer, this);
-        m_backdropLayer->setPosition(m_layer->position());
-        m_backdropLayer->setBounds(m_layer->bounds());
-        m_backdropLayer->setAnchorPoint(m_layer->anchorPoint());
+        m_backdropLayer->setAnchorPoint(FloatPoint3D());
         m_backdropLayer->setMasksToBounds(true);
     }
     m_backdropLayer->setFilters(m_backdropFilters);
 }
 
+void GraphicsLayerCA::updateBackdropFiltersRect()
+{
+    if (!m_backdropLayer)
+        return;
+    FloatRect contentBounds(0, 0, m_backdropFiltersRect.width(), m_backdropFiltersRect.height());
+    m_backdropLayer->setBounds(contentBounds);
+    m_backdropLayer->setPosition(m_backdropFiltersRect.location());
+}
+
 #if ENABLE(CSS_COMPOSITING)
 void GraphicsLayerCA::updateBlendMode()
 {
@@ -2259,7 +2272,7 @@
         return;
 
     FloatPoint contentOrigin;
-    FloatRect contentBounds(0, 0, m_contentsRect.width(), m_contentsRect.height());
+    const FloatRect contentBounds(0, 0, m_contentsRect.width(), m_contentsRect.height());
 
     FloatPoint clippingOrigin(m_contentsClippingRect.rect().location());
     FloatRect clippingBounds(FloatPoint(), m_contentsClippingRect.rect().size());

Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h (185123 => 185124)


--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h	2015-06-02 21:30:27 UTC (rev 185123)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h	2015-06-02 21:35:24 UTC (rev 185124)
@@ -103,6 +103,7 @@
     virtual bool filtersCanBeComposited(const FilterOperations&);
 
     WEBCORE_EXPORT virtual bool setBackdropFilters(const FilterOperations&) override;
+    WEBCORE_EXPORT virtual void setBackdropFiltersRect(const FloatRect&) override;
 
 #if ENABLE(CSS_COMPOSITING)
     WEBCORE_EXPORT virtual void setBlendMode(BlendMode) override;
@@ -398,6 +399,7 @@
     void updateOpacityOnLayer();
     void updateFilters();
     void updateBackdropFilters();
+    void updateBackdropFiltersRect();
 
 #if ENABLE(CSS_COMPOSITING)
     void updateBlendMode();
@@ -465,13 +467,14 @@
         CoverageRectChanged =           1LLU << 26,
         FiltersChanged =                1LLU << 27,
         BackdropFiltersChanged =        1LLU << 28,
-        TilingAreaChanged =             1LLU << 29,
-        TilesAdded =                    1LLU << 30,
-        DebugIndicatorsChanged =        1LLU << 31,
-        CustomAppearanceChanged =       1LLU << 32,
-        BlendModeChanged =              1LLU << 33,
-        ShapeChanged =                  1LLU << 34,
-        WindRuleChanged =               1LLU << 35,
+        BackdropFiltersRectChanged =    1LLU << 29,
+        TilingAreaChanged =             1LLU << 30,
+        TilesAdded =                    1LLU << 31,
+        DebugIndicatorsChanged =        1LLU << 32,
+        CustomAppearanceChanged =       1LLU << 33,
+        BlendModeChanged =              1LLU << 34,
+        ShapeChanged =                  1LLU << 35,
+        WindRuleChanged =               1LLU << 36,
     };
     typedef uint64_t LayerChangeFlags;
     enum ScheduleFlushOrNot { ScheduleFlush, DontScheduleFlush };

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (185123 => 185124)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2015-06-02 21:30:27 UTC (rev 185123)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2015-06-02 21:35:24 UTC (rev 185124)
@@ -390,6 +390,13 @@
 {
     m_canCompositeBackdropFilters = m_graphicsLayer->setBackdropFilters(style.backdropFilter());
 }
+
+void RenderLayerBacking::updateBackdropFiltersGeometry()
+{
+    if (!m_canCompositeBackdropFilters)
+        return;
+    m_graphicsLayer->setBackdropFiltersRect(snapRectToDevicePixels(contentsBox(), deviceScaleFactor()));
+}
 #endif
 
 #if ENABLE(CSS_COMPOSITING)
@@ -990,7 +997,9 @@
 
     // If this layer was created just for clipping or to apply perspective, it doesn't need its own backing store.
     setRequiresOwnBackingStore(compositor().requiresOwnBackingStore(m_owningLayer, compAncestor, enclosingRelativeCompositingBounds, ancestorCompositingBounds));
-
+#if ENABLE(FILTERS_LEVEL_2)
+    updateBackdropFiltersGeometry();
+#endif
     updateAfterWidgetResize();
 
     compositor().updateScrollCoordinatedStatus(m_owningLayer);

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.h (185123 => 185124)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.h	2015-06-02 21:30:27 UTC (rev 185123)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.h	2015-06-02 21:35:24 UTC (rev 185124)
@@ -288,6 +288,7 @@
     void updateFilters(const RenderStyle&);
 #if ENABLE(FILTERS_LEVEL_2)
     void updateBackdropFilters(const RenderStyle&);
+    void updateBackdropFiltersGeometry();
 #endif
 #if ENABLE(CSS_COMPOSITING)
     void updateBlendMode(const RenderStyle&);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to