mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +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
|
@ -44,7 +44,6 @@ where
|
|||
|
||||
struct MatchingResults {
|
||||
rule_node: StrongRuleNode,
|
||||
relevant_link_found: bool,
|
||||
}
|
||||
|
||||
/// A style returned from the resolver machinery.
|
||||
|
@ -158,15 +157,17 @@ where
|
|||
let primary_results =
|
||||
self.match_primary(VisitedHandlingMode::AllLinksUnvisited);
|
||||
|
||||
let relevant_link_found = primary_results.relevant_link_found;
|
||||
let inside_link =
|
||||
parent_style.map_or(false, |s| s.visited_style().is_some());
|
||||
|
||||
let visited_rules = if relevant_link_found {
|
||||
let visited_matching_results =
|
||||
self.match_primary(VisitedHandlingMode::RelevantLinkVisited);
|
||||
Some(visited_matching_results.rule_node)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let visited_rules =
|
||||
if inside_link || self.element.is_link() {
|
||||
let visited_matching_results =
|
||||
self.match_primary(VisitedHandlingMode::RelevantLinkVisited);
|
||||
Some(visited_matching_results.rule_node)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
self.cascade_primary_style(
|
||||
CascadeInputs {
|
||||
|
@ -446,7 +447,6 @@ where
|
|||
// FIXME(emilio): This is a hack for animations, and should go away.
|
||||
self.element.unset_dirty_style_attribute();
|
||||
|
||||
let relevant_link_found = matching_context.relevant_link_found;
|
||||
let rule_node = stylist.rule_tree().compute_rule_node(
|
||||
&mut applicable_declarations,
|
||||
&self.context.shared.guards
|
||||
|
@ -462,7 +462,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
MatchingResults { rule_node, relevant_link_found }
|
||||
MatchingResults { rule_node, }
|
||||
}
|
||||
|
||||
fn match_pseudo(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue