⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 246311 in webkit


Ignore:
Timestamp:
Jun 11, 2019, 7:46:23 AM (7 years ago)
Author:
Wenson Hsieh
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):

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r246308 r246311  
     12019-06-11  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Quotes are always inserted as smart quotes on stackblitz.com, causing compilation errors
     4        https://bugs.webkit.org/show_bug.cgi?id=198735
     5        <rdar://problem/51557159>
     6
     7        Reviewed by Megan Gardner.
     8
     9        Add a flag in FocusedElementInformation to indicate whether spellchecking is allowed in the focused element.
     10        If spellchecking is not allowed, then disable smart quotes and dashes, which matches behavior on macOS.
     11
     12        * Shared/FocusedElementInformation.cpp:
     13        (WebKit::FocusedElementInformation::encode const):
     14        (WebKit::FocusedElementInformation::decode):
     15        * Shared/FocusedElementInformation.h:
     16        * UIProcess/ios/WKContentViewInteraction.mm:
     17        (-[WKContentView textInputTraits]):
     18        * WebProcess/WebPage/ios/WebPageIOS.mm:
     19        (WebKit::WebPage::getFocusedElementInformation):
     20
    1212019-06-11  Carlos Garcia Campos  <cgarcia@igalia.com>
    222
  • trunk/Source/WebKit/Shared/FocusedElementInformation.cpp

    r246226 r246311  
    106106#endif
    107107    encoder << shouldSynthesizeKeyEventsForEditing;
     108    encoder << isSpellCheckingEnabled;
    108109}
    109110
     
    227228        return false;
    228229
     230    if (!decoder.decode(result.isSpellCheckingEnabled))
     231        return false;
     232
    229233    return true;
    230234}
  • trunk/Source/WebKit/Shared/FocusedElementInformation.h

    r246226 r246311  
    138138#endif
    139139    bool shouldSynthesizeKeyEventsForEditing { false };
     140    bool isSpellCheckingEnabled { true };
    140141
    141142    FocusedElementIdentifier focusedElementIdentifier { 0 };
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r246300 r246311  
    43854385    }
    43864386
     4387    if (!_focusedElementInformation.isSpellCheckingEnabled) {
     4388        [_traits setSmartQuotesType:UITextSmartQuotesTypeNo];
     4389        [_traits setSmartDashesType:UITextSmartDashesTypeNo];
     4390    }
     4391
    43874392    switch (_focusedElementInformation.inputMode) {
    43884393    case WebCore::InputMode::None:
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r246276 r246311  
    27672767        information.elementRect = IntRect();
    27682768
     2769    if (is<HTMLElement>(m_focusedElement))
     2770        information.isSpellCheckingEnabled = downcast<HTMLElement>(*m_focusedElement).spellcheck();
     2771
    27692772    information.minimumScaleFactor = minimumPageScaleFactor();
    27702773    information.maximumScaleFactor = maximumPageScaleFactor();
  • trunk/Tools/ChangeLog

    r246307 r246311  
     12019-06-11  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Quotes are always inserted as smart quotes on stackblitz.com, causing compilation errors
     4        https://bugs.webkit.org/show_bug.cgi?id=198735
     5        <rdar://problem/51557159>
     6
     7        Reviewed by Megan Gardner.
     8
     9        Add a test to verify that spellcheck="false" disables smart quotes and dashes, but any other value defers to the
     10        user's preferences by using UITextSmartQuotesTypeDefault and UITextSmartDashesTypeDefault.
     11
     12        * TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm:
     13        (TestWebKitAPI::TEST):
     14
    1152019-06-11  Tadeu Zagallo  <tzagallo@apple.com>
    216
  • trunk/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm

    r246229 r246311  
    474474}
    475475
     476TEST(KeyboardInputTests, DisableSmartQuotesAndDashes)
     477{
     478    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
     479    auto inputDelegate = adoptNS([[TestInputDelegate alloc] init]);
     480    [inputDelegate setFocusStartsInputSessionPolicyHandler:[&] (WKWebView *, id <_WKFocusedElementInfo>) -> _WKFocusStartsInputSessionPolicy {
     481        return _WKFocusStartsInputSessionPolicyAllow;
     482    }];
     483    [webView _setInputDelegate:inputDelegate.get()];
     484
     485    auto checkSmartQuotesAndDashesType = [&] (UITextSmartDashesType dashesType, UITextSmartQuotesType quotesType) {
     486        UITextInputTraits *traits = [[webView textInputContentView] textInputTraits];
     487        EXPECT_EQ(dashesType, traits.smartDashesType);
     488        EXPECT_EQ(quotesType, traits.smartQuotesType);
     489    };
     490
     491    [webView synchronouslyLoadHTMLString:@"<div id='foo' contenteditable spellcheck='false'></div><textarea id='bar' spellcheck='false'></textarea><input id='baz' spellcheck='false'>"];
     492    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"foo.focus()"];
     493    checkSmartQuotesAndDashesType(UITextSmartDashesTypeNo, UITextSmartQuotesTypeNo);
     494    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"bar.focus()"];
     495    checkSmartQuotesAndDashesType(UITextSmartDashesTypeNo, UITextSmartQuotesTypeNo);
     496    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"baz.focus()"];
     497    checkSmartQuotesAndDashesType(UITextSmartDashesTypeNo, UITextSmartQuotesTypeNo);
     498
     499    [webView synchronouslyLoadHTMLString:@"<div id='foo' contenteditable></div><textarea id='bar' spellcheck='true'></textarea><input id='baz'>"];
     500    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"foo.focus()"];
     501    checkSmartQuotesAndDashesType(UITextSmartDashesTypeDefault, UITextSmartQuotesTypeDefault);
     502    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"bar.focus()"];
     503    checkSmartQuotesAndDashesType(UITextSmartDashesTypeDefault, UITextSmartQuotesTypeDefault);
     504    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"baz.focus()"];
     505    checkSmartQuotesAndDashesType(UITextSmartDashesTypeDefault, UITextSmartQuotesTypeDefault);
     506}
     507
    476508} // namespace TestWebKitAPI
    477509
Note: See TracChangeset for help on using the changeset viewer.