Title: [248620] branches/safari-608-branch
Revision
248620
Author
[email protected]
Date
2019-08-13 13:01:15 -0700 (Tue, 13 Aug 2019)

Log Message

Cherry-pick r248487. rdar://problem/54237679

    [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:

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

Modified Paths

Diff

Modified: branches/safari-608-branch/Source/WebKit/ChangeLog (248619 => 248620)


--- branches/safari-608-branch/Source/WebKit/ChangeLog	2019-08-13 20:01:12 UTC (rev 248619)
+++ branches/safari-608-branch/Source/WebKit/ChangeLog	2019-08-13 20:01:15 UTC (rev 248620)
@@ -1,5 +1,63 @@
 2019-08-13  Alan Coon  <[email protected]>
 
+        Cherry-pick r248487. rdar://problem/54237679
+
+    [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:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248487 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-08-09  Wenson Hsieh  <[email protected]>
+
+            [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.
+
+            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]):
+
+2019-08-13  Alan Coon  <[email protected]>
+
         Cherry-pick r248433. rdar://problem/54237689
 
     [iOS 13] Taps that interrupt momentum scrolling are recognized as clicks

Modified: branches/safari-608-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (248619 => 248620)


--- branches/safari-608-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-08-13 20:01:12 UTC (rev 248619)
+++ branches/safari-608-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-08-13 20:01:15 UTC (rev 248620)
@@ -6840,6 +6840,11 @@
     return nil;
 }
 
+- (BOOL)supportsImagePaste
+{
+    return mayContainSelectableText(_focusedElementInformation.elementType);
+}
+
 #if HAVE(UI_WK_DOCUMENT_CONTEXT)
 
 static inline OptionSet<WebKit::DocumentEditingContextRequest::Options> toWebDocumentRequestOptions(UIWKDocumentRequestFlags flags)

Modified: branches/safari-608-branch/Tools/ChangeLog (248619 => 248620)


--- branches/safari-608-branch/Tools/ChangeLog	2019-08-13 20:01:12 UTC (rev 248619)
+++ branches/safari-608-branch/Tools/ChangeLog	2019-08-13 20:01:15 UTC (rev 248620)
@@ -1,5 +1,55 @@
 2019-08-13  Alan Coon  <[email protected]>
 
+        Cherry-pick r248487. rdar://problem/54237679
+
+    [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:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248487 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-08-09  Wenson Hsieh  <[email protected]>
+
+            [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.
+
+            Add a new API test to exercise -supportsImagePaste.
+
+            * TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm:
+            (TestWebKitAPI::TEST):
+            * TestWebKitAPI/ios/UIKitSPI.h:
+
+2019-08-13  Alan Coon  <[email protected]>
+
         Cherry-pick r248281. rdar://problem/54237787
 
     iOS 13: Overflow:hidden on body prevents PDF scroll

Modified: branches/safari-608-branch/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm (248619 => 248620)


--- branches/safari-608-branch/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm	2019-08-13 20:01:12 UTC (rev 248619)
+++ branches/safari-608-branch/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm	2019-08-13 20:01:15 UTC (rev 248620)
@@ -527,6 +527,38 @@
     EXPECT_EQ(20, selectionClipRect.size.height);
 }
 
+TEST(KeyboardInputTests, SupportsImagePaste)
+{
+    auto inputDelegate = adoptNS([[TestInputDelegate alloc] init]);
+    [inputDelegate setFocusStartsInputSessionPolicyHandler:[&] (WKWebView *, id <_WKFocusedElementInfo>) -> _WKFocusStartsInputSessionPolicy {
+        return _WKFocusStartsInputSessionPolicyAllow;
+    }];
+
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 568)]);
+    auto contentView = (id <UITextInputPrivate_Staging_54140418>)[webView textInputContentView];
+    [webView synchronouslyLoadHTMLString:@"<input id='input'></input><div contenteditable id='editor'></div><textarea id='textarea'></textarea>"];
+    [webView _setInputDelegate:inputDelegate.get()];
+
+    [webView stringByEvaluatingJavaScript:@"input.focus()"];
+    EXPECT_TRUE(contentView.supportsImagePaste);
+
+    [webView stringByEvaluatingJavaScript:@"document.activeElement.blur(); input.type = 'date'"];
+    [webView waitForNextPresentationUpdate];
+    [webView stringByEvaluatingJavaScript:@"input.focus()"];
+    EXPECT_FALSE(contentView.supportsImagePaste);
+
+    [webView stringByEvaluatingJavaScript:@"editor.focus()"];
+    EXPECT_TRUE(contentView.supportsImagePaste);
+
+    [webView stringByEvaluatingJavaScript:@"document.activeElement.blur(); input.type = 'color'"];
+    [webView waitForNextPresentationUpdate];
+    [webView stringByEvaluatingJavaScript:@"input.focus()"];
+    EXPECT_FALSE(contentView.supportsImagePaste);
+
+    [webView stringByEvaluatingJavaScript:@"textarea.focus()"];
+    EXPECT_TRUE(contentView.supportsImagePaste);
+}
+
 } // namespace TestWebKitAPI
 
 #endif // PLATFORM(IOS_FAMILY)

Modified: branches/safari-608-branch/Tools/TestWebKitAPI/ios/UIKitSPI.h (248619 => 248620)


--- branches/safari-608-branch/Tools/TestWebKitAPI/ios/UIKitSPI.h	2019-08-13 20:01:12 UTC (rev 248619)
+++ branches/safari-608-branch/Tools/TestWebKitAPI/ios/UIKitSPI.h	2019-08-13 20:01:15 UTC (rev 248620)
@@ -212,6 +212,10 @@
 - (void)pasteWithCompletionHandler:(void (^)(void))completionHandler;
 @end
 
+@protocol UITextInputPrivate_Staging_54140418 <UITextInputPrivate>
+@property (nonatomic, readonly) BOOL supportsImagePaste;
+@end
+
 @interface UIWebFormAccessory (Staging_49666643)
 - (void)setNextPreviousItemsVisible:(BOOL)visible;
 @end
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to