Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nt1m committed Dec 8, 2022
1 parent 60342c9 commit 2a5bd0f
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 29 deletions.
3 changes: 0 additions & 3 deletions LayoutTests/TestExpectations
Expand Up @@ -6176,9 +6176,6 @@ imported/w3c/web-platform-tests/xhr/send-after-setting-document-domain.htm [ Ski
fast/text/text-edge-no-half-leading-simple.html [ Skip ]
fast/text/text-edge-no-half-leading-with-line-height-simple.html [ Skip ]

# This test isn't working as expected, it will be fixed in webkit.org/b/248148.
webkit.org/b/248148 fullscreen/full-screen-layer-dump.html [ Failure ]

# CSS Nesting
imported/w3c/web-platform-tests/css/css-nesting/conditional-properties.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-nesting/conditional-rules.html [ ImageOnlyFailure ]
Expand Down
@@ -1,4 +1,4 @@
Test that only elements in fullscreen subtree get layer backed.
Test that only elements in fullscreen subtree and the associated backdrop get layer backed.

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

Expand All @@ -17,7 +17,28 @@ foobar
(bounds 800.00 600.00)
(contentsOpaque 1)
(backingStoreAttached 1)
(children 1
(children 2
(GraphicsLayer
(preserves3D 1)
(backingStoreAttached 0)
(children 1
(GraphicsLayer
(bounds 800.00 600.00)
(backingStoreAttached 1)
(children 2
(GraphicsLayer
(anchor 0.00 0.00)
(bounds 800.00 600.00)
(backingStoreAttached 1)
)
(GraphicsLayer
(bounds 800.00 600.00)
(backingStoreAttached 1)
)
)
)
)
)
(GraphicsLayer
(preserves3D 1)
(backingStoreAttached 0)
Expand Down
Expand Up @@ -9,7 +9,7 @@
<script src="../resources/js-test.js"></script>
<script>

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

function goFullscreen() {
host.webkitRequestFullscreen();
Expand Down
28 changes: 23 additions & 5 deletions LayoutTests/fullscreen/full-screen-layer-dump-expected.txt
@@ -1,24 +1,42 @@
Test passes if you see a contents layer 3x the size and with a negative offset equal to the size:

(GraphicsLayer
(anchor 0.00 0.00)
(bounds 800.00 600.00)
(children 1
(GraphicsLayer
(bounds 800.00 600.00)
(contentsOpaque 1)
(children 1
(children 2
(GraphicsLayer
(preserves3D 1)
(children 1
(GraphicsLayer
(bounds 800.00 600.00)
(contentsOpaque 1)
(contents layer (background color)
(position 0.00 0.00)
(bounds 800.00 600.00)
(children 2
(GraphicsLayer
(anchor 0.00 0.00)
(bounds 800.00 600.00)
(contents layer (background color)
(position -800.00 -600.00)
(bounds 2400.00 1800.00)
)
)
(GraphicsLayer
(bounds 800.00 600.00)
)
)
)
)
)
(GraphicsLayer
(preserves3D 1)
(children 1
(GraphicsLayer
(bounds 800.00 600.00)
)
)
)
)
)
)
Expand Down
3 changes: 2 additions & 1 deletion LayoutTests/fullscreen/full-screen-layer-dump.html
Expand Up @@ -23,7 +23,8 @@
document.addEventListener('webkitfullscreenchange', event => {
if (document.webkitIsFullScreen) {
setTimeout(() => {
out.innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_CONTENT_LAYERS);
out.innerText = "Test passes if you see a contents layer 3x the size and with a negative offset equal to the size:\n\n";
out.innerText += internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_CONTENT_LAYERS);
document.webkitCancelFullScreen();
}, 0)
} else
Expand Down
@@ -1,4 +1,4 @@
Test that only elements in fullscreen subtree get layer backed.
Test that only elements in fullscreen subtree and the associated backdrop get layer backed.

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

Expand All @@ -17,7 +17,28 @@ foobar
(bounds 800.00 600.00)
(contentsOpaque 1)
(backingStoreAttached 1)
(children 1
(children 2
(GraphicsLayer
(preserves3D 1)
(backingStoreAttached 1)
(children 1
(GraphicsLayer
(bounds 800.00 600.00)
(backingStoreAttached 1)
(children 2
(GraphicsLayer
(anchor 0.00 0.00)
(bounds 800.00 600.00)
(backingStoreAttached 1)
)
(GraphicsLayer
(bounds 800.00 600.00)
(backingStoreAttached 1)
)
)
)
)
)
(GraphicsLayer
(preserves3D 1)
(backingStoreAttached 1)
Expand Down
5 changes: 0 additions & 5 deletions Source/WebCore/rendering/RenderElement.cpp
Expand Up @@ -757,11 +757,6 @@ void RenderElement::propagateStyleToAnonymousChildren(StylePropagationType propa
if (propagationType == PropagateToBlockChildrenOnly && !is<RenderBlock>(elementChild))
continue;

#if ENABLE(FULLSCREEN_API)
if (elementChild.isRenderFullScreen() || elementChild.isRenderFullScreenPlaceholder())
continue;
#endif

// RenderFragmentedFlows are updated through the RenderView::styleDidChange function.
if (is<RenderFragmentedFlow>(elementChild))
continue;
Expand Down
18 changes: 16 additions & 2 deletions Source/WebCore/rendering/RenderLayerBacking.cpp
Expand Up @@ -205,10 +205,24 @@ RenderLayerBacking::RenderLayerBacking(RenderLayer& layer)
m_isMainFrameRenderViewLayer = renderer().frame().isMainFrame();
m_isFrameLayerWithTiledBacking = renderer().page().chrome().client().shouldUseTiledBackingForFrameView(renderer().view().frameView());
}

createPrimaryGraphicsLayer();
#if ENABLE(FULLSCREEN_API)
setRequiresBackgroundLayer(layer.renderer().isRenderFullScreen());
auto isFullsizeBackdrop = [](const RenderElement& renderer) -> bool {
auto& style = renderer.style();
if (style.styleType() != PseudoId::Backdrop || style.position() != PositionType::Fixed)
return false;

if (style.hasTransform() || style.hasClip() || style.hasMask())
return false;

if (!is<RenderBox>(renderer))
return false;

auto rendererRect = downcast<RenderBox>(renderer).frameRect();
return rendererRect == renderer.view().frameRect();
};
setRequiresBackgroundLayer(isFullsizeBackdrop(layer.renderer()));
#endif

if (auto* tiledBacking = this->tiledBacking()) {
Expand Down
4 changes: 4 additions & 0 deletions Source/WebCore/rendering/RenderLayerCompositor.cpp
Expand Up @@ -2670,6 +2670,10 @@ static FullScreenDescendant isDescendantOfFullScreenLayer(const RenderLayer& lay
if (!fullScreenRenderer || !fullScreenLayer)
return FullScreenDescendant::NotApplicable;

auto backdropRenderer = fullScreenRenderer->backdropRenderer();
if (backdropRenderer && backdropRenderer.get() == &layer.renderer())
return FullScreenDescendant::Yes;

return layer.isDescendantOf(*fullScreenLayer) ? FullScreenDescendant::Yes : FullScreenDescendant::No;
}
#endif
Expand Down
8 changes: 0 additions & 8 deletions Source/WebCore/rendering/RenderObject.h
Expand Up @@ -262,10 +262,6 @@ class RenderObject : public CachedImageClient {
virtual bool isCanvas() const { return false; }
#if ENABLE(ATTACHMENT_ELEMENT)
virtual bool isAttachment() const { return false; }
#endif
#if ENABLE(FULLSCREEN_API)
virtual bool isRenderFullScreen() const { return false; }
virtual bool isRenderFullScreenPlaceholder() const { return false; }
#endif
virtual bool isRenderGrid() const { return false; }

Expand Down Expand Up @@ -1159,10 +1155,6 @@ inline bool RenderObject::isAnonymousBlock() const
&& (style().display() == DisplayType::Block || style().display() == DisplayType::Box)
&& style().styleType() == PseudoId::None
&& isRenderBlock()
#if ENABLE(FULLSCREEN_API)
&& !isRenderFullScreen()
&& !isRenderFullScreenPlaceholder()
#endif
#if ENABLE(MATHML)
&& !isRenderMathMLBlock()
#endif
Expand Down

0 comments on commit 2a5bd0f

Please sign in to comment.