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

LibWeb: Layout viewport rect was lagging behind when resizing

Layout was using an outdated viewport rect that we set *after* doing
a layout due to resize. That meant that layout-in-response-to-resize
was always lagging behind the current size of the view.

The root of this problem was how Frame kept both a viewport rect
(with both scroll offset and size) and a frame size. To fix this,
only store the viewport scroll offset, and always use the frame size.
This way they can't get out of sync and the problem goes away. :^)

Fixes #4250.
This commit is contained in:
Andreas Kling 2020-12-02 23:40:57 +01:00
parent 766db673c1
commit 15e35b0d71
4 changed files with 11 additions and 11 deletions

View file

@ -63,8 +63,8 @@ public:
void set_needs_display(const Gfx::IntRect&);
void set_viewport_rect(const Gfx::IntRect&);
Gfx::IntRect viewport_rect() const { return m_viewport_rect; }
void set_viewport_scroll_offset(const Gfx::IntPoint&);
Gfx::IntRect viewport_rect() const { return { m_viewport_scroll_offset, m_size }; }
void did_scroll(Badge<InProcessWebView>);
@ -109,7 +109,7 @@ private:
WeakPtr<DOM::Element> m_host_element;
RefPtr<DOM::Document> m_document;
Gfx::IntSize m_size;
Gfx::IntRect m_viewport_rect;
Gfx::IntPoint m_viewport_scroll_offset;
DOM::Position m_cursor_position;
RefPtr<Core::Timer> m_cursor_blink_timer;