1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 01:47:34 +00:00

LibWeb: Resolve outline CSS property before paint commands recording

Refactor to resolve paint-only properties before painting, aiming to
stop using layout nodes during recording of painting commands.

Also adds a test, as we have not had any for outlines yet.
This commit is contained in:
Aliaksandr Kalenik 2024-02-11 01:56:39 +01:00 committed by Alexander Kalenik
parent f19b17e089
commit 95d91a37d2
7 changed files with 64 additions and 11 deletions

View file

@ -227,6 +227,7 @@ void ViewportPaintable::resolve_paint_only_properties()
// - Text shadows
// - Transforms
// - Transform origins
// - Outlines
for_each_in_inclusive_subtree([&](Paintable& paintable) {
auto& node = paintable.layout_node();
@ -416,6 +417,21 @@ void ViewportPaintable::resolve_paint_only_properties()
paintable_box.set_transform_origin({ x, y });
}
// Outlines
auto const& computed_values = node.computed_values();
auto outline_width = computed_values.outline_width().to_px(node);
auto outline_data = borders_data_for_outline(node, computed_values.outline_color(), computed_values.outline_style(), outline_width);
auto outline_offset = computed_values.outline_offset().to_px(node);
if (is_paintable_box) {
auto& paintable_box = static_cast<Painting::PaintableBox&>(paintable);
paintable_box.set_outline_data(outline_data);
paintable_box.set_outline_offset(outline_offset);
} else if (is_inline_paintable) {
auto& inline_paintable = static_cast<Painting::InlinePaintable&>(paintable);
inline_paintable.set_outline_data(outline_data);
inline_paintable.set_outline_offset(outline_offset);
}
return TraversalDecision::Continue;
});
}