diff options
-rw-r--r-- | components/selectors/context.rs | 6 | ||||
-rw-r--r-- | components/selectors/matching.rs | 8 | ||||
-rw-r--r-- | components/style/data.rs | 8 | ||||
-rw-r--r-- | components/style/gecko/wrapper.rs | 4 | ||||
-rw-r--r-- | components/style/invalidation/element/invalidator.rs | 10 | ||||
-rw-r--r-- | components/style/matching.rs | 8 |
6 files changed, 42 insertions, 2 deletions
diff --git a/components/selectors/context.rs b/components/selectors/context.rs index c40c4b68ab4..12ebd977837 100644 --- a/components/selectors/context.rs +++ b/components/selectors/context.rs @@ -48,6 +48,12 @@ pub enum MatchingMode { pub enum VisitedHandlingMode { /// All links are matched as if they are unvisted. AllLinksUnvisited, + /// All links are matched as if they are visited and unvisited (both :link + /// and :visited match). + /// + /// This is intended to be used from invalidation code, to be conservative + /// about whether we need to restyle a link. + AllLinksVisitedAndUnvisited, /// A element's "relevant link" is the element being matched if it is a link /// or the nearest ancestor link. The relevant link is matched as though it /// is visited, and all other links are matched as if they are unvisited. diff --git a/components/selectors/matching.rs b/components/selectors/matching.rs index fc970374e38..3ab8f83c004 100644 --- a/components/selectors/matching.rs +++ b/components/selectors/matching.rs @@ -253,6 +253,10 @@ impl RelevantLinkStatus { return false } + if context.visited_handling == VisitedHandlingMode::AllLinksVisitedAndUnvisited { + return true; + } + // Non-relevant links are always unvisited. if *self != RelevantLinkStatus::Found { return false @@ -274,6 +278,10 @@ impl RelevantLinkStatus { return false } + if context.visited_handling == VisitedHandlingMode::AllLinksVisitedAndUnvisited { + return true; + } + // Non-relevant links are always unvisited. if *self != RelevantLinkStatus::Found { return true diff --git a/components/style/data.rs b/components/style/data.rs index ffb2ea4578c..677b4d78567 100644 --- a/components/style/data.rs +++ b/components/style/data.rs @@ -268,6 +268,10 @@ impl EagerPseudoStyles { rules: StrongRuleNode) -> bool { match visited_handling { + VisitedHandlingMode::AllLinksVisitedAndUnvisited => { + unreachable!("We should never try to selector match with \ + AllLinksVisitedAndUnvisited"); + }, VisitedHandlingMode::AllLinksUnvisited => { self.add_unvisited_rules(&pseudo, rules) }, @@ -286,6 +290,10 @@ impl EagerPseudoStyles { visited_handling: VisitedHandlingMode) -> bool { match visited_handling { + VisitedHandlingMode::AllLinksVisitedAndUnvisited => { + unreachable!("We should never try to selector match with \ + AllLinksVisitedAndUnvisited"); + }, VisitedHandlingMode::AllLinksUnvisited => { self.remove_unvisited_rules(&pseudo) }, diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index 40f587b1ea8..b419e258e45 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -1258,6 +1258,10 @@ impl<'le> PresentationalHintsSynthesizer for GeckoElement<'le> { // Unvisited vs. visited styles are computed up-front based on the // visited mode (not the element's actual state). let declarations = match visited_handling { + VisitedHandlingMode::AllLinksVisitedAndUnvisited => { + unreachable!("We should never try to selector match with \ + AllLinksVisitedAndUnvisited"); + }, VisitedHandlingMode::AllLinksUnvisited => unsafe { Gecko_GetUnvisitedLinkAttrDeclarationBlock(self.0) }, diff --git a/components/style/invalidation/element/invalidator.rs b/components/style/invalidation/element/invalidator.rs index c6d23dc89e2..df92a4f3a8d 100644 --- a/components/style/invalidation/element/invalidator.rs +++ b/components/style/invalidation/element/invalidator.rs @@ -420,8 +420,14 @@ impl<'a, 'b: 'a, E> TreeStyleInvalidator<'a, 'b, E> debug!("TreeStyleInvalidator::process_invalidation({:?}, {:?})", self.element, invalidation); - let mut context = MatchingContext::new(MatchingMode::Normal, None, - self.shared_context.quirks_mode); + let mut context = + MatchingContext::new_for_visited( + MatchingMode::Normal, + None, + VisitedHandlingMode::AllLinksVisitedAndUnvisited, + self.shared_context.quirks_mode, + ); + let matching_result = matches_compound_selector( &invalidation.selector, invalidation.offset, diff --git a/components/style/matching.rs b/components/style/matching.rs index 1d57956efc5..7866aea0a22 100644 --- a/components/style/matching.rs +++ b/components/style/matching.rs @@ -991,6 +991,10 @@ pub trait MatchMethods : TElement { &context.shared.guards); let rules_changed = match visited_handling { + VisitedHandlingMode::AllLinksVisitedAndUnvisited => { + unreachable!("We should never try to selector match with \ + AllLinksVisitedAndUnvisited"); + }, VisitedHandlingMode::AllLinksUnvisited => { data.set_primary_rules(rules) }, @@ -1070,6 +1074,10 @@ pub trait MatchMethods : TElement { ); let rules_changed = match visited_handling { + VisitedHandlingMode::AllLinksVisitedAndUnvisited => { + unreachable!("We should never try to selector match with \ + AllLinksVisitedAndUnvisited"); + }, VisitedHandlingMode::AllLinksUnvisited => { data.set_primary_rules(primary_rule_node) }, |