style: Add a shadow root accessor.

I'm going to use it in a bit.
This commit is contained in:
Emilio Cobos Álvarez 2018-02-24 20:29:36 +01:00
parent 6a2feb3c1b
commit da99f159f4
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -226,7 +226,7 @@ impl<'ln> GeckoNode<'ln> {
} }
if let Some(parent) = parent_el { 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; return false;
} }
} }
@ -519,9 +519,10 @@ impl<'le> GeckoElement<'le> {
} }
/// Returns true if this element has a shadow root. /// Returns true if this element has a shadow root.
fn has_shadow_root(&self) -> bool { #[inline]
self.get_extended_slots() fn shadow_root(&self) -> Option<&structs::ShadowRoot> {
.map_or(false, |slots| !slots.mShadowRoot.mRawPtr.is_null()) 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. /// Returns a reference to the DOM slots for this Element, if they exist.