1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:17:45 +00:00

LibWeb: Render multiple box-shadows

Because why not? :^)
This commit is contained in:
Sam Atkins 2022-02-08 14:48:37 +00:00 committed by Andreas Kling
parent b51f428165
commit 10c6c77b5c
8 changed files with 107 additions and 65 deletions

View file

@ -769,18 +769,35 @@ Optional<CSS::Overflow> StyleProperties::overflow(CSS::PropertyID property_id) c
}
}
Optional<CSS::BoxShadowData> StyleProperties::box_shadow() const
Vector<BoxShadowData> StyleProperties::box_shadow() const
{
auto value_or_error = property(CSS::PropertyID::BoxShadow);
auto value_or_error = property(PropertyID::BoxShadow);
if (!value_or_error.has_value())
return {};
auto value = value_or_error.value();
if (!value->is_box_shadow())
return {};
auto& box = value->as_box_shadow();
return { { box.offset_x(), box.offset_y(), box.blur_radius(), box.color() } };
auto make_box_shadow_data = [](BoxShadowStyleValue const& box) {
return BoxShadowData { box.offset_x(), box.offset_y(), box.blur_radius(), box.color() };
};
if (value->is_value_list()) {
auto& value_list = value->as_value_list();
Vector<BoxShadowData> box_shadow_data;
box_shadow_data.ensure_capacity(value_list.size());
for (auto const& layer_value : value_list.values())
box_shadow_data.append(make_box_shadow_data(layer_value.as_box_shadow()));
return box_shadow_data;
}
if (value->is_box_shadow()) {
auto& box = value->as_box_shadow();
return { make_box_shadow_data(box) };
}
return {};
}
CSS::BoxSizing StyleProperties::box_sizing() const