diff options
author | Andreas Kling <kling@serenityos.org> | 2023-05-15 12:06:40 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-05-15 14:08:08 +0200 |
commit | 990e7219d655d39b76105ddd2678966c89be1ad3 (patch) | |
tree | 3372116892afc9c4429c5831c00b7cbedb308318 /Userland/Libraries | |
parent | 44049f5ad5e7adedcdbc06723856be689c9779b2 (diff) | |
download | serenity-990e7219d655d39b76105ddd2678966c89be1ad3.zip |
LibWeb: Fix iframes flickering on window resize
After finishing layout, iframe layout boxes (FrameBox) get notified
about their new size by LayoutState::commit(). This information is
forwarded to the nested browsing context, where it can be used for
layout of the nested document.
The problem here was that we notified the FrameBox twice. Once when
assigning the used offset to its paintable, and once when assigning its
size. Because the offset was assigned first, we ended up telling the
FrameBox "btw, your size is 0x0". This caused us to throw away all
the layout information we had for the nested document.
We'd then say "actually, your size is 300x200" (or something) but by
then it was already too late, and we had to do a full relayout.
This caused iframes to flicker as every time their containing document
was laid out, we'd nuke the iframe layout and redo it (on a zero timer).
The fix is pleasantly simple: we didn't need to inform the nested
document of its offset in the containing document's layout anyway. Only
its size is relevant. So we can simply remove the first call, which
removes the bogus 0x0 temporary size.
Note that iframes may still flicker if they change size in the
containing document. That's a separate issue that will require more
finesse to solve. However, this fixes a very noticeable common case.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/Box.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/FrameBox.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/FrameBox.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Painting/PaintableBox.cpp | 3 |
4 files changed, 5 insertions, 6 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/Box.h b/Userland/Libraries/LibWeb/Layout/Box.h index 20b7094fd0..a996209aaa 100644 --- a/Userland/Libraries/LibWeb/Layout/Box.h +++ b/Userland/Libraries/LibWeb/Layout/Box.h @@ -38,7 +38,7 @@ public: virtual ~Box() override; - virtual void did_set_rect() { } + virtual void did_set_content_size() { } virtual JS::GCPtr<Painting::Paintable> create_paintable() const override; diff --git a/Userland/Libraries/LibWeb/Layout/FrameBox.cpp b/Userland/Libraries/LibWeb/Layout/FrameBox.cpp index fb98c9afc2..d2be5968ea 100644 --- a/Userland/Libraries/LibWeb/Layout/FrameBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/FrameBox.cpp @@ -28,9 +28,9 @@ void FrameBox::prepare_for_replaced_layout() set_intrinsic_height(dom_node().attribute(HTML::AttributeNames::height).to_int().value_or(150)); } -void FrameBox::did_set_rect() +void FrameBox::did_set_content_size() { - ReplacedBox::did_set_rect(); + ReplacedBox::did_set_content_size(); VERIFY(dom_node().nested_browsing_context()); dom_node().nested_browsing_context()->set_size(paintable_box()->content_size()); diff --git a/Userland/Libraries/LibWeb/Layout/FrameBox.h b/Userland/Libraries/LibWeb/Layout/FrameBox.h index 4f225fae5d..0dec7b0a8b 100644 --- a/Userland/Libraries/LibWeb/Layout/FrameBox.h +++ b/Userland/Libraries/LibWeb/Layout/FrameBox.h @@ -26,7 +26,7 @@ public: virtual JS::GCPtr<Painting::Paintable> create_paintable() const override; private: - virtual void did_set_rect() override; + virtual void did_set_content_size() override; }; } diff --git a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp index 75d5659d7e..639b077bb3 100644 --- a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp +++ b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp @@ -63,13 +63,12 @@ PaintableWithLines::~PaintableWithLines() void PaintableBox::set_offset(CSSPixelPoint offset) { m_offset = offset; - layout_box().did_set_rect(); } void PaintableBox::set_content_size(CSSPixelSize size) { m_content_size = size; - layout_box().did_set_rect(); + layout_box().did_set_content_size(); } CSSPixelPoint PaintableBox::effective_offset() const |