Title: [266656] trunk
- Revision
- 266656
- Author
- [email protected]
- Date
- 2020-09-04 23:43:37 -0700 (Fri, 04 Sep 2020)
Log Message
CSS :visited color taken on non-visited link when using CSS variables
https://bugs.webkit.org/show_bug.cgi?id=210525
Source/WebCore:
Patch by Tyler Wilcock <[email protected]> on 2020-09-04
Reviewed by Darin Adler.
This patch fixes a bug in which :visited styles with variables (custom properties)
were being applied to non-visited links, as the builder link match state was
unconditionally changed from MatchVisited to MatchDefault when resolving said variables.
Now all link state mutations are limited to the smallest scope possible, meaning the
erroneous reset to MatchDefault is no longer necessary.
Test: fast/css/link-with-variable-styling.html
* style/StyleBuilder.cpp:
(WebCore::Style::Builder::applyCustomProperty): Limit m_linkState mutations with SetForScope to prevent said
mutations from leaking out and causing unintended side effects.
LayoutTests:
Add reftest ensuring :visited link styles don't override regular styles
for links that have not yet been visited.
Patch by Tyler Wilcock <[email protected]> on 2020-09-04
Reviewed by Darin Adler.
* fast/css/link-with-variable-styling-expected.html: Added.
* fast/css/link-with-variable-styling.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (266655 => 266656)
--- trunk/LayoutTests/ChangeLog 2020-09-05 04:53:16 UTC (rev 266655)
+++ trunk/LayoutTests/ChangeLog 2020-09-05 06:43:37 UTC (rev 266656)
@@ -1,3 +1,16 @@
+2020-09-04 Tyler Wilcock <[email protected]>
+
+ CSS :visited color taken on non-visited link when using CSS variables
+ https://bugs.webkit.org/show_bug.cgi?id=210525
+
+ Add reftest ensuring :visited link styles don't override regular styles
+ for links that have not yet been visited.
+
+ Reviewed by Darin Adler.
+
+ * fast/css/link-with-variable-styling-expected.html: Added.
+ * fast/css/link-with-variable-styling.html: Added.
+
2020-09-04 Karl Rackler <[email protected]>
(REGRESSION (r266045): [ Big Sur ] 6 forms and 3 tables tests are a constant failure with approximately 1px difference)
Added: trunk/LayoutTests/fast/css/link-with-variable-styling-expected.html (0 => 266656)
--- trunk/LayoutTests/fast/css/link-with-variable-styling-expected.html (rev 0)
+++ trunk/LayoutTests/fast/css/link-with-variable-styling-expected.html 2020-09-05 06:43:37 UTC (rev 266656)
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <style>
+ .link {
+ color: green;
+ }
+ .link:visited {
+ color: red;
+ }
+ </style>
+ </head>
+ <body>
+ <a href="" class="link">Link</a>
+ </body>
+</html>
+
Added: trunk/LayoutTests/fast/css/link-with-variable-styling.html (0 => 266656)
--- trunk/LayoutTests/fast/css/link-with-variable-styling.html (rev 0)
+++ trunk/LayoutTests/fast/css/link-with-variable-styling.html 2020-09-05 06:43:37 UTC (rev 266656)
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <style>
+ .link {
+ color: var(--link-color);
+ }
+ .link:visited {
+ color: var(--link-color-visited);
+ }
+ .theme {
+ --link-color: green;
+ --link-color-visited: red;
+ }
+ </style>
+ </head>
+ <body>
+ <a href="" class="link theme">Link</a>
+ </body>
+</html>
+
Modified: trunk/Source/WebCore/ChangeLog (266655 => 266656)
--- trunk/Source/WebCore/ChangeLog 2020-09-05 04:53:16 UTC (rev 266655)
+++ trunk/Source/WebCore/ChangeLog 2020-09-05 06:43:37 UTC (rev 266656)
@@ -1,3 +1,22 @@
+2020-09-04 Tyler Wilcock <[email protected]>
+
+ CSS :visited color taken on non-visited link when using CSS variables
+ https://bugs.webkit.org/show_bug.cgi?id=210525
+
+ Reviewed by Darin Adler.
+
+ This patch fixes a bug in which :visited styles with variables (custom properties)
+ were being applied to non-visited links, as the builder link match state was
+ unconditionally changed from MatchVisited to MatchDefault when resolving said variables.
+ Now all link state mutations are limited to the smallest scope possible, meaning the
+ erroneous reset to MatchDefault is no longer necessary.
+
+ Test: fast/css/link-with-variable-styling.html
+
+ * style/StyleBuilder.cpp:
+ (WebCore::Style::Builder::applyCustomProperty): Limit m_linkState mutations with SetForScope to prevent said
+ mutations from leaking out and causing unintended side effects.
+
2020-09-04 Alex Christensen <[email protected]>
Fix build when using non-standard unified sources.
Modified: trunk/Source/WebCore/style/StyleBuilder.cpp (266655 => 266656)
--- trunk/Source/WebCore/style/StyleBuilder.cpp 2020-09-05 04:53:16 UTC (rev 266655)
+++ trunk/Source/WebCore/style/StyleBuilder.cpp 2020-09-05 06:43:37 UTC (rev 266656)
@@ -40,6 +40,8 @@
#include "StyleFontSizeFunctions.h"
#include "StylePropertyShorthand.h"
+#include <wtf/SetForScope.h>
+
namespace WebCore {
namespace Style {
@@ -215,12 +217,11 @@
}
if (m_state.m_inProgressPropertiesCustom.contains(name)) {
- m_state.m_linkMatch = index;
+ SetForScope<SelectorChecker::LinkMatchMask> scopedLinkMatchMutation(m_state.m_linkMatch, index);
applyProperty(CSSPropertyCustom, valueToApply.get(), index);
}
}
- m_state.m_linkMatch = SelectorChecker::MatchDefault;
m_state.m_inProgressPropertiesCustom.remove(name);
m_state.m_appliedCustomProperties.add(name);
@@ -246,7 +247,7 @@
auto applyWithLinkMatch = [&](SelectorChecker::LinkMatchMask linkMatch) {
if (property.cssValue[linkMatch]) {
- m_state.m_linkMatch = linkMatch;
+ SetForScope<SelectorChecker::LinkMatchMask> scopedLinkMatchMutation(m_state.m_linkMatch, linkMatch);
applyProperty(property.id, *property.cssValue[linkMatch], linkMatch);
}
};
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes