Modified: trunk/Source/WebKit2/ChangeLog (160192 => 160193)
--- trunk/Source/WebKit2/ChangeLog 2013-12-05 21:59:44 UTC (rev 160192)
+++ trunk/Source/WebKit2/ChangeLog 2013-12-05 22:30:40 UTC (rev 160193)
@@ -1,5 +1,27 @@
2013-12-05 Anders Carlsson <[email protected]>
+ "Use Selection for Find" doesn't work in PDF viewed in Safari
+ https://bugs.webkit.org/show_bug.cgi?id=125319
+ <rdar://problem/15486983>
+
+ Reviewed by Tim Horton.
+
+ * WebProcess/Plugins/PDF/PDFPlugin.h:
+ * WebProcess/Plugins/PDF/PDFPlugin.mm:
+ (-[WKPDFLayerControllerDelegate writeItemsToPasteboard:withTypes:]):
+ Pass NSGeneralPboard to writeItemsToPasteboard.
+
+ (WebKit::PDFPlugin::handleEditingCommand):
+ Handle takeFindStringFromSelection by getting the current selection string and writing it to the find pasteboard.
+
+ (WebKit::PDFPlugin::isEditingCommandEnabled):
+ Handle takeFindStringFromSelection.
+
+ (WebKit::PDFPlugin::writeItemsToPasteboard):
+ Update this to take a pasteboard name.
+
+2013-12-05 Anders Carlsson <[email protected]>
+
WebKit2 API should use weak ownership for delegate properties rather than assign
https://bugs.webkit.org/show_bug.cgi?id=125316
<rdar://problem/15560614>
Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h (160192 => 160193)
--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h 2013-12-05 21:59:44 UTC (rev 160192)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h 2013-12-05 22:30:40 UTC (rev 160193)
@@ -88,7 +88,7 @@
void clickedLink(NSURL *);
void saveToPDF();
void openWithNativeApplication();
- void writeItemsToPasteboard(NSArray *items, NSArray *types);
+ void writeItemsToPasteboard(NSString *pasteboardName, NSArray *items, NSArray *types);
void showDefinitionForAttributedString(NSAttributedString *, CGPoint);
void performWebSearch(NSString *);
void performSpotlightSearch(NSString *);
Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm (160192 => 160193)
--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm 2013-12-05 21:59:44 UTC (rev 160192)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm 2013-12-05 22:30:40 UTC (rev 160193)
@@ -335,7 +335,7 @@
- (void)writeItemsToPasteboard:(NSArray *)items withTypes:(NSArray *)types
{
- _pdfPlugin->writeItemsToPasteboard(items, types);
+ _pdfPlugin->writeItemsToPasteboard(NSGeneralPboard, items, types);
}
- (void)showDefinitionForAttributedString:(NSAttributedString *)string atPoint:(CGPoint)point
@@ -1480,17 +1480,22 @@
bool PDFPlugin::handleEditingCommand(const String& commandName, const String& argument)
{
if (commandName == "copy")
- [m_pdfLayerController.get() copySelection];
+ [m_pdfLayerController copySelection];
else if (commandName == "selectAll")
- [m_pdfLayerController.get() selectAll];
-
+ [m_pdfLayerController selectAll];
+ else if (commandName == "takeFindStringFromSelection") {
+ NSString *string = [m_pdfLayerController currentSelection].string;
+ if (string.length)
+ writeItemsToPasteboard(NSFindPboard, @[ [string dataUsingEncoding:NSUTF8StringEncoding] ], @[ NSPasteboardTypeString ]);
+ }
+
return true;
}
bool PDFPlugin::isEditingCommandEnabled(const String& commandName)
{
- if (commandName == "copy")
- return [m_pdfLayerController.get() currentSelection];
+ if (commandName == "copy" || commandName == "takeFindStringFromSelection")
+ return [m_pdfLayerController currentSelection];
if (commandName == "selectAll")
return true;
@@ -1630,7 +1635,7 @@
webFrame()->page()->send(Messages::WebPageProxy::OpenPDFFromTemporaryFolderWithNativeApplication(m_temporaryPDFUUID));
}
-void PDFPlugin::writeItemsToPasteboard(NSArray *items, NSArray *types)
+void PDFPlugin::writeItemsToPasteboard(NSString *pasteboardName, NSArray *items, NSArray *types)
{
Vector<String> pasteboardTypes;
@@ -1638,7 +1643,7 @@
pasteboardTypes.append(type);
uint64_t newChangeCount;
- WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::SetPasteboardTypes(NSGeneralPboard, pasteboardTypes),
+ WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::SetPasteboardTypes(pasteboardName, pasteboardTypes),
Messages::WebContext::SetPasteboardTypes::Reply(newChangeCount), 0);
for (NSUInteger i = 0, count = items.count; i < count; ++i) {
@@ -1653,7 +1658,7 @@
if ([type isEqualToString:NSStringPboardType] || [type isEqualToString:NSPasteboardTypeString]) {
RetainPtr<NSString> plainTextString = adoptNS([[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
- WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::SetPasteboardStringForType(NSGeneralPboard, type, plainTextString.get()),
+ WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::SetPasteboardStringForType(pasteboardName, type, plainTextString.get()),
Messages::WebContext::SetPasteboardStringForType::Reply(newChangeCount), 0);
} else {
RefPtr<SharedBuffer> buffer = SharedBuffer::wrapNSData(data);
@@ -1665,7 +1670,7 @@
RefPtr<SharedMemory> sharedMemory = SharedMemory::create(buffer->size());
memcpy(sharedMemory->data(), buffer->data(), buffer->size());
sharedMemory->createHandle(handle, SharedMemory::ReadOnly);
- WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::SetPasteboardBufferForType(NSGeneralPboard, type, handle, buffer->size()),
+ WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::SetPasteboardBufferForType(pasteboardName, type, handle, buffer->size()),
Messages::WebContext::SetPasteboardBufferForType::Reply(newChangeCount), 0);
}
}