style: Add also a containing_shadow API.

This commit is contained in:
Emilio Cobos Álvarez 2018-03-03 22:33:29 +01:00
parent 2f0df1b421
commit a19219ec79
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
3 changed files with 13 additions and 0 deletions

View file

@ -562,6 +562,10 @@ impl<'le> TElement for ServoLayoutElement<'le> {
fn shadow_root(&self) -> Option<ShadowRoot<'le>> { fn shadow_root(&self) -> Option<ShadowRoot<'le>> {
None None
} }
fn containing_shadow(&self) -> Option<ShadowRoot<'le>> {
None
}
} }
impl<'le> PartialEq for ServoLayoutElement<'le> { impl<'le> PartialEq for ServoLayoutElement<'le> {

View file

@ -740,6 +740,9 @@ pub trait TElement
/// The shadow root this element is a host of. /// The shadow root this element is a host of.
fn shadow_root(&self) -> Option<<Self::ConcreteNode as TNode>::ConcreteShadowRoot>; fn shadow_root(&self) -> Option<<Self::ConcreteNode as TNode>::ConcreteShadowRoot>;
/// The shadow root which roots the subtree this element is contained in.
fn containing_shadow(&self) -> Option<<Self::ConcreteNode as TNode>::ConcreteShadowRoot>;
/// Return the element which we can use to look up rules in the selector /// Return the element which we can use to look up rules in the selector
/// maps. /// maps.
/// ///

View file

@ -1068,6 +1068,12 @@ impl<'le> TElement for GeckoElement<'le> {
unsafe { slots.mShadowRoot.mRawPtr.as_ref().map(GeckoShadowRoot) } unsafe { slots.mShadowRoot.mRawPtr.as_ref().map(GeckoShadowRoot) }
} }
#[inline]
fn containing_shadow(&self) -> Option<GeckoShadowRoot<'le>> {
let slots = self.extended_slots()?;
unsafe { slots._base.mContainingShadow.mRawPtr.as_ref().map(GeckoShadowRoot) }
}
/// Execute `f` for each anonymous content child element (apart from /// Execute `f` for each anonymous content child element (apart from
/// ::before and ::after) whose originating element is `self`. /// ::before and ::after) whose originating element is `self`.
fn each_anonymous_content_child<F>(&self, mut f: F) fn each_anonymous_content_child<F>(&self, mut f: F)