1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:57: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

@ -99,15 +99,18 @@ void Box::paint_background(PaintContext& context)
void Box::paint_box_shadow(PaintContext& context)
{
auto box_shadow_data = computed_values().box_shadow();
if (!box_shadow_data.has_value())
if (box_shadow_data.is_empty())
return;
auto resolved_box_shadow_data = Painting::BoxShadowData {
.offset_x = (int)box_shadow_data->offset_x.resolved_or_zero(*this).to_px(*this),
.offset_y = (int)box_shadow_data->offset_y.resolved_or_zero(*this).to_px(*this),
.blur_radius = (int)box_shadow_data->blur_radius.resolved_or_zero(*this).to_px(*this),
.color = box_shadow_data->color
};
Vector<Painting::BoxShadowData> resolved_box_shadow_data;
resolved_box_shadow_data.ensure_capacity(box_shadow_data.size());
for (auto const& layer : box_shadow_data) {
resolved_box_shadow_data.empend(
static_cast<int>(layer.offset_x.resolved_or_zero(*this).to_px(*this)),
static_cast<int>(layer.offset_y.resolved_or_zero(*this).to_px(*this)),
static_cast<int>(layer.blur_radius.resolved_or_zero(*this).to_px(*this)),
layer.color);
}
Painting::paint_box_shadow(context, enclosing_int_rect(bordered_rect()), resolved_box_shadow_data);
}