mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Stylo: Correct style match for element instances under a use-element tree.
This commit is contained in:
parent
4d997f0d0c
commit
727725ac3d
6 changed files with 170 additions and 137 deletions
|
@ -532,8 +532,12 @@ fn matches_complex_selector_internal<E, F>(mut selector_iter: SelectorIter<E::Im
|
||||||
SelectorMatchingResult::NotMatchedAndRestartFromClosestDescendant)
|
SelectorMatchingResult::NotMatchedAndRestartFromClosestDescendant)
|
||||||
}
|
}
|
||||||
Combinator::Child | Combinator::Descendant => {
|
Combinator::Child | Combinator::Descendant => {
|
||||||
(element.parent_element(),
|
if element.blocks_ancestor_combinators() {
|
||||||
SelectorMatchingResult::NotMatchedGlobally)
|
(None, SelectorMatchingResult::NotMatchedGlobally)
|
||||||
|
} else {
|
||||||
|
(element.parent_element(),
|
||||||
|
SelectorMatchingResult::NotMatchedGlobally)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Combinator::PseudoElement => {
|
Combinator::PseudoElement => {
|
||||||
(element.pseudo_element_originating_element(),
|
(element.pseudo_element_originating_element(),
|
||||||
|
|
|
@ -85,4 +85,11 @@ pub trait Element: Sized + Debug {
|
||||||
/// Note: this can be false even if `.parent_element()` is `None`
|
/// Note: this can be false even if `.parent_element()` is `None`
|
||||||
/// if the parent node is a `DocumentFragment`.
|
/// if the parent node is a `DocumentFragment`.
|
||||||
fn is_root(&self) -> bool;
|
fn is_root(&self) -> bool;
|
||||||
|
|
||||||
|
/// Return true if we want to stop lookup ancestor of the current
|
||||||
|
/// element while matching complex selectors with descendant/child
|
||||||
|
/// combinator.
|
||||||
|
fn blocks_ancestor_combinators(&self) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10627,73 +10627,74 @@ pub mod root {
|
||||||
mozIsHTML = 18,
|
mozIsHTML = 18,
|
||||||
unresolved = 19,
|
unresolved = 19,
|
||||||
mozNativeAnonymous = 20,
|
mozNativeAnonymous = 20,
|
||||||
mozSystemMetric = 21,
|
mozUseShadowTreeRoot = 21,
|
||||||
mozLocaleDir = 22,
|
mozSystemMetric = 22,
|
||||||
mozLWTheme = 23,
|
mozLocaleDir = 23,
|
||||||
mozLWThemeBrightText = 24,
|
mozLWTheme = 24,
|
||||||
mozLWThemeDarkText = 25,
|
mozLWThemeBrightText = 25,
|
||||||
mozWindowInactive = 26,
|
mozLWThemeDarkText = 26,
|
||||||
mozTableBorderNonzero = 27,
|
mozWindowInactive = 27,
|
||||||
mozBrowserFrame = 28,
|
mozTableBorderNonzero = 28,
|
||||||
scope = 29,
|
mozBrowserFrame = 29,
|
||||||
negation = 30,
|
scope = 30,
|
||||||
dir = 31,
|
negation = 31,
|
||||||
link = 32,
|
dir = 32,
|
||||||
mozAnyLink = 33,
|
link = 33,
|
||||||
anyLink = 34,
|
mozAnyLink = 34,
|
||||||
visited = 35,
|
anyLink = 35,
|
||||||
active = 36,
|
visited = 36,
|
||||||
checked = 37,
|
active = 37,
|
||||||
disabled = 38,
|
checked = 38,
|
||||||
enabled = 39,
|
disabled = 39,
|
||||||
focus = 40,
|
enabled = 40,
|
||||||
focusWithin = 41,
|
focus = 41,
|
||||||
hover = 42,
|
focusWithin = 42,
|
||||||
mozDragOver = 43,
|
hover = 43,
|
||||||
target = 44,
|
mozDragOver = 44,
|
||||||
indeterminate = 45,
|
target = 45,
|
||||||
mozDevtoolsHighlighted = 46,
|
indeterminate = 46,
|
||||||
mozStyleeditorTransitioning = 47,
|
mozDevtoolsHighlighted = 47,
|
||||||
fullscreen = 48,
|
mozStyleeditorTransitioning = 48,
|
||||||
mozFullScreen = 49,
|
fullscreen = 49,
|
||||||
mozFocusRing = 50,
|
mozFullScreen = 50,
|
||||||
mozBroken = 51,
|
mozFocusRing = 51,
|
||||||
mozLoading = 52,
|
mozBroken = 52,
|
||||||
mozUserDisabled = 53,
|
mozLoading = 53,
|
||||||
mozSuppressed = 54,
|
mozUserDisabled = 54,
|
||||||
mozHandlerClickToPlay = 55,
|
mozSuppressed = 55,
|
||||||
mozHandlerVulnerableUpdatable = 56,
|
mozHandlerClickToPlay = 56,
|
||||||
mozHandlerVulnerableNoUpdate = 57,
|
mozHandlerVulnerableUpdatable = 57,
|
||||||
mozHandlerDisabled = 58,
|
mozHandlerVulnerableNoUpdate = 58,
|
||||||
mozHandlerBlocked = 59,
|
mozHandlerDisabled = 59,
|
||||||
mozHandlerCrashed = 60,
|
mozHandlerBlocked = 60,
|
||||||
mozMathIncrementScriptLevel = 61,
|
mozHandlerCrashed = 61,
|
||||||
mozHasDirAttr = 62,
|
mozMathIncrementScriptLevel = 62,
|
||||||
mozDirAttrLTR = 63,
|
mozHasDirAttr = 63,
|
||||||
mozDirAttrRTL = 64,
|
mozDirAttrLTR = 64,
|
||||||
mozDirAttrLikeAuto = 65,
|
mozDirAttrRTL = 65,
|
||||||
mozAutofill = 66,
|
mozDirAttrLikeAuto = 66,
|
||||||
mozAutofillPreview = 67,
|
mozAutofill = 67,
|
||||||
required = 68,
|
mozAutofillPreview = 68,
|
||||||
optional = 69,
|
required = 69,
|
||||||
valid = 70,
|
optional = 70,
|
||||||
invalid = 71,
|
valid = 71,
|
||||||
inRange = 72,
|
invalid = 72,
|
||||||
outOfRange = 73,
|
inRange = 73,
|
||||||
defaultPseudo = 74,
|
outOfRange = 74,
|
||||||
placeholderShown = 75,
|
defaultPseudo = 75,
|
||||||
mozReadOnly = 76,
|
placeholderShown = 76,
|
||||||
mozReadWrite = 77,
|
mozReadOnly = 77,
|
||||||
mozSubmitInvalid = 78,
|
mozReadWrite = 78,
|
||||||
mozUIInvalid = 79,
|
mozSubmitInvalid = 79,
|
||||||
mozUIValid = 80,
|
mozUIInvalid = 80,
|
||||||
mozMeterOptimum = 81,
|
mozUIValid = 81,
|
||||||
mozMeterSubOptimum = 82,
|
mozMeterOptimum = 82,
|
||||||
mozMeterSubSubOptimum = 83,
|
mozMeterSubOptimum = 83,
|
||||||
mozPlaceholder = 84,
|
mozMeterSubSubOptimum = 84,
|
||||||
Count = 85,
|
mozPlaceholder = 85,
|
||||||
NotPseudo = 86,
|
Count = 86,
|
||||||
MAX = 87,
|
NotPseudo = 87,
|
||||||
|
MAX = 88,
|
||||||
}
|
}
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
|
@ -10360,73 +10360,74 @@ pub mod root {
|
||||||
mozIsHTML = 18,
|
mozIsHTML = 18,
|
||||||
unresolved = 19,
|
unresolved = 19,
|
||||||
mozNativeAnonymous = 20,
|
mozNativeAnonymous = 20,
|
||||||
mozSystemMetric = 21,
|
mozUseShadowTreeRoot = 21,
|
||||||
mozLocaleDir = 22,
|
mozSystemMetric = 22,
|
||||||
mozLWTheme = 23,
|
mozLocaleDir = 23,
|
||||||
mozLWThemeBrightText = 24,
|
mozLWTheme = 24,
|
||||||
mozLWThemeDarkText = 25,
|
mozLWThemeBrightText = 25,
|
||||||
mozWindowInactive = 26,
|
mozLWThemeDarkText = 26,
|
||||||
mozTableBorderNonzero = 27,
|
mozWindowInactive = 27,
|
||||||
mozBrowserFrame = 28,
|
mozTableBorderNonzero = 28,
|
||||||
scope = 29,
|
mozBrowserFrame = 29,
|
||||||
negation = 30,
|
scope = 30,
|
||||||
dir = 31,
|
negation = 31,
|
||||||
link = 32,
|
dir = 32,
|
||||||
mozAnyLink = 33,
|
link = 33,
|
||||||
anyLink = 34,
|
mozAnyLink = 34,
|
||||||
visited = 35,
|
anyLink = 35,
|
||||||
active = 36,
|
visited = 36,
|
||||||
checked = 37,
|
active = 37,
|
||||||
disabled = 38,
|
checked = 38,
|
||||||
enabled = 39,
|
disabled = 39,
|
||||||
focus = 40,
|
enabled = 40,
|
||||||
focusWithin = 41,
|
focus = 41,
|
||||||
hover = 42,
|
focusWithin = 42,
|
||||||
mozDragOver = 43,
|
hover = 43,
|
||||||
target = 44,
|
mozDragOver = 44,
|
||||||
indeterminate = 45,
|
target = 45,
|
||||||
mozDevtoolsHighlighted = 46,
|
indeterminate = 46,
|
||||||
mozStyleeditorTransitioning = 47,
|
mozDevtoolsHighlighted = 47,
|
||||||
fullscreen = 48,
|
mozStyleeditorTransitioning = 48,
|
||||||
mozFullScreen = 49,
|
fullscreen = 49,
|
||||||
mozFocusRing = 50,
|
mozFullScreen = 50,
|
||||||
mozBroken = 51,
|
mozFocusRing = 51,
|
||||||
mozLoading = 52,
|
mozBroken = 52,
|
||||||
mozUserDisabled = 53,
|
mozLoading = 53,
|
||||||
mozSuppressed = 54,
|
mozUserDisabled = 54,
|
||||||
mozHandlerClickToPlay = 55,
|
mozSuppressed = 55,
|
||||||
mozHandlerVulnerableUpdatable = 56,
|
mozHandlerClickToPlay = 56,
|
||||||
mozHandlerVulnerableNoUpdate = 57,
|
mozHandlerVulnerableUpdatable = 57,
|
||||||
mozHandlerDisabled = 58,
|
mozHandlerVulnerableNoUpdate = 58,
|
||||||
mozHandlerBlocked = 59,
|
mozHandlerDisabled = 59,
|
||||||
mozHandlerCrashed = 60,
|
mozHandlerBlocked = 60,
|
||||||
mozMathIncrementScriptLevel = 61,
|
mozHandlerCrashed = 61,
|
||||||
mozHasDirAttr = 62,
|
mozMathIncrementScriptLevel = 62,
|
||||||
mozDirAttrLTR = 63,
|
mozHasDirAttr = 63,
|
||||||
mozDirAttrRTL = 64,
|
mozDirAttrLTR = 64,
|
||||||
mozDirAttrLikeAuto = 65,
|
mozDirAttrRTL = 65,
|
||||||
mozAutofill = 66,
|
mozDirAttrLikeAuto = 66,
|
||||||
mozAutofillPreview = 67,
|
mozAutofill = 67,
|
||||||
required = 68,
|
mozAutofillPreview = 68,
|
||||||
optional = 69,
|
required = 69,
|
||||||
valid = 70,
|
optional = 70,
|
||||||
invalid = 71,
|
valid = 71,
|
||||||
inRange = 72,
|
invalid = 72,
|
||||||
outOfRange = 73,
|
inRange = 73,
|
||||||
defaultPseudo = 74,
|
outOfRange = 74,
|
||||||
placeholderShown = 75,
|
defaultPseudo = 75,
|
||||||
mozReadOnly = 76,
|
placeholderShown = 76,
|
||||||
mozReadWrite = 77,
|
mozReadOnly = 77,
|
||||||
mozSubmitInvalid = 78,
|
mozReadWrite = 78,
|
||||||
mozUIInvalid = 79,
|
mozSubmitInvalid = 79,
|
||||||
mozUIValid = 80,
|
mozUIInvalid = 80,
|
||||||
mozMeterOptimum = 81,
|
mozUIValid = 81,
|
||||||
mozMeterSubOptimum = 82,
|
mozMeterOptimum = 82,
|
||||||
mozMeterSubSubOptimum = 83,
|
mozMeterSubOptimum = 83,
|
||||||
mozPlaceholder = 84,
|
mozMeterSubSubOptimum = 84,
|
||||||
Count = 85,
|
mozPlaceholder = 85,
|
||||||
NotPseudo = 86,
|
Count = 86,
|
||||||
MAX = 87,
|
NotPseudo = 87,
|
||||||
|
MAX = 88,
|
||||||
}
|
}
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
|
@ -111,6 +111,7 @@ macro_rules! apply_non_ts_list {
|
||||||
("-moz-last-node", MozLastNode, lastNode, _, _),
|
("-moz-last-node", MozLastNode, lastNode, _, _),
|
||||||
("-moz-only-whitespace", MozOnlyWhitespace, mozOnlyWhitespace, _, _),
|
("-moz-only-whitespace", MozOnlyWhitespace, mozOnlyWhitespace, _, _),
|
||||||
("-moz-native-anonymous", MozNativeAnonymous, mozNativeAnonymous, _, PSEUDO_CLASS_INTERNAL),
|
("-moz-native-anonymous", MozNativeAnonymous, mozNativeAnonymous, _, PSEUDO_CLASS_INTERNAL),
|
||||||
|
("-moz-use-shadow-tree-root", MozUseShadowTreeRoot, mozUseShadowTreeRoot, _, PSEUDO_CLASS_INTERNAL),
|
||||||
("-moz-is-html", MozIsHTML, mozIsHTML, _, _),
|
("-moz-is-html", MozIsHTML, mozIsHTML, _, _),
|
||||||
("-moz-placeholder", MozPlaceholder, mozPlaceholder, _, _),
|
("-moz-placeholder", MozPlaceholder, mozPlaceholder, _, _),
|
||||||
],
|
],
|
||||||
|
|
|
@ -1567,7 +1567,8 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
||||||
}
|
}
|
||||||
NonTSPseudoClass::MozTableBorderNonzero |
|
NonTSPseudoClass::MozTableBorderNonzero |
|
||||||
NonTSPseudoClass::MozBrowserFrame |
|
NonTSPseudoClass::MozBrowserFrame |
|
||||||
NonTSPseudoClass::MozNativeAnonymous => unsafe {
|
NonTSPseudoClass::MozNativeAnonymous |
|
||||||
|
NonTSPseudoClass::MozUseShadowTreeRoot => unsafe {
|
||||||
Gecko_MatchesElement(pseudo_class.to_gecko_pseudoclasstype().unwrap(), self.0)
|
Gecko_MatchesElement(pseudo_class.to_gecko_pseudoclasstype().unwrap(), self.0)
|
||||||
},
|
},
|
||||||
NonTSPseudoClass::MozIsHTML => {
|
NonTSPseudoClass::MozIsHTML => {
|
||||||
|
@ -1656,6 +1657,24 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
||||||
node_info.mInner.mNamespaceID == (structs::root::kNameSpaceID_XHTML as i32) &&
|
node_info.mInner.mNamespaceID == (structs::root::kNameSpaceID_XHTML as i32) &&
|
||||||
node.owner_doc().mType == structs::root::nsIDocument_Type::eHTML
|
node.owner_doc().mType == structs::root::nsIDocument_Type::eHTML
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn blocks_ancestor_combinators(&self) -> bool {
|
||||||
|
use gecko_bindings::structs::NODE_IS_ANONYMOUS_ROOT;
|
||||||
|
if self.flags() & (NODE_IS_ANONYMOUS_ROOT as u32) == 0 {
|
||||||
|
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.get_local_name().as_ptr() == atom!("use").as_ptr() &&
|
||||||
|
e.get_namespace() == &*Namespace(atom!("http://www.w3.org/2000/svg"))
|
||||||
|
},
|
||||||
|
None => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A few helpers to help with attribute selectors and snapshotting.
|
/// A few helpers to help with attribute selectors and snapshotting.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue