Title: [98735] trunk
Revision
98735
Author
simon.fra...@apple.com
Date
2011-10-28 10:46:38 -0700 (Fri, 28 Oct 2011)

Log Message

Source/WebCore: The HTML5 video element in Safari does not respect "visibility:hidden" CSS property
https://bugs.webkit.org/show_bug.cgi?id=38829

Reviewed by James Robinson.

Make compositing and CSS visibility play nicely together.

The main issue was that an old optimization (see bug 4377) caused
visibility:hidden layers to not appear in the z-order lists, but those
layers could still become composited, but would remain detached. In addition,
composited layers which were visibility:hidden would become visible sometimes.

With this fix, the z-order lists always contain all layers when the page
is in compositing mode. GraphicsLayer is changed to ensure that visibility:hidden
layers show no content, and visible descendants of hidden layers work correctly.

Tests: compositing/visibility/visibility-composited-transforms.html
       compositing/visibility/visibility-composited.html
       compositing/visibility/visibility-image-layers-dynamic.html
       compositing/visibility/visibility-image-layers.html

* platform/graphics/GraphicsLayer.cpp:
(WebCore::GraphicsLayer::GraphicsLayer): Init m_contentsVisible to true.
(WebCore::GraphicsLayer::dumpProperties): Dump m_contentsVisible if not true.
* platform/graphics/GraphicsLayer.h:
(WebCore::GraphicsLayer::contentsAreVisible): Getter for m_contentsVisible.
(WebCore::GraphicsLayer::setContentsVisible): Setter for m_contentsVisible.
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::setContentsVisible): Override setContentsVisible.
(WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers): Handle ContentsVisibilityChanged
flag
(WebCore::GraphicsLayerCA::updateSublayerList): Only parent the m_contentsLayer if the layer
has visible contents.
(WebCore::GraphicsLayerCA::updateContentsVisibility): For bits painted into the layer itself,
we hide it by clearing the backing store.
* platform/graphics/ca/GraphicsLayerCA.h: Removed obsolete comment on the DrawsContentChanged flag,
added ContentsVisibilityChanged flag.
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::updateZOrderLists): If we're in compositing mode, include all layers
in the z-order lists.
(WebCore::RenderLayer::collectLayers): New param to specify whether we need to collect all layers.
* rendering/RenderLayer.h:
(WebCore::RenderLayer::hasVisibleDescendant): Add comment about the need for an assertion in hasVisibleContent()
, and assertion in hasVisibleDescendant().
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateGraphicsLayerGeometry): Call setContentsVisible() on the GraphicsLayer.
(WebCore::RenderLayerBacking::isSimpleContainerCompositingLayer): We can use simple container layers in cases
where visibility:hidden causes layer content to not be drawn.
(WebCore::RenderLayerBacking::hasVisibleNonCompositingDescendants): Renamed from hasNonCompositingDescendants()
because it now also looks at visibility to decide when things are visible.
* rendering/RenderLayerBacking.h: hasNonCompositingDescendants() renamed to hasVisibleNonCompositingDescendants().

LayoutTests: The HTML5 video element in Safari does not respect "visibility:hidden" CSS property
https://bugs.webkit.org/show_bug.cgi?id=38829

Test various configurations of compositing layers and visibility.

Reviewed by James Robinson.

* compositing/visibility/visibility-composited-expected.png: Added.
* compositing/visibility/visibility-composited-transforms-expected.png: Added.
* compositing/visibility/visibility-composited-transforms.html: Added.
* compositing/visibility/visibility-composited.html: Added.
* compositing/visibility/visibility-image-layers-dynamic-expected.txt: Added.
* compositing/visibility/visibility-image-layers-dynamic.html: Added.
* compositing/visibility/visibility-image-layers-expected.png: Added.
* compositing/visibility/visibility-image-layers.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (98734 => 98735)


--- trunk/LayoutTests/ChangeLog	2011-10-28 17:42:59 UTC (rev 98734)
+++ trunk/LayoutTests/ChangeLog	2011-10-28 17:46:38 UTC (rev 98735)
@@ -1,3 +1,21 @@
+2011-10-28  Simon Fraser  <simon.fra...@apple.com>
+
+        The HTML5 video element in Safari does not respect "visibility:hidden" CSS property
+        https://bugs.webkit.org/show_bug.cgi?id=38829
+        
+        Test various configurations of compositing layers and visibility.
+
+        Reviewed by James Robinson.
+
+        * compositing/visibility/visibility-composited-expected.png: Added.
+        * compositing/visibility/visibility-composited-transforms-expected.png: Added.
+        * compositing/visibility/visibility-composited-transforms.html: Added.
+        * compositing/visibility/visibility-composited.html: Added.
+        * compositing/visibility/visibility-image-layers-dynamic-expected.txt: Added.
+        * compositing/visibility/visibility-image-layers-dynamic.html: Added.
+        * compositing/visibility/visibility-image-layers-expected.png: Added.
+        * compositing/visibility/visibility-image-layers.html: Added.
+
 2011-10-28  Erik Arvidsson  <a...@chromium.org>
 
         JS Test Harness: Remove js-test-post-function.js

Added: trunk/LayoutTests/compositing/visibility/visibility-composited-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/compositing/visibility/visibility-composited-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/compositing/visibility/visibility-composited-transforms-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/compositing/visibility/visibility-composited-transforms-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/compositing/visibility/visibility-composited-transforms.html (0 => 98735)


--- trunk/LayoutTests/compositing/visibility/visibility-composited-transforms.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/visibility/visibility-composited-transforms.html	2011-10-28 17:46:38 UTC (rev 98735)
@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+  <style>
+    .container {
+      -webkit-perspective: 500px;
+    }
+    .set {
+      position: absolute;
+      top: 8px;
+    }
+    .box {
+      height: 100px;
+      width: 100px;
+    }
+    
+    .hidden {
+      visibility: hidden;
+    }
+
+    .visible {
+      visibility: visible;
+    }
+
+    .should-be-visible {
+      background-color: green !important;
+    }
+    .composited {
+      -webkit-transform: rotate3d(0, 0, 1, 45deg);
+    }
+    
+    .hidden-indicator {
+      background-color: red;
+    }
+    
+    .intermediate {
+      -webkit-transform: rotate3d(0, 0, 1, -45deg);
+      -webkit-transform-style: preserve-3d;
+      background-color: red;
+    }
+  </style>
+</head>
+<body>
+  <!-- Tests that a transform on a hidden div affects its visible children. -->
+  <!-- You should see a single green box, with no red. -->
+
+  <div class="set">
+    <div class="hidden-indicator box"></div>
+  </div>
+
+  <div class="set">
+    <div class="container">
+      <div class="hidden intermediate">
+        <div class="visible composited box should-be-visible"></div>
+      </div>
+    </div>
+
+  </div>
+</body>
+</html>
Property changes on: trunk/LayoutTests/compositing/visibility/visibility-composited-transforms.html
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/compositing/visibility/visibility-composited.html (0 => 98735)


--- trunk/LayoutTests/compositing/visibility/visibility-composited.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/visibility/visibility-composited.html	2011-10-28 17:46:38 UTC (rev 98735)
@@ -0,0 +1,72 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+  <style>
+    .set {
+      position: absolute;
+      top: 8px;
+    }
+    .box {
+      height: 100px;
+      width: 100px;
+      background-color: blue;
+    }
+    
+    .hidden {
+      visibility: hidden;
+    }
+
+    .container.hidden {
+      outline: 4px solid red;
+    }
+
+    .visible {
+      visibility: visible;
+    }
+    .should-be-hidden {
+      background-color: red !important;
+    }
+    .should-be-visible {
+      background-color: green !important;
+    }
+    .composited {
+      -webkit-transform: translateZ(1px);
+    }
+    
+    .visible-indicator {
+      background-color: green;
+    }
+
+    .hidden-indicator {
+      background-color: red;
+    }
+  </style>
+</head>
+<body>
+  <!-- Tests various configurations of visibility:hidden and visible compositing layers. -->
+  <!-- You should see a green vertical bar, with no red. -->
+  <div class="set">
+    <div class="visible-indicator box"></div>
+    <div class="visible-indicator box"></div>
+    <div class="hidden-indicator box"></div>
+  </div>
+
+  <div class="set">
+    <div class="container">
+      <div class="hidden composited box should-be-hidden">
+      </div>
+    </div>
+
+    <div class="hidden container">
+      <div class="composited box should-be-hidden">
+      </div>
+    </div>
+
+    <div class="hidden container">
+      <div class="visible composited box should-be-visible">
+      </div>
+    </div>
+  </div>
+</body>
+</html>
Property changes on: trunk/LayoutTests/compositing/visibility/visibility-composited.html
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/compositing/visibility/visibility-image-layers-dynamic-expected.txt (0 => 98735)


--- trunk/LayoutTests/compositing/visibility/visibility-image-layers-dynamic-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/compositing/visibility/visibility-image-layers-dynamic-expected.txt	2011-10-28 17:46:38 UTC (rev 98735)
@@ -0,0 +1,139 @@
+
+
+
+Initial
+
+(GraphicsLayer
+  (bounds 785.00 622.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 785.00 622.00)
+      (children 3
+        (GraphicsLayer
+          (position 14.00 6.00)
+          (bounds 757.00 152.00)
+          (children 1
+            (GraphicsLayer
+              (position 20.00 20.00)
+              (bounds 108.00 108.00)
+              (contentsVisible 0)
+            )
+          )
+        )
+        (GraphicsLayer
+          (position 14.00 160.00)
+          (bounds 757.00 152.00)
+          (contentsVisible 0)
+          (children 1
+            (GraphicsLayer
+              (position 20.00 20.00)
+              (bounds 108.00 108.00)
+              (contentsVisible 0)
+            )
+          )
+        )
+        (GraphicsLayer
+          (position 14.00 314.00)
+          (bounds 757.00 152.00)
+          (contentsVisible 0)
+          (children 1
+            (GraphicsLayer
+              (position 20.00 20.00)
+              (bounds 108.00 108.00)
+            )
+          )
+        )
+      )
+    )
+  )
+)
+After step 1
+
+(GraphicsLayer
+  (bounds 785.00 1301.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 785.00 1301.00)
+      (children 3
+        (GraphicsLayer
+          (position 14.00 6.00)
+          (bounds 757.00 152.00)
+          (children 1
+            (GraphicsLayer
+              (position 20.00 20.00)
+              (bounds 108.00 108.00)
+            )
+          )
+        )
+        (GraphicsLayer
+          (position 14.00 160.00)
+          (bounds 757.00 152.00)
+          (contentsVisible 0)
+          (children 1
+            (GraphicsLayer
+              (position 20.00 20.00)
+              (bounds 108.00 108.00)
+              (contentsVisible 0)
+            )
+          )
+        )
+        (GraphicsLayer
+          (position 14.00 314.00)
+          (bounds 757.00 152.00)
+          (contentsVisible 0)
+          (children 1
+            (GraphicsLayer
+              (position 20.00 20.00)
+              (bounds 108.00 108.00)
+            )
+          )
+        )
+      )
+    )
+  )
+)
+After step 2
+
+(GraphicsLayer
+  (bounds 785.00 1965.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 785.00 1965.00)
+      (children 3
+        (GraphicsLayer
+          (position 14.00 6.00)
+          (bounds 757.00 152.00)
+          (children 1
+            (GraphicsLayer
+              (position 20.00 20.00)
+              (bounds 108.00 108.00)
+            )
+          )
+        )
+        (GraphicsLayer
+          (position 14.00 160.00)
+          (bounds 757.00 152.00)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (position 20.00 20.00)
+              (bounds 108.00 108.00)
+            )
+          )
+        )
+        (GraphicsLayer
+          (position 14.00 314.00)
+          (bounds 757.00 152.00)
+          (contentsVisible 0)
+          (children 1
+            (GraphicsLayer
+              (position 20.00 20.00)
+              (bounds 108.00 108.00)
+            )
+          )
+        )
+      )
+    )
+  )
+)
+
Property changes on: trunk/LayoutTests/compositing/visibility/visibility-image-layers-dynamic-expected.txt
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/compositing/visibility/visibility-image-layers-dynamic.html (0 => 98735)


--- trunk/LayoutTests/compositing/visibility/visibility-image-layers-dynamic.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/visibility/visibility-image-layers-dynamic.html	2011-10-28 17:46:38 UTC (rev 98735)
@@ -0,0 +1,95 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+  <style>
+    .set {
+      position: absolute;
+      top: 8px;
+    }
+    .box {
+      height: 100px;
+      width: 100px;
+    }
+    
+    .hidden {
+      visibility: hidden;
+    }
+    
+    .container {
+      margin: 10px;
+      padding: 20px;
+    }
+    .container.hidden {
+      outline: 4px solid red;
+    }
+    
+    .visible {
+      visibility: visible;
+    }
+    .should-be-hidden {
+      background-color: red !important;
+    }
+    .should-be-visible {
+      background-color: green !important;
+    }
+    .composited {
+      -webkit-transform: translateZ(0);
+    }
+    
+    .visible-indicator {
+      background-color: green;
+    }
+
+    .hidden-indicator {
+      background-color: red;
+    }
+  </style>
+  <script>
+    if (window.layoutTestController) {
+      layoutTestController.dumpAsText();
+      layoutTestController.waitUntilDone();
+    }
+
+    function doTest()
+    {
+      if (window.layoutTestController)
+        document.getElementById('layers1').innerText = layoutTestController.layerTreeAsText();
+
+      window.setTimeout(function() {
+        var firstImage = document.querySelectorAll('img')[0];
+        firstImage.style.visibility = 'visible';
+
+        if (window.layoutTestController)
+          document.getElementById('layers2').innerText = layoutTestController.layerTreeAsText();
+
+          window.setTimeout(function() {
+            var secondContainer = document.querySelectorAll('.container')[1];
+            secondContainer.style.visibility = 'visible';
+
+            if (window.layoutTestController) {
+              document.getElementById('layers3').innerText = layoutTestController.layerTreeAsText();
+              layoutTestController.notifyDone();
+            }
+          }, 0);
+      }, 0);
+    }
+    window.addEventListener('load', doTest, false);
+  </script>
+</head>
+<body>
+    <!-- Tests dynamic changes of visibility, using directly composited images. -->
+    <div class="composited container"><img src="" class="hidden composited box"></div>
+    <div class="composited hidden container"><img src="" class="composited box"></div>
+    <div class="composited hidden container"><img src="" class="visible composited box"></div>
+  
+<h2>Initial</h2>
+<pre id="layers1"></pre>
+
+<h2>After step 1</h2>
+<pre id="layers2"></pre>
+
+<h2>After step 2</h2>
+<pre id="layers3"></pre>
+</body>
+</html>
Property changes on: trunk/LayoutTests/compositing/visibility/visibility-image-layers-dynamic.html
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/compositing/visibility/visibility-image-layers-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/compositing/visibility/visibility-image-layers-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/compositing/visibility/visibility-image-layers.html (0 => 98735)


--- trunk/LayoutTests/compositing/visibility/visibility-image-layers.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/visibility/visibility-image-layers.html	2011-10-28 17:46:38 UTC (rev 98735)
@@ -0,0 +1,68 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+  <style>
+    .set {
+      display: inline-block;
+      border: 1px solid black;
+    }
+    .box {
+      height: 100px;
+      width: 100px;
+    }
+    
+    .hidden {
+      visibility: hidden;
+    }
+    
+    .container {
+      margin: 10px;
+      padding: 20px;
+    }
+    .container.hidden {
+      outline: 4px solid red;
+    }
+    
+    .visible {
+      visibility: visible;
+    }
+    .should-be-hidden {
+      background-color: red !important;
+    }
+    .should-be-visible {
+      background-color: green !important;
+    }
+    .composited {
+      -webkit-transform: translateZ(1px);
+    }
+    
+    .visible-indicator {
+      background-color: green;
+    }
+
+    .hidden-indicator {
+      background-color: red;
+    }
+  </style>
+  <script>
+    if (window.layoutTestController)
+      layoutTestController.dumpAsText(true);
+  </script>
+</head>
+<body>
+  <!-- Tests visibility with directly composited images. -->
+  <!-- Left and right sides should look the same -->
+  <div class="set">
+    <div class="container"><img src="" class="hidden box"></div>
+    <div class="hidden container"><img src="" class="box"></div>
+    <div class="hidden container"><img src="" class="visible box"></div>
+  </div>
+
+  <div class="set">
+    <div class="composited container"><img src="" class="hidden composited box"></div>
+    <div class="composited hidden container"><img src="" class="composited box"></div>
+    <div class="composited hidden container"><img src="" class="visible composited box"></div>
+  </div>
+</body>
+</html>
Property changes on: trunk/LayoutTests/compositing/visibility/visibility-image-layers.html
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (98734 => 98735)


--- trunk/Source/WebCore/ChangeLog	2011-10-28 17:42:59 UTC (rev 98734)
+++ trunk/Source/WebCore/ChangeLog	2011-10-28 17:46:38 UTC (rev 98735)
@@ -1,3 +1,57 @@
+2011-10-28  Simon Fraser  <simon.fra...@apple.com>
+
+        The HTML5 video element in Safari does not respect "visibility:hidden" CSS property
+        https://bugs.webkit.org/show_bug.cgi?id=38829
+
+        Reviewed by James Robinson.
+        
+        Make compositing and CSS visibility play nicely together.
+        
+        The main issue was that an old optimization (see bug 4377) caused
+        visibility:hidden layers to not appear in the z-order lists, but those
+        layers could still become composited, but would remain detached. In addition,
+        composited layers which were visibility:hidden would become visible sometimes.
+        
+        With this fix, the z-order lists always contain all layers when the page
+        is in compositing mode. GraphicsLayer is changed to ensure that visibility:hidden
+        layers show no content, and visible descendants of hidden layers work correctly.
+
+        Tests: compositing/visibility/visibility-composited-transforms.html
+               compositing/visibility/visibility-composited.html
+               compositing/visibility/visibility-image-layers-dynamic.html
+               compositing/visibility/visibility-image-layers.html
+
+        * platform/graphics/GraphicsLayer.cpp:
+        (WebCore::GraphicsLayer::GraphicsLayer): Init m_contentsVisible to true.
+        (WebCore::GraphicsLayer::dumpProperties): Dump m_contentsVisible if not true.
+        * platform/graphics/GraphicsLayer.h:
+        (WebCore::GraphicsLayer::contentsAreVisible): Getter for m_contentsVisible.
+        (WebCore::GraphicsLayer::setContentsVisible): Setter for m_contentsVisible.
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::setContentsVisible): Override setContentsVisible.
+        (WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers): Handle ContentsVisibilityChanged
+        flag
+        (WebCore::GraphicsLayerCA::updateSublayerList): Only parent the m_contentsLayer if the layer
+        has visible contents.
+        (WebCore::GraphicsLayerCA::updateContentsVisibility): For bits painted into the layer itself,
+        we hide it by clearing the backing store.
+        * platform/graphics/ca/GraphicsLayerCA.h: Removed obsolete comment on the DrawsContentChanged flag,
+        added ContentsVisibilityChanged flag.
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::updateZOrderLists): If we're in compositing mode, include all layers
+        in the z-order lists.
+        (WebCore::RenderLayer::collectLayers): New param to specify whether we need to collect all layers.
+        * rendering/RenderLayer.h:
+        (WebCore::RenderLayer::hasVisibleDescendant): Add comment about the need for an assertion in hasVisibleContent()
+        , and assertion in hasVisibleDescendant().
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::updateGraphicsLayerGeometry): Call setContentsVisible() on the GraphicsLayer.
+        (WebCore::RenderLayerBacking::isSimpleContainerCompositingLayer): We can use simple container layers in cases
+        where visibility:hidden causes layer content to not be drawn.
+        (WebCore::RenderLayerBacking::hasVisibleNonCompositingDescendants): Renamed from hasNonCompositingDescendants()
+        because it now also looks at visibility to decide when things are visible.
+        * rendering/RenderLayerBacking.h: hasNonCompositingDescendants() renamed to hasVisibleNonCompositingDescendants().
+
 2011-10-22  Philippe Normand  <pnorm...@igalia.com>
 
         [GTK] Build fixes for glib 2.31 (current master)

Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp (98734 => 98735)


--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp	2011-10-28 17:42:59 UTC (rev 98734)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp	2011-10-28 17:46:38 UTC (rev 98735)
@@ -77,6 +77,7 @@
     , m_usingTiledLayer(false)
     , m_masksToBounds(false)
     , m_drawsContent(false)
+    , m_contentsVisible(true)
     , m_acceleratesDrawing(false)
     , m_maintainsPixelAlignment(false)
     , m_appliesPageScale(false)
@@ -504,6 +505,11 @@
         ts << "(drawsContent " << m_drawsContent << ")\n";
     }
 
+    if (!m_contentsVisible) {
+        writeIndent(ts, indent + 1);
+        ts << "(contentsVisible " << m_contentsVisible << ")\n";
+    }
+
     if (!m_backfaceVisibility) {
         writeIndent(ts, indent + 1);
         ts << "(backfaceVisibility " << (m_backfaceVisibility ? "visible" : "hidden") << ")\n";

Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.h (98734 => 98735)


--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.h	2011-10-28 17:42:59 UTC (rev 98734)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.h	2011-10-28 17:46:38 UTC (rev 98735)
@@ -264,6 +264,9 @@
     bool drawsContent() const { return m_drawsContent; }
     virtual void setDrawsContent(bool b) { m_drawsContent = b; }
 
+    bool contentsAreVisible() const { return m_contentsVisible; }
+    virtual void setContentsVisible(bool b) { m_contentsVisible = b; }
+
     bool acceleratesDrawing() const { return m_acceleratesDrawing; }
     virtual void setAcceleratesDrawing(bool b) { m_acceleratesDrawing = b; }
 
@@ -424,6 +427,7 @@
     bool m_usingTiledLayer : 1;
     bool m_masksToBounds : 1;
     bool m_drawsContent : 1;
+    bool m_contentsVisible : 1;
     bool m_acceleratesDrawing : 1;
     bool m_maintainsPixelAlignment : 1;
     bool m_appliesPageScale : 1; // Set for the layer which has the page scale applied to it.

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


--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2011-10-28 17:42:59 UTC (rev 98734)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2011-10-28 17:46:38 UTC (rev 98735)
@@ -490,6 +490,18 @@
     noteLayerPropertyChanged(DrawsContentChanged);
 }
 
+void GraphicsLayerCA::setContentsVisible(bool contentsVisible)
+{
+    if (contentsVisible == m_contentsVisible)
+        return;
+
+    GraphicsLayer::setContentsVisible(contentsVisible);
+    noteLayerPropertyChanged(ContentsVisibilityChanged);
+    // Visibility affects whether the contentsLayer is parented.
+    if (m_contentsLayer)
+        noteSublayersChanged();
+}
+
 void GraphicsLayerCA::setAcceleratesDrawing(bool acceleratesDrawing)
 {
     if (acceleratesDrawing == m_acceleratesDrawing)
@@ -952,6 +964,9 @@
     if (m_uncommittedChanges & DrawsContentChanged)
         updateLayerDrawsContent(pageScaleFactor, positionRelativeToBase);
 
+    if (m_uncommittedChanges & ContentsVisibilityChanged)
+        updateContentsVisibility();
+
     if (m_uncommittedChanges & ContentsOpaqueChanged)
         updateContentsOpaque();
 
@@ -1021,7 +1036,7 @@
                 newSublayers.append(static_cast<GraphicsLayerCA*>(m_replicaLayer)->primaryLayer());
             // Add the primary layer. Even if we have negative z-order children, the primary layer always comes behind.
             newSublayers.append(m_layer);
-        } else if (m_contentsLayer) {
+        } else if (m_contentsLayer && m_contentsVisible) {
             // FIXME: add the contents layer in the correct order with negative z-order children.
             // This does not cause visible rendering issues because currently contents layers are only used
             // for replaced elements that don't have children.
@@ -1051,7 +1066,8 @@
             // If we have a transform layer, then the contents layer is parented in the 
             // primary layer (which is itself a child of the transform layer).
             m_layer->removeAllSublayers();
-            m_layer->appendSublayer(m_contentsLayer.get());
+            if (m_contentsVisible)
+                m_layer->appendSublayer(m_contentsLayer.get());
         }
     } else
         m_layer->setSublayers(newSublayers);
@@ -1175,6 +1191,23 @@
     updateDebugIndicators();
 }
 
+void GraphicsLayerCA::updateContentsVisibility()
+{
+    // Note that m_contentsVisible also affects whether m_contentsLayer is parented.
+    if (m_contentsVisible) {
+        if (m_drawsContent)
+            m_layer->setNeedsDisplay();
+    } else {
+        m_layer.get()->setContents(0);
+
+        if (LayerMap* layerCloneMap = m_layerClones.get()) {
+            LayerMap::const_iterator end = layerCloneMap->end();
+            for (LayerMap::const_iterator it = layerCloneMap->begin(); it != end; ++it)
+                it->second->setContents(0);
+        }
+    }
+}
+
 void GraphicsLayerCA::updateContentsOpaque()
 {
     m_layer.get()->setOpaque(m_contentsOpaque);

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


--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h	2011-10-28 17:42:59 UTC (rev 98734)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h	2011-10-28 17:46:38 UTC (rev 98735)
@@ -85,6 +85,7 @@
     virtual void setPreserves3D(bool);
     virtual void setMasksToBounds(bool);
     virtual void setDrawsContent(bool);
+    virtual void setContentsVisible(bool);
     virtual void setAcceleratesDrawing(bool);
 
     virtual void setBackgroundColor(const Color&);
@@ -278,6 +279,7 @@
     void updateTransform();
     void updateChildrenTransform();
     void updateMasksToBounds();
+    void updateContentsVisibility();
     void updateContentsOpaque();
     void updateBackfaceVisibility();
     void updateStructuralLayer(float pixelAlignmentScale, const FloatPoint& positionRelativeToBase);
@@ -321,7 +323,7 @@
         ChildrenTransformChanged = 1 << 5,
         Preserves3DChanged = 1 << 6,
         MasksToBoundsChanged = 1 << 7,
-        DrawsContentChanged = 1 << 8, // need this?
+        DrawsContentChanged = 1 << 8,
         BackgroundColorChanged = 1 << 9,
         ContentsOpaqueChanged = 1 << 10,
         BackfaceVisibilityChanged = 1 << 11,
@@ -336,7 +338,8 @@
         ReplicatedLayerChanged = 1 << 20,
         ContentsNeedsDisplay = 1 << 21,
         AcceleratesDrawingChanged = 1 << 22,
-        ContentsScaleChanged = 1 << 23
+        ContentsScaleChanged = 1 << 23,
+        ContentsVisibilityChanged = 1 << 24,
     };
     typedef unsigned LayerChangeFlags;
     void noteLayerPropertyChanged(LayerChangeFlags flags);

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (98734 => 98735)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2011-10-28 17:42:59 UTC (rev 98734)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2011-10-28 17:46:38 UTC (rev 98735)
@@ -4006,9 +4006,10 @@
     if (!isStackingContext() || !m_zOrderListsDirty)
         return;
 
+    bool includeHiddenLayers = compositor()->inCompositingMode();
     for (RenderLayer* child = firstChild(); child; child = child->nextSibling())
         if (!m_reflection || reflectionLayer() != child)
-            child->collectLayers(m_posZOrderList, m_negZOrderList);
+            child->collectLayers(includeHiddenLayers, m_posZOrderList, m_negZOrderList);
 
     // Sort the two lists.
     if (m_posZOrderList)
@@ -4037,12 +4038,13 @@
     m_normalFlowListDirty = false;
 }
 
-void RenderLayer::collectLayers(Vector<RenderLayer*>*& posBuffer, Vector<RenderLayer*>*& negBuffer)
+void RenderLayer::collectLayers(bool includeHiddenLayers, Vector<RenderLayer*>*& posBuffer, Vector<RenderLayer*>*& negBuffer)
 {
     updateVisibilityStatus();
 
     // Overflow layers are just painted by their enclosing layers, so they don't get put in zorder lists.
-    if ((m_hasVisibleContent || (m_hasVisibleDescendant && isStackingContext())) && !isNormalFlowOnly() && !renderer()->isRenderFlowThread()) {
+    bool includeHiddenLayer = includeHiddenLayers || (m_hasVisibleContent || (m_hasVisibleDescendant && isStackingContext()));
+    if (includeHiddenLayer && !isNormalFlowOnly() && !renderer()->isRenderFlowThread()) {
         // Determine which buffer the child should be in.
         Vector<RenderLayer*>*& buffer = (zIndex() >= 0) ? posBuffer : negBuffer;
 
@@ -4056,11 +4058,11 @@
 
     // Recur into our children to collect more layers, but only if we don't establish
     // a stacking context.
-    if (m_hasVisibleDescendant && !isStackingContext()) {
+    if ((includeHiddenLayers || m_hasVisibleDescendant) && !isStackingContext()) {
         for (RenderLayer* child = firstChild(); child; child = child->nextSibling()) {
             // Ignore reflections.
             if (!m_reflection || reflectionLayer() != child)
-                child->collectLayers(posBuffer, negBuffer);
+                child->collectLayers(includeHiddenLayers, posBuffer, negBuffer);
         }
     }
 }

Modified: trunk/Source/WebCore/rendering/RenderLayer.h (98734 => 98735)


--- trunk/Source/WebCore/rendering/RenderLayer.h	2011-10-28 17:42:59 UTC (rev 98734)
+++ trunk/Source/WebCore/rendering/RenderLayer.h	2011-10-28 17:46:38 UTC (rev 98735)
@@ -385,8 +385,9 @@
     void updateNormalFlowList();
     Vector<RenderLayer*>* normalFlowList() const { return m_normalFlowList; }
 
+    // FIXME: We should ASSERT(!m_visibleContentStatusDirty) here, but see https://bugs.webkit.org/show_bug.cgi?id=71044
     bool hasVisibleContent() const { return m_hasVisibleContent; }
-    bool hasVisibleDescendant() const { return m_hasVisibleDescendant; }
+    bool hasVisibleDescendant() const { ASSERT(!m_visibleDescendantStatusDirty); return m_hasVisibleDescendant; }
     void setHasVisibleContent(bool);
     void dirtyVisibleContentStatus();
 
@@ -544,7 +545,7 @@
     LayoutUnit renderBoxX() const { return renderBoxLocation().x(); }
     LayoutUnit renderBoxY() const { return renderBoxLocation().y(); }
 
-    void collectLayers(Vector<RenderLayer*>*&, Vector<RenderLayer*>*&);
+    void collectLayers(bool includeHiddenLayers, Vector<RenderLayer*>*&, Vector<RenderLayer*>*&);
 
     void updateLayerListsIfNeeded();
     void updateCompositingAndLayerListsIfNeeded();

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (98734 => 98735)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2011-10-28 17:42:59 UTC (rev 98734)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2011-10-28 17:46:38 UTC (rev 98735)
@@ -360,6 +360,9 @@
     if (!renderer()->animation()->isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyOpacity))
         updateLayerOpacity(renderer()->style());
     
+    m_owningLayer->updateVisibilityStatus();
+    m_graphicsLayer->setContentsVisible(m_owningLayer->hasVisibleContent());
+    
     RenderStyle* style = renderer()->style();
     m_graphicsLayer->setPreserves3D(style->transformStyle3D() == TransformStyle3DPreserve3D && !renderer()->hasReflection());
     m_graphicsLayer->setBackfaceVisibility(style->backfaceVisibility() == BackfaceVisibilityVisible);
@@ -788,14 +791,15 @@
         return false;
 
     RenderStyle* style = renderObject->style();
+    bool isVisible = m_owningLayer->hasVisibleContent();
 
     // Reject anything that has a border, a border-radius or outline,
     // or any background (color or image).
     // FIXME: we could optimize layers for simple backgrounds.
-    if (hasBoxDecorationsOrBackground(renderObject))
+    if (isVisible && hasBoxDecorationsOrBackground(renderObject))
         return false;
 
-    if (m_owningLayer->hasOverflowControls())
+    if (isVisible && m_owningLayer->hasOverflowControls())
         return false;
 
     // If we have got this far and the renderer has no children, then we're ok.
@@ -827,21 +831,21 @@
             return false;
 
         // Check to see if all the body's children are compositing layers.
-        if (hasNonCompositingDescendants())
+        if (hasVisibleNonCompositingDescendants())
             return false;
         
         return true;
     }
 
     // Check to see if all the renderer's children are compositing layers.
-    if (hasNonCompositingDescendants())
+    if (isVisible && hasVisibleNonCompositingDescendants())
         return false;
     
     return true;
 }
 
 // Conservative test for having no rendered children.
-bool RenderLayerBacking::hasNonCompositingDescendants() const
+bool RenderLayerBacking::hasVisibleNonCompositingDescendants() const
 {
     // Some HTML can cause whitespace text nodes to have renderers, like:
     // <div>
@@ -858,13 +862,25 @@
         }
     }
 
+    if (Vector<RenderLayer*>* normalFlowList = m_owningLayer->normalFlowList()) {
+        size_t listSize = normalFlowList->size();
+        for (size_t i = 0; i < listSize; ++i) {
+            RenderLayer* curLayer = normalFlowList->at(i);
+            if (!curLayer->isComposited() && curLayer->hasVisibleContent())
+                return true;
+        }
+    }
+
     if (m_owningLayer->isStackingContext()) {
+        if (!m_owningLayer->hasVisibleDescendant())
+            return false;
+
         // Use the m_hasCompositingDescendant bit to optimize?
         if (Vector<RenderLayer*>* negZOrderList = m_owningLayer->negZOrderList()) {
             size_t listSize = negZOrderList->size();
             for (size_t i = 0; i < listSize; ++i) {
                 RenderLayer* curLayer = negZOrderList->at(i);
-                if (!curLayer->isComposited())
+                if (!curLayer->isComposited() && curLayer->hasVisibleContent())
                     return true;
             }
         }
@@ -873,21 +889,12 @@
             size_t listSize = posZOrderList->size();
             for (size_t i = 0; i < listSize; ++i) {
                 RenderLayer* curLayer = posZOrderList->at(i);
-                if (!curLayer->isComposited())
+                if (!curLayer->isComposited() && curLayer->hasVisibleContent())
                     return true;
             }
         }
     }
 
-    if (Vector<RenderLayer*>* normalFlowList = m_owningLayer->normalFlowList()) {
-        size_t listSize = normalFlowList->size();
-        for (size_t i = 0; i < listSize; ++i) {
-            RenderLayer* curLayer = normalFlowList->at(i);
-            if (!curLayer->isComposited())
-                return true;
-        }
-    }
-
     return false;
 }
 

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.h (98734 => 98735)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.h	2011-10-28 17:42:59 UTC (rev 98734)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.h	2011-10-28 17:46:38 UTC (rev 98735)
@@ -188,7 +188,7 @@
     Color rendererBackgroundColor() const;
     void updateBackgroundColor();
 
-    bool hasNonCompositingDescendants() const;
+    bool hasVisibleNonCompositingDescendants() const;
     
     void paintIntoLayer(RenderLayer* rootLayer, GraphicsContext*, const LayoutRect& paintDirtyRect, PaintBehavior, GraphicsLayerPaintingPhase, RenderObject* paintingRoot);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to