Changeset 283935 in webkit
- Timestamp:
- Oct 11, 2021, 1:59:43 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 39 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/TestExpectations (modified) (1 diff)
-
LayoutTests/fast/dom/Window/window-scroll-ignore-null-frame.html (modified) (2 diffs)
-
LayoutTests/fast/dom/adopt-node-crash-2-expected.txt (modified) (1 diff)
-
LayoutTests/fast/dom/adopt-node-crash-2.html (modified) (2 diffs)
-
LayoutTests/fast/dom/window-inner-width-crash.html (modified) (1 diff)
-
LayoutTests/fast/forms/autofocus-in-sandbox-with-allow-scripts-expected.txt (modified) (1 diff)
-
LayoutTests/fast/forms/autofocus-in-sandbox-with-allow-scripts.html (modified) (1 diff)
-
LayoutTests/fast/forms/autofocus-keygen.html (modified) (1 diff)
-
LayoutTests/fast/forms/autofocus-opera-001.html (modified) (1 diff)
-
LayoutTests/fast/forms/autofocus-opera-002.html (modified) (1 diff)
-
LayoutTests/fast/forms/autofocus-opera-003.html (modified) (1 diff)
-
LayoutTests/fast/forms/autofocus-opera-006.html (modified) (2 diffs)
-
LayoutTests/fast/forms/autofocus-opera-007.html (modified) (1 diff)
-
LayoutTests/fast/forms/change-input-type-in-focus-handler.html (modified) (2 diffs)
-
LayoutTests/fast/frames/crash-when-iframe-is-remove-in-eventhandler.html (modified) (2 diffs)
-
LayoutTests/fast/history/page-cache-execute-script-during-restore.html (modified) (1 diff)
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/document-with-fragment-empty-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/document-with-fragment-nonexistent-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/document-with-fragment-top-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-when-later-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/queue-non-focusable-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/selection/selection-select-all-move-input-crash-expected.txt (modified) (1 diff)
-
LayoutTests/platform/ios-wk2/TestExpectations (modified) (1 diff)
-
LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering-expected.txt (modified) (1 diff)
-
LayoutTests/platform/ios/imported/w3c/web-platform-tests/selection/selection-select-all-move-input-crash-expected.txt (modified) (1 diff)
-
LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/html/interaction (deleted)
-
LayoutTests/platform/win/TestExpectations (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/dom/Document.cpp (modified) (1 diff)
-
Source/WebCore/dom/Document.h (modified) (3 diffs)
-
Source/WebCore/dom/Element.cpp (modified) (1 diff)
-
Source/WebCore/dom/Element.h (modified) (1 diff)
-
Source/WebCore/html/HTMLFormControlElement.cpp (modified) (6 diffs)
-
Source/WebCore/html/HTMLFormControlElement.h (modified) (3 diffs)
-
Source/WebCore/page/Page.cpp (modified) (2 diffs)
-
Source/WebCore/page/Page.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r283918 r283935 1 2021-10-11 Tim Nguyen <ntim@apple.com> 2 3 Implement new autofocus behavior 4 https://bugs.webkit.org/show_bug.cgi?id=203139 5 <rdar://problem/56397019> 6 7 Reviewed by Wenson Hsieh. 8 9 Make WebKit match the new autofocus spec: 10 - https://html.spec.whatwg.org/multipage/interaction.html#the-autofocus-attribute 11 - https://html.spec.whatwg.org/multipage/interaction.html#focusing-steps 12 13 The new autofocus behavior queues up all autofocusable elements (visible or not), then 14 fires autofocus asynchronously during the "update rendering" steps, unlike the old behavior 15 which runs focus synchronously whenever it finds a visible autofocusable element. 16 17 Original patch by Ryosuke Niwa. 18 19 * TestExpectations: 20 * fast/dom/Window/window-scroll-ignore-null-frame.html: 21 * fast/dom/adopt-node-crash-2-expected.txt: 22 * fast/dom/adopt-node-crash-2.html: 23 * fast/dom/window-inner-width-crash.html: 24 * fast/forms/autofocus-in-sandbox-with-allow-scripts-expected.txt: 25 * fast/forms/autofocus-in-sandbox-with-allow-scripts.html: 26 * fast/forms/autofocus-keygen.html: 27 * fast/forms/autofocus-opera-001.html: 28 * fast/forms/autofocus-opera-002.html: 29 * fast/forms/autofocus-opera-003.html: 30 * fast/forms/autofocus-opera-006.html: 31 * fast/forms/autofocus-opera-007.html: 32 * fast/forms/change-input-type-in-focus-handler.html: 33 * fast/frames/crash-when-iframe-is-remove-in-eventhandler.html: 34 * fast/history/page-cache-execute-script-during-restore.html: 35 * platform/ios-wk2/TestExpectations: 36 * platform/ios-wk2/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering-expected.txt: 37 * platform/ios/imported/w3c/web-platform-tests/selection/selection-select-all-move-input-crash-expected.txt: 38 * platform/mac-wk1/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering-expected.txt: 39 * platform/win/TestExpectations: 40 1 41 2021-10-11 Ayumi Kojima <ayumi_kojima@apple.com> 2 42 -
trunk/LayoutTests/TestExpectations
r283892 r283935 807 807 imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/combination_history_003.html [ Failure Pass ] 808 808 imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/execution-timing/058.html [ Failure Pass ] 809 imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering.html [ Failure Pass ]810 809 imported/w3c/web-platform-tests/html/rendering/widgets/baseline-alignment-and-overflow.tentative.html [ Failure Pass ] 811 810 imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/loading-the-media-resource/resource-selection-pointer-remove-source.html [ Failure Pass ] -
trunk/LayoutTests/fast/dom/Window/window-scroll-ignore-null-frame.html
r255334 r283935 3 3 4 4 function runTest() { 5 if (window.testRunner) 5 if (window.testRunner) { 6 6 testRunner.dumpAsText(); 7 testRunner.waitUntilDone(); 8 } 7 9 8 10 select1.appendChild(inputParent); … … 10 12 input1.setSelectionRange(1, 0); 11 13 document.body.appendChild(input1); 12 frame1.contentWindow.scrollBy({left: 1, top: 0}); 14 requestAnimationFrame(() => { 15 frame1.contentWindow.scrollBy({left: 1, top: 0}); 16 if (window.testRunner) 17 testRunner.notifyDone(); 18 }); 13 19 } 14 20 -
trunk/LayoutTests/fast/dom/adopt-node-crash-2-expected.txt
r234485 r283935 1 Tests for a crash due to adopting a DOM node during DOMFocusOut event. Test passes if it doesn't crash.1 Tests for a crash due to adopting a DOM node when unfocusing. Test passes if it doesn't crash. 2 2 3 PASS: Focused node should be keygen 4 PASS: Focused node should no longer be keygen -
trunk/LayoutTests/fast/dom/adopt-node-crash-2.html
r268400 r283935 1 1 <!DOCTYPE html><!-- webkit-test-runner [ KeygenElementEnabled=true ] --> 2 2 <html> 3 <div>Tests for a crash due to adopting a DOM node during DOMFocusOut event. Test passes if it doesn't crash.</div>3 <div>Tests for a crash due to adopting a DOM node when unfocusing. Test passes if it doesn't crash.</div> 4 4 <script> 5 5 if (window.testRunner) { … … 15 15 </applet> 16 16 <header id="header1"> 17 <keygen autofocus>17 <keygen id="keygen" autofocus> 18 18 </header> 19 19 </div> 20 <div id="logs"></div> 20 21 <script> 21 function doit()22 { 23 div2.addEventListener("DOMFocusOut", function () {24 d ocument.implementation.createDocument("", "", null).adoptNode(div2);25 setTimeout(() => {26 if (window.internals)27 internals.updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks();28 if (window.testRunner) 29 testRunner.notifyDone(); 30 }, 0); 31 }, false);22 function assert_true(assert, text) { 23 const div = document.createElement("div"); 24 if (assert) 25 div.textContent = "PASS: " + text; 26 else 27 div.textContent = "FAIL: " + text; 28 logs.append(div); 29 } 30 31 function doit() { 32 assert_true(document.activeElement == keygen, "Focused node should be keygen"); 32 33 div1.outerHTML = header1.outerHTML; 34 assert_true(document.activeElement != keygen, "Focused node should no longer be keygen"); 35 document.implementation.createDocument("", "", null).adoptNode(div2); 36 if (window.internals) 37 internals.updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(); 38 if (window.testRunner) 39 testRunner.notifyDone(); 33 40 } 34 41 window.onload = function() { 35 if (window.internals) 36 internals.updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(); 37 else 38 div2.getBoundingClientRect(); 39 setTimeout("doit()", 1); 40 } 42 requestAnimationFrame(doit); 43 }; 41 44 </script> 42 45 </html> -
trunk/LayoutTests/fast/dom/window-inner-width-crash.html
r245509 r283935 7 7 8 8 function runTest() { 9 button.autofocus = true;10 9 body.appendChild(paragraph); 10 button.focus(); 11 11 var testVal = window[0].innerWidth; 12 12 } -
trunk/LayoutTests/fast/forms/autofocus-in-sandbox-with-allow-scripts-expected.txt
r272607 r283935 1 CONSOLE MESSAGE: INPUT 2 This test passes if the activeElement is the input element rather than the body (which it would be if the sandbox didn't allow autofocus although allow-scripts flag is set). 1 This tests having an input element with autofocus content attribute inside a sandboxed iframe. 2 The input element should be autofocused since scripts are allowed. 3 4 -------- 5 Frame: '<!--frame1-->' 6 -------- 7 PASS -
trunk/LayoutTests/fast/forms/autofocus-in-sandbox-with-allow-scripts.html
r272607 r283935 1 1 <script> 2 if (window.testRunner) 2 if (window.testRunner) { 3 3 testRunner.dumpAsText(); 4 testRunner.dumpChildFramesAsText(); 5 } 4 6 </script> 5 This test passes if the activeElement is the input element rather than the body 6 (which it would be if the sandbox didn't allow autofocus although allow-scripts flag is set). 7 <iframe sandbox="allow-scripts allow-modals" 8 src="data:text/html,<input autofocus onfocus><script>window.onload = function() { console.log(document.activeElement.tagName) }</script>"></iframe> 7 This tests having an input element with autofocus content attribute inside a sandboxed iframe.<br> 8 The input element should be autofocused since scripts are allowed. 9 <iframe sandbox="allow-scripts" 10 src="data:text/html,<input id=input autofocus onfocus><script> 11 if (window.testRunner) 12 testRunner.waitUntilDone(); 13 window.onload = function () { 14 requestAnimationFrame(() => { 15 document.body.append(document.activeElement == input ? 'PASS' : 'FAIL'); 16 if (window.testRunner) 17 testRunner.notifyDone(); 18 }); 19 }</script>"></iframe> -
trunk/LayoutTests/fast/forms/autofocus-keygen.html
r268400 r283935 7 7 8 8 function onLoad() { 9 shouldBe('document.activeElement', 'document.querySelector("keygen")'); 10 shouldBe('document.activeElement.autofocus', 'true'); 11 finishJSTest(); 9 requestAnimationFrame(() => { 10 shouldBe('document.activeElement', 'document.querySelector("keygen")'); 11 shouldBe('document.activeElement.autofocus', 'true'); 12 finishJSTest(); 13 }); 12 14 } 13 15 </script> -
trunk/LayoutTests/fast/forms/autofocus-opera-001.html
r283659 r283935 12 12 13 13 function test() { 14 if (window.testRunner) 14 if (window.testRunner) { 15 15 testRunner.dumpAsText(); 16 testRunner.waitUntilDone(); 17 } 16 18 17 if (document.activeElement == document.getElementsByTagName("input")[0]) 18 log("SUCCESS"); 19 else 20 log("FAILURE"); 19 requestAnimationFrame(() => { 20 if (document.activeElement == document.getElementsByTagName("input")[0]) 21 log("SUCCESS"); 22 else 23 log("FAILURE"); 24 if (window.testRunner) 25 testRunner.notifyDone(); 26 }); 21 27 } 22 28 </script> -
trunk/LayoutTests/fast/forms/autofocus-opera-002.html
r283659 r283935 12 12 13 13 function test() { 14 if (window.testRunner) 14 if (window.testRunner) { 15 15 testRunner.dumpAsText(); 16 testRunner.waitUntilDone(); 17 } 16 18 17 if (document.activeElement == document.getElementsByTagName("input")[0]) 18 log("SUCCESS"); 19 else 20 log("FAILURE"); 19 requestAnimationFrame(() => { 20 if (document.activeElement == document.getElementsByTagName("input")[0]) 21 log("SUCCESS"); 22 else 23 log("FAILURE"); 24 if (window.testRunner) 25 testRunner.notifyDone(); 26 }); 21 27 } 22 28 </script> -
trunk/LayoutTests/fast/forms/autofocus-opera-003.html
r283659 r283935 13 13 14 14 function test() { 15 if (window.testRunner) 15 if (window.testRunner) { 16 16 testRunner.dumpAsText(); 17 testRunner.waitUntilDone(); 18 } 17 19 18 if (document.activeElement == document.getElementsByTagName("input")[0] && 19 document.scrollingElement.scrollTop != 0) 20 log("SUCCESS"); 21 else 22 log("FAILURE"); 20 requestAnimationFrame(() => { 21 if (document.activeElement == document.getElementsByTagName("input")[0] && 22 document.scrollingElement.scrollTop != 0) 23 log("SUCCESS"); 24 else 25 log("FAILURE"); 26 if (window.testRunner) 27 testRunner.notifyDone(); 28 }); 23 29 } 24 30 </script> -
trunk/LayoutTests/fast/forms/autofocus-opera-006.html
r283659 r283935 12 12 13 13 function test() { 14 if (window.testRunner) 14 if (window.testRunner) { 15 15 testRunner.dumpAsText(); 16 testRunner.waitUntilDone(); 17 } 16 18 17 if (document.activeElement == document.getElementById("test")) 18 log("SUCCESS"); 19 else 20 log("FAILURE"); 19 requestAnimationFrame(() => { 20 if (document.activeElement == document.getElementById("test")) 21 log("SUCCESS"); 22 else 23 log("FAILURE"); 24 if (window.testRunner) 25 testRunner.notifyDone(); 26 }); 27 21 28 } 22 29 </script> … … 24 31 <body onload="test()"> 25 32 <p>All form controls below should have a green background:</p> 26 <p><input autofocus >33 <p><input autofocus id="test"> 27 34 <p><input autofocus> 28 35 <p><input autofocus> 29 36 <p><input> 30 <p><input autofocus id="test">37 <p><input autofocus> 31 38 <p><input> 32 39 <hr/> -
trunk/LayoutTests/fast/forms/autofocus-opera-007.html
r283659 r283935 18 18 19 19 function test() { 20 if (window.testRunner) 20 if (window.testRunner) { 21 21 testRunner.dumpAsText(); 22 testRunner.waitUntilDone(); 23 } 22 24 23 if (gotBlur) 24 log("SUCCESS"); 25 else 26 log("FAILURE"); 25 requestAnimationFrame(() => { 26 if (gotBlur) 27 log("SUCCESS"); 28 else 29 log("FAILURE"); 30 if (window.testRunner) 31 testRunner.notifyDone(); 32 }); 27 33 } 28 34 </script> -
trunk/LayoutTests/fast/forms/change-input-type-in-focus-handler.html
r222114 r283935 11 11 if (input.autofocus) { 12 12 input.type = "checkbox"; 13 document.body.innerHTML = "<code style='color: green'>PASS</code>"; 13 document.body.innerHTML = "FAIL - focus event handler called for autofocus"; 14 if (window.testRunner) 15 testRunner.notifyDone(); 14 16 return; 15 17 } … … 17 19 document.body.appendChild(input); 18 20 input.autofocus = true; 21 requestAnimationFrame(() => { 22 document.body.textContent = document.activeElement == document.body ? "PASS" : "FAIL"; 23 if (window.testRunner) 24 testRunner.notifyDone(); 25 }); 19 26 } 20 27 21 if (window.testRunner) 28 if (window.testRunner) { 22 29 testRunner.dumpAsText(); 30 testRunner.waitUntilDone(); 31 } 23 32 24 33 input.focus(); -
trunk/LayoutTests/fast/frames/crash-when-iframe-is-remove-in-eventhandler.html
r225719 r283935 7 7 <textarea id=textarea onfocus="eventhandler()"></textarea> 8 8 <script> 9 if (window.testRunner) 9 if (window.testRunner) { 10 10 testRunner.dumpAsText(); 11 testRunner.waitUntilDone(); 12 } 13 11 14 document.offsetHeight; 12 15 textarea.autofocus = true; … … 14 17 span.appendChild(iframe); 15 18 wrapper.appendChild(textarea); 19 requestAnimationFrame(() => { 20 if (window.testRunner) 21 testRunner.notifyDone(); 22 }); 16 23 iframe.contentDocument.caretRangeFromPoint(); 17 24 -
trunk/LayoutTests/fast/history/page-cache-execute-script-during-restore.html
r268400 r283935 17 17 18 18 window.addEventListener("pageshow", (event) => { 19 if (event.persisted) 19 if (event.persisted) { 20 requestAnimationFrame(finish); 20 21 return; 22 } 21 23 if (window.testRunner) 22 24 setTimeout(runTest, 0); -
trunk/LayoutTests/imported/w3c/ChangeLog
r283916 r283935 1 2021-10-11 Tim Nguyen <ntim@apple.com> 2 3 Implement new autofocus behavior 4 https://bugs.webkit.org/show_bug.cgi?id=203139 5 <rdar://problem/56397019> 6 7 Reviewed by Wenson Hsieh. 8 9 Make WebKit match the new autofocus spec: 10 - https://html.spec.whatwg.org/multipage/interaction.html#the-autofocus-attribute 11 - https://html.spec.whatwg.org/multipage/interaction.html#focusing-steps 12 13 The new autofocus behavior queues up all autofocusable elements (visible or not), then 14 fires autofocus asynchronously during the "update rendering" steps, unlike the old behavior 15 which runs focus synchronously whenever it finds a visible autofocusable element. 16 17 Original patch by Ryosuke Niwa. 18 19 * web-platform-tests/html/interaction/focus/the-autofocus-attribute/document-with-fragment-empty-expected.txt: 20 * web-platform-tests/html/interaction/focus/the-autofocus-attribute/document-with-fragment-nonexistent-expected.txt: 21 * web-platform-tests/html/interaction/focus/the-autofocus-attribute/document-with-fragment-top-expected.txt: 22 * web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-expected.txt: 23 * web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-when-later-expected.txt: 24 * web-platform-tests/html/interaction/focus/the-autofocus-attribute/queue-non-focusable-expected.txt: 25 * web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering-expected.txt: 26 * web-platform-tests/selection/selection-select-all-move-input-crash-expected.txt: Expected change since input autofocus now places caret at start 27 1 28 2021-10-11 Ben Nham <nham@apple.com> 2 29 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/document-with-fragment-empty-expected.txt
r279427 r283935 1 1 2 2 3 FAIL Autofocus elements in iframed documents with empty fragments should work. assert_not_equals: got disallowed value Element node <input autofocus=""></input> 3 PASS Autofocus elements in iframed documents with empty fragments should work. 4 4 PASS Autofocus elements in top-level browsing context's documents with empty fragments should work. 5 5 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/document-with-fragment-nonexistent-expected.txt
r279427 r283935 1 1 2 2 3 FAIL Autofocus elements in iframed documents with non-existent fragments should work. assert_not_equals: got disallowed value Element node <input autofocus=""></input> 3 PASS Autofocus elements in iframed documents with non-existent fragments should work. 4 4 PASS Autofocus elements in top-level browsing context's documents with non-existent fragments should work. 5 5 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/document-with-fragment-top-expected.txt
r279427 r283935 1 1 2 2 3 FAIL Autofocus elements in iframed documents with "top" fragments should work. assert_not_equals: got disallowed value Element node <input autofocus=""></input> 3 PASS Autofocus elements in iframed documents with "top" fragments should work. 4 4 PASS Autofocus elements in top-level browsing context's documents with "top" fragments should work. 5 5 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-expected.txt
r267646 r283935 1 1 2 2 3 FAIL The first autofocus element in the document should win. assert_equals: expected Element node <input autofocus=""></input> but got Element node <input autofocus=""></input> 3 PASS The first autofocus element in the document should win. 4 4 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-when-later-expected.txt
r267646 r283935 1 1 2 2 3 FAIL The first autofocus in the document wins, even if elements are inserted later. assert_equals: expected Element node <input autofocus=""></input> but got Element node <input autofocus=""></input> 3 PASS The first autofocus in the document wins, even if elements are inserted later. 4 4 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/queue-non-focusable-expected.txt
r267646 r283935 1 1 2 2 3 FAIL If the first autofocus element is not focusable, but becomes focusable before a frame, it should be focused. assert_equals: expected Element node <textarea autofocus=""></textarea> but got Element node <select autofocus=""></select> 3 PASS If the first autofocus element is not focusable, but becomes focusable before a frame, it should be focused. 4 4 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering-expected.txt
r250823 r283935 1 1 2 PASS "Flush autofocus candidates" should be happen before a scroll event and animation frame callbacks 2 3 3 FAIL "Flush autofocus candidates" should be happen after the first animation frame callbacks, and before a resize event in the next iteration of window event loop. assert_array_equals: lengths differ, expected 3 got 44 -
trunk/LayoutTests/imported/w3c/web-platform-tests/selection/selection-select-all-move-input-crash-expected.txt
r266784 r283935 10 10 layer at (5,605) size 141x13 11 11 RenderBlock {DIV} at (3,3) size 141x13 12 caret: position 1 of body 12 caret: position 0 of child 0 {DIV} of {#document-fragment} of child 2 {INPUT} of child 0 {HTML} of document 13 scrolled to 0,23 -
trunk/LayoutTests/platform/ios-wk2/TestExpectations
r283918 r283935 2063 2063 webkit.org/b/227998 imported/w3c/web-platform-tests/html/semantics/embedded-content/the-embed-element/embed-network-error.sub.html [ Pass Failure ] 2064 2064 2065 webkit.org/b/227762 [ Debug ]imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/document-with-fragment-valid.html [ Pass Failure ]2065 webkit.org/b/227762 imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/document-with-fragment-valid.html [ Pass Failure ] 2066 2066 2067 2067 webkit.org/b/226789 imported/w3c/web-platform-tests/webstorage/event_case_sensitive.html [ Pass Failure ] -
trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering-expected.txt
r250823 r283935 1 1 2 FAIL "Flush autofocus candidates" should be happen before a scroll event and animation frame callbacks assert_array_equals: autofocus,animationFrame lengths differ, expected array ["autofocus", "scroll", "animationFrame"] length 3, got ["autofocus", "animationFrame"] length 2 2 3 3 FAIL "Flush autofocus candidates" should be happen after the first animation frame callbacks, and before a resize event in the next iteration of window event loop. assert_array_equals: property 0, expected "animationFrame" but got "autofocus"4 -
trunk/LayoutTests/platform/ios/imported/w3c/web-platform-tests/selection/selection-select-all-move-input-crash-expected.txt
r279795 r283935 10 10 layer at (9,605) size 141x14 11 11 RenderBlock {DIV} at (6,3) size 143x15 12 caret: position 1 of body12 caret: position 0 of child 0 {DIV} of {#document-fragment} of child 2 {INPUT} of child 0 {HTML} of document -
trunk/LayoutTests/platform/win/TestExpectations
r283799 r283935 4608 4608 fast/inline/crash-when-negative-spacing-produce-nan.html [ Timeout ] 4609 4609 imported/blink/fast/dom/Window/open-window-features-fuzz.html [ Timeout ] 4610 4610 fast/forms/form-submission-crash-3.html [ Timeout ] 4611 4611 4612 4612 webkit.org/b/227896 fast/text/pua-charactersTreatedAsSpace.html [ ImageOnlyFailure ] -
trunk/Source/WebCore/ChangeLog
r283930 r283935 1 2021-10-11 Tim Nguyen <ntim@apple.com> 2 3 Implement new autofocus behavior 4 https://bugs.webkit.org/show_bug.cgi?id=203139 5 <rdar://problem/56397019> 6 7 Reviewed by Wenson Hsieh. 8 9 Make WebKit match the new autofocus spec: 10 - https://html.spec.whatwg.org/multipage/interaction.html#the-autofocus-attribute 11 - https://html.spec.whatwg.org/multipage/interaction.html#focusing-steps 12 13 The new autofocus behavior queues up all autofocusable elements (visible or not), then 14 fires autofocus asynchronously during the "update rendering" steps, unlike the old behavior 15 which runs focus synchronously whenever it finds a visible autofocusable element. 16 17 Original patch by Ryosuke Niwa. 18 19 * dom/Document.cpp: 20 (WebCore::Document::appendAutofocusCandidate): 21 (WebCore::Document::flushAutofocusCandidates): 22 * dom/Document.h: 23 (WebCore::Document::isAutofocusProcessed const): 24 (WebCore::Document::setAutofocusProcessed): 25 * dom/Element.cpp: 26 (WebCore::Element::runFocusingStepsForAutofocus): 27 * dom/Element.h: 28 * html/HTMLFormControlElement.cpp: 29 (WebCore::shouldAutofocus): 30 (WebCore::HTMLFormControlElement::didAttachRenderers): 31 (WebCore::HTMLFormControlElement::insertedIntoAncestor): 32 (WebCore::HTMLFormControlElement::runFocusingStepsForAutofocus): 33 * html/HTMLFormControlElement.h: 34 (WebCore::HTMLFormControlElement::hasAutofocused const): Deleted. 35 (WebCore::HTMLFormControlElement::setAutofocused): Deleted. 36 * page/Page.cpp: 37 (WebCore::Page::updateRendering): 38 * page/Page.h: 39 1 40 2021-10-11 Alex Christensen <achristensen@webkit.org> 2 41 -
trunk/Source/WebCore/dom/Document.cpp
r283851 r283935 4471 4471 } 4472 4472 4473 void Document::appendAutofocusCandidate(Element& candidate) 4474 { 4475 ASSERT(isTopDocument()); 4476 ASSERT(!m_isAutofocusProcessed); 4477 auto it = m_autofocusCandidates.findIf([&candidate](auto& c) { 4478 return c == &candidate; 4479 }); 4480 if (it != m_autofocusCandidates.end()) 4481 m_autofocusCandidates.remove(it); 4482 m_autofocusCandidates.append(makeWeakPtr(candidate)); 4483 } 4484 4485 void Document::flushAutofocusCandidates() 4486 { 4487 ASSERT(isTopDocument()); 4488 if (m_isAutofocusProcessed) 4489 return; 4490 while (!m_autofocusCandidates.isEmpty()) { 4491 RefPtr element = m_autofocusCandidates.takeFirst().get(); 4492 if (!element || !element->document().isFullyActive() || &element->document().topDocument() != this) 4493 continue; 4494 if (auto* parser = scriptableDocumentParser(); parser && parser->hasScriptsWaitingForStylesheets()) 4495 break; 4496 // FIXME: Need to ignore if the inclusive ancestor documents has a target element. 4497 // FIXME: Use the result of getting the focusable area for element if element is not focusable. 4498 if (element->isFocusable()) { 4499 m_autofocusCandidates.clear(); 4500 setAutofocusProcessed(); 4501 element->runFocusingStepsForAutofocus(); 4502 return; 4503 } 4504 } 4505 } 4506 4473 4507 void Document::hoveredElementDidDetach(Element& element) 4474 4508 { -
trunk/Source/WebCore/dom/Document.h
r283526 r283935 789 789 void adjustFocusNavigationNodeOnNodeRemoval(Node&, NodeRemoval = NodeRemoval::Node); 790 790 791 bool isAutofocusProcessed() const { return m_isAutofocusProcessed; } 792 void setAutofocusProcessed() { m_isAutofocusProcessed = true; } 793 void appendAutofocusCandidate(Element&); 794 void flushAutofocusCandidates(); 795 791 796 void hoveredElementDidDetach(Element&); 792 797 void elementInActiveChainDidDetach(Element&); … … 1802 1807 1803 1808 RefPtr<Node> m_focusNavigationStartingNode; 1809 Deque<WeakPtr<Element>> m_autofocusCandidates; 1804 1810 RefPtr<Element> m_focusedElement; 1805 1811 RefPtr<Element> m_hoveredElement; … … 2113 2119 bool m_isSynthesized { false }; 2114 2120 bool m_isNonRenderedPlaceholder { false }; 2121 2122 bool m_isAutofocusProcessed { false }; 2115 2123 2116 2124 bool m_sawElementsInKnownNamespaces { false }; -
trunk/Source/WebCore/dom/Element.cpp
r283851 r283935 3177 3177 } 3178 3178 3179 void Element::runFocusingStepsForAutofocus() 3180 { 3181 focus(); 3182 } 3183 3179 3184 void Element::dispatchFocusInEvent(const AtomString& eventType, RefPtr<Element>&& oldFocusedElement) 3180 3185 { -
trunk/Source/WebCore/dom/Element.h
r283851 r283935 423 423 virtual void updateFocusAppearance(SelectionRestorationMode, SelectionRevealMode = SelectionRevealMode::Reveal); 424 424 virtual void blur(); 425 virtual void runFocusingStepsForAutofocus(); 425 426 426 427 WEBCORE_EXPORT String innerHTML() const; -
trunk/Source/WebCore/html/HTMLFormControlElement.cpp
r283851 r283935 73 73 , m_isValid(true) 74 74 , m_wasChangedSinceLastFormControlChangeEvent(false) 75 , m_hasAutofocused(false)76 75 { 77 76 setHasCustomStyleResolveCallbacks(); … … 204 203 static bool shouldAutofocus(const HTMLFormControlElement& element) 205 204 { 206 if (!element.renderer())207 return false;208 205 if (!element.hasAttributeWithoutSynchronization(autofocusAttr)) 209 206 return false; 210 207 211 208 auto& document = element.document(); 212 if (!element.isConnected() || !document. renderView())209 if (!element.isConnected() || !document.hasBrowsingContext()) 213 210 return false; 214 211 if (document.isSandboxed(SandboxAutomaticFeatures)) { … … 222 219 } 223 220 224 if ( element.hasAutofocused())221 if (document.topDocument().isAutofocusProcessed()) 225 222 return false; 226 223 227 // FIXME: Should this set of hasTagName checks be replaced by a 228 // virtual member function? 224 // FIXME: autofocus is a global attribute. 229 225 if (is<HTMLInputElement>(element)) 230 226 return !downcast<HTMLInputElement>(element).isInputTypeHidden(); … … 248 244 if (renderer()) 249 245 renderer()->updateFromElement(); 250 251 if (shouldAutofocus(*this)) {252 setAutofocused();253 254 RefPtr<HTMLFormControlElement> element = this;255 RefPtr frameView = document().view();256 if (frameView && frameView->layoutContext().isInLayout()) {257 frameView->queuePostLayoutCallback([element] {258 element->focus({ SelectionRestorationMode::PlaceCaretAtStart });259 });260 } else {261 Style::deprecatedQueuePostResolutionCallback([element] {262 element->focus({ SelectionRestorationMode::PlaceCaretAtStart });263 });264 }265 }266 246 } 267 247 … … 302 282 HTMLElement::insertedIntoAncestor(insertionType, parentOfInsertedTree); 303 283 FormAssociatedElement::insertedIntoAncestor(insertionType, parentOfInsertedTree); 284 285 if (shouldAutofocus(*this)) 286 document().topDocument().appendAutofocusCandidate(*this); 287 304 288 return InsertedIntoAncestorResult::NeedsPostInsertionCallback; 305 289 } … … 395 379 return false; 396 380 #endif 381 } 382 383 void HTMLFormControlElement::runFocusingStepsForAutofocus() 384 { 385 focus({ SelectionRestorationMode::PlaceCaretAtStart }); 397 386 } 398 387 -
trunk/Source/WebCore/html/HTMLFormControlElement.h
r283851 r283935 117 117 bool isDisabledOrReadOnly() const { return isDisabledFormControl() || m_isReadOnly; } 118 118 119 bool hasAutofocused() const { return m_hasAutofocused; }120 void setAutofocused() { m_hasAutofocused = true; }121 122 119 WEBCORE_EXPORT String autocomplete() const; 123 120 WEBCORE_EXPORT void setAutocomplete(const String&); … … 171 168 void derefFormAssociatedElement() override { deref(); } 172 169 170 void runFocusingStepsForAutofocus() final; 171 173 172 bool matchesValidPseudoClass() const override; 174 173 bool matchesInvalidPseudoClass() const override; … … 216 215 217 216 unsigned m_wasChangedSinceLastFormControlChangeEvent : 1; 218 219 unsigned m_hasAutofocused : 1;220 217 }; 221 218 -
trunk/Source/WebCore/page/Page.cpp
r283522 r283935 1561 1561 }; 1562 1562 1563 // FIXME: Flush autofocus candidates. 1563 runProcessingStep(RenderingUpdateStep::FlushAutofocusCandidates, [] (Document& document) { 1564 if (document.isTopDocument()) 1565 document.flushAutofocusCandidates(); 1566 }); 1564 1567 1565 1568 runProcessingStep(RenderingUpdateStep::Resize, [] (Document& document) { … … 3606 3609 { 3607 3610 switch (step) { 3611 case RenderingUpdateStep::FlushAutofocusCandidates: ts << "FlushAutofocusCandidates"; break; 3608 3612 case RenderingUpdateStep::Resize: ts << "Resize"; break; 3609 3613 case RenderingUpdateStep::Scroll: ts << "Scroll"; break; -
trunk/Source/WebCore/page/Page.h
r283522 r283935 209 209 ScrollingTreeUpdate = 1 << 13, 210 210 #endif 211 FlushAutofocusCandidates = 1 << 14, 211 212 }; 212 213 213 214 constexpr OptionSet<RenderingUpdateStep> updateRenderingSteps = { 215 RenderingUpdateStep::FlushAutofocusCandidates, 214 216 RenderingUpdateStep::Resize, 215 217 RenderingUpdateStep::Scroll,
Note:
See TracChangeset
for help on using the changeset viewer.