Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Implement new autofocus behavior
https://bugs.webkit.org/show_bug.cgi?id=203139 <rdar://problem/56397019> Reviewed by Wenson Hsieh. Make WebKit match the new autofocus spec: - https://html.spec.whatwg.org/multipage/interaction.html#the-autofocus-attribute - https://html.spec.whatwg.org/multipage/interaction.html#focusing-steps The new autofocus behavior queues up all autofocusable elements (visible or not), then fires autofocus asynchronously during the "update rendering" steps, unlike the old behavior which runs focus synchronously whenever it finds a visible autofocusable element. Original patch by Ryosuke Niwa. LayoutTests/imported/w3c: * web-platform-tests/html/interaction/focus/the-autofocus-attribute/document-with-fragment-empty-expected.txt: * web-platform-tests/html/interaction/focus/the-autofocus-attribute/document-with-fragment-nonexistent-expected.txt: * web-platform-tests/html/interaction/focus/the-autofocus-attribute/document-with-fragment-top-expected.txt: * web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-expected.txt: * web-platform-tests/html/interaction/focus/the-autofocus-attribute/first-when-later-expected.txt: * web-platform-tests/html/interaction/focus/the-autofocus-attribute/queue-non-focusable-expected.txt: * web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering-expected.txt: * web-platform-tests/selection/selection-select-all-move-input-crash-expected.txt: Expected change since input autofocus now places caret at start Source/WebCore: * dom/Document.cpp: (WebCore::Document::appendAutofocusCandidate): (WebCore::Document::flushAutofocusCandidates): * dom/Document.h: (WebCore::Document::isAutofocusProcessed const): (WebCore::Document::setAutofocusProcessed): * dom/Element.cpp: (WebCore::Element::runFocusingStepsForAutofocus): * dom/Element.h: * html/HTMLFormControlElement.cpp: (WebCore::shouldAutofocus): (WebCore::HTMLFormControlElement::didAttachRenderers): (WebCore::HTMLFormControlElement::insertedIntoAncestor): (WebCore::HTMLFormControlElement::runFocusingStepsForAutofocus): * html/HTMLFormControlElement.h: (WebCore::HTMLFormControlElement::hasAutofocused const): Deleted. (WebCore::HTMLFormControlElement::setAutofocused): Deleted. * page/Page.cpp: (WebCore::Page::updateRendering): * page/Page.h: LayoutTests: * TestExpectations: * fast/dom/Window/window-scroll-ignore-null-frame.html: * fast/dom/adopt-node-crash-2-expected.txt: * fast/dom/adopt-node-crash-2.html: * fast/dom/window-inner-width-crash.html: * fast/forms/autofocus-in-sandbox-with-allow-scripts-expected.txt: * fast/forms/autofocus-in-sandbox-with-allow-scripts.html: * fast/forms/autofocus-keygen.html: * fast/forms/autofocus-opera-001.html: * fast/forms/autofocus-opera-002.html: * fast/forms/autofocus-opera-003.html: * fast/forms/autofocus-opera-006.html: * fast/forms/autofocus-opera-007.html: * fast/forms/change-input-type-in-focus-handler.html: * fast/frames/crash-when-iframe-is-remove-in-eventhandler.html: * fast/history/page-cache-execute-script-during-restore.html: * platform/ios-wk2/TestExpectations: * platform/ios-wk2/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering-expected.txt: * platform/ios/imported/w3c/web-platform-tests/selection/selection-select-all-move-input-crash-expected.txt: * platform/mac-wk1/imported/w3c/web-platform-tests/html/interaction/focus/the-autofocus-attribute/update-the-rendering-expected.txt: * platform/win/TestExpectations: Canonical link: https://commits.webkit.org/242794@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@283935 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
40 changed files
with
330 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @@ -1,2 +1,4 @@ | ||
| Tests for a crash due to adopting a DOM node during DOMFocusOut event. Test passes if it doesn't crash. | ||
| Tests for a crash due to adopting a DOM node when unfocusing. Test passes if it doesn't crash. | ||
|
|
||
| PASS: Focused node should be keygen | ||
| PASS: Focused node should no longer be keygen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @@ -6,8 +6,8 @@ | ||
| testRunner.dumpAsText(); | ||
|
|
||
| function runTest() { | ||
| button.autofocus = true; | ||
| body.appendChild(paragraph); | ||
| button.focus(); | ||
| var testVal = window[0].innerWidth; | ||
| } | ||
|
|
||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @@ -1,2 +1,7 @@ | ||
| CONSOLE MESSAGE: INPUT | ||
| 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). | ||
| This tests having an input element with autofocus content attribute inside a sandboxed iframe. | ||
| The input element should be autofocused since scripts are allowed. | ||
|
|
||
| -------- | ||
| Frame: '<!--frame1-->' | ||
| -------- | ||
| PASS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @@ -1,8 +1,19 @@ | ||
| <script> | ||
| if (window.testRunner) | ||
| if (window.testRunner) { | ||
| testRunner.dumpAsText(); | ||
| testRunner.dumpChildFramesAsText(); | ||
| } | ||
| </script> | ||
| 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). | ||
| <iframe sandbox="allow-scripts allow-modals" | ||
| src="data:text/html,<input autofocus onfocus><script>window.onload = function() { console.log(document.activeElement.tagName) }</script>"></iframe> | ||
| This tests having an input element with autofocus content attribute inside a sandboxed iframe.<br> | ||
| The input element should be autofocused since scripts are allowed. | ||
| <iframe sandbox="allow-scripts" | ||
| src="data:text/html,<input id=input autofocus onfocus><script> | ||
| if (window.testRunner) | ||
| testRunner.waitUntilDone(); | ||
| window.onload = function () { | ||
| requestAnimationFrame(() => { | ||
| document.body.append(document.activeElement == input ? 'PASS' : 'FAIL'); | ||
| if (window.testRunner) | ||
| testRunner.notifyDone(); | ||
| }); | ||
| }</script>"></iframe> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.