Title: [295468] trunk
Revision
295468
Author
[email protected]
Date
2022-06-10 16:26:43 -0700 (Fri, 10 Jun 2022)

Log Message

[iOS] Specifying spellcheck="false" on a contentEditable element should suppress platform spellchecking
https://bugs.webkit.org/show_bug.cgi?id=241514
rdar://91123300

Reviewed by Devin Rousso.

Additionally set `-[UITextInputTraits spellCheckingType]` to `UITextSpellCheckingTypeNo` when
focusing editable fields with the DOM attribute `spellcheck="false"`. This provides a hint to UIKit
that system spellchecking should be disabled when editing this field - among other things, this
allows us to avoid showing text candidates in the case where `autocorrect="off"` is additionally
specified.

If either `spellcheck="true"` is set or `spellcheck` is not specified, we fall back to the user's
preference by using `UITextSpellCheckingTypeDefault`.

Test: KeyboardInputTests.DisableSpellChecking

* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _updateTextInputTraits:]):
* Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm:
(TestWebKitAPI::TEST):

Canonical link: https://commits.webkit.org/251473@main

Modified Paths

Diff

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (295467 => 295468)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2022-06-10 23:10:44 UTC (rev 295467)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2022-06-10 23:26:43 UTC (rev 295468)
@@ -5897,6 +5897,7 @@
             traits.smartQuotesType = UITextSmartQuotesTypeNo;
         if ([traits respondsToSelector:@selector(setSmartDashesType:)])
             traits.smartDashesType = UITextSmartDashesTypeNo;
+        traits.spellCheckingType = UITextSpellCheckingTypeNo;
     }
 
     switch (_focusedElementInformation.inputMode) {

Modified: trunk/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm (295467 => 295468)


--- trunk/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm	2022-06-10 23:10:44 UTC (rev 295467)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm	2022-06-10 23:26:43 UTC (rev 295468)
@@ -624,7 +624,7 @@
     EXPECT_EQ(inputView.get(), [contentView inputView]);
 }
 
-TEST(KeyboardInputTests, DisableSmartQuotesAndDashes)
+TEST(KeyboardInputTests, DisableSpellChecking)
 {
     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
     auto inputDelegate = adoptNS([[TestInputDelegate alloc] init]);
@@ -633,27 +633,28 @@
     }];
     [webView _setInputDelegate:inputDelegate.get()];
 
-    auto checkSmartQuotesAndDashesType = [&] (UITextSmartDashesType dashesType, UITextSmartQuotesType quotesType) {
+    auto checkSmartQuotesAndDashesType = [&] (UITextSmartDashesType dashesType, UITextSmartQuotesType quotesType, UITextSpellCheckingType spellCheckingType) {
         UITextInputTraits *traits = [[webView textInputContentView] textInputTraits];
         EXPECT_EQ(dashesType, traits.smartDashesType);
         EXPECT_EQ(quotesType, traits.smartQuotesType);
+        EXPECT_EQ(spellCheckingType, traits.spellCheckingType);
     };
 
     [webView synchronouslyLoadHTMLString:@"<div id='foo' contenteditable spellcheck='false'></div><textarea id='bar' spellcheck='false'></textarea><input id='baz' spellcheck='false'>"];
     [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"foo.focus()"];
-    checkSmartQuotesAndDashesType(UITextSmartDashesTypeNo, UITextSmartQuotesTypeNo);
+    checkSmartQuotesAndDashesType(UITextSmartDashesTypeNo, UITextSmartQuotesTypeNo, UITextSpellCheckingTypeNo);
     [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"bar.focus()"];
-    checkSmartQuotesAndDashesType(UITextSmartDashesTypeNo, UITextSmartQuotesTypeNo);
+    checkSmartQuotesAndDashesType(UITextSmartDashesTypeNo, UITextSmartQuotesTypeNo, UITextSpellCheckingTypeNo);
     [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"baz.focus()"];
-    checkSmartQuotesAndDashesType(UITextSmartDashesTypeNo, UITextSmartQuotesTypeNo);
+    checkSmartQuotesAndDashesType(UITextSmartDashesTypeNo, UITextSmartQuotesTypeNo, UITextSpellCheckingTypeNo);
 
     [webView synchronouslyLoadHTMLString:@"<div id='foo' contenteditable></div><textarea id='bar' spellcheck='true'></textarea><input id='baz'>"];
     [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"foo.focus()"];
-    checkSmartQuotesAndDashesType(UITextSmartDashesTypeDefault, UITextSmartQuotesTypeDefault);
+    checkSmartQuotesAndDashesType(UITextSmartDashesTypeDefault, UITextSmartQuotesTypeDefault, UITextSpellCheckingTypeDefault);
     [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"bar.focus()"];
-    checkSmartQuotesAndDashesType(UITextSmartDashesTypeDefault, UITextSmartQuotesTypeDefault);
+    checkSmartQuotesAndDashesType(UITextSmartDashesTypeDefault, UITextSmartQuotesTypeDefault, UITextSpellCheckingTypeDefault);
     [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"baz.focus()"];
-    checkSmartQuotesAndDashesType(UITextSmartDashesTypeDefault, UITextSmartQuotesTypeDefault);
+    checkSmartQuotesAndDashesType(UITextSmartDashesTypeDefault, UITextSmartQuotesTypeDefault, UITextSpellCheckingTypeDefault);
 }
 
 TEST(KeyboardInputTests, SelectionClipRectsWhenPresentingInputView)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to