Make :-moz-native-anonymous and :-moz-use-shadow-tree-root matches in Rust code.

This commit is contained in:
Xidorn Quan 2018-03-28 09:45:25 +11:00
parent bb15111dab
commit 911f174b70

View file

@ -814,6 +814,21 @@ impl<'le> GeckoElement<'le> {
(!self.as_node().is_in_shadow_tree() && self.has_xbl_binding_parent())
}
/// Returns true if this node is the shadow root of an use-element shadow tree.
#[inline]
fn is_root_of_use_element_shadow_tree(&self) -> bool {
if !self.is_root_of_anonymous_subtree() {
return false
}
match self.parent_element() {
Some(e) => {
e.local_name() == &*local_name!("use") &&
e.namespace() == &*ns!("http://www.w3.org/2000/svg")
},
None => false,
}
}
fn css_transitions_info(&self) -> FnvHashMap<LonghandId, Arc<AnimationValue>> {
use gecko_bindings::bindings::Gecko_ElementTransitions_EndValueAt;
use gecko_bindings::bindings::Gecko_ElementTransitions_Length;
@ -2103,10 +2118,14 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
}
true
}
NonTSPseudoClass::MozNativeAnonymous => {
self.is_in_native_anonymous_subtree()
}
NonTSPseudoClass::MozUseShadowTreeRoot => {
self.is_root_of_use_element_shadow_tree()
}
NonTSPseudoClass::MozTableBorderNonzero |
NonTSPseudoClass::MozBrowserFrame |
NonTSPseudoClass::MozNativeAnonymous |
NonTSPseudoClass::MozUseShadowTreeRoot => unsafe {
NonTSPseudoClass::MozBrowserFrame => unsafe {
Gecko_MatchesElement(pseudo_class.to_gecko_pseudoclasstype().unwrap(), self.0)
},
NonTSPseudoClass::MozIsHTML => {
@ -2235,20 +2254,10 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
#[inline]
fn blocks_ancestor_combinators(&self) -> bool {
if !self.is_root_of_anonymous_subtree() {
return false
}
match self.parent_element() {
Some(e) => {
// If this element is the shadow root of an use-element shadow
// tree, according to the spec, we should not match rules
// cross the shadow DOM boundary.
e.local_name() == &*local_name!("use") &&
e.namespace() == &*ns!("http://www.w3.org/2000/svg")
},
None => false,
}
// If this element is the shadow root of an use-element shadow tree,
// according to the spec, we should not match rules cross the shadow
// DOM boundary.
self.is_root_of_use_element_shadow_tree()
}
}