mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:48:14 +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:
parent
abe811104f
commit
cfab53903f
22 changed files with 109 additions and 95 deletions
|
@ -49,18 +49,21 @@ void LayoutCanvas::layout(LayoutMode layout_mode)
|
|||
LayoutReplaced::layout(layout_mode);
|
||||
}
|
||||
|
||||
void LayoutCanvas::render(RenderingContext& context)
|
||||
void LayoutCanvas::render(RenderingContext& context, PaintPhase phase)
|
||||
{
|
||||
if (!is_visible())
|
||||
return;
|
||||
|
||||
// FIXME: This should be done at a different level. Also rect() does not include padding etc!
|
||||
if (!context.viewport_rect().intersects(enclosing_int_rect(absolute_rect())))
|
||||
return;
|
||||
LayoutReplaced::render(context, phase);
|
||||
|
||||
if (node().bitmap())
|
||||
context.painter().draw_scaled_bitmap(enclosing_int_rect(absolute_rect()), *node().bitmap(), node().bitmap()->rect());
|
||||
LayoutReplaced::render(context);
|
||||
if (phase == PaintPhase::Foreground) {
|
||||
// FIXME: This should be done at a different level. Also rect() does not include padding etc!
|
||||
if (!context.viewport_rect().intersects(enclosing_int_rect(absolute_rect())))
|
||||
return;
|
||||
|
||||
if (node().bitmap())
|
||||
context.painter().draw_scaled_bitmap(enclosing_int_rect(absolute_rect()), *node().bitmap(), node().bitmap()->rect());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue