Changeset 289541 in webkit
- Timestamp:
- Feb 10, 2022, 9:04:20 AM (4 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r289528 r289541 1 2022-02-10 Megan Gardner <megan_gardner@apple.com> 2 3 Mail attachment switched to TIFF and balloons in size after markup. 4 https://bugs.webkit.org/show_bug.cgi?id=236405 5 rdar://87358910 6 7 Reviewed by Wenson Hsieh. 8 9 When pulling data from the webprocess to pass to the Sharing Service 10 for markup, we would convert it to TIFF format. This would cause files 11 to increase in size, and lose their original formatting, as well as outright 12 break PDFs. Instead we should be pulling the data from the attachment, which 13 already exists in the UI process and is the source of truth for that data anyways. 14 This allows us to give the correct type to the sharing service, and we should 15 take the data back as the same original type when getting the data back from 16 markup. 17 18 * UIProcess/API/APIAttachment.cpp: 19 (API::Attachment::enclosingImageData const): 20 * UIProcess/API/APIAttachment.h: 21 * UIProcess/API/Cocoa/APIAttachmentCocoa.mm: 22 (API::Attachment::enclosingImageNSData const): 23 * UIProcess/mac/WKSharingServicePickerDelegate.mm: 24 (-[WKSharingServicePickerDelegate sharingService:didShareItems:]): 25 * UIProcess/mac/WebContextMenuProxyMac.mm: 26 (WebKit::WebContextMenuProxyMac::setupServicesMenu): 27 1 28 2022-02-10 Carlos Garcia Campos <cgarcia@igalia.com> 2 29 -
trunk/Source/WebKit/UIProcess/API/APIAttachment.h
r287021 r289541 85 85 86 86 RefPtr<WebCore::FragmentedSharedBuffer> enclosingImageData() const; 87 #if PLATFORM(COCOA) 88 NSData *enclosingImageNSData() const; 89 #endif 87 90 std::optional<uint64_t> fileSizeForDisplay() const; 88 91 -
trunk/Source/WebKit/UIProcess/API/Cocoa/APIAttachmentCocoa.mm
r287021 r289541 155 155 } 156 156 157 NSData *Attachment::enclosingImageNSData() const 158 { 159 if (!m_hasEnclosingImage) 160 return nil; 161 162 auto fileWrapper = this->fileWrapper(); 163 164 if (![fileWrapper isRegularFile]) 165 return nil; 166 167 return fileWrapper.regularFileContents; 168 } 169 157 170 bool Attachment::isEmpty() const 158 171 { -
trunk/Source/WebKit/UIProcess/mac/WKSharingServicePickerDelegate.mm
r287034 r289541 150 150 ALLOW_DEPRECATED_DECLARATIONS_BEGIN 151 151 WeakPtr weakPage = _menuProxy->page(); 152 [itemProvider loadDataRepresentationForTypeIdentifier:(NSString *)kUTTypeData completionHandler:[weakPage, attachmentID = _attachmentID](NSData *data, NSError *error) { 152 NSString *itemUTI = itemProvider.registeredTypeIdentifiers.firstObject; 153 [itemProvider loadDataRepresentationForTypeIdentifier:itemUTI completionHandler:[weakPage, attachmentID = _attachmentID, itemUTI](NSData *data, NSError *error) { 153 154 RefPtr webPage = weakPage.get(); 154 155 … … 164 165 165 166 auto attachment = wrapper(apiAttachment); 166 [attachment setData:data newContentType: String(NSPasteboardTypeTIFF)];167 [attachment setData:data newContentType:itemUTI]; 167 168 webPage->didInvalidateDataForAttachment(*apiAttachment.get()); 168 169 }]; -
trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm
r288541 r289541 213 213 NSArray *items = nil; 214 214 if (hasControlledImage) { 215 RefPtr<ShareableBitmap> image = m_context.controlledImage(); 216 if (!image) 217 return; 218 219 auto cgImage = image->makeCGImage(); 220 auto nsImage = adoptNS([[NSImage alloc] initWithCGImage:cgImage.get() size:image->size()]); 221 222 ALLOW_DEPRECATED_DECLARATIONS_BEGIN 223 auto itemProvider = adoptNS([[NSItemProvider alloc] initWithItem:[nsImage TIFFRepresentation] typeIdentifier:(__bridge NSString *)kUTTypeTIFF]); 224 ALLOW_DEPRECATED_DECLARATIONS_END 215 auto attachment = page()->attachmentForIdentifier(m_context.controlledImageAttachmentID()); 216 RetainPtr<NSItemProvider> itemProvider; 217 if (attachment) 218 itemProvider = adoptNS([[NSItemProvider alloc] initWithItem:attachment->enclosingImageNSData() typeIdentifier:attachment->utiType()]); 219 else { 220 RefPtr<ShareableBitmap> image = m_context.controlledImage(); 221 if (!image) 222 return; 223 auto cgImage = image->makeCGImage(); 224 auto nsImage = adoptNS([[NSImage alloc] initWithCGImage:cgImage.get() size:image->size()]); 225 226 ALLOW_DEPRECATED_DECLARATIONS_BEGIN 227 itemProvider = adoptNS([[NSItemProvider alloc] initWithItem:[nsImage TIFFRepresentation] typeIdentifier:(__bridge NSString *)kUTTypeTIFF]); 228 ALLOW_DEPRECATED_DECLARATIONS_END 229 } 225 230 items = @[ itemProvider.get() ]; 231 226 232 } else if (!m_context.controlledSelectionData().isEmpty()) { 227 233 auto selectionData = adoptNS([[NSData alloc] initWithBytes:static_cast<const void*>(m_context.controlledSelectionData().data()) length:m_context.controlledSelectionData().size()]);
Note:
See TracChangeset
for help on using the changeset viewer.