Bug 1591987 - Fix ElementWrapper::is_link. r=jwatt

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2019-11-05 10:24:36 +00:00
parent 799a5345a7
commit e75a804980
3 changed files with 7 additions and 9 deletions

View File

@ -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]

View File

@ -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 {

View File

@ -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.