style: no-op visited changes earlier if visited links are disabled.

We force a repaint from ContentStateChangedInternal if visited links are
disabled, and that's observable. Let's cut it off as early as we can to avoid
timing attacks even when :visited is disabled.

Differential Revision: https://phabricator.services.mozilla.com/D3304
This commit is contained in:
Emilio Cobos Álvarez 2018-08-14 10:47:25 +02:00
parent cc1897597c
commit 87b1e1cdc9
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 14 additions and 41 deletions

View file

@ -167,8 +167,13 @@ where
// do for this case.
if state_changes.intersects(ElementState::IN_VISITED_OR_UNVISITED_STATE) {
trace!(" > visitedness change, force subtree restyle");
// If we get here with visited links disabled, we should probably
// just avoid the restyle and remove the state change here, not only
// as an optimization, but also because it kind of would kill the
// point of disabling visited links.
debug_assert!(self.shared_context.visited_styles_enabled);
// We can't just return here because there may also be attribute
// changes as well that imply additional hints.
// changes as well that imply additional hints for siblings.
self.data.hint.insert(RestyleHint::restyle_subtree());
}