diff --git a/Source/WebCore/dom/DataTransfer.cpp b/Source/WebCore/dom/DataTransfer.cpp index e252c8972cdf..16dc5a9fb91e 100644 --- a/Source/WebCore/dom/DataTransfer.cpp +++ b/Source/WebCore/dom/DataTransfer.cpp @@ -317,10 +317,11 @@ Vector DataTransfer::types(AddFilesType addFilesType) const if (!canReadTypes()) return { }; + bool hideFilesType = !canWriteData() && !allowsFileAccess(); if (!DeprecatedGlobalSettings::customPasteboardDataEnabled()) { auto types = m_pasteboard->typesForLegacyUnsafeBindings(); ASSERT(!types.contains("Files"_s)); - if (m_pasteboard->fileContentState() != Pasteboard::FileContentState::NoFileOrImageData && addFilesType == AddFilesType::Yes) + if (!hideFilesType && m_pasteboard->fileContentState() != Pasteboard::FileContentState::NoFileOrImageData && addFilesType == AddFilesType::Yes) types.append("Files"_s); return types; } @@ -333,7 +334,7 @@ Vector DataTransfer::types(AddFilesType addFilesType) const auto fileContentState = m_pasteboard->fileContentState(); if (hasFileBackedItem || fileContentState != Pasteboard::FileContentState::NoFileOrImageData) { Vector types; - if (addFilesType == AddFilesType::Yes) + if (!hideFilesType && addFilesType == AddFilesType::Yes) types.append("Files"_s); if (fileContentState != Pasteboard::FileContentState::MayContainFilePaths) { @@ -356,7 +357,7 @@ Vector> DataTransfer::filesFromPasteboardAndItemList(ScriptExecutionCo { bool addedFilesFromPasteboard = false; Vector> files; - if ((!forDrag() || forFileDrag()) && m_pasteboard->fileContentState() != Pasteboard::FileContentState::NoFileOrImageData) { + if (allowsFileAccess() && m_pasteboard->fileContentState() != Pasteboard::FileContentState::NoFileOrImageData) { WebCorePasteboardFileReader reader(context); m_pasteboard->read(reader); files = WTFMove(reader.files); diff --git a/Source/WebCore/dom/DataTransfer.h b/Source/WebCore/dom/DataTransfer.h index fbcdea3855b8..6e9203839a42 100644 --- a/Source/WebCore/dom/DataTransfer.h +++ b/Source/WebCore/dom/DataTransfer.h @@ -119,6 +119,11 @@ class DataTransfer : public RefCounted { enum class Type { CopyAndPaste, DragAndDropData, DragAndDropFiles, InputEvent }; DataTransfer(StoreMode, std::unique_ptr, Type = Type::CopyAndPaste, String&& effectAllowed = "uninitialized"_s); + bool allowsFileAccess() const + { + return !forDrag() || forFileDrag(); + } + #if ENABLE(DRAG_SUPPORT) bool forDrag() const { return m_type == Type::DragAndDropData || m_type == Type::DragAndDropFiles; } bool forFileDrag() const { return m_type == Type::DragAndDropFiles; } diff --git a/Source/WebCore/page/DragController.cpp b/Source/WebCore/page/DragController.cpp index a9dbe73f5f87..307ac7ea7ad4 100644 --- a/Source/WebCore/page/DragController.cpp +++ b/Source/WebCore/page/DragController.cpp @@ -216,13 +216,15 @@ void DragController::dragEnded() client().dragEnded(); } -std::optional DragController::dragEntered(const DragData& dragData) +std::optional DragController::dragEntered(DragData&& dragData) { - return dragEnteredOrUpdated(dragData); + return dragEnteredOrUpdated(WTFMove(dragData)); } -void DragController::dragExited(const DragData& dragData) +void DragController::dragExited(DragData&& dragData) { + disallowFileAccessIfNeeded(dragData); + auto& mainFrame = m_page.mainFrame(); if (mainFrame.view()) mainFrame.eventHandler().cancelDragAndDrop(createMouseEvent(dragData), Pasteboard::create(dragData), dragData.draggingSourceOperationMask(), dragData.containsFiles()); @@ -232,9 +234,9 @@ void DragController::dragExited(const DragData& dragData) m_fileInputElementUnderMouse = nullptr; } -std::optional DragController::dragUpdated(const DragData& dragData) +std::optional DragController::dragUpdated(DragData&& dragData) { - return dragEnteredOrUpdated(dragData); + return dragEnteredOrUpdated(WTFMove(dragData)); } inline static bool dragIsHandledByDocument(DragHandlingMethod dragHandlingMethod) @@ -242,7 +244,7 @@ inline static bool dragIsHandledByDocument(DragHandlingMethod dragHandlingMethod return dragHandlingMethod != DragHandlingMethod::None && dragHandlingMethod != DragHandlingMethod::PageLoad; } -bool DragController::performDragOperation(const DragData& dragData) +bool DragController::performDragOperation(DragData&& dragData) { if (!m_droppedImagePlaceholders.isEmpty() && m_droppedImagePlaceholderRange && tryToUpdateDroppedImagePlaceholders(dragData)) { m_droppedImagePlaceholders.clear(); @@ -259,6 +261,8 @@ bool DragController::performDragOperation(const DragData& dragData) m_documentUnderMouse = m_page.mainFrame().documentAtPoint(dragData.clientPosition()); + disallowFileAccessIfNeeded(dragData); + ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy = ShouldOpenExternalURLsPolicy::ShouldNotAllow; if (m_documentUnderMouse) shouldOpenExternalURLsPolicy = m_documentUnderMouse->shouldOpenExternalURLsPolicyToPropagate(); @@ -314,7 +318,7 @@ void DragController::mouseMovedIntoDocument(Document* newDocument) m_documentUnderMouse = newDocument; } -std::optional DragController::dragEnteredOrUpdated(const DragData& dragData) +std::optional DragController::dragEnteredOrUpdated(DragData&& dragData) { mouseMovedIntoDocument(m_page.mainFrame().documentAtPoint(dragData.clientPosition())); @@ -324,6 +328,8 @@ std::optional DragController::dragEnteredOrUpdated(const DragData return std::nullopt; } + disallowFileAccessIfNeeded(dragData); + std::optional dragOperation; m_dragHandlingMethod = tryDocumentDrag(dragData, m_dragDestinationActionMask, dragOperation); if (m_dragHandlingMethod == DragHandlingMethod::None && (m_dragDestinationActionMask.contains(DragDestinationAction::Load))) { @@ -337,6 +343,13 @@ std::optional DragController::dragEnteredOrUpdated(const DragData return dragOperation; } +void DragController::disallowFileAccessIfNeeded(DragData& dragData) +{ + RefPtr frame = m_documentUnderMouse ? m_documentUnderMouse->frame() : nullptr; + if (frame && !frame->eventHandler().canDropCurrentlyDraggedImageAsFile()) + dragData.disallowFileAccess(); +} + static HTMLInputElement* asFileInput(Node& node) { if (!is(node)) diff --git a/Source/WebCore/page/DragController.h b/Source/WebCore/page/DragController.h index fe4973e98f74..12c43406805d 100644 --- a/Source/WebCore/page/DragController.h +++ b/Source/WebCore/page/DragController.h @@ -61,10 +61,10 @@ class DragController { static DragOperation platformGenericDragOperation(); - WEBCORE_EXPORT std::optional dragEntered(const DragData&); - WEBCORE_EXPORT void dragExited(const DragData&); - WEBCORE_EXPORT std::optional dragUpdated(const DragData&); - WEBCORE_EXPORT bool performDragOperation(const DragData&); + WEBCORE_EXPORT std::optional dragEntered(DragData&&); + WEBCORE_EXPORT void dragExited(DragData&&); + WEBCORE_EXPORT std::optional dragUpdated(DragData&&); + WEBCORE_EXPORT bool performDragOperation(DragData&&); WEBCORE_EXPORT void dragCancelled(); bool mouseIsOverFileInput() const { return m_fileInputElementUnderMouse; } @@ -110,7 +110,7 @@ class DragController { bool dispatchTextInputEventFor(Frame*, const DragData&); bool canProcessDrag(const DragData&); bool concludeEditDrag(const DragData&); - std::optional dragEnteredOrUpdated(const DragData&); + std::optional dragEnteredOrUpdated(DragData&&); std::optional operationForLoad(const DragData&); DragHandlingMethod tryDocumentDrag(const DragData&, OptionSet, std::optional&); bool tryDHTMLDrag(const DragData&, std::optional&); @@ -121,6 +121,7 @@ class DragController { void mouseMovedIntoDocument(Document*); bool shouldUseCachedImageForDragImage(const Image&) const; + void disallowFileAccessIfNeeded(DragData&); std::optional hitTestResultForDragStart(Frame&, Element&, const IntPoint&) const; diff --git a/Source/WebCore/page/DragState.h b/Source/WebCore/page/DragState.h index 3b0fc9e4558a..a15403883eaf 100644 --- a/Source/WebCore/page/DragState.h +++ b/Source/WebCore/page/DragState.h @@ -37,6 +37,7 @@ struct DragState { bool shouldDispatchEvents; OptionSet type; // Should be std::optional<>. See bug 213086. RefPtr dataTransfer; // Used on only the source side of dragging. + RefPtr restrictedOriginForImageData; }; } // namespace WebCore diff --git a/Source/WebCore/page/EventHandler.cpp b/Source/WebCore/page/EventHandler.cpp index 2bf547f81305..130bca60a35f 100644 --- a/Source/WebCore/page/EventHandler.cpp +++ b/Source/WebCore/page/EventHandler.cpp @@ -2299,6 +2299,12 @@ Element* EventHandler::draggingElement() const return dragState().source.get(); } +bool EventHandler::canDropCurrentlyDraggedImageAsFile() const +{ + auto sourceOrigin = dragState().restrictedOriginForImageData; + return !sourceOrigin || m_frame.document()->securityOrigin().canReceiveDragData(*sourceOrigin); +} + static std::pair> contentFrameForNode(Node* target) { if (!is(target)) @@ -4067,6 +4073,7 @@ bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event, CheckDr // Careful that the drag starting logic stays in sync with eventMayStartDrag(). if (m_mouseDownMayStartDrag && !dragState().source) { dragState().shouldDispatchEvents = updateDragSourceActionsAllowed().contains(DragSourceAction::DHTML); + dragState().restrictedOriginForImageData = nullptr; // Try to find an element that wants to be dragged. HitTestResult result(m_mouseDownContentsPosition); @@ -4166,6 +4173,14 @@ bool EventHandler::handleDrag(const MouseEventWithHitTestResults& event, CheckDr } } + if (dragState().source && dragState().type == DragSourceAction::Image) { + if (auto* renderImage = dynamicDowncast(dragState().source->renderer())) { + auto* image = renderImage->cachedImage(); + if (image && !image->isCORSSameOrigin()) + dragState().restrictedOriginForImageData = SecurityOrigin::create(image->url()); + } + } + dragState().dataTransfer->makeInvalidForSecurity(); if (m_mouseDownMayStartDrag) { diff --git a/Source/WebCore/page/EventHandler.h b/Source/WebCore/page/EventHandler.h index e3c31cf0b588..6b902a57f215 100644 --- a/Source/WebCore/page/EventHandler.h +++ b/Source/WebCore/page/EventHandler.h @@ -353,6 +353,8 @@ class EventHandler { Element* draggingElement() const; #endif + bool canDropCurrentlyDraggedImageAsFile() const; + WEBCORE_EXPORT void invalidateClick(); #if ENABLE(IMAGE_ANALYSIS) diff --git a/Source/WebCore/page/SecurityOrigin.cpp b/Source/WebCore/page/SecurityOrigin.cpp index d08652501dbb..47439f9f9b2f 100644 --- a/Source/WebCore/page/SecurityOrigin.cpp +++ b/Source/WebCore/page/SecurityOrigin.cpp @@ -355,6 +355,9 @@ bool SecurityOrigin::canReceiveDragData(const SecurityOrigin& dragInitiator) con if (this == &dragInitiator) return true; + if (dragInitiator.isLocal() && isLocal()) + return true; + return isSameOriginDomain(dragInitiator); } diff --git a/Source/WebCore/platform/DragData.cpp b/Source/WebCore/platform/DragData.cpp index f32573234fa0..5b1b5e55b9d0 100644 --- a/Source/WebCore/platform/DragData.cpp +++ b/Source/WebCore/platform/DragData.cpp @@ -61,6 +61,12 @@ std::unique_ptr DragData::createPasteboardContext() const return PagePasteboardContext::create(std::optional { m_pageID }); } +void DragData::disallowFileAccess() +{ + m_fileNames = { }; + m_disallowFileAccess = true; +} + } // namespace WebCore #endif // ENABLE(DRAG_SUPPORT) diff --git a/Source/WebCore/platform/DragData.h b/Source/WebCore/platform/DragData.h index 6600dfa7b189..9bfca89c3beb 100644 --- a/Source/WebCore/platform/DragData.h +++ b/Source/WebCore/platform/DragData.h @@ -108,6 +108,7 @@ class DragData { OptionSet dragDestinationActionMask() const { return m_dragDestinationActionMask; } void setFileNames(Vector& fileNames) { m_fileNames = WTFMove(fileNames); } const Vector& fileNames() const { return m_fileNames; } + void disallowFileAccess(); #if PLATFORM(COCOA) const String& pasteboardName() const { return m_pasteboardName; } bool containsURLTypeIdentifier() const; @@ -133,6 +134,7 @@ class DragData { #if PLATFORM(WIN) DragDataMap m_dragDataMap; #endif + bool m_disallowFileAccess { false }; }; } // namespace WebCore diff --git a/Source/WebCore/platform/cocoa/DragDataCocoa.mm b/Source/WebCore/platform/cocoa/DragDataCocoa.mm index 7bee621b775c..4cbbb888a45d 100644 --- a/Source/WebCore/platform/cocoa/DragDataCocoa.mm +++ b/Source/WebCore/platform/cocoa/DragDataCocoa.mm @@ -182,17 +182,21 @@ static inline String tiffPasteboardType() bool DragData::containsFiles() const { - return numberOfFiles(); + return !m_disallowFileAccess && numberOfFiles(); } unsigned DragData::numberOfFiles() const { + if (m_disallowFileAccess) + return 0; auto context = createPasteboardContext(); return platformStrategies()->pasteboardStrategy()->getNumberOfFiles(m_pasteboardName, context.get()); } Vector DragData::asFilenames() const { + if (m_disallowFileAccess) + return { }; auto context = createPasteboardContext(); #if PLATFORM(MAC) Vector types; @@ -264,8 +268,8 @@ static inline String tiffPasteboardType() || types.contains(htmlPasteboardType()) || types.contains(String(kUTTypeWebArchive)) #if PLATFORM(MAC) - || types.contains(String(legacyFilenamesPasteboardType())) - || types.contains(String(legacyFilesPromisePasteboardType())) + || (!m_disallowFileAccess && types.contains(String(legacyFilenamesPasteboardType()))) + || (!m_disallowFileAccess && types.contains(String(legacyFilesPromisePasteboardType()))) #endif || types.contains(tiffPasteboardType()) || types.contains(pdfPasteboardType()) @@ -282,6 +286,8 @@ static inline String tiffPasteboardType() bool DragData::containsPromise() const { + if (m_disallowFileAccess) + return false; auto context = createPasteboardContext(); // FIXME: legacyFilesPromisePasteboardType() contains UTIs, not path names. Also, why do we // think promises should only contain one file (or UTI)? diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.cpp b/Source/WebKit/WebProcess/WebPage/WebPage.cpp index dc1d87f2d22a..21e4fa71bfa2 100644 --- a/Source/WebKit/WebProcess/WebPage/WebPage.cpp +++ b/Source/WebKit/WebProcess/WebPage/WebPage.cpp @@ -4643,28 +4643,28 @@ void WebPage::performDragControllerAction(DragControllerAction action, const Int DragData dragData(&selectionData, clientPosition, globalPosition, draggingSourceOperationMask, flags, anyDragDestinationAction(), m_identifier); switch (action) { case DragControllerAction::Entered: { - auto resolvedDragOperation = m_page->dragController().dragEntered(dragData); + auto resolvedDragOperation = m_page->dragController().dragEntered(WTFMove(dragData)); send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController().dragHandlingMethod(), m_page->dragController().mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted(), { }, { })); return; } case DragControllerAction::Updated: { - auto resolvedDragOperation = m_page->dragController().dragUpdated(dragData); + auto resolvedDragOperation = m_page->dragController().dragUpdated(WTFMove(dragData)); send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController().dragHandlingMethod(), m_page->dragController().mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted(), { }, { })); return; } case DragControllerAction::Exited: - m_page->dragController().dragExited(dragData); + m_page->dragController().dragExited(WTFMove(dragData)); return; case DragControllerAction::PerformDragOperation: { - m_page->dragController().performDragOperation(dragData); + m_page->dragController().performDragOperation(WTFMove(dragData)); return; } } ASSERT_NOT_REACHED(); } #else -void WebPage::performDragControllerAction(DragControllerAction action, const WebCore::DragData& dragData, SandboxExtension::Handle&& sandboxExtensionHandle, Vector&& sandboxExtensionsHandleArray) +void WebPage::performDragControllerAction(DragControllerAction action, WebCore::DragData&& dragData, SandboxExtension::Handle&& sandboxExtensionHandle, Vector&& sandboxExtensionsHandleArray) { if (!m_page) { send(Messages::WebPageProxy::DidPerformDragControllerAction(std::nullopt, DragHandlingMethod::None, false, 0, { }, { })); @@ -4673,17 +4673,17 @@ void WebPage::performDragControllerAction(DragControllerAction action, const Web switch (action) { case DragControllerAction::Entered: { - auto resolvedDragOperation = m_page->dragController().dragEntered(dragData); + auto resolvedDragOperation = m_page->dragController().dragEntered(WTFMove(dragData)); send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController().dragHandlingMethod(), m_page->dragController().mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted(), m_page->dragCaretController().caretRectInRootViewCoordinates(), m_page->dragCaretController().editableElementRectInRootViewCoordinates())); return; } case DragControllerAction::Updated: { - auto resolvedDragOperation = m_page->dragController().dragUpdated(dragData); + auto resolvedDragOperation = m_page->dragController().dragUpdated(WTFMove(dragData)); send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController().dragHandlingMethod(), m_page->dragController().mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted(), m_page->dragCaretController().caretRectInRootViewCoordinates(), m_page->dragCaretController().editableElementRectInRootViewCoordinates())); return; } case DragControllerAction::Exited: - m_page->dragController().dragExited(dragData); + m_page->dragController().dragExited(WTFMove(dragData)); send(Messages::WebPageProxy::DidPerformDragControllerAction(std::nullopt, DragHandlingMethod::None, false, 0, { }, { })); return; @@ -4696,7 +4696,7 @@ void WebPage::performDragControllerAction(DragControllerAction action, const Web m_pendingDropExtensionsForFileUpload.append(extension); } - bool handled = m_page->dragController().performDragOperation(dragData); + bool handled = m_page->dragController().performDragOperation(WTFMove(dragData)); // If we started loading a local file, the sandbox extension tracker would have adopted this // pending drop sandbox extension. If not, we'll play it safe and clear it. diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.h b/Source/WebKit/WebProcess/WebPage/WebPage.h index 845567213825..1cd4415fa9bc 100644 --- a/Source/WebKit/WebProcess/WebPage/WebPage.h +++ b/Source/WebKit/WebProcess/WebPage/WebPage.h @@ -1027,7 +1027,7 @@ class WebPage : public API::ObjectImpl, public IP #endif #if ENABLE(DRAG_SUPPORT) && !PLATFORM(GTK) - void performDragControllerAction(DragControllerAction, const WebCore::DragData&, SandboxExtension::Handle&&, Vector&&); + void performDragControllerAction(DragControllerAction, WebCore::DragData&&, SandboxExtension::Handle&&, Vector&&); #endif #if ENABLE(DRAG_SUPPORT) diff --git a/Source/WebKitLegacy/mac/WebView/WebView.mm b/Source/WebKitLegacy/mac/WebView/WebView.mm index 48cc5be9887a..09dae0b3087b 100644 --- a/Source/WebKitLegacy/mac/WebView/WebView.mm +++ b/Source/WebKitLegacy/mac/WebView/WebView.mm @@ -2012,21 +2012,21 @@ - (uint64_t)_enteredDataInteraction:(id )session client:(CGPoint) { WebThreadLock(); auto dragData = [self dragDataForSession:session client:clientPosition global:globalPosition operation:operation]; - return kit(_private->page->dragController().dragEntered(dragData)); + return kit(_private->page->dragController().dragEntered(WTFMove(dragData))); } - (uint64_t)_updatedDataInteraction:(id )session client:(CGPoint)clientPosition global:(CGPoint)globalPosition operation:(uint64_t)operation { WebThreadLock(); auto dragData = [self dragDataForSession:session client:clientPosition global:globalPosition operation:operation]; - return kit(_private->page->dragController().dragUpdated(dragData)); + return kit(_private->page->dragController().dragUpdated(WTFMove(dragData))); } - (void)_exitedDataInteraction:(id )session client:(CGPoint)clientPosition global:(CGPoint)globalPosition operation:(uint64_t)operation { WebThreadLock(); auto dragData = [self dragDataForSession:session client:clientPosition global:globalPosition operation:operation]; - _private->page->dragController().dragExited(dragData); + _private->page->dragController().dragExited(WTFMove(dragData)); } - (void)_performDataInteraction:(id )session client:(CGPoint)clientPosition global:(CGPoint)globalPosition operation:(uint64_t)operation @@ -2038,7 +2038,7 @@ - (BOOL)_tryToPerformDataInteraction:(id )session client:(CGPoint { WebThreadLock(); auto dragData = [self dragDataForSession:session client:clientPosition global:globalPosition operation:operation]; - return _private->page->dragController().performDragOperation(dragData); + return _private->page->dragController().performDragOperation(WTFMove(dragData)); } - (void)_endedDataInteraction:(CGPoint)clientPosition global:(CGPoint)globalPosition @@ -6366,7 +6366,7 @@ - (NSDragOperation)draggingEntered:(id )draggingInfo WebCore::IntPoint global(WebCore::globalPoint([draggingInfo draggingLocation], [self window])); WebCore::DragData dragData(draggingInfo, client, global, coreDragOperationMask([draggingInfo draggingSourceOperationMask]), [self _applicationFlagsForDrag:draggingInfo], [self actionMaskForDraggingInfo:draggingInfo]); - return kit(core(self)->dragController().dragEntered(dragData)); + return kit(core(self)->dragController().dragEntered(WTFMove(dragData))); } - (NSDragOperation)draggingUpdated:(id )draggingInfo @@ -6379,7 +6379,7 @@ - (NSDragOperation)draggingUpdated:(id )draggingInfo WebCore::IntPoint global(WebCore::globalPoint([draggingInfo draggingLocation], [self window])); WebCore::DragData dragData(draggingInfo, client, global, coreDragOperationMask([draggingInfo draggingSourceOperationMask]), [self _applicationFlagsForDrag:draggingInfo], [self actionMaskForDraggingInfo:draggingInfo]); - return kit(page->dragController().dragUpdated(dragData)); + return kit(page->dragController().dragUpdated(WTFMove(dragData))); } - (void)draggingExited:(id )draggingInfo @@ -6391,7 +6391,7 @@ - (void)draggingExited:(id )draggingInfo WebCore::IntPoint client([draggingInfo draggingLocation]); WebCore::IntPoint global(WebCore::globalPoint([draggingInfo draggingLocation], [self window])); WebCore::DragData dragData(draggingInfo, client, global, coreDragOperationMask([draggingInfo draggingSourceOperationMask]), [self _applicationFlagsForDrag:draggingInfo]); - page->dragController().dragExited(dragData); + page->dragController().dragExited(WTFMove(dragData)); } - (BOOL)prepareForDragOperation:(id )draggingInfo @@ -6439,7 +6439,7 @@ - (BOOL)performDragOperation:(id )draggingInfo fileNames->append(path.get()); if (fileNames->size() == fileCount) { dragData->setFileNames(*fileNames); - core(self)->dragController().performDragOperation(*dragData); + core(self)->dragController().performDragOperation(WebCore::DragData { *dragData }); delete dragData; delete fileNames; } @@ -6449,7 +6449,7 @@ - (BOOL)performDragOperation:(id )draggingInfo return true; } - bool returnValue = core(self)->dragController().performDragOperation(*dragData); + bool returnValue = core(self)->dragController().performDragOperation(WebCore::DragData { *dragData }); delete dragData; return returnValue; diff --git a/Source/WebKitLegacy/win/WebView.cpp b/Source/WebKitLegacy/win/WebView.cpp index c01cf7d5db13..6b8d6a839652 100644 --- a/Source/WebKitLegacy/win/WebView.cpp +++ b/Source/WebKitLegacy/win/WebView.cpp @@ -5624,7 +5624,7 @@ HRESULT WebView::DragEnter(IDataObject* pDataObject, DWORD grfKeyState, POINTL p ::ScreenToClient(m_viewWindow, (LPPOINT)&localpt); DragData data(pDataObject, IntPoint(localpt.x, localpt.y), IntPoint(pt.x, pt.y), keyStateToDragOperation(grfKeyState)); - *pdwEffect = dragOperationToDragCursor(m_page->dragController().dragEntered(data)); + *pdwEffect = dragOperationToDragCursor(m_page->dragController().dragEntered(WTFMove(data))); m_lastDropEffect = *pdwEffect; m_dragData = pDataObject; @@ -5642,7 +5642,7 @@ HRESULT WebView::DragOver(DWORD grfKeyState, POINTL pt, DWORD* pdwEffect) ::ScreenToClient(m_viewWindow, (LPPOINT)&localpt); DragData data(m_dragData.get(), IntPoint(localpt.x, localpt.y), IntPoint(pt.x, pt.y), keyStateToDragOperation(grfKeyState)); - *pdwEffect = dragOperationToDragCursor(m_page->dragController().dragUpdated(data)); + *pdwEffect = dragOperationToDragCursor(m_page->dragController().dragUpdated(WTFMove(data))); } else *pdwEffect = DROPEFFECT_NONE; @@ -5657,7 +5657,7 @@ HRESULT WebView::DragLeave() if (m_dragData) { DragData data(m_dragData.get(), IntPoint(), IntPoint(), { }); - m_page->dragController().dragExited(data); + m_page->dragController().dragExited(WTFMove(data)); m_dragData = 0; } return S_OK; @@ -5674,7 +5674,7 @@ HRESULT WebView::Drop(IDataObject* pDataObject, DWORD grfKeyState, POINTL pt, DW ::ScreenToClient(m_viewWindow, (LPPOINT)&localpt); DragData data(pDataObject, IntPoint(localpt.x, localpt.y), IntPoint(pt.x, pt.y), keyStateToDragOperation(grfKeyState)); - m_page->dragController().performDragOperation(data); + m_page->dragController().performDragOperation(WTFMove(data)); return S_OK; } diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/DragAndDropTests.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/DragAndDropTests.mm index 3f4b53ccb100..e7989bb5caf6 100644 --- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/DragAndDropTests.mm +++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/DragAndDropTests.mm @@ -30,6 +30,7 @@ #import "DragAndDropSimulator.h" #import "PlatformUtilities.h" +#import "TestURLSchemeHandler.h" #import "WKWebViewConfigurationExtras.h" #import #import @@ -443,4 +444,8 @@ static DragStartData runDragStartDataTestCase(DragAndDropSimulator *simulator, N #endif // ENABLE(IMAGE_ANALYSIS) +#if USE(APPLE_INTERNAL_SDK) && __has_include() +#import +#endif + #endif // ENABLE(DRAG_SUPPORT) && !PLATFORM(MACCATALYST)