Diff
Modified: trunk/LayoutTests/ChangeLog (265508 => 265509)
--- trunk/LayoutTests/ChangeLog 2020-08-11 18:14:26 UTC (rev 265508)
+++ trunk/LayoutTests/ChangeLog 2020-08-11 19:45:57 UTC (rev 265509)
@@ -1,3 +1,34 @@
+2020-08-11 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Text input autocorrect="off" attribute ignored on Mac
+ https://bugs.webkit.org/show_bug.cgi?id=151019
+ <rdar://problem/65061700>
+
+ Reviewed by Simon Fraser.
+
+ Move the existing test `fast/events/ios/contenteditable-autocorrect.html` into `editing/input/cocoa`, and
+ refactor it so that it:
+ - Works on both iOS and macOS.
+ - Tests both the `contenteditable` case and the form control case.
+ - Is split into two tests: one of which uses autocorrect="off" by typing "Tset" and expecting it to remain
+ as-is, and a second test that uses autocorrect="on" and verifies that "Tset" is autocorrected to "Test",
+ firing an input event with `inputType` `"insertReplacementText"` in the process.
+
+ * TestExpectations:
+ * editing/input/cocoa/autocorrect-off-expected.txt: Added.
+ * editing/input/cocoa/autocorrect-off.html: Added.
+ * editing/input/cocoa/autocorrect-on-expected.txt: Added.
+ * editing/input/cocoa/autocorrect-on.html: Added.
+ * fast/events/ios/contenteditable-autocorrect-expected.txt: Removed.
+ * fast/events/ios/contenteditable-autocorrect.html: Removed.
+ * js/dom/dom-static-property-for-in-iteration-expected.txt:
+
+ Rebaseline a couple of existing layout tests, as well.
+
+ * platform/ios/TestExpectations:
+ * platform/mac-wk2/js/dom/dom-static-property-for-in-iteration-expected.txt:
+ * platform/mac/TestExpectations:
+
2020-08-11 Kenneth Russell <k...@chromium.org>
[WebGL2] expando-loss and expando-loss-2 conformance tests are failing
Modified: trunk/LayoutTests/TestExpectations (265508 => 265509)
--- trunk/LayoutTests/TestExpectations 2020-08-11 18:14:26 UTC (rev 265508)
+++ trunk/LayoutTests/TestExpectations 2020-08-11 19:45:57 UTC (rev 265509)
@@ -20,6 +20,7 @@
editing/caret/ios [ Skip ]
editing/editable-region [ Skip ]
editing/execCommand/ios [ Skip ]
+editing/input/cocoa [ Skip ]
editing/input/ios [ Skip ]
editing/find [ Skip ]
editing/pasteboard/gtk [ Skip ]
Added: trunk/LayoutTests/editing/input/cocoa/autocorrect-off-expected.txt (0 => 265509)
--- trunk/LayoutTests/editing/input/cocoa/autocorrect-off-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/input/cocoa/autocorrect-off-expected.txt 2020-08-11 19:45:57 UTC (rev 265509)
@@ -0,0 +1,10 @@
+ This test verifies that autocorrect=off disables autocorrection. To manually test, type 'Tset' into both editable areas and a period, and verify that it is not autocorrected.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS contenteditable.textContent is "Tset."
+PASS textarea.value is "Tset."
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/editing/input/cocoa/autocorrect-off.html (0 => 265509)
--- trunk/LayoutTests/editing/input/cocoa/autocorrect-off.html (rev 0)
+++ trunk/LayoutTests/editing/input/cocoa/autocorrect-off.html 2020-08-11 19:45:57 UTC (rev 265509)
@@ -0,0 +1,77 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<html>
+<head>
+ <meta name="viewport" content="initial-scale=1.0, width=device-width, user-scalable=no">
+ <script src=""
+ <script src=""
+ <style>
+ div[contenteditable], textarea {
+ width: 200px;
+ height: 100px;
+ font-size: 24px;
+ border: 1px solid tomato;
+ margin: 10px;
+ }
+ </style>
+</head>
+<body>
+ <div contenteditable autocorrect="off"></div>
+ <textarea autocorrect="off"></textarea>
+ <pre id="description"></pre>
+ <pre id="console"></pre>
+ <script>
+ const stringToType = "Tset.";
+ window.jsTestIsAsync = true;
+ description("This test verifies that autocorrect=off disables autocorrection. To manually test, type 'Tset' into both editable areas and a period, and verify that it is not autocorrected.");
+
+ async function runTestForElement(element, stringToType)
+ {
+ if (window.testRunner)
+ await UIHelper.activateElementAndWaitForInputSession(element);
+
+ for (let character of [...stringToType]) {
+ await UIHelper.callFunctionAndWaitForEvent(() => {
+ return window.testRunner ? UIHelper.typeCharacter(character) : Promise.resolve();
+ }, element, "input");
+ }
+
+ element.blur();
+
+ if (window.testRunner)
+ await UIHelper.waitForKeyboardToHide();
+ }
+
+ addEventListener("load", async () => {
+ if (window.testRunner) {
+ await UIHelper.setContinuousSpellCheckingEnabled(true);
+ await UIHelper.setSpellCheckerResults({
+ "Tset.": [
+ {
+ "replacement": "Test",
+ "type": "correction",
+ "from": 0,
+ "to": 4
+ }
+ ]
+ });
+
+ internals.setAutomaticTextReplacementEnabled(true);
+ internals.setAutomaticSpellingCorrectionEnabled(true);
+ }
+
+ contenteditable = document.querySelector("div[contenteditable]");
+ textarea = document.querySelector("textarea");
+
+ await runTestForElement(contenteditable, stringToType);
+ shouldBeEqualToString("contenteditable.textContent", stringToType);
+
+ await runTestForElement(textarea, stringToType);
+ shouldBeEqualToString("textarea.value", stringToType);
+
+ contenteditable.remove();
+ textarea.remove();
+ finishJSTest();
+ });
+ </script>
+</body>
+</html>
\ No newline at end of file
Added: trunk/LayoutTests/editing/input/cocoa/autocorrect-on-expected.txt (0 => 265509)
--- trunk/LayoutTests/editing/input/cocoa/autocorrect-on-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/input/cocoa/autocorrect-on-expected.txt 2020-08-11 19:45:57 UTC (rev 265509)
@@ -0,0 +1,22 @@
+ This test verifies that autocorrection=on enables autocorrection. To manually test, type 'Tset' into both editable areas and a period, and verify that it is not autocorrected.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS insertedText became true
+PASS insertedText became true
+PASS insertedText became true
+PASS insertedText became true
+PASS insertedText became true
+PASS insertedReplacementText became true
+PASS contenteditable.textContent is "Test."
+PASS insertedText became true
+PASS insertedText became true
+PASS insertedText became true
+PASS insertedText became true
+PASS insertedText became true
+PASS insertedReplacementText became true
+PASS textarea.value is "Test."
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/editing/input/cocoa/autocorrect-on.html (0 => 265509)
--- trunk/LayoutTests/editing/input/cocoa/autocorrect-on.html (rev 0)
+++ trunk/LayoutTests/editing/input/cocoa/autocorrect-on.html 2020-08-11 19:45:57 UTC (rev 265509)
@@ -0,0 +1,94 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<html>
+<head>
+ <meta name="viewport" content="initial-scale=1.0, width=device-width, user-scalable=no">
+ <script src=""
+ <script src=""
+ <style>
+ div[contenteditable], textarea {
+ width: 200px;
+ height: 100px;
+ font-size: 24px;
+ border: 1px solid tomato;
+ margin: 10px;
+ }
+ </style>
+</head>
+<body>
+ <div contenteditable autocorrect="on"></div>
+ <textarea autocorrect="on"></textarea>
+ <pre id="description"></pre>
+ <pre id="console"></pre>
+ <script>
+ const stringToType = "Tset.";
+ const autocorrectedString = "Test.";
+ window.jsTestIsAsync = true;
+ window.insertedText = false;
+ window.insertedReplacementText = false;
+ description("This test verifies that autocorrection=on enables autocorrection. To manually test, type 'Tset' into both editable areas and a period, and verify that it is not autocorrected.");
+
+ function handleInput(event) {
+ if (event.inputType === "insertText")
+ window.insertedText = true;
+ else if (event.inputType === "insertReplacementText")
+ window.insertedReplacementText = true;
+ }
+
+ async function runTestForElement(element, stringToType)
+ {
+ if (window.testRunner)
+ await UIHelper.activateElementAndWaitForInputSession(element);
+
+ window.insertedReplacementText = false;
+
+ for (let character of [...stringToType]) {
+ window.insertedText = false;
+ if (window.testRunner)
+ await UIHelper.typeCharacter(character);
+ await new Promise(resolve => shouldBecomeEqual("insertedText", "true", resolve));
+ }
+
+ await new Promise(resolve => shouldBecomeEqual("insertedReplacementText", "true", resolve));
+
+ element.blur();
+
+ if (window.testRunner)
+ await UIHelper.waitForKeyboardToHide();
+ }
+
+ addEventListener("load", async () => {
+ if (window.testRunner) {
+ await UIHelper.setContinuousSpellCheckingEnabled(true);
+ await UIHelper.setSpellCheckerResults({
+ "Tset.": [
+ {
+ "replacement": "Test",
+ "type": "correction",
+ "from": 0,
+ "to": 4
+ }
+ ]
+ });
+
+ internals.setAutomaticTextReplacementEnabled(true);
+ internals.setAutomaticSpellingCorrectionEnabled(true);
+ }
+
+ contenteditable = document.querySelector("div[contenteditable]");
+ contenteditable.addEventListener("input", handleInput);
+ textarea = document.querySelector("textarea");
+ textarea.addEventListener("input", handleInput);
+
+ await runTestForElement(contenteditable, stringToType);
+ shouldBeEqualToString("contenteditable.textContent", autocorrectedString);
+
+ await runTestForElement(textarea, stringToType);
+ shouldBeEqualToString("textarea.value", autocorrectedString);
+
+ contenteditable.remove();
+ textarea.remove();
+ finishJSTest();
+ });
+ </script>
+</body>
+</html>
\ No newline at end of file
Deleted: trunk/LayoutTests/fast/events/ios/contenteditable-autocorrect-expected.txt (265508 => 265509)
--- trunk/LayoutTests/fast/events/ios/contenteditable-autocorrect-expected.txt 2020-08-11 18:14:26 UTC (rev 265508)
+++ trunk/LayoutTests/fast/events/ios/contenteditable-autocorrect-expected.txt 2020-08-11 19:45:57 UTC (rev 265509)
@@ -1,5 +0,0 @@
-To manually test, type 'Ti' into the contenteditable and a space. The 'Ti' should not be autocorrected.
-
-With autocorrect off, the result is: "Ti"
-With autocorrect on, the result is: "To"
-
Deleted: trunk/LayoutTests/fast/events/ios/contenteditable-autocorrect.html (265508 => 265509)
--- trunk/LayoutTests/fast/events/ios/contenteditable-autocorrect.html 2020-08-11 18:14:26 UTC (rev 265508)
+++ trunk/LayoutTests/fast/events/ios/contenteditable-autocorrect.html 2020-08-11 19:45:57 UTC (rev 265509)
@@ -1,77 +0,0 @@
-<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
-
-<html>
-
-<head>
- <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
- <script>
- let write = message => output.innerHTML += message + "<br>";
- if (window.testRunner) {
- testRunner.dumpAsText();
- testRunner.waitUntilDone();
- }
-
- let remainingInputEventCount = 0;
- let resolveExpectedInputEvents = null;
- function handleInput() {
- remainingInputEventCount--;
- if (resolveExpectedInputEvents && !remainingInputEventCount)
- resolveExpectedInputEvents();
- }
-
- function runUIScriptAndExpectInputEvents(inputEventCount, nextAutocorrectValue)
- {
- remainingInputEventCount = inputEventCount;
- resolveExpectedInputEvents = () => {
- write(`With autocorrect ${editable.autocorrect ? "on" : "off"}, the result is: "${editable.textContent.trim()}"`);
- editable.textContent = "";
- editable.autocorrect = nextAutocorrectValue;
- editable.blur();
- };
-
- return new Promise(function(resolve) {
- let rect = editable.getBoundingClientRect();
- testRunner.runUIScript(`(function() {
- uiController.didShowKeyboardCallback = function() {
- uiController.typeCharacterUsingHardwareKeyboard("t", function() {
- uiController.typeCharacterUsingHardwareKeyboard("i", function() {
- uiController.typeCharacterUsingHardwareKeyboard(" ", function() { });
- });
- });
- }
- uiController.didHideKeyboardCallback = function() {
- uiController.uiScriptComplete();
- }
- uiController.singleTapAtPoint(${rect.left + rect.width / 2}, ${rect.top + rect.height / 2}, function() {});
- })();`, resolve);
- });
- }
-
- function runTest()
- {
- if (!window.testRunner || !testRunner.runUIScript)
- return;
-
- runUIScriptAndExpectInputEvents(3, "on")
- .then(() => runUIScriptAndExpectInputEvents(4, null))
- .then(() => testRunner.notifyDone());
- }
- </script>
- <style>
- #editable {
- width: 200px;
- height: 100px;
- top: 0;
- left: 0;
- position: absolute;
- }
- </style>
-</head>
-
-<body _onload_=runTest()>
- <div style="font-size: 24px;" contenteditable autocorrect="off" id="editable" _oninput_=handleInput()></div>
- <p>To manually test, type 'Ti' into the contenteditable and a space. The 'Ti' should not be autocorrected.</p>
- <code><div id="output"></div></code>
-</body>
-
-</html>
Modified: trunk/LayoutTests/js/dom/dom-static-property-for-in-iteration-expected.txt (265508 => 265509)
--- trunk/LayoutTests/js/dom/dom-static-property-for-in-iteration-expected.txt 2020-08-11 18:14:26 UTC (rev 265508)
+++ trunk/LayoutTests/js/dom/dom-static-property-for-in-iteration-expected.txt 2020-08-11 19:45:57 UTC (rev 265509)
@@ -50,6 +50,7 @@
PASS a["offsetWidth"] is 40
PASS a["offsetHeight"] is 18
PASS a["outerText"] is nerget
+PASS a["autocorrect"] is true
PASS a["webkitdropzone"] is
PASS a["inputMode"] is
PASS a["style"] is [object CSSStyleDeclaration]
Modified: trunk/LayoutTests/platform/ios/TestExpectations (265508 => 265509)
--- trunk/LayoutTests/platform/ios/TestExpectations 2020-08-11 18:14:26 UTC (rev 265508)
+++ trunk/LayoutTests/platform/ios/TestExpectations 2020-08-11 19:45:57 UTC (rev 265509)
@@ -11,6 +11,7 @@
editing/editable-region [ Pass ]
editing/execCommand/ios [ Pass ]
editing/deleting/ios [ Pass ]
+editing/input/cocoa [ Pass ]
http/tests/quicklook [ Pass ]
media/ios [ Pass ]
quicklook [ Pass ]
Modified: trunk/LayoutTests/platform/mac/TestExpectations (265508 => 265509)
--- trunk/LayoutTests/platform/mac/TestExpectations 2020-08-11 18:14:26 UTC (rev 265508)
+++ trunk/LayoutTests/platform/mac/TestExpectations 2020-08-11 19:45:57 UTC (rev 265509)
@@ -9,6 +9,7 @@
accessibility/mac [ Pass ]
compositing/scrolling/async-overflow-scrolling/mac [ Pass ]
displaylists [ Pass ]
+editing/input/cocoa [ Pass ]
editing/mac [ Pass ]
editing/pasteboard/mac [ Pass ]
fast/dom/Range/mac [ Pass ]
Modified: trunk/LayoutTests/platform/mac-wk2/js/dom/dom-static-property-for-in-iteration-expected.txt (265508 => 265509)
--- trunk/LayoutTests/platform/mac-wk2/js/dom/dom-static-property-for-in-iteration-expected.txt 2020-08-11 18:14:26 UTC (rev 265508)
+++ trunk/LayoutTests/platform/mac-wk2/js/dom/dom-static-property-for-in-iteration-expected.txt 2020-08-11 19:45:57 UTC (rev 265509)
@@ -52,6 +52,7 @@
PASS a["offsetWidth"] is 40
PASS a["offsetHeight"] is 18
PASS a["outerText"] is nerget
+PASS a["autocorrect"] is true
PASS a["webkitdropzone"] is
PASS a["inputMode"] is
PASS a["enterKeyHint"] is
Modified: trunk/Source/WTF/ChangeLog (265508 => 265509)
--- trunk/Source/WTF/ChangeLog 2020-08-11 18:14:26 UTC (rev 265508)
+++ trunk/Source/WTF/ChangeLog 2020-08-11 19:45:57 UTC (rev 265509)
@@ -1,3 +1,13 @@
+2020-08-11 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Text input autocorrect="off" attribute ignored on Mac
+ https://bugs.webkit.org/show_bug.cgi?id=151019
+ <rdar://problem/65061700>
+
+ Reviewed by Simon Fraser.
+
+ * wtf/PlatformEnableCocoa.h: Turn the feature on for macOS.
+
2020-08-10 Myles C. Maxfield <mmaxfi...@apple.com>
[Cocoa] Migrate from CTFontTransformGlyphsWithLanguage() to CTFontShapeGlyphs()
Modified: trunk/Source/WTF/wtf/PlatformEnableCocoa.h (265508 => 265509)
--- trunk/Source/WTF/wtf/PlatformEnableCocoa.h 2020-08-11 18:14:26 UTC (rev 265508)
+++ trunk/Source/WTF/wtf/PlatformEnableCocoa.h 2020-08-11 19:45:57 UTC (rev 265509)
@@ -87,7 +87,7 @@
#define ENABLE_AUTOCAPITALIZE 1
#endif
-#if !defined(ENABLE_AUTOCORRECT) && !PLATFORM(MAC)
+#if !defined(ENABLE_AUTOCORRECT)
#define ENABLE_AUTOCORRECT 1
#endif
Modified: trunk/Source/WebCore/ChangeLog (265508 => 265509)
--- trunk/Source/WebCore/ChangeLog 2020-08-11 18:14:26 UTC (rev 265508)
+++ trunk/Source/WebCore/ChangeLog 2020-08-11 19:45:57 UTC (rev 265509)
@@ -1,3 +1,20 @@
+2020-08-11 Wenson Hsieh <wenson_hs...@apple.com>
+
+ Text input autocorrect="off" attribute ignored on Mac
+ https://bugs.webkit.org/show_bug.cgi?id=151019
+ <rdar://problem/65061700>
+
+ Reviewed by Simon Fraser.
+
+ Add support for the `autocorrect` attribute on macOS, by not showing the automatic spell checking popup or
+ automatically correcting misspelled words if the root editable element has `autocorrect="off"`.
+
+ Tests: editing/input/cocoa/autocorrect-off.html
+ editing/input/cocoa/autocorrect-on.html
+
+ * editing/AlternativeTextController.cpp:
+ (WebCore::AlternativeTextController::isAutomaticSpellingCorrectionEnabled):
+
2020-08-11 Sihui Liu <sihui_...@apple.com>
Text manipulation crashes when replacing element with img role
Modified: trunk/Source/WebCore/editing/AlternativeTextController.cpp (265508 => 265509)
--- trunk/Source/WebCore/editing/AlternativeTextController.cpp 2020-08-11 18:14:26 UTC (rev 265508)
+++ trunk/Source/WebCore/editing/AlternativeTextController.cpp 2020-08-11 19:45:57 UTC (rev 265509)
@@ -337,7 +337,23 @@
bool AlternativeTextController::isAutomaticSpellingCorrectionEnabled()
{
- return editorClient() && editorClient()->isAutomaticSpellingCorrectionEnabled();
+ if (!editorClient() || !editorClient()->isAutomaticSpellingCorrectionEnabled())
+ return false;
+
+#if ENABLE(AUTOCORRECT)
+ auto position = m_document.selection().selection().start();
+ if (auto editableRoot = position.rootEditableElement()) {
+ if (is<HTMLElement>(editableRoot) && !downcast<HTMLElement>(*editableRoot).shouldAutocorrect())
+ return false;
+ }
+
+ if (auto control = enclosingTextFormControl(position)) {
+ if (!control->shouldAutocorrect())
+ return false;
+ }
+#endif
+
+ return true;
}
FloatRect AlternativeTextController::rootViewRectForRange(const SimpleRange& range) const