From 1b6f0f857e98d419c4ee5853e609f6e800f518dd Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 12 Oct 2021 17:53:38 +0200 Subject: [PATCH] LibWeb: Re-mark nodes as needing style after moving between documents Since style update is driven by Document, moving a node with dirty style from one document to another means that we have to schedule a style update in the new document. --- Userland/Libraries/LibWeb/DOM/Node.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index 7f76f6d343..b33dd01881 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -529,6 +529,14 @@ void Node::set_document(Badge, Document& document) document.ref_from_node({}); m_document->unref_from_node({}); m_document = &document; + + if (needs_style_update() || child_needs_style_update()) { + // NOTE: We unset and reset the "needs style update" flag here. + // This ensures that there's a pending style update in the new document + // that will eventually assign some style to this node if needed. + set_needs_style_update(false); + set_needs_style_update(true); + } } bool Node::is_editable() const