[webkit-changes] [WebKit/WebKit] 693035: Stop using delayedPreviewProviderForDroppingItem t...

Wenson Hsieh noreply at github.com
Mon Nov 6 14:58:00 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 69303581ae36c561183cca0a5fdea24e9500ee5e
      https://github.com/WebKit/WebKit/commit/69303581ae36c561183cca0a5fdea24e9500ee5e
  Author: Wenson Hsieh <wenson_hsieh at apple.com>
  Date:   2023-11-06 (Mon, 06 Nov 2023)

  Changed paths:
    M Source/WebKit/Platform/spi/ios/UIKitSPI.h
    M Source/WebKit/UIProcess/ios/DragDropInteractionState.h
    M Source/WebKit/UIProcess/ios/DragDropInteractionState.mm
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
    M Tools/TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm

  Log Message:
  -----------
  Stop using delayedPreviewProviderForDroppingItem to update drop previews asynchronously
https://bugs.webkit.org/show_bug.cgi?id=263983
rdar://114331921

Reviewed by Aditya Keerthi.

Stop relying on this private `UIDropInteraction` delegate method. Instead, adopt a new method,
`-[UIDragItem _setNeedsDropPreviewUpdate]`, to inform UIKit that a given item's associated drop
preview is changing. The drop session will then query the normal API again
(`-[UIDropInteractionDelegate dropInteraction:previewForDroppingItem:withDefault:]`), and
automatically retarget the drop animation based on the new result preview.

See below for more details.

* Source/WebKit/Platform/spi/ios/UIKitSPI.h:
* Source/WebKit/UIProcess/ios/DragDropInteractionState.h:
* Source/WebKit/UIProcess/ios/DragDropInteractionState.mm:
(WebKit::createTargetedDragPreview):
(WebKit::DragDropInteractionState::addDefaultDropPreview):
(WebKit::DragDropInteractionState::defaultDropPreview const):
(WebKit::DragDropInteractionState::finalDropPreview const):

Refactor the drag and drop interaction state to accomodate the new way of updating previews on drop.
In particular, replace `m_delayedItemPreviewProviders` with `m_finalDropPreviews` instead. We no
longer need to save a list of preview-provider blocks, and can instead:

1.  Stash away any incoming asynchronously-delivered previews on the interaction state…
2.  Call `-_setNeedsDropPreviewUpdate` on the drag item, and finally…
3.  Return the final drag preview in `-dropInteraction:previewForDroppingItem:withDefault:`, for
    that drag item.

(WebKit::dragItemSupportsAsynchronousUpdates):
(WebKit::DragDropInteractionState::deliverDelayedDropPreview):
(WebKit::DragDropInteractionState::dragAndDropSessionsDidBecomeInactive):
(WebKit::DragDropInteractionState::setDefaultDropPreview): Deleted.
(WebKit::BlockPtr<void): Deleted.
(WebKit::DragDropInteractionState::prepareForDelayedDropPreview): Deleted.
(WebKit::DragDropInteractionState::clearAllDelayedItemPreviewProviders): Deleted.
(WebKit::DragDropInteractionState::dragAndDropSessionsDidEnd): Deleted.
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView cleanUpDragSourceSessionState]):
(-[WKContentView _handleDropByInsertingImagePlaceholders:session:]):
(-[WKContentView dropInteraction:concludeDrop:]):
(-[WKContentView dropInteraction:previewForDroppingItem:withDefault:]):

Return the final drop preview, if available. See above for more details.

(-[WKContentView _dropInteraction:delayedPreviewProviderForDroppingItem:previewProvider:]): Deleted.
* Tools/TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm:
(-[UIDragItem _dragAndDropSimulator]):
(-[UIDragItem _setDragAndDropSimulator:]):
(-[UIDragItem _setNeedsDropPreviewUpdate]):
(-[DragAndDropSimulator _resetSimulatedState]):
(-[DragAndDropSimulator runFrom:to:additionalItemRequestLocations:]):
(-[DragAndDropSimulator defaultDropPreviewForItemAtIndex:]):
(-[DragAndDropSimulator _setNeedsDropPreviewUpdate:]):
(-[DragAndDropSimulator _concludeDropAndPerformOperationIfNecessary]):

Update our drag and drop test infrastructure to handle calls to `-_setNeedsDropPreviewUpdate` by
having the drop simulator query `-dropInteraction:previewForDroppingItem:withDefault:` again and
save the result, which aligns with platform behavior support for this new API.

Canonical link: https://commits.webkit.org/270290@main




More information about the webkit-changes mailing list