diff options
author | Andreas Kling <kling@serenityos.org> | 2020-03-25 18:51:04 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-03-25 18:51:04 +0100 |
commit | 1146ab0fae03ea7b6f812606bb69a11d5e161434 (patch) | |
tree | ca12c8b00b7bc6858a4ae288660c271cc79cf999 /Libraries/LibWeb | |
parent | 90a53b3520cda8f19362ec6b7dc207f3bfb274f7 (diff) | |
download | serenity-1146ab0fae03ea7b6f812606bb69a11d5e161434.zip |
LibWeb: Add Document::invalidate_layout()
This function allows you to throw away the entire layout tree if that's
something you want to do.
It's certainly not super cheap to reconstruct, but hey, who am I to
tell you what to do? :^)
Diffstat (limited to 'Libraries/LibWeb')
-rw-r--r-- | Libraries/LibWeb/DOM/Document.cpp | 10 | ||||
-rw-r--r-- | Libraries/LibWeb/DOM/Document.h | 1 |
2 files changed, 10 insertions, 1 deletions
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(); |