1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:38:10 +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

@ -518,12 +518,23 @@ RefPtr<StyleValue> ResolvedCSSStyleDeclaration::style_value_for_property(Layout:
case CSS::PropertyID::JustifyContent:
return IdentifierStyleValue::create(to_css_value_id(layout_node.computed_values().justify_content()));
case CSS::PropertyID::BoxShadow: {
auto maybe_box_shadow = layout_node.computed_values().box_shadow();
if (!maybe_box_shadow.has_value())
auto box_shadow_layers = layout_node.computed_values().box_shadow();
if (box_shadow_layers.is_empty())
return {};
auto box_shadow_data = maybe_box_shadow.release_value();
// FIXME: Add extra properties to BoxShadowData so we can include them here!
return BoxShadowStyleValue::create(box_shadow_data.color, box_shadow_data.offset_x, box_shadow_data.offset_y, box_shadow_data.blur_radius, Length::make_px(0), BoxShadowPlacement::Outer);
auto make_box_shadow_style_value = [](BoxShadowData const& data) {
// FIXME: Add extra properties to BoxShadowData so we can include them here!
return BoxShadowStyleValue::create(data.color, data.offset_x, data.offset_y, data.blur_radius, Length::make_px(0), BoxShadowPlacement::Outer);
};
if (box_shadow_layers.size() == 1)
return make_box_shadow_style_value(box_shadow_layers.first());
NonnullRefPtrVector<StyleValue> box_shadow;
box_shadow.ensure_capacity(box_shadow_layers.size());
for (auto const& layer : box_shadow_layers)
box_shadow.append(make_box_shadow_style_value(layer));
return StyleValueList::create(move(box_shadow), StyleValueList::Separator::Comma);
}
case CSS::PropertyID::Width:
return style_value_for_length_percentage(layout_node.computed_values().width());