Changeset 136154 in webkit
- Timestamp:
- Nov 29, 2012, 1:05:19 PM (14 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
WebProcess/Plugins/PDF/PDFPlugin.h (modified) (1 diff)
-
WebProcess/Plugins/PDF/PDFPlugin.mm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r136152 r136154 1 2012-11-29 Tim Horton <timothy_horton@apple.com> 2 3 PDFPlugin: Only plain text can be copied out of PDFs 4 https://bugs.webkit.org/show_bug.cgi?id=103591 5 <rdar://problem/12555161> 6 7 Reviewed by Alexey Proskuryakov. 8 9 Enable rich data to be copied from PDFKit to the pasteboard. 10 11 * WebProcess/Plugins/PDF/PDFPlugin.h: 12 (PDFPlugin): Add writeItemsToPasteboard. 13 * WebProcess/Plugins/PDF/PDFPlugin.mm: 14 (-[WKPDFLayerControllerDelegate writeItemsToPasteboard:withTypes:]): Move implementation to PDFPlugin. 15 (WebKit::PDFPlugin::writeItemsToPasteboard): Don't round-trip through WebCore for pasteboard operations, 16 use WebContext directly. This provides a simple way to hand over a buffer for complex pasteboard types 17 (RTF, HTML, etc.). Use this interface for arbitrary non-plain-text pasteboard data that PDFKit hands us. 18 1 19 2012-11-29 Martin Robinson <mrobinson@igalia.com> 2 20 -
trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h
r135925 r136154 68 68 void clickedLink(NSURL *); 69 69 void saveToPDF(); 70 void writeItemsToPasteboard(NSArray *items, NSArray *types); 70 71 71 72 private: -
trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm
r135958 r136154 37 37 #import "PluginView.h" 38 38 #import "ShareableBitmap.h" 39 #import "WebContextMessages.h" 39 40 #import "WebEvent.h" 40 41 #import "WebEventConversion.h" 41 42 #import "WebPage.h" 42 43 #import "WebPageProxyMessages.h" 44 #import "WebProcess.h" 43 45 #import <PDFKit/PDFKit.h> 44 46 #import <QuartzCore/QuartzCore.h> … … 155 157 - (void)writeItemsToPasteboard:(NSArray *)items withTypes:(NSArray *)types 156 158 { 157 // FIXME: Handle types other than plain text. 158 159 for (NSUInteger i = 0, count = items.count; i < count; ++i) { 160 NSString *type = [types objectAtIndex:i]; 161 if ([type isEqualToString:NSStringPboardType] || [type isEqualToString:NSPasteboardTypeString]) { 162 RetainPtr<NSString> plainTextString(AdoptNS, [[NSString alloc] initWithData:[items objectAtIndex:i] encoding:NSUTF8StringEncoding]); 163 Pasteboard::generalPasteboard()->writePlainText(plainTextString.get(), Pasteboard::CannotSmartReplace); 164 } 165 } 159 _pdfPlugin->writeItemsToPasteboard(items, types); 166 160 } 167 161 … … 766 760 } 767 761 762 void PDFPlugin::writeItemsToPasteboard(NSArray *items, NSArray *types) 763 { 764 Vector<String> pasteboardTypes; 765 766 for (NSString *type in types) 767 pasteboardTypes.append(type); 768 769 WebProcess::shared().connection()->send(Messages::WebContext::SetPasteboardTypes(NSGeneralPboard, pasteboardTypes), 0); 770 771 for (NSUInteger i = 0, count = items.count; i < count; ++i) { 772 NSString *type = [types objectAtIndex:i]; 773 NSData *data = [items objectAtIndex:i]; 774 775 if ([type isEqualToString:NSStringPboardType] || [type isEqualToString:NSPasteboardTypeString]) { 776 RetainPtr<NSString> plainTextString(AdoptNS, [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); 777 WebProcess::shared().connection()->send(Messages::WebContext::SetPasteboardStringForType(NSGeneralPboard, type, plainTextString.get()), 0); 778 } else { 779 RefPtr<SharedBuffer> buffer = SharedBuffer::wrapNSData(data); 780 781 if (!buffer) 782 continue; 783 784 SharedMemory::Handle handle; 785 RefPtr<SharedMemory> sharedMemory = SharedMemory::create(buffer->size()); 786 memcpy(sharedMemory->data(), buffer->data(), buffer->size()); 787 sharedMemory->createHandle(handle, SharedMemory::ReadOnly); 788 WebProcess::shared().connection()->send(Messages::WebContext::SetPasteboardBufferForType(NSGeneralPboard, type, handle, buffer->size()), 0); 789 } 790 } 791 792 } 793 768 794 } // namespace WebKit 769 795
Note:
See TracChangeset
for help on using the changeset viewer.