Diff
Modified: trunk/Source/WebKit/ChangeLog (271684 => 271685)
--- trunk/Source/WebKit/ChangeLog 2021-01-21 02:53:18 UTC (rev 271684)
+++ trunk/Source/WebKit/ChangeLog 2021-01-21 03:29:56 UTC (rev 271685)
@@ -1,3 +1,37 @@
+2021-01-20 Wenson Hsieh <wenson_hs...@apple.com>
+
+ [macOS] Include an origin identifier when writing promised image data to the drag pasteboard
+ https://bugs.webkit.org/show_bug.cgi?id=220782
+
+ Reviewed by Megan Gardner.
+
+ Add plumbing in WebKit to serialize and write the pasteboard origin identifier via custom data when dragging an
+ image with promised data on macOS. In the case where we're dragging an image into a contenteditable area in a
+ document with the *same* pasteboard origin, this allows us to avoid sanitizing the web archive data upon
+ handling the drop.
+
+ Test: DragAndDropTests.ProvideImageDataForMultiplePasteboards
+
+ * UIProcess/Cocoa/WebPageProxyCocoa.mm:
+ (WebKit::WebPageProxy::setPromisedDataForImage):
+ * UIProcess/Cocoa/WebViewImpl.h:
+ * UIProcess/Cocoa/WebViewImpl.mm:
+ (WebKit::WebViewImpl::setPromisedDataForImage):
+
+ If specified, write the origin to the drag pasteboard by creating a new `PasteboardCustomData` object, setting
+ its origin, and then serializing the custom data object into an `NSData`.
+
+ * UIProcess/PageClient.h:
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebPageProxy.messages.in:
+ * UIProcess/mac/PageClientImplMac.h:
+ * UIProcess/mac/PageClientImplMac.mm:
+ (WebKit::PageClientImpl::setPromisedDataForImage):
+ * UIProcess/mac/WebPageProxyMac.mm:
+ (WebKit::WebPageProxy::setPromisedDataForImage):
+ * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
+ (WebKit::WebDragClient::declareAndWriteDragImage):
+
2021-01-20 Kenneth Russell <k...@chromium.org>
Support WEBGL_multi_draw extension
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm (271684 => 271685)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm 2021-01-21 02:53:18 UTC (rev 271684)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm 2021-01-21 03:29:56 UTC (rev 271685)
@@ -210,7 +210,7 @@
// FIXME: Move these functions to WebPageProxyIOS.mm.
#if PLATFORM(IOS_FAMILY)
-void WebPageProxy::setPromisedDataForImage(const String&, const SharedMemory::IPCHandle&, const String&, const String&, const String&, const String&, const String&, const SharedMemory::IPCHandle&)
+void WebPageProxy::setPromisedDataForImage(const String&, const SharedMemory::IPCHandle&, const String&, const String&, const String&, const String&, const String&, const SharedMemory::IPCHandle&, const String&)
{
notImplemented();
}
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h (271684 => 271685)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h 2021-01-21 02:53:18 UTC (rev 271684)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h 2021-01-21 03:29:56 UTC (rev 271685)
@@ -486,7 +486,7 @@
void startDrag(const WebCore::DragItem&, const ShareableBitmap::Handle& image);
void setFileAndURLTypes(NSString *filename, NSString *extension, NSString *title, NSString *url, NSString *visibleURL, NSPasteboard *);
- void setPromisedDataForImage(WebCore::Image*, NSString *filename, NSString *extension, NSString *title, NSString *url, NSString *visibleURL, WebCore::SharedBuffer* archiveBuffer, NSString *pasteboardName);
+ void setPromisedDataForImage(WebCore::Image*, NSString *filename, NSString *extension, NSString *title, NSString *url, NSString *visibleURL, WebCore::SharedBuffer* archiveBuffer, NSString *pasteboardName, NSString *pasteboardOrigin);
void pasteboardChangedOwner(NSPasteboard *);
void provideDataForPasteboard(NSPasteboard *, NSString *type);
NSArray *namesOfPromisedFilesDroppedAtDestination(NSURL *dropDestination);
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (271684 => 271685)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2021-01-21 02:53:18 UTC (rev 271684)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2021-01-21 03:29:56 UTC (rev 271685)
@@ -4329,7 +4329,7 @@
m_promisedURL = url;
}
-void WebViewImpl::setPromisedDataForImage(WebCore::Image* image, NSString *filename, NSString *extension, NSString *title, NSString *url, NSString *visibleURL, WebCore::SharedBuffer* archiveBuffer, NSString *pasteboardName)
+void WebViewImpl::setPromisedDataForImage(WebCore::Image* image, NSString *filename, NSString *extension, NSString *title, NSString *url, NSString *visibleURL, WebCore::SharedBuffer* archiveBuffer, NSString *pasteboardName, NSString *originIdentifier)
{
NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:pasteboardName];
RetainPtr<NSMutableArray> types = adoptNS([[NSMutableArray alloc] initWithObjects:WebCore::legacyFilesPromisePasteboardType(), nil]);
@@ -4337,6 +4337,14 @@
if (image && !image->uti().isEmpty() && image->data() && !image->data()->isEmpty())
[types addObject:image->uti()];
+ RetainPtr<NSData> customDataBuffer;
+ if (originIdentifier.length) {
+ [types addObject:@(PasteboardCustomData::cocoaType())];
+ PasteboardCustomData customData;
+ customData.setOrigin(originIdentifier);
+ customDataBuffer = customData.createSharedBuffer()->createNSData();
+ }
+
[types addObjectsFromArray:archiveBuffer ? PasteboardTypes::forImagesWithArchive() : PasteboardTypes::forImages()];
[pasteboard declareTypes:types.get() owner:m_view.getAutoreleased()];
setFileAndURLTypes(filename, extension, title, url, visibleURL, pasteboard);
@@ -4349,6 +4357,9 @@
[pasteboard setData:nsData.get() forType:PasteboardTypes::WebArchivePboardType];
}
+ if (customDataBuffer)
+ [pasteboard setData:customDataBuffer.get() forType:@(PasteboardCustomData::cocoaType())];
+
m_promisedImage = image;
}
Modified: trunk/Source/WebKit/UIProcess/PageClient.h (271684 => 271685)
--- trunk/Source/WebKit/UIProcess/PageClient.h 2021-01-21 02:53:18 UTC (rev 271684)
+++ trunk/Source/WebKit/UIProcess/PageClient.h 2021-01-21 03:29:56 UTC (rev 271685)
@@ -308,7 +308,7 @@
#endif
#if USE(APPKIT)
- virtual void setPromisedDataForImage(const String& pasteboardName, Ref<WebCore::SharedBuffer>&& imageBuffer, const String& filename, const String& extension, const String& title, const String& url, const String& visibleUrl, RefPtr<WebCore::SharedBuffer>&& archiveBuffer) = 0;
+ virtual void setPromisedDataForImage(const String& pasteboardName, Ref<WebCore::SharedBuffer>&& imageBuffer, const String& filename, const String& extension, const String& title, const String& url, const String& visibleURL, RefPtr<WebCore::SharedBuffer>&& archiveBuffer, const String& originIdentifier) = 0;
#endif
virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&) = 0;
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (271684 => 271685)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2021-01-21 02:53:18 UTC (rev 271684)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2021-01-21 03:29:56 UTC (rev 271685)
@@ -1173,7 +1173,7 @@
#if PLATFORM(COCOA)
void startDrag(const WebCore::DragItem&, const ShareableBitmap::Handle& dragImageHandle);
void setPromisedDataForImage(const String& pasteboardName, const SharedMemory::IPCHandle& imageHandle, const String& filename, const String& extension,
- const String& title, const String& url, const String& visibleURL, const SharedMemory::IPCHandle& archiveHandle);
+ const String& title, const String& url, const String& visibleURL, const SharedMemory::IPCHandle& archiveHandle, const String& originIdentifier);
#endif
#if PLATFORM(GTK)
void startDrag(WebCore::SelectionData&&, OptionSet<WebCore::DragOperation>, const ShareableBitmap::Handle& dragImage);
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (271684 => 271685)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2021-01-21 02:53:18 UTC (rev 271684)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2021-01-21 03:29:56 UTC (rev 271685)
@@ -307,7 +307,7 @@
#endif
#if PLATFORM(COCOA) && ENABLE(DRAG_SUPPORT)
StartDrag(struct WebCore::DragItem dragItem, WebKit::ShareableBitmap::Handle dragImage)
- SetPromisedDataForImage(String pasteboardName, WebKit::SharedMemory::IPCHandle imageHandle, String filename, String extension, String title, String url, String visibleURL, WebKit::SharedMemory::IPCHandle archiveHandle)
+ SetPromisedDataForImage(String pasteboardName, WebKit::SharedMemory::IPCHandle imageHandle, String filename, String extension, String title, String url, String visibleURL, WebKit::SharedMemory::IPCHandle archiveHandle, String originIdentifier)
#endif
#if PLATFORM(GTK) && ENABLE(DRAG_SUPPORT)
StartDrag(WebCore::SelectionData selectionData, OptionSet<WebCore::DragOperation> dragOperationMask, WebKit::ShareableBitmap::Handle dragImage)
Modified: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h (271684 => 271685)
--- trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h 2021-01-21 02:53:18 UTC (rev 271684)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h 2021-01-21 03:29:56 UTC (rev 271685)
@@ -101,7 +101,7 @@
bool executeSavedCommandBySelector(const String& selector) override;
void startDrag(const WebCore::DragItem&, const ShareableBitmap::Handle& image) override;
void setPromisedDataForImage(const String& pasteboardName, Ref<WebCore::SharedBuffer>&& imageBuffer, const String& filename, const String& extension, const String& title,
- const String& url, const String& visibleUrl, RefPtr<WebCore::SharedBuffer>&& archiveBuffer) override;
+ const String& url, const String& visibleURL, RefPtr<WebCore::SharedBuffer>&& archiveBuffer, const String& originIdentifier) override;
void updateSecureInputState() override;
void resetSecureInputState() override;
void notifyInputContextAboutDiscardedComposition() override;
Modified: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm (271684 => 271685)
--- trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm 2021-01-21 02:53:18 UTC (rev 271684)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm 2021-01-21 03:29:56 UTC (rev 271685)
@@ -399,11 +399,11 @@
m_impl->startDrag(item, image);
}
-void PageClientImpl::setPromisedDataForImage(const String& pasteboardName, Ref<SharedBuffer>&& imageBuffer, const String& filename, const String& extension, const String& title, const String& url, const String& visibleURL, RefPtr<SharedBuffer>&& archiveBuffer)
+void PageClientImpl::setPromisedDataForImage(const String& pasteboardName, Ref<SharedBuffer>&& imageBuffer, const String& filename, const String& extension, const String& title, const String& url, const String& visibleURL, RefPtr<SharedBuffer>&& archiveBuffer, const String& originIdentifier)
{
auto image = BitmapImage::create();
image->setData(WTFMove(imageBuffer), true);
- m_impl->setPromisedDataForImage(image.ptr(), filename, extension, title, url, visibleURL, archiveBuffer.get(), pasteboardName);
+ m_impl->setPromisedDataForImage(image.ptr(), filename, extension, title, url, visibleURL, archiveBuffer.get(), pasteboardName, originIdentifier);
}
void PageClientImpl::updateSecureInputState()
Modified: trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm (271684 => 271685)
--- trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm 2021-01-21 02:53:18 UTC (rev 271684)
+++ trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm 2021-01-21 03:29:56 UTC (rev 271685)
@@ -262,7 +262,7 @@
#if ENABLE(DRAG_SUPPORT)
void WebPageProxy::setPromisedDataForImage(const String& pasteboardName, const SharedMemory::IPCHandle& imageHandle, const String& filename, const String& extension,
- const String& title, const String& url, const String& visibleURL, const SharedMemory::IPCHandle& archiveHandle)
+ const String& title, const String& url, const String& visibleURL, const SharedMemory::IPCHandle& archiveHandle, const String& originIdentifier)
{
MESSAGE_CHECK_URL(url);
MESSAGE_CHECK_URL(visibleURL);
@@ -281,7 +281,7 @@
return;
archiveBuffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryArchive->data()), static_cast<size_t>(archiveHandle.dataSize));
}
- pageClient().setPromisedDataForImage(pasteboardName, WTFMove(imageBuffer), ResourceResponseBase::sanitizeSuggestedFilename(filename), extension, title, url, visibleURL, WTFMove(archiveBuffer));
+ pageClient().setPromisedDataForImage(pasteboardName, WTFMove(imageBuffer), ResourceResponseBase::sanitizeSuggestedFilename(filename), extension, title, url, visibleURL, WTFMove(archiveBuffer), originIdentifier);
}
#endif
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm (271684 => 271685)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm 2021-01-21 02:53:18 UTC (rev 271684)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm 2021-01-21 03:29:56 UTC (rev 271685)
@@ -181,7 +181,7 @@
filename = downloadFilename;
}
- m_page->send(Messages::WebPageProxy::SetPromisedDataForImage(pasteboardName, SharedMemory::IPCHandle { WTFMove(imageHandle), imageSize }, filename, extension, title, String([[response URL] absoluteString]), WTF::userVisibleString(url), SharedMemory::IPCHandle { WTFMove(archiveHandle), archiveSize }));
+ m_page->send(Messages::WebPageProxy::SetPromisedDataForImage(pasteboardName, SharedMemory::IPCHandle { WTFMove(imageHandle), imageSize }, filename, extension, title, String([[response URL] absoluteString]), WTF::userVisibleString(url), SharedMemory::IPCHandle { WTFMove(archiveHandle), archiveSize }, element.document().originIdentifierForPasteboard()));
}
#else
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (271684 => 271685)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2021-01-21 02:53:18 UTC (rev 271684)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2021-01-21 03:29:56 UTC (rev 271685)
@@ -1,3 +1,15 @@
+2021-01-20 Wenson Hsieh <wenson_hs...@apple.com>
+
+ [macOS] Include an origin identifier when writing promised image data to the drag pasteboard
+ https://bugs.webkit.org/show_bug.cgi?id=220782
+
+ Reviewed by Megan Gardner.
+
+ See WebKit ChangeLog for more details.
+
+ * Misc/WebNSPasteboardExtras.mm:
+ (-[NSPasteboard _web_declareAndWriteDragImageForElement:URL:title:archive:source:]):
+
2021-01-19 Keith Rollin <krol...@apple.com>
Modularize WebKitLegacy.framework
Modified: trunk/Source/WebKitLegacy/mac/Misc/WebNSPasteboardExtras.mm (271684 => 271685)
--- trunk/Source/WebKitLegacy/mac/Misc/WebNSPasteboardExtras.mm 2021-01-21 02:53:18 UTC (rev 271684)
+++ trunk/Source/WebKitLegacy/mac/Misc/WebNSPasteboardExtras.mm 2021-01-21 03:29:56 UTC (rev 271685)
@@ -43,6 +43,7 @@
#import <WebCore/Image.h>
#import <WebCore/LegacyNSPasteboardTypes.h>
#import <WebCore/MIMETypeRegistry.h>
+#import <WebCore/PasteboardCustomData.h>
#import <WebCore/RenderAttachment.h>
#import <WebCore/RenderImage.h>
#import <WebKitLegacy/DOMExtensions.h>
@@ -282,6 +283,15 @@
NSString *extension = @"";
RetainPtr<NSMutableArray> types = adoptNS([[NSMutableArray alloc] initWithObjects:legacyFilesPromisePasteboardType(), nil]);
+ NSString *originIdentifier = core(element)->document().originIdentifierForPasteboard();
+ RetainPtr<NSData> customDataBuffer;
+ if (originIdentifier.length) {
+ [types addObject:@(PasteboardCustomData::cocoaType())];
+ PasteboardCustomData customData;
+ customData.setOrigin(originIdentifier);
+ customDataBuffer = customData.createSharedBuffer()->createNSData();
+ }
+
if (auto* renderer = core(element)->renderer()) {
if (is<RenderImage>(*renderer)) {
if (auto* image = downcast<RenderImage>(*renderer).cachedImage()) {
@@ -304,6 +314,8 @@
}
[self _web_writeImage:nil element:element URL:URL title:title archive:archive types:types.get() source:source];
+ if (customDataBuffer)
+ [self setData:customDataBuffer.get() forType:@(PasteboardCustomData::cocoaType())];
NSArray *extensions = [[NSArray alloc] initWithObjects:extension, nil];
[self setPropertyList:extensions forType:legacyFilesPromisePasteboardType()];
Modified: trunk/Tools/ChangeLog (271684 => 271685)
--- trunk/Tools/ChangeLog 2021-01-21 02:53:18 UTC (rev 271684)
+++ trunk/Tools/ChangeLog 2021-01-21 03:29:56 UTC (rev 271685)
@@ -1,3 +1,15 @@
+2021-01-20 Wenson Hsieh <wenson_hs...@apple.com>
+
+ [macOS] Include an origin identifier when writing promised image data to the drag pasteboard
+ https://bugs.webkit.org/show_bug.cgi?id=220782
+
+ Reviewed by Megan Gardner.
+
+ Make a slight adjustment to an existing API test, to verify that custom pasteboard data is serialized when
+ dragging an image element.
+
+ * TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm:
+
2021-01-20 Jonathan Bedard <jbed...@apple.com>
[webkitcorepy] Add TaskPool
Modified: trunk/Tools/TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm (271684 => 271685)
--- trunk/Tools/TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm 2021-01-21 02:53:18 UTC (rev 271684)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm 2021-01-21 03:29:56 UTC (rev 271685)
@@ -28,6 +28,7 @@
#import "DragAndDropSimulator.h"
#import "InstanceMethodSwizzler.h"
#import "PlatformUtilities.h"
+#import <WebCore/PasteboardCustomData.h>
#import <WebKit/WKPreferencesPrivate.h>
#import <WebKit/WKWebViewPrivate.h>
@@ -188,6 +189,7 @@
EXPECT_EQ(imageFromUniquePasteboard.TIFFRepresentation.length, imageFromDragPasteboard.TIFFRepresentation.length);
EXPECT_TRUE(NSEqualSizes(imageFromDragPasteboard.size, imageFromUniquePasteboard.size));
EXPECT_FALSE(NSEqualSizes(NSZeroSize, imageFromUniquePasteboard.size));
+ EXPECT_GT([dragPasteboard dataForType:@(WebCore::PasteboardCustomData::cocoaType())].length, 0u);
}
TEST(DragAndDropTests, ProvideImageDataAsTypeIdentifiers)