haikuwebkit/LayoutTests/compositing/layer-creation/fixed-position-descendants-...

62 lines
1.4 KiB
HTML
Raw Permalink Normal View History

[iOS WK2] Avoid lots of compositing backing store for offscreen position:fixed descendants https://bugs.webkit.org/show_bug.cgi?id=199819 rdar://problem/51977416 Reviewed by Zalan Bujtas. Source/WebCore: There was code to ensure that position:fixed layers and their descendants don't have their backing store detached (thrown away to save memory when offscreen), since that can trigger flashing when async scrolling moves layers in and out of the visual viewport. However, some pages have many descendant layers of positon:fixed which entrain backing store, because, for example, they have a stack of translated-offscreen menu elements inside a fixed header, and those elements may composite because of overflow:scroll. To avoid using too much memory on such pages, allow backing store detachment for fixed layers that are outside the layout viewport. Add a flag to RenderLayer that's set for layers which are fixed, or descendants of fixed, and consult that flag in updateAllowsBackingStoreDetaching(). The logic there is similar to RenderLayerCompositor::requiresCompositingForPosition(). I considered allowing all position:fixed to composite (since this patch would keep most of the memory saving), but historically we've avoided compositing out-of-viewport position:fixed because it's quite common to have them with negative z-index, and compositing those has significant compositing knock-on effects. GraphicsLayer flushing no longer needs to track the viewport-constrained status of layers, so remove that code. This patch removes backing-store pinning for sticky layers. scrolling/ios/reconcile-layer-position-recursive.html then revealed a bug in ScrollingStateStickyNode::reconcileLayerPositionForViewportRect(), which was assuming that the sticky element was scrolled by the page, causing a bad layer position to get sync'd onto the layer. Fixed by copying code from ScrollingTreeStickyNode that is smarter about computing layer positions. This patch fixes jetsams on kmart.com.au in iOS 13 beta. Test: compositing/layer-creation/fixed-position-descendants-out-of-view.html * page/scrolling/ScrollingStateStickyNode.cpp: (WebCore::ScrollingStateStickyNode::computeLayerPosition const): (WebCore::ScrollingStateStickyNode::reconcileLayerPositionForViewportRect): * page/scrolling/ScrollingStateStickyNode.h: * platform/graphics/GraphicsLayer.h: (WebCore::GraphicsLayer::setAllowsBackingStoreDetaching): (WebCore::GraphicsLayer::allowsBackingStoreDetaching const): (WebCore::GraphicsLayer::setIsViewportConstrained): Deleted. (WebCore::GraphicsLayer::isViewportConstrained const): Deleted. (WebCore::GraphicsLayer::setCanDetachBackingStore): Deleted. (WebCore::GraphicsLayer::canDetachBackingStore const): Deleted. * platform/graphics/ca/GraphicsLayerCA.cpp: (WebCore::GraphicsLayerCA::GraphicsLayerCA): (WebCore::GraphicsLayerCA::recursiveVisibleRectChangeRequiresFlush const): (WebCore::GraphicsLayerCA::setVisibleAndCoverageRects): (WebCore::GraphicsLayerCA::recursiveCommitChanges): (WebCore::GraphicsLayerCA::updateCoverage): (WebCore::GraphicsLayerCA::createTransformAnimationsFromKeyframes): * platform/graphics/ca/GraphicsLayerCA.h: * rendering/RenderLayer.cpp: (WebCore::RenderLayer::RenderLayer): (WebCore::RenderLayer::updateLayerPositions): (WebCore::outputPaintOrderTreeLegend): (WebCore::outputPaintOrderTreeRecursive): * rendering/RenderLayer.h: * rendering/RenderLayerBacking.cpp: (WebCore::RenderLayerBacking::updateAllowsBackingStoreDetaching): (WebCore::RenderLayerBacking::updateOverflowControlsLayers): (WebCore::RenderLayerBacking::setIsScrollCoordinatedWithViewportConstrainedRole): Deleted. * rendering/RenderLayerBacking.h: * rendering/RenderLayerCompositor.cpp: (WebCore::RenderLayerCompositor::computeCompositingRequirements): (WebCore::RenderLayerCompositor::requiresCompositingForPosition const): (WebCore::RenderLayerCompositor::updateOverflowControlsLayers): (WebCore::RenderLayerCompositor::updateScrollCoordinationForLayer): LayoutTests: * compositing/layer-creation/fixed-position-change-out-of-view-in-view.html: * compositing/layer-creation/fixed-position-descendants-out-of-view-expected.txt: Added. * compositing/layer-creation/fixed-position-descendants-out-of-view.html: Added. * compositing/layer-creation/fixed-position-out-of-view.html: * platform/ios-wk2/fast/scrolling/ios/reconcile-layer-position-recursive-expected.txt: Added. Canonical link: https://commits.webkit.org/213760@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247540 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-07-17 22:49:39 +00:00
<!DOCTYPE html>
<html>
<head>
<style>
.fixed {
position: fixed;
width: 100px;
height: 100px;
background-color: silver;
transform: translateX(0); /* Defeat clip to viewport */
}
.offscreen {
transform: translateX(-110%);
}
.absolute {
position: absolute;
width: 100px;
height: 100px;
border: 1px solid black;
transform: translateZ(0);
}
.absolute.onscreen {
transform: translate3d(120%, 0, 0);
}
</style>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
window.addEventListener("load", () => {
document.getElementById("layertree").innerText = window.internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_BACKING_STORE_ATTACHED);
}, false);
}
</script>
</head>
<body>
<div class="fixed container">
<div class="absolute">
</div>
</div>
<div class="fixed offscreen container" style="top: 120px">
<div class="absolute">
</div>
</div>
<div class="fixed offscreen container" style="top: 240px">
<div class="absolute onscreen">
</div>
</div>
<pre id="layertree"></pre>
</body>
</html>