mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
selectors: Simplify :visited by only using the "is inside link" information.
Right now we go through a lot of hoops to see if we ever see a relevant link. However, that information is not needed: if the element is a link, we'll always need to compute its visited style because its its own relevant link. If the element inherits from a link, we need to also compute the visited style anyway. So the "has a relevant link been found" is pretty useless when we know what are we inheriting from. The branches at the beginning of matches_complex_selector_internal were affecting performance, and there are no good reasons to keep them. I've verified that this passes all the visited tests in mozilla central, and that the test-cases too-flaky to be landed still pass.
This commit is contained in:
parent
e4bb3a102e
commit
3119db724a
10 changed files with 128 additions and 208 deletions
|
@ -76,7 +76,7 @@ use selector_parser::{AttrValue, Direction, PseudoClassStringArg};
|
|||
use selectors::{Element, OpaqueElement};
|
||||
use selectors::attr::{AttrSelectorOperation, AttrSelectorOperator, CaseSensitivity, NamespaceConstraint};
|
||||
use selectors::matching::{ElementSelectorFlags, MatchingContext};
|
||||
use selectors::matching::{RelevantLinkStatus, VisitedHandlingMode};
|
||||
use selectors::matching::VisitedHandlingMode;
|
||||
use selectors::sink::Push;
|
||||
use servo_arc::{Arc, ArcBorrow, RawOffsetArc};
|
||||
use shared_lock::Locked;
|
||||
|
@ -1977,7 +1977,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
|||
&self,
|
||||
pseudo_class: &NonTSPseudoClass,
|
||||
context: &mut MatchingContext<Self::Impl>,
|
||||
relevant_link: &RelevantLinkStatus,
|
||||
visited_handling: VisitedHandlingMode,
|
||||
flags_setter: &mut F,
|
||||
) -> bool
|
||||
where
|
||||
|
@ -2037,8 +2037,12 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
|||
self.get_state().intersects(pseudo_class.state_flag())
|
||||
},
|
||||
NonTSPseudoClass::AnyLink => self.is_link(),
|
||||
NonTSPseudoClass::Link => relevant_link.is_unvisited(self, context),
|
||||
NonTSPseudoClass::Visited => relevant_link.is_visited(self, context),
|
||||
NonTSPseudoClass::Link => {
|
||||
self.is_link() && visited_handling.matches_unvisited()
|
||||
}
|
||||
NonTSPseudoClass::Visited => {
|
||||
self.is_link() && visited_handling.matches_visited()
|
||||
}
|
||||
NonTSPseudoClass::MozFirstNode => {
|
||||
flags_setter(self, ElementSelectorFlags::HAS_EDGE_CHILD_SELECTOR);
|
||||
let mut elem = self.as_node();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue