Factor out Lookup invocation
https://bugs.webkit.org/show_bug.cgi?id=148509

Reviewed by Anders Carlsson.

There's a ton of duplicated code in legacy and modern WebKit to talk to
Lookup. And, it's pretty messy. As a first step to making it less messy,
make it so we only have it in one place instead of four (or two).

* editing/DictionaryPopupInfo.h:
Move DictionaryPopupInfo into WebCore. This was duplicated
in both legacy and modern WebKit.

* editing/mac/DictionaryLookup.h:
* editing/mac/DictionaryLookup.mm:
(WebCore::DictionaryLookup::rangeForSelection):
(WebCore::DictionaryLookup::rangeAtHitTestResult):
(WebCore::DictionaryLookup::stringForPDFSelection):
(WebCore::showPopupOrCreateAnimationController):
(WebCore::DictionaryLookup::showPopup):
(WebCore::DictionaryLookup::hidePopup):
(WebCore::DictionaryLookup::animationControllerForPopup):
(WebCore::rangeForDictionaryLookupForSelection): Deleted.
(WebCore::rangeForDictionaryLookupAtHitTestResult): Deleted.
(WebCore::dictionaryLookupForPDFSelection): Deleted.
Move DictionaryLookup stuff into a class for better names.

Move showPopup, hidePopup, and animationControllerForPopup here.
showPopup and animationControllerForPopup both bottleneck through
a single function, where previously we duplicated all of the code
for both of them, and in both legacy and modern WebKit.

showPopup and animationControllerForPopup take a block that they *may*
call if we have support for overriding Lookup's indicator with TextIndicator,
because the installation process is different per WebKit.

* page/mac/EventHandlerMac.mm:
(WebCore::EventHandler::selectClosestWordFromHitTestResultBasedOnLookup):
* testing/Internals.cpp:
(WebCore::Internals::rangeForDictionaryLookupAtLocation):
Adjust to the new naming.

* Shared/DictionaryPopupInfo.cpp: Removed.
* Shared/DictionaryPopupInfo.h: Removed.
Moved to WebCore.

* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<DictionaryPopupInfo>::encode):
(IPC::ArgumentCoder<DictionaryPopupInfo>::decode):
Add encode/decoders for DictionaryPopupInfo now that it's in WebCore.

* Shared/WebCoreArgumentCoders.h:
* Shared/WebHitTestResult.h:
* Shared/mac/ArgumentCodersMac.h:
* UIProcess/API/mac/WKView.mm:
(+[WKView hideWordDefinitionWindow]):
(-[WKView _dismissContentRelativeChildWindows]):
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/mac/PageClientImpl.h:
* UIProcess/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::didPerformDictionaryLookup):
* UIProcess/mac/WKImmediateActionController.mm:
(-[WKImmediateActionController _animationControllerForText]):
* UIProcess/mac/WebPageProxyMac.mm:
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::PDFPlugin::showDefinitionForAttributedString):
(WebKit::PDFPlugin::lookupTextAtLocation):
* WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm:
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::performDictionaryLookupAtLocation):
(WebKit::WebPage::performDictionaryLookupForSelection):
(WebKit::WebPage::dictionaryPopupInfoForRange):
(WebKit::WebPage::dictionaryPopupInfoForSelectionInPDFPlugin):
(WebKit::WebPage::lookupTextAtLocation):
Adjust to new names and move stuff to WebCore.

* WebKit.xcodeproj/project.pbxproj:

* WebView/DictionaryPopupInfo.h: Removed.
Move to WebCore.

* WebView/WebHTMLView.mm:
(-[WebHTMLView _lookUpInDictionaryFromMenu:]):
DictionaryPopupInfo keeps a TextIndicatorData, not a TextIndicator.

* WebView/WebImmediateActionController.mm:
(-[WebImmediateActionController _animationControllerForDataDetectedLink]):
(dictionaryPopupInfoForRange):
(-[WebImmediateActionController _animationControllerForText]):
* WebView/WebView.mm:
(-[WebView _prepareForDictionaryLookup]):
(-[WebView _animationControllerForDictionaryLookupPopupInfo:]):
(-[WebView _setTextIndicator:withLifetime:]):
(-[WebView _showDictionaryLookupPopup:]):
* WebView/WebViewInternal.h:
Move a bunch of code to WebCore.
Factor some that has to stay out into _prepareForDictionaryLookup.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@189052 268f45cc-cd09-0410-ab3c-d52691b4dbfc
35 files changed