mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Auto merge of #17427 - CJKu:cku-master, r=emilio
Stylo: Correct style match for element instances under a use-element … <!-- Please describe your changes on the following line: --> This patch is the last one of bug 265894. It fixes two things: 1. Do not cross shadow tree boundary while matching rules. 2. Change display value to 'inline' while cloning a root symbol element instance. Bugzilla link: https://bugzilla.mozilla.org/show_bug.cgi?id=265894 --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17427) <!-- Reviewable:end -->
This commit is contained in:
commit
b2549bb6c4
4 changed files with 34 additions and 3 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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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, _, _),
|
||||||
],
|
],
|
||||||
|
|
|
@ -1645,7 +1645,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 => {
|
||||||
|
@ -1734,6 +1735,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