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

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
parent bd33bfd120
commit 137f6d44ec
8 changed files with 27 additions and 11 deletions

View file

@ -34,9 +34,10 @@ namespace Web {
class RenderingContext {
public:
explicit RenderingContext(GUI::Painter& painter, const Palette& palette)
explicit RenderingContext(GUI::Painter& painter, const Palette& palette, const Gfx::IntPoint& scroll_offset)
: m_painter(painter)
, m_palette(palette)
, m_scroll_offset(scroll_offset)
{
}
@ -49,10 +50,13 @@ public:
Gfx::IntRect viewport_rect() const { return m_viewport_rect; }
void set_viewport_rect(const Gfx::IntRect& rect) { m_viewport_rect = rect; }
const Gfx::IntPoint& scroll_offset() const { return m_scroll_offset; }
private:
GUI::Painter& m_painter;
Palette m_palette;
Gfx::IntRect m_viewport_rect;
Gfx::IntPoint m_scroll_offset;
bool m_should_show_line_box_borders { false };
};