diff --git a/components/layout_thread/dom_wrapper.rs b/components/layout_thread/dom_wrapper.rs index 1aa9488c327..0558d648eb8 100644 --- a/components/layout_thread/dom_wrapper.rs +++ b/components/layout_thread/dom_wrapper.rs @@ -313,6 +313,10 @@ impl<'ln> TNode for ServoLayoutNode<'ln> { self.node.downcast().map(ServoShadowRoot::from_layout_js) } + fn is_in_document(&self) -> bool { + unsafe { self.node.get_flag(NodeFlags::IS_IN_DOC) } + } + fn is_connected(&self) -> bool { unsafe { self.node.get_flag(NodeFlags::IS_CONNECTED) } } @@ -555,7 +559,7 @@ impl<'le> TElement for ServoLayoutElement<'le> { } unsafe fn set_dirty_descendants(&self) { - debug_assert!(self.as_node().is_connected()); + debug_assert!(self.as_node().is_in_document()); self.as_node() .node .set_flag(NodeFlags::HAS_DIRTY_DESCENDANTS, true) diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index c58313f6ee0..0d25b535593 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -644,7 +644,7 @@ impl Document { } pub fn content_and_heritage_changed(&self, node: &Node) { - if node.is_connected() { + if node.is_in_doc() { node.note_dirty_descendants(); } diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 79d838c5292..a93389638fe 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -568,7 +568,7 @@ impl Node { // FIXME(emilio): This and the function below should move to Element. pub fn note_dirty_descendants(&self) { - debug_assert!(self.is_connected()); + debug_assert!(self.is_in_doc()); for ancestor in self.shadow_including_inclusive_ancestors() { if ancestor.get_flag(NodeFlags::HAS_DIRTY_DESCENDANTS) { diff --git a/components/style/dom.rs b/components/style/dom.rs index d282ceeafad..541ef4dbcdc 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -185,6 +185,9 @@ pub trait TNode: Sized + Copy + Clone + Debug + NodeInfo + PartialEq { DomChildren(self.first_child()) } + /// Returns whether the node is attached to a document. + fn is_in_document(&self) -> bool; + /// Returns whether the node is connected. fn is_connected(&self) -> bool; diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index 0fa354fb139..e8e5078c53a 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -421,6 +421,11 @@ impl<'ln> TNode for GeckoNode<'ln> { self.get_bool_flag(nsINode_BooleanFlag::IsInDocument) } + #[inline] + fn is_connected(&self) -> bool { + self.get_bool_flag(nsINode_BooleanFlag::IsConnected) + } + fn traversal_parent(&self) -> Option> { self.flattened_tree_parent().and_then(|n| n.as_element()) }