style: Separate the XBL and shadow dom styling bits.

Bug: 1441022
Reviewed-by: xidorn
MozReview-Commit-ID: 2W0BmZ8wWXg
This commit is contained in:
Emilio Cobos Álvarez 2018-03-05 12:50:04 +01:00
parent 3b96fb2cbe
commit ef4ea7cc49
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
7 changed files with 107 additions and 57 deletions

View file

@ -147,6 +147,30 @@ impl<'lr> TShadowRoot for GeckoShadowRoot<'lr> {
fn host(&self) -> GeckoElement<'lr> {
GeckoElement(unsafe { &*self.0._base.mHost.mRawPtr })
}
#[inline]
fn style_data<'a>(&self) -> &'a CascadeData
where
Self: 'a,
{
debug_assert!(!self.0.mServoStyles.mPtr.is_null());
let author_styles = unsafe {
&*(self.0.mServoStyles.mPtr
as *const structs::RawServoAuthorStyles
as *const bindings::RawServoAuthorStyles)
};
let author_styles =
AuthorStyles::<GeckoStyleSheet>::from_ffi(author_styles);
debug_assert!(
author_styles.quirks_mode == self.as_node().owner_doc().quirks_mode() ||
author_styles.stylesheets.is_empty()
);
&author_styles.data
}
}
/// A simple wrapper over a non-null Gecko node (`nsINode`) pointer.
@ -1457,26 +1481,6 @@ impl<'le> TElement for GeckoElement<'le> {
// rule_hash_target, that is, our originating element.
let mut current = Some(self.rule_hash_target());
while let Some(element) = current {
// TODO(emilio): Deal with Shadow DOM separately than with XBL
// (right now we still rely on get_xbl_binding_parent()).
//
// That will allow to clean up a bunch in
// push_applicable_declarations.
if let Some(shadow) = element.shadow_root() {
debug_assert!(!shadow.0.mServoStyles.mPtr.is_null());
let author_styles = unsafe {
&*(shadow.0.mServoStyles.mPtr
as *const structs::RawServoAuthorStyles
as *const bindings::RawServoAuthorStyles)
};
let author_styles: &'a _ = AuthorStyles::<GeckoStyleSheet>::from_ffi(author_styles);
f(&author_styles.data, author_styles.quirks_mode);
if element != *self {
break;
}
}
if let Some(binding) = element.xbl_binding() {
binding.each_xbl_cascade_data(&mut f);