When setting colors for anchor tags using css-vars, the visited color in a css-variable override is taken even if other anchor tags on the same page (that are not using css-vars) don't exhibit the same behavior. https://jsfiddle.net/rf1njobm/3/ The first link on the page gets its styles from a --link-color-visited variable. An identical anchor tag (with the same href) that doesn't use a variable (only raw colors) doesn't appear to be visited.
<rdar://problem/61800412>
Created attachment 408005 [details] Patch
Created attachment 408018 [details] Patch
Comment on attachment 408018 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=408018&action=review > Source/WebCore/style/StyleBuilder.cpp:190 > + auto originalLinkMatch = m_state.m_linkMatch; This won’t do the right thing if the "return" below is done after changing m_state.m_linkMatch. We have a class SetForScope designed for this kind of thing, that could make sure we get that right.
Created attachment 408059 [details] Patch
TIL of SetForScope, thanks Darin! I think I've fixed it -- can you take another look?
Comment on attachment 408059 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=408059&action=review > Source/WebCore/style/StyleBuilder.cpp:43 > #include "StylePropertyShorthand.h" > > +#include <wtf/SetForScope.h> WebKit coding style does not leave a space between these making it two paragraphs. But fine to land like this for now. > Source/WebCore/style/StyleBuilder.cpp:220 > + SetForScope<SelectorChecker::LinkMatchMask> scopedLinkMatchMutation(m_state.m_linkMatch, index); Oh, looks like there is a better way to write it: auto scopedLinkMatchMutation = SetForScope(m_state.m_linkMatch, index); That way we don’t have to write out the type. But fine to land like this for now.
Committed r266656: <https://trac.webkit.org/changeset/266656> All reviewed patches have been landed. Closing bug and clearing flags on attachment 408059 [details].