diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2018-02-24 20:29:36 +0100 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2018-02-24 20:29:36 +0100 |
commit | da99f159f43cef17bf94cbc00da2ce21fe2df5ba (patch) | |
tree | 0573524fce5652bc553399bc17e966bdd055a2db /components | |
parent | 6a2feb3c1bc1374dc97c788f07c2074895d2f1f1 (diff) | |
download | servo-da99f159f43cef17bf94cbc00da2ce21fe2df5ba.tar.gz servo-da99f159f43cef17bf94cbc00da2ce21fe2df5ba.zip |
style: Add a shadow root accessor.
I'm going to use it in a bit.
Diffstat (limited to 'components')
-rw-r--r-- | components/style/gecko/wrapper.rs | 9 |
1 files 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. |