[iOS] WKWebView does not respect system spellchecking preference
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Nov 2019 00:07:00 +0000 (00:07 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Nov 2019 00:07:00 +0000 (00:07 +0000)
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):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@252377 268f45cc-cd09-0410-ab3c-d52691b4dbfc

30 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/spelling/toggle-spellchecking-expected.txt [new file with mode: 0644]
LayoutTests/editing/spelling/toggle-spellchecking.html [new file with mode: 0644]
LayoutTests/platform/win/TestExpectations
LayoutTests/platform/wincairo/TestExpectations
LayoutTests/resources/ui-helper.js
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h
Source/WebKit/UIProcess/Cocoa/WebViewImpl.h
Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
Source/WebKit/UIProcess/TextChecker.h
Source/WebKit/UIProcess/gtk/TextCheckerGtk.cpp
Source/WebKit/UIProcess/ios/TextCheckerIOS.mm
Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit/UIProcess/mac/TextCheckerMac.mm
Source/WebKit/UIProcess/win/TextCheckerWin.cpp
Source/WebKit/UIProcess/wpe/TextCheckerWPE.cpp
Tools/ChangeLog
Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj
Tools/DumpRenderTree/cocoa/UIScriptControllerCocoa.h [new file with mode: 0644]
Tools/DumpRenderTree/cocoa/UIScriptControllerCocoa.mm [new file with mode: 0644]
Tools/DumpRenderTree/ios/UIScriptControllerIOS.h
Tools/DumpRenderTree/mac/UIScriptControllerMac.h
Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl
Tools/TestRunnerShared/UIScriptContext/UIScriptController.h
Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm
Tools/WebKitTestRunner/cocoa/UIScriptControllerCocoa.h
Tools/WebKitTestRunner/cocoa/UIScriptControllerCocoa.mm

index 7814f3e..39901a2 100644 (file)
@@ -1,3 +1,25 @@
+2019-11-12  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [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  <clopez@igalia.com>
 
         [GTK][WPE] Support Pointer Events
diff --git a/LayoutTests/editing/spelling/toggle-spellchecking-expected.txt b/LayoutTests/editing/spelling/toggle-spellchecking-expected.txt
new file mode 100644 (file)
index 0000000..4cf0c07
--- /dev/null
@@ -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
+
diff --git a/LayoutTests/editing/spelling/toggle-spellchecking.html b/LayoutTests/editing/spelling/toggle-spellchecking.html
new file mode 100644 (file)
index 0000000..194ca8a
--- /dev/null
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src="../../resources/js-test.js"></script>
+    <script src="../../resources/ui-helper.js"></script>
+    <script src="../editing.js"></script>
+    <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>
index b587ff3..95dc08f 100644 (file)
@@ -1305,6 +1305,7 @@ editing/spelling/spellcheck-paste.html [ Skip ]
 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 ]
index e798965..3ca1d69 100644 (file)
@@ -725,6 +725,9 @@ editing/spelling/spelling-attribute-at-child.html [ Timeout ]
 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 ]
index 6e95a87..7a1fcf6 100644 (file)
@@ -1061,4 +1061,10 @@ window.UIHelper = class UIHelper {
         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);
+        });
+    }
 }
index 6467b14..7407295 100644 (file)
@@ -1,3 +1,50 @@
+2019-11-12  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [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  <tsavell@apple.com>
 
         Unreviewed, rolling out r252351.
index 500db5c..134e5d5 100644 (file)
@@ -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 @@ static WebCore::UserInterfaceLayoutDirection toUserInterfaceLayoutDirection(UISe
 
 @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"]) {
index fd91910..095a16c 100644 (file)
@@ -454,6 +454,7 @@ typedef NS_OPTIONS(NSUInteger, _WKRectEdge) {
 
 @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
index 33d7a9a..7fe4474 100644 (file)
@@ -350,6 +350,8 @@ public:
     void showGuessPanel(id);
     void checkSpelling();
     void changeSpelling(id);
+
+    void setContinuousSpellCheckingEnabled(bool);
     void toggleContinuousSpellChecking();
 
     bool isGrammarCheckingEnabled();
index f6a13eb..673ab45 100644 (file)
@@ -3117,6 +3117,15 @@ void WebViewImpl::changeSpelling(id sender)
     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;
index e4f05e5..58c3afe 100644 (file)
@@ -41,7 +41,7 @@ public:
     static const TextCheckerState& state();
     static bool isContinuousSpellCheckingAllowed();
 
-    static void setContinuousSpellCheckingEnabled(bool);
+    static bool setContinuousSpellCheckingEnabled(bool);
     static void setGrammarCheckingEnabled(bool);
     
     static void setTestingMode(bool);
index cdf1d77..4d9ca69 100644 (file)
@@ -85,16 +85,17 @@ bool TextChecker::isContinuousSpellCheckingAllowed()
 #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)
index d310232..9200eb6 100644 (file)
@@ -64,9 +64,13 @@ bool TextChecker::isContinuousSpellCheckingAllowed()
 #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)
index bd83c64..92da603 100644 (file)
@@ -557,6 +557,7 @@ FOR_EACH_PRIVATE_WKCONTENTVIEW_ACTION(DECLARE_WKCONTENTVIEW_ACTION_FOR_WEB_VIEW)
 @property (nonatomic, readonly) BOOL _shouldUseLegacySelectPopoverDismissalBehavior;
 
 - (void)_didChangeLinkPreviewAvailability;
+- (void)setContinuousSpellCheckingEnabled:(BOOL)enabled;
 
 @end
 
index 122f87a..2d03fc0 100644 (file)
@@ -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 @@ static inline bool hasFocusedElement(WebKit::FocusedElementInformation focusedEl
     _textCheckingController = makeUnique<WebKit::TextCheckingController>(*_page);
 #endif
 
+    _page->process().updateTextCheckerState();
+
     _hasSetUpInteractions = YES;
 }
 
@@ -7818,6 +7821,12 @@ static Vector<WebCore::IntSize> sizesOfPlaceholderElementsToInsertWhenDroppingIt
 }
 #endif // HAVE(PENCILKIT)
 
+- (void)setContinuousSpellCheckingEnabled:(BOOL)enabled
+{
+    if (WebKit::TextChecker::setContinuousSpellCheckingEnabled(enabled))
+        _page->process().updateTextCheckerState();
+}
+
 @end
 
 @implementation WKContentView (WKTesting)
index d003ea9..0ca133a 100644 (file)
@@ -143,16 +143,17 @@ bool TextChecker::isContinuousSpellCheckingAllowed()
     return allowContinuousSpellChecking;
 }
 
-void TextChecker::setContinuousSpellCheckingEnabled(bool isContinuousSpellCheckingEnabled)
+bool TextChecker::setContinuousSpellCheckingEnabled(bool isContinuousSpellCheckingEnabled)
 {
     if (state().isContinuousSpellCheckingEnabled == isContinuousSpellCheckingEnabled)
-        return;
+        return false;
                                                                                       
     mutableState().isContinuousSpellCheckingEnabled = isContinuousSpellCheckingEnabled;
     if (!testingModeEnabled)
         [[NSUserDefaults standardUserDefaults] setBool:isContinuousSpellCheckingEnabled forKey:WebContinuousSpellCheckingEnabled];
 
     // FIXME: preflight the spell checker.
+    return true;
 }
 
 void TextChecker::setGrammarCheckingEnabled(bool isGrammarCheckingEnabled)
index 54d3383..c7f2f70 100644 (file)
@@ -61,8 +61,9 @@ bool TextChecker::isContinuousSpellCheckingAllowed()
     return false;
 }
 
-void TextChecker::setContinuousSpellCheckingEnabled(bool)
+bool TextChecker::setContinuousSpellCheckingEnabled(bool)
 {
+    return false;
 }
 
 void TextChecker::setGrammarCheckingEnabled(bool)
index f9eaedd..0192121 100644 (file)
@@ -55,9 +55,10 @@ bool TextChecker::isContinuousSpellCheckingAllowed()
     return false;
 }
 
-void TextChecker::setContinuousSpellCheckingEnabled(bool)
+bool TextChecker::setContinuousSpellCheckingEnabled(bool)
 {
     notImplemented();
+    return false;
 }
 
 void TextChecker::setGrammarCheckingEnabled(bool)
index 4692ce4..cb9160a 100644 (file)
@@ -1,3 +1,44 @@
+2019-11-12  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [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  <aakash_jain@apple.com>
 
         Update unit-tests for JSC EWS
index d90c4ef..dd0e445 100644 (file)
                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 */; };
                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>"; };
                        isa = PBXGroup;
                        children = (
                                0F18E6EE1D6B9C0C0027E547 /* Bindings */,
+                               F484C220237B27A800BF77D0 /* cocoa */,
                                0F18E6EF1D6B9C120027E547 /* Derived Sources */,
                                0F6A0DFF1D6E0F8600F1C9A8 /* ios */,
                                0F6A0E001D6E0F8A00F1C9A8 /* mac */,
                        name = PixelDump;
                        sourceTree = "<group>";
                };
+               F484C220237B27A800BF77D0 /* cocoa */ = {
+                       isa = PBXGroup;
+                       children = (
+                               F484C221237B27D600BF77D0 /* UIScriptControllerCocoa.h */,
+                               F484C222237B27D600BF77D0 /* UIScriptControllerCocoa.mm */,
+                       );
+                       name = cocoa;
+                       sourceTree = "<group>";
+               };
                F4B6C31820E84382008AC225 /* cocoa */ = {
                        isa = PBXGroup;
                        children = (
                                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 */,
diff --git a/Tools/DumpRenderTree/cocoa/UIScriptControllerCocoa.h b/Tools/DumpRenderTree/cocoa/UIScriptControllerCocoa.h
new file mode 100644 (file)
index 0000000..80959bf
--- /dev/null
@@ -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)
diff --git a/Tools/DumpRenderTree/cocoa/UIScriptControllerCocoa.mm b/Tools/DumpRenderTree/cocoa/UIScriptControllerCocoa.mm
new file mode 100644 (file)
index 0000000..67a780c
--- /dev/null
@@ -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)
index 7a2a2e0..d4424a0 100644 (file)
 
 #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)
     {
     }
 
index 678bc21..47a8d7a 100644 (file)
 
 #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)
     {
     }
 
index a9c0f57..7480a02 100644 (file)
@@ -78,6 +78,7 @@ interface UIScriptController {
 
     void keyDown(DOMString character, object modifierArray);
     void toggleCapsLock(object callback);
+    void setContinuousSpellCheckingEnabled(boolean enabled);
 
     void rawKeyDown(DOMString key);
     void rawKeyUp(DOMString key);
index 4e0c75e..a963c83 100644 (file)
@@ -156,6 +156,7 @@ public:
 
     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(); }
index 612760c..e923b85 100644 (file)
@@ -258,11 +258,7 @@ void TestController::cocoaResetStateToConsistentValues(const TestOptions& option
         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];
     }
 
index 3e4bfd8..f569841 100644 (file)
@@ -54,6 +54,8 @@ public:
     void dismissMenu() override;
     bool isShowingMenu() const override;
 
+    void setContinuousSpellCheckingEnabled(bool) override;
+
 protected:
     explicit UIScriptControllerCocoa(UIScriptContext&);
     TestRunnerWKWebView *webView() const;
index 0f4eb07..bee0497 100644 (file)
@@ -196,4 +196,9 @@ bool UIScriptControllerCocoa::isShowingMenu() const
     return webView().showingMenu;
 }
 
+void UIScriptControllerCocoa::setContinuousSpellCheckingEnabled(bool enabled)
+{
+    [webView() _setContinuousSpellCheckingEnabledForTesting:enabled];
+}
+
 } // namespace WTR