LibWeb: Add basic support for position:fixed

Fixed position elements have the ICB as their containing block.
The magic of fixed positioning is implemented at the rendering stage,
where we temporarily translate painting by the current scroll offset.

Note that "absolutely positioned" includes both position:absolute
and position:fixed.
This commit is contained in:
Andreas Kling 2020-06-12 14:19:03 +02:00
commit 137f6d44ec
Notes: sideshowbarker 2024-07-19 05:42:43 +09:00
8 changed files with 27 additions and 11 deletions

View file

@ -194,6 +194,10 @@ void LayoutBox::render(RenderingContext& context)
if (!is_visible())
return;
Gfx::PainterStateSaver saver(context.painter());
if (is_fixed_position())
context.painter().translate(context.scroll_offset());
#ifdef DRAW_BOXES_AROUND_LAYOUT_NODES
context.painter().draw_rect(m_rect, Color::Blue);
#endif