mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 09:07:45 +00:00
LibWeb: Apply scroll boxes offsets after painting commands recording
With this change, instead of applying scroll offsets during the recording of the painting command list, we do the following: 1. Collect all boxes with scrollable overflow into a PaintContext, each with an id and the total amount of scrolling offset accumulated from ancestor scrollable boxes. 2. During the recording phase assign a corresponding scroll_frame_id to each command that paints content within a scrollable box. 3. Before executing the recorded commands, translate each command that has a scroll_frame_id by the accumulated scroll offset. This approach has following advantages: - Implementing nested scrollables becomes much simpler, as the recording phase only requires the correct assignment of the nearest scrollable's scroll_frame_id, while the accumulated offset from ancestors is applied subsequently. - The recording of painting commands is not tied to a specific offset within scrollable boxes, which means in the future, it will be possible to update the scrolling offset and repaint without the need to re-record painting commands.
This commit is contained in:
parent
d3025668a4
commit
ac6b3c989d
12 changed files with 307 additions and 24 deletions
|
@ -72,11 +72,14 @@ public:
|
|||
|
||||
double device_pixels_per_css_pixel() const { return m_device_pixels_per_css_pixel; }
|
||||
|
||||
CSSPixelPoint scroll_offset() const { return m_scroll_offset; }
|
||||
void translate_scroll_offset_by(CSSPixelPoint offset) { m_scroll_offset.translate_by(offset); }
|
||||
|
||||
u32 allocate_corner_clipper_id() { return m_next_corner_clipper_id++; }
|
||||
|
||||
struct ScrollFrame {
|
||||
i32 id { -1 };
|
||||
CSSPixelPoint offset;
|
||||
};
|
||||
HashMap<Painting::PaintableBox const*, ScrollFrame>& scroll_frames() { return m_scroll_frames; }
|
||||
|
||||
private:
|
||||
Painting::RecordingPainter& m_recording_painter;
|
||||
Palette m_palette;
|
||||
|
@ -85,9 +88,9 @@ private:
|
|||
bool m_should_show_line_box_borders { false };
|
||||
bool m_should_paint_overlay { true };
|
||||
bool m_focus { false };
|
||||
CSSPixelPoint m_scroll_offset;
|
||||
Gfx::AffineTransform m_svg_transform;
|
||||
u32 m_next_corner_clipper_id { 0 };
|
||||
HashMap<Painting::PaintableBox const*, ScrollFrame> m_scroll_frames;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue