layout: Do not add empty border images to the display list (#37534)

Zero-sized gradient border images cause WebRender to panic, so simply
don't add them to the display list.

Testing: This change adds a WPT crash test.
Fixes: #37432

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2025-06-18 17:53:29 +02:00 committed by GitHub
parent fc2135cc02
commit bdf8c0ebc8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 34 additions and 0 deletions

View file

@ -1509,6 +1509,13 @@ impl<'a> BuilderForBoxFragment<'a> {
}; };
let size = euclid::Size2D::new(width as i32, height as i32); let size = euclid::Size2D::new(width as i32, height as i32);
// If the size of the border is zero or the size of the border image is zero, just
// don't render anything. Zero-sized gradients cause problems in WebRender.
if size.is_empty() || border_image_size.is_empty() {
return true;
}
let details = BorderDetails::NinePatch(NinePatchBorder { let details = BorderDetails::NinePatch(NinePatchBorder {
source, source,
width: size.width, width: size.width,

View file

@ -952,6 +952,15 @@
] ]
] ]
}, },
"css-borders": {
"border-image-gradient-zero-size-transform-crash.html": [
"c722267fc08e41e1d5e4496d583fcaf4d179b2dd",
[
null,
{}
]
]
},
"css-break": { "css-break": {
"area-crash.html": [ "area-crash.html": [
"d47327cde3f6a963b8c6e61280d3063b28a2d25c", "d47327cde3f6a963b8c6e61280d3063b28a2d25c",

View file

@ -0,0 +1,18 @@
<!DOCTYPE html>
<style>
#container {
border-style: dotted hidden;
border-image: repeating-linear-gradient(to left top, blue, red);
width: 0;
transition: all 0.5s;
}
</style>
<div id="container"></div>
<script>
addEventListener("load", () => {
container.style.padding = "1px";
});
</script>
</body>