[iOS DnD] Upstream iOS drag and drop implementation into OpenSource WebKit
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 17 Jun 2017 00:33:23 +0000 (00:33 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 17 Jun 2017 00:33:23 +0000 (00:33 +0000)
commit8002fbcb2a233da76d55bc24835519e4b3290f48
tree9e34339c584c4b9fb754c118b9a4a08b82cd261d
parentb31e42cb9e38c6fc89c3a6ae22571a083066bb71
[iOS DnD] Upstream iOS drag and drop implementation into OpenSource WebKit
https://bugs.webkit.org/show_bug.cgi?id=173366
<rdar://problem/32767014>

Reviewed by Tim Horton.

Source/JavaScriptCore:

Introduce ENABLE_DATA_INTERACTION and ENABLE_DRAG_SUPPORT to FeatureDefines.xcconfig.

* Configurations/FeatureDefines.xcconfig:

Source/WebCore:

Moves all drag and drop logic previously hidden behind WebKitAdditions into the open source repository, along
with unit test pages in TestWebKitAPI. Also removes all #includes and #imports of dragging-related files in
WebKitAdditions from the open source repository.

This initial upstreaming phase is only concerned with moving code out of WebKitAdditions, and attempts to
preserve the code as-is, with the exception of trivial style changes so that the open source linter passes.
Future patches will remove the DATA_INTERACTION feature flag altogether and unobscure all variable and function
names referencing "data interaction".

No change in behavior from the internal build.

* Configurations/FeatureDefines.xcconfig:
* page/ios/EventHandlerIOS.mm:
(WebCore::EventHandler::createDraggingDataTransfer):
(WebCore::EventHandler::eventLoopHandleMouseDragged):
(WebCore::EventHandler::tryToBeginDataInteractionAtPoint):
* platform/ios/DragImageIOS.mm:
(WebCore::dragImageSize):
(WebCore::scaleDragImage):
(WebCore::createDragImageFromImage):
(WebCore::deleteDragImage):
(WebCore::createDragImageForLink):
(WebCore::createDragImageIconForCachedImageFilename):
(WebCore::platformAdjustDragImageForDeviceScaleFactor):
(WebCore::createDragImageForSelection):
(WebCore::dissolveDragImageToFraction):
* platform/ios/PasteboardIOS.mm:
(WebCore::Pasteboard::Pasteboard):
(WebCore::Pasteboard::setDragImage):
(WebCore::Pasteboard::createForDragAndDrop):
* platform/mac/DragDataMac.mm:
(WebCore::rtfPasteboardType):
(WebCore::rtfdPasteboardType):
(WebCore::stringPasteboardType):
(WebCore::urlPasteboardType):
(WebCore::htmlPasteboardType):
(WebCore::colorPasteboardType):
(WebCore::pdfPasteboardType):
(WebCore::tiffPasteboardType):
(WebCore::DragData::asFilenames):
(WebCore::DragData::containsURL):
(rtfPasteboardType): Deleted.
(rtfdPasteboardType): Deleted.
(stringPasteboardType): Deleted.
(urlPasteboardType): Deleted.
(htmlPasteboardType): Deleted.
(colorPasteboardType): Deleted.
(pdfPasteboardType): Deleted.
(tiffPasteboardType): Deleted.

Source/WebCore/PAL:

Introduce ENABLE_DATA_INTERACTION and ENABLE_DRAG_SUPPORT to FeatureDefines.xcconfig.

* Configurations/FeatureDefines.xcconfig:

Source/WebKit/mac:

Move pieces of iOS WebKit1 drag and drop implementation into OpenSource. No change in behavior.

* Configurations/FeatureDefines.xcconfig:
* WebCoreSupport/WebDragClient.mm:
(WebDragClient::useLegacyDragClient):
(WebDragClient::willPerformDragDestinationAction):
(WebDragClient::dragSourceActionMaskForPoint):
(WebDragClient::willPerformDragSourceAction):
(WebDragClient::startDrag):
(WebDragClient::beginDrag):
(WebDragClient::declareAndWriteDragImage):
(WebDragClient::declareAndWriteAttachment):
(WebDragClient::didConcludeEditDrag):
* WebView/WebView.mm:
(-[WebView _setDataInteractionData:textIndicator:atClientPosition:anchorPoint:action:]):
(-[WebView _getDataInteractionData]):
(-[WebView dragDataForSession:client:global:operation:]):
(-[WebView _enteredDataInteraction:client:global:operation:]):
(-[WebView _updatedDataInteraction:client:global:operation:]):
(-[WebView _exitedDataInteraction:client:global:operation:]):
(-[WebView _performDataInteraction:client:global:operation:]):
(-[WebView _tryToPerformDataInteraction:client:global:operation:]):
(-[WebView _endedDataInteraction:global:]):
(-[WebView _didConcludeEditDataInteraction]):
(floatRectsForCGRectArray): Deleted.
(-[WebView _createImageWithPlatterForImage:boundingRect:contentScaleFactor:clippingRects:]): Deleted.
* WebView/WebViewData.h:
* WebView/WebViewData.mm:
(-[WebViewPrivate dealloc]):
* WebView/WebViewPrivate.h:

Source/WebKit2:

Move pieces of iOS WebKit2 drag and drop implementation into OpenSource. No change in behavior.

* Configurations/FeatureDefines.xcconfig:
* UIProcess/Cocoa/WebPageProxyCocoa.mm:
(WebKit::WebPageProxy::setDragImage):
(WebKit::WebPageProxy::setPromisedDataForImage):
(WebKit::WebPageProxy::setPromisedDataForAttachment):
(WebKit::WebPageProxy::setDragCaretRect):
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(longPressActionDelayAfterLift):
(-[WKContentView webViewUIDelegate]):
(-[WKContentView setupDataInteractionDelegates]):
(-[WKContentView teardownDataInteractionDelegates]):
(-[WKContentView _startDataInteractionWithImage:withIndicatorData:atClientPosition:anchorPoint:action:]):
(-[WKContentView _didHandleStartDataInteractionRequest:]):
(uiImageForImage):
(shouldUseTextIndicatorToCreatePreviewForDragAction):
(-[WKContentView dragPreviewForImage:frameInRootViewCoordinates:clippingRectsInFrameCoordinates:backgroundColor:]):
(-[WKContentView dragPreviewForCurrentDataInteractionState]):
(-[WKContentView performDeferredActionAtDragOrigin]):
(-[WKContentView cancelDeferredActionAtDragOrigin]):
(-[WKContentView computeClientAndGlobalPointsForDropSession:outClientPoint:outGlobalPoint:]):
(dropOperationForWebCoreDragOperation):
(-[WKContentView dragDataForDropSession:dragDestinationAction:]):
(-[WKContentView cleanUpDragSourceSessionState]):
(extractItemProvidersFromDragItems):
(extractItemProvidersFromDropSession):
(-[WKContentView _didConcludeEditDataInteraction:]):
(-[WKContentView _didPerformDataInteractionControllerOperation:]):
(-[WKContentView _transitionDragPreviewToImageIfNecessary:]):
(-[WKContentView _didChangeDataInteractionCaretRect:currentRect:]):
(-[WKContentView _dragDestinationActionForDropSession:]):
(positionInformationMayStartDataInteraction):
(-[WKContentView currentDragOrDropSession]):
(-[WKContentView _dragInteraction:prepareForSession:completion:]):
(-[WKContentView dragInteraction:itemsForBeginningSession:]):
(-[WKContentView _api_dragInteraction:previewForLiftingItem:session:]):
(-[WKContentView dragInteraction:sessionWillBegin:]):
(-[WKContentView _api_dragInteraction:session:didEndWithOperation:]):
(-[WKContentView dragInteraction:previewForCancellingItem:withDefault:]):
(-[WKContentView _api_dragInteraction:item:willAnimateCancelWithAnimator:]):
(-[WKContentView dropInteraction:canHandleSession:]):
(-[WKContentView _api_dropInteraction:sessionDidEnter:]):
(-[WKContentView _api_dropInteraction:sessionDidUpdate:]):
(-[WKContentView dropInteraction:sessionDidExit:]):
(-[WKContentView dropInteraction:performDrop:]):
(-[WKContentView dropInteraction:previewForDroppingItem:withDefault:]):
(-[WKContentView dropInteraction:sessionDidEnd:]):
(-[WKContentView _simulateDataInteractionEntered:]):
(-[WKContentView _simulateDataInteractionUpdated:]):
(-[WKContentView _simulateDataInteractionEnded:]):
(-[WKContentView _simulateDataInteractionPerformOperation:]):
(-[WKContentView _simulateDataInteractionSessionDidEnd:]):
(-[WKContentView _simulateWillBeginDataInteractionWithSession:]):
(-[WKContentView _simulatedItemsForSession:]):
(-[WKContentView _simulatePrepareForDataInteractionSession:completion:]):
* WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
(WebKit::convertCGImageToBitmap):
(WebKit::WebDragClient::startDrag):
(WebKit::WebDragClient::declareAndWriteDragImage):
(WebKit::WebDragClient::didConcludeEditDrag):
(WebKit::WebDragClient::declareAndWriteAttachment):

Source/WTF:

Define ENABLE_DRAG_SUPPORT as 1 by default and 0 for iOS, and define ENABLE_DATA_INTERACTION as 0 by default.
These are overridden to both be 1 for iOS 11+ in the FeatureDefines.xcconfig within each individual project.

* wtf/Platform.h:

Tools:

Move test pages and pieces of DataInteractionSimulator hidden behind WebKitAdditions into TestWebKitAPI. No
change in behavior.

* TestWebKitAPI/Configurations/FeatureDefines.xcconfig:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2Cocoa/autofocus-contenteditable.html: Added.
* TestWebKitAPI/Tests/WebKit2Cocoa/background-image-link-and-input.html: Added.
* TestWebKitAPI/Tests/WebKit2Cocoa/contenteditable-and-textarea.html: Added.
* TestWebKitAPI/Tests/WebKit2Cocoa/div-and-large-image.html: Added.
* TestWebKitAPI/Tests/WebKit2Cocoa/file-uploading.html: Added.
* TestWebKitAPI/Tests/WebKit2Cocoa/image-and-contenteditable.html: Added.
* TestWebKitAPI/Tests/WebKit2Cocoa/image-and-textarea.html: Added.
* TestWebKitAPI/Tests/WebKit2Cocoa/link-and-input.html: Added.
* TestWebKitAPI/Tests/WebKit2Cocoa/link-and-target-div.html: Added.
* TestWebKitAPI/Tests/WebKit2Cocoa/prevent-operation.html: Added.
* TestWebKitAPI/Tests/WebKit2Cocoa/prevent-start.html: Added.
* TestWebKitAPI/Tests/WebKit2Cocoa/textarea-to-input.html: Added.
* TestWebKitAPI/ios/DataInteractionSimulator.mm:
(-[MockDragDropSession initWithItems:location:window:]):
(-[MockDragDropSession allowsMoveOperation]):
(-[MockDragDropSession isRestrictedToDraggingApplication]):
(-[MockDragDropSession hasItemsConformingToTypeIdentifiers:]):
(-[MockDragDropSession canLoadObjectsOfClass:]):
(-[MockDragDropSession canLoadObjectsOfClasses:]):
(-[MockDragDropSession items]):
(-[MockDragDropSession setItems:]):
(-[MockDragDropSession locationInView:]):
(-[MockDataOperationSession initWithProviders:location:window:]):
(-[MockDataOperationSession session]):
(-[MockDataOperationSession isLocal]):
(-[MockDataOperationSession progress]):
(-[MockDataOperationSession setProgressIndicatorStyle:]):
(-[MockDataOperationSession progressIndicatorStyle]):
(-[MockDataOperationSession operationMask]):
(-[MockDataOperationSession localDragSession]):
(-[MockDataOperationSession hasItemsConformingToTypeIdentifier:]):
(-[MockDataOperationSession canCreateItemsOfClass:]):
(-[MockDataOperationSession loadObjectsOfClass:completion:]):
(-[MockDataInteractionSession initWithWindow:]):
(-[MockDataInteractionSession localOperationMask]):
(-[MockDataInteractionSession externalOperationMask]):
(-[MockDataInteractionSession session]):
(-[DataInteractionSimulator _advanceProgress]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@218433 268f45cc-cd09-0410-ab3c-d52691b4dbfc
41 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/Configurations/FeatureDefines.xcconfig
Source/WTF/ChangeLog
Source/WTF/wtf/Platform.h
Source/WebCore/ChangeLog
Source/WebCore/Configurations/FeatureDefines.xcconfig
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/Configurations/FeatureDefines.xcconfig
Source/WebCore/page/ios/EventHandlerIOS.mm
Source/WebCore/platform/ios/DragImageIOS.mm
Source/WebCore/platform/ios/PasteboardIOS.mm
Source/WebCore/platform/mac/DragDataMac.mm
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Configurations/FeatureDefines.xcconfig
Source/WebKit/mac/WebCoreSupport/WebDragClient.mm
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit/mac/WebView/WebViewData.h
Source/WebKit/mac/WebView/WebViewData.mm
Source/WebKit/mac/WebView/WebViewPrivate.h
Source/WebKit2/ChangeLog
Source/WebKit2/Configurations/FeatureDefines.xcconfig
Source/WebKit2/UIProcess/Cocoa/WebPageProxyCocoa.mm
Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h
Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm
Tools/ChangeLog
Tools/TestWebKitAPI/Configurations/FeatureDefines.xcconfig
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/autofocus-contenteditable.html [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/background-image-link-and-input.html [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/contenteditable-and-textarea.html [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/div-and-large-image.html [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/file-uploading.html [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/image-and-contenteditable.html [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/image-and-textarea.html [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/link-and-input.html [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/link-and-target-div.html [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/prevent-operation.html [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/prevent-start.html [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/textarea-to-input.html [new file with mode: 0644]
Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm