LibWeb: Fail less when multiple mask images are defined

We don't yet support multiple images but we at least continue to use the
first rather than having none
This commit is contained in:
Callum Law 2025-11-13 14:00:26 +13:00 committed by Sam Atkins
parent 5371862d11
commit 1a5933cb04
Notes: github-actions[bot] 2025-12-01 10:19:11 +00:00
3 changed files with 32 additions and 1 deletions

View file

@ -787,7 +787,15 @@ void NodeWithStyle::apply_style(CSS::ComputedProperties const& computed_style)
computed_values.set_shape_rendering(computed_style.shape_rendering());
computed_values.set_paint_order(computed_style.paint_order());
auto const& mask_image = computed_style.property(CSS::PropertyID::MaskImage);
// FIXME: We should actually support more than one mask image rather than just using the first
auto const& mask_image = [&] -> CSS::StyleValue const& {
auto const& value = computed_style.property(CSS::PropertyID::MaskImage);
if (value.is_value_list())
return value.as_value_list().values()[0];
return value;
}();
if (mask_image.is_url()) {
computed_values.set_mask(mask_image.as_url().url());
} else if (mask_image.is_abstract_image()) {

View file

@ -0,0 +1,9 @@
<!DOCTYPE html>
<style>
#mask-image-box {
background-color: green;
width: 100px;
height: 100px;
}
</style>
<div id="mask-image-box"></div>

View file

@ -0,0 +1,14 @@
<!DOCTYPE html>
<link rel="match" href="../expected/mask-image-multiple-same-ref.html" />
<style>
#mask-image-box {
background-color: green;
width: 100px;
height: 200px;
mask-image: url("../data/mask-image-100x200.png"), url("../data/mask-image-100x200.png");
}
</style>
<div id="mask-image-box"></div>
<!-- FIXME: Workaround to ensure CSS mask-image is loaded before taking screenshot: https://github.com/LadybirdBrowser/ladybird/issues/3448 -->
<img style="display: none" src="../data/mask-image-100x200.png" />