Skip to content

Commit 2a5bd0f

Browse files
committed
Make ::backdrop renderers use background layers when possible
https://bugs.webkit.org/show_bug.cgi?id=248148 rdar://102566049 Reviewed by Simon Fraser. Right now, when rotating in fullscreen on iPad, there are white gaps around the edges. This was avoided by RenderFullscreen using "background layers" that are 3x the size with a negative offset. Now that RenderFullscreen is gone, we need to target ::backdrop pseudo elements that have: - The same rect as the RenderView - position: fixed, since position: absolute can allow scrolling away from the ::backdrop, since the containing block is the ICB - No transforms/clips/masks (since they intentionally do not cover the whole screen) Also clean up remainders of RenderFullscreen which has been removed in 255641@main. * LayoutTests/compositing/no-compositing-when-full-screen-is-present-expected.txt: * LayoutTests/compositing/no-compositing-when-full-screen-is-present.html: * LayoutTests/platform/gtk/compositing/no-compositing-when-full-screen-is-present-expected.txt: Update test expectations to reflect that ::backdrop is now layer backed in fullscreen. * LayoutTests/TestExpectations: * LayoutTests/fullscreen/full-screen-layer-dump-expected.txt: * LayoutTests/fullscreen/full-screen-layer-dump.html: Make test expectation more clear in the description to avoid regressing this test again, and update test expectation to reflect that "background layers" now work again. * Source/WebCore/rendering/RenderElement.cpp: (WebCore::RenderElement::propagateStyleToAnonymousChildren): * Source/WebCore/rendering/RenderLayerBacking.cpp: (WebCore::RenderLayerBacking::RenderLayerBacking): * Source/WebCore/rendering/RenderLayerCompositor.cpp: (WebCore::isDescendantOfFullScreenLayer): Consider the fullscreen element's associated ::backdrop as fullscreen layer, otherwise the renderer is never layer-backed meaning we can't use "background layers". We avoid backing non-fullscreen layers to optimize for power usage. * Source/WebCore/rendering/RenderObject.h: (WebCore::RenderObject::isAttachment const): (WebCore::RenderObject::isAnonymousBlock const): (WebCore::RenderObject::isRenderFullScreen const): Deleted. (WebCore::RenderObject::isRenderFullScreenPlaceholder const): Deleted. Canonical link: https://commits.webkit.org/257538@main
1 parent 60342c9 commit 2a5bd0f

10 files changed

+92
-29
lines changed

LayoutTests/TestExpectations

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6176,9 +6176,6 @@ imported/w3c/web-platform-tests/xhr/send-after-setting-document-domain.htm [ Ski
61766176
fast/text/text-edge-no-half-leading-simple.html [ Skip ]
61776177
fast/text/text-edge-no-half-leading-with-line-height-simple.html [ Skip ]
61786178

6179-
# This test isn't working as expected, it will be fixed in webkit.org/b/248148.
6180-
webkit.org/b/248148 fullscreen/full-screen-layer-dump.html [ Failure ]
6181-
61826179
# CSS Nesting
61836180
imported/w3c/web-platform-tests/css/css-nesting/conditional-properties.html [ ImageOnlyFailure ]
61846181
imported/w3c/web-platform-tests/css/css-nesting/conditional-rules.html [ ImageOnlyFailure ]

LayoutTests/compositing/no-compositing-when-full-screen-is-present-expected.txt

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Test that only elements in fullscreen subtree get layer backed.
1+
Test that only elements in fullscreen subtree and the associated backdrop get layer backed.
22

33
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
44

@@ -17,7 +17,28 @@ foobar
1717
(bounds 800.00 600.00)
1818
(contentsOpaque 1)
1919
(backingStoreAttached 1)
20-
(children 1
20+
(children 2
21+
(GraphicsLayer
22+
(preserves3D 1)
23+
(backingStoreAttached 0)
24+
(children 1
25+
(GraphicsLayer
26+
(bounds 800.00 600.00)
27+
(backingStoreAttached 1)
28+
(children 2
29+
(GraphicsLayer
30+
(anchor 0.00 0.00)
31+
(bounds 800.00 600.00)
32+
(backingStoreAttached 1)
33+
)
34+
(GraphicsLayer
35+
(bounds 800.00 600.00)
36+
(backingStoreAttached 1)
37+
)
38+
)
39+
)
40+
)
41+
)
2142
(GraphicsLayer
2243
(preserves3D 1)
2344
(backingStoreAttached 0)

LayoutTests/compositing/no-compositing-when-full-screen-is-present.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<script src="../resources/js-test.js"></script>
1010
<script>
1111

12-
description("Test that only elements in fullscreen subtree get layer backed.");
12+
description("Test that only elements in fullscreen subtree and the associated backdrop get layer backed.");
1313

1414
function goFullscreen() {
1515
host.webkitRequestFullscreen();

LayoutTests/fullscreen/full-screen-layer-dump-expected.txt

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,42 @@
1+
Test passes if you see a contents layer 3x the size and with a negative offset equal to the size:
2+
13
(GraphicsLayer
24
(anchor 0.00 0.00)
35
(bounds 800.00 600.00)
46
(children 1
57
(GraphicsLayer
68
(bounds 800.00 600.00)
79
(contentsOpaque 1)
8-
(children 1
10+
(children 2
911
(GraphicsLayer
1012
(preserves3D 1)
1113
(children 1
1214
(GraphicsLayer
1315
(bounds 800.00 600.00)
14-
(contentsOpaque 1)
15-
(contents layer (background color)
16-
(position 0.00 0.00)
17-
(bounds 800.00 600.00)
16+
(children 2
17+
(GraphicsLayer
18+
(anchor 0.00 0.00)
19+
(bounds 800.00 600.00)
20+
(contents layer (background color)
21+
(position -800.00 -600.00)
22+
(bounds 2400.00 1800.00)
23+
)
24+
)
25+
(GraphicsLayer
26+
(bounds 800.00 600.00)
27+
)
1828
)
1929
)
2030
)
2131
)
32+
(GraphicsLayer
33+
(preserves3D 1)
34+
(children 1
35+
(GraphicsLayer
36+
(bounds 800.00 600.00)
37+
)
38+
)
39+
)
2240
)
2341
)
2442
)

LayoutTests/fullscreen/full-screen-layer-dump.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
document.addEventListener('webkitfullscreenchange', event => {
2424
if (document.webkitIsFullScreen) {
2525
setTimeout(() => {
26-
out.innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_CONTENT_LAYERS);
26+
out.innerText = "Test passes if you see a contents layer 3x the size and with a negative offset equal to the size:\n\n";
27+
out.innerText += internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_CONTENT_LAYERS);
2728
document.webkitCancelFullScreen();
2829
}, 0)
2930
} else

LayoutTests/platform/gtk/compositing/no-compositing-when-full-screen-is-present-expected.txt

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Test that only elements in fullscreen subtree get layer backed.
1+
Test that only elements in fullscreen subtree and the associated backdrop get layer backed.
22

33
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
44

@@ -17,7 +17,28 @@ foobar
1717
(bounds 800.00 600.00)
1818
(contentsOpaque 1)
1919
(backingStoreAttached 1)
20-
(children 1
20+
(children 2
21+
(GraphicsLayer
22+
(preserves3D 1)
23+
(backingStoreAttached 1)
24+
(children 1
25+
(GraphicsLayer
26+
(bounds 800.00 600.00)
27+
(backingStoreAttached 1)
28+
(children 2
29+
(GraphicsLayer
30+
(anchor 0.00 0.00)
31+
(bounds 800.00 600.00)
32+
(backingStoreAttached 1)
33+
)
34+
(GraphicsLayer
35+
(bounds 800.00 600.00)
36+
(backingStoreAttached 1)
37+
)
38+
)
39+
)
40+
)
41+
)
2142
(GraphicsLayer
2243
(preserves3D 1)
2344
(backingStoreAttached 1)

Source/WebCore/rendering/RenderElement.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -757,11 +757,6 @@ void RenderElement::propagateStyleToAnonymousChildren(StylePropagationType propa
757757
if (propagationType == PropagateToBlockChildrenOnly && !is<RenderBlock>(elementChild))
758758
continue;
759759

760-
#if ENABLE(FULLSCREEN_API)
761-
if (elementChild.isRenderFullScreen() || elementChild.isRenderFullScreenPlaceholder())
762-
continue;
763-
#endif
764-
765760
// RenderFragmentedFlows are updated through the RenderView::styleDidChange function.
766761
if (is<RenderFragmentedFlow>(elementChild))
767762
continue;

Source/WebCore/rendering/RenderLayerBacking.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,24 @@ RenderLayerBacking::RenderLayerBacking(RenderLayer& layer)
205205
m_isMainFrameRenderViewLayer = renderer().frame().isMainFrame();
206206
m_isFrameLayerWithTiledBacking = renderer().page().chrome().client().shouldUseTiledBackingForFrameView(renderer().view().frameView());
207207
}
208-
208+
209209
createPrimaryGraphicsLayer();
210210
#if ENABLE(FULLSCREEN_API)
211-
setRequiresBackgroundLayer(layer.renderer().isRenderFullScreen());
211+
auto isFullsizeBackdrop = [](const RenderElement& renderer) -> bool {
212+
auto& style = renderer.style();
213+
if (style.styleType() != PseudoId::Backdrop || style.position() != PositionType::Fixed)
214+
return false;
215+
216+
if (style.hasTransform() || style.hasClip() || style.hasMask())
217+
return false;
218+
219+
if (!is<RenderBox>(renderer))
220+
return false;
221+
222+
auto rendererRect = downcast<RenderBox>(renderer).frameRect();
223+
return rendererRect == renderer.view().frameRect();
224+
};
225+
setRequiresBackgroundLayer(isFullsizeBackdrop(layer.renderer()));
212226
#endif
213227

214228
if (auto* tiledBacking = this->tiledBacking()) {

Source/WebCore/rendering/RenderLayerCompositor.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2670,6 +2670,10 @@ static FullScreenDescendant isDescendantOfFullScreenLayer(const RenderLayer& lay
26702670
if (!fullScreenRenderer || !fullScreenLayer)
26712671
return FullScreenDescendant::NotApplicable;
26722672

2673+
auto backdropRenderer = fullScreenRenderer->backdropRenderer();
2674+
if (backdropRenderer && backdropRenderer.get() == &layer.renderer())
2675+
return FullScreenDescendant::Yes;
2676+
26732677
return layer.isDescendantOf(*fullScreenLayer) ? FullScreenDescendant::Yes : FullScreenDescendant::No;
26742678
}
26752679
#endif

Source/WebCore/rendering/RenderObject.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,6 @@ class RenderObject : public CachedImageClient {
262262
virtual bool isCanvas() const { return false; }
263263
#if ENABLE(ATTACHMENT_ELEMENT)
264264
virtual bool isAttachment() const { return false; }
265-
#endif
266-
#if ENABLE(FULLSCREEN_API)
267-
virtual bool isRenderFullScreen() const { return false; }
268-
virtual bool isRenderFullScreenPlaceholder() const { return false; }
269265
#endif
270266
virtual bool isRenderGrid() const { return false; }
271267

@@ -1159,10 +1155,6 @@ inline bool RenderObject::isAnonymousBlock() const
11591155
&& (style().display() == DisplayType::Block || style().display() == DisplayType::Box)
11601156
&& style().styleType() == PseudoId::None
11611157
&& isRenderBlock()
1162-
#if ENABLE(FULLSCREEN_API)
1163-
&& !isRenderFullScreen()
1164-
&& !isRenderFullScreenPlaceholder()
1165-
#endif
11661158
#if ENABLE(MATHML)
11671159
&& !isRenderMathMLBlock()
11681160
#endif

0 commit comments

Comments
 (0)