- Revision
- 288530
- Author
- [email protected]
- Date
- 2022-01-24 17:56:58 -0800 (Mon, 24 Jan 2022)
Log Message
Cherry-pick r288429. rdar://problem/86612099
Position:fixed layers shouldn't allocate a backing buffer if all children are offscreen.
https://bugs.webkit.org/show_bug.cgi?id=235420
<rdar://86612099>
Patch by Matt Woodrow <[email protected]> on 2022-01-23
Reviewed by Simon Fraser and Darin Adler.
Source/WebCore:
Adds a bounds intersection check to isPaintDestinationForDescendantLayers,
so that we can exclude descendants that definitely won't draw anything into
the compositing layer. Uses a conservative check, which gives up if there are
any transforms in the ancestor chain.
Test: compositing/backing/no-backing-for-offscreen-children-of-position-fixed.html
* rendering/RenderLayerBacking.cpp:
(WebCore::intersectsWithAncestor):
(WebCore::RenderLayerBacking::isPaintDestinationForDescendantLayers const):
LayoutTests:
Adds a test that has a viewport sized position:fixed element (with compositing
layer), and a single child which is entirely offscreen. Tests that we correctly
determine that we don't need a backing store for the layer.
* compositing/backing/no-backing-for-offscreen-children-of-position-fixed-expected.txt: Added.
* compositing/backing/no-backing-for-offscreen-children-of-position-fixed.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288429 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Modified Paths
Added Paths
Diff
Modified: branches/safari-613-branch/LayoutTests/ChangeLog (288529 => 288530)
--- branches/safari-613-branch/LayoutTests/ChangeLog 2022-01-25 01:56:53 UTC (rev 288529)
+++ branches/safari-613-branch/LayoutTests/ChangeLog 2022-01-25 01:56:58 UTC (rev 288530)
@@ -1,5 +1,55 @@
2022-01-24 Alan Coon <[email protected]>
+ Cherry-pick r288429. rdar://problem/86612099
+
+ Position:fixed layers shouldn't allocate a backing buffer if all children are offscreen.
+ https://bugs.webkit.org/show_bug.cgi?id=235420
+ <rdar://86612099>
+
+ Patch by Matt Woodrow <[email protected]> on 2022-01-23
+ Reviewed by Simon Fraser and Darin Adler.
+
+ Source/WebCore:
+
+ Adds a bounds intersection check to isPaintDestinationForDescendantLayers,
+ so that we can exclude descendants that definitely won't draw anything into
+ the compositing layer. Uses a conservative check, which gives up if there are
+ any transforms in the ancestor chain.
+
+ Test: compositing/backing/no-backing-for-offscreen-children-of-position-fixed.html
+
+ * rendering/RenderLayerBacking.cpp:
+ (WebCore::intersectsWithAncestor):
+ (WebCore::RenderLayerBacking::isPaintDestinationForDescendantLayers const):
+
+ LayoutTests:
+
+ Adds a test that has a viewport sized position:fixed element (with compositing
+ layer), and a single child which is entirely offscreen. Tests that we correctly
+ determine that we don't need a backing store for the layer.
+
+ * compositing/backing/no-backing-for-offscreen-children-of-position-fixed-expected.txt: Added.
+ * compositing/backing/no-backing-for-offscreen-children-of-position-fixed.html: Added.
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288429 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2022-01-23 Matt Woodrow <[email protected]>
+
+ Position:fixed layers shouldn't allocate a backing buffer if all children are offscreen.
+ https://bugs.webkit.org/show_bug.cgi?id=235420
+ <rdar://86612099>
+
+ Reviewed by Simon Fraser and Darin Adler.
+
+ Adds a test that has a viewport sized position:fixed element (with compositing
+ layer), and a single child which is entirely offscreen. Tests that we correctly
+ determine that we don't need a backing store for the layer.
+
+ * compositing/backing/no-backing-for-offscreen-children-of-position-fixed-expected.txt: Added.
+ * compositing/backing/no-backing-for-offscreen-children-of-position-fixed.html: Added.
+
+2022-01-24 Alan Coon <[email protected]>
+
Cherry-pick r288336. rdar://problem/86558157
REGRESSION (r284136): A slight horizontal rubberband kills scroll momentum
Copied: branches/safari-613-branch/LayoutTests/compositing/backing/no-backing-for-offscreen-children-of-position-fixed-expected.txt (from rev 288529, branches/safari-613-branch/LayoutTests/compositing/clip-child-by-non-stacking-ancestor-expected.txt) (0 => 288530)
--- branches/safari-613-branch/LayoutTests/compositing/backing/no-backing-for-offscreen-children-of-position-fixed-expected.txt (rev 0)
+++ branches/safari-613-branch/LayoutTests/compositing/backing/no-backing-for-offscreen-children-of-position-fixed-expected.txt 2022-01-25 01:56:58 UTC (rev 288530)
@@ -0,0 +1,16 @@
+(GraphicsLayer
+ (anchor 0.00 0.00)
+ (bounds 800.00 600.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 800.00 600.00)
+ (contentsOpaque 1)
+ (children 1
+ (GraphicsLayer
+ (bounds 200.00 200.00)
+ )
+ )
+ )
+ )
+)
+
Added: branches/safari-613-branch/LayoutTests/compositing/backing/no-backing-for-offscreen-children-of-position-fixed.html (0 => 288530)
--- branches/safari-613-branch/LayoutTests/compositing/backing/no-backing-for-offscreen-children-of-position-fixed.html (rev 0)
+++ branches/safari-613-branch/LayoutTests/compositing/backing/no-backing-for-offscreen-children-of-position-fixed.html 2022-01-25 01:56:58 UTC (rev 288530)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script>
+ if (window.testRunner)
+ testRunner.dumpAsText();
+
+ function dumpLayers()
+ {
+ var layersResult = document.getElementById('layers');
+ if (window.testRunner)
+ layersResult.innerText = window.internals.layerTreeAsText(document);
+
+ }
+ window.addEventListener('load', dumpLayers, false)
+ </script>
+</head>
+<body>
+ <div style="position: fixed; left: 0; top: 0; width:200px; height:200px;">
+ <div style="position: absolute; left: -300px; width: 300px; height: 200px; background-color: blue;"></div>
+ </div>
+<pre id="layers">Layer tree goes here in DRT</pre>
+</body>
+</html>
Modified: branches/safari-613-branch/LayoutTests/compositing/clip-child-by-non-stacking-ancestor-expected.txt (288529 => 288530)
--- branches/safari-613-branch/LayoutTests/compositing/clip-child-by-non-stacking-ancestor-expected.txt 2022-01-25 01:56:53 UTC (rev 288529)
+++ branches/safari-613-branch/LayoutTests/compositing/clip-child-by-non-stacking-ancestor-expected.txt 2022-01-25 01:56:58 UTC (rev 288530)
@@ -10,7 +10,6 @@
(position 8.00 8.00)
(bounds 100.00 100.00)
(contentsOpaque 1)
- (drawsContent 1)
)
)
)
Modified: branches/safari-613-branch/LayoutTests/compositing/geometry/limit-layer-bounds-fixed-expected.txt (288529 => 288530)
--- branches/safari-613-branch/LayoutTests/compositing/geometry/limit-layer-bounds-fixed-expected.txt 2022-01-25 01:56:53 UTC (rev 288529)
+++ branches/safari-613-branch/LayoutTests/compositing/geometry/limit-layer-bounds-fixed-expected.txt 2022-01-25 01:56:58 UTC (rev 288530)
@@ -15,7 +15,6 @@
(offsetFromRenderer width=-100 height=-100)
(position 0.00 3000.00)
(bounds 300.00 200.00)
- (drawsContent 1)
)
)
)
Modified: branches/safari-613-branch/LayoutTests/platform/ios-wk2/compositing/geometry/limit-layer-bounds-fixed-expected.txt (288529 => 288530)
--- branches/safari-613-branch/LayoutTests/platform/ios-wk2/compositing/geometry/limit-layer-bounds-fixed-expected.txt 2022-01-25 01:56:53 UTC (rev 288529)
+++ branches/safari-613-branch/LayoutTests/platform/ios-wk2/compositing/geometry/limit-layer-bounds-fixed-expected.txt 2022-01-25 01:56:58 UTC (rev 288530)
@@ -15,7 +15,6 @@
(offsetFromRenderer width=-100 height=-100)
(position 0.00 3000.00)
(bounds 300.00 200.00)
- (drawsContent 1)
)
)
)
Modified: branches/safari-613-branch/Source/WebCore/ChangeLog (288529 => 288530)
--- branches/safari-613-branch/Source/WebCore/ChangeLog 2022-01-25 01:56:53 UTC (rev 288529)
+++ branches/safari-613-branch/Source/WebCore/ChangeLog 2022-01-25 01:56:58 UTC (rev 288530)
@@ -1,5 +1,59 @@
2022-01-24 Alan Coon <[email protected]>
+ Cherry-pick r288429. rdar://problem/86612099
+
+ Position:fixed layers shouldn't allocate a backing buffer if all children are offscreen.
+ https://bugs.webkit.org/show_bug.cgi?id=235420
+ <rdar://86612099>
+
+ Patch by Matt Woodrow <[email protected]> on 2022-01-23
+ Reviewed by Simon Fraser and Darin Adler.
+
+ Source/WebCore:
+
+ Adds a bounds intersection check to isPaintDestinationForDescendantLayers,
+ so that we can exclude descendants that definitely won't draw anything into
+ the compositing layer. Uses a conservative check, which gives up if there are
+ any transforms in the ancestor chain.
+
+ Test: compositing/backing/no-backing-for-offscreen-children-of-position-fixed.html
+
+ * rendering/RenderLayerBacking.cpp:
+ (WebCore::intersectsWithAncestor):
+ (WebCore::RenderLayerBacking::isPaintDestinationForDescendantLayers const):
+
+ LayoutTests:
+
+ Adds a test that has a viewport sized position:fixed element (with compositing
+ layer), and a single child which is entirely offscreen. Tests that we correctly
+ determine that we don't need a backing store for the layer.
+
+ * compositing/backing/no-backing-for-offscreen-children-of-position-fixed-expected.txt: Added.
+ * compositing/backing/no-backing-for-offscreen-children-of-position-fixed.html: Added.
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288429 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2022-01-23 Matt Woodrow <[email protected]>
+
+ Position:fixed layers shouldn't allocate a backing buffer if all children are offscreen.
+ https://bugs.webkit.org/show_bug.cgi?id=235420
+ <rdar://86612099>
+
+ Reviewed by Simon Fraser and Darin Adler.
+
+ Adds a bounds intersection check to isPaintDestinationForDescendantLayers,
+ so that we can exclude descendants that definitely won't draw anything into
+ the compositing layer. Uses a conservative check, which gives up if there are
+ any transforms in the ancestor chain.
+
+ Test: compositing/backing/no-backing-for-offscreen-children-of-position-fixed.html
+
+ * rendering/RenderLayerBacking.cpp:
+ (WebCore::intersectsWithAncestor):
+ (WebCore::RenderLayerBacking::isPaintDestinationForDescendantLayers const):
+
+2022-01-24 Alan Coon <[email protected]>
+
Cherry-pick r288415. rdar://problem/87904254
REGRESSION(r280887) broke some svg based chart content repaint
Modified: branches/safari-613-branch/Source/WebCore/rendering/RenderLayerBacking.cpp (288529 => 288530)
--- branches/safari-613-branch/Source/WebCore/rendering/RenderLayerBacking.cpp 2022-01-25 01:56:53 UTC (rev 288529)
+++ branches/safari-613-branch/Source/WebCore/rendering/RenderLayerBacking.cpp 2022-01-25 01:56:58 UTC (rev 288530)
@@ -2790,12 +2790,34 @@
return LayerTraversal::Continue;
}
+static std::optional<bool> intersectsWithAncestor(const RenderLayer& child, const RenderLayer& ancestor, const LayoutRect& ancestorCompositedBounds)
+{
+ // If any layers between child and ancestor are transformed, then adjusting the offset is
+ // insufficient to convert coordinates into ancestor's coordinate space.
+ for (auto* layer = &child; layer != &ancestor; layer = layer->parent()) {
+ if (!layer->canUseOffsetFromAncestor())
+ return std::nullopt;
+ }
+
+ auto offset = child.convertToLayerCoords(&ancestor, { }, RenderLayer::AdjustForColumns);
+ auto overlap = child.overlapBounds();
+ overlap.moveBy(offset);
+ return overlap.intersects(ancestorCompositedBounds);
+}
+
// Conservative test for having no rendered children.
bool RenderLayerBacking::isPaintDestinationForDescendantLayers(RenderLayer::PaintedContentRequest& request) const
{
bool hasPaintingDescendant = false;
- traverseVisibleNonCompositedDescendantLayers(m_owningLayer, [&hasPaintingDescendant, &request](const RenderLayer& layer) {
- hasPaintingDescendant |= layer.isVisuallyNonEmpty(&request);
+ traverseVisibleNonCompositedDescendantLayers(m_owningLayer, [&hasPaintingDescendant, &request, this](const RenderLayer& layer) {
+ RenderLayer::PaintedContentRequest localRequest;
+ if (layer.isVisuallyNonEmpty(&localRequest)) {
+ bool mayIntersect = intersectsWithAncestor(layer, m_owningLayer, compositedBounds()).value_or(true);
+ if (mayIntersect) {
+ hasPaintingDescendant = true;
+ request.setHasPaintedContent();
+ }
+ }
return (hasPaintingDescendant && request.isSatisfied()) ? LayerTraversal::Stop : LayerTraversal::Continue;
});