Changeset 248487 in webkit


Ignore:
Timestamp:
Aug 9, 2019 4:06:19 PM (5 years ago)
Author:
Wenson Hsieh
Message:

[iOS 13] Google Docs/Slides/Sheets: paste often doesn't work and sometimes produces an error
https://bugs.webkit.org/show_bug.cgi?id=200591
<rdar://problem/54102238>

Reviewed by Ryosuke Niwa and Tim Horton.

Source/WebKit:

Adopts UIKit SPI to avoid incrementing the general pasteboard's change count whenever an editable element is
focused. This is due to how, in iOS 13, UIKit temporarily writes an image to the pasteboard when showing the
keyboard, to determine whether or not to show the Memojis in the input view.

This causes UIPasteboard's changeCount to increment twice due to adding and then removing the image, which means
that the changeCount sanity checks in the web process will race against the pasteboard gaining and then losing
this temporary image.

Instead, the new -supportsImagePaste SPI may be used to short-circuit this step, and avoid updating the
changeCount when UIKeyboardImpl's delegate changes.

  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView supportsImagePaste]):

Tools:

Add a new API test to exercise -supportsImagePaste.

  • TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm:

(TestWebKitAPI::TEST):

  • TestWebKitAPI/ios/UIKitSPI.h:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r248486 r248487  
     12019-08-09  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iOS 13] Google Docs/Slides/Sheets: paste often doesn't work and sometimes produces an error
     4        https://bugs.webkit.org/show_bug.cgi?id=200591
     5        <rdar://problem/54102238>
     6
     7        Reviewed by Ryosuke Niwa and Tim Horton.
     8
     9        Adopts UIKit SPI to avoid incrementing the general pasteboard's change count whenever an editable element is
     10        focused. This is due to how, in iOS 13, UIKit temporarily writes an image to the pasteboard when showing the
     11        keyboard, to determine whether or not to show the Memojis in the input view.
     12
     13        This causes UIPasteboard's changeCount to increment twice due to adding and then removing the image, which means
     14        that the changeCount sanity checks in the web process will race against the pasteboard gaining and then losing
     15        this temporary image.
     16
     17        Instead, the new -supportsImagePaste SPI may be used to short-circuit this step, and avoid updating the
     18        changeCount when UIKeyboardImpl's delegate changes.
     19
     20        * UIProcess/ios/WKContentViewInteraction.mm:
     21        (-[WKContentView supportsImagePaste]):
     22
    1232019-08-09  Alex Christensen  <achristensen@webkit.org>
    224
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r248481 r248487  
    68396839}
    68406840
     6841- (BOOL)supportsImagePaste
     6842{
     6843    return mayContainSelectableText(_focusedElementInformation.elementType);
     6844}
     6845
    68416846#if HAVE(UI_WK_DOCUMENT_CONTEXT)
    68426847
  • trunk/Tools/ChangeLog

    r248475 r248487  
     12019-08-09  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iOS 13] Google Docs/Slides/Sheets: paste often doesn't work and sometimes produces an error
     4        https://bugs.webkit.org/show_bug.cgi?id=200591
     5        <rdar://problem/54102238>
     6
     7        Reviewed by Ryosuke Niwa and Tim Horton.
     8
     9        Add a new API test to exercise -supportsImagePaste.
     10
     11        * TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm:
     12        (TestWebKitAPI::TEST):
     13        * TestWebKitAPI/ios/UIKitSPI.h:
     14
    1152019-08-09  Aakash Jain  <aakash_jain@apple.com>
    216
  • trunk/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm

    r247804 r248487  
    556556}
    557557
     558TEST(KeyboardInputTests, SupportsImagePaste)
     559{
     560    auto inputDelegate = adoptNS([[TestInputDelegate alloc] init]);
     561    [inputDelegate setFocusStartsInputSessionPolicyHandler:[&] (WKWebView *, id <_WKFocusedElementInfo>) -> _WKFocusStartsInputSessionPolicy {
     562        return _WKFocusStartsInputSessionPolicyAllow;
     563    }];
     564
     565    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 568)]);
     566    auto contentView = (id <UITextInputPrivate_Staging_54140418>)[webView textInputContentView];
     567    [webView synchronouslyLoadHTMLString:@"<input id='input'></input><div contenteditable id='editor'></div><textarea id='textarea'></textarea>"];
     568    [webView _setInputDelegate:inputDelegate.get()];
     569
     570    [webView stringByEvaluatingJavaScript:@"input.focus()"];
     571    EXPECT_TRUE(contentView.supportsImagePaste);
     572
     573    [webView stringByEvaluatingJavaScript:@"document.activeElement.blur(); input.type = 'date'"];
     574    [webView waitForNextPresentationUpdate];
     575    [webView stringByEvaluatingJavaScript:@"input.focus()"];
     576    EXPECT_FALSE(contentView.supportsImagePaste);
     577
     578    [webView stringByEvaluatingJavaScript:@"editor.focus()"];
     579    EXPECT_TRUE(contentView.supportsImagePaste);
     580
     581    [webView stringByEvaluatingJavaScript:@"document.activeElement.blur(); input.type = 'color'"];
     582    [webView waitForNextPresentationUpdate];
     583    [webView stringByEvaluatingJavaScript:@"input.focus()"];
     584    EXPECT_FALSE(contentView.supportsImagePaste);
     585
     586    [webView stringByEvaluatingJavaScript:@"textarea.focus()"];
     587    EXPECT_TRUE(contentView.supportsImagePaste);
     588}
     589
    558590} // namespace TestWebKitAPI
    559591
  • trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h

    r248186 r248487  
    218218@end
    219219
     220@protocol UITextInputPrivate_Staging_54140418 <UITextInputPrivate>
     221@property (nonatomic, readonly) BOOL supportsImagePaste;
     222@end
     223
    220224@interface UIWebFormAccessory (Staging_49666643)
    221225- (void)setNextPreviousItemsVisible:(BOOL)visible;
Note: See TracChangeset for help on using the changeset viewer.