mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
style: Make style sharing look at XBL / Shadow DOM rules.
Bug: 1412251 Reviewed-by: bz MozReview-Commit-ID: II6lk6OmSZU
This commit is contained in:
parent
328f142f38
commit
4b43b7c7f8
5 changed files with 148 additions and 47 deletions
|
@ -487,9 +487,14 @@ impl<'le> GeckoElement<'le> {
|
|||
.and_then(|s| unsafe { s.mExtendedSlots.mPtr.as_ref() })
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn may_be_in_binding_manager(&self) -> bool {
|
||||
self.flags() & (structs::NODE_MAY_BE_IN_BINDING_MNGR as u32) != 0
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn get_xbl_binding(&self) -> Option<GeckoXBLBinding<'le>> {
|
||||
if self.flags() & (structs::NODE_MAY_BE_IN_BINDING_MNGR as u32) == 0 {
|
||||
if !self.may_be_in_binding_manager() {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
@ -522,9 +527,11 @@ impl<'le> GeckoElement<'le> {
|
|||
} else {
|
||||
let binding_parent = unsafe {
|
||||
self.get_non_xul_xbl_binding_parent_raw_content().as_ref()
|
||||
}.map(GeckoNode::from_content)
|
||||
.and_then(|n| n.as_element());
|
||||
debug_assert!(binding_parent == unsafe { bindings::Gecko_GetBindingParent(self.0).map(GeckoElement) });
|
||||
}.map(GeckoNode::from_content).and_then(|n| n.as_element());
|
||||
|
||||
debug_assert!(binding_parent == unsafe {
|
||||
bindings::Gecko_GetBindingParent(self.0).map(GeckoElement)
|
||||
});
|
||||
binding_parent
|
||||
}
|
||||
}
|
||||
|
@ -900,6 +907,28 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
self.get_before_or_after_pseudo(/* is_before = */ false)
|
||||
}
|
||||
|
||||
/// Ensure this accurately represents the rules that an element may ever
|
||||
/// match, even in the native anonymous content case.
|
||||
fn style_scope(&self) -> Self::ConcreteNode {
|
||||
if self.implemented_pseudo_element().is_some() {
|
||||
return self.closest_non_native_anonymous_ancestor().unwrap().style_scope();
|
||||
}
|
||||
|
||||
if self.is_in_native_anonymous_subtree() {
|
||||
return self.as_node().owner_doc().as_node();
|
||||
}
|
||||
|
||||
if self.get_xbl_binding().is_some() {
|
||||
return self.as_node();
|
||||
}
|
||||
|
||||
if let Some(parent) = self.get_xbl_binding_parent() {
|
||||
return parent.as_node();
|
||||
}
|
||||
|
||||
self.as_node().owner_doc().as_node()
|
||||
}
|
||||
|
||||
/// Execute `f` for each anonymous content child element (apart from
|
||||
/// ::before and ::after) whose originating element is `self`.
|
||||
fn each_anonymous_content_child<F>(&self, mut f: F)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue