From da99f159f43cef17bf94cbc00da2ce21fe2df5ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sat, 24 Feb 2018 20:29:36 +0100 Subject: [PATCH] style: Add a shadow root accessor. I'm going to use it in a bit. --- components/style/gecko/wrapper.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index adac5713cb4..5fd26382cb9 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -226,7 +226,7 @@ impl<'ln> GeckoNode<'ln> { } if let Some(parent) = parent_el { - if parent.has_shadow_root() || parent.get_xbl_binding().is_some() { + if parent.shadow_root().is_some() || parent.get_xbl_binding().is_some() { return false; } } @@ -519,9 +519,10 @@ impl<'le> GeckoElement<'le> { } /// Returns true if this element has a shadow root. - fn has_shadow_root(&self) -> bool { - self.get_extended_slots() - .map_or(false, |slots| !slots.mShadowRoot.mRawPtr.is_null()) + #[inline] + fn shadow_root(&self) -> Option<&structs::ShadowRoot> { + let slots = self.get_extended_slots()?; + unsafe { slots.mShadowRoot.mRawPtr.as_ref() } } /// Returns a reference to the DOM slots for this Element, if they exist.