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

Changeset 243519 in webkit


Ignore:
Timestamp:
Mar 26, 2019, 2:15:16 PM (7 years ago)
Author:
Wenson Hsieh
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:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r243511 r243519  
     12019-03-26  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Implement async paste method on UIWKInteractionViewProtocol
     4        https://bugs.webkit.org/show_bug.cgi?id=196267
     5        <rdar://problem/49236346>
     6
     7        Reviewed by Tim Horton.
     8
     9        Implement a new UIWKInteractionViewProtocol hook to perform a paste command, and invoke the given completion
     10        handler when pasting is finished.
     11
     12        Test: UIPasteboardTests.PasteWithCompletionHandler
     13
     14        * UIProcess/ios/WKContentViewInteraction.mm:
     15        (-[WKContentView pasteWithCompletionHandler:]):
     16
    1172019-03-26  Per Arne Vollan  <pvollan@apple.com>
    218
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r243454 r243519  
    23832383}
    23842384
     2385- (void)pasteWithCompletionHandler:(void (^)(void))completionHandler
     2386{
     2387    _page->executeEditCommand("Paste"_s, { }, [completion = makeBlockPtr(completionHandler)] (auto) {
     2388        if (completion)
     2389            completion();
     2390    });
     2391}
     2392
    23852393- (void)clearSelection
    23862394{
  • trunk/Tools/ChangeLog

    r243518 r243519  
     12019-03-26  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Implement async paste method on UIWKInteractionViewProtocol
     4        https://bugs.webkit.org/show_bug.cgi?id=196267
     5        <rdar://problem/49236346>
     6
     7        Reviewed by Tim Horton.
     8
     9        Add a new test to exercise the new SPI. Additionally, add staging forward declarations for
     10        -pasteWithCompletionHandler:, and remove some old existing staging declarations for other bits of UIKit SPI that
     11        are now a part of all iOS 12 internal SDKs.
     12
     13        * TestWebKitAPI/Tests/ios/UIPasteboardTests.mm:
     14
     15        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
     16        prior to 12, these version checks are effectively only about iOS vs. tvOS or watchOS).
     17
     18        * TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm:
     19        * TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm:
     20        (-[DragAndDropSimulator _sendQueuedAdditionalItemRequest]):
     21        * TestWebKitAPI/ios/UIKitSPI.h:
     22
    1232019-03-26  Aakash Jain  <aakash_jain@apple.com>
    224
  • trunk/Tools/TestWebKitAPI/Tests/ios/UIPasteboardTests.mm

    r242339 r243519  
    3939typedef void (^DataLoadCompletionBlock)(NSData *, NSError *);
    4040
    41 #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110300
     41#if PLATFORM(IOS)
    4242
    4343static void checkJSONWithLogging(NSString *jsonString, NSDictionary *expected)
     
    4949}
    5050
    51 #endif // __IPHONE_OS_VERSION_MIN_REQUIRED >= 110300
     51#endif // PLATFORM(IOS)
    5252
    5353namespace TestWebKitAPI {
     
    146146}
    147147
    148 #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110300
     148TEST(UIPasteboardTests, PasteWithCompletionHandler)
     149{
     150    auto webView = setUpWebViewForPasteboardTests(@"DataTransfer");
     151    [UIPasteboard generalPasteboard].URL = [NSURL URLWithString:@"https://www.apple.com/"];
     152
     153    bool done = false;
     154    [(id <UIWKInteractionViewProtocol_Staging_49236384>)[webView textInputContentView] pasteWithCompletionHandler:[webView, &done] {
     155        [UIPasteboard generalPasteboard].items = @[ ];
     156        done = true;
     157    }];
     158
     159    Util::run(&done);
     160
     161    EXPECT_WK_STREQ("text/uri-list, text/plain", [webView stringByEvaluatingJavaScript:@"types.textContent"]);
     162    EXPECT_WK_STREQ("(STRING, text/uri-list), (STRING, text/plain)", [webView stringByEvaluatingJavaScript:@"items.textContent"]);
     163    EXPECT_WK_STREQ("https://www.apple.com/", [webView stringByEvaluatingJavaScript:@"urlData.textContent"]);
     164    EXPECT_WK_STREQ("https://www.apple.com/", [webView stringByEvaluatingJavaScript:@"textData.textContent"]);
     165}
     166
     167#if PLATFORM(IOS)
    149168
    150169TEST(UIPasteboardTests, DataTransferGetDataWhenPastingURL)
     
    284303}
    285304
    286 #endif // __IPHONE_OS_VERSION_MIN_REQUIRED >= 110300
     305#endif // PLATFORM(IOS)
    287306
    288307} // namespace TestWebKitAPI
  • trunk/Tools/TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm

    r242339 r243519  
    3636#import <wtf/BlockPtr.h>
    3737
    38 typedef UIView <UITextInputTraits_Private_Proposed_SPI_34583628> AutofillInputView;
     38typedef UIView <UITextInputPrivate> AutofillInputView;
    3939
    4040@interface AutofillTestView : TestWKWebView
  • trunk/Tools/TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm

    r242339 r243519  
    505505
    506506    auto requestLocation = [[_webView window] convertPoint:[requestLocationValue CGPointValue] toView:_webView.get()];
    507     [(id <UIDragInteractionDelegate_Proposed_SPI_33146803>)[_webView dragInteractionDelegate] _dragInteraction:[_webView dragInteraction] itemsForAddingToSession:_dragSession.get() withTouchAtPoint:requestLocation completion:[dragSession = _dragSession, dropSession = _dropSession] (NSArray *items) {
     507    [(id <UIDragInteractionDelegate_ForWebKitOnly>)[_webView dragInteractionDelegate] _dragInteraction:[_webView dragInteraction] itemsForAddingToSession:_dragSession.get() withTouchAtPoint:requestLocation completion:[dragSession = _dragSession, dropSession = _dropSession] (NSArray *items) {
    508508        [dragSession addItems:items];
    509509        [dropSession addItems:items];
  • trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h

    r243370 r243519  
    4040#import <UIKit/UIWKTextInteractionAssistant.h>
    4141
    42 #if ENABLE(DRAG_SUPPORT)
     42#if PLATFORM(IOS)
    4343@protocol UIDragSession;
    4444@class UIDragInteraction;
     
    4646#import <UIKit/NSItemProvider+UIKitAdditions_Private.h>
    4747#import <UIKit/UIDragInteraction_Private.h>
    48 #endif // ENABLE(DRAG_SUPPORT)
     48#endif // PLATFORM(IOS)
    4949
    5050#else
     
    6666@optional
    6767- (void)_dragInteraction:(UIDragInteraction *)interaction prepareForSession:(id<UIDragSession>)session completion:(void(^)(void))completion;
     68- (void)_dragInteraction:(UIDragInteraction *)interaction itemsForAddingToSession:(id <UIDragSession>)session withTouchAtPoint:(CGPoint)point completion:(void(^)(NSArray<UIDragItem *> *))completion;
    6869@end
    6970
     
    8081- (void)handleKeyWebEvent:(WebEvent *)theEvent withCompletionHandler:(void (^)(WebEvent *, BOOL))completionHandler;
    8182- (BOOL)_shouldSuppressSelectionCommands;
     83- (NSDictionary *)_autofillContext;
    8284@end
    8385
     
    134136#endif
    135137
    136 @protocol UITextInputTraits_Private_Proposed_SPI_34583628 <UITextInputPrivate>
    137 - (NSDictionary *)_autofillContext;
    138 @end
    139 
    140 #if ENABLE(DRAG_SUPPORT)
    141 @protocol UIDragInteractionDelegate_Proposed_SPI_33146803 <UIDragInteractionDelegate>
    142 - (void)_dragInteraction:(UIDragInteraction *)interaction itemsForAddingToSession:(id <UIDragSession>)session withTouchAtPoint:(CGPoint)point completion:(void(^)(NSArray<UIDragItem *> *))completion;
    143 @end
    144 #endif
    145 
    146138#if __has_include(<UIKit/UITextAutofillSuggestion.h>)
    147139// FIXME: Move this import under USE(APPLE_INTERNAL_SDK) once <rdar://problem/34583628> lands in the SDK.
     
    175167@end
    176168
     169@protocol UIWKInteractionViewProtocol_Staging_49236384
     170- (void)pasteWithCompletionHandler:(void (^)(void))completionHandler;
     171@end
     172
    177173#endif // PLATFORM(IOS_FAMILY)
Note: See TracChangeset for help on using the changeset viewer.