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

LibWeb: Resolve text shadows in LayoutState::commit()

Rather than resolving the text-shadow each time painting commands are
recorded, we can resolve it once during the layout commit and save the
resolved values in paintable fragments. This is also step towards
getting rid of layout node pointer in paintable fragment.
This commit is contained in:
Aliaksandr Kalenik 2024-01-13 10:38:07 +01:00 committed by Andreas Kling
parent c3059701b0
commit ee5d66c5d5
4 changed files with 32 additions and 18 deletions

View file

@ -662,24 +662,7 @@ void PaintableWithLines::paint(PaintContext& context, PaintPhase phase) const
for (auto& fragment : fragments()) {
if (fragment.contained_by_inline_node())
continue;
if (is<Layout::TextNode>(fragment.layout_node())) {
auto& text_shadow = fragment.layout_node().computed_values().text_shadow();
if (!text_shadow.is_empty()) {
Vector<ShadowData> resolved_shadow_data;
resolved_shadow_data.ensure_capacity(text_shadow.size());
for (auto const& layer : text_shadow) {
resolved_shadow_data.empend(
layer.color,
layer.offset_x.to_px(layout_box()),
layer.offset_y.to_px(layout_box()),
layer.blur_radius.to_px(layout_box()),
layer.spread_distance.to_px(layout_box()),
ShadowPlacement::Outer);
}
context.recording_painter().set_font(fragment.layout_node().first_available_font());
paint_text_shadow(context, fragment, resolved_shadow_data);
}
}
paint_text_shadow(context, fragment, fragment.shadows());
}
}