aboutsummaryrefslogtreecommitdiffstats
path: root/components/style/sharing
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-05-24 19:53:48 -0500
committerGitHub <noreply@github.com>2017-05-24 19:53:48 -0500
commit1f323f8848e47b01779de5145dd21d0f74ed16ca (patch)
treee6255957ec4d4055f033d7f039cf1c6adc3563ad /components/style/sharing
parente457d22f81ac0f45c4dc96867162f276de7bd291 (diff)
parentf12af6c8d606f63fbba32e1dc3580f38604da24a (diff)
downloadservo-1f323f8848e47b01779de5145dd21d0f74ed16ca.tar.gz
servo-1f323f8848e47b01779de5145dd21d0f74ed16ca.zip
Auto merge of #17032 - jryans:stylo-visited, r=emilio
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 -->
Diffstat (limited to 'components/style/sharing')
-rw-r--r--components/style/sharing/checks.rs15
-rw-r--r--components/style/sharing/mod.rs2
2 files changed, 16 insertions, 1 deletions
diff --git a/components/style/sharing/checks.rs b/components/style/sharing/checks.rs
index 5cc5869e509..4ac537e0009 100644
--- a/components/style/sharing/checks.rs
+++ b/components/style/sharing/checks.rs
@@ -8,6 +8,7 @@
use context::{CurrentElementInfo, SelectorFlagsMap, SharedStyleContext};
use dom::TElement;
+use element_state::*;
use matching::MatchMethods;
use selectors::bloom::BloomFilter;
use selectors::matching::{ElementSelectorFlags, StyleRelations};
@@ -80,6 +81,20 @@ pub fn have_same_class<E>(element: E,
element_class_attributes == *candidate.class_attributes.as_ref().unwrap()
}
+/// Compare element and candidate state, but ignore visitedness. Styles don't
+/// actually changed based on visitedness (since both possibilities are computed
+/// up front), so it's safe to share styles if visitedness differs.
+pub fn have_same_state_ignoring_visitedness<E>(element: E,
+ candidate: &StyleSharingCandidate<E>)
+ -> bool
+ where E: TElement,
+{
+ let state_mask = !IN_VISITED_OR_UNVISITED_STATE;
+ let state = element.get_state() & state_mask;
+ let candidate_state = candidate.element.get_state() & state_mask;
+ state == candidate_state
+}
+
/// Whether a given element and a candidate match the same set of "revalidation"
/// selectors.
///
diff --git a/components/style/sharing/mod.rs b/components/style/sharing/mod.rs
index 744571ca863..67fde2e047b 100644
--- a/components/style/sharing/mod.rs
+++ b/components/style/sharing/mod.rs
@@ -349,7 +349,7 @@ impl<E: TElement> StyleSharingCandidateCache<E> {
miss!(UserAndAuthorRules)
}
- if element.get_state() != candidate.element.get_state() {
+ if !checks::have_same_state_ignoring_visitedness(element, candidate) {
miss!(State)
}