Title: [246311] trunk
Revision
246311
Author
[email protected]
Date
2019-06-11 07:46:23 -0700 (Tue, 11 Jun 2019)

Log Message

Quotes are always inserted as smart quotes on stackblitz.com, causing compilation errors
https://bugs.webkit.org/show_bug.cgi?id=198735
<rdar://problem/51557159>

Reviewed by Megan Gardner.

Source/WebKit:

Add a flag in FocusedElementInformation to indicate whether spellchecking is allowed in the focused element.
If spellchecking is not allowed, then disable smart quotes and dashes, which matches behavior on macOS.

* Shared/FocusedElementInformation.cpp:
(WebKit::FocusedElementInformation::encode const):
(WebKit::FocusedElementInformation::decode):
* Shared/FocusedElementInformation.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView textInputTraits]):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::getFocusedElementInformation):

Tools:

Add a test to verify that spellcheck="false" disables smart quotes and dashes, but any other value defers to the
user's preferences by using UITextSmartQuotesTypeDefault and UITextSmartDashesTypeDefault.

* TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm:
(TestWebKitAPI::TEST):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (246310 => 246311)


--- trunk/Source/WebKit/ChangeLog	2019-06-11 12:52:21 UTC (rev 246310)
+++ trunk/Source/WebKit/ChangeLog	2019-06-11 14:46:23 UTC (rev 246311)
@@ -1,3 +1,23 @@
+2019-06-11  Wenson Hsieh  <[email protected]>
+
+        Quotes are always inserted as smart quotes on stackblitz.com, causing compilation errors
+        https://bugs.webkit.org/show_bug.cgi?id=198735
+        <rdar://problem/51557159>
+
+        Reviewed by Megan Gardner.
+
+        Add a flag in FocusedElementInformation to indicate whether spellchecking is allowed in the focused element.
+        If spellchecking is not allowed, then disable smart quotes and dashes, which matches behavior on macOS.
+
+        * Shared/FocusedElementInformation.cpp:
+        (WebKit::FocusedElementInformation::encode const):
+        (WebKit::FocusedElementInformation::decode):
+        * Shared/FocusedElementInformation.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView textInputTraits]):
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::getFocusedElementInformation):
+
 2019-06-11  Carlos Garcia Campos  <[email protected]>
 
         [GTK] Remove option REDIRECTED_XCOMPOSITE_WINDOW

Modified: trunk/Source/WebKit/Shared/FocusedElementInformation.cpp (246310 => 246311)


--- trunk/Source/WebKit/Shared/FocusedElementInformation.cpp	2019-06-11 12:52:21 UTC (rev 246310)
+++ trunk/Source/WebKit/Shared/FocusedElementInformation.cpp	2019-06-11 14:46:23 UTC (rev 246311)
@@ -105,6 +105,7 @@
 #endif
 #endif
     encoder << shouldSynthesizeKeyEventsForEditing;
+    encoder << isSpellCheckingEnabled;
 }
 
 bool FocusedElementInformation::decode(IPC::Decoder& decoder, FocusedElementInformation& result)
@@ -226,6 +227,9 @@
     if (!decoder.decode(result.shouldSynthesizeKeyEventsForEditing))
         return false;
 
+    if (!decoder.decode(result.isSpellCheckingEnabled))
+        return false;
+
     return true;
 }
 #endif

Modified: trunk/Source/WebKit/Shared/FocusedElementInformation.h (246310 => 246311)


--- trunk/Source/WebKit/Shared/FocusedElementInformation.h	2019-06-11 12:52:21 UTC (rev 246310)
+++ trunk/Source/WebKit/Shared/FocusedElementInformation.h	2019-06-11 14:46:23 UTC (rev 246311)
@@ -137,6 +137,7 @@
 #endif
 #endif
     bool shouldSynthesizeKeyEventsForEditing { false };
+    bool isSpellCheckingEnabled { true };
 
     FocusedElementIdentifier focusedElementIdentifier { 0 };
 

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (246310 => 246311)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-06-11 12:52:21 UTC (rev 246310)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-06-11 14:46:23 UTC (rev 246311)
@@ -4384,6 +4384,11 @@
         [_traits setAutocorrectionType:_focusedElementInformation.isAutocorrect ? UITextAutocorrectionTypeYes : UITextAutocorrectionTypeNo];
     }
 
+    if (!_focusedElementInformation.isSpellCheckingEnabled) {
+        [_traits setSmartQuotesType:UITextSmartQuotesTypeNo];
+        [_traits setSmartDashesType:UITextSmartDashesTypeNo];
+    }
+
     switch (_focusedElementInformation.inputMode) {
     case WebCore::InputMode::None:
     case WebCore::InputMode::Unspecified:

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (246310 => 246311)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2019-06-11 12:52:21 UTC (rev 246310)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2019-06-11 14:46:23 UTC (rev 246311)
@@ -2766,6 +2766,9 @@
     } else
         information.elementRect = IntRect();
 
+    if (is<HTMLElement>(m_focusedElement))
+        information.isSpellCheckingEnabled = downcast<HTMLElement>(*m_focusedElement).spellcheck();
+
     information.minimumScaleFactor = minimumPageScaleFactor();
     information.maximumScaleFactor = maximumPageScaleFactor();
     information.maximumScaleFactorIgnoringAlwaysScalable = maximumPageScaleFactorIgnoringAlwaysScalable();

Modified: trunk/Tools/ChangeLog (246310 => 246311)


--- trunk/Tools/ChangeLog	2019-06-11 12:52:21 UTC (rev 246310)
+++ trunk/Tools/ChangeLog	2019-06-11 14:46:23 UTC (rev 246311)
@@ -1,3 +1,17 @@
+2019-06-11  Wenson Hsieh  <[email protected]>
+
+        Quotes are always inserted as smart quotes on stackblitz.com, causing compilation errors
+        https://bugs.webkit.org/show_bug.cgi?id=198735
+        <rdar://problem/51557159>
+
+        Reviewed by Megan Gardner.
+
+        Add a test to verify that spellcheck="false" disables smart quotes and dashes, but any other value defers to the
+        user's preferences by using UITextSmartQuotesTypeDefault and UITextSmartDashesTypeDefault.
+
+        * TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm:
+        (TestWebKitAPI::TEST):
+
 2019-06-11  Tadeu Zagallo  <[email protected]>
 
         Unreviewed, add myself to the _javascript_Core watchlist.

Modified: trunk/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm (246310 => 246311)


--- trunk/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm	2019-06-11 12:52:21 UTC (rev 246310)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm	2019-06-11 14:46:23 UTC (rev 246311)
@@ -473,6 +473,38 @@
     EXPECT_EQ(inputView.get(), [contentView inputView]);
 }
 
+TEST(KeyboardInputTests, DisableSmartQuotesAndDashes)
+{
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
+    auto inputDelegate = adoptNS([[TestInputDelegate alloc] init]);
+    [inputDelegate setFocusStartsInputSessionPolicyHandler:[&] (WKWebView *, id <_WKFocusedElementInfo>) -> _WKFocusStartsInputSessionPolicy {
+        return _WKFocusStartsInputSessionPolicyAllow;
+    }];
+    [webView _setInputDelegate:inputDelegate.get()];
+
+    auto checkSmartQuotesAndDashesType = [&] (UITextSmartDashesType dashesType, UITextSmartQuotesType quotesType) {
+        UITextInputTraits *traits = [[webView textInputContentView] textInputTraits];
+        EXPECT_EQ(dashesType, traits.smartDashesType);
+        EXPECT_EQ(quotesType, traits.smartQuotesType);
+    };
+
+    [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);
+    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"bar.focus()"];
+    checkSmartQuotesAndDashesType(UITextSmartDashesTypeNo, UITextSmartQuotesTypeNo);
+    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"baz.focus()"];
+    checkSmartQuotesAndDashesType(UITextSmartDashesTypeNo, UITextSmartQuotesTypeNo);
+
+    [webView synchronouslyLoadHTMLString:@"<div id='foo' contenteditable></div><textarea id='bar' spellcheck='true'></textarea><input id='baz'>"];
+    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"foo.focus()"];
+    checkSmartQuotesAndDashesType(UITextSmartDashesTypeDefault, UITextSmartQuotesTypeDefault);
+    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"bar.focus()"];
+    checkSmartQuotesAndDashesType(UITextSmartDashesTypeDefault, UITextSmartQuotesTypeDefault);
+    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"baz.focus()"];
+    checkSmartQuotesAndDashesType(UITextSmartDashesTypeDefault, UITextSmartQuotesTypeDefault);
+}
+
 } // namespace TestWebKitAPI
 
 #endif // PLATFORM(IOS_FAMILY)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to