From d797b0e47523fe7326abe874cf2e77b460f98c75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Tue, 5 Nov 2019 10:24:36 +0000 Subject: [PATCH] style: Fix ElementWrapper::is_link. And do a full restyle only when the state goes from visited to unvisited or vice versa. That is, use regular invalidation for addition or removals of href attributes, for example. Differential Revision: https://phabricator.services.mozilla.com/D50821 --- components/style/gecko/wrapper.rs | 3 +-- components/style/invalidation/element/element_wrapper.rs | 5 ++++- .../style/invalidation/element/state_and_attributes.rs | 8 ++------ 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index c2c4a0c0feb..da989e5a74a 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -2191,8 +2191,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> { #[inline] fn is_link(&self) -> bool { - self.state() - .intersects(NonTSPseudoClass::AnyLink.state_flag()) + self.state().intersects(ElementState::IN_VISITED_OR_UNVISITED_STATE) } #[inline] diff --git a/components/style/invalidation/element/element_wrapper.rs b/components/style/invalidation/element/element_wrapper.rs index cb63e611348..b8e29095d24 100644 --- a/components/style/invalidation/element/element_wrapper.rs +++ b/components/style/invalidation/element/element_wrapper.rs @@ -270,7 +270,10 @@ where } fn is_link(&self) -> bool { - self.element.is_link() + match self.snapshot().and_then(|s| s.state()) { + Some(state) => state.intersects(ElementState::IN_VISITED_OR_UNVISITED_STATE), + None => self.element.is_link(), + } } fn opaque(&self) -> OpaqueElement { diff --git a/components/style/invalidation/element/state_and_attributes.rs b/components/style/invalidation/element/state_and_attributes.rs index c4671b0011c..cb3a5525e39 100644 --- a/components/style/invalidation/element/state_and_attributes.rs +++ b/components/style/invalidation/element/state_and_attributes.rs @@ -159,14 +159,10 @@ where // 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. // - // TODO(emilio): This should be contains(), to avoid doing subtree - // restyles when adding or removing an href attribute, but invalidation - // for that case is broken right now (bug 1591987). - // - // This piece of code should be removed when + // TODO(emilio): This piece of code should be removed when // layout.css.always-repaint-on-unvisited is true, since we cannot get // into this situation in that case. - if state_changes.intersects(ElementState::IN_VISITED_OR_UNVISITED_STATE) { + if state_changes.contains(ElementState::IN_VISITED_OR_UNVISITED_STATE) { trace!(" > visitedness change, force subtree restyle"); // We can't just return here because there may also be attribute // changes as well that imply additional hints for siblings.