Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upStylo: visited pseudo-class support #17032
Merged
Conversation
Adjust the matching process to look for a "relevant link" while matching. A "relevant link" is the element being matched if it is a link or the nearest ancestor link. Matching for links now depends on the `VisitedHandlingMode`, which determines whether all links match as if they are unvisited (the default) or if the relevant link matches as visited (and all others remain unvisited). If a relevant link is ever found for any selector, track this as part of the `MatchingContext` object. This is used in the next patch to determine if an additional match and cascade should be performed to compute the styles when visited. MozReview-Commit-ID: 3xUbRo7vpuD
To support visited styles, we match and cascade a separate set of styles any time we notice that an element has a relevant link. The visited rules and values are held in `ComputedStyle` alongside the regular rules and values, which simplifies supporting various APIs like `cascade_primary_and_pseudos` which expect easy access to previously matched rules. To simplify passing the additional values around, an additional reference to the visited `ComputedValues` is placed inside the regular `ComputedValues`. MozReview-Commit-ID: 2ebbjcfkfWf
Since visited rules are stored separately, we need also run `replace_rules` for those in addition to regular rules. MozReview-Commit-ID: 4KYhOBXm88O
Extend restyle hints to check additional cases for visited. If we are sensitive to visitedness and the visited state changed, we force a restyle here. Matching doesn't depend on the actual visited state at all, so we can't look at matching results to decide what to do for this case. This also updates the snapshot version of `match_non_ts_pseudo_class` to check the relevant link instead of the element state, just like we do when matching with regular Gecko elements. There's also a separate case of a visited-dependent selector when other state or attributes change. For this, we need to cover both types of matching we use when cascading values. If there is a relevant link, then we also matched in visited mode. Match again in this mode to ensure this also matches. Note that we never actually match directly against the element's true visited state at all, since that would expose us to timing attacks. The matching process only considers the relevant link state and visited handling mode when deciding if visited matches. MozReview-Commit-ID: CVGquetQ2VW
The style sharing cache stores the regular `ComputedValues`, so it would also have the visited values as well for anything inserted into the cache (since they are nested inside). Unlike all other element states, a change in state of unvisited vs. visited does not change the style system's output, since we have already computed both possible outputs up front. We change the element state checks when looking for style sharing cache hits to ignore visitedness, since that's handled by the two separate sets of values. MozReview-Commit-ID: Dt8uK8gSQSP
Speed up the visited cascade by only running it for the properties that are actually visited dependent. (These are only the properties where the separate set of visited styles is even read at all, so running the rest is wasted work.) MozReview-Commit-ID: 5B7wYtuH974
highfive
commented
May 24, 2017
|
Heads up! This PR modifies the following files:
|
highfive
commented
May 24, 2017
|
@bors-servo r=emilio |
|
|
|
@bors-servo p=1 |
bors-servo
added a commit
that referenced
this pull request
May 24, 2017
Stylo: visited pseudo-class support Reviewed in https://bugzilla.mozilla.org/show_bug.cgi?id=1328509 <!-- 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/17032) <!-- Reviewable:end -->
|
|
|
@bors-servo retry |
|
The last run hit the intermittent #16783 issue, hopefully the next run will work. |
|
@bors-servo p=10 |
bors-servo
added a commit
that referenced
this pull request
May 25, 2017
Stylo: visited pseudo-class support Reviewed in https://bugzilla.mozilla.org/show_bug.cgi?id=1328509 <!-- 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/17032) <!-- Reviewable:end -->
|
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
jryans commentedMay 24, 2017
•
edited by larsbergstrom
Reviewed in https://bugzilla.mozilla.org/show_bug.cgi?id=1328509
This change is