- Revision
- 130396
- Author
- [email protected]
- Date
- 2012-10-04 08:57:50 -0700 (Thu, 04 Oct 2012)
Log Message
Fixed position visibility check does not consider descendants
https://bugs.webkit.org/show_bug.cgi?id=98144
Patch by Sami Kyostila <[email protected]> on 2012-10-04
Reviewed by Simon Fraser.
Source/WebCore:
The check against creating composition layers for invisible fixed positioned
elements is too aggressive in that it does not consider descendants of the
fixed positioned element that may be visible even though the element itself is
out of view.
Fix the problem by calculating the true composited bounds of the fixed
element instead of just using the size of the fixed layer. Because calculating
the true bounds may be expensive, it is only done if the fixed layer itself is
invisible.
Test: compositing/layer-creation/fixed-position-absolute-descendant.html
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::calculateCompositedBounds):
(WebCore::RenderLayerCompositor::requiresCompositingForPosition):
* rendering/RenderLayerCompositor.h:
LayoutTests:
Added a test for the fixed position layer visibility check.
* compositing/layer-creation/fixed-position-absolute-descendant-expected.txt: Added.
* compositing/layer-creation/fixed-position-absolute-descendant.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (130395 => 130396)
--- trunk/LayoutTests/ChangeLog 2012-10-04 15:52:29 UTC (rev 130395)
+++ trunk/LayoutTests/ChangeLog 2012-10-04 15:57:50 UTC (rev 130396)
@@ -1,3 +1,15 @@
+2012-10-04 Sami Kyostila <[email protected]>
+
+ Fixed position visibility check does not consider descendants
+ https://bugs.webkit.org/show_bug.cgi?id=98144
+
+ Reviewed by Simon Fraser.
+
+ Added a test for the fixed position layer visibility check.
+
+ * compositing/layer-creation/fixed-position-absolute-descendant-expected.txt: Added.
+ * compositing/layer-creation/fixed-position-absolute-descendant.html: Added.
+
2012-10-04 Ádám Kallai <[email protected]>
[Qt] Unreviewed gardening after r130385. Skip some failing test.
Added: trunk/LayoutTests/compositing/layer-creation/fixed-position-absolute-descendant-expected.txt (0 => 130396)
--- trunk/LayoutTests/compositing/layer-creation/fixed-position-absolute-descendant-expected.txt (rev 0)
+++ trunk/LayoutTests/compositing/layer-creation/fixed-position-absolute-descendant-expected.txt 2012-10-04 15:57:50 UTC (rev 130396)
@@ -0,0 +1,20 @@
+(GraphicsLayer
+ (bounds 800.00 600.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 800.00 600.00)
+ (children 2
+ (GraphicsLayer
+ (position 58.00 63.00)
+ (bounds 50.00 50.00)
+ (drawsContent 1)
+ )
+ (GraphicsLayer
+ (position 8.00 13.00)
+ (drawsContent 1)
+ )
+ )
+ )
+ )
+)
+
Added: trunk/LayoutTests/compositing/layer-creation/fixed-position-absolute-descendant.html (0 => 130396)
--- trunk/LayoutTests/compositing/layer-creation/fixed-position-absolute-descendant.html (rev 0)
+++ trunk/LayoutTests/compositing/layer-creation/fixed-position-absolute-descendant.html 2012-10-04 15:57:50 UTC (rev 130396)
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+ <style>
+ .fixed {
+ position: fixed;
+ }
+ .absolute {
+ position: absolute;
+ }
+ .in-view {
+ top: 50px;
+ left: 50px;
+ }
+ .out-of-view {
+ top: 50px;
+ left: -150px;
+ }
+ .box {
+ width: 50px;
+ height: 50px;
+ background: green;
+ }
+ </style>
+
+ <script type="text/_javascript_">
+ if (window.internals) {
+ window.internals.settings.setEnableCompositingForFixedPosition(true);
+ window.internals.settings.setFixedPositionCreatesStackingContext(true);
+ }
+
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+
+ window.addEventListener("load", function() {
+ document.getElementById("layertree").innerText = testRunner.layerTreeAsText();
+ }, false);
+ }
+ </script>
+</head>
+
+<body>
+ <!-- This element gets its own layer even though its layout size is empty
+ because it has a descendant that intersects with the viewport. -->
+ <div class="fixed">
+ <div class="absolute in-view box"></div>
+ </div>
+
+ <!-- This element doesn't get a layer, because neither it or any of its
+ children intersect with the viewport. -->
+ <div class="fixed">
+ <div class="absolute out-of-view box"></div>
+ </div>
+
+ <pre id="layertree"></pre>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (130395 => 130396)
--- trunk/Source/WebCore/ChangeLog 2012-10-04 15:52:29 UTC (rev 130395)
+++ trunk/Source/WebCore/ChangeLog 2012-10-04 15:57:50 UTC (rev 130396)
@@ -1,3 +1,27 @@
+2012-10-04 Sami Kyostila <[email protected]>
+
+ Fixed position visibility check does not consider descendants
+ https://bugs.webkit.org/show_bug.cgi?id=98144
+
+ Reviewed by Simon Fraser.
+
+ The check against creating composition layers for invisible fixed positioned
+ elements is too aggressive in that it does not consider descendants of the
+ fixed positioned element that may be visible even though the element itself is
+ out of view.
+
+ Fix the problem by calculating the true composited bounds of the fixed
+ element instead of just using the size of the fixed layer. Because calculating
+ the true bounds may be expensive, it is only done if the fixed layer itself is
+ invisible.
+
+ Test: compositing/layer-creation/fixed-position-absolute-descendant.html
+
+ * rendering/RenderLayerCompositor.cpp:
+ (WebCore::RenderLayerCompositor::calculateCompositedBounds):
+ (WebCore::RenderLayerCompositor::requiresCompositingForPosition):
+ * rendering/RenderLayerCompositor.h:
+
2012-10-04 Vsevolod Vlasov <[email protected]>
Web Inspector: When uiSourceCode content has diverged from VM script, call frames should be shown in temporary script based uiSourceCodes.
Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (130395 => 130396)
--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2012-10-04 15:52:29 UTC (rev 130395)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2012-10-04 15:57:50 UTC (rev 130396)
@@ -607,7 +607,7 @@
// The bounds of the GraphicsLayer created for a compositing layer is the union of the bounds of all the descendant
// RenderLayers that are rendered by the composited RenderLayer.
-IntRect RenderLayerCompositor::calculateCompositedBounds(const RenderLayer* layer, const RenderLayer* ancestorLayer)
+IntRect RenderLayerCompositor::calculateCompositedBounds(const RenderLayer* layer, const RenderLayer* ancestorLayer) const
{
if (!canBeComposited(layer))
return IntRect();
@@ -1854,9 +1854,11 @@
return false;
// Fixed position elements that are invisible in the current view don't get their own layer.
- FrameView* frameView = m_renderView->frameView();
- if (frameView && !layer->absoluteBoundingBox().intersects(IntRect(IntPoint(frameView->scrollOffsetForFixedPosition()), frameView->layoutSize())))
- return false;
+ if (FrameView* frameView = m_renderView->frameView()) {
+ IntRect viewBounds = IntRect(IntPoint(frameView->scrollOffsetForFixedPosition()), frameView->layoutSize());
+ if (!layer->absoluteBoundingBox().intersects(viewBounds) && !calculateCompositedBounds(layer, rootRenderLayer()).intersects(viewBounds))
+ return false;
+ }
return true;
}
Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.h (130395 => 130396)
--- trunk/Source/WebCore/rendering/RenderLayerCompositor.h 2012-10-04 15:52:29 UTC (rev 130395)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.h 2012-10-04 15:57:50 UTC (rev 130396)
@@ -124,7 +124,7 @@
bool needsContentsCompositingLayer(const RenderLayer*) const;
// Return the bounding box required for compositing layer and its childern, relative to ancestorLayer.
// If layerBoundingBox is not 0, on return it contains the bounding box of this layer only.
- IntRect calculateCompositedBounds(const RenderLayer*, const RenderLayer* ancestorLayer);
+ IntRect calculateCompositedBounds(const RenderLayer*, const RenderLayer* ancestorLayer) const;
// Repaint the appropriate layers when the given RenderLayer starts or stops being composited.
void repaintOnCompositingChange(RenderLayer*);
Modified: trunk/Source/WebCore/testing/InternalSettings.cpp (130395 => 130396)
--- trunk/Source/WebCore/testing/InternalSettings.cpp 2012-10-04 15:52:29 UTC (rev 130395)
+++ trunk/Source/WebCore/testing/InternalSettings.cpp 2012-10-04 15:57:50 UTC (rev 130396)
@@ -81,6 +81,7 @@
#endif
, m_originalEditingBehavior(settings->editingBehaviorType())
, m_originalUnifiedSpellCheckerEnabled(settings->unifiedTextCheckerEnabled())
+ , m_originalAcceleratedCompositingForFixedPositionEnabled(settings->acceleratedCompositingForFixedPositionEnabled())
, m_originalFixedPositionCreatesStackingContext(settings->fixedPositionCreatesStackingContext())
, m_originalSyncXHRInDocumentsEnabled(settings->syncXHRInDocumentsEnabled())
#if ENABLE(INSPECTOR) && ENABLE(_javascript__DEBUGGER)
@@ -116,6 +117,7 @@
#endif
settings->setEditingBehaviorType(m_originalEditingBehavior);
settings->setUnifiedTextCheckerEnabled(m_originalUnifiedSpellCheckerEnabled);
+ settings->setAcceleratedCompositingForFixedPositionEnabled(m_originalAcceleratedCompositingForFixedPositionEnabled);
settings->setFixedPositionCreatesStackingContext(m_originalFixedPositionCreatesStackingContext);
settings->setSyncXHRInDocumentsEnabled(m_originalSyncXHRInDocumentsEnabled);
#if ENABLE(INSPECTOR) && ENABLE(_javascript__DEBUGGER)
Modified: trunk/Source/WebCore/testing/InternalSettings.h (130395 => 130396)
--- trunk/Source/WebCore/testing/InternalSettings.h 2012-10-04 15:52:29 UTC (rev 130395)
+++ trunk/Source/WebCore/testing/InternalSettings.h 2012-10-04 15:57:50 UTC (rev 130396)
@@ -63,6 +63,7 @@
#endif
EditingBehaviorType m_originalEditingBehavior;
bool m_originalUnifiedSpellCheckerEnabled;
+ bool m_originalAcceleratedCompositingForFixedPositionEnabled;
bool m_originalFixedPositionCreatesStackingContext;
bool m_originalSyncXHRInDocumentsEnabled;
#if ENABLE(INSPECTOR) && ENABLE(_javascript__DEBUGGER)