style: Introduce TNode::is_in_document. draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 27 Oct 2017 12:18:27 +0200
changeset 690479 d072aa344d893ce7079f466d5d66a55344fc2613
parent 690478 d925490a884bedba8c81459914c679a20bc3a7b7
child 690480 031f26da5cdd56f88bfd8b5cf28ded38a2dad241
push id87308
push userbmo:emilio@crisal.io
push dateThu, 02 Nov 2017 01:16:37 +0000
milestone58.0a1
style: Introduce TNode::is_in_document. MozReview-Commit-ID: BrhhoOghtUL
servo/components/style/dom.rs
servo/components/style/gecko/wrapper.rs
--- a/servo/components/style/dom.rs
+++ b/servo/components/style/dom.rs
@@ -186,16 +186,19 @@ pub trait TNode : Sized + Copy + Clone +
     /// Get the owner document of this node.
     fn owner_doc(&self) -> Self::ConcreteDocument;
 
     /// Iterate over the DOM children of a node.
     fn dom_children(&self) -> DomChildren<Self> {
         DomChildren(self.first_child())
     }
 
+    /// Returns whether the node is attached to a document.
+    fn is_in_document(&self) -> bool;
+
     /// Iterate over the DOM children of a node, in preorder.
     fn dom_descendants(&self) -> DomDescendants<Self> {
         DomDescendants {
             previous: Some(*self),
             scope: *self,
         }
     }
 
--- a/servo/components/style/gecko/wrapper.rs
+++ b/servo/components/style/gecko/wrapper.rs
@@ -282,16 +282,21 @@ impl<'ln> TNode for GeckoNode<'ln> {
     }
 
     #[inline]
     fn owner_doc(&self) -> Self::ConcreteDocument {
         debug_assert!(!self.node_info().mDocument.is_null());
         GeckoDocument(unsafe { &*self.node_info().mDocument })
     }
 
+    #[inline]
+    fn is_in_document(&self) -> bool {
+        self.get_bool_flag(nsINode_BooleanFlag::IsInDocument)
+    }
+
     fn traversal_parent(&self) -> Option<GeckoElement<'ln>> {
         self.flattened_tree_parent().and_then(|n| n.as_element())
     }
 
     fn opaque(&self) -> OpaqueNode {
         let ptr: usize = self.0 as *const _ as usize;
         OpaqueNode(ptr)
     }