diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cpp index 058c702d29..0816775695 100644 --- a/Libraries/LibWeb/DOM/Document.cpp +++ b/Libraries/LibWeb/DOM/Document.cpp @@ -196,14 +196,22 @@ URL Document::complete_url(const String& string) const return m_url.complete_url(string); } -void Document::force_layout() +void Document::invalidate_layout() { m_layout_root = nullptr; +} + +void Document::force_layout() +{ + invalidate_layout(); layout(); } void Document::layout() { + if (!frame()) + return; + if (!m_layout_root) { LayoutTreeBuilder tree_builder; m_layout_root = tree_builder.build(*this); diff --git a/Libraries/LibWeb/DOM/Document.h b/Libraries/LibWeb/DOM/Document.h index 911e4c9f35..c80f6dfe98 100644 --- a/Libraries/LibWeb/DOM/Document.h +++ b/Libraries/LibWeb/DOM/Document.h @@ -106,6 +106,7 @@ public: void layout(); void force_layout(); + void invalidate_layout(); void update_style(); void update_layout();