⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 176281 in webkit


Ignore:
Timestamp:
Nov 18, 2014, 1:28:10 PM (12 years ago)
Author:
dburkart@apple.com
Message:

Merge r176164. rdar://problem/18953982

Location:
branches/safari-600.3-branch/Source
Files:
28 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/safari-600.3-branch/Source/WebCore/ChangeLog

    r176280 r176281  
     12014-11-18  Dana Burkart  <dburkart@apple.com>
     2
     3        Merge r176164. rdar://problem/18953982
     4
     5    2014-11-16  Tim Horton  <timothy_horton@apple.com>
     6
     7            Use TextIndicator instead of the built in Lookup highlight
     8            https://bugs.webkit.org/show_bug.cgi?id=138775
     9            <rdar://problem/18953982>
     10
     11            Reviewed by Anders Carlsson.
     12
     13            * WebCore.exp.in:
     14            * platform/mac/WebCoreSystemInterface.h:
     15            * platform/mac/WebCoreSystemInterface.mm:
     16            Remove a WKSI import/export that we don't need anymore.
     17           
     18            * platform/spi/mac/LookupSPI.h: Added.
     19            (WebCore::canDisableLookupIndicator):
     20            Add Lookup SPI header.
     21            Add a 'canDisableLookupIndicator', which must be called in any translation
     22            unit that wants to use either of the soft-linked constants related to
     23            that functionality, before calling the get* function.
     24
     25            * WebCore.xcodeproj/project.pbxproj:
     26            * editing/mac/DictionaryLookup.mm:
     27            (WebCore::rangeForDictionaryLookupForSelection):
     28            (WebCore::rangeForDictionaryLookupAtHitTestResult):
     29            Adopt the Lookup SPI header.
     30
    1312014-11-18  Dana Burkart  <dburkart@apple.com>
    232
  • branches/safari-600.3-branch/Source/WebCore/WebCore.exp.in

    r176249 r176281  
    24212421_wkDrawTextFieldCellFocusRing
    24222422_wkExecutableWasLinkedOnOrBeforeSnowLeopard
    2423 _wkExtractWordDefinitionTokenRangeFromContextualString
    24242423_wkGetAXTextMarkerRangeTypeID
    24252424_wkGetAXTextMarkerTypeID
  • branches/safari-600.3-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r176249 r176281  
    10841084                2D3EF44A1917915C00034184 /* WebCoreCALayerExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D3EF4461917915C00034184 /* WebCoreCALayerExtras.h */; settings = {ATTRIBUTES = (Private, ); }; };
    10851085                2D3EF44B1917915C00034184 /* WebCoreCALayerExtras.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D3EF4471917915C00034184 /* WebCoreCALayerExtras.mm */; };
     1086                2D413F611A187A3F0041A521 /* LookupSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D413F601A187A3F0041A521 /* LookupSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
    10861087                2D46F04E17B96FBD005647F0 /* IntPoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D46F04D17B96FBD005647F0 /* IntPoint.cpp */; };
    10871088                2D46F05017B96FD2005647F0 /* IntSize.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D46F04F17B96FD2005647F0 /* IntSize.cpp */; };
     
    81078108                2D3EF4461917915C00034184 /* WebCoreCALayerExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreCALayerExtras.h; sourceTree = "<group>"; };
    81088109                2D3EF4471917915C00034184 /* WebCoreCALayerExtras.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreCALayerExtras.mm; sourceTree = "<group>"; };
     8110                2D413F601A187A3F0041A521 /* LookupSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LookupSPI.h; sourceTree = "<group>"; };
    81098111                2D46F04D17B96FBD005647F0 /* IntPoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IntPoint.cpp; sourceTree = "<group>"; };
    81108112                2D46F04F17B96FD2005647F0 /* IntSize.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IntSize.cpp; sourceTree = "<group>"; };
     
    1763017632                        children = (
    1763117633                                2D59F1BE1A0044C6001F3D29 /* DataDetectorsSPI.h */,
     17634                                2D413F601A187A3F0041A521 /* LookupSPI.h */,
    1763217635                                2DCB837719F99BBA00A7FBE4 /* NSSharingServicePickerSPI.h */,
    1763317636                                2DCB837819F99BBA00A7FBE4 /* NSSharingServiceSPI.h */,
     
    2362723630                                A584FE2618637DAB00843B10 /* CommandLineAPIModuleSource.h in Headers */,
    2362823631                                2D29ECC8192ECC8300984B78 /* DisplayRefreshMonitorManager.h in Headers */,
     23632                                2D413F611A187A3F0041A521 /* LookupSPI.h in Headers */,
    2362923633                                6550B6A2099DF0270090D781 /* Comment.h in Headers */,
    2363023634                                E1FE137518402A6700892F13 /* CommonCryptoUtilities.h in Headers */,
  • branches/safari-600.3-branch/Source/WebCore/editing/mac/DictionaryLookup.mm

    r176249 r176281  
    3535#import "HTMLConverter.h"
    3636#import "HitTestResult.h"
     37#import "LookupSPI.h"
    3738#import "Page.h"
    3839#import "Range.h"
     
    116117
    117118    // Since we already have the range we want, we just need to grab the returned options.
    118     wkExtractWordDefinitionTokenRangeFromContextualString(fullPlainTextString, rangeToPass, options);
    119    
     119    if (Class luLookupDefinitionModule = getLULookupDefinitionModuleClass())
     120        [luLookupDefinitionModule tokenRangeForString:fullPlainTextString range:rangeToPass options:options];
     121
    120122    return selectedRange.release();
    121123}
     
    156158    String fullPlainTextString = plainText(fullCharacterRange.get());
    157159
    158     NSRange extractedRange = wkExtractWordDefinitionTokenRangeFromContextualString(fullPlainTextString, rangeToPass, options);
     160    NSRange extractedRange = NSMakeRange(rangeToPass.location, 0);
     161    if (Class luLookupDefinitionModule = getLULookupDefinitionModuleClass())
     162        extractedRange = [luLookupDefinitionModule tokenRangeForString:fullPlainTextString range:rangeToPass options:options];
    159163
    160164    // This function sometimes returns {NSNotFound, 0} if it was unable to determine a good string.
  • branches/safari-600.3-branch/Source/WebCore/platform/mac/WebCoreSystemInterface.h

    r176249 r176281  
    289289extern bool (*wkExecutableWasLinkedOnOrBeforeSnowLeopard)(void);
    290290
    291 extern NSRange (*wkExtractWordDefinitionTokenRangeFromContextualString)(NSString *contextString, NSRange range, NSDictionary **options);
    292 
    293291extern CFStringRef (*wkCopyDefaultSearchProviderDisplayName)(void);
    294292
  • branches/safari-600.3-branch/Source/WebCore/platform/mac/WebCoreSystemInterface.mm

    r176249 r176281  
    147147bool (*wkExecutableWasLinkedOnOrBeforeSnowLeopard)(void);
    148148
    149 NSRange (*wkExtractWordDefinitionTokenRangeFromContextualString)(NSString *contextString, NSRange range, NSDictionary **options);
    150 
    151149CFStringRef (*wkCopyDefaultSearchProviderDisplayName)(void);
    152150void (*wkSetCrashReportApplicationSpecificInformation)(CFStringRef);
  • branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog

    r176249 r176281  
     12014-11-18  Dana Burkart  <dburkart@apple.com>
     2
     3        Merge r176164. rdar://problem/18953982
     4       
     5    2014-11-16  Tim Horton  <timothy_horton@apple.com>
     6
     7            Use TextIndicator instead of the built in Lookup highlight
     8            https://bugs.webkit.org/show_bug.cgi?id=138775
     9            <rdar://problem/18953982>
     10
     11            Reviewed by Anders Carlsson.
     12
     13            * WebCoreSupport/WebSystemInterface.mm:
     14            (InitWebCoreSystemInterface):
     15            Remove a WKSI import.
     16
     17            * WebView/WebActionMenuController.mm:
     18            (-[WebActionMenuController _lookupText:]):
     19            (-[WebActionMenuController _createActionMenuItemForTag:]):
     20            Make use of the new Lookup SPI header.
     21            Disable the Lookup item if lookup is not available.
     22
    1232014-11-17  Dana Burkart  <dburkart@apple.com>
    224
  • branches/safari-600.3-branch/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm

    r176249 r176281  
    164164    INIT(RecommendedScrollerStyle);
    165165    INIT(ExecutableWasLinkedOnOrBeforeSnowLeopard);
    166     INIT(ExtractWordDefinitionTokenRangeFromContextualString);
    167166    INIT(CopyDefaultSearchProviderDisplayName);
    168167    INIT(Cursor);
  • branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebActionMenuController.mm

    r176249 r176281  
    4949#import <WebCore/HTMLConverter.h>
    5050#import <WebCore/LocalizedStrings.h>
     51#import <WebCore/LookupSPI.h>
    5152#import <WebCore/NSSharingServicePickerSPI.h>
    5253#import <WebCore/NSSharingServiceSPI.h>
     
    565566    textBaselineOrigin = [_webView.window convertRectToScreen:NSMakeRect(textBaselineOrigin.x, textBaselineOrigin.y, 0, 0)].origin;
    566567
    567     WKShowWordDefinitionWindow(popupInfo.attributedString.get(), textBaselineOrigin, popupInfo.options.get());
     568    [getLULookupDefinitionModuleClass() showDefinitionForTerm:popupInfo.attributedString.get() atLocation:textBaselineOrigin options:popupInfo.options.get()];
    568569}
    569570
     
    691692    NSString *title = nil;
    692693    NSImage *image = nil;
     694    bool enabled = true;
    693695
    694696    switch (tag) {
     
    721723        title = WEB_UI_STRING_KEY("Look Up", "Look Up (action menu item)", "action menu item");
    722724        image = [NSImage imageNamed:@"NSActionMenuLookup"];
     725        enabled = getLULookupDefinitionModuleClass();
    723726        break;
    724727
     
    783786    [item setTarget:self];
    784787    [item setTag:tag];
     788    [item setEnabled:enabled];
    785789    return item;
    786790}
  • branches/safari-600.3-branch/Source/WebKit2/ChangeLog

    r176280 r176281  
     12014-11-18  Dana Burkart  <dburkart@apple.com>
     2
     3        Merge r176164. rdar://problem/18953982
     4
     5    2014-11-16  Tim Horton  <timothy_horton@apple.com>
     6
     7            Use TextIndicator instead of the built in Lookup highlight
     8            https://bugs.webkit.org/show_bug.cgi?id=138775
     9            <rdar://problem/18953982>
     10
     11            Reviewed by Anders Carlsson.
     12
     13            In order to make the yellow highlight for Lookup more accurately match the
     14            painted content of the web page (in light of e.g. Web fonts, and interesting
     15            text features that only WebKit implements and cannot round-trip through
     16            NSAttributedString), use a TextIndicator instead of the built-in Lookup
     17            highlight where possible.
     18
     19            * Configurations/BaseTarget.xcconfig:
     20            Make it possible to include headers from private frameworks. This matches WebCore.
     21
     22            * Shared/DictionaryPopupInfo.cpp:
     23            (WebKit::DictionaryPopupInfo::encode):
     24            (WebKit::DictionaryPopupInfo::decode):
     25            * Shared/DictionaryPopupInfo.h:
     26            Include the attributed string inside the DictionaryPopupInfo, instead of
     27            as a secondary argument to DidPerformDictionaryLookup.
     28            Add a TextIndicator to DictionaryPopupInfo, which can be used to highlight
     29            the text in the UI process.
     30
     31            * UIProcess/API/mac/WKView.mm:
     32            (-[WKView dealloc]):
     33            (-[WKView viewDidMoveToWindow]):
     34            (-[WKView _dictionaryLookupPopoverWillClose:]):
     35            (-[WKView _setTextIndicator:fadeOut:animate:animationCompletionHandler:]):
     36            (-[WKView _setTextIndicator:fadeOut:animate:]):
     37            (-[WKView initWithFrame:context:configuration:webView:]):
     38            (+[WKView hideWordDefinitionWindow]):
     39            * UIProcess/API/mac/WKViewInternal.h:
     40            Adopt the Lookup SPI header.
     41            If we have the requisite API, register the notification that Lookup sends
     42            when the popover closes, and hook that up to hide the text indicator.
     43            Add a version of _setTextIndicator: that takes an animation completion handler.
     44
     45            * UIProcess/PageClient.h:
     46            * UIProcess/WebPageProxy.h:
     47            * UIProcess/WebPageProxy.messages.in:
     48            * UIProcess/ios/WebPageProxyIOS.mm:
     49            (WebKit::WebPageProxy::didPerformDictionaryLookup):
     50            * UIProcess/mac/WebPageProxyMac.mm:
     51            (WebKit::WebPageProxy::didPerformDictionaryLookup):
     52            Adjust to the new didPerformDictionaryLookup signature.
     53
     54            * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
     55            (InitWebCoreSystemInterface):
     56            Remove a WKSI import.
     57
     58            * UIProcess/mac/PageClientImpl.h:
     59            * UIProcess/mac/PageClientImpl.mm:
     60            (WebKit::PageClientImpl::didPerformDictionaryLookup):
     61            If we have the requisite API, disable Lookup's built-in highlight and
     62            present a TextIndicator instead.
     63            We currently have to run the animations serially (first bounce the TextIndicator,
     64            then animate in the Lookup popover) because the act of adding the Lookup popover
     65            blocks us from getting any animation events for the TextIndicator, and breaks
     66            the bounce. We could also fix this by using a threaded animation for the TextIndicator,
     67            but it's not clear that it's safe to do so.
     68
     69            (WebKit::PageClientImpl::dismissDictionaryLookupPanel):
     70            When explicitly dismissing the Lookup panel, also hide the text indicator.
     71
     72            * UIProcess/mac/TextIndicatorWindow.h:
     73            * UIProcess/mac/TextIndicatorWindow.mm:
     74            (WebKit::TextIndicatorWindow::setTextIndicator):
     75            Store the completion handler.
     76
     77            (WebKit::TextIndicatorWindow::bounceAnimationDidEnd):
     78            Call the completion handler when the animation completes.
     79
     80            * UIProcess/mac/WKActionMenuController.mm:
     81            (-[WKActionMenuController _createActionMenuItemForTag:]):
     82            Disable the Lookup item if lookup is not available.
     83
     84            * WebProcess/Plugins/PDF/PDFPlugin.mm:
     85            (WebKit::PDFPlugin::showDefinitionForAttributedString):
     86            Adjust to the new didPerformDictionaryLookup signature.
     87            Since PDFPlugin can't trivially repaint the required part of the PDF,
     88            we don't build a TextIndicator. This will result in PDFPlugin continuing
     89            to use Lookup's built-in highlight.
     90           
     91            * WebProcess/WebPage/mac/WebPageMac.mm:
     92            (WebKit::WebPage::performDictionaryLookupForRange):
     93            Build a TextIndicator from the Lookup range and pass it along with
     94            the DictionaryPopupInfo.
     95
    1962014-11-18  Dana Burkart  <dburkart@apple.com>
    297
  • branches/safari-600.3-branch/Source/WebKit2/Configurations/BaseTarget.xcconfig

    r176249 r176281  
    3030HEADER_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR)/usr/local/include $(WEBCORE_PRIVATE_HEADERS_DIR)/ForwardingHeaders $(WEBCORE_PRIVATE_HEADERS_DIR)/icu $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2 $(HEADER_SEARCH_PATHS);
    3131
    32 OTHER_CFLAGS = $(inherited) -iframework $(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/ApplicationServices.framework/Frameworks -iframework $(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/Carbon.framework/Frameworks -iframework $(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/Quartz.framework/Frameworks -iframework $(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/CoreServices.framework/Frameworks;
     32OTHER_CFLAGS = $(inherited) -iframework $(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/ApplicationServices.framework/Frameworks -iframework $(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/Carbon.framework/Frameworks -iframework $(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/Quartz.framework/Frameworks -iframework $(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/CoreServices.framework/Frameworks -iframework $(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks;
    3333OTHER_CPLUSPLUSFLAGS = $(OTHER_CFLAGS);
    3434
  • branches/safari-600.3-branch/Source/WebKit2/Shared/DictionaryPopupInfo.cpp

    r176249 r176281  
    3838{
    3939    encoder << origin;
     40    encoder << textIndicator;
    4041
    4142#if PLATFORM(COCOA)
     
    4445    if (hadOptions)
    4546        IPC::encode(encoder, options.get());
     47
     48    encoder << attributedString;
    4649#endif
    4750}
     
    5154    if (!decoder.decode(result.origin))
    5255        return false;
     56
     57    if (!decoder.decode(result.textIndicator))
     58        return false;
     59
    5360#if PLATFORM(COCOA)
    5461    bool hadOptions;
     
    5966            return false;
    6067    }
     68
     69    if (!decoder.decode(result.attributedString))
     70        return false;
    6171#endif
    6272    return true;
  • branches/safari-600.3-branch/Source/WebKit2/Shared/DictionaryPopupInfo.h

    r176249 r176281  
    2727#define DictionaryPopupInfo_h
    2828
     29#include "TextIndicator.h"
    2930#include <WebCore/FloatPoint.h>
    3031
    3132#if PLATFORM(COCOA)
     33#include "AttributedString.h"
    3234#include <wtf/RetainPtr.h>
    3335#endif
    3436
    3537namespace IPC {
    36     class ArgumentDecoder;
    37     class ArgumentEncoder;
     38class ArgumentDecoder;
     39class ArgumentEncoder;
    3840}
    3941
     
    4547
    4648    WebCore::FloatPoint origin;
     49    TextIndicator::Data textIndicator;
    4750#if PLATFORM(COCOA)
    4851    RetainPtr<CFDictionaryRef> options;
     52    AttributedString attributedString;
    4953#endif
    5054};
  • branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm

    r176249 r176281  
    8989#import <WebCore/KeyboardEvent.h>
    9090#import <WebCore/LocalizedStrings.h>
     91#import <WebCore/LookupSPI.h>
    9192#import <WebCore/NSViewSPI.h>
    9293#import <WebCore/PlatformEventFactoryMac.h>
     
    325326
    326327    [[NSNotificationCenter defaultCenter] removeObserver:self name:NSApplicationWillTerminateNotification object:NSApp];
     328
     329    if (canDisableLookupIndicator())
     330        [[NSNotificationCenter defaultCenter] removeObserver:self name:getLUNotificationPopoverWillClose() object:nil];
    327331
    328332    WebContext::statistics().wkViewCount--;
     
    25542558        _data->_flagsChangedEventMonitor = nil;
    25552559
    2556         WKHideWordDefinitionWindow();
     2560        if (getLULookupDefinitionModuleClass())
     2561            [getLULookupDefinitionModuleClass() hideDefinition];
    25572562        [self _dismissActionMenuPopovers];
    25582563    }
     
    26882693{
    26892694    _data->_page->process().context().applicationWillTerminate();
     2695}
     2696
     2697- (void)_dictionaryLookupPopoverWillClose:(NSNotification *)notification
     2698{
     2699    [self _setTextIndicator:nil fadeOut:NO animate:NO];
    26902700}
    26912701
     
    30583068}
    30593069
    3060 - (void)_setTextIndicator:(PassRefPtr<TextIndicator>)textIndicator fadeOut:(BOOL)fadeOut animate:(BOOL)animate
     3070- (void)_setTextIndicator:(PassRefPtr<TextIndicator>)textIndicator fadeOut:(BOOL)fadeOut animate:(BOOL)animate animationCompletionHandler:(std::function<void ()>)completionHandler
    30613071{
    30623072    if (!textIndicator) {
     
    30683078        _data->_textIndicatorWindow = std::make_unique<TextIndicatorWindow>(self);
    30693079
    3070     _data->_textIndicatorWindow->setTextIndicator(textIndicator, fadeOut, animate);
     3080    _data->_textIndicatorWindow->setTextIndicator(textIndicator, fadeOut, animate, WTF::move(completionHandler));
     3081}
     3082
     3083- (void)_setTextIndicator:(PassRefPtr<TextIndicator>)textIndicator fadeOut:(BOOL)fadeOut animate:(BOOL)animate
     3084{
     3085    [self _setTextIndicator:textIndicator fadeOut:fadeOut animate:animate animationCompletionHandler:[] {}];
    30713086}
    30723087
     
    35603575    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:NSApp];
    35613576
     3577    if (canDisableLookupIndicator())
     3578        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_dictionaryLookupPopoverWillClose:) name:getLUNotificationPopoverWillClose() object:nil];
     3579
    35623580#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
    35633581    if ([self respondsToSelector:@selector(setActionMenu:)]) {
     
    38023820+ (void)hideWordDefinitionWindow
    38033821{
    3804     WKHideWordDefinitionWindow();
     3822    if (!getLULookupDefinitionModuleClass())
     3823        return;
     3824    [getLULookupDefinitionModuleClass() hideDefinition];
    38053825}
    38063826
  • branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h

    r176249 r176281  
    8282- (NSRect)_convertToUserSpace:(NSRect)rect;
    8383- (void)_setTextIndicator:(PassRefPtr<WebKit::TextIndicator>)textIndicator fadeOut:(BOOL)fadeOut animate:(BOOL)animate;
     84- (void)_setTextIndicator:(PassRefPtr<WebKit::TextIndicator>)textIndicator fadeOut:(BOOL)fadeOut animate:(BOOL)animate animationCompletionHandler:(std::function<void ()>)completionHandler;
    8485
    8586- (void)_setAcceleratedCompositingModeRootLayer:(CALayer *)rootLayer;
  • branches/safari-600.3-branch/Source/WebKit2/UIProcess/PageClient.h

    r176249 r176281  
    224224    virtual void pluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus) = 0;
    225225    virtual void setPluginComplexTextInputState(uint64_t pluginComplexTextInputIdentifier, PluginComplexTextInputState) = 0;
    226     virtual void didPerformDictionaryLookup(const AttributedString&, const DictionaryPopupInfo&) = 0;
     226    virtual void didPerformDictionaryLookup(const DictionaryPopupInfo&) = 0;
    227227    virtual void dismissDictionaryLookupPanel() = 0;
    228228    virtual void dismissActionMenuPopovers() = 0;
  • branches/safari-600.3-branch/Source/WebKit2/UIProcess/WebPageProxy.h

    r176249 r176281  
    11491149
    11501150    // Dictionary.
    1151     void didPerformDictionaryLookup(const AttributedString&, const DictionaryPopupInfo&);
     1151    void didPerformDictionaryLookup(const DictionaryPopupInfo&);
    11521152#endif
    11531153
  • branches/safari-600.3-branch/Source/WebKit2/UIProcess/WebPageProxy.messages.in

    r176249 r176281  
    288288#if PLATFORM(COCOA)
    289289    # Dictionary support.
    290     DidPerformDictionaryLookup(WebKit::AttributedString text, WebKit::DictionaryPopupInfo dictionaryPopupInfo)
     290    DidPerformDictionaryLookup(WebKit::DictionaryPopupInfo dictionaryPopupInfo)
    291291
    292292    # Keyboard input support messages
  • branches/safari-600.3-branch/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm

    r176249 r176281  
    751751}
    752752
    753 void WebPageProxy::didPerformDictionaryLookup(const AttributedString&, const DictionaryPopupInfo&)
     753void WebPageProxy::didPerformDictionaryLookup(const DictionaryPopupInfo&)
    754754{
    755755    notImplemented();
  • branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.h

    r176249 r176281  
    137137    virtual void makeFirstResponder();
    138138   
    139     virtual void didPerformDictionaryLookup(const AttributedString&, const DictionaryPopupInfo&);
     139    virtual void didPerformDictionaryLookup(const DictionaryPopupInfo&);
    140140    virtual void dismissDictionaryLookupPanel();
    141141    virtual void dismissActionMenuPopovers();
  • branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.mm

    r176249 r176281  
    5959#import <WebCore/Image.h>
    6060#import <WebCore/KeyboardEvent.h>
     61#import <WebCore/LookupSPI.h>
    6162#import <WebCore/NotImplemented.h>
    6263#import <WebCore/SharedBuffer.h>
     
    530531}
    531532
    532 void PageClientImpl::didPerformDictionaryLookup(const AttributedString& text, const DictionaryPopupInfo& dictionaryPopupInfo)
    533 {
    534     RetainPtr<NSAttributedString> attributedString = text.string;
     533void PageClientImpl::didPerformDictionaryLookup(const DictionaryPopupInfo& dictionaryPopupInfo)
     534{
     535    if (!getLULookupDefinitionModuleClass())
     536        return;
     537
    535538    NSPoint textBaselineOrigin = dictionaryPopupInfo.origin;
    536539
     
    539542    textBaselineOrigin = [m_wkView.window convertRectToScreen:NSMakeRect(textBaselineOrigin.x, textBaselineOrigin.y, 0, 0)].origin;
    540543
    541     WKShowWordDefinitionWindow(attributedString.get(), textBaselineOrigin, (NSDictionary *)dictionaryPopupInfo.options.get());
     544    RetainPtr<NSMutableDictionary> mutableOptions = adoptNS([(NSDictionary *)dictionaryPopupInfo.options.get() mutableCopy]);
     545
     546    if (canDisableLookupIndicator() && dictionaryPopupInfo.textIndicator.contentImage) {
     547        // Run the animations serially because attaching another subwindow breaks the bounce animation.
     548        // We could consider making the bounce NSAnimationNonblockingThreaded instead, which seems
     549        // to work, but need to consider all of the implications.
     550        [m_wkView _setTextIndicator:TextIndicator::create(dictionaryPopupInfo.textIndicator) fadeOut:NO animate:YES animationCompletionHandler:[dictionaryPopupInfo, textBaselineOrigin, mutableOptions] {
     551            [mutableOptions setObject:@YES forKey:getLUTermOptionDisableSearchTermIndicator()];
     552            [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.string.get() atLocation:textBaselineOrigin options:mutableOptions.get()];
     553        }];
     554    } else
     555        [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.string.get() atLocation:textBaselineOrigin options:mutableOptions.get()];
    542556}
    543557
    544558void PageClientImpl::dismissDictionaryLookupPanel()
    545559{
     560    if (!getLULookupDefinitionModuleClass())
     561        return;
     562
    546563    // FIXME: We don't know which panel we are dismissing, it may not even be in the current page (see <rdar://problem/13875766>).
    547     WKHideWordDefinitionWindow();
     564    [getLULookupDefinitionModuleClass() hideDefinition];
     565    setTextIndicator(nil, false, true);
    548566}
    549567
  • branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/TextIndicatorWindow.h

    r176249 r176281  
    3030
    3131#import "WebKitSystemInterface.h"
     32#import <functional>
    3233#import <wtf/Noncopyable.h>
    3334#import <wtf/RefPtr.h>
     
    4950    ~TextIndicatorWindow();
    5051
    51     void setTextIndicator(PassRefPtr<TextIndicator>, bool fadeOut, bool animate);
     52    void setTextIndicator(PassRefPtr<TextIndicator>, bool fadeOut, bool animate, std::function<void ()> animationCompletionHandler);
    5253
    5354private:
     
    7172    RunLoop::Timer<TextIndicatorWindow> m_startFadeOutTimer;
    7273    RetainPtr<WKTextIndicatorWindowAnimation> m_fadeOutAnimation;
     74
     75    std::function<void ()> m_bounceAnimationCompletionHandler;
    7376};
    7477
  • branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/TextIndicatorWindow.mm

    r176249 r176281  
    121121}
    122122
    123 void TextIndicatorWindow::setTextIndicator(PassRefPtr<TextIndicator> textIndicator, bool fadeOut, bool animate)
     123void TextIndicatorWindow::setTextIndicator(PassRefPtr<TextIndicator> textIndicator, bool fadeOut, bool animate, std::function<void ()> animationCompletionHandler)
    124124{
    125125    if (m_textIndicator == textIndicator)
     
    155155
    156156    if (animate) {
     157        m_bounceAnimationCompletionHandler = WTF::move(animationCompletionHandler);
    157158        // Start the bounce animation.
    158159        m_bounceAnimationContext = WKWindowBounceAnimationContextCreate(m_textIndicatorWindow.get());
     
    231232    WKWindowBounceAnimationContextDestroy(m_bounceAnimationContext);
    232233    m_bounceAnimationContext = 0;
     234    m_bounceAnimationCompletionHandler();
    233235}
    234236
  • branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm

    r176249 r176281  
    4646#import <WebCore/GeometryUtilities.h>
    4747#import <WebCore/LocalizedStrings.h>
     48#import <WebCore/LookupSPI.h>
    4849#import <WebCore/NSSharingServiceSPI.h>
    4950#import <WebCore/NSSharingServicePickerSPI.h>
     
    757758    NSString *title = nil;
    758759    NSImage *image = nil;
     760    bool enabled = true;
    759761
    760762    switch (tag) {
     
    812814        title = WEB_UI_STRING_KEY("Look Up", "Look Up (action menu item)", "action menu item");
    813815        image = [NSImage imageNamed:@"NSActionMenuLookup"];
     816        enabled = getLULookupDefinitionModuleClass();
    814817        break;
    815818
     
    851854    [item setTarget:self];
    852855    [item setTag:tag];
     856    [item setEnabled:enabled];
    853857    return item;
    854858}
  • branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm

    r176249 r176281  
    451451}
    452452
    453 void WebPageProxy::didPerformDictionaryLookup(const AttributedString& text, const DictionaryPopupInfo& dictionaryPopupInfo)
    454 {
    455     m_pageClient.didPerformDictionaryLookup(text, dictionaryPopupInfo);
     453void WebPageProxy::didPerformDictionaryLookup(const DictionaryPopupInfo& dictionaryPopupInfo)
     454{
     455    m_pageClient.didPerformDictionaryLookup(dictionaryPopupInfo);
    456456}
    457457   
  • branches/safari-600.3-branch/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm

    r176249 r176281  
    17011701    DictionaryPopupInfo dictionaryPopupInfo;
    17021702    dictionaryPopupInfo.origin = convertFromPDFViewToRootView(IntPoint(point));
    1703 
    1704     AttributedString attributedString;
    1705     attributedString.string = string;
    1706 
    1707     webFrame()->page()->send(Messages::WebPageProxy::DidPerformDictionaryLookup(attributedString, dictionaryPopupInfo));
     1703    dictionaryPopupInfo.attributedString.string = string;
     1704
     1705    webFrame()->page()->send(Messages::WebPageProxy::DidPerformDictionaryLookup(dictionaryPopupInfo));
    17081706}
    17091707
  • branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm

    r176249 r176281  
    154154        INIT(RecommendedScrollerStyle);
    155155        INIT(ExecutableWasLinkedOnOrBeforeSnowLeopard);
    156         INIT(ExtractWordDefinitionTokenRangeFromContextualString);
    157156        INIT(CopyDefaultSearchProviderDisplayName);
    158157        INIT(Cursor);
  • branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm

    r176249 r176281  
    544544    }];
    545545
    546     AttributedString attributedString;
    547     attributedString.string = scaledNSAttributedString;
    548 
    549     send(Messages::WebPageProxy::DidPerformDictionaryLookup(attributedString, dictionaryPopupInfo));
     546    RefPtr<TextIndicator> textIndicator = TextIndicator::createWithRange(range);
     547    if (!textIndicator)
     548        return;
     549
     550    dictionaryPopupInfo.textIndicator = textIndicator->data();
     551    dictionaryPopupInfo.attributedString.string = scaledNSAttributedString;
     552
     553    send(Messages::WebPageProxy::DidPerformDictionaryLookup(dictionaryPopupInfo));
    550554}
    551555
Note: See TracChangeset for help on using the changeset viewer.