Changeset 271685 in webkit
- Timestamp:
- Jan 20, 2021 7:29:56 PM (18 months ago)
- Location:
- trunk
- Files:
-
- 15 edited
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm (modified) (1 diff)
-
Source/WebKit/UIProcess/Cocoa/WebViewImpl.h (modified) (1 diff)
-
Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (modified) (3 diffs)
-
Source/WebKit/UIProcess/PageClient.h (modified) (1 diff)
-
Source/WebKit/UIProcess/WebPageProxy.h (modified) (1 diff)
-
Source/WebKit/UIProcess/WebPageProxy.messages.in (modified) (1 diff)
-
Source/WebKit/UIProcess/mac/PageClientImplMac.h (modified) (1 diff)
-
Source/WebKit/UIProcess/mac/PageClientImplMac.mm (modified) (1 diff)
-
Source/WebKit/UIProcess/mac/WebPageProxyMac.mm (modified) (2 diffs)
-
Source/WebKit/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm (modified) (1 diff)
-
Source/WebKitLegacy/mac/ChangeLog (modified) (1 diff)
-
Source/WebKitLegacy/mac/Misc/WebNSPasteboardExtras.mm (modified) (3 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r271679 r271685 1 2021-01-20 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [macOS] Include an origin identifier when writing promised image data to the drag pasteboard 4 https://bugs.webkit.org/show_bug.cgi?id=220782 5 6 Reviewed by Megan Gardner. 7 8 Add plumbing in WebKit to serialize and write the pasteboard origin identifier via custom data when dragging an 9 image with promised data on macOS. In the case where we're dragging an image into a contenteditable area in a 10 document with the *same* pasteboard origin, this allows us to avoid sanitizing the web archive data upon 11 handling the drop. 12 13 Test: DragAndDropTests.ProvideImageDataForMultiplePasteboards 14 15 * UIProcess/Cocoa/WebPageProxyCocoa.mm: 16 (WebKit::WebPageProxy::setPromisedDataForImage): 17 * UIProcess/Cocoa/WebViewImpl.h: 18 * UIProcess/Cocoa/WebViewImpl.mm: 19 (WebKit::WebViewImpl::setPromisedDataForImage): 20 21 If specified, write the origin to the drag pasteboard by creating a new `PasteboardCustomData` object, setting 22 its origin, and then serializing the custom data object into an `NSData`. 23 24 * UIProcess/PageClient.h: 25 * UIProcess/WebPageProxy.h: 26 * UIProcess/WebPageProxy.messages.in: 27 * UIProcess/mac/PageClientImplMac.h: 28 * UIProcess/mac/PageClientImplMac.mm: 29 (WebKit::PageClientImpl::setPromisedDataForImage): 30 * UIProcess/mac/WebPageProxyMac.mm: 31 (WebKit::WebPageProxy::setPromisedDataForImage): 32 * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm: 33 (WebKit::WebDragClient::declareAndWriteDragImage): 34 1 35 2021-01-20 Kenneth Russell <kbr@chromium.org> 2 36 -
trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm
r271493 r271685 211 211 #if PLATFORM(IOS_FAMILY) 212 212 213 void WebPageProxy::setPromisedDataForImage(const String&, const SharedMemory::IPCHandle&, const String&, const String&, const String&, const String&, const String&, const SharedMemory::IPCHandle& )213 void WebPageProxy::setPromisedDataForImage(const String&, const SharedMemory::IPCHandle&, const String&, const String&, const String&, const String&, const String&, const SharedMemory::IPCHandle&, const String&) 214 214 { 215 215 notImplemented(); -
trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h
r266654 r271685 487 487 void startDrag(const WebCore::DragItem&, const ShareableBitmap::Handle& image); 488 488 void setFileAndURLTypes(NSString *filename, NSString *extension, NSString *title, NSString *url, NSString *visibleURL, NSPasteboard *); 489 void setPromisedDataForImage(WebCore::Image*, NSString *filename, NSString *extension, NSString *title, NSString *url, NSString *visibleURL, WebCore::SharedBuffer* archiveBuffer, NSString *pasteboardName );489 void setPromisedDataForImage(WebCore::Image*, NSString *filename, NSString *extension, NSString *title, NSString *url, NSString *visibleURL, WebCore::SharedBuffer* archiveBuffer, NSString *pasteboardName, NSString *pasteboardOrigin); 490 490 void pasteboardChangedOwner(NSPasteboard *); 491 491 void provideDataForPasteboard(NSPasteboard *, NSString *type); -
trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
r271493 r271685 4330 4330 } 4331 4331 4332 void WebViewImpl::setPromisedDataForImage(WebCore::Image* image, NSString *filename, NSString *extension, NSString *title, NSString *url, NSString *visibleURL, WebCore::SharedBuffer* archiveBuffer, NSString *pasteboardName )4332 void WebViewImpl::setPromisedDataForImage(WebCore::Image* image, NSString *filename, NSString *extension, NSString *title, NSString *url, NSString *visibleURL, WebCore::SharedBuffer* archiveBuffer, NSString *pasteboardName, NSString *originIdentifier) 4333 4333 { 4334 4334 NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:pasteboardName]; … … 4337 4337 if (image && !image->uti().isEmpty() && image->data() && !image->data()->isEmpty()) 4338 4338 [types addObject:image->uti()]; 4339 4340 RetainPtr<NSData> customDataBuffer; 4341 if (originIdentifier.length) { 4342 [types addObject:@(PasteboardCustomData::cocoaType())]; 4343 PasteboardCustomData customData; 4344 customData.setOrigin(originIdentifier); 4345 customDataBuffer = customData.createSharedBuffer()->createNSData(); 4346 } 4339 4347 4340 4348 [types addObjectsFromArray:archiveBuffer ? PasteboardTypes::forImagesWithArchive() : PasteboardTypes::forImages()]; … … 4349 4357 [pasteboard setData:nsData.get() forType:PasteboardTypes::WebArchivePboardType]; 4350 4358 } 4359 4360 if (customDataBuffer) 4361 [pasteboard setData:customDataBuffer.get() forType:@(PasteboardCustomData::cocoaType())]; 4351 4362 4352 4363 m_promisedImage = image; -
trunk/Source/WebKit/UIProcess/PageClient.h
r271660 r271685 309 309 310 310 #if USE(APPKIT) 311 virtual void setPromisedDataForImage(const String& pasteboardName, Ref<WebCore::SharedBuffer>&& imageBuffer, const String& filename, const String& extension, const String& title, const String& url, const String& visibleU rl, RefPtr<WebCore::SharedBuffer>&& archiveBuffer) = 0;311 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; 312 312 #endif 313 313 -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r271660 r271685 1174 1174 void startDrag(const WebCore::DragItem&, const ShareableBitmap::Handle& dragImageHandle); 1175 1175 void setPromisedDataForImage(const String& pasteboardName, const SharedMemory::IPCHandle& imageHandle, const String& filename, const String& extension, 1176 const String& title, const String& url, const String& visibleURL, const SharedMemory::IPCHandle& archiveHandle );1176 const String& title, const String& url, const String& visibleURL, const SharedMemory::IPCHandle& archiveHandle, const String& originIdentifier); 1177 1177 #endif 1178 1178 #if PLATFORM(GTK) -
trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in
r271378 r271685 308 308 #if PLATFORM(COCOA) && ENABLE(DRAG_SUPPORT) 309 309 StartDrag(struct WebCore::DragItem dragItem, WebKit::ShareableBitmap::Handle dragImage) 310 SetPromisedDataForImage(String pasteboardName, WebKit::SharedMemory::IPCHandle imageHandle, String filename, String extension, String title, String url, String visibleURL, WebKit::SharedMemory::IPCHandle archiveHandle )310 SetPromisedDataForImage(String pasteboardName, WebKit::SharedMemory::IPCHandle imageHandle, String filename, String extension, String title, String url, String visibleURL, WebKit::SharedMemory::IPCHandle archiveHandle, String originIdentifier) 311 311 #endif 312 312 #if PLATFORM(GTK) && ENABLE(DRAG_SUPPORT) -
trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h
r266654 r271685 102 102 void startDrag(const WebCore::DragItem&, const ShareableBitmap::Handle& image) override; 103 103 void setPromisedDataForImage(const String& pasteboardName, Ref<WebCore::SharedBuffer>&& imageBuffer, const String& filename, const String& extension, const String& title, 104 const String& url, const String& visibleU rl, RefPtr<WebCore::SharedBuffer>&& archiveBuffer) override;104 const String& url, const String& visibleURL, RefPtr<WebCore::SharedBuffer>&& archiveBuffer, const String& originIdentifier) override; 105 105 void updateSecureInputState() override; 106 106 void resetSecureInputState() override; -
trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm
r268376 r271685 400 400 } 401 401 402 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 )402 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) 403 403 { 404 404 auto image = BitmapImage::create(); 405 405 image->setData(WTFMove(imageBuffer), true); 406 m_impl->setPromisedDataForImage(image.ptr(), filename, extension, title, url, visibleURL, archiveBuffer.get(), pasteboardName );406 m_impl->setPromisedDataForImage(image.ptr(), filename, extension, title, url, visibleURL, archiveBuffer.get(), pasteboardName, originIdentifier); 407 407 } 408 408 -
trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm
r271187 r271685 263 263 264 264 void WebPageProxy::setPromisedDataForImage(const String& pasteboardName, const SharedMemory::IPCHandle& imageHandle, const String& filename, const String& extension, 265 const String& title, const String& url, const String& visibleURL, const SharedMemory::IPCHandle& archiveHandle )265 const String& title, const String& url, const String& visibleURL, const SharedMemory::IPCHandle& archiveHandle, const String& originIdentifier) 266 266 { 267 267 MESSAGE_CHECK_URL(url); … … 282 282 archiveBuffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryArchive->data()), static_cast<size_t>(archiveHandle.dataSize)); 283 283 } 284 pageClient().setPromisedDataForImage(pasteboardName, WTFMove(imageBuffer), ResourceResponseBase::sanitizeSuggestedFilename(filename), extension, title, url, visibleURL, WTFMove(archiveBuffer) );284 pageClient().setPromisedDataForImage(pasteboardName, WTFMove(imageBuffer), ResourceResponseBase::sanitizeSuggestedFilename(filename), extension, title, url, visibleURL, WTFMove(archiveBuffer), originIdentifier); 285 285 } 286 286 -
trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm
r265702 r271685 182 182 } 183 183 184 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 } ));184 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())); 185 185 } 186 186 -
trunk/Source/WebKitLegacy/mac/ChangeLog
r271607 r271685 1 2021-01-20 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [macOS] Include an origin identifier when writing promised image data to the drag pasteboard 4 https://bugs.webkit.org/show_bug.cgi?id=220782 5 6 Reviewed by Megan Gardner. 7 8 See WebKit ChangeLog for more details. 9 10 * Misc/WebNSPasteboardExtras.mm: 11 (-[NSPasteboard _web_declareAndWriteDragImageForElement:URL:title:archive:source:]): 12 1 13 2021-01-19 Keith Rollin <krollin@apple.com> 2 14 -
trunk/Source/WebKitLegacy/mac/Misc/WebNSPasteboardExtras.mm
r260485 r271685 44 44 #import <WebCore/LegacyNSPasteboardTypes.h> 45 45 #import <WebCore/MIMETypeRegistry.h> 46 #import <WebCore/PasteboardCustomData.h> 46 47 #import <WebCore/RenderAttachment.h> 47 48 #import <WebCore/RenderImage.h> … … 283 284 NSString *extension = @""; 284 285 RetainPtr<NSMutableArray> types = adoptNS([[NSMutableArray alloc] initWithObjects:legacyFilesPromisePasteboardType(), nil]); 286 NSString *originIdentifier = core(element)->document().originIdentifierForPasteboard(); 287 RetainPtr<NSData> customDataBuffer; 288 if (originIdentifier.length) { 289 [types addObject:@(PasteboardCustomData::cocoaType())]; 290 PasteboardCustomData customData; 291 customData.setOrigin(originIdentifier); 292 customDataBuffer = customData.createSharedBuffer()->createNSData(); 293 } 294 285 295 if (auto* renderer = core(element)->renderer()) { 286 296 if (is<RenderImage>(*renderer)) { … … 305 315 306 316 [self _web_writeImage:nil element:element URL:URL title:title archive:archive types:types.get() source:source]; 317 if (customDataBuffer) 318 [self setData:customDataBuffer.get() forType:@(PasteboardCustomData::cocoaType())]; 307 319 308 320 NSArray *extensions = [[NSArray alloc] initWithObjects:extension, nil]; -
trunk/Tools/ChangeLog
r271683 r271685 1 2021-01-20 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [macOS] Include an origin identifier when writing promised image data to the drag pasteboard 4 https://bugs.webkit.org/show_bug.cgi?id=220782 5 6 Reviewed by Megan Gardner. 7 8 Make a slight adjustment to an existing API test, to verify that custom pasteboard data is serialized when 9 dragging an image element. 10 11 * TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm: 12 1 13 2021-01-20 Jonathan Bedard <jbedard@apple.com> 2 14 -
trunk/Tools/TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm
r265480 r271685 29 29 #import "InstanceMethodSwizzler.h" 30 30 #import "PlatformUtilities.h" 31 #import <WebCore/PasteboardCustomData.h> 31 32 #import <WebKit/WKPreferencesPrivate.h> 32 33 #import <WebKit/WKWebViewPrivate.h> … … 189 190 EXPECT_TRUE(NSEqualSizes(imageFromDragPasteboard.size, imageFromUniquePasteboard.size)); 190 191 EXPECT_FALSE(NSEqualSizes(NSZeroSize, imageFromUniquePasteboard.size)); 192 EXPECT_GT([dragPasteboard dataForType:@(WebCore::PasteboardCustomData::cocoaType())].length, 0u); 191 193 } 192 194
Note: See TracChangeset
for help on using the changeset viewer.