mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +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
|
@ -825,15 +825,16 @@ impl Stylist {
|
|||
where
|
||||
E: TElement,
|
||||
{
|
||||
let cascade_inputs =
|
||||
self.lazy_pseudo_rules(
|
||||
guards,
|
||||
element,
|
||||
pseudo,
|
||||
is_probe,
|
||||
rule_inclusion,
|
||||
matching_fn
|
||||
);
|
||||
let cascade_inputs = self.lazy_pseudo_rules(
|
||||
guards,
|
||||
element,
|
||||
parent_style,
|
||||
pseudo,
|
||||
is_probe,
|
||||
rule_inclusion,
|
||||
matching_fn
|
||||
);
|
||||
|
||||
self.compute_pseudo_element_style_with_inputs(
|
||||
&cascade_inputs,
|
||||
pseudo,
|
||||
|
@ -981,10 +982,11 @@ impl Stylist {
|
|||
///
|
||||
/// See the documentation on lazy pseudo-elements in
|
||||
/// docs/components/style.md
|
||||
pub fn lazy_pseudo_rules<E>(
|
||||
fn lazy_pseudo_rules<E>(
|
||||
&self,
|
||||
guards: &StylesheetGuards,
|
||||
element: &E,
|
||||
parent_style: &ComputedValues,
|
||||
pseudo: &PseudoElement,
|
||||
is_probe: bool,
|
||||
rule_inclusion: RuleInclusion,
|
||||
|
@ -1028,13 +1030,13 @@ impl Stylist {
|
|||
|
||||
let mut inputs = CascadeInputs::default();
|
||||
let mut declarations = ApplicableDeclarationList::new();
|
||||
let mut matching_context =
|
||||
MatchingContext::new(
|
||||
MatchingMode::ForStatelessPseudoElement,
|
||||
None,
|
||||
None,
|
||||
self.quirks_mode,
|
||||
);
|
||||
let mut matching_context = MatchingContext::new(
|
||||
MatchingMode::ForStatelessPseudoElement,
|
||||
None,
|
||||
None,
|
||||
self.quirks_mode,
|
||||
);
|
||||
|
||||
matching_context.pseudo_element_matching_fn = matching_fn;
|
||||
|
||||
self.push_applicable_declarations(
|
||||
|
@ -1062,7 +1064,7 @@ impl Stylist {
|
|||
return inputs;
|
||||
}
|
||||
|
||||
if matching_context.relevant_link_found {
|
||||
if parent_style.visited_style().is_some() {
|
||||
let mut declarations = ApplicableDeclarationList::new();
|
||||
let mut matching_context =
|
||||
MatchingContext::new_for_visited(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue