Files
sousa-gecko/testing/web-platform/tests/css/css-content/element-replacement-root-canvas-bg.html
T
Andreu Botella 49223f48b7 Bug 2007625 [wpt PR 56912] - layout: Support content: <image> on non-pseudo-elements, a=testonly
Automatic update from web-platform-tests
layout: Support `content: <image>` on non-pseudo-elements

Per CSS-CONTENT-3, one of the possible values of the `content` CSS
property is `<content-replacement>`, which evaluates to a single
`<image>`. This value is also allowed on regular elements, not just on
pseudo-elements, and it will make the element into a replaced element
representing the given image, discarding its contents.

This patch implements this in `traverse_element`: if the `display`
value is not `none` or `contents`, we first check whether the
`contents` property should make the element replaced, and if it
shouldn't, then we check whether the element itself is replaced or a
widget.

Per the spec, an invalid image must be treated as representing a
transparent black image with zero natural width and height – in
particular, it must not show a broken image icon. We added the method
`ReplacedContents::zero_sized_invalid_image` to implement this.

This patch adds support for image URL references, but not for color
gradients, which are treated as invalid images. The reason for this is
that currently Servo does not support gradients in
`ReplacedContentKind`. This is left as a follow-up change.

Testing: Existing `css/css-content/element-replacement*` WPT tests
that now pass with this patch. `element-replacement-gradient.html`
still fails because this patch does not add support for gradients.

Fixes: #41479

Signed-off-by: Andreu Botella <andreu@andreubotella.com>

--

wpt-commits: 906e94ddad86d602b328c3331c6573192bd98f24
wpt-pr: 56912
2026-02-03 10:08:37 +00:00

16 lines
694 B
HTML

<!DOCTYPE html>
<title>When content CSS attribute can replace a document's root, its canvas still becomes the canvas background</title>
<link rel="match" href="element-replacement-root-canvas-bg-ref.html" />
<link rel="help" href="https://drafts.csswg.org/css-content-3/#content-property" />
<link rel="help" href="https://drafts.csswg.org/css-backgrounds-3/#root-background" />
<meta name="assert" content="When the content CSS attribute replaces a document's root, it does not affect the fact that the root's background becomes the canvas background" />
<style>
:root {
content: url('resources/rect.svg');
background-color: aquamarine;
}
</style>
<p>This text should not be visible</p>