From 8d7a3683771f79c6ebaabc2d526ef387fbbae1a1 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Tue, 18 Jul 2017 12:40:01 -0700 Subject: [PATCH] stylo: Don't ignore visited state when deciding to share style contexts --- components/style/sharing/checks.rs | 15 --------------- components/style/sharing/mod.rs | 5 ++++- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/components/style/sharing/checks.rs b/components/style/sharing/checks.rs index b710dffdc4d..8ff232d7f42 100644 --- a/components/style/sharing/checks.rs +++ b/components/style/sharing/checks.rs @@ -10,7 +10,6 @@ use Atom; use bloom::StyleBloom; use context::{SelectorFlagsMap, SharedStyleContext}; use dom::TElement; -use element_state::*; use sharing::{StyleSharingCandidate, StyleSharingTarget}; use stylearc::Arc; @@ -68,20 +67,6 @@ pub fn have_same_class(target: &mut StyleSharingTarget, target.class_list() == candidate.class_list() } -/// 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(element: E, - candidate: &StyleSharingCandidate) - -> 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 462d0b16e1e..daf81862c38 100644 --- a/components/style/sharing/mod.rs +++ b/components/style/sharing/mod.rs @@ -643,7 +643,10 @@ impl StyleSharingCandidateCache { miss!(UserAndAuthorRules) } - if !checks::have_same_state_ignoring_visitedness(target.element, candidate) { + // We do not ignore visited state here, because Gecko + // needs to store extra bits on visited style contexts, + // so these contexts cannot be shared + if target.element.get_state() != candidate.get_state() { miss!(State) }