Title: [292531] trunk
- Revision
- 292531
- Author
- [email protected]
- Date
- 2022-04-07 05:57:58 -0700 (Thu, 07 Apr 2022)
Log Message
[:has() pseudo-class] Support invalidation for :autofill pseudo class
https://bugs.webkit.org/show_bug.cgi?id=238899
Reviewed by Antti Koivisto.
Source/WebCore:
Tests: LayoutTests/fast/forms/input-autofilled-*.html
I've only added tests for the :autofill case, since the other pseudo-classes are supposed to be internal-only.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::setAutoFilled):
(WebCore::HTMLInputElement::setAutoFilledAndViewable):
(WebCore::HTMLInputElement::setAutoFilledAndObscured):
LayoutTests:
* fast/forms/input-autofilled-expected.txt:
* fast/forms/input-autofilled.html:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (292530 => 292531)
--- trunk/LayoutTests/ChangeLog 2022-04-07 11:41:33 UTC (rev 292530)
+++ trunk/LayoutTests/ChangeLog 2022-04-07 12:57:58 UTC (rev 292531)
@@ -1,3 +1,13 @@
+2022-04-07 Tim Nguyen <[email protected]>
+
+ [:has() pseudo-class] Support invalidation for :autofill pseudo class
+ https://bugs.webkit.org/show_bug.cgi?id=238899
+
+ Reviewed by Antti Koivisto.
+
+ * fast/forms/input-autofilled-expected.txt:
+ * fast/forms/input-autofilled.html:
+
2022-04-06 Myles C. Maxfield <[email protected]>
NBSP characters drawn in fonts that don't support the space character turn into boxes
Modified: trunk/LayoutTests/fast/forms/input-autofilled-expected.txt (292530 => 292531)
--- trunk/LayoutTests/fast/forms/input-autofilled-expected.txt 2022-04-07 11:41:33 UTC (rev 292530)
+++ trunk/LayoutTests/fast/forms/input-autofilled-expected.txt 2022-04-07 12:57:58 UTC (rev 292531)
@@ -1,4 +1,6 @@
-This tests that foreground and background colors properly change for autofilled inputs. It can only be run using DumpRenderTree.
+This tests that foreground and background colors properly change for autofilled inputs.
-PASS
+PASS Testing input style changing with UA stylesheet
+PASS Testing form style changing with :has() selector
+
Modified: trunk/LayoutTests/fast/forms/input-autofilled.html (292530 => 292531)
--- trunk/LayoutTests/fast/forms/input-autofilled.html 2022-04-07 11:41:33 UTC (rev 292530)
+++ trunk/LayoutTests/fast/forms/input-autofilled.html 2022-04-07 12:57:58 UTC (rev 292531)
@@ -1,65 +1,53 @@
+<!DOCTYPE html>
<html>
<head>
- <script src=""
+ <style>
+ input {
+ color: #FFFFFF;
+ background-color: #FFFFFF;
+ }
+ form:has(input:autofill) {
+ background-color: green;
+ color: white;
+ }
+ </style>
+</head>
+<body>
+ This tests that foreground and background colors properly change for autofilled inputs.<br>
+ <form name="form" id="form">
+ <input type="text" id="input" value="Field value" />
+ </form>
+ <script src=""
+ <script src=""
<script>
- function test() {
- if (window.testRunner) {
- testRunner.dumpAsText();
- }
+ test(() => {
+ testElement(input);
+ }, "Testing input style changing with UA stylesheet");
+ test(() => {
+ testElement(form);
+ }, "Testing form style changing with :has() selector");
- var tf = document.getElementById('tf');
- var computedStyle = document.defaultView.getComputedStyle(tf);
- var originalForeground = computedStyle.color;
- var originalBackground = computedStyle.backgroundColor;
+ function testElement(element) {
+ let computedStyle = getComputedStyle(element);
+ let originalForeground = computedStyle.color;
+ let originalBackground = computedStyle.backgroundColor;
- if (window.internals) {
- window.internals.setAutofilled(tf, true);
- }
+ if (window.internals)
+ window.internals.setAutofilled(input, true);
- // Both the foreground and background colors should change.
- computedStyle = document.defaultView.getComputedStyle(tf);
- var autofilledForeground = computedStyle.color;
- var autofilledBackground = computedStyle.backgroundColor;
- if (autofilledForeground == originalForeground) {
- testFailed('Foreground color did not change when autofilled.');
- return;
- }
- if (autofilledBackground == originalBackground) {
- testFailed('Background color did not change when autofilled.');
- return;
- }
+ // Both the foreground and background colors should change when autofilled.
+ computedStyle = getComputedStyle(element);
+ assert_not_equals(computedStyle.color, originalForeground, "Text color should change when autofilled.");
+ assert_not_equals(computedStyle.backgroundColor, originalBackground, "Background color should change when autofilled.")
- if (window.internals) {
- window.internals.setAutofilled(tf, false);
- }
+ if (window.internals)
+ window.internals.setAutofilled(input, false);
// Colors should be restored.
- computedStyle = document.defaultView.getComputedStyle(tf);
- if (computedStyle.color != originalForeground) {
- testFailed('Foreground color did not revert when un-autofilled.');
- return;
- }
- if (computedStyle.backgroundColor != originalBackground) {
- testFailed('Background color did not revert when un-autofilled.');
- return;
- }
-
- testPassed('');
+ computedStyle = getComputedStyle(element);
+ assert_equals(computedStyle.color, originalForeground, "Text color should be restored");
+ assert_equals(computedStyle.backgroundColor, originalBackground, "Background color should be restored")
}
</script>
-
- <style>
- #tf {
- color: #FFFFFF;
- background-color: #FFFFFF;
- }
- </style>
-</head>
-<body _onload_="test()">
- This tests that foreground and background colors properly change for autofilled inputs. It can only be run using DumpRenderTree.<br>
- <form name="fm">
- <input type="text" id="tf" value="Field value" />
- </form>
- <div id="console"></div>
</body>
</html>
Modified: trunk/Source/WebCore/ChangeLog (292530 => 292531)
--- trunk/Source/WebCore/ChangeLog 2022-04-07 11:41:33 UTC (rev 292530)
+++ trunk/Source/WebCore/ChangeLog 2022-04-07 12:57:58 UTC (rev 292531)
@@ -1,3 +1,19 @@
+2022-04-07 Tim Nguyen <[email protected]>
+
+ [:has() pseudo-class] Support invalidation for :autofill pseudo class
+ https://bugs.webkit.org/show_bug.cgi?id=238899
+
+ Reviewed by Antti Koivisto.
+
+ Tests: LayoutTests/fast/forms/input-autofilled-*.html
+
+ I've only added tests for the :autofill case, since the other pseudo-classes are supposed to be internal-only.
+
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::setAutoFilled):
+ (WebCore::HTMLInputElement::setAutoFilledAndViewable):
+ (WebCore::HTMLInputElement::setAutoFilledAndObscured):
+
2022-04-07 Carlos Garcia Campos <[email protected]>
Unreviewed. [GStreamer] Fix compile warning
Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (292530 => 292531)
--- trunk/Source/WebCore/html/HTMLInputElement.cpp 2022-04-07 11:41:33 UTC (rev 292530)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp 2022-04-07 12:57:58 UTC (rev 292531)
@@ -1406,8 +1406,8 @@
if (autoFilled == m_isAutoFilled)
return;
+ Style::PseudoClassChangeInvalidation styleInvalidation(*this, CSSSelector::PseudoClassAutofill, autoFilled);
m_isAutoFilled = autoFilled;
- invalidateStyleForSubtree();
}
void HTMLInputElement::setAutoFilledAndViewable(bool autoFilledAndViewable)
@@ -1415,8 +1415,8 @@
if (autoFilledAndViewable == m_isAutoFilledAndViewable)
return;
+ Style::PseudoClassChangeInvalidation styleInvalidation(*this, CSSSelector::PseudoClassAutofillStrongPasswordViewable, autoFilledAndViewable);
m_isAutoFilledAndViewable = autoFilledAndViewable;
- invalidateStyleForSubtree();
}
void HTMLInputElement::setAutoFilledAndObscured(bool autoFilledAndObscured)
@@ -1424,8 +1424,8 @@
if (autoFilledAndObscured == m_isAutoFilledAndObscured)
return;
+ Style::PseudoClassChangeInvalidation styleInvalidation(*this, CSSSelector::PseudoClassAutofillAndObscured, autoFilledAndObscured);
m_isAutoFilledAndObscured = autoFilledAndObscured;
- invalidateStyleForSubtree();
}
void HTMLInputElement::setShowAutoFillButton(AutoFillButtonType autoFillButtonType)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes