Title: [252377] trunk
Revision
252377
Author
[email protected]
Date
2019-11-12 16:07:00 -0800 (Tue, 12 Nov 2019)

Log Message

[iOS] WKWebView does not respect system spellchecking preference
https://bugs.webkit.org/show_bug.cgi?id=204100
<rdar://problem/56653808>

Reviewed by Tim Horton.

Source/WebKit:

Implements a platform hook on iOS (-setContinuousSpellCheckingEnabled:) to allow UIKit to inform us when the
system spellchecking preference changes, and adds logic to propagate these changes to the web process. See below
for more details.

Test: editing/spelling/toggle-spellchecking.html

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _setContinuousSpellCheckingEnabledForTesting:]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:

Add testing SPI to enable or disable continuous spellchecking, for both iOS and macOS.

* UIProcess/Cocoa/WebViewImpl.h:
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::setContinuousSpellCheckingEnabled):
* UIProcess/TextChecker.h:
* UIProcess/gtk/TextCheckerGtk.cpp:
(WebKit::TextChecker::setContinuousSpellCheckingEnabled):
* UIProcess/ios/TextCheckerIOS.mm:
(WebKit::TextChecker::setContinuousSpellCheckingEnabled):
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView setupInteraction]):
(-[WKContentView setContinuousSpellCheckingEnabled:]):

Implement this method to handle changes to the system spellchecking preference. This hook is also used by legacy
WebKit on iOS to turn spellchecking on or off. If the value of the preference changed, we additionally notify
the web process. In the future, we should consider refactoring TextCheckerState to be per-web view and per-page,
since Cocoa platform APIs would allow for different WKWebViews to have different spell checking preferences.

* UIProcess/mac/TextCheckerMac.mm:
(WebKit::TextChecker::setContinuousSpellCheckingEnabled):
* UIProcess/win/TextCheckerWin.cpp:
(WebKit::TextChecker::setContinuousSpellCheckingEnabled):
* UIProcess/wpe/TextCheckerWPE.cpp:
(WebKit::TextChecker::setContinuousSpellCheckingEnabled):

Adjusted setContinuousSpellCheckingEnabled to return whether or not the continuous spellchecking state changed.

Tools:

* DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
* DumpRenderTree/cocoa/UIScriptControllerCocoa.h:
* DumpRenderTree/cocoa/UIScriptControllerCocoa.mm:
(WTR::UIScriptControllerCocoa::UIScriptControllerCocoa):
(WTR::UIScriptControllerCocoa::setContinuousSpellCheckingEnabled):

Add a new UIScriptControllerCocoa subclass for DumpRenderTree. For now, this will just contain the cross-
platform implementation of setContinuousSpellCheckingEnabled.

* DumpRenderTree/ios/UIScriptControllerIOS.h:
(WTR::UIScriptControllerIOS::UIScriptControllerIOS):
* DumpRenderTree/mac/UIScriptControllerMac.h:
(WTR::UIScriptControllerMac::UIScriptControllerMac):

Make both -IOS and -Mac subclasses inherit from UIScriptControllerCocoa.

* TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* TestRunnerShared/UIScriptContext/UIScriptController.h:
(WTR::UIScriptController::setContinuousSpellCheckingEnabled):

Add a new script controller method to change the platform spell checking preference during a layout test.

* WebKitTestRunner/TestController.cpp:
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::TestController::cocoaResetStateToConsistentValues):

Adjust this to explicitly turn continuous spellchecking on or off based on the `shouldShowSpellCheckingDots`
test option flag, instead of toggling it on and then off when resetting state before and after the layout test.

* WebKitTestRunner/cocoa/UIScriptControllerCocoa.h:
* WebKitTestRunner/cocoa/UIScriptControllerCocoa.mm:
(WTR::UIScriptControllerCocoa::setContinuousSpellCheckingEnabled):

LayoutTests:

Add a new layout test to verify that the changes to platform spellchecking preferences are reflected in editable
content. See other changelogs for more information.

* editing/spelling/toggle-spellchecking-expected.txt: Added.
* editing/spelling/toggle-spellchecking.html: Added.
* platform/win/TestExpectations:
* platform/wincairo/TestExpectations:
* resources/ui-helper.js:
(window.UIHelper.async.setContinuousSpellCheckingEnabled):

Also, add a new UIHelper method to enable or disable continuous spellchecking during a layout test.

(window.UIHelper):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (252376 => 252377)


--- trunk/LayoutTests/ChangeLog	2019-11-12 23:50:42 UTC (rev 252376)
+++ trunk/LayoutTests/ChangeLog	2019-11-13 00:07:00 UTC (rev 252377)
@@ -1,3 +1,25 @@
+2019-11-12  Wenson Hsieh  <[email protected]>
+
+        [iOS] WKWebView does not respect system spellchecking preference
+        https://bugs.webkit.org/show_bug.cgi?id=204100
+        <rdar://problem/56653808>
+
+        Reviewed by Tim Horton.
+
+        Add a new layout test to verify that the changes to platform spellchecking preferences are reflected in editable
+        content. See other changelogs for more information.
+
+        * editing/spelling/toggle-spellchecking-expected.txt: Added.
+        * editing/spelling/toggle-spellchecking.html: Added.
+        * platform/win/TestExpectations:
+        * platform/wincairo/TestExpectations:
+        * resources/ui-helper.js:
+        (window.UIHelper.async.setContinuousSpellCheckingEnabled):
+
+        Also, add a new UIHelper method to enable or disable continuous spellchecking during a layout test.
+
+        (window.UIHelper):
+
 2019-11-12  Carlos Alberto Lopez Perez  <[email protected]>
 
         [GTK][WPE] Support Pointer Events

Added: trunk/LayoutTests/editing/spelling/toggle-spellchecking-expected.txt (0 => 252377)


--- trunk/LayoutTests/editing/spelling/toggle-spellchecking-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/spelling/toggle-spellchecking-expected.txt	2019-11-13 00:07:00 UTC (rev 252377)
@@ -0,0 +1,15 @@
+This test verifies that enabling or disabling platform spell checking preferences influences the presence of spelling markers in the document. Requires WebKitTestRunner.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Turned continuous spell checking off.
+PASS internals.hasSpellingMarker(0, 3) is false
+PASS Turned continuous spell checking on.
+PASS internals.hasSpellingMarker(0, 3) is true
+PASS Turned continuous spell checking off again.
+PASS internals.hasSpellingMarker(0, 3) is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/editing/spelling/toggle-spellchecking.html (0 => 252377)


--- trunk/LayoutTests/editing/spelling/toggle-spellchecking.html	                        (rev 0)
+++ trunk/LayoutTests/editing/spelling/toggle-spellchecking.html	2019-11-13 00:07:00 UTC (rev 252377)
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src=""
+    <script src=""
+    <script src=""
+    <script>
+        jsTestIsAsync = true;
+
+        addEventListener("load", async () => {
+            description("This test verifies that enabling or disabling platform spell checking preferences influences the presence of spelling markers in the document. Requires WebKitTestRunner.");
+
+            document.getElementById("editor").focus();
+
+            if (!window.internals || !window.testRunner)
+                return;
+
+            await UIHelper.setContinuousSpellCheckingEnabled(false);
+            testPassed("Turned continuous spell checking off.");
+
+            [..."zzr "].map(typeCharacterCommand);
+            shouldBeFalse("internals.hasSpellingMarker(0, 3)");
+
+            await UIHelper.setContinuousSpellCheckingEnabled(true);
+            testPassed("Turned continuous spell checking on.");
+
+            deleteCommand();
+            typeCharacterCommand(" ");
+            shouldBeTrue("internals.hasSpellingMarker(0, 3)");
+
+            await UIHelper.setContinuousSpellCheckingEnabled(false);
+            testPassed("Turned continuous spell checking off again.");
+
+            deleteCommand();
+            typeCharacterCommand(" ");
+            shouldBeFalse("internals.hasSpellingMarker(0, 3)");
+
+            finishJSTest();
+        });
+    </script>
+</head>
+<body>
+<textarea id="editor"></textarea>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/win/TestExpectations (252376 => 252377)


--- trunk/LayoutTests/platform/win/TestExpectations	2019-11-12 23:50:42 UTC (rev 252376)
+++ trunk/LayoutTests/platform/win/TestExpectations	2019-11-13 00:07:00 UTC (rev 252377)
@@ -1305,6 +1305,7 @@
 editing/spelling/spellcheck-paste-disabled.html [ Skip ]
 editing/spelling/spelling-unified-emulation.html [ Skip ]
 editing/spelling/grammar-markers.html [ Skip ]
+editing/spelling/toggle-spellchecking.html [ Skip ]
 
 # No concept of secure text input
 editing/secure-input [ Skip ]

Modified: trunk/LayoutTests/platform/wincairo/TestExpectations (252376 => 252377)


--- trunk/LayoutTests/platform/wincairo/TestExpectations	2019-11-12 23:50:42 UTC (rev 252376)
+++ trunk/LayoutTests/platform/wincairo/TestExpectations	2019-11-13 00:07:00 UTC (rev 252377)
@@ -725,6 +725,9 @@
 editing/spelling/spelling-attribute-change.html [ Timeout ]
 editing/spelling/spellcheck-attribute.html [ Timeout ]
 
+# UIScriptController.setContinuousSpellCheckingEnabled is not implemented.
+editing/spelling/toggle-spellchecking.html [ Skip ]
+
 # LayoutTest/fast/loader tests that fail or time out.
 fast/loader/local-CSS-from-local.html [ Failure Timeout ]
 fast/loader/local-_javascript_-from-local.html [ Failure Timeout ]

Modified: trunk/LayoutTests/resources/ui-helper.js (252376 => 252377)


--- trunk/LayoutTests/resources/ui-helper.js	2019-11-12 23:50:42 UTC (rev 252376)
+++ trunk/LayoutTests/resources/ui-helper.js	2019-11-13 00:07:00 UTC (rev 252377)
@@ -1061,4 +1061,10 @@
         const copyTextScript = `uiController.copyText(\`${text.replace(/`/g, "\\`")}\`)()`;
         return new Promise(resolve => testRunner.runUIScript(copyTextScript, resolve));
     }
+
+    static async setContinuousSpellCheckingEnabled(enabled) {
+        return new Promise(resolve => {
+            testRunner.runUIScript(`uiController.setContinuousSpellCheckingEnabled(${enabled})`, resolve);
+        });
+    }
 }

Modified: trunk/Source/WebKit/ChangeLog (252376 => 252377)


--- trunk/Source/WebKit/ChangeLog	2019-11-12 23:50:42 UTC (rev 252376)
+++ trunk/Source/WebKit/ChangeLog	2019-11-13 00:07:00 UTC (rev 252377)
@@ -1,3 +1,50 @@
+2019-11-12  Wenson Hsieh  <[email protected]>
+
+        [iOS] WKWebView does not respect system spellchecking preference
+        https://bugs.webkit.org/show_bug.cgi?id=204100
+        <rdar://problem/56653808>
+
+        Reviewed by Tim Horton.
+
+        Implements a platform hook on iOS (-setContinuousSpellCheckingEnabled:) to allow UIKit to inform us when the
+        system spellchecking preference changes, and adds logic to propagate these changes to the web process. See below
+        for more details.
+
+        Test: editing/spelling/toggle-spellchecking.html
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _setContinuousSpellCheckingEnabledForTesting:]):
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+
+        Add testing SPI to enable or disable continuous spellchecking, for both iOS and macOS.
+
+        * UIProcess/Cocoa/WebViewImpl.h:
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::WebViewImpl::setContinuousSpellCheckingEnabled):
+        * UIProcess/TextChecker.h:
+        * UIProcess/gtk/TextCheckerGtk.cpp:
+        (WebKit::TextChecker::setContinuousSpellCheckingEnabled):
+        * UIProcess/ios/TextCheckerIOS.mm:
+        (WebKit::TextChecker::setContinuousSpellCheckingEnabled):
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView setupInteraction]):
+        (-[WKContentView setContinuousSpellCheckingEnabled:]):
+
+        Implement this method to handle changes to the system spellchecking preference. This hook is also used by legacy
+        WebKit on iOS to turn spellchecking on or off. If the value of the preference changed, we additionally notify
+        the web process. In the future, we should consider refactoring TextCheckerState to be per-web view and per-page,
+        since Cocoa platform APIs would allow for different WKWebViews to have different spell checking preferences.
+
+        * UIProcess/mac/TextCheckerMac.mm:
+        (WebKit::TextChecker::setContinuousSpellCheckingEnabled):
+        * UIProcess/win/TextCheckerWin.cpp:
+        (WebKit::TextChecker::setContinuousSpellCheckingEnabled):
+        * UIProcess/wpe/TextCheckerWPE.cpp:
+        (WebKit::TextChecker::setContinuousSpellCheckingEnabled):
+
+        Adjusted setContinuousSpellCheckingEnabled to return whether or not the continuous spellchecking state changed.
+
 2019-11-12  Truitt Savell  <[email protected]>
 
         Unreviewed, rolling out r252351.

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (252376 => 252377)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2019-11-12 23:50:42 UTC (rev 252376)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2019-11-13 00:07:00 UTC (rev 252377)
@@ -49,6 +49,8 @@
 #import "RemoteObjectRegistry.h"
 #import "RemoteObjectRegistryMessages.h"
 #import "SafeBrowsingWarning.h"
+#import "TextChecker.h"
+#import "TextCheckerState.h"
 #import "UIDelegate.h"
 #import "UserMediaProcessManager.h"
 #import "VersionChecks.h"
@@ -6897,6 +6899,15 @@
 
 @implementation WKWebView (WKTesting)
 
+- (void)_setContinuousSpellCheckingEnabledForTesting:(BOOL)enabled
+{
+#if PLATFORM(IOS_FAMILY)
+    [_contentView setContinuousSpellCheckingEnabled:enabled];
+#else
+    _impl->setContinuousSpellCheckingEnabled(enabled);
+#endif
+}
+
 - (NSDictionary *)_contentsOfUserInterfaceItem:(NSString *)userInterfaceItem
 {
     if ([userInterfaceItem isEqualToString:@"validationBubble"]) {

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h (252376 => 252377)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h	2019-11-12 23:50:42 UTC (rev 252376)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h	2019-11-13 00:07:00 UTC (rev 252377)
@@ -454,6 +454,7 @@
 
 @interface WKWebView (WKTesting)
 
+- (void)_setContinuousSpellCheckingEnabledForTesting:(BOOL)enabled WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
 - (NSDictionary *)_contentsOfUserInterfaceItem:(NSString *)userInterfaceItem WK_API_AVAILABLE(macos(10.12.3), ios(10.3));
 
 #if TARGET_OS_IPHONE

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h (252376 => 252377)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h	2019-11-12 23:50:42 UTC (rev 252376)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h	2019-11-13 00:07:00 UTC (rev 252377)
@@ -350,6 +350,8 @@
     void showGuessPanel(id);
     void checkSpelling();
     void changeSpelling(id);
+
+    void setContinuousSpellCheckingEnabled(bool);
     void toggleContinuousSpellChecking();
 
     bool isGrammarCheckingEnabled();

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (252376 => 252377)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2019-11-12 23:50:42 UTC (rev 252376)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2019-11-13 00:07:00 UTC (rev 252377)
@@ -3117,6 +3117,15 @@
     m_page->changeSpellingToWord(word);
 }
 
+void WebViewImpl::setContinuousSpellCheckingEnabled(bool enabled)
+{
+    if (TextChecker::state().isContinuousSpellCheckingEnabled == enabled)
+        return;
+
+    TextChecker::setContinuousSpellCheckingEnabled(enabled);
+    m_page->process().updateTextCheckerState();
+}
+
 void WebViewImpl::toggleContinuousSpellChecking()
 {
     bool spellCheckingEnabled = !TextChecker::state().isContinuousSpellCheckingEnabled;

Modified: trunk/Source/WebKit/UIProcess/TextChecker.h (252376 => 252377)


--- trunk/Source/WebKit/UIProcess/TextChecker.h	2019-11-12 23:50:42 UTC (rev 252376)
+++ trunk/Source/WebKit/UIProcess/TextChecker.h	2019-11-13 00:07:00 UTC (rev 252377)
@@ -41,7 +41,7 @@
     static const TextCheckerState& state();
     static bool isContinuousSpellCheckingAllowed();
 
-    static void setContinuousSpellCheckingEnabled(bool);
+    static bool setContinuousSpellCheckingEnabled(bool);
     static void setGrammarCheckingEnabled(bool);
     
     static void setTestingMode(bool);

Modified: trunk/Source/WebKit/UIProcess/gtk/TextCheckerGtk.cpp (252376 => 252377)


--- trunk/Source/WebKit/UIProcess/gtk/TextCheckerGtk.cpp	2019-11-12 23:50:42 UTC (rev 252376)
+++ trunk/Source/WebKit/UIProcess/gtk/TextCheckerGtk.cpp	2019-11-13 00:07:00 UTC (rev 252377)
@@ -85,16 +85,17 @@
 #endif
 }
 
-void TextChecker::setContinuousSpellCheckingEnabled(bool isContinuousSpellCheckingEnabled)
+bool TextChecker::setContinuousSpellCheckingEnabled(bool isContinuousSpellCheckingEnabled)
 {
 #if ENABLE(SPELLCHECK)
     if (checkerState().isContinuousSpellCheckingEnabled == isContinuousSpellCheckingEnabled)
-        return;
+        return false;
     checkerState().isContinuousSpellCheckingEnabled = isContinuousSpellCheckingEnabled;
     updateStateForAllProcessPools();
 #else
     UNUSED_PARAM(isContinuousSpellCheckingEnabled);
 #endif
+    return true;
 }
 
 void TextChecker::setGrammarCheckingEnabled(bool isGrammarCheckingEnabled)

Modified: trunk/Source/WebKit/UIProcess/ios/TextCheckerIOS.mm (252376 => 252377)


--- trunk/Source/WebKit/UIProcess/ios/TextCheckerIOS.mm	2019-11-12 23:50:42 UTC (rev 252376)
+++ trunk/Source/WebKit/UIProcess/ios/TextCheckerIOS.mm	2019-11-13 00:07:00 UTC (rev 252377)
@@ -64,9 +64,13 @@
 #endif
 }
 
-void TextChecker::setContinuousSpellCheckingEnabled(bool enabled)
+bool TextChecker::setContinuousSpellCheckingEnabled(bool enabled)
 {
+    if (state().isContinuousSpellCheckingEnabled == enabled)
+        return false;
+
     mutableState().isContinuousSpellCheckingEnabled = enabled;
+    return true;
 }
 
 void TextChecker::setGrammarCheckingEnabled(bool)

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (252376 => 252377)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2019-11-12 23:50:42 UTC (rev 252376)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2019-11-13 00:07:00 UTC (rev 252377)
@@ -557,6 +557,7 @@
 @property (nonatomic, readonly) BOOL _shouldUseLegacySelectPopoverDismissalBehavior;
 
 - (void)_didChangeLinkPreviewAvailability;
+- (void)setContinuousSpellCheckingEnabled:(BOOL)enabled;
 
 @end
 

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (252376 => 252377)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-11-12 23:50:42 UTC (rev 252376)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-11-13 00:07:00 UTC (rev 252377)
@@ -40,6 +40,7 @@
 #import "RemoteLayerTreeDrawingAreaProxy.h"
 #import "RemoteLayerTreeViews.h"
 #import "SmartMagnificationController.h"
+#import "TextChecker.h"
 #import "TextInputSPI.h"
 #import "UIKitSPI.h"
 #import "VersionChecks.h"
@@ -860,6 +861,8 @@
     _textCheckingController = makeUnique<WebKit::TextCheckingController>(*_page);
 #endif
 
+    _page->process().updateTextCheckerState();
+
     _hasSetUpInteractions = YES;
 }
 
@@ -7818,6 +7821,12 @@
 }
 #endif // HAVE(PENCILKIT)
 
+- (void)setContinuousSpellCheckingEnabled:(BOOL)enabled
+{
+    if (WebKit::TextChecker::setContinuousSpellCheckingEnabled(enabled))
+        _page->process().updateTextCheckerState();
+}
+
 @end
 
 @implementation WKContentView (WKTesting)

Modified: trunk/Source/WebKit/UIProcess/mac/TextCheckerMac.mm (252376 => 252377)


--- trunk/Source/WebKit/UIProcess/mac/TextCheckerMac.mm	2019-11-12 23:50:42 UTC (rev 252376)
+++ trunk/Source/WebKit/UIProcess/mac/TextCheckerMac.mm	2019-11-13 00:07:00 UTC (rev 252377)
@@ -143,10 +143,10 @@
     return allowContinuousSpellChecking;
 }
 
-void TextChecker::setContinuousSpellCheckingEnabled(bool isContinuousSpellCheckingEnabled)
+bool TextChecker::setContinuousSpellCheckingEnabled(bool isContinuousSpellCheckingEnabled)
 {
     if (state().isContinuousSpellCheckingEnabled == isContinuousSpellCheckingEnabled)
-        return;
+        return false;
                                                                                       
     mutableState().isContinuousSpellCheckingEnabled = isContinuousSpellCheckingEnabled;
     if (!testingModeEnabled)
@@ -153,6 +153,7 @@
         [[NSUserDefaults standardUserDefaults] setBool:isContinuousSpellCheckingEnabled forKey:WebContinuousSpellCheckingEnabled];
 
     // FIXME: preflight the spell checker.
+    return true;
 }
 
 void TextChecker::setGrammarCheckingEnabled(bool isGrammarCheckingEnabled)

Modified: trunk/Source/WebKit/UIProcess/win/TextCheckerWin.cpp (252376 => 252377)


--- trunk/Source/WebKit/UIProcess/win/TextCheckerWin.cpp	2019-11-12 23:50:42 UTC (rev 252376)
+++ trunk/Source/WebKit/UIProcess/win/TextCheckerWin.cpp	2019-11-13 00:07:00 UTC (rev 252377)
@@ -61,8 +61,9 @@
     return false;
 }
 
-void TextChecker::setContinuousSpellCheckingEnabled(bool)
+bool TextChecker::setContinuousSpellCheckingEnabled(bool)
 {
+    return false;
 }
 
 void TextChecker::setGrammarCheckingEnabled(bool)

Modified: trunk/Source/WebKit/UIProcess/wpe/TextCheckerWPE.cpp (252376 => 252377)


--- trunk/Source/WebKit/UIProcess/wpe/TextCheckerWPE.cpp	2019-11-12 23:50:42 UTC (rev 252376)
+++ trunk/Source/WebKit/UIProcess/wpe/TextCheckerWPE.cpp	2019-11-13 00:07:00 UTC (rev 252377)
@@ -55,9 +55,10 @@
     return false;
 }
 
-void TextChecker::setContinuousSpellCheckingEnabled(bool)
+bool TextChecker::setContinuousSpellCheckingEnabled(bool)
 {
     notImplemented();
+    return false;
 }
 
 void TextChecker::setGrammarCheckingEnabled(bool)

Modified: trunk/Tools/ChangeLog (252376 => 252377)


--- trunk/Tools/ChangeLog	2019-11-12 23:50:42 UTC (rev 252376)
+++ trunk/Tools/ChangeLog	2019-11-13 00:07:00 UTC (rev 252377)
@@ -1,3 +1,44 @@
+2019-11-12  Wenson Hsieh  <[email protected]>
+
+        [iOS] WKWebView does not respect system spellchecking preference
+        https://bugs.webkit.org/show_bug.cgi?id=204100
+        <rdar://problem/56653808>
+
+        Reviewed by Tim Horton.
+
+        * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
+        * DumpRenderTree/cocoa/UIScriptControllerCocoa.h:
+        * DumpRenderTree/cocoa/UIScriptControllerCocoa.mm:
+        (WTR::UIScriptControllerCocoa::UIScriptControllerCocoa):
+        (WTR::UIScriptControllerCocoa::setContinuousSpellCheckingEnabled):
+
+        Add a new UIScriptControllerCocoa subclass for DumpRenderTree. For now, this will just contain the cross-
+        platform implementation of setContinuousSpellCheckingEnabled.
+
+        * DumpRenderTree/ios/UIScriptControllerIOS.h:
+        (WTR::UIScriptControllerIOS::UIScriptControllerIOS):
+        * DumpRenderTree/mac/UIScriptControllerMac.h:
+        (WTR::UIScriptControllerMac::UIScriptControllerMac):
+
+        Make both -IOS and -Mac subclasses inherit from UIScriptControllerCocoa.
+
+        * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
+        * TestRunnerShared/UIScriptContext/UIScriptController.h:
+        (WTR::UIScriptController::setContinuousSpellCheckingEnabled):
+
+        Add a new script controller method to change the platform spell checking preference during a layout test.
+
+        * WebKitTestRunner/TestController.cpp:
+        * WebKitTestRunner/cocoa/TestControllerCocoa.mm:
+        (WTR::TestController::cocoaResetStateToConsistentValues):
+
+        Adjust this to explicitly turn continuous spellchecking on or off based on the `shouldShowSpellCheckingDots`
+        test option flag, instead of toggling it on and then off when resetting state before and after the layout test.
+
+        * WebKitTestRunner/cocoa/UIScriptControllerCocoa.h:
+        * WebKitTestRunner/cocoa/UIScriptControllerCocoa.mm:
+        (WTR::UIScriptControllerCocoa::setContinuousSpellCheckingEnabled):
+
 2019-11-12  Aakash Jain  <[email protected]>
 
         Update unit-tests for JSC EWS

Modified: trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj (252376 => 252377)


--- trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj	2019-11-12 23:50:42 UTC (rev 252376)
+++ trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj	2019-11-13 00:07:00 UTC (rev 252377)
@@ -159,6 +159,7 @@
 		E1B7816511AF31B7007E1BC2 /* MockGeolocationProvider.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1B7808711AF1669007E1BC2 /* MockGeolocationProvider.mm */; };
 		F44A531D21B89A4D00DBB99C /* ClassMethodSwizzler.mm in Sources */ = {isa = PBXBuildFile; fileRef = F44A531A21B89A4400DBB99C /* ClassMethodSwizzler.mm */; };
 		F44A531E21B89A5000DBB99C /* InstanceMethodSwizzler.mm in Sources */ = {isa = PBXBuildFile; fileRef = F44A531C21B89A4500DBB99C /* InstanceMethodSwizzler.mm */; };
+		F484C223237B27D600BF77D0 /* UIScriptControllerCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = F484C222237B27D600BF77D0 /* UIScriptControllerCocoa.mm */; };
 		F4C3578D20E8444E00FA0748 /* LayoutTestSpellChecker.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4C3578820E8442700FA0748 /* LayoutTestSpellChecker.mm */; };
 		F4D423611DD5048200678290 /* TextInputControllerIOS.m in Sources */ = {isa = PBXBuildFile; fileRef = F4D4235F1DD5045300678290 /* TextInputControllerIOS.m */; };
 		F4FED32023582158003C139C /* NSPasteboardAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4FED31F23582158003C139C /* NSPasteboardAdditions.mm */; };
@@ -430,6 +431,8 @@
 		F44A531A21B89A4400DBB99C /* ClassMethodSwizzler.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ClassMethodSwizzler.mm; sourceTree = "<group>"; };
 		F44A531B21B89A4400DBB99C /* ClassMethodSwizzler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClassMethodSwizzler.h; sourceTree = "<group>"; };
 		F44A531C21B89A4500DBB99C /* InstanceMethodSwizzler.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = InstanceMethodSwizzler.mm; sourceTree = "<group>"; };
+		F484C221237B27D600BF77D0 /* UIScriptControllerCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = UIScriptControllerCocoa.h; path = cocoa/UIScriptControllerCocoa.h; sourceTree = "<group>"; };
+		F484C222237B27D600BF77D0 /* UIScriptControllerCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = UIScriptControllerCocoa.mm; path = cocoa/UIScriptControllerCocoa.mm; sourceTree = "<group>"; };
 		F4C3578820E8442700FA0748 /* LayoutTestSpellChecker.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LayoutTestSpellChecker.mm; sourceTree = "<group>"; };
 		F4C3578920E8442700FA0748 /* LayoutTestSpellChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutTestSpellChecker.h; sourceTree = "<group>"; };
 		F4D4235F1DD5045300678290 /* TextInputControllerIOS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TextInputControllerIOS.m; path = ios/TextInputControllerIOS.m; sourceTree = "<group>"; };
@@ -523,6 +526,7 @@
 			isa = PBXGroup;
 			children = (
 				0F18E6EE1D6B9C0C0027E547 /* Bindings */,
+				F484C220237B27A800BF77D0 /* cocoa */,
 				0F18E6EF1D6B9C120027E547 /* Derived Sources */,
 				0F6A0DFF1D6E0F8600F1C9A8 /* ios */,
 				0F6A0E001D6E0F8A00F1C9A8 /* mac */,
@@ -850,6 +854,15 @@
 			name = PixelDump;
 			sourceTree = "<group>";
 		};
+		F484C220237B27A800BF77D0 /* cocoa */ = {
+			isa = PBXGroup;
+			children = (
+				F484C221237B27D600BF77D0 /* UIScriptControllerCocoa.h */,
+				F484C222237B27D600BF77D0 /* UIScriptControllerCocoa.mm */,
+			);
+			name = cocoa;
+			sourceTree = "<group>";
+		};
 		F4B6C31820E84382008AC225 /* cocoa */ = {
 			isa = PBXGroup;
 			children = (
@@ -1216,6 +1229,7 @@
 				BCA18B6A0C9B08C200114369 /* UIDelegate.mm in Sources */,
 				0F18E6EC1D6B9C070027E547 /* UIScriptContext.cpp in Sources */,
 				0F18E6ED1D6B9C070027E547 /* UIScriptController.cpp in Sources */,
+				F484C223237B27D600BF77D0 /* UIScriptControllerCocoa.mm in Sources */,
 				0F18E70D1D6BAC8C0027E547 /* UIScriptControllerIOS.mm in Sources */,
 				0F18E70F1D6BACB60027E547 /* UIScriptControllerMac.mm in Sources */,
 				BC9D90240C97472E0099A4A3 /* WorkQueue.cpp in Sources */,

Copied: trunk/Tools/DumpRenderTree/cocoa/UIScriptControllerCocoa.h (from rev 252375, trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.h) (0 => 252377)


--- trunk/Tools/DumpRenderTree/cocoa/UIScriptControllerCocoa.h	                        (rev 0)
+++ trunk/Tools/DumpRenderTree/cocoa/UIScriptControllerCocoa.h	2019-11-13 00:07:00 UTC (rev 252377)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if PLATFORM(COCOA)
+
+#import "UIScriptController.h"
+
+namespace WTR {
+
+class UIScriptControllerCocoa : public UIScriptController {
+public:
+    void setContinuousSpellCheckingEnabled(bool) override;
+
+protected:
+    explicit UIScriptControllerCocoa(UIScriptContext&);
+};
+
+} // namespace WTR
+
+#endif // PLATFORM(COCOA)

Copied: trunk/Tools/DumpRenderTree/cocoa/UIScriptControllerCocoa.mm (from rev 252375, trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.h) (0 => 252377)


--- trunk/Tools/DumpRenderTree/cocoa/UIScriptControllerCocoa.mm	                        (rev 0)
+++ trunk/Tools/DumpRenderTree/cocoa/UIScriptControllerCocoa.mm	2019-11-13 00:07:00 UTC (rev 252377)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "UIScriptControllerCocoa.h"
+
+#if PLATFORM(COCOA)
+
+#import "DumpRenderTree.h"
+#import "UIScriptContext.h"
+#import <WebKit/WebViewPrivate.h>
+
+namespace WTR {
+
+UIScriptControllerCocoa::UIScriptControllerCocoa(UIScriptContext& context)
+    : UIScriptController(context)
+{
+}
+
+void UIScriptControllerCocoa::setContinuousSpellCheckingEnabled(bool enabled)
+{
+    mainFrame.webView.continuousSpellCheckingEnabled = enabled;
+}
+
+} // namespace WTR
+
+#endif // PLATFORM(COCOA)

Modified: trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.h (252376 => 252377)


--- trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.h	2019-11-12 23:50:42 UTC (rev 252376)
+++ trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.h	2019-11-13 00:07:00 UTC (rev 252377)
@@ -25,16 +25,16 @@
 
 #pragma once
 
-#import "UIScriptController.h"
+#import "UIScriptControllerCocoa.h"
 
 #if PLATFORM(IOS_FAMILY)
 
 namespace WTR {
 
-class UIScriptControllerIOS : public UIScriptController {
+class UIScriptControllerIOS : public UIScriptControllerCocoa {
 public:
     explicit UIScriptControllerIOS(UIScriptContext& context)
-        : UIScriptController(context)
+        : UIScriptControllerCocoa(context)
     {
     }
 

Modified: trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.h (252376 => 252377)


--- trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.h	2019-11-12 23:50:42 UTC (rev 252376)
+++ trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.h	2019-11-13 00:07:00 UTC (rev 252377)
@@ -25,16 +25,16 @@
 
 #pragma once
 
-#import "UIScriptController.h"
+#import "UIScriptControllerCocoa.h"
 
 #if PLATFORM(MAC)
 
 namespace WTR {
 
-class UIScriptControllerMac : public UIScriptController {
+class UIScriptControllerMac : public UIScriptControllerCocoa {
 public:
     explicit UIScriptControllerMac(UIScriptContext& context)
-        : UIScriptController(context)
+        : UIScriptControllerCocoa(context)
     {
     }
 

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl (252376 => 252377)


--- trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl	2019-11-12 23:50:42 UTC (rev 252376)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl	2019-11-13 00:07:00 UTC (rev 252377)
@@ -78,6 +78,7 @@
 
     void keyDown(DOMString character, object modifierArray);
     void toggleCapsLock(object callback);
+    void setContinuousSpellCheckingEnabled(boolean enabled);
 
     void rawKeyDown(DOMString key);
     void rawKeyUp(DOMString key);

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h (252376 => 252377)


--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h	2019-11-12 23:50:42 UTC (rev 252376)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h	2019-11-13 00:07:00 UTC (rev 252377)
@@ -156,6 +156,7 @@
 
     virtual void keyDown(JSStringRef character, JSValueRef modifierArray) { notImplemented(); }
     virtual void toggleCapsLock(JSValueRef callback) { notImplemented(); }
+    virtual void setContinuousSpellCheckingEnabled(bool) { notImplemented(); }
 
     virtual void rawKeyDown(JSStringRef) { notImplemented(); }
     virtual void rawKeyUp(JSStringRef) { notImplemented(); }

Modified: trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm (252376 => 252377)


--- trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm	2019-11-12 23:50:42 UTC (rev 252376)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm	2019-11-13 00:07:00 UTC (rev 252377)
@@ -258,11 +258,7 @@
         TestRunnerWKWebView *platformView = webView->platformView();
         platformView._viewScale = 1;
         platformView._minimumEffectiveDeviceWidth = 0;
-
-        // Toggle on before the test, and toggle off after the test.
-        if (options.shouldShowSpellCheckingDots)
-            [platformView toggleContinuousSpellChecking:nil];
-
+        [platformView _setContinuousSpellCheckingEnabledForTesting:options.shouldShowSpellCheckingDots];
         [platformView resetInteractionCallbacks];
     }
 

Modified: trunk/Tools/WebKitTestRunner/cocoa/UIScriptControllerCocoa.h (252376 => 252377)


--- trunk/Tools/WebKitTestRunner/cocoa/UIScriptControllerCocoa.h	2019-11-12 23:50:42 UTC (rev 252376)
+++ trunk/Tools/WebKitTestRunner/cocoa/UIScriptControllerCocoa.h	2019-11-13 00:07:00 UTC (rev 252377)
@@ -54,6 +54,8 @@
     void dismissMenu() override;
     bool isShowingMenu() const override;
 
+    void setContinuousSpellCheckingEnabled(bool) override;
+
 protected:
     explicit UIScriptControllerCocoa(UIScriptContext&);
     TestRunnerWKWebView *webView() const;

Modified: trunk/Tools/WebKitTestRunner/cocoa/UIScriptControllerCocoa.mm (252376 => 252377)


--- trunk/Tools/WebKitTestRunner/cocoa/UIScriptControllerCocoa.mm	2019-11-12 23:50:42 UTC (rev 252376)
+++ trunk/Tools/WebKitTestRunner/cocoa/UIScriptControllerCocoa.mm	2019-11-13 00:07:00 UTC (rev 252377)
@@ -196,4 +196,9 @@
     return webView().showingMenu;
 }
 
+void UIScriptControllerCocoa::setContinuousSpellCheckingEnabled(bool enabled)
+{
+    [webView() _setContinuousSpellCheckingEnabledForTesting:enabled];
+}
+
 } // namespace WTR
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to