mirror of
https://github.com/servo/servo.git
synced 2025-07-24 07:40:27 +01:00
Auto merge of #18104 - aethanyc:fix-nth-child-xbl-bug1382102, r=emilio
style: Skip matching :nth-child if element is the root of anonymous subtree This was reviewed in https://bugzilla.mozilla.org/show_bug.cgi?id=1382102 <!-- 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/18104) <!-- Reviewable:end -->
This commit is contained in:
commit
24270f9357
3 changed files with 21 additions and 2 deletions
|
@ -776,6 +776,10 @@ fn matches_generic_nth_child<E, F>(element: &E,
|
||||||
where E: Element,
|
where E: Element,
|
||||||
F: FnMut(&E, ElementSelectorFlags),
|
F: FnMut(&E, ElementSelectorFlags),
|
||||||
{
|
{
|
||||||
|
if element.ignores_nth_child_selectors() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
flags_setter(element, if is_from_end {
|
flags_setter(element, if is_from_end {
|
||||||
HAS_SLOW_SELECTOR
|
HAS_SLOW_SELECTOR
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -86,6 +86,12 @@ pub trait Element: Sized + Debug {
|
||||||
/// if the parent node is a `DocumentFragment`.
|
/// if the parent node is a `DocumentFragment`.
|
||||||
fn is_root(&self) -> bool;
|
fn is_root(&self) -> bool;
|
||||||
|
|
||||||
|
/// Returns whether this element should ignore matching nth child
|
||||||
|
/// selector.
|
||||||
|
fn ignores_nth_child_selectors(&self) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
/// Return true if we want to stop lookup ancestor of the current
|
/// Return true if we want to stop lookup ancestor of the current
|
||||||
/// element while matching complex selectors with descendant/child
|
/// element while matching complex selectors with descendant/child
|
||||||
/// combinator.
|
/// combinator.
|
||||||
|
|
|
@ -729,6 +729,12 @@ impl<'le> GeckoElement<'le> {
|
||||||
debug!("(Element not styled, discarding hints)");
|
debug!("(Element not styled, discarding hints)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// This logic is duplicated in Gecko's nsIContent::IsRootOfAnonymousSubtree.
|
||||||
|
fn is_root_of_anonymous_subtree(&self) -> bool {
|
||||||
|
use gecko_bindings::structs::NODE_IS_ANONYMOUS_ROOT;
|
||||||
|
self.flags() & (NODE_IS_ANONYMOUS_ROOT as u32) != 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts flags from the layout used by rust-selectors to the layout used
|
/// Converts flags from the layout used by rust-selectors to the layout used
|
||||||
|
@ -1970,9 +1976,12 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
||||||
node.owner_doc().mType == structs::root::nsIDocument_Type::eHTML
|
node.owner_doc().mType == structs::root::nsIDocument_Type::eHTML
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn ignores_nth_child_selectors(&self) -> bool {
|
||||||
|
self.is_root_of_anonymous_subtree()
|
||||||
|
}
|
||||||
|
|
||||||
fn blocks_ancestor_combinators(&self) -> bool {
|
fn blocks_ancestor_combinators(&self) -> bool {
|
||||||
use gecko_bindings::structs::NODE_IS_ANONYMOUS_ROOT;
|
if !self.is_root_of_anonymous_subtree() {
|
||||||
if self.flags() & (NODE_IS_ANONYMOUS_ROOT as u32) == 0 {
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue