Skip to content

Commit 1a5933c

Browse files
Calme1709AtkinsSJ
authored andcommitted
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
1 parent 5371862 commit 1a5933c

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

Libraries/LibWeb/Layout/Node.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,15 @@ void NodeWithStyle::apply_style(CSS::ComputedProperties const& computed_style)
787787
computed_values.set_shape_rendering(computed_style.shape_rendering());
788788
computed_values.set_paint_order(computed_style.paint_order());
789789

790-
auto const& mask_image = computed_style.property(CSS::PropertyID::MaskImage);
790+
// FIXME: We should actually support more than one mask image rather than just using the first
791+
auto const& mask_image = [&] -> CSS::StyleValue const& {
792+
auto const& value = computed_style.property(CSS::PropertyID::MaskImage);
793+
794+
if (value.is_value_list())
795+
return value.as_value_list().values()[0];
796+
797+
return value;
798+
}();
791799
if (mask_image.is_url()) {
792800
computed_values.set_mask(mask_image.as_url().url());
793801
} else if (mask_image.is_abstract_image()) {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE html>
2+
<style>
3+
#mask-image-box {
4+
background-color: green;
5+
width: 100px;
6+
height: 100px;
7+
}
8+
</style>
9+
<div id="mask-image-box"></div>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<link rel="match" href="../expected/mask-image-multiple-same-ref.html" />
3+
<style>
4+
#mask-image-box {
5+
background-color: green;
6+
width: 100px;
7+
height: 200px;
8+
mask-image: url("../data/mask-image-100x200.png"), url("../data/mask-image-100x200.png");
9+
}
10+
</style>
11+
12+
<div id="mask-image-box"></div>
13+
<!-- FIXME: Workaround to ensure CSS mask-image is loaded before taking screenshot: https://github.com/LadybirdBrowser/ladybird/issues/3448 -->
14+
<img style="display: none" src="../data/mask-image-100x200.png" />

0 commit comments

Comments
 (0)