From 382a89511a3999da3a9464da9cd3959997b7df14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 1 Dec 2017 20:17:53 +0100 Subject: [PATCH] style: Add a fast-path for GeckoElement::is_root. --- components/style/gecko/wrapper.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index 15d3f785b6e..2babb8664a7 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -1917,6 +1917,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() { + return false; + } + unsafe { Gecko_IsRootElement(self.0) }