Source/WebCore:
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Apr 2015 21:23:54 +0000 (21:23 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Apr 2015 21:23:54 +0000 (21:23 +0000)
commitbed1eb8138f669549138ed36fa6e7d40b9f2e383
tree77850b586d97fb5b420e29f59682976d2f3e9a3d
parent440d5f025cf01b35b0eb574d01f249c9862e4a7b
Source/WebCore:
[Mac] Extend action menus to support PDF
https://bugs.webkit.org/show_bug.cgi?id=143895
<rdar://problem/19003333>

Reviewed by Tim Horton.

Tested by TestWebKitAPI ActionMenus.mm.

Add a new dictionary lookup method to support PDF Selections. This code replicates the
DOM Range-based logic used for HTML documents, but does so using the PDFKit API and
its support types.

* Configurations/Base.xcconfig: Add PDFKit include path for build.
* editing/mac/DictionaryLookup.h:
* editing/mac/DictionaryLookup.mm:
(WebCore::expandSelectionByCharacters): Helper function for PDF support.
(WebCore::dictionaryLookupForPDFSelection): Added.

Source/WebKit/mac:
Extend action menus to support PDF
https://bugs.webkit.org/show_bug.cgi?id=143895
<rdar://problem/19003333>

Reviewed by Tim Horton.

Prevent a crash when someone attempts to invoke an action menu on a PDF hosted
in a WK1 view.

* WebView/WebActionMenuController.mm:
(-[WebActionMenuController performHitTestAtPoint:]): Handle WebPDFView as well as
the WebHTMLView case.
* WebView/WebDocument.h:
* WebView/WebHTMLView.h:
* WebView/WebHTMLView.mm:
(-[WebHTMLView _frame]):
* WebView/WebHTMLViewInternal.h:
* WebView/WebPDFView.h:
* WebView/WebPDFView.mm:
(-[WebPDFView _frame]): Added.

Source/WebKit2:
Extend action menus to support PDF
https://bugs.webkit.org/show_bug.cgi?id=143895
<rdar://problem/19003333>

Reviewed by Tim Horton.

If the mouse pointer is over a PDF, try to provide a relevant action menu for whatever
content is under the mouse. For now, we only support copying text and handling URLs.

If no text is selected, use the dictionary lookup service to find a semantically appropriate
selection underneath the mouse. This is consistent with how normal text is treated in pure HTML
views. If some text is already selected, and the mouse is over the existing selection, continue
using the selected text. Otherwise, discard the old selection and select the most appropriate
region under the mouse pointer.

* Shared/API/c/WKActionMenuTypes.h: Add PDF menu option.
* Shared/WebMouseEvent.cpp: Recognize mouse force events as valid mouse events.
* UIProcess/mac/WKActionMenuController.mm:
(-[WKActionMenuController _defaultMenuItemsForPDF]): Add simply copy text option.
(-[WKActionMenuController _defaultMenuItems]): Recognize PDFs and add relevant action
menu entries.
* WebProcess/Plugins/Netscape/NetscapePlugin.h: Provide stub for new method.
* WebProcess/Plugins/PDF/PDFLayerControllerDetails.h: Expose 'rectsForSelectionInLayerSpace',
'rectsForAnnotationInLayoutSpace', 'layout', and 'currentPage'.
* WebProcess/Plugins/PDF/PDFPlugin.h:
* WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::PDFPlugin::getSelectionForWordAtPoint): Added.
(WebKit::PDFPlugin::existingSelectionContainsPoint): Added.
(WebKit::PDFPlugin::lookupTextAtLocation): Added.
* WebProcess/Plugins/Plugin.h: Add declaration for new 'getSelectionForWordAtPoint' method.
* WebProcess/Plugins/PluginProxy.h: Provide stub for new method.
* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::getSelectionForWordAtPoint): Added.
(WebKit::PluginView::existingSelectionContainsPoint): Added.
(WebKit::PluginView::lookupTextAtLocation): Added.
* WebProcess/Plugins/PluginView.h:
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::performActionMenuHitTestAtLocation): Update to support PDF documents and retrieve
relevant content to support later action menu handling.

Tools:
[Mac] Extend action menus to support PDF
https://bugs.webkit.org/show_bug.cgi?id=143895
<rdar://problem/19003333>

Reviewed by Tim Horton.

Reactivate the action menu tests, and add a new PDF-based test to make sure that selection
of PDF content works.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Add new 'test.pdf' resource to bundle.
* TestWebKitAPI/Tests/WebKit2/action-menu-targets.html: Update with a new PDF pane.
* TestWebKitAPI/Tests/WebKit2/test.pdf: Added.
* TestWebKitAPI/Tests/WebKit2ObjC/ActionMenus.mm:
(-[ActionMenusTestWKView _actionMenuItemsForHitTestResult:withType:defaultActionMenuItems:userData:]):
Update to support PDF tests.
(TestWebKitAPI::windowPointForTarget): Add new target for PDF test.
(TestWebKitAPI::waitForPDFToLoad): New helper function to avoid starting test before the PDF is available.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183136 268f45cc-cd09-0410-ab3c-d52691b4dbfc
26 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Configurations/WebCore.xcconfig
Source/WebCore/editing/mac/DictionaryLookup.h
Source/WebCore/editing/mac/DictionaryLookup.mm
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebActionMenuController.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebHitTestResult.h
Source/WebKit2/Shared/WebMouseEvent.cpp
Source/WebKit2/UIProcess/API/C/WKHitTestResult.cpp
Source/WebKit2/UIProcess/API/C/WKHitTestResult.h
Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
Source/WebKit2/WebProcess/Plugins/PDF/PDFLayerControllerDetails.h
Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h
Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm
Source/WebKit2/WebProcess/Plugins/Plugin.h
Source/WebKit2/WebProcess/Plugins/PluginProxy.h
Source/WebKit2/WebProcess/Plugins/PluginView.cpp
Source/WebKit2/WebProcess/Plugins/PluginView.h
Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2/action-menu-target.pdf [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKit2/action-menu-targets.html
Tools/TestWebKitAPI/Tests/WebKit2/test.pdf [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKit2ObjC/ActionMenus.mm