Changeset 189052 in webkit


Ignore:
Timestamp:
Aug 27, 2015 2:24:27 PM (9 years ago)
Author:
timothy_horton@apple.com
Message:

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.

Location:
trunk/Source
Files:
1 added
3 deleted
32 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r189051 r189052  
     12015-08-27  Timothy Horton  <timothy_horton@apple.com>
     2
     3        Factor out Lookup invocation
     4        https://bugs.webkit.org/show_bug.cgi?id=148509
     5
     6        Reviewed by Anders Carlsson.
     7
     8        There's a ton of duplicated code in legacy and modern WebKit to talk to
     9        Lookup. And, it's pretty messy. As a first step to making it less messy,
     10        make it so we only have it in one place instead of four (or two).
     11
     12        * editing/DictionaryPopupInfo.h:
     13        Move DictionaryPopupInfo into WebCore. This was duplicated
     14        in both legacy and modern WebKit.
     15
     16        * editing/mac/DictionaryLookup.h:
     17        * editing/mac/DictionaryLookup.mm:
     18        (WebCore::DictionaryLookup::rangeForSelection):
     19        (WebCore::DictionaryLookup::rangeAtHitTestResult):
     20        (WebCore::DictionaryLookup::stringForPDFSelection):
     21        (WebCore::showPopupOrCreateAnimationController):
     22        (WebCore::DictionaryLookup::showPopup):
     23        (WebCore::DictionaryLookup::hidePopup):
     24        (WebCore::DictionaryLookup::animationControllerForPopup):
     25        (WebCore::rangeForDictionaryLookupForSelection): Deleted.
     26        (WebCore::rangeForDictionaryLookupAtHitTestResult): Deleted.
     27        (WebCore::dictionaryLookupForPDFSelection): Deleted.
     28        Move DictionaryLookup stuff into a class for better names.
     29
     30        Move showPopup, hidePopup, and animationControllerForPopup here.
     31        showPopup and animationControllerForPopup both bottleneck through
     32        a single function, where previously we duplicated all of the code
     33        for both of them, and in both legacy and modern WebKit.
     34
     35        showPopup and animationControllerForPopup take a block that they *may*
     36        call if we have support for overriding Lookup's indicator with TextIndicator,
     37        because the installation process is different per WebKit.
     38
     39        * page/mac/EventHandlerMac.mm:
     40        (WebCore::EventHandler::selectClosestWordFromHitTestResultBasedOnLookup):
     41        * testing/Internals.cpp:
     42        (WebCore::Internals::rangeForDictionaryLookupAtLocation):
     43        Adjust to the new naming.
     44
    1452015-08-27  Jon Davis  <jond@apple.com>
    246
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r189031 r189052  
    11401140                2D5002FB1B56D7990020AAF7 /* PathUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D5002F91B56D7990020AAF7 /* PathUtilities.cpp */; };
    11411141                2D5002FC1B56D7990020AAF7 /* PathUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D5002FA1B56D7990020AAF7 /* PathUtilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1142                2D5646B01B8F8493003C4994 /* DictionaryPopupInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D5646AF1B8F8493003C4994 /* DictionaryPopupInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
    11421143                2D58D8551A15F65F00A5F726 /* DataDetection.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D58D8531A15F65F00A5F726 /* DataDetection.h */; settings = {ATTRIBUTES = (Private, ); }; };
    11431144                2D58D8561A15F65F00A5F726 /* DataDetection.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D58D8541A15F65F00A5F726 /* DataDetection.mm */; };
     
    83528353                2D5002F91B56D7990020AAF7 /* PathUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PathUtilities.cpp; sourceTree = "<group>"; };
    83538354                2D5002FA1B56D7990020AAF7 /* PathUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PathUtilities.h; sourceTree = "<group>"; };
     8355                2D5646AF1B8F8493003C4994 /* DictionaryPopupInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DictionaryPopupInfo.h; sourceTree = "<group>"; };
    83548356                2D58D8531A15F65F00A5F726 /* DataDetection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataDetection.h; sourceTree = "<group>"; };
    83558357                2D58D8541A15F65F00A5F726 /* DataDetection.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DataDetection.mm; sourceTree = "<group>"; };
     
    1797817980                                CECADFC4153778FF00E37068 /* DictationCommand.cpp */,
    1797917981                                CECADFC5153778FF00E37068 /* DictationCommand.h */,
     17982                                2D5646AF1B8F8493003C4994 /* DictionaryPopupInfo.h */,
    1798017983                                93309D93099E64910056E581 /* EditAction.h */,
    1798117984                                93309D94099E64910056E581 /* EditCommand.cpp */,
     
    2437524378                                BC772E131331620C001EC9CE /* CSSLineBoxContainValue.h in Headers */,
    2437624379                                A80E6D030A1989CA007FB8C5 /* CSSMediaRule.h in Headers */,
     24380                                2D5646B01B8F8493003C4994 /* DictionaryPopupInfo.h in Headers */,
    2437724381                                F98FFF4511A2676200F548E8 /* CSSOMUtils.h in Headers */,
    2437824382                                A80E6D000A1989CA007FB8C5 /* CSSPageRule.h in Headers */,
  • trunk/Source/WebCore/editing/mac/DictionaryLookup.h

    r188565 r189052  
    2929#if PLATFORM(MAC)
    3030
     31#include "DictionaryPopupInfo.h"
     32#include <functional>
    3133#include <wtf/PassRefPtr.h>
    3234
    33 OBJC_CLASS NSDictionary;
     35OBJC_CLASS NSString;
     36OBJC_CLASS NSView;
    3437OBJC_CLASS PDFSelection;
     38
     39// This file is included in Internals.cpp, so we can't use ObjC outright.
     40#if defined(__OBJC__) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
     41#include "NSImmediateActionGestureRecognizerSPI.h"
     42#define PlatformAnimationController id<NSImmediateActionAnimationController>
     43#else
     44#define PlatformAnimationController void*
     45#endif
    3546
    3647namespace WebCore {
     
    4051class VisibleSelection;
    4152
    42 WEBCORE_EXPORT PassRefPtr<Range> rangeForDictionaryLookupForSelection(const VisibleSelection&, NSDictionary **options);
    43 WEBCORE_EXPORT PassRefPtr<Range> rangeForDictionaryLookupAtHitTestResult(const HitTestResult&, NSDictionary **options);
    44 WEBCORE_EXPORT NSString *dictionaryLookupForPDFSelection(PDFSelection *, NSDictionary **options);
     53class DictionaryLookup {
     54public:
     55    WEBCORE_EXPORT static PassRefPtr<Range> rangeForSelection(const VisibleSelection&, NSDictionary **options);
     56    WEBCORE_EXPORT static PassRefPtr<Range> rangeAtHitTestResult(const HitTestResult&, NSDictionary **options);
     57    WEBCORE_EXPORT static NSString *stringForPDFSelection(PDFSelection *, NSDictionary **options);
     58
     59    // FIXME: Should move/unify dictionaryPopupInfoForRange here too.
     60
     61    WEBCORE_EXPORT static void showPopup(const DictionaryPopupInfo&, NSView *, std::function<void(TextIndicator&)> textIndicatorInstallationCallback);
     62    WEBCORE_EXPORT static void hidePopup();
     63
     64    WEBCORE_EXPORT static PlatformAnimationController animationControllerForPopup(const DictionaryPopupInfo&, NSView *, std::function<void(TextIndicator&)> textIndicatorInstallationCallback);
     65};
    4566
    4667} // namespace WebCore
  • trunk/Source/WebCore/editing/mac/DictionaryLookup.mm

    r188565 r189052  
    3636#import "HitTestResult.h"
    3737#import "LookupSPI.h"
     38#import "NSImmediateActionGestureRecognizerSPI.h"
    3839#import "Page.h"
    3940#import "Range.h"
     
    4849#import <wtf/RefPtr.h>
    4950
     51SOFT_LINK_CONSTANT_MAY_FAIL(Lookup, LUTermOptionDisableSearchTermIndicator, NSString *)
     52
    5053namespace WebCore {
    5154
     
    6265}
    6366
    64 PassRefPtr<Range> rangeForDictionaryLookupForSelection(const VisibleSelection& selection, NSDictionary **options)
     67PassRefPtr<Range> DictionaryLookup::rangeForSelection(const VisibleSelection& selection, NSDictionary **options)
    6568{
    6669    RefPtr<Range> selectedRange = selection.toNormalizedRange();
     
    8891}
    8992
    90 PassRefPtr<Range> rangeForDictionaryLookupAtHitTestResult(const HitTestResult& hitTestResult, NSDictionary **options)
     93PassRefPtr<Range> DictionaryLookup::rangeAtHitTestResult(const HitTestResult& hitTestResult, NSDictionary **options)
    9194{
    9295    Node* node = hitTestResult.innerNonSharedNode();
     
    114117    VisibleSelection selection = frame->page()->focusController().focusedOrMainFrame().selection().selection();
    115118    if (selectionContainsPosition(position, selection))
    116         return rangeForDictionaryLookupForSelection(selection, options);
     119        return DictionaryLookup::rangeForSelection(selection, options);
    117120
    118121    VisibleSelection selectionAccountingForLineRules = VisibleSelection(position);
     
    151154}
    152155
    153 NSString *dictionaryLookupForPDFSelection(PDFSelection *selection, NSDictionary **options)
     156NSString *DictionaryLookup::stringForPDFSelection(PDFSelection *selection, NSDictionary **options)
    154157{
    155158    // Don't do anything if there is no character at the point.
     
    186189}
    187190
     191static PlatformAnimationController showPopupOrCreateAnimationController(bool createAnimationController, const DictionaryPopupInfo& dictionaryPopupInfo, NSView *view, std::function<void(TextIndicator&)> textIndicatorInstallationCallback)
     192{
     193    if (!getLULookupDefinitionModuleClass())
     194        return nil;
     195
     196    RetainPtr<NSMutableDictionary> mutableOptions = adoptNS([(NSDictionary *)dictionaryPopupInfo.options.get() mutableCopy]);
     197
     198    auto textIndicator = TextIndicator::create(dictionaryPopupInfo.textIndicator);
     199
     200    if (canLoadLUTermOptionDisableSearchTermIndicator() && textIndicator.get().contentImage()) {
     201        textIndicatorInstallationCallback(textIndicator.get());
     202        [mutableOptions setObject:@YES forKey:getLUTermOptionDisableSearchTermIndicator()];
     203
     204        if ([getLULookupDefinitionModuleClass() respondsToSelector:@selector(showDefinitionForTerm:relativeToRect:ofView:options:)]) {
     205            FloatRect firstTextRectInViewCoordinates = textIndicator.get().textRectsInBoundingRectCoordinates()[0];
     206            firstTextRectInViewCoordinates.moveBy(textIndicator.get().textBoundingRectInRootViewCoordinates().location());
     207            if (createAnimationController) {
     208#if  __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
     209                return [getLULookupDefinitionModuleClass() lookupAnimationControllerForTerm:dictionaryPopupInfo.attributedString.get() relativeToRect:firstTextRectInViewCoordinates ofView:view options:mutableOptions.get()];
     210#else
     211                return nil;
     212#endif
     213            }
     214            [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.get() relativeToRect:firstTextRectInViewCoordinates ofView:view options:mutableOptions.get()];
     215            return nil;
     216        }
     217    }
     218
     219    NSPoint textBaselineOrigin = dictionaryPopupInfo.origin;
     220
     221    // Convert to screen coordinates.
     222    textBaselineOrigin = [view convertPoint:textBaselineOrigin toView:nil];
     223    textBaselineOrigin = [view.window convertRectToScreen:NSMakeRect(textBaselineOrigin.x, textBaselineOrigin.y, 0, 0)].origin;
     224
     225    if (createAnimationController) {
     226#if  __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
     227        return [getLULookupDefinitionModuleClass() lookupAnimationControllerForTerm:dictionaryPopupInfo.attributedString.get() atLocation:textBaselineOrigin options:mutableOptions.get()];
     228#else
     229        return nil;
     230#endif
     231    }
     232
     233    [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.get() atLocation:textBaselineOrigin options:mutableOptions.get()];
     234    return nil;
     235}
     236
     237void DictionaryLookup::showPopup(const DictionaryPopupInfo& dictionaryPopupInfo, NSView *view, std::function<void(TextIndicator&)> textIndicatorInstallationCallback)
     238{
     239    showPopupOrCreateAnimationController(false, dictionaryPopupInfo, view, textIndicatorInstallationCallback);
     240}
     241
     242void DictionaryLookup::hidePopup()
     243{
     244    if (!getLULookupDefinitionModuleClass())
     245        return;
     246    [getLULookupDefinitionModuleClass() hideDefinition];
     247}
     248
     249PlatformAnimationController DictionaryLookup::animationControllerForPopup(const DictionaryPopupInfo& dictionaryPopupInfo, NSView *view, std::function<void(TextIndicator&)> textIndicatorInstallationCallback)
     250{
     251    return showPopupOrCreateAnimationController(true, dictionaryPopupInfo, view, textIndicatorInstallationCallback);
     252}
     253
    188254} // namespace WebCore
    189255
  • trunk/Source/WebCore/page/mac/EventHandlerMac.mm

    r188860 r189052  
    10801080
    10811081    NSDictionary *options = nil;
    1082     if (RefPtr<Range> range = rangeForDictionaryLookupAtHitTestResult(result, &options))
     1082    if (RefPtr<Range> range = DictionaryLookup::rangeAtHitTestResult(result, &options))
    10831083        return VisibleSelection(*range);
    10841084
  • trunk/Source/WebCore/testing/Internals.cpp

    r189034 r189052  
    12701270    HitTestResult result = document->frame()->mainFrame().eventHandler().hitTestResultAtPoint(IntPoint(x, y));
    12711271    NSDictionary *options = nullptr;
    1272     return rangeForDictionaryLookupAtHitTestResult(result, &options);
     1272    return DictionaryLookup::rangeAtHitTestResult(result, &options);
    12731273#else
    12741274    UNUSED_PARAM(x);
  • trunk/Source/WebKit/ChangeLog

    r188995 r189052  
     12015-08-27  Timothy Horton  <timothy_horton@apple.com>
     2
     3        Factor out Lookup invocation
     4        https://bugs.webkit.org/show_bug.cgi?id=148509
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * WebKit.xcodeproj/project.pbxproj:
     9
    1102015-08-26  Brent Fulgham  <bfulgham@apple.com>
    211
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r186268 r189052  
    102102                2DD632C219E5D1F0002E9C7B /* WebSelectionServiceController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DD632C019E5D1F0002E9C7B /* WebSelectionServiceController.h */; };
    103103                2DD632C319E5D1F0002E9C7B /* WebSelectionServiceController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DD632C119E5D1F0002E9C7B /* WebSelectionServiceController.mm */; };
    104                 2DF064A91A2DD53C00DBB354 /* DictionaryPopupInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DF064A81A2DD53C00DBB354 /* DictionaryPopupInfo.h */; };
    105104                312E2FE514E48182007CCA18 /* WebNotification.h in Headers */ = {isa = PBXBuildFile; fileRef = 312E2FE314E48182007CCA18 /* WebNotification.h */; settings = {ATTRIBUTES = (Private, ); }; };
    106105                312E2FE614E48182007CCA18 /* WebNotification.mm in Sources */ = {isa = PBXBuildFile; fileRef = 312E2FE414E48182007CCA18 /* WebNotification.mm */; };
     
    564563                2DD632C019E5D1F0002E9C7B /* WebSelectionServiceController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSelectionServiceController.h; sourceTree = "<group>"; };
    565564                2DD632C119E5D1F0002E9C7B /* WebSelectionServiceController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebSelectionServiceController.mm; sourceTree = "<group>"; };
    566                 2DF064A81A2DD53C00DBB354 /* DictionaryPopupInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DictionaryPopupInfo.h; sourceTree = "<group>"; };
    567565                312E2FE314E48182007CCA18 /* WebNotification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebNotification.h; sourceTree = "<group>"; };
    568566                312E2FE414E48182007CCA18 /* WebNotification.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebNotification.mm; sourceTree = "<group>"; };
     
    13221320                                51E94C0706C02CA300A9B09E /* PDF */,
    13231321                                A10C1D79182030190036883A /* ios */,
    1324                                 2DF064A81A2DD53C00DBB354 /* DictionaryPopupInfo.h */,
    13251322                                8373435A0624EE0D00F3B289 /* WebArchive.h */,
    13261323                                8373435B0624EE0D00F3B289 /* WebArchive.mm */,
     
    18411838                                9398106D0824BF01008DF038 /* WebKitErrorsPrivate.h in Headers */,
    18421839                                CD8BFCE815531224005AFB25 /* WebKitFullScreenListener.h in Headers */,
    1843                                 2DF064A91A2DD53C00DBB354 /* DictionaryPopupInfo.h in Headers */,
    18441840                                9398101D0824BF01008DF038 /* WebKitLogging.h in Headers */,
    18451841                                9398101E0824BF01008DF038 /* WebKitNSStringExtras.h in Headers */,
  • trunk/Source/WebKit/mac/ChangeLog

    r189034 r189052  
     12015-08-27  Timothy Horton  <timothy_horton@apple.com>
     2
     3        Factor out Lookup invocation
     4        https://bugs.webkit.org/show_bug.cgi?id=148509
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * WebView/DictionaryPopupInfo.h: Removed.
     9        Move to WebCore.
     10
     11        * WebView/WebHTMLView.mm:
     12        (-[WebHTMLView _lookUpInDictionaryFromMenu:]):
     13        DictionaryPopupInfo keeps a TextIndicatorData, not a TextIndicator.
     14
     15        * WebView/WebImmediateActionController.mm:
     16        (-[WebImmediateActionController _animationControllerForDataDetectedLink]):
     17        (dictionaryPopupInfoForRange):
     18        (-[WebImmediateActionController _animationControllerForText]):
     19        * WebView/WebView.mm:
     20        (-[WebView _prepareForDictionaryLookup]):
     21        (-[WebView _animationControllerForDictionaryLookupPopupInfo:]):
     22        (-[WebView _setTextIndicator:withLifetime:]):
     23        (-[WebView _showDictionaryLookupPopup:]):
     24        * WebView/WebViewInternal.h:
     25        Move a bunch of code to WebCore.
     26        Factor some that has to stay out into _prepareForDictionaryLookup.
     27
    1282015-08-27  Brian Burg  <bburg@apple.com>
    229
  • trunk/Source/WebKit/mac/WebView/WebHTMLView.mm

    r188420 r189052  
    3535#import "DOMNodeInternal.h"
    3636#import "DOMRangeInternal.h"
    37 #import "DictionaryPopupInfo.h"
    3837#import "WebArchive.h"
    3938#import "WebClipView.h"
     
    8382#import <WebCore/ContextMenu.h>
    8483#import <WebCore/ContextMenuController.h>
     84#import <WebCore/DictionaryLookup.h>
    8585#import <WebCore/Document.h>
    8686#import <WebCore/DocumentFragment.h>
     
    56905690    info.attributedString = attrString;
    56915691    info.origin = coreFrame->view()->contentsToWindow(enclosingIntRect(rect)).location();
    5692     info.textIndicator = TextIndicator::createWithSelectionInFrame(*coreFrame, TextIndicatorOptionIncludeSnapshotWithSelectionHighlight, TextIndicatorPresentationTransition::BounceAndCrossfade);
     5692    if (auto textIndicator = TextIndicator::createWithSelectionInFrame(*coreFrame, TextIndicatorOptionIncludeSnapshotWithSelectionHighlight, TextIndicatorPresentationTransition::BounceAndCrossfade))
     5693        info.textIndicator = textIndicator->data();
    56935694    [[self _webView] _showDictionaryLookupPopup:info];
    56945695}
  • trunk/Source/WebKit/mac/WebView/WebImmediateActionController.mm

    r188990 r189052  
    3131#import "DOMNodeInternal.h"
    3232#import "DOMRangeInternal.h"
    33 #import "DictionaryPopupInfo.h"
    3433#import "WebElementDictionary.h"
    3534#import "WebFrameInternal.h"
     
    455454        return nullptr;
    456455    RefPtr<TextIndicator> indicator = TextIndicator::createWithRange(*linkRange, TextIndicatorOptionDefault, TextIndicatorPresentationTransition::FadeIn);
     456    indicator->data().textBoundingRectInRootViewCoordinates = [_webView _convertRectFromRootView:indicator->textBoundingRectInRootViewCoordinates()];
    457457
    458458    _currentActionContext = [actionContext contextForView:_webView altMode:YES interactionStartedHandler:^() {
     
    511511
    512512    popupInfo.attributedString = scaledNSAttributedString.get();
    513     popupInfo.textIndicator = TextIndicator::createWithRange(range, TextIndicatorOptionDefault, presentationTransition);
     513
     514    if (auto textIndicator = TextIndicator::createWithRange(range, TextIndicatorOptionDefault, presentationTransition))
     515        popupInfo.textIndicator = textIndicator->data();
    514516    return popupInfo;
    515517}
     
    529531
    530532    NSDictionary *options = nil;
    531     RefPtr<Range> dictionaryRange = rangeForDictionaryLookupAtHitTestResult(_hitTestResult, &options);
     533    RefPtr<Range> dictionaryRange = DictionaryLookup::rangeAtHitTestResult(_hitTestResult, &options);
    532534    if (!dictionaryRange)
    533535        return nil;
  • trunk/Source/WebKit/mac/WebView/WebView.mm

    r188594 r189052  
    3636#import "DOMNodeInternal.h"
    3737#import "DOMRangeInternal.h"
    38 #import "DictionaryPopupInfo.h"
    3938#import "StorageThread.h"
    4039#import "WebAlternativeTextClient.h"
     
    124123#import <WebCore/ColorMac.h>
    125124#import <WebCore/DatabaseManager.h>
     125#import <WebCore/DictionaryLookup.h>
    126126#import <WebCore/Document.h>
    127127#import <WebCore/DocumentLoader.h>
     
    296296#if PLATFORM(MAC)
    297297SOFT_LINK_CONSTANT_MAY_FAIL(Lookup, LUNotificationPopoverWillClose, NSString *)
    298 SOFT_LINK_CONSTANT_MAY_FAIL(Lookup, LUTermOptionDisableSearchTermIndicator, NSString *)
    299298#endif
    300299
     
    85528551        return nil;
    85538552
    8554     if (canLoadLUTermOptionDisableSearchTermIndicator() && canLoadLUNotificationPopoverWillClose() && dictionaryPopupInfo.textIndicator) {
    8555         if (!_private->hasInitializedLookupObserver) {
    8556             [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_dictionaryLookupPopoverWillClose:) name:getLUNotificationPopoverWillClose() object:nil];
    8557             _private->hasInitializedLookupObserver = YES;
    8558         }
    8559 
    8560         RetainPtr<NSMutableDictionary> mutableOptions = adoptNS([dictionaryPopupInfo.options mutableCopy]);
    8561         if (!mutableOptions)
    8562             mutableOptions = adoptNS([[NSMutableDictionary alloc] init]);
    8563         [mutableOptions setObject:@YES forKey:getLUTermOptionDisableSearchTermIndicator()];
    8564         [self _setTextIndicator:*dictionaryPopupInfo.textIndicator withLifetime:TextIndicatorWindowLifetime::Permanent];
    8565 
    8566         if ([getLULookupDefinitionModuleClass() respondsToSelector:@selector(lookupAnimationControllerForTerm:relativeToRect:ofView:options:)]) {
    8567             FloatRect firstTextRectInViewCoordinates = dictionaryPopupInfo.textIndicator->textRectsInBoundingRectCoordinates()[0];
    8568             firstTextRectInViewCoordinates.moveBy(dictionaryPopupInfo.textIndicator->textBoundingRectInRootViewCoordinates().location());
    8569             return [getLULookupDefinitionModuleClass() lookupAnimationControllerForTerm:dictionaryPopupInfo.attributedString.get() relativeToRect:[self _convertRectFromRootView:firstTextRectInViewCoordinates] ofView:self options:mutableOptions.get()];
    8570         }
    8571     }
    8572 
    8573     // Convert to screen coordinates.
    8574     NSPoint textBaselineOrigin = [self.window convertRectToScreen:NSMakeRect(dictionaryPopupInfo.origin.x, dictionaryPopupInfo.origin.y, 0, 0)].origin;
    8575 
    8576     return [getLULookupDefinitionModuleClass() lookupAnimationControllerForTerm:dictionaryPopupInfo.attributedString.get() atLocation:textBaselineOrigin options:dictionaryPopupInfo.options.get()];
     8553    [self _prepareForDictionaryLookup];
     8554
     8555    DictionaryPopupInfo adjustedPopupInfo = dictionaryPopupInfo;
     8556    adjustedPopupInfo.textIndicator.textBoundingRectInRootViewCoordinates = [self _convertRectFromRootView:adjustedPopupInfo.textIndicator.textBoundingRectInRootViewCoordinates];
     8557
     8558    return DictionaryLookup::animationControllerForPopup(adjustedPopupInfo, self, [self](TextIndicator& textIndicator) {
     8559        [self _setTextIndicator:textIndicator withLifetime:TextIndicatorWindowLifetime::Permanent];
     8560    });
    85778561}
    85788562#endif // __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
     
    85988582        _private->textIndicatorWindow = std::make_unique<TextIndicatorWindow>(self);
    85998583
    8600     NSRect textBoundingRectInWindowCoordinates = [self convertRect:[self _convertRectFromRootView:textIndicator.textBoundingRectInRootViewCoordinates()] toView:nil];
     8584    NSRect textBoundingRectInWindowCoordinates = [self convertRect:textIndicator.textBoundingRectInRootViewCoordinates() toView:nil];
    86018585    NSRect textBoundingRectInScreenCoordinates = [self.window convertRectToScreen:textBoundingRectInWindowCoordinates];
    86028586    _private->textIndicatorWindow->setTextIndicator(textIndicator, NSRectToCGRect(textBoundingRectInScreenCoordinates), lifetime);
     
    86168600}
    86178601
     8602- (void)_prepareForDictionaryLookup
     8603{
     8604    if (_private->hasInitializedLookupObserver)
     8605        return;
     8606
     8607    _private->hasInitializedLookupObserver = YES;
     8608
     8609    if (canLoadLUNotificationPopoverWillClose())
     8610        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_dictionaryLookupPopoverWillClose:) name:getLUNotificationPopoverWillClose() object:nil];
     8611}
     8612
    86188613- (void)_showDictionaryLookupPopup:(const DictionaryPopupInfo&)dictionaryPopupInfo
    86198614{
     
    86218616        return;
    86228617
    8623     if (canLoadLUTermOptionDisableSearchTermIndicator() && canLoadLUNotificationPopoverWillClose() && dictionaryPopupInfo.textIndicator) {
    8624         if (!_private->hasInitializedLookupObserver) {
    8625             [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_dictionaryLookupPopoverWillClose:) name:getLUNotificationPopoverWillClose() object:nil];
    8626             _private->hasInitializedLookupObserver = YES;
    8627         }
    8628 
    8629         RetainPtr<NSMutableDictionary> mutableOptions = adoptNS([dictionaryPopupInfo.options mutableCopy]);
    8630         if (!mutableOptions)
    8631             mutableOptions = adoptNS([[NSMutableDictionary alloc] init]);
    8632         [mutableOptions setObject:@YES forKey:getLUTermOptionDisableSearchTermIndicator()];
    8633         [self _setTextIndicator:*dictionaryPopupInfo.textIndicator withLifetime:TextIndicatorWindowLifetime::Permanent];
    8634 
    8635         if ([getLULookupDefinitionModuleClass() respondsToSelector:@selector(showDefinitionForTerm:relativeToRect:ofView:options:)]) {
    8636             FloatRect firstTextRectInViewCoordinates = dictionaryPopupInfo.textIndicator->textRectsInBoundingRectCoordinates()[0];
    8637             firstTextRectInViewCoordinates.moveBy(dictionaryPopupInfo.textIndicator->textBoundingRectInRootViewCoordinates().location());
    8638             [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.get() relativeToRect:[self _convertRectFromRootView:firstTextRectInViewCoordinates] ofView:self options:mutableOptions.get()];
    8639             return;
    8640         }
    8641     }
    8642 
    8643     // Convert to screen coordinates.
    8644     NSPoint textBaselineOrigin = [self.window convertRectToScreen:NSMakeRect(dictionaryPopupInfo.origin.x, dictionaryPopupInfo.origin.y, 0, 0)].origin;
    8645 
    8646     [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.get() atLocation:textBaselineOrigin options:dictionaryPopupInfo.options.get()];
     8618    [self _prepareForDictionaryLookup];
     8619
     8620    DictionaryPopupInfo adjustedPopupInfo = dictionaryPopupInfo;
     8621    adjustedPopupInfo.textIndicator.textBoundingRectInRootViewCoordinates = [self _convertRectFromRootView:adjustedPopupInfo.textIndicator.textBoundingRectInRootViewCoordinates];
     8622
     8623    DictionaryLookup::showPopup(adjustedPopupInfo, self, [self](TextIndicator& textIndicator) {
     8624        [self _setTextIndicator:textIndicator withLifetime:TextIndicatorWindowLifetime::Permanent];
     8625    });
    86478626}
    86488627
  • trunk/Source/WebKit/mac/WebView/WebViewInternal.h

    r188420 r189052  
    5959class URL;
    6060struct DictationAlternative;
     61struct DictionaryPopupInfo;
    6162}
    6263
    63 struct DictionaryPopupInfo;
    6464class WebMediaPlaybackTargetPicker;
    6565class WebSelectionServiceController;
     
    270270- (void)_clearTextIndicatorWithAnimation:(WebCore::TextIndicatorWindowDismissalAnimation)animation;
    271271- (void)_setTextIndicatorAnimationProgress:(float)progress;
    272 - (void)_showDictionaryLookupPopup:(const DictionaryPopupInfo&)dictionaryPopupInfo;
     272- (void)_showDictionaryLookupPopup:(const WebCore::DictionaryPopupInfo&)dictionaryPopupInfo;
    273273#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
    274 - (id)_animationControllerForDictionaryLookupPopupInfo:(const DictionaryPopupInfo&)dictionaryPopupInfo;
     274- (id)_animationControllerForDictionaryLookupPopupInfo:(const WebCore::DictionaryPopupInfo&)dictionaryPopupInfo;
    275275- (WebImmediateActionController *)_immediateActionController;
    276276#endif
  • trunk/Source/WebKit2/CMakeLists.txt

    r188900 r189052  
    218218    Shared/ChildProcessProxy.cpp
    219219    Shared/ContextMenuContextData.cpp
    220     Shared/DictionaryPopupInfo.cpp
    221220    Shared/EditorState.cpp
    222221    Shared/FontInfo.cpp
  • trunk/Source/WebKit2/ChangeLog

    r189034 r189052  
     12015-08-27  Timothy Horton  <timothy_horton@apple.com>
     2
     3        Factor out Lookup invocation
     4        https://bugs.webkit.org/show_bug.cgi?id=148509
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * Shared/DictionaryPopupInfo.cpp: Removed.
     9        * Shared/DictionaryPopupInfo.h: Removed.
     10        Moved to WebCore.
     11
     12        * Shared/WebCoreArgumentCoders.cpp:
     13        (IPC::ArgumentCoder<DictionaryPopupInfo>::encode):
     14        (IPC::ArgumentCoder<DictionaryPopupInfo>::decode):
     15        Add encode/decoders for DictionaryPopupInfo now that it's in WebCore.
     16
     17        * Shared/WebCoreArgumentCoders.h:
     18        * Shared/WebHitTestResult.h:
     19        * Shared/mac/ArgumentCodersMac.h:
     20        * UIProcess/API/mac/WKView.mm:
     21        (+[WKView hideWordDefinitionWindow]):
     22        (-[WKView _dismissContentRelativeChildWindows]):
     23        * UIProcess/PageClient.h:
     24        * UIProcess/WebPageProxy.h:
     25        * UIProcess/WebPageProxy.messages.in:
     26        * UIProcess/mac/PageClientImpl.h:
     27        * UIProcess/mac/PageClientImpl.mm:
     28        (WebKit::PageClientImpl::didPerformDictionaryLookup):
     29        * UIProcess/mac/WKImmediateActionController.mm:
     30        (-[WKImmediateActionController _animationControllerForText]):
     31        * UIProcess/mac/WebPageProxyMac.mm:
     32        * WebKit2.xcodeproj/project.pbxproj:
     33        * WebProcess/Plugins/PDF/PDFPlugin.mm:
     34        (WebKit::PDFPlugin::showDefinitionForAttributedString):
     35        (WebKit::PDFPlugin::lookupTextAtLocation):
     36        * WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm:
     37        * WebProcess/WebPage/WebPage.h:
     38        * WebProcess/WebPage/mac/WebPageMac.mm:
     39        (WebKit::WebPage::performDictionaryLookupAtLocation):
     40        (WebKit::WebPage::performDictionaryLookupForSelection):
     41        (WebKit::WebPage::dictionaryPopupInfoForRange):
     42        (WebKit::WebPage::dictionaryPopupInfoForSelectionInPDFPlugin):
     43        (WebKit::WebPage::lookupTextAtLocation):
     44        Adjust to new names and move stuff to WebCore.
     45
    1462015-08-27  Brian Burg  <bburg@apple.com>
    247
  • trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp

    r188526 r189052  
    3737#include <WebCore/DatabaseDetails.h>
    3838#include <WebCore/DictationAlternative.h>
     39#include <WebCore/DictionaryPopupInfo.h>
    3940#include <WebCore/Editor.h>
    4041#include <WebCore/FileChooser.h>
     
    7475#if PLATFORM(COCOA)
    7576#include "ArgumentCodersCF.h"
     77#include "ArgumentCodersMac.h"
    7678#endif
    7779
     
    22042206#endif
    22052207
     2208void ArgumentCoder<DictionaryPopupInfo>::encode(IPC::ArgumentEncoder& encoder, const DictionaryPopupInfo& info)
     2209{
     2210    encoder << info.origin;
     2211    encoder << info.textIndicator;
     2212
     2213#if PLATFORM(COCOA)
     2214    bool hadOptions = info.options;
     2215    encoder << hadOptions;
     2216    if (hadOptions)
     2217        IPC::encode(encoder, info.options.get());
     2218
     2219    bool hadAttributedString = info.attributedString;
     2220    encoder << hadAttributedString;
     2221    if (hadAttributedString)
     2222        IPC::encode(encoder, info.attributedString.get());
     2223#endif
     2224}
     2225
     2226bool ArgumentCoder<DictionaryPopupInfo>::decode(IPC::ArgumentDecoder& decoder, DictionaryPopupInfo& result)
     2227{
     2228    if (!decoder.decode(result.origin))
     2229        return false;
     2230
     2231    if (!decoder.decode(result.textIndicator))
     2232        return false;
     2233
     2234#if PLATFORM(COCOA)
     2235    bool hadOptions;
     2236    if (!decoder.decode(hadOptions))
     2237        return false;
     2238    if (hadOptions) {
     2239        if (!IPC::decode(decoder, result.options))
     2240            return false;
     2241    } else
     2242        result.options = nullptr;
     2243
     2244    bool hadAttributedString;
     2245    if (!decoder.decode(hadAttributedString))
     2246        return false;
     2247    if (hadAttributedString) {
     2248        if (!IPC::decode(decoder, result.attributedString))
     2249            return false;
     2250    } else
     2251        result.attributedString = nullptr;
     2252#endif
     2253    return true;
     2254}
     2255
    22062256} // namespace IPC
  • trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.h

    r188983 r189052  
    7272struct Cookie;
    7373struct DictationAlternative;
     74struct DictionaryPopupInfo;
    7475struct FileChooserSettings;
    7576struct IDBDatabaseMetadata;
     
    474475};
    475476
     477template<> struct ArgumentCoder<WebCore::DictionaryPopupInfo> {
     478    static void encode(ArgumentEncoder&, const WebCore::DictionaryPopupInfo&);
     479    static bool decode(ArgumentDecoder&, WebCore::DictionaryPopupInfo&);
     480};
     481
    476482#if ENABLE(WIRELESS_PLAYBACK_TARGET)
    477483template<> struct ArgumentCoder<WebCore::MediaPlaybackTargetContext> {
  • trunk/Source/WebKit2/Shared/WebHitTestResult.h

    r184780 r189052  
    2222
    2323#include "APIObject.h"
    24 #include "DictionaryPopupInfo.h"
    2524#include "SharedMemory.h"
     25#include <WebCore/DictionaryPopupInfo.h>
    2626#include <WebCore/FloatPoint.h>
    2727#include <WebCore/IntRect.h>
     
    7676        WebCore::PageOverlay::PageOverlayID detectedDataOriginatingPageOverlay;
    7777
    78         DictionaryPopupInfo dictionaryPopupInfo;
     78        WebCore::DictionaryPopupInfo dictionaryPopupInfo;
    7979
    8080        RefPtr<WebCore::TextIndicator> linkTextIndicator;
  • trunk/Source/WebKit2/Shared/mac/ArgumentCodersMac.h

    r161148 r189052  
    2828
    2929#include <wtf/RetainPtr.h>
     30
     31OBJC_CLASS NSArray;
     32OBJC_CLASS NSAttributedString;
     33OBJC_CLASS NSColor;
     34OBJC_CLASS NSData;
     35OBJC_CLASS NSDate;
     36OBJC_CLASS NSDictionary;
     37OBJC_CLASS NSFont;
     38OBJC_CLASS NSNumber;
     39OBJC_CLASS NSString;
    3040
    3141namespace IPC {
  • trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm

    r188718 r189052  
    8484#import <WebCore/ColorMac.h>
    8585#import <WebCore/DataDetectorsSPI.h>
     86#import <WebCore/DictionaryLookup.h>
    8687#import <WebCore/DragController.h>
    8788#import <WebCore/DragData.h>
     
    40844085+ (void)hideWordDefinitionWindow
    40854086{
    4086     if (!getLULookupDefinitionModuleClass())
    4087         return;
    4088     [getLULookupDefinitionModuleClass() hideDefinition];
     4087    DictionaryLookup::hidePopup();
    40894088}
    40904089
     
    46774676#endif
    46784677        ) {
    4679         if (Class lookupDefinitionModuleClass = getLULookupDefinitionModuleClass())
    4680             [lookupDefinitionModuleClass hideDefinition];
     4678        DictionaryLookup::hidePopup();
    46814679
    46824680#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
  • trunk/Source/WebKit2/UIProcess/PageClient.h

    r188693 r189052  
    240240    virtual void pluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus) = 0;
    241241    virtual void setPluginComplexTextInputState(uint64_t pluginComplexTextInputIdentifier, PluginComplexTextInputState) = 0;
    242     virtual void didPerformDictionaryLookup(const DictionaryPopupInfo&) = 0;
     242    virtual void didPerformDictionaryLookup(const WebCore::DictionaryPopupInfo&) = 0;
    243243    virtual void dismissContentRelativeChildWindows(bool withAnimation = true) = 0;
    244244    virtual void showCorrectionPanel(WebCore::AlternativeTextType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings) = 0;
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r188983 r189052  
    156156class SharedBuffer;
    157157class TextIndicator;
     158struct DictionaryPopupInfo;
    158159struct FileChooserSettings;
    159160struct TextAlternativeWithRange;
     
    202203struct AttributedString;
    203204struct ColorSpaceData;
    204 struct DictionaryPopupInfo;
    205205struct EditingRange;
    206206struct EditorState;
     
    12961296
    12971297    // Dictionary.
    1298     void didPerformDictionaryLookup(const DictionaryPopupInfo&);
     1298    void didPerformDictionaryLookup(const WebCore::DictionaryPopupInfo&);
    12991299#endif
    13001300
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in

    r188693 r189052  
    309309#if PLATFORM(COCOA)
    310310    # Dictionary support.
    311     DidPerformDictionaryLookup(struct WebKit::DictionaryPopupInfo dictionaryPopupInfo)
     311    DidPerformDictionaryLookup(struct WebCore::DictionaryPopupInfo dictionaryPopupInfo)
    312312
    313313    # Keyboard input support messages
  • trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h

    r188693 r189052  
    146146    virtual void makeFirstResponder() override;
    147147   
    148     virtual void didPerformDictionaryLookup(const DictionaryPopupInfo&) override;
     148    virtual void didPerformDictionaryLookup(const WebCore::DictionaryPopupInfo&) override;
    149149    virtual void dismissContentRelativeChildWindows(bool withAnimation = true) override;
    150150
  • trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm

    r188693 r189052  
    2929#if PLATFORM(MAC)
    3030
    31 #import "AttributedString.h"
    3231#import "ColorSpaceData.h"
    3332#import "DataReference.h"
    34 #import "DictionaryPopupInfo.h"
    3533#import "DownloadProxy.h"
    3634#import "NativeWebKeyboardEvent.h"
     
    5452#import <WebCore/BitmapImage.h>
    5553#import <WebCore/Cursor.h>
     54#import <WebCore/DictionaryLookup.h>
    5655#import <WebCore/FloatRect.h>
    5756#import <WebCore/GraphicsContext.h>
    5857#import <WebCore/Image.h>
    5958#import <WebCore/KeyboardEvent.h>
    60 #import <WebCore/LookupSPI.h>
    6159#import <WebCore/NotImplemented.h>
    6260#import <WebCore/SharedBuffer.h>
     
    8684#endif
    8785
    88 SOFT_LINK_CONSTANT_MAY_FAIL(Lookup, LUTermOptionDisableSearchTermIndicator, NSString *)
    89 
    9086using namespace WebCore;
    9187using namespace WebKit;
     
    586582void PageClientImpl::didPerformDictionaryLookup(const DictionaryPopupInfo& dictionaryPopupInfo)
    587583{
    588     if (!getLULookupDefinitionModuleClass())
    589         return;
    590 
    591     RetainPtr<NSMutableDictionary> mutableOptions = adoptNS([(NSDictionary *)dictionaryPopupInfo.options.get() mutableCopy]);
    592 
    593584    [m_wkView _prepareForDictionaryLookup];
    594585
    595     if (canLoadLUTermOptionDisableSearchTermIndicator() && dictionaryPopupInfo.textIndicator.contentImage) {
    596         [m_wkView _setTextIndicator:TextIndicator::create(dictionaryPopupInfo.textIndicator) withLifetime:TextIndicatorWindowLifetime::Permanent];
    597         [mutableOptions setObject:@YES forKey:getLUTermOptionDisableSearchTermIndicator()];
    598 
    599         if ([getLULookupDefinitionModuleClass() respondsToSelector:@selector(showDefinitionForTerm:relativeToRect:ofView:options:)]) {
    600             FloatRect firstTextRectInViewCoordinates = dictionaryPopupInfo.textIndicator.textRectsInBoundingRectCoordinates[0];
    601             firstTextRectInViewCoordinates.moveBy(dictionaryPopupInfo.textIndicator.textBoundingRectInRootViewCoordinates.location());
    602             [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.string.get() relativeToRect:firstTextRectInViewCoordinates ofView:m_wkView options:mutableOptions.get()];
    603             return;
    604         }
    605     }
    606 
    607     NSPoint textBaselineOrigin = dictionaryPopupInfo.origin;
    608 
    609     // Convert to screen coordinates.
    610     textBaselineOrigin = [m_wkView convertPoint:textBaselineOrigin toView:nil];
    611     textBaselineOrigin = [m_wkView.window convertRectToScreen:NSMakeRect(textBaselineOrigin.x, textBaselineOrigin.y, 0, 0)].origin;
    612 
    613     [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.string.get() atLocation:textBaselineOrigin options:mutableOptions.get()];
     586    DictionaryLookup::showPopup(dictionaryPopupInfo, m_wkView, [this](TextIndicator& textIndicator) {
     587        [m_wkView _setTextIndicator:textIndicator withLifetime:TextIndicatorWindowLifetime::Permanent];
     588    });
    614589}
    615590
  • trunk/Source/WebKit2/UIProcess/mac/WKImmediateActionController.mm

    r188443 r189052  
    3636#import "WebProcessProxy.h"
    3737#import <WebCore/DataDetectorsSPI.h>
     38#import <WebCore/DictionaryLookup.h>
    3839#import <WebCore/GeometryUtilities.h>
    3940#import <WebCore/LookupSPI.h>
     
    4748SOFT_LINK_FRAMEWORK_IN_UMBRELLA(Quartz, QuickLookUI)
    4849SOFT_LINK_CLASS(QuickLookUI, QLPreviewMenuItem)
    49 SOFT_LINK_CONSTANT_MAY_FAIL(Lookup, LUTermOptionDisableSearchTermIndicator, NSString *)
    5050
    5151using namespace WebCore;
     
    462462        return nil;
    463463
    464     if (!getLULookupDefinitionModuleClass())
    465         return nil;
    466 
    467464    DictionaryPopupInfo dictionaryPopupInfo = _hitTestResultData.dictionaryPopupInfo;
    468     if (!dictionaryPopupInfo.attributedString.string)
     465    if (!dictionaryPopupInfo.attributedString)
    469466        return nil;
    470467
    471468    [_wkView _prepareForDictionaryLookup];
    472469
    473     RetainPtr<NSMutableDictionary> mutableOptions = adoptNS([(NSDictionary *)dictionaryPopupInfo.options.get() mutableCopy]);
    474     if (canLoadLUTermOptionDisableSearchTermIndicator() && dictionaryPopupInfo.textIndicator.contentImage) {
    475         [_wkView _setTextIndicator:TextIndicator::create(dictionaryPopupInfo.textIndicator) withLifetime:TextIndicatorWindowLifetime::Permanent];
    476         [mutableOptions setObject:@YES forKey:getLUTermOptionDisableSearchTermIndicator()];
    477 
    478         if ([getLULookupDefinitionModuleClass() respondsToSelector:@selector(lookupAnimationControllerForTerm:relativeToRect:ofView:options:)]) {
    479             FloatRect firstTextRectInViewCoordinates = dictionaryPopupInfo.textIndicator.textRectsInBoundingRectCoordinates[0];
    480             firstTextRectInViewCoordinates.moveBy(dictionaryPopupInfo.textIndicator.textBoundingRectInRootViewCoordinates.location());
    481             return [getLULookupDefinitionModuleClass() lookupAnimationControllerForTerm:dictionaryPopupInfo.attributedString.string.get() relativeToRect:firstTextRectInViewCoordinates ofView:_wkView options:mutableOptions.get()];
    482         }
    483     }
    484 
    485     // Convert baseline to screen coordinates.
    486     NSPoint textBaselineOrigin = dictionaryPopupInfo.origin;
    487     textBaselineOrigin = [_wkView convertPoint:textBaselineOrigin toView:nil];
    488     textBaselineOrigin = [_wkView.window convertRectToScreen:NSMakeRect(textBaselineOrigin.x, textBaselineOrigin.y, 0, 0)].origin;
    489 
    490     return [getLULookupDefinitionModuleClass() lookupAnimationControllerForTerm:dictionaryPopupInfo.attributedString.string.get() atLocation:textBaselineOrigin options:mutableOptions.get()];
     470    return DictionaryLookup::animationControllerForPopup(dictionaryPopupInfo, _wkView, [self](TextIndicator& textIndicator) {
     471        [_wkView _setTextIndicator:textIndicator withLifetime:TextIndicatorWindowLifetime::Permanent];
     472    });
    491473}
    492474
  • trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm

    r187609 r189052  
    3333#import "ColorSpaceData.h"
    3434#import "DataReference.h"
    35 #import "DictionaryPopupInfo.h"
    3635#import "EditingRange.h"
    3736#import "EditorState.h"
     
    4948#import "WebProcessProxy.h"
    5049#import <WebCore/DictationAlternative.h>
     50#import <WebCore/DictionaryLookup.h>
    5151#import <WebCore/GraphicsLayer.h>
    5252#import <WebCore/RuntimeApplicationChecks.h>
  • trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj

    r188895 r189052  
    15951595                BCE81D8C1319F7EF00241910 /* FontInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCE81D8A1319F7EF00241910 /* FontInfo.cpp */; };
    15961596                BCE81D8D1319F7EF00241910 /* FontInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE81D8B1319F7EF00241910 /* FontInfo.h */; };
    1597                 BCE81D98131AE02100241910 /* DictionaryPopupInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCE81D96131AE02000241910 /* DictionaryPopupInfo.cpp */; };
    1598                 BCE81D99131AE02100241910 /* DictionaryPopupInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE81D97131AE02100241910 /* DictionaryPopupInfo.h */; };
    15991597                BCEE7AD012817988009827DA /* WebProcessProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEE7ACC12817988009827DA /* WebProcessProxyMessageReceiver.cpp */; };
    16001598                BCEE7AD112817988009827DA /* WebProcessProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEE7ACD12817988009827DA /* WebProcessProxyMessages.h */; };
     
    38223820                BCE81D8A1319F7EF00241910 /* FontInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontInfo.cpp; sourceTree = "<group>"; };
    38233821                BCE81D8B1319F7EF00241910 /* FontInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontInfo.h; sourceTree = "<group>"; };
    3824                 BCE81D96131AE02000241910 /* DictionaryPopupInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DictionaryPopupInfo.cpp; sourceTree = "<group>"; };
    3825                 BCE81D97131AE02100241910 /* DictionaryPopupInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DictionaryPopupInfo.h; sourceTree = "<group>"; };
    38263822                BCE9C0CF1485965D00E33D61 /* WebConnectionToUIProcess.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebConnectionToUIProcess.cpp; sourceTree = "<group>"; };
    38273823                BCE9C0D01485965D00E33D61 /* WebConnectionToUIProcess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebConnectionToUIProcess.h; sourceTree = "<group>"; };
     
    47014697                                5106D7BF18BDBE73000AB166 /* ContextMenuContextData.cpp */,
    47024698                                5106D7C018BDBE73000AB166 /* ContextMenuContextData.h */,
    4703                                 BCE81D96131AE02000241910 /* DictionaryPopupInfo.cpp */,
    4704                                 BCE81D97131AE02100241910 /* DictionaryPopupInfo.h */,
    47054699                                C517388012DF8F4F00EE3F47 /* DragControllerAction.h */,
    47064700                                0FB659221208B4DB0044816C /* DrawingAreaInfo.h */,
     
    76387632                                1AC75380183BE50F0072CB15 /* DataReference.h in Headers */,
    76397633                                83891B6C1A68C30B0030F386 /* DiagnosticLoggingClient.h in Headers */,
    7640                                 BCE81D99131AE02100241910 /* DictionaryPopupInfo.h in Headers */,
    76417634                                518E8F0816B2093700E91429 /* Download.h in Headers */,
    76427635                                518E8F0A16B2093700E91429 /* DownloadAuthenticationClient.h in Headers */,
     
    94419434                                1AC7537F183BE50F0072CB15 /* DataReference.cpp in Sources */,
    94429435                                83891B6D1A68C30B0030F386 /* DiagnosticLoggingClient.mm in Sources */,
    9443                                 BCE81D98131AE02100241910 /* DictionaryPopupInfo.cpp in Sources */,
    94449436                                518E8F0716B2093700E91429 /* Download.cpp in Sources */,
    94459437                                518E8F0916B2093700E91429 /* DownloadAuthenticationClient.cpp in Sources */,
  • trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm

    r187002 r189052  
    3030
    3131#import "ArgumentCoders.h"
    32 #import "AttributedString.h"
    3332#import "DataReference.h"
    34 #import "DictionaryPopupInfo.h"
    3533#import "PDFAnnotationTextWidgetDetails.h"
    3634#import "PDFKitImports.h"
     
    17211719    DictionaryPopupInfo dictionaryPopupInfo;
    17221720    dictionaryPopupInfo.origin = convertFromPDFViewToRootView(IntPoint(point));
    1723     dictionaryPopupInfo.attributedString.string = string;
     1721    dictionaryPopupInfo.attributedString = string;
    17241722
    17251723    webFrame()->page()->send(Messages::WebPageProxy::DidPerformDictionaryLookup(dictionaryPopupInfo));
     
    19381936    }
    19391937   
    1940     NSString *lookupText = dictionaryLookupForPDFSelection(selection, options);
     1938    NSString *lookupText = DictionaryLookup::stringForPDFSelection(selection, options);
    19411939    if (!lookupText || !lookupText.length)
    19421940        return @"";
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm

    r183547 r189052  
    2929#if ENABLE(CONTEXT_MENUS)
    3030
    31 #import "DictionaryPopupInfo.h"
    3231#import "WebCoreArgumentCoders.h"
    3332#import "WebPage.h"
    3433#import "WebPageProxyMessages.h"
     34#import <WebCore/DictionaryLookup.h>
    3535#import <WebCore/FrameView.h>
    3636#import <WebCore/MainFrame.h>
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h

    r188828 r189052  
    3131#include "APIInjectedBundlePageUIClient.h"
    3232#include "APIObject.h"
    33 #include "DictionaryPopupInfo.h"
    3433#include "FindController.h"
    3534#include "GeolocationPermissionRequestManager.h"
     
    5049#include "UserMediaPermissionRequestManager.h"
    5150#include <WebCore/DictationAlternative.h>
     51#include <WebCore/DictionaryPopupInfo.h>
    5252#include <WebCore/DragData.h>
    5353#include <WebCore/Editor.h>
     
    10561056    void performDictionaryLookupOfCurrentSelection();
    10571057    void performDictionaryLookupForRange(WebCore::Frame*, WebCore::Range&, NSDictionary *options, WebCore::TextIndicatorPresentationTransition);
    1058     DictionaryPopupInfo dictionaryPopupInfoForRange(WebCore::Frame* frame, WebCore::Range& range, NSDictionary **options, WebCore::TextIndicatorPresentationTransition presentationTransition);
     1058    WebCore::DictionaryPopupInfo dictionaryPopupInfoForRange(WebCore::Frame*, WebCore::Range&, NSDictionary **options, WebCore::TextIndicatorPresentationTransition);
    10591059#if ENABLE(PDFKIT_PLUGIN)
    1060     DictionaryPopupInfo dictionaryPopupInfoForSelectionInPDFPlugin(PDFSelection *, PDFPlugin&, NSDictionary **options, WebCore::TextIndicatorPresentationTransition);
     1060    WebCore::DictionaryPopupInfo dictionaryPopupInfoForSelectionInPDFPlugin(PDFSelection *, PDFPlugin&, NSDictionary **options, WebCore::TextIndicatorPresentationTransition);
    10611061#endif
    10621062
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm

    r188990 r189052  
    3131#import "AttributedString.h"
    3232#import "DataReference.h"
    33 #import "DictionaryPopupInfo.h"
    3433#import "EditingRange.h"
    3534#import "EditorState.h"
     
    519518    Frame* frame = result.innerNonSharedNode() ? result.innerNonSharedNode()->document().frame() : &m_page->focusController().focusedOrMainFrame();
    520519    NSDictionary *options = nil;
    521     RefPtr<Range> range = rangeForDictionaryLookupAtHitTestResult(result, &options);
     520    RefPtr<Range> range = DictionaryLookup::rangeAtHitTestResult(result, &options);
    522521    if (!range)
    523522        return;
     
    529528{
    530529    NSDictionary *options = nil;
    531     RefPtr<Range> selectedRange = rangeForDictionaryLookupForSelection(selection, &options);
     530    RefPtr<Range> selectedRange = DictionaryLookup::rangeForSelection(selection, &options);
    532531    if (selectedRange)
    533532        performDictionaryLookupForRange(frame, *selectedRange, options, presentationTransition);
     
    557556
    558557    dictionaryPopupInfo.origin = FloatPoint(rangeRect.x(), rangeRect.y() + (style.fontMetrics().ascent() * pageScaleFactor()));
    559     dictionaryPopupInfo.options = (CFDictionaryRef)*options;
     558    dictionaryPopupInfo.options = *options;
    560559
    561560    NSAttributedString *nsAttributedString = editingAttributedStringFromRange(range, IncludeImagesInAttributedString::No);
     
    586585
    587586    dictionaryPopupInfo.textIndicator = textIndicator->data();
    588     dictionaryPopupInfo.attributedString.string = scaledNSAttributedString;
     587    dictionaryPopupInfo.attributedString = scaledNSAttributedString;
    589588
    590589    return dictionaryPopupInfo;
     
    639638   
    640639    dictionaryPopupInfo.origin = rangeRect.origin;
    641     dictionaryPopupInfo.options = (CFDictionaryRef)*options;
     640    dictionaryPopupInfo.options = *options;
    642641    dictionaryPopupInfo.textIndicator = dataForSelection;
    643     dictionaryPopupInfo.attributedString.string = scaledNSAttributedString;
     642    dictionaryPopupInfo.attributedString = scaledNSAttributedString;
    644643   
    645644    return dictionaryPopupInfo;
     
    11991198    IntPoint point = roundedIntPoint(locationInViewCoordinates);
    12001199    HitTestResult result = mainFrame.eventHandler().hitTestResultAtPoint(m_page->mainFrame().view()->windowToContents(point));
    1201     return rangeForDictionaryLookupAtHitTestResult(result, options);
     1200    return DictionaryLookup::rangeAtHitTestResult(result, options);
    12021201}
    12031202
Note: See TracChangeset for help on using the changeset viewer.