Title: [243519] trunk
Revision
243519
Author
wenson_hs...@apple.com
Date
2019-03-26 14:15:16 -0700 (Tue, 26 Mar 2019)

Log Message

Implement async paste method on UIWKInteractionViewProtocol
https://bugs.webkit.org/show_bug.cgi?id=196267
<rdar://problem/49236346>

Reviewed by Tim Horton.

Source/WebKit:

Implement a new UIWKInteractionViewProtocol hook to perform a paste command, and invoke the given completion
handler when pasting is finished.

Test: UIPasteboardTests.PasteWithCompletionHandler

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView pasteWithCompletionHandler:]):

Tools:

Add a new test to exercise the new SPI. Additionally, add staging forward declarations for
-pasteWithCompletionHandler:, and remove some old existing staging declarations for other bits of UIKit SPI that
are now a part of all iOS 12 internal SDKs.

* TestWebKitAPI/Tests/ios/UIPasteboardTests.mm:

While we're here, also change a few iOS 11.3 checks to just be about PLATFORM(IOS) (since we don't build for iOS
prior to 12, these version checks are effectively only about iOS vs. tvOS or watchOS).

* TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm:
* TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm:
(-[DragAndDropSimulator _sendQueuedAdditionalItemRequest]):
* TestWebKitAPI/ios/UIKitSPI.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (243518 => 243519)


--- trunk/Source/WebKit/ChangeLog	2019-03-26 21:04:53 UTC (rev 243518)
+++ trunk/Source/WebKit/ChangeLog	2019-03-26 21:15:16 UTC (rev 243519)
@@ -1,3 +1,19 @@
+2019-03-26  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        Implement async paste method on UIWKInteractionViewProtocol
+        https://bugs.webkit.org/show_bug.cgi?id=196267
+        <rdar://problem/49236346>
+
+        Reviewed by Tim Horton.
+
+        Implement a new UIWKInteractionViewProtocol hook to perform a paste command, and invoke the given completion
+        handler when pasting is finished.
+
+        Test: UIPasteboardTests.PasteWithCompletionHandler
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView pasteWithCompletionHandler:]):
+
 2019-03-26  Per Arne Vollan  <pvol...@apple.com>
 
         [macOS] Fix sandbox violations

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (243518 => 243519)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-03-26 21:04:53 UTC (rev 243518)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2019-03-26 21:15:16 UTC (rev 243519)
@@ -2382,6 +2382,14 @@
     }
 }
 
+- (void)pasteWithCompletionHandler:(void (^)(void))completionHandler
+{
+    _page->executeEditCommand("Paste"_s, { }, [completion = makeBlockPtr(completionHandler)] (auto) {
+        if (completion)
+            completion();
+    });
+}
+
 - (void)clearSelection
 {
     [self _elementDidBlur];

Modified: trunk/Tools/ChangeLog (243518 => 243519)


--- trunk/Tools/ChangeLog	2019-03-26 21:04:53 UTC (rev 243518)
+++ trunk/Tools/ChangeLog	2019-03-26 21:15:16 UTC (rev 243519)
@@ -1,3 +1,25 @@
+2019-03-26  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        Implement async paste method on UIWKInteractionViewProtocol
+        https://bugs.webkit.org/show_bug.cgi?id=196267
+        <rdar://problem/49236346>
+
+        Reviewed by Tim Horton.
+
+        Add a new test to exercise the new SPI. Additionally, add staging forward declarations for
+        -pasteWithCompletionHandler:, and remove some old existing staging declarations for other bits of UIKit SPI that
+        are now a part of all iOS 12 internal SDKs.
+
+        * TestWebKitAPI/Tests/ios/UIPasteboardTests.mm:
+
+        While we're here, also change a few iOS 11.3 checks to just be about PLATFORM(IOS) (since we don't build for iOS
+        prior to 12, these version checks are effectively only about iOS vs. tvOS or watchOS).
+
+        * TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm:
+        * TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm:
+        (-[DragAndDropSimulator _sendQueuedAdditionalItemRequest]):
+        * TestWebKitAPI/ios/UIKitSPI.h:
+
 2019-03-26  Aakash Jain  <aakash_j...@apple.com>
 
         [ews-build] Use PostgreSQL for ews.webkit.org database

Modified: trunk/Tools/TestWebKitAPI/Tests/ios/UIPasteboardTests.mm (243518 => 243519)


--- trunk/Tools/TestWebKitAPI/Tests/ios/UIPasteboardTests.mm	2019-03-26 21:04:53 UTC (rev 243518)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/UIPasteboardTests.mm	2019-03-26 21:15:16 UTC (rev 243519)
@@ -38,7 +38,7 @@
 
 typedef void (^DataLoadCompletionBlock)(NSData *, NSError *);
 
-#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110300
+#if PLATFORM(IOS)
 
 static void checkJSONWithLogging(NSString *jsonString, NSDictionary *expected)
 {
@@ -48,7 +48,7 @@
         NSLog(@"Expected JSON: %@ to match values: %@", jsonString, expected);
 }
 
-#endif // __IPHONE_OS_VERSION_MIN_REQUIRED >= 110300
+#endif // PLATFORM(IOS)
 
 namespace TestWebKitAPI {
 
@@ -145,8 +145,27 @@
     EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"!!rich.querySelector('a')"].boolValue);
 }
 
-#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110300
+TEST(UIPasteboardTests, PasteWithCompletionHandler)
+{
+    auto webView = setUpWebViewForPasteboardTests(@"DataTransfer");
+    [UIPasteboard generalPasteboard].URL = "" URLWithString:@"https://www.apple.com/"];
 
+    bool done = false;
+    [(id <UIWKInteractionViewProtocol_Staging_49236384>)[webView textInputContentView] pasteWithCompletionHandler:[webView, &done] {
+        [UIPasteboard generalPasteboard].items = @[ ];
+        done = true;
+    }];
+
+    Util::run(&done);
+
+    EXPECT_WK_STREQ("text/uri-list, text/plain", [webView stringByEvaluatingJavaScript:@"types.textContent"]);
+    EXPECT_WK_STREQ("(STRING, text/uri-list), (STRING, text/plain)", [webView stringByEvaluatingJavaScript:@"items.textContent"]);
+    EXPECT_WK_STREQ("https://www.apple.com/", [webView stringByEvaluatingJavaScript:@"urlData.textContent"]);
+    EXPECT_WK_STREQ("https://www.apple.com/", [webView stringByEvaluatingJavaScript:@"textData.textContent"]);
+}
+
+#if PLATFORM(IOS)
+
 TEST(UIPasteboardTests, DataTransferGetDataWhenPastingURL)
 {
     auto webView = setUpWebViewForPasteboardTests(@"dump-datatransfer-types");
@@ -283,7 +302,7 @@
     EXPECT_WK_STREQ("https://www.apple.com/", [webView stringByEvaluatingJavaScript:@"textData.textContent"]);
 }
 
-#endif // __IPHONE_OS_VERSION_MIN_REQUIRED >= 110300
+#endif // PLATFORM(IOS)
 
 } // namespace TestWebKitAPI
 

Modified: trunk/Tools/TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm (243518 => 243519)


--- trunk/Tools/TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm	2019-03-26 21:04:53 UTC (rev 243518)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm	2019-03-26 21:15:16 UTC (rev 243519)
@@ -35,7 +35,7 @@
 #import <WebKit/WKWebViewPrivate.h>
 #import <wtf/BlockPtr.h>
 
-typedef UIView <UITextInputTraits_Private_Proposed_SPI_34583628> AutofillInputView;
+typedef UIView <UITextInputPrivate> AutofillInputView;
 
 @interface AutofillTestView : TestWKWebView
 @end

Modified: trunk/Tools/TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm (243518 => 243519)


--- trunk/Tools/TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm	2019-03-26 21:04:53 UTC (rev 243518)
+++ trunk/Tools/TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm	2019-03-26 21:15:16 UTC (rev 243519)
@@ -504,7 +504,7 @@
     [_queuedAdditionalItemRequestLocations removeObjectAtIndex:0];
 
     auto requestLocation = [[_webView window] convertPoint:[requestLocationValue CGPointValue] toView:_webView.get()];
-    [(id <UIDragInteractionDelegate_Proposed_SPI_33146803>)[_webView dragInteractionDelegate] _dragInteraction:[_webView dragInteraction] itemsForAddingToSession:_dragSession.get() withTouchAtPoint:requestLocation completion:[dragSession = _dragSession, dropSession = _dropSession] (NSArray *items) {
+    [(id <UIDragInteractionDelegate_ForWebKitOnly>)[_webView dragInteractionDelegate] _dragInteraction:[_webView dragInteraction] itemsForAddingToSession:_dragSession.get() withTouchAtPoint:requestLocation completion:[dragSession = _dragSession, dropSession = _dropSession] (NSArray *items) {
         [dragSession addItems:items];
         [dropSession addItems:items];
     }];

Modified: trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h (243518 => 243519)


--- trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h	2019-03-26 21:04:53 UTC (rev 243518)
+++ trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h	2019-03-26 21:15:16 UTC (rev 243519)
@@ -39,13 +39,13 @@
 #import <UIKit/UIViewController_Private.h>
 #import <UIKit/UIWKTextInteractionAssistant.h>
 
-#if ENABLE(DRAG_SUPPORT)
+#if PLATFORM(IOS)
 @protocol UIDragSession;
 @class UIDragInteraction;
 @class UIDragItem;
 #import <UIKit/NSItemProvider+UIKitAdditions_Private.h>
 #import <UIKit/UIDragInteraction_Private.h>
-#endif // ENABLE(DRAG_SUPPORT)
+#endif // PLATFORM(IOS)
 
 #else
 
@@ -65,6 +65,7 @@
 @protocol UIDragInteractionDelegate_ForWebKitOnly <UIDragInteractionDelegate>
 @optional
 - (void)_dragInteraction:(UIDragInteraction *)interaction prepareForSession:(id<UIDragSession>)session completion:(void(^)(void))completion;
+- (void)_dragInteraction:(UIDragInteraction *)interaction itemsForAddingToSession:(id <UIDragSession>)session withTouchAtPoint:(CGPoint)point completion:(void(^)(NSArray<UIDragItem *> *))completion;
 @end
 
 @protocol UITextInputTraits_Private <NSObject, UITextInputTraits>
@@ -79,6 +80,7 @@
 - (void)insertTextSuggestion:(UITextSuggestion *)textSuggestion;
 - (void)handleKeyWebEvent:(WebEvent *)theEvent withCompletionHandler:(void (^)(WebEvent *, BOOL))completionHandler;
 - (BOOL)_shouldSuppressSelectionCommands;
+- (NSDictionary *)_autofillContext;
 @end
 
 @protocol UITextInputMultiDocument <NSObject>
@@ -133,16 +135,6 @@
 
 #endif
 
-@protocol UITextInputTraits_Private_Proposed_SPI_34583628 <UITextInputPrivate>
-- (NSDictionary *)_autofillContext;
-@end
-
-#if ENABLE(DRAG_SUPPORT)
-@protocol UIDragInteractionDelegate_Proposed_SPI_33146803 <UIDragInteractionDelegate>
-- (void)_dragInteraction:(UIDragInteraction *)interaction itemsForAddingToSession:(id <UIDragSession>)session withTouchAtPoint:(CGPoint)point completion:(void(^)(NSArray<UIDragItem *> *))completion;
-@end
-#endif
-
 #if __has_include(<UIKit/UITextAutofillSuggestion.h>)
 // FIXME: Move this import under USE(APPLE_INTERNAL_SDK) once <rdar://problem/34583628> lands in the SDK.
 #import <UIKit/UITextAutofillSuggestion.h>
@@ -174,4 +166,8 @@
 + (BOOL)isInHardwareKeyboardMode;
 @end
 
+@protocol UIWKInteractionViewProtocol_Staging_49236384
+- (void)pasteWithCompletionHandler:(void (^)(void))completionHandler;
+@end
+
 #endif // PLATFORM(IOS_FAMILY)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to