- Revision
- 123971
- Author
- [email protected]
- Date
- 2012-07-28 12:44:23 -0700 (Sat, 28 Jul 2012)
Log Message
Ignore visibility:hidden elements when computing compositing layer bounds
https://bugs.webkit.org/show_bug.cgi?id=92569
Reviewed by Dan Bernstein.
Source/WebCore:
When computing the bounds of compositing layers, we would take into account
layers with no visible content (visibility:hidden, and no non-hidden descendants).
This caused some huge layers in mobile Google maps.
Tests: compositing/geometry/bounds-ignores-hidden-composited-descendant.html
compositing/geometry/bounds-ignores-hidden-dynamic.html
compositing/geometry/bounds-ignores-hidden.html
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::calculateLayerBounds): If the ExcludeHiddenDescendants flag is set, return
the empty rect for layers with no visible content or descendants, as long as the layer is not
the root of the subtree whose bounds are being computed.
calculateLayerBounds() currently (I think incorrectly) passes the default flags to the recursive calls.
It should probably just pass 'flags', but to make this change safe, OR in the ExcludeHiddenDescendants
flag.
* rendering/RenderLayer.h: Add an ExcludeHiddenDescendants flag to the CalculateLayerBoundsFlags.
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::calculateCompositedBounds): Pass the ExcludeHiddenDescendants
flag.
LayoutTests:
Tests related to visibility:hidden's affect on composited layer bounds.
* compositing/geometry/bounds-ignores-hidden-composited-expected.txt: Added.
* compositing/geometry/bounds-ignores-hidden-composited-descendant.html: Added.
Test with visibility:visible descendants of a visibility:hidden element in a
compositing layer.
* compositing/geometry/bounds-ignores-hidden-dynamic-expected.txt: Added.
* compositing/geometry/bounds-ignores-hidden-dynamic.html: Added.
Test that changes visibility on descendants of a compositing layer, to test dynamic changes.
* compositing/geometry/bounds-ignores-hidden-expected.txt: Added.
* compositing/geometry/bounds-ignores-hidden.html: Added.
Test with a compositing layer having visibility:hidden descendants, which dumps
layer tree information.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (123970 => 123971)
--- trunk/LayoutTests/ChangeLog 2012-07-28 19:35:27 UTC (rev 123970)
+++ trunk/LayoutTests/ChangeLog 2012-07-28 19:44:23 UTC (rev 123971)
@@ -1,3 +1,27 @@
+2012-07-28 Simon Fraser <[email protected]>
+
+ Ignore visibility:hidden elements when computing compositing layer bounds
+ https://bugs.webkit.org/show_bug.cgi?id=92569
+
+ Reviewed by Dan Bernstein.
+
+ Tests related to visibility:hidden's affect on composited layer bounds.
+
+ * compositing/geometry/bounds-ignores-hidden-composited-expected.txt: Added.
+ * compositing/geometry/bounds-ignores-hidden-composited-descendant.html: Added.
+ Test with visibility:visible descendants of a visibility:hidden element in a
+ compositing layer.
+
+ * compositing/geometry/bounds-ignores-hidden-dynamic-expected.txt: Added.
+ * compositing/geometry/bounds-ignores-hidden-dynamic.html: Added.
+ Test that changes visibility on descendants of a compositing layer, to test dynamic changes.
+
+ * compositing/geometry/bounds-ignores-hidden-expected.txt: Added.
+ * compositing/geometry/bounds-ignores-hidden.html: Added.
+ Test with a compositing layer having visibility:hidden descendants, which dumps
+ layer tree information.
+
+
2012-07-28 Peter Kasting <[email protected]>
[Chromium] Widen expectation for crashing test.
Added: trunk/LayoutTests/compositing/geometry/bounds-ignores-hidden-composited-descendant-expected.txt (0 => 123971)
--- trunk/LayoutTests/compositing/geometry/bounds-ignores-hidden-composited-descendant-expected.txt (rev 0)
+++ trunk/LayoutTests/compositing/geometry/bounds-ignores-hidden-composited-descendant-expected.txt 2012-07-28 19:44:23 UTC (rev 123971)
@@ -0,0 +1,32 @@
+
+
+(GraphicsLayer
+ (bounds 800.00 600.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 800.00 600.00)
+ (children 2
+ (GraphicsLayer
+ (position 10.00 10.00)
+ (anchor -0.02 -0.05)
+ (bounds 590.00 208.00)
+ (drawsContent 1)
+ )
+ (GraphicsLayer
+ (position 10.00 260.00)
+ (anchor -0.02 -0.05)
+ (bounds 590.00 208.00)
+ (drawsContent 1)
+ (children 1
+ (GraphicsLayer
+ (position 490.00 108.00)
+ (bounds 100.00 100.00)
+ (drawsContent 1)
+ )
+ )
+ )
+ )
+ )
+ )
+)
+
Added: trunk/LayoutTests/compositing/geometry/bounds-ignores-hidden-composited-descendant.html (0 => 123971)
--- trunk/LayoutTests/compositing/geometry/bounds-ignores-hidden-composited-descendant.html (rev 0)
+++ trunk/LayoutTests/compositing/geometry/bounds-ignores-hidden-composited-descendant.html 2012-07-28 19:44:23 UTC (rev 123971)
@@ -0,0 +1,58 @@
+<style>
+ .composited {
+ -webkit-transform: translateZ(0);
+ }
+
+ img {
+ background-color: black;
+ width: 50px;
+ height: 50px;
+ }
+
+ .box {
+ width: 100px;
+ height: 100px;
+ background-color: blue;
+ }
+
+ .inner {
+ position: relative;
+ visibility: visible;
+ }
+
+ #layers {
+ opacity: 0; /* hide from pixel result */
+ }
+</style>
+<script>
+ if (window.testRunner)
+ testRunner.dumpAsText();
+
+ function dumpLayers()
+ {
+ if (window.testRunner) {
+ document.getElementById('layers').innerText = window.testRunner.layerTreeAsText();
+ }
+ }
+ window.addEventListener('load', dumpLayers, false);
+</script>
+<body>
+ <div style="position: absolute; left: 0px; top: 0px; z-index: 1; " class="composited">
+ <img style="position: absolute; left: 10px; top: 10px; z-index: 0;">
+ <div style="position: absolute; left: 500px; top: 100px; z-index: 1; visibility: hidden;">
+ stuff
+ <div class="inner box"></div>
+ </div>
+ </div>
+
+ <div style="position: absolute; left: 0px; top: 250px; z-index: 1; " class="composited">
+ <img style="position: absolute; left: 10px; top: 10px; z-index: 0;">
+ <div style="position: absolute; left: 500px; top: 100px; z-index: 1; visibility: hidden;">
+ stuff
+ <!-- Ideally this layer wouldn't affect the bounds of its composited ancestor. -->
+ <div class="composited inner box"></div>
+ </div>
+ </div>
+
+<pre id="layers">Layer tree goes here in DRT</pre>
+</body>
Added: trunk/LayoutTests/compositing/geometry/bounds-ignores-hidden-dynamic-expected.txt (0 => 123971)
--- trunk/LayoutTests/compositing/geometry/bounds-ignores-hidden-dynamic-expected.txt (rev 0)
+++ trunk/LayoutTests/compositing/geometry/bounds-ignores-hidden-dynamic-expected.txt 2012-07-28 19:44:23 UTC (rev 123971)
@@ -0,0 +1,24 @@
+
+(GraphicsLayer
+ (bounds 800.00 600.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 800.00 600.00)
+ (children 2
+ (GraphicsLayer
+ (position 10.00 10.00)
+ (anchor -0.02 -0.04)
+ (bounds 540.00 240.00)
+ (drawsContent 1)
+ )
+ (GraphicsLayer
+ (position 10.00 260.00)
+ (anchor -0.20 -0.20)
+ (bounds 50.00 50.00)
+ (drawsContent 1)
+ )
+ )
+ )
+ )
+)
+
Added: trunk/LayoutTests/compositing/geometry/bounds-ignores-hidden-dynamic.html (0 => 123971)
--- trunk/LayoutTests/compositing/geometry/bounds-ignores-hidden-dynamic.html (rev 0)
+++ trunk/LayoutTests/compositing/geometry/bounds-ignores-hidden-dynamic.html 2012-07-28 19:44:23 UTC (rev 123971)
@@ -0,0 +1,65 @@
+<style>
+ .composited {
+ -webkit-transform: translateZ(0);
+ }
+
+ .box {
+ width: 100px;
+ height: 100px;
+ background-color: blue;
+ }
+
+ img {
+ background-color: black;
+ width: 50px;
+ height: 50px;
+ }
+
+ img.to-visible {
+ visibility: hidden;
+ }
+ body.changed img.to-visible {
+ visibility: visible;
+ }
+
+ img.to-hidden {
+ visibility: visible;
+ }
+ body.changed img.to-hidden {
+ visibility: hidden;
+ }
+
+ #layers {
+ opacity: 0; /* hide from pixel result */
+ }
+</style>
+<script>
+ if (window.testRunner) {
+ testRunner.dumpAsText(true);
+ testRunner.waitUntilDone();
+ }
+
+ function doTest()
+ {
+ window.setTimeout(function() {
+ document.body.classList.add('changed');
+ if (window.testRunner) {
+ document.getElementById('layers').innerText = testRunner.layerTreeAsText();
+ testRunner.notifyDone();
+ }
+ }, 0);
+ }
+ window.addEventListener('load', doTest, false);
+</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: 0;">
+ <img style="position: absolute; left: 500px; top: 200px; z-index: 0;" class="to-visible">
+ </div>
+
+ <div style="position: absolute; left: 0px; top: 250px; z-index: 106; " class="composited">
+ <img style="position: absolute; left: 10px; top: 10px; z-index: 0;">
+ <img style="position: absolute; left: 500px; top: 200px; z-index: 0;" class="to-hidden">
+ </div>
+<pre id="layers">Layer tree goes here in DRT</pre>
+</body>
Added: trunk/LayoutTests/compositing/geometry/bounds-ignores-hidden-expected.txt (0 => 123971)
--- trunk/LayoutTests/compositing/geometry/bounds-ignores-hidden-expected.txt (rev 0)
+++ trunk/LayoutTests/compositing/geometry/bounds-ignores-hidden-expected.txt 2012-07-28 19:44:23 UTC (rev 123971)
@@ -0,0 +1,24 @@
+
+(GraphicsLayer
+ (bounds 44990.00 15063.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 44990.00 15063.00)
+ (children 1
+ (GraphicsLayer
+ (position 10.00 10.00)
+ (anchor -0.20 -0.20)
+ (bounds 50.00 50.00)
+ (drawsContent 1)
+ (children 1
+ (GraphicsLayer
+ (bounds 50.00 50.00)
+ (drawsContent 1)
+ )
+ )
+ )
+ )
+ )
+ )
+)
+
Added: trunk/LayoutTests/compositing/geometry/bounds-ignores-hidden.html (0 => 123971)
--- trunk/LayoutTests/compositing/geometry/bounds-ignores-hidden.html (rev 0)
+++ trunk/LayoutTests/compositing/geometry/bounds-ignores-hidden.html 2012-07-28 19:44:23 UTC (rev 123971)
@@ -0,0 +1,30 @@
+<style>
+ .composited {
+ -webkit-transform: translateZ(0);
+ }
+
+ img {
+ background-color: black;
+ width: 50px;
+ height: 50px;
+ }
+</style>
+<script>
+ if (window.testRunner)
+ testRunner.dumpAsText();
+
+ function dumpLayers()
+ {
+ if (window.testRunner) {
+ document.getElementById('layers').innerText = window.testRunner.layerTreeAsText();
+ }
+ }
+ window.addEventListener('load', dumpLayers, false);
+</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 style="position: absolute; left: 44940px; top: 15013px; z-index: 0; visibility: hidden;">
+ </div>
+<pre id="layers">Layer tree goes here in DRT</pre>
+</body>
Modified: trunk/Source/WebCore/ChangeLog (123970 => 123971)
--- trunk/Source/WebCore/ChangeLog 2012-07-28 19:35:27 UTC (rev 123970)
+++ trunk/Source/WebCore/ChangeLog 2012-07-28 19:44:23 UTC (rev 123971)
@@ -1,3 +1,30 @@
+2012-07-28 Simon Fraser <[email protected]>
+
+ Ignore visibility:hidden elements when computing compositing layer bounds
+ https://bugs.webkit.org/show_bug.cgi?id=92569
+
+ Reviewed by Dan Bernstein.
+
+ When computing the bounds of compositing layers, we would take into account
+ layers with no visible content (visibility:hidden, and no non-hidden descendants).
+ This caused some huge layers in mobile Google maps.
+
+ Tests: compositing/geometry/bounds-ignores-hidden-composited-descendant.html
+ compositing/geometry/bounds-ignores-hidden-dynamic.html
+ compositing/geometry/bounds-ignores-hidden.html
+
+ * rendering/RenderLayer.cpp:
+ (WebCore::RenderLayer::calculateLayerBounds): If the ExcludeHiddenDescendants flag is set, return
+ the empty rect for layers with no visible content or descendants, as long as the layer is not
+ the root of the subtree whose bounds are being computed.
+ calculateLayerBounds() currently (I think incorrectly) passes the default flags to the recursive calls.
+ It should probably just pass 'flags', but to make this change safe, OR in the ExcludeHiddenDescendants
+ flag.
+ * rendering/RenderLayer.h: Add an ExcludeHiddenDescendants flag to the CalculateLayerBoundsFlags.
+ * rendering/RenderLayerCompositor.cpp:
+ (WebCore::RenderLayerCompositor::calculateCompositedBounds): Pass the ExcludeHiddenDescendants
+ flag.
+
2012-07-28 Min Qin <[email protected]>
Add an overlay play button to media controls on android
Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (123970 => 123971)
--- trunk/Source/WebCore/rendering/RenderLayer.cpp 2012-07-28 19:35:27 UTC (rev 123970)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp 2012-07-28 19:44:23 UTC (rev 123971)
@@ -4226,6 +4226,10 @@
if (!layer->isSelfPaintingLayer())
return IntRect();
+ // FIXME: This could be improved to do a check like hasVisibleNonCompositingDescendantLayers() (bug 92580).
+ if ((flags & ExcludeHiddenDescendants) && layer != ancestorLayer && !layer->hasVisibleContent() && !layer->hasVisibleDescendant())
+ return IntRect();
+
LayoutRect boundingBoxRect = layer->localBoundingBox();
if (layer->renderer()->isBox())
layer->renderBox()->flipForWritingMode(boundingBoxRect);
@@ -4260,11 +4264,14 @@
}
}
+ // FIXME: should probably just pass 'flags' down to descendants.
+ CalculateLayerBoundsFlags descendantFlags = DefaultCalculateLayerBoundsFlags | (flags & ExcludeHiddenDescendants);
+
const_cast<RenderLayer*>(layer)->updateLayerListsIfNeeded();
if (RenderLayer* reflection = layer->reflectionLayer()) {
if (!reflection->isComposited()) {
- IntRect childUnionBounds = calculateLayerBounds(reflection, layer);
+ IntRect childUnionBounds = calculateLayerBounds(reflection, layer, descendantFlags);
unionBounds.unite(childUnionBounds);
}
}
@@ -4280,7 +4287,7 @@
for (size_t i = 0; i < listSize; ++i) {
RenderLayer* curLayer = negZOrderList->at(i);
if (!curLayer->isComposited()) {
- IntRect childUnionBounds = calculateLayerBounds(curLayer, layer);
+ IntRect childUnionBounds = calculateLayerBounds(curLayer, layer, descendantFlags);
unionBounds.unite(childUnionBounds);
}
}
@@ -4291,7 +4298,7 @@
for (size_t i = 0; i < listSize; ++i) {
RenderLayer* curLayer = posZOrderList->at(i);
if (!curLayer->isComposited()) {
- IntRect childUnionBounds = calculateLayerBounds(curLayer, layer);
+ IntRect childUnionBounds = calculateLayerBounds(curLayer, layer, descendantFlags);
unionBounds.unite(childUnionBounds);
}
}
@@ -4302,7 +4309,7 @@
for (size_t i = 0; i < listSize; ++i) {
RenderLayer* curLayer = normalFlowList->at(i);
if (!curLayer->isComposited()) {
- IntRect curAbsBounds = calculateLayerBounds(curLayer, layer);
+ IntRect curAbsBounds = calculateLayerBounds(curLayer, layer, descendantFlags);
unionBounds.unite(curAbsBounds);
}
}
Modified: trunk/Source/WebCore/rendering/RenderLayer.h (123970 => 123971)
--- trunk/Source/WebCore/rendering/RenderLayer.h 2012-07-28 19:35:27 UTC (rev 123970)
+++ trunk/Source/WebCore/rendering/RenderLayer.h 2012-07-28 19:44:23 UTC (rev 123971)
@@ -547,6 +547,7 @@
IncludeSelfTransform = 1 << 0,
UseLocalClipRectIfPossible = 1 << 1,
IncludeLayerFilterOutsets = 1 << 2,
+ ExcludeHiddenDescendants = 1 << 3,
DefaultCalculateLayerBoundsFlags = IncludeSelfTransform | UseLocalClipRectIfPossible | IncludeLayerFilterOutsets
};
typedef unsigned CalculateLayerBoundsFlags;
Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (123970 => 123971)
--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2012-07-28 19:35:27 UTC (rev 123970)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2012-07-28 19:44:23 UTC (rev 123971)
@@ -612,7 +612,7 @@
{
if (!canBeComposited(layer))
return IntRect();
- return RenderLayer::calculateLayerBounds(layer, ancestorLayer);
+ return RenderLayer::calculateLayerBounds(layer, ancestorLayer, RenderLayer::DefaultCalculateLayerBoundsFlags | RenderLayer::ExcludeHiddenDescendants);
}
void RenderLayerCompositor::layerWasAdded(RenderLayer* /*parent*/, RenderLayer* /*child*/)