Changeset 252874 in webkit
- Timestamp:
- Nov 25, 2019 10:08:58 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r252873 r252874 1 2019-11-25 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [macOS] Dragged images are only available as .tiff when dropping onto macCatalyst apps 4 https://bugs.webkit.org/show_bug.cgi?id=204598 5 <rdar://problem/57093920> 6 7 Reviewed by Tim Horton. 8 9 On macOS, writing dragged images to the pasteboard only as file promises is mostly sufficient for the purposes 10 of dropping into Finder, Photos, and other apps. However, when dropping into a macCatalyst app, the contents of 11 NSPasteboard will only contain a file URL, which most Catalyst apps aren't able to handle. The only other valid 12 image representation that is written to the pasteboard in this case is "public.tiff", which loses fidelity in 13 the case of animated GIFs. 14 15 Instead, if the dragged image has a corresponding UTI and corresponding decoded image data, declare the UTI when 16 writing promised data to the pasteboard, and later provide data for the UTI, if the drop destination asks, by 17 using the promised image's data. 18 19 Test: DragAndDropTests.ProvideImageDataAsTypeIdentifiers 20 21 * UIProcess/Cocoa/WebViewImpl.mm: 22 (WebKit::WebViewImpl::setPromisedDataForImage): 23 (WebKit::WebViewImpl::provideDataForPasteboard): 24 1 25 2019-11-25 Fujii Hironori <Hironori.Fujii@sony.com> 2 26 -
trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
r252762 r252874 4238 4238 RetainPtr<NSMutableArray> types = adoptNS([[NSMutableArray alloc] initWithObjects:WebCore::legacyFilesPromisePasteboardType(), nil]); 4239 4239 4240 if (image && !image->uti().isEmpty() && image->data() && !image->data()->isEmpty()) 4241 [types addObject:image->uti()]; 4242 4240 4243 [types addObjectsFromArray:archiveBuffer ? PasteboardTypes::forImagesWithArchive() : PasteboardTypes::forImages()]; 4241 4244 [pasteboard declareTypes:types.get() owner:m_view.getAutoreleased()]; … … 4265 4268 void WebViewImpl::provideDataForPasteboard(NSPasteboard *pasteboard, NSString *type) 4266 4269 { 4270 if (!m_promisedImage) 4271 return; 4272 4273 if ([type isEqual:m_promisedImage->uti()] && m_promisedImage->data()) { 4274 if (auto platformData = m_promisedImage->data()->createNSData()) 4275 [pasteboard setData:(__bridge NSData *)platformData.get() forType:type]; 4276 } 4277 4267 4278 // FIXME: Need to support NSRTFDPboardType. 4268 if ([type isEqual:WebCore::legacyTIFFPasteboardType()] && m_promisedImage)4279 if ([type isEqual:WebCore::legacyTIFFPasteboardType()]) 4269 4280 [pasteboard setData:(__bridge NSData *)m_promisedImage->tiffRepresentation() forType:WebCore::legacyTIFFPasteboardType()]; 4270 4281 } -
trunk/Tools/ChangeLog
r252872 r252874 1 2019-11-25 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [macOS] Dragged images are only available as .tiff when dropping onto macCatalyst apps 4 https://bugs.webkit.org/show_bug.cgi?id=204598 5 <rdar://problem/57093920> 6 7 Reviewed by Tim Horton. 8 9 Verify that WKWebView is able to provide data in non-TIFF formats when dragging several types of images using a 10 new API test. 11 12 * TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm: 13 1 14 2019-11-25 Ross Kirsling <ross.kirsling@sony.com> 2 15 -
trunk/Tools/TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm
r248166 r252874 28 28 #import "DragAndDropSimulator.h" 29 29 #import "PlatformUtilities.h" 30 #import <WebKit/WKPreferencesPrivate.h> 30 31 31 32 #if ENABLE(DRAG_SUPPORT) && PLATFORM(MAC) … … 159 160 } 160 161 162 TEST(DragAndDropTests, ProvideImageDataAsTypeIdentifiers) 163 { 164 auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 165 [[configuration preferences] _setLargeImageAsyncDecodingEnabled:NO]; 166 167 auto simulator = adoptNS([[DragAndDropSimulator alloc] initWithWebViewFrame:NSMakeRect(0, 0, 400, 400) configuration:configuration.get()]); 168 TestWKWebView *webView = [simulator webView]; 169 170 auto uniquePasteboard = retainPtr(NSPasteboard.pasteboardWithUniqueName); 171 172 [webView synchronouslyLoadHTMLString:@"<img src='sunset-in-cupertino-600px.jpg'></img>"]; 173 [simulator runFrom:NSMakePoint(25, 25) to:NSMakePoint(300, 300)]; 174 [webView pasteboard:uniquePasteboard.get() provideDataForType:(__bridge NSString *)kUTTypeJPEG]; 175 EXPECT_GT([uniquePasteboard dataForType:(__bridge NSString *)kUTTypeJPEG].length, 0u); 176 177 [webView synchronouslyLoadHTMLString:@"<img src='icon.png'></img>"]; 178 [simulator runFrom:NSMakePoint(25, 25) to:NSMakePoint(300, 300)]; 179 [webView pasteboard:uniquePasteboard.get() provideDataForType:(__bridge NSString *)kUTTypePNG]; 180 EXPECT_GT([uniquePasteboard dataForType:(__bridge NSString *)kUTTypePNG].length, 0u); 181 182 [webView synchronouslyLoadHTMLString:@"<img src='apple.gif'></img>"]; 183 [simulator runFrom:NSMakePoint(25, 25) to:NSMakePoint(300, 300)]; 184 [webView pasteboard:uniquePasteboard.get() provideDataForType:(__bridge NSString *)kUTTypeGIF]; 185 EXPECT_GT([uniquePasteboard dataForType:(__bridge NSString *)kUTTypeGIF].length, 0u); 186 } 187 161 188 #endif // ENABLE(DRAG_SUPPORT) && PLATFORM(MAC)
Note: See TracChangeset
for help on using the changeset viewer.