diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index eed9ebe00af..b00755a1d5b 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -2074,15 +2074,15 @@ impl<'le> ::selectors::Element for GeckoElement<'le> { #[inline] fn is_root(&self) -> bool { - let parent_node = match self.as_node().parent_node() { - Some(parent_node) => parent_node, - None => return false, - }; - - if !parent_node.is_document() { + if self.as_node().get_bool_flag(nsINode_BooleanFlag::ParentIsContent) { return false; } + if !self.as_node().is_in_document() { + return false; + } + + debug_assert!(self.as_node().parent_node().map_or(false, |p| p.is_document())); unsafe { bindings::Gecko_IsRootElement(self.0) } }