Changeset 239039 in webkit
- Timestamp:
- Dec 10, 2018 12:27:59 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r239038 r239039 1 2018-12-10 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [iOS] Caret is obscured by finger when dragging over an editable element 4 https://bugs.webkit.org/show_bug.cgi?id=192499 5 <rdar://problem/46570101> 6 7 Reviewed by Tim Horton. 8 9 * page/DragActions.h: 10 11 Move DragHandlingMethod to DragActions.h, and drive-by fix some minor issues (i.e. make a couple of enum classes 12 use 8 bits, fix the indentation levels, and update the copyright year). Also add `EnumTraits` for 13 DragHandlingMethod so that it may be encoded over IPC. 14 15 * page/DragController.cpp: 16 (WebCore::dragIsHandledByDocument): 17 18 Simplify this helper function. 19 20 (WebCore::DragController::tryDocumentDrag): 21 * page/DragController.h: 22 23 Expose the current DragHandlingMethod via a const getter method. 24 25 (WebCore::DragController::dragHandlingMethod const): 26 1 27 2018-12-10 Youenn Fablet <youenn@apple.com> 2 28 -
trunk/Source/WebCore/page/DragActions.h
r234930 r239039 1 1 /* 2 * Copyright (C) 2007 , 2012Apple Inc. All rights reserved.2 * Copyright (C) 2007-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 27 27 28 28 #include <limits.h> 29 #include <wtf/Forward.h> 29 30 30 31 namespace WebCore { 31 32 32 // WebCoreDragDestinationAction should be kept in sync with WebDragDestinationAction 33 34 35 36 37 38 39 40 41 // WebCoreDragSourceAction should be kept in sync with WebDragSourceAction 42 43 44 45 46 47 33 // WebCoreDragDestinationAction should be kept in sync with WebDragDestinationAction. 34 typedef enum { 35 DragDestinationActionNone = 0, 36 DragDestinationActionDHTML = 1, 37 DragDestinationActionEdit = 2, 38 DragDestinationActionLoad = 4, 39 DragDestinationActionAny = UINT_MAX 40 } DragDestinationAction; 41 42 // WebCoreDragSourceAction should be kept in sync with WebDragSourceAction. 43 typedef enum { 44 DragSourceActionNone = 0, 45 DragSourceActionDHTML = 1, 46 DragSourceActionImage = 2, 47 DragSourceActionLink = 4, 48 DragSourceActionSelection = 8, 48 49 #if ENABLE(ATTACHMENT_ELEMENT) 49 50 DragSourceActionAttachment = 16, 50 51 #endif 51 52 #if ENABLE(INPUT_TYPE_COLOR) 52 53 DragSourceActionColor = 32, 53 54 #endif 54 DragSourceActionAny = UINT_MAX 55 } DragSourceAction; 56 57 //matches NSDragOperation 58 typedef enum { 59 DragOperationNone = 0, 60 DragOperationCopy = 1, 61 DragOperationLink = 2, 62 DragOperationGeneric = 4, 63 DragOperationPrivate = 8, 64 DragOperationMove = 16, 65 DragOperationDelete = 32, 66 DragOperationEvery = UINT_MAX 67 } DragOperation; 55 DragSourceActionAny = UINT_MAX 56 } DragSourceAction; 68 57 69 enum class MayExtendDragSession { No, Yes }; 70 enum class HasNonDefaultPasteboardData { No, Yes }; 71 58 // Matches NSDragOperation. 59 typedef enum { 60 DragOperationNone = 0, 61 DragOperationCopy = 1, 62 DragOperationLink = 2, 63 DragOperationGeneric = 4, 64 DragOperationPrivate = 8, 65 DragOperationMove = 16, 66 DragOperationDelete = 32, 67 DragOperationEvery = UINT_MAX 68 } DragOperation; 69 70 enum class MayExtendDragSession : bool { No, Yes }; 71 enum class HasNonDefaultPasteboardData : bool { No, Yes }; 72 enum class DragHandlingMethod : uint8_t { None, EditPlainText, EditRichText, UploadFile, PageLoad, SetColor, NonDefault }; 73 72 74 } // namespace WebCore 75 76 namespace WTF { 77 78 template<> struct EnumTraits<WebCore::DragHandlingMethod> { 79 using values = EnumValues< 80 WebCore::DragHandlingMethod, 81 WebCore::DragHandlingMethod::None, 82 WebCore::DragHandlingMethod::EditPlainText, 83 WebCore::DragHandlingMethod::EditRichText, 84 WebCore::DragHandlingMethod::UploadFile, 85 WebCore::DragHandlingMethod::PageLoad, 86 WebCore::DragHandlingMethod::SetColor, 87 WebCore::DragHandlingMethod::NonDefault 88 >; 89 }; 90 91 } // namespace WTF -
trunk/Source/WebCore/page/DragController.cpp
r238771 r239039 238 238 } 239 239 240 inline static bool dragIsHandledByDocument(DragController::DragHandlingMethod dragHandlingMethod) 241 { 242 if (dragHandlingMethod == DragController::DragHandlingMethod::None) 243 return false; 244 245 if (dragHandlingMethod == DragController::DragHandlingMethod::PageLoad) 246 return false; 247 248 return true; 240 inline static bool dragIsHandledByDocument(DragHandlingMethod dragHandlingMethod) 241 { 242 return dragHandlingMethod != DragHandlingMethod::None && dragHandlingMethod != DragHandlingMethod::PageLoad; 249 243 } 250 244 … … 386 380 #endif 387 381 388 Drag Controller::DragHandlingMethod DragController::tryDocumentDrag(const DragData& dragData, DragDestinationAction actionMask, DragOperation& dragOperation)382 DragHandlingMethod DragController::tryDocumentDrag(const DragData& dragData, DragDestinationAction actionMask, DragOperation& dragOperation) 389 383 { 390 384 if (!m_documentUnderMouse) -
trunk/Source/WebCore/page/DragController.h
r238771 r239039 79 79 const IntPoint& dragOffset() const { return m_dragOffset; } 80 80 DragSourceAction dragSourceAction() const { return m_dragSourceAction; } 81 DragHandlingMethod dragHandlingMethod() const { return m_dragHandlingMethod; } 81 82 82 enum class DragHandlingMethod { None, EditPlainText, EditRichText, UploadFile, PageLoad, SetColor, NonDefault };83 83 Document* documentUnderMouse() const { return m_documentUnderMouse.get(); } 84 84 DragDestinationAction dragDestinationAction() const { return m_dragDestinationAction; } … … 144 144 RefPtr<HTMLInputElement> m_fileInputElementUnderMouse; 145 145 unsigned m_numberOfItemsToBeAccepted; 146 DragHandlingMethod m_dragHandlingMethod ;146 DragHandlingMethod m_dragHandlingMethod { DragHandlingMethod::None }; 147 147 148 148 DragDestinationAction m_dragDestinationAction; -
trunk/Source/WebKit/ChangeLog
r239038 r239039 1 2018-12-10 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [iOS] Caret is obscured by finger when dragging over an editable element 4 https://bugs.webkit.org/show_bug.cgi?id=192499 5 <rdar://problem/46570101> 6 7 Reviewed by Tim Horton. 8 9 Add support for setting the `precise` property of `UIDropProposal` to YES when dragging over an editable area. 10 When enabled, this property shifts the drop location up by a small amount, allowing the user to see the drop 11 caret (currently, this is not the case, and it's difficult to drop text at a precise location on iOS). Changes 12 are covered by adding to existing API tests. 13 14 * Scripts/webkit/messages.py: 15 * UIProcess/API/Cocoa/WKUIDelegatePrivate.h: 16 17 Add a new version of `-_webView:willUpdateDataInteractionOperationToOperation:forSession:` that receives and 18 returns a UIDropProposal, so that Mail can more easily port over existing logic in its legacy-WebKit-based 19 compose implementation. iOS Safari is currently the only client of this private delegate, so the old version can 20 be easily removed once Safari adopts this new version. 21 22 * UIProcess/WebPageProxy.cpp: 23 (WebKit::WebPageProxy::didPerformDragControllerAction): 24 25 Add plumbing to send the latest drag handling method from WebPage to WebPageProxy. 26 27 (WebKit::WebPageProxy::resetCurrentDragInformation): 28 * UIProcess/WebPageProxy.h: 29 (WebKit::WebPageProxy::currentDragHandlingMethod const): 30 * UIProcess/WebPageProxy.messages.in: 31 * UIProcess/ios/WKContentViewInteraction.mm: 32 (-[WKContentView dropInteraction:sessionDidUpdate:]): 33 34 Call the new UI delegate hook when determining the drop proposal to return to UIKit. Additionally set the 35 `precise` bit on the drop proposal in the case where the drop handling method is either "editing rich text" or 36 "editing plain text". 37 38 * WebProcess/WebPage/WebPage.cpp: 39 (WebKit::WebPage::performDragControllerAction): 40 * WebProcess/WebPage/WebPage.h: 41 1 42 2018-12-10 Youenn Fablet <youenn@apple.com> 2 43 -
trunk/Source/WebKit/Scripts/webkit/messages.py
r239006 r239039 398 398 'PAL::SessionID': ['<pal/SessionID.h>'], 399 399 'WebCore::AutoplayEventFlags': ['<WebCore/AutoplayEvent.h>'], 400 'WebCore::DragHandlingMethod': ['<WebCore/DragActions.h>'], 400 401 'WebCore::ExceptionDetails': ['<WebCore/JSDOMExceptionHandling.h>'], 401 402 'WebCore::FileChooserSettings': ['<WebCore/FileChooser.h>'], -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h
r238726 r239039 158 158 - (void)_webView:(WKWebView *)webView dataInteractionOperationWasHandled:(BOOL)handled forSession:(id)session itemProviders:(NSArray *)itemProviders WK_API_AVAILABLE(ios(11.0)); 159 159 - (NSUInteger)_webView:(WKWebView *)webView willUpdateDataInteractionOperationToOperation:(NSUInteger)operation forSession:(id)session WK_API_AVAILABLE(ios(11.0)); 160 - (UIDropProposal *)_webView:(WKWebView *)webView willUpdateDropProposalToProposal:(UIDropProposal *)proposal forSession:(id <UIDropSession>)session WK_API_AVAILABLE(ios(WK_IOS_TBA)); 160 161 #if TARGET_OS_IOS 161 162 - (UITargetedDragPreview *)_webView:(WKWebView *)webView previewForLiftingItem:(UIDragItem *)item session:(id <UIDragSession>)session WK_API_AVAILABLE(ios(11.0)); -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r238939 r239039 2047 2047 } 2048 2048 2049 void WebPageProxy::didPerformDragControllerAction(uint64_t dragOperation, bool mouseIsOverFileInput, unsigned numberOfItemsToBeAccepted, const IntRect& insertionRect)2049 void WebPageProxy::didPerformDragControllerAction(uint64_t dragOperation, WebCore::DragHandlingMethod dragHandlingMethod, bool mouseIsOverFileInput, unsigned numberOfItemsToBeAccepted, const IntRect& insertionRect) 2050 2050 { 2051 2051 MESSAGE_CHECK(dragOperation <= DragOperationDelete); 2052 2052 2053 2053 m_currentDragOperation = static_cast<DragOperation>(dragOperation); 2054 m_currentDragHandlingMethod = dragHandlingMethod; 2054 2055 m_currentDragIsOverFileInput = mouseIsOverFileInput; 2055 2056 m_currentDragNumberOfFilesToBeAccepted = numberOfItemsToBeAccepted; … … 2100 2101 { 2101 2102 m_currentDragOperation = WebCore::DragOperationNone; 2103 m_currentDragHandlingMethod = DragHandlingMethod::None; 2102 2104 m_currentDragIsOverFileInput = false; 2103 2105 m_currentDragNumberOfFilesToBeAccepted = 0; -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r238939 r239039 974 974 void didPerformDragOperation(bool handled); 975 975 976 void didPerformDragControllerAction(uint64_t dragOperation, bool mouseIsOverFileInput, unsigned numberOfItemsToBeAccepted, const WebCore::IntRect& insertionRect);976 void didPerformDragControllerAction(uint64_t dragOperation, WebCore::DragHandlingMethod, bool mouseIsOverFileInput, unsigned numberOfItemsToBeAccepted, const WebCore::IntRect& insertionRect); 977 977 void dragEnded(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, uint64_t operation); 978 978 void didStartDrag(); … … 1030 1030 #if ENABLE(DRAG_SUPPORT) 1031 1031 WebCore::DragOperation currentDragOperation() const { return m_currentDragOperation; } 1032 WebCore::DragHandlingMethod currentDragHandlingMethod() const { return m_currentDragHandlingMethod; } 1032 1033 bool currentDragIsOverFileInput() const { return m_currentDragIsOverFileInput; } 1033 1034 unsigned currentDragNumberOfFilesToBeAccepted() const { return m_currentDragNumberOfFilesToBeAccepted; } … … 2152 2153 // so we preserve them to be used when the next dragging delegate call is made. 2153 2154 WebCore::DragOperation m_currentDragOperation { WebCore::DragOperationNone }; 2155 WebCore::DragHandlingMethod m_currentDragHandlingMethod { WebCore::DragHandlingMethod::None }; 2154 2156 bool m_currentDragIsOverFileInput { false }; 2155 2157 unsigned m_currentDragNumberOfFilesToBeAccepted { 0 }; -
trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in
r238771 r239039 312 312 # Drag and drop messages 313 313 #if ENABLE(DRAG_SUPPORT) 314 DidPerformDragControllerAction(uint64_t dragOperation, bool mouseIsOverFileInput, unsigned numberOfItemsToBeAccepted, WebCore::IntRect insertionRect)314 DidPerformDragControllerAction(uint64_t dragOperation, enum:uint8_t WebCore::DragHandlingMethod dragHandlingMethod, bool mouseIsOverFileInput, unsigned numberOfItemsToBeAccepted, WebCore::IntRect insertionRect) 315 315 DidEndDragging(); 316 316 #endif -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
r239029 r239039 5888 5888 _dragDropInteractionState.dropSessionDidEnterOrUpdate(session, dragData); 5889 5889 5890 NSUInteger operation = dropOperationForWebCoreDragOperation(_page->currentDragOperation()); 5891 if ([self.webViewUIDelegate respondsToSelector:@selector(_webView:willUpdateDataInteractionOperationToOperation:forSession:)]) 5892 operation = [self.webViewUIDelegate _webView:_webView willUpdateDataInteractionOperationToOperation:operation forSession:session]; 5893 5894 return [[[UIDropProposal alloc] initWithDropOperation:static_cast<UIDropOperation>(operation)] autorelease]; 5890 auto delegate = self.webViewUIDelegate; 5891 auto operation = dropOperationForWebCoreDragOperation(_page->currentDragOperation()); 5892 if ([delegate respondsToSelector:@selector(_webView:willUpdateDataInteractionOperationToOperation:forSession:)]) 5893 operation = static_cast<UIDropOperation>([delegate _webView:_webView willUpdateDataInteractionOperationToOperation:operation forSession:session]); 5894 5895 auto proposal = adoptNS([[UIDropProposal alloc] initWithDropOperation:static_cast<UIDropOperation>(operation)]); 5896 auto dragHandlingMethod = _page->currentDragHandlingMethod(); 5897 [proposal setPrecise:dragHandlingMethod == DragHandlingMethod::EditPlainText || dragHandlingMethod == DragHandlingMethod::EditRichText]; 5898 if ([delegate respondsToSelector:@selector(_webView:willUpdateDropProposalToProposal:forSession:)]) 5899 proposal = [delegate _webView:_webView willUpdateDropProposalToProposal:proposal.get() forSession:session]; 5900 5901 return proposal.autorelease(); 5895 5902 } 5896 5903 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r239006 r239039 3621 3621 { 3622 3622 if (!m_page) { 3623 send(Messages::WebPageProxy::DidPerformDragControllerAction(DragOperationNone, false, 0, { }));3623 send(Messages::WebPageProxy::DidPerformDragControllerAction(DragOperationNone, DragHandlingMethod::None, false, 0, { })); 3624 3624 return; 3625 3625 } … … 3629 3629 case DragControllerAction::Entered: { 3630 3630 DragOperation resolvedDragOperation = m_page->dragController().dragEntered(dragData); 3631 send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController(). mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted(), { }));3631 send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController().dragHandlingMethod(), m_page->dragController().mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted(), { })); 3632 3632 return; 3633 3633 } 3634 3634 case DragControllerAction::Updated: { 3635 3635 DragOperation resolvedDragOperation = m_page->dragController().dragEntered(dragData); 3636 send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController(). mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted(), { }));3636 send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController().dragHandlingMethod(), m_page->dragController().mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted(), { })); 3637 3637 return; 3638 3638 } … … 3652 3652 { 3653 3653 if (!m_page) { 3654 send(Messages::WebPageProxy::DidPerformDragControllerAction(DragOperationNone, false, 0, { }));3654 send(Messages::WebPageProxy::DidPerformDragControllerAction(DragOperationNone, DragHandlingMethod::None, false, 0, { })); 3655 3655 return; 3656 3656 } … … 3659 3659 case DragControllerAction::Entered: { 3660 3660 DragOperation resolvedDragOperation = m_page->dragController().dragEntered(dragData); 3661 send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController(). mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted(), m_page->dragCaretController().caretRectInRootViewCoordinates()));3661 send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController().dragHandlingMethod(), m_page->dragController().mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted(), m_page->dragCaretController().caretRectInRootViewCoordinates())); 3662 3662 return; 3663 3663 } 3664 3664 case DragControllerAction::Updated: { 3665 3665 DragOperation resolvedDragOperation = m_page->dragController().dragUpdated(dragData); 3666 send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController(). mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted(), m_page->dragCaretController().caretRectInRootViewCoordinates()));3666 send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController().dragHandlingMethod(), m_page->dragController().mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted(), m_page->dragCaretController().caretRectInRootViewCoordinates())); 3667 3667 return; 3668 3668 } 3669 3669 case DragControllerAction::Exited: 3670 3670 m_page->dragController().dragExited(dragData); 3671 send(Messages::WebPageProxy::DidPerformDragControllerAction(DragOperationNone, false, 0, { }));3671 send(Messages::WebPageProxy::DidPerformDragControllerAction(DragOperationNone, DragHandlingMethod::None, false, 0, { })); 3672 3672 return; 3673 3673 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r239006 r239039 168 168 169 169 enum SyntheticClickType : int8_t; 170 enum class DragHandlingMethod : uint8_t; 170 171 enum class ShouldTreatAsContinuingLoad : bool; 171 172 enum class TextIndicatorPresentationTransition : uint8_t; -
trunk/Tools/ChangeLog
r239028 r239039 1 2018-12-10 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [iOS] Caret is obscured by finger when dragging over an editable element 4 https://bugs.webkit.org/show_bug.cgi?id=192499 5 <rdar://problem/46570101> 6 7 Reviewed by Tim Horton. 8 9 Augment some existing API tests to check that the `precise` flag is either on or off on `UIDropProposal`. 10 11 * TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm: 12 * TestWebKitAPI/cocoa/DragAndDropSimulator.h: 13 * TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm: 14 (-[DragAndDropSimulator _resetSimulatedState]): 15 (-[DragAndDropSimulator lastKnownDropProposal]): 16 17 Rename `currentDropProposal` to `lastKnownDropProposal`, and expose it as a readonly property. 18 19 (-[DragAndDropSimulator _concludeDropAndPerformOperationIfNecessary]): 20 (-[DragAndDropSimulator _advanceProgress]): 21 (-[DragAndDropSimulator setShowCustomActionSheetBlock:]): 22 (-[DragAndDropSimulator showCustomActionSheetBlock]): 23 (-[DragAndDropSimulator setConvertItemProvidersBlock:]): 24 (-[DragAndDropSimulator convertItemProvidersBlock]): 25 (-[DragAndDropSimulator setOverridePerformDropBlock:]): 26 (-[DragAndDropSimulator overridePerformDropBlock]): 27 (-[DragAndDropSimulator setOverrideDragUpdateBlock:]): 28 (-[DragAndDropSimulator overrideDragUpdateBlock]): 29 (-[DragAndDropSimulator setDropCompletionBlock:]): 30 (-[DragAndDropSimulator dropCompletionBlock]): 31 32 Refactor these properties to return and take normal Objective-C blocks, rather than `BlockPtr`s. However, use 33 `BlockPtr` instance variables to manage the lifetimes of these blocks. 34 35 (-[DragAndDropSimulator _webView:willUpdateDropProposalToProposal:forSession:]): 36 (-[DragAndDropSimulator _webView:willUpdateDataInteractionOperationToOperation:forSession:]): Deleted. 37 38 Update this to use the new WebKit delegate hook for overriding the drop proposal. 39 1 40 2018-12-10 Michael Catanzaro <mcatanzaro@igalia.com> 2 41 -
trunk/Tools/TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm
r238795 r239039 273 273 checkFirstTypeIsPresentAndSecondTypeIsMissing(simulator.get(), kUTTypePNG, kUTTypeFileURL); 274 274 checkEstimatedSize(simulator.get(), { 215, 174 }); 275 EXPECT_TRUE([simulator lastKnownDropProposal].precise); 275 276 } 276 277 … … 317 318 checkSuggestedNameAndEstimatedSize(simulator.get(), @"icon.png", { 215, 174 }); 318 319 checkTypeIdentifierIsRegisteredAtIndex(simulator.get(), (__bridge NSString *)kUTTypePNG, 0); 320 EXPECT_TRUE([simulator lastKnownDropProposal].precise); 319 321 } 320 322 … … 364 366 checkSelectionRectsWithLogging(@[ makeCGRectValue(1, 201, 961, 227) ], [simulator finalSelectionRects]); 365 367 checkRichTextTypePrecedesPlainTextType(simulator.get()); 368 EXPECT_TRUE([simulator lastKnownDropProposal].precise); 366 369 } 367 370 … … 384 387 checkSelectionRectsWithLogging(@[ makeCGRectValue(6, 203, 990, 232) ], [simulator finalSelectionRects]); 385 388 checkRichTextTypePrecedesPlainTextType(simulator.get()); 389 EXPECT_TRUE([simulator lastKnownDropProposal].precise); 386 390 } 387 391 … … 414 418 EXPECT_GT(firstParagraphOffset, secondParagraphOffset); 415 419 checkSelectionRectsWithLogging(@[ makeCGRectValue(190, 100, 130, 20), makeCGRectValue(0, 120, 320, 100), makeCGRectValue(0, 220, 252, 20) ], [simulator finalSelectionRects]); 420 EXPECT_TRUE([simulator lastKnownDropProposal].precise); 416 421 } 417 422 … … 630 635 631 636 EXPECT_WK_STREQ("", [webView stringByEvaluatingJavaScript:@"output.value"]); 637 EXPECT_FALSE([simulator lastKnownDropProposal].precise); 632 638 } 633 639 … … 646 652 647 653 EXPECT_WK_STREQ("application/json", [webView stringByEvaluatingJavaScript:@"output.value"]); 654 EXPECT_FALSE([simulator lastKnownDropProposal].precise); 648 655 } 649 656 … … 663 670 NSString *outputValue = [webView stringByEvaluatingJavaScript:@"output.value"]; 664 671 EXPECT_WK_STREQ("image/jpeg", outputValue.UTF8String); 672 EXPECT_FALSE([simulator lastKnownDropProposal].precise); 665 673 } 666 674 … … 682 690 NSString *outputValue = [webView stringByEvaluatingJavaScript:@"output.value"]; 683 691 EXPECT_WK_STREQ("text/html", outputValue.UTF8String); 692 EXPECT_FALSE([simulator lastKnownDropProposal].precise); 684 693 } 685 694 … … 719 728 NSString *outputValue = [webView stringByEvaluatingJavaScript:@"output.value"]; 720 729 EXPECT_WK_STREQ("application/zip", outputValue.UTF8String); 730 EXPECT_FALSE([simulator lastKnownDropProposal].precise); 721 731 } 722 732 … … 735 745 NSString *outputValue = [webView stringByEvaluatingJavaScript:@"output.value"]; 736 746 EXPECT_WK_STREQ("application/zip", outputValue.UTF8String); 747 EXPECT_FALSE([simulator lastKnownDropProposal].precise); 737 748 } 738 749 … … 756 767 NSString *outputValue = [webView stringByEvaluatingJavaScript:@"output.value"]; 757 768 EXPECT_WK_STREQ("", outputValue.UTF8String); 769 EXPECT_FALSE([simulator lastKnownDropProposal].precise); 758 770 } 759 771 … … 778 790 NSString *outputValue = [webView stringByEvaluatingJavaScript:@"output.value"]; 779 791 EXPECT_WK_STREQ("image/jpeg, text/html", outputValue.UTF8String); 792 EXPECT_FALSE([simulator lastKnownDropProposal].precise); 780 793 } 781 794 … … 804 817 NSString *outputValue = [webView stringByEvaluatingJavaScript:@"output.value"]; 805 818 EXPECT_WK_STREQ("image/jpeg, text/html, text/html", outputValue.UTF8String); 819 EXPECT_FALSE([simulator lastKnownDropProposal].precise); 806 820 } 807 821 … … 1030 1044 NSString *outputValue = [webView stringByEvaluatingJavaScript:@"output.value"]; 1031 1045 EXPECT_WK_STREQ("text/html", outputValue.UTF8String); 1046 EXPECT_FALSE([simulator lastKnownDropProposal].precise); 1032 1047 } 1033 1048 … … 1155 1170 auto simulator = adoptNS([[DragAndDropSimulator alloc] initWithWebView:webView.get()]); 1156 1171 [simulator setExternalItemProviders:@[ simulatedItemProvider.get() ]]; 1157 [simulator setOverrideDragUpdateBlock:^NSUInteger(NSUInteger operation, id session) 1158 { 1159 EXPECT_EQ(0U, operation); 1172 [simulator setOverrideDragUpdateBlock:[] (UIDropOperation operation, id <UIDropSession> session) { 1173 EXPECT_EQ(UIDropOperationCancel, operation); 1160 1174 return UIDropOperationCopy; 1161 1175 }]; -
trunk/Tools/TestWebKitAPI/cocoa/DragAndDropSimulator.h
r238728 r239039 96 96 @property (nonatomic) BOOL shouldEnsureUIApplication; 97 97 @property (nonatomic) BOOL shouldAllowMoveOperation; 98 @property (nonatomic) BlockPtr<BOOL(_WKActivatedElementInfo *)> showCustomActionSheetBlock;99 @property (nonatomic) BlockPtr<NSArray *(NSItemProvider *, NSArray *, NSDictionary *)> convertItemProvidersBlock;100 @property (nonatomic) BlockPtr<NSArray *(id <UIDropSession>)> overridePerformDropBlock;101 98 @property (nonatomic, strong) NSArray *externalItemProviders; 102 @property (nonatomic) BlockPtr<NSUInteger(NSUInteger, id)> overrideDragUpdateBlock; 103 @property (nonatomic) BlockPtr<void(BOOL, NSArray *)> dropCompletionBlock; 99 @property (nonatomic, readonly) UIDropProposal *lastKnownDropProposal; 100 101 @property (nonatomic, copy) BOOL(^showCustomActionSheetBlock)(_WKActivatedElementInfo *); 102 @property (nonatomic, copy) NSArray *(^convertItemProvidersBlock)(NSItemProvider *, NSArray *, NSDictionary *); 103 @property (nonatomic, copy) NSArray *(^overridePerformDropBlock)(id <UIDropSession>); 104 @property (nonatomic, copy) void(^dropCompletionBlock)(BOOL, NSArray *); 105 @property (nonatomic, copy) UIDropOperation(^overrideDragUpdateBlock)(UIDropOperation, id <UIDropSession>); 104 106 105 107 @property (nonatomic, readonly) NSArray *sourceItemProviders; -
trunk/Tools/TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm
r238728 r239039 317 317 318 318 BOOL _suppressedSelectionCommandsDuringDrop; 319 RetainPtr<UIDropProposal> _currentDropProposal; 319 RetainPtr<UIDropProposal> _lastKnownDropProposal; 320 321 BlockPtr<BOOL(_WKActivatedElementInfo *)> _showCustomActionSheetBlock; 322 BlockPtr<NSArray *(NSItemProvider *, NSArray *, NSDictionary *)> _convertItemProvidersBlock; 323 BlockPtr<NSArray *(id <UIDropSession>)> _overridePerformDropBlock; 324 BlockPtr<UIDropOperation(UIDropOperation, id)> _overrideDragUpdateBlock; 325 BlockPtr<void(BOOL, NSArray *)> _dropCompletionBlock; 320 326 } 321 327 … … 368 374 _dragSession = nil; 369 375 _dropSession = nil; 370 _ currentDropProposal = nil;376 _lastKnownDropProposal = nil; 371 377 _lastKnownDragCaretRect = CGRectZero; 372 378 _remainingAdditionalItemRequestLocationsByProgress = nil; … … 379 385 { 380 386 return _observedEventNames.get(); 387 } 388 389 - (UIDropProposal *)lastKnownDropProposal 390 { 391 return _lastKnownDropProposal.get(); 381 392 } 382 393 … … 449 460 { 450 461 _lastKnownDragCaretRect = [_webView _dragCaretRect]; 451 auto operation = [_ currentDropProposal operation];462 auto operation = [_lastKnownDropProposal operation]; 452 463 if (operation != UIDropOperationCancel && operation != UIDropOperationForbidden) { 453 464 [[_webView dropInteractionDelegate] dropInteraction:[_webView dropInteraction] performDrop:_dropSession.get()]; … … 570 581 break; 571 582 case DragAndDropPhaseEntered: { 572 _ currentDropProposal = [[_webView dropInteractionDelegate] dropInteraction:[_webView dropInteraction] sessionDidUpdate:_dropSession.get()];573 if (![self shouldAllowMoveOperation] && [_ currentDropProposal operation] == UIDropOperationMove)574 _ currentDropProposal = adoptNS([[UIDropProposal alloc] initWithDropOperation:UIDropOperationCancel]);583 _lastKnownDropProposal = [[_webView dropInteractionDelegate] dropInteraction:[_webView dropInteraction] sessionDidUpdate:_dropSession.get()]; 584 if (![self shouldAllowMoveOperation] && [_lastKnownDropProposal operation] == UIDropOperationMove) 585 _lastKnownDropProposal = adoptNS([[UIDropProposal alloc] initWithDropOperation:UIDropOperationCancel]); 575 586 break; 576 587 } … … 655 666 } 656 667 668 - (void)setShowCustomActionSheetBlock:(BOOL(^)(_WKActivatedElementInfo *))showCustomActionSheetBlock 669 { 670 _showCustomActionSheetBlock = showCustomActionSheetBlock; 671 } 672 673 - (BOOL(^)(_WKActivatedElementInfo *))showCustomActionSheetBlock 674 { 675 return _showCustomActionSheetBlock.get(); 676 } 677 678 - (void)setConvertItemProvidersBlock:(NSArray *(^)(NSItemProvider *, NSArray *, NSDictionary *))convertItemProvidersBlock 679 { 680 _convertItemProvidersBlock = convertItemProvidersBlock; 681 } 682 683 - (NSArray *(^)(NSItemProvider *, NSArray *, NSDictionary *))convertItemProvidersBlock 684 { 685 return _convertItemProvidersBlock.get(); 686 } 687 688 - (void)setOverridePerformDropBlock:(NSArray *(^)(id <UIDropSession>))overridePerformDropBlock 689 { 690 _overridePerformDropBlock = overridePerformDropBlock; 691 } 692 693 - (NSArray *(^)(id <UIDropSession>))overridePerformDropBlock 694 { 695 return _overridePerformDropBlock.get(); 696 } 697 698 - (void)setOverrideDragUpdateBlock:(UIDropOperation(^)(UIDropOperation, id <UIDropSession>))overrideDragUpdateBlock 699 { 700 _overrideDragUpdateBlock = overrideDragUpdateBlock; 701 } 702 703 - (UIDropOperation(^)(UIDropOperation, id <UIDropSession>))overrideDragUpdateBlock 704 { 705 return _overrideDragUpdateBlock.get(); 706 } 707 708 - (void)setDropCompletionBlock:(void(^)(BOOL, NSArray *))dropCompletionBlock 709 { 710 _dropCompletionBlock = dropCompletionBlock; 711 } 712 713 - (void(^)(BOOL, NSArray *))dropCompletionBlock 714 { 715 return _dropCompletionBlock.get(); 716 } 717 657 718 #pragma mark - WKUIDelegatePrivate 658 719 … … 666 727 } 667 728 668 - (NSUInteger)_webView:(WKWebView *)webView willUpdateDataInteractionOperationToOperation:(NSUInteger)operation forSession:(id)session 669 { 670 return self.overrideDragUpdateBlock ? self.overrideDragUpdateBlock(operation, session) : operation; 729 - (UIDropProposal *)_webView:(WKWebView *)webView willUpdateDropProposalToProposal:(UIDropProposal *)proposal forSession:(id <UIDropSession>)session 730 { 731 if (!self.overrideDragUpdateBlock) 732 return proposal; 733 734 return [[[UIDropProposal alloc] initWithDropOperation:self.overrideDragUpdateBlock(proposal.operation, session)] autorelease]; 671 735 } 672 736
Note: See TracChangeset
for help on using the changeset viewer.