diff options
author | Conrad Pankoff <deoxxa@fknsrs.biz> | 2019-10-06 22:58:18 +1100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-10-06 14:33:00 +0200 |
commit | ef8b754a468639d50f3d422397aa626e8272fba2 (patch) | |
tree | e98c4448b6b11e2cb3965922aea201582fdca648 /Libraries/LibHTML/DOM | |
parent | 15a016d3e3ccbfd9ef0afd46c0b175c00bfe318e (diff) | |
download | serenity-ef8b754a468639d50f3d422397aa626e8272fba2.zip |
LibHTML: Add function for invalidating the document layout
This allows any external actor to signal that the document layout may be
stale. This can be used when loading resources, changing the size or
placement of an element, adding/removing nodes, or really any time.
Diffstat (limited to 'Libraries/LibHTML/DOM')
-rw-r--r-- | Libraries/LibHTML/DOM/Document.cpp | 6 | ||||
-rw-r--r-- | Libraries/LibHTML/DOM/Document.h | 4 |
2 files changed, 10 insertions, 0 deletions
diff --git a/Libraries/LibHTML/DOM/Document.cpp b/Libraries/LibHTML/DOM/Document.cpp index c884a00dd1..5ba2665d65 100644 --- a/Libraries/LibHTML/DOM/Document.cpp +++ b/Libraries/LibHTML/DOM/Document.cpp @@ -126,6 +126,12 @@ URL Document::complete_url(const String& string) const return url; } +void Document::invalidate_layout() +{ + if (on_invalidate_layout) + on_invalidate_layout(); +} + RefPtr<LayoutNode> Document::create_layout_node(const StyleResolver&, const StyleProperties*) const { return adopt(*new LayoutDocument(*this, StyleProperties::create())); diff --git a/Libraries/LibHTML/DOM/Document.h b/Libraries/LibHTML/DOM/Document.h index 6124736571..00a3024b6f 100644 --- a/Libraries/LibHTML/DOM/Document.h +++ b/Libraries/LibHTML/DOM/Document.h @@ -1,5 +1,6 @@ #pragma once +#include <AK/Function.h> #include <AK/NonnullRefPtrVector.h> #include <AK/OwnPtr.h> #include <AK/String.h> @@ -63,6 +64,9 @@ public: Color visited_link_color() const { return m_visited_link_color; } void set_visited_link_color(Color); + void invalidate_layout(); + Function<void()> on_invalidate_layout; + private: virtual RefPtr<LayoutNode> create_layout_node(const StyleResolver&, const StyleProperties* parent_properties) const override; |