1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:48:11 +00:00

LibWeb: Separate layout tree rendering into phases

CSS defines a very specific paint order. This patch starts steering us
towards respecting that by introducing the PaintPhase enum with values:

- Background
- Border
- Foreground
- Overlay (internal overlays used by inspector)

Basically, to get the right visual result, we have to render the page
multiple times, going one phase at a time.
This commit is contained in:
Andreas Kling 2020-06-18 18:57:35 +02:00
parent abe811104f
commit cfab53903f
22 changed files with 109 additions and 95 deletions

View file

@ -600,19 +600,22 @@ void LayoutBlock::compute_height()
}
}
void LayoutBlock::render(RenderingContext& context)
void LayoutBlock::render(RenderingContext& context, PaintPhase phase)
{
if (!is_visible())
return;
LayoutBox::render(context);
LayoutBox::render(context, phase);
if (children_are_inline()) {
for (auto& line_box : m_line_boxes) {
for (auto& fragment : line_box.fragments()) {
if (context.should_show_line_box_borders())
context.painter().draw_rect(enclosing_int_rect(fragment.absolute_rect()), Color::Green);
fragment.render(context);
// FIXME: Inline backgrounds etc.
if (phase == PaintPhase::Foreground) {
if (children_are_inline()) {
for (auto& line_box : m_line_boxes) {
for (auto& fragment : line_box.fragments()) {
if (context.should_show_line_box_borders())
context.painter().draw_rect(enclosing_int_rect(fragment.absolute_rect()), Color::Green);
fragment.render(context);
}
}
}
}