Changeset 292531 in webkit
- Timestamp:
- Apr 7, 2022 5:57:58 AM (3 months ago)
- Location:
- trunk
- Files:
-
- 5 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/forms/input-autofilled-expected.txt (modified) (1 diff)
-
LayoutTests/fast/forms/input-autofilled.html (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/html/HTMLInputElement.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r292522 r292531 1 2022-04-07 Tim Nguyen <ntim@apple.com> 2 3 [:has() pseudo-class] Support invalidation for :autofill pseudo class 4 https://bugs.webkit.org/show_bug.cgi?id=238899 5 6 Reviewed by Antti Koivisto. 7 8 * fast/forms/input-autofilled-expected.txt: 9 * fast/forms/input-autofilled.html: 10 1 11 2022-04-06 Myles C. Maxfield <mmaxfield@apple.com> 2 12 -
trunk/LayoutTests/fast/forms/input-autofilled-expected.txt
r267644 r292531 1 This tests that foreground and background colors properly change for autofilled inputs. It can only be run using DumpRenderTree.1 This tests that foreground and background colors properly change for autofilled inputs. 2 2 3 PASS4 3 4 PASS Testing input style changing with UA stylesheet 5 PASS Testing form style changing with :has() selector 6 -
trunk/LayoutTests/fast/forms/input-autofilled.html
r155268 r292531 1 <!DOCTYPE html> 1 2 <html> 2 3 <head> 3 <script src="../../resources/js-test-pre.js"></script>4 <script>5 function test() {6 if (window.testRunner) {7 testRunner.dumpAsText();8 }9 10 var tf = document.getElementById('tf');11 var computedStyle = document.defaultView.getComputedStyle(tf);12 var originalForeground = computedStyle.color;13 var originalBackground = computedStyle.backgroundColor;14 15 if (window.internals) {16 window.internals.setAutofilled(tf, true);17 }18 19 // Both the foreground and background colors should change.20 computedStyle = document.defaultView.getComputedStyle(tf);21 var autofilledForeground = computedStyle.color;22 var autofilledBackground = computedStyle.backgroundColor;23 if (autofilledForeground == originalForeground) {24 testFailed('Foreground color did not change when autofilled.');25 return;26 }27 if (autofilledBackground == originalBackground) {28 testFailed('Background color did not change when autofilled.');29 return;30 }31 32 if (window.internals) {33 window.internals.setAutofilled(tf, false);34 }35 36 // Colors should be restored.37 computedStyle = document.defaultView.getComputedStyle(tf);38 if (computedStyle.color != originalForeground) {39 testFailed('Foreground color did not revert when un-autofilled.');40 return;41 }42 if (computedStyle.backgroundColor != originalBackground) {43 testFailed('Background color did not revert when un-autofilled.');44 return;45 }46 47 testPassed('');48 }49 </script>50 51 4 <style> 52 #tf{5 input { 53 6 color: #FFFFFF; 54 7 background-color: #FFFFFF; 55 8 } 9 form:has(input:autofill) { 10 background-color: green; 11 color: white; 12 } 56 13 </style> 57 14 </head> 58 <body onload="test()">59 This tests that foreground and background colors properly change for autofilled inputs. It can only be run using DumpRenderTree.<br>60 <form name="f m">61 <input type="text" id=" tf" value="Field value" />15 <body> 16 This tests that foreground and background colors properly change for autofilled inputs.<br> 17 <form name="form" id="form"> 18 <input type="text" id="input" value="Field value" /> 62 19 </form> 63 <div id="console"></div> 20 <script src="../../resources/testharness.js"></script> 21 <script src="../../resources/testharnessreport.js"></script> 22 <script> 23 test(() => { 24 testElement(input); 25 }, "Testing input style changing with UA stylesheet"); 26 test(() => { 27 testElement(form); 28 }, "Testing form style changing with :has() selector"); 29 30 function testElement(element) { 31 let computedStyle = getComputedStyle(element); 32 let originalForeground = computedStyle.color; 33 let originalBackground = computedStyle.backgroundColor; 34 35 if (window.internals) 36 window.internals.setAutofilled(input, true); 37 38 // Both the foreground and background colors should change when autofilled. 39 computedStyle = getComputedStyle(element); 40 assert_not_equals(computedStyle.color, originalForeground, "Text color should change when autofilled."); 41 assert_not_equals(computedStyle.backgroundColor, originalBackground, "Background color should change when autofilled.") 42 43 if (window.internals) 44 window.internals.setAutofilled(input, false); 45 46 // Colors should be restored. 47 computedStyle = getComputedStyle(element); 48 assert_equals(computedStyle.color, originalForeground, "Text color should be restored"); 49 assert_equals(computedStyle.backgroundColor, originalBackground, "Background color should be restored") 50 } 51 </script> 64 52 </body> 65 53 </html> -
trunk/Source/WebCore/ChangeLog
r292530 r292531 1 2022-04-07 Tim Nguyen <ntim@apple.com> 2 3 [:has() pseudo-class] Support invalidation for :autofill pseudo class 4 https://bugs.webkit.org/show_bug.cgi?id=238899 5 6 Reviewed by Antti Koivisto. 7 8 Tests: LayoutTests/fast/forms/input-autofilled-*.html 9 10 I've only added tests for the :autofill case, since the other pseudo-classes are supposed to be internal-only. 11 12 * html/HTMLInputElement.cpp: 13 (WebCore::HTMLInputElement::setAutoFilled): 14 (WebCore::HTMLInputElement::setAutoFilledAndViewable): 15 (WebCore::HTMLInputElement::setAutoFilledAndObscured): 16 1 17 2022-04-07 Carlos Garcia Campos <cgarcia@igalia.com> 2 18 -
trunk/Source/WebCore/html/HTMLInputElement.cpp
r292466 r292531 1407 1407 return; 1408 1408 1409 Style::PseudoClassChangeInvalidation styleInvalidation(*this, CSSSelector::PseudoClassAutofill, autoFilled); 1409 1410 m_isAutoFilled = autoFilled; 1410 invalidateStyleForSubtree();1411 1411 } 1412 1412 … … 1416 1416 return; 1417 1417 1418 Style::PseudoClassChangeInvalidation styleInvalidation(*this, CSSSelector::PseudoClassAutofillStrongPasswordViewable, autoFilledAndViewable); 1418 1419 m_isAutoFilledAndViewable = autoFilledAndViewable; 1419 invalidateStyleForSubtree();1420 1420 } 1421 1421 … … 1425 1425 return; 1426 1426 1427 Style::PseudoClassChangeInvalidation styleInvalidation(*this, CSSSelector::PseudoClassAutofillAndObscured, autoFilledAndObscured); 1427 1428 m_isAutoFilledAndObscured = autoFilledAndObscured; 1428 invalidateStyleForSubtree();1429 1429 } 1430 1430
Note: See TracChangeset
for help on using the changeset viewer.