Changeset 160193 in webkit


Ignore:
Timestamp:
Dec 5, 2013 2:30:40 PM (10 years ago)
Author:
andersca@apple.com
Message:

"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.

Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r160191 r160193  
     12013-12-05  Anders Carlsson  <andersca@apple.com>
     2
     3        "Use Selection for Find" doesn't work in PDF viewed in Safari
     4        https://bugs.webkit.org/show_bug.cgi?id=125319
     5        <rdar://problem/15486983>
     6
     7        Reviewed by Tim Horton.
     8
     9        * WebProcess/Plugins/PDF/PDFPlugin.h:
     10        * WebProcess/Plugins/PDF/PDFPlugin.mm:
     11        (-[WKPDFLayerControllerDelegate writeItemsToPasteboard:withTypes:]):
     12        Pass NSGeneralPboard to writeItemsToPasteboard.
     13
     14        (WebKit::PDFPlugin::handleEditingCommand):
     15        Handle takeFindStringFromSelection by getting the current selection string and writing it to the find pasteboard.
     16
     17        (WebKit::PDFPlugin::isEditingCommandEnabled):
     18        Handle takeFindStringFromSelection.
     19
     20        (WebKit::PDFPlugin::writeItemsToPasteboard):
     21        Update this to take a pasteboard name.
     22
    1232013-12-05  Anders Carlsson  <andersca@apple.com>
    224
  • trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h

    r157253 r160193  
    8989    void saveToPDF();
    9090    void openWithNativeApplication();
    91     void writeItemsToPasteboard(NSArray *items, NSArray *types);
     91    void writeItemsToPasteboard(NSString *pasteboardName, NSArray *items, NSArray *types);
    9292    void showDefinitionForAttributedString(NSAttributedString *, CGPoint);
    9393    void performWebSearch(NSString *);
  • trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm

    r160028 r160193  
    336336- (void)writeItemsToPasteboard:(NSArray *)items withTypes:(NSArray *)types
    337337{
    338     _pdfPlugin->writeItemsToPasteboard(items, types);
     338    _pdfPlugin->writeItemsToPasteboard(NSGeneralPboard, items, types);
    339339}
    340340
     
    14811481{
    14821482    if (commandName == "copy")
    1483         [m_pdfLayerController.get() copySelection];
     1483        [m_pdfLayerController copySelection];
    14841484    else if (commandName == "selectAll")
    1485         [m_pdfLayerController.get() selectAll];
    1486    
     1485        [m_pdfLayerController selectAll];
     1486    else if (commandName == "takeFindStringFromSelection") {
     1487        NSString *string = [m_pdfLayerController currentSelection].string;
     1488        if (string.length)
     1489            writeItemsToPasteboard(NSFindPboard, @[ [string dataUsingEncoding:NSUTF8StringEncoding] ], @[ NSPasteboardTypeString ]);
     1490    }
     1491
    14871492    return true;
    14881493}
     
    14901495bool PDFPlugin::isEditingCommandEnabled(const String& commandName)
    14911496{
    1492     if (commandName == "copy")
    1493         return [m_pdfLayerController.get() currentSelection];
     1497    if (commandName == "copy" || commandName == "takeFindStringFromSelection")
     1498        return [m_pdfLayerController currentSelection];
    14941499       
    14951500    if (commandName == "selectAll")
     
    16311636}
    16321637
    1633 void PDFPlugin::writeItemsToPasteboard(NSArray *items, NSArray *types)
     1638void PDFPlugin::writeItemsToPasteboard(NSString *pasteboardName, NSArray *items, NSArray *types)
    16341639{
    16351640    Vector<String> pasteboardTypes;
     
    16391644
    16401645    uint64_t newChangeCount;
    1641     WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::SetPasteboardTypes(NSGeneralPboard, pasteboardTypes),
     1646    WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::SetPasteboardTypes(pasteboardName, pasteboardTypes),
    16421647        Messages::WebContext::SetPasteboardTypes::Reply(newChangeCount), 0);
    16431648
     
    16541659        if ([type isEqualToString:NSStringPboardType] || [type isEqualToString:NSPasteboardTypeString]) {
    16551660            RetainPtr<NSString> plainTextString = adoptNS([[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
    1656             WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::SetPasteboardStringForType(NSGeneralPboard, type, plainTextString.get()),
     1661            WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::SetPasteboardStringForType(pasteboardName, type, plainTextString.get()),
    16571662                Messages::WebContext::SetPasteboardStringForType::Reply(newChangeCount), 0);
    16581663        } else {
     
    16661671            memcpy(sharedMemory->data(), buffer->data(), buffer->size());
    16671672            sharedMemory->createHandle(handle, SharedMemory::ReadOnly);
    1668             WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::SetPasteboardBufferForType(NSGeneralPboard, type, handle, buffer->size()),
     1673            WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebContext::SetPasteboardBufferForType(pasteboardName, type, handle, buffer->size()),
    16691674                Messages::WebContext::SetPasteboardBufferForType::Reply(newChangeCount), 0);
    16701675        }
Note: See TracChangeset for help on using the changeset viewer.