Przeglądaj źródła

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.
Andreas Kling 3 lat temu
rodzic
commit
1b6f0f857e
1 zmienionych plików z 8 dodań i 0 usunięć
  1. 8 0
      Userland/Libraries/LibWeb/DOM/Node.cpp

+ 8 - 0
Userland/Libraries/LibWeb/DOM/Node.cpp

@@ -529,6 +529,14 @@ void Node::set_document(Badge<Document>, 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