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.