From ef8b754a468639d50f3d422397aa626e8272fba2 Mon Sep 17 00:00:00 2001 From: Conrad Pankoff Date: Sun, 6 Oct 2019 22:58:18 +1100 Subject: 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. --- Libraries/LibHTML/DOM/Document.cpp | 6 ++++++ Libraries/LibHTML/DOM/Document.h | 4 ++++ 2 files changed, 10 insertions(+) (limited to 'Libraries/LibHTML/DOM') 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 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 #include #include #include @@ -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 on_invalidate_layout; + private: virtual RefPtr create_layout_node(const StyleResolver&, const StyleProperties* parent_properties) const override; -- cgit v1.2.3