In Servo, the `:link` and `:any-link` pseudo-classes correctly match
link elements when they are part of a compound selector whose last
simple selector does not start with them (e.g. `a:link` or `:link b`),
but they do not match when the last simple selector starts with `:link`.
The reason for this seems to be that Stylo uses two methods to determine
whether an element is an (unvisited) link: to call the `is_link()`
method on the `selectors::Element` trait, and to check if the element's
state has `ElementState::UNVISITED` set.
In a browser like Servo which does not support visited styles, these two
checks should be equivalent. However, they turn out not to be, because
Servo never actually sets `ElementState::UNVISITED`.
Since per the HTML spec the `:link` selector applies to all `<a>` and
`<area>` elements that have an `href` attribute, this patch fixes this
by setting `ElementState::UNVISITED` on such elements when the `href`
attribute is set, and by unsetting it when it is removed.
Testing: There are two invalidation-related WPT tests about the
`:any-link` selector that now pass with this patch.
Fixes: servo/stylo#282
---------
Signed-off-by: Andreu Botella <andreu@andreubotella.com>
Additionally, changes now need to be made to `servo.css` in order to
ensure that `<button>` text is centered the same way that it is for
`<input type=button>`. In the past the rule for centering text for the
latter was ignored because it used `:is()`.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>