Stylo: Correct style match for element instances under a use-element tree.

This commit is contained in:
cku 2017-06-20 16:44:59 +08:00
parent 4d997f0d0c
commit 727725ac3d
6 changed files with 170 additions and 137 deletions

View file

@ -532,8 +532,12 @@ fn matches_complex_selector_internal<E, F>(mut selector_iter: SelectorIter<E::Im
SelectorMatchingResult::NotMatchedAndRestartFromClosestDescendant)
}
Combinator::Child | Combinator::Descendant => {
(element.parent_element(),
SelectorMatchingResult::NotMatchedGlobally)
if element.blocks_ancestor_combinators() {
(None, SelectorMatchingResult::NotMatchedGlobally)
} else {
(element.parent_element(),
SelectorMatchingResult::NotMatchedGlobally)
}
}
Combinator::PseudoElement => {
(element.pseudo_element_originating_element(),

View file

@ -85,4 +85,11 @@ pub trait Element: Sized + Debug {
/// Note: this can be false even if `.parent_element()` is `None`
/// if the parent node is a `DocumentFragment`.
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
}
}