Title: [248487] trunk
Revision
248487
Author
wenson_hs...@apple.com
Date
2019-08-09 16:06:19 -0700 (Fri, 09 Aug 2019)

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

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (248486 => 248487)


--- trunk/Source/WebKit/ChangeLog	2019-08-09 22:58:47 UTC (rev 248486)
+++ trunk/Source/WebKit/ChangeLog	2019-08-09 23:06:19 UTC (rev 248487)
@@ -1,3 +1,25 @@
+2019-08-09  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [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-09  Alex Christensen  <achristen...@webkit.org>
 
         Remove unused Connection::sendWithReply

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (248486 => 248487)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-08-09 22:58:47 UTC (rev 248486)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-08-09 23:06:19 UTC (rev 248487)
@@ -6838,6 +6838,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: trunk/Tools/ChangeLog (248486 => 248487)


--- trunk/Tools/ChangeLog	2019-08-09 22:58:47 UTC (rev 248486)
+++ trunk/Tools/ChangeLog	2019-08-09 23:06:19 UTC (rev 248487)
@@ -1,3 +1,17 @@
+2019-08-09  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [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-09  Aakash Jain  <aakash_j...@apple.com>
 
         Follow-up commit to r248474 as webkit-patch did not commit the svn property changes.

Modified: trunk/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm (248486 => 248487)


--- trunk/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm	2019-08-09 22:58:47 UTC (rev 248486)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm	2019-08-09 23:06:19 UTC (rev 248487)
@@ -555,6 +555,38 @@
     EXPECT_TRUE([[actual allValues] containsObject:expected]);
 }
 
+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: trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h (248486 => 248487)


--- trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h	2019-08-09 22:58:47 UTC (rev 248486)
+++ trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h	2019-08-09 23:06:19 UTC (rev 248487)
@@ -217,6 +217,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
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to