Changeset 176164 in webkit
- Timestamp:
- Nov 16, 2014, 12:41:27 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 1 added
- 28 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/WebCore.exp.in (modified) (1 diff)
-
WebCore/WebCore.xcodeproj/project.pbxproj (modified) (4 diffs)
-
WebCore/editing/mac/DictionaryLookup.mm (modified) (3 diffs)
-
WebCore/platform/mac/WebCoreSystemInterface.h (modified) (1 diff)
-
WebCore/platform/mac/WebCoreSystemInterface.mm (modified) (1 diff)
-
WebCore/platform/spi/mac/LookupSPI.h (added)
-
WebKit/mac/ChangeLog (modified) (1 diff)
-
WebKit/mac/WebCoreSupport/WebSystemInterface.mm (modified) (1 diff)
-
WebKit/mac/WebView/WebActionMenuController.mm (modified) (5 diffs)
-
WebKit2/ChangeLog (modified) (1 diff)
-
WebKit2/Configurations/BaseTarget.xcconfig (modified) (1 diff)
-
WebKit2/Shared/DictionaryPopupInfo.cpp (modified) (4 diffs)
-
WebKit2/Shared/DictionaryPopupInfo.h (modified) (2 diffs)
-
WebKit2/UIProcess/API/mac/WKView.mm (modified) (8 diffs)
-
WebKit2/UIProcess/API/mac/WKViewInternal.h (modified) (1 diff)
-
WebKit2/UIProcess/PageClient.h (modified) (1 diff)
-
WebKit2/UIProcess/WebPageProxy.h (modified) (1 diff)
-
WebKit2/UIProcess/WebPageProxy.messages.in (modified) (1 diff)
-
WebKit2/UIProcess/ios/WebPageProxyIOS.mm (modified) (1 diff)
-
WebKit2/UIProcess/mac/PageClientImpl.h (modified) (1 diff)
-
WebKit2/UIProcess/mac/PageClientImpl.mm (modified) (3 diffs)
-
WebKit2/UIProcess/mac/TextIndicatorWindow.h (modified) (3 diffs)
-
WebKit2/UIProcess/mac/TextIndicatorWindow.mm (modified) (3 diffs)
-
WebKit2/UIProcess/mac/WKActionMenuController.mm (modified) (4 diffs)
-
WebKit2/UIProcess/mac/WebPageProxyMac.mm (modified) (1 diff)
-
WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm (modified) (1 diff)
-
WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm (modified) (1 diff)
-
WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r176163 r176164 1 2014-11-16 Tim Horton <timothy_horton@apple.com> 2 3 Use TextIndicator instead of the built in Lookup highlight 4 https://bugs.webkit.org/show_bug.cgi?id=138775 5 <rdar://problem/18953982> 6 7 Reviewed by Anders Carlsson. 8 9 * WebCore.exp.in: 10 * platform/mac/WebCoreSystemInterface.h: 11 * platform/mac/WebCoreSystemInterface.mm: 12 Remove a WKSI import/export that we don't need anymore. 13 14 * platform/spi/mac/LookupSPI.h: Added. 15 (WebCore::canDisableLookupIndicator): 16 Add Lookup SPI header. 17 Add a 'canDisableLookupIndicator', which must be called in any translation 18 unit that wants to use either of the soft-linked constants related to 19 that functionality, before calling the get* function. 20 21 * WebCore.xcodeproj/project.pbxproj: 22 * editing/mac/DictionaryLookup.mm: 23 (WebCore::rangeForDictionaryLookupForSelection): 24 (WebCore::rangeForDictionaryLookupAtHitTestResult): 25 Adopt the Lookup SPI header. 26 1 27 2014-11-16 Joanmarie Diggs <jdiggs@igalia.com> 2 28 -
trunk/Source/WebCore/WebCore.exp.in
r176156 r176164 2442 2442 _wkDrawMediaUIPart 2443 2443 _wkExecutableWasLinkedOnOrBeforeSnowLeopard 2444 _wkExtractWordDefinitionTokenRangeFromContextualString2445 2444 _wkGetAXTextMarkerRangeTypeID 2446 2445 _wkGetAXTextMarkerTypeID -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r176157 r176164 1097 1097 2D3EF44A1917915C00034184 /* WebCoreCALayerExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D3EF4461917915C00034184 /* WebCoreCALayerExtras.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1098 1098 2D3EF44B1917915C00034184 /* WebCoreCALayerExtras.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D3EF4471917915C00034184 /* WebCoreCALayerExtras.mm */; }; 1099 2D413F611A187A3F0041A521 /* LookupSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D413F601A187A3F0041A521 /* LookupSPI.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1099 1100 2D46F04E17B96FBD005647F0 /* IntPoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D46F04D17B96FBD005647F0 /* IntPoint.cpp */; }; 1100 1101 2D46F05017B96FD2005647F0 /* IntSize.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D46F04F17B96FD2005647F0 /* IntSize.cpp */; }; … … 8107 8108 2D3EF4461917915C00034184 /* WebCoreCALayerExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreCALayerExtras.h; sourceTree = "<group>"; }; 8108 8109 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>"; }; 8109 8111 2D46F04D17B96FBD005647F0 /* IntPoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IntPoint.cpp; sourceTree = "<group>"; }; 8110 8112 2D46F04F17B96FD2005647F0 /* IntSize.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IntSize.cpp; sourceTree = "<group>"; }; … … 17545 17547 children = ( 17546 17548 2D59F1BE1A0044C6001F3D29 /* DataDetectorsSPI.h */, 17549 2D413F601A187A3F0041A521 /* LookupSPI.h */, 17547 17550 1C6466271A12C3F90094603C /* NSFontSPI.h */, 17548 17551 2DCB837719F99BBA00A7FBE4 /* NSSharingServicePickerSPI.h */, … … 23562 23565 A584FE2C1863870F00843B10 /* CommandLineAPIModule.h in Headers */, 23563 23566 A584FE2618637DAB00843B10 /* CommandLineAPIModuleSource.h in Headers */, 23567 2D413F611A187A3F0041A521 /* LookupSPI.h in Headers */, 23564 23568 6550B6A2099DF0270090D781 /* Comment.h in Headers */, 23565 23569 E1FE137518402A6700892F13 /* CommonCryptoUtilities.h in Headers */, -
trunk/Source/WebCore/editing/mac/DictionaryLookup.mm
r176137 r176164 35 35 #import "HTMLConverter.h" 36 36 #import "HitTestResult.h" 37 #import "LookupSPI.h" 37 38 #import "Page.h" 38 39 #import "Range.h" … … 116 117 117 118 // 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 120 122 return selectedRange.release(); 121 123 } … … 156 158 String fullPlainTextString = plainText(fullCharacterRange.get()); 157 159 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]; 159 163 160 164 // This function sometimes returns {NSNotFound, 0} if it was unable to determine a good string. -
trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.h
r176112 r176164 239 239 extern bool (*wkExecutableWasLinkedOnOrBeforeSnowLeopard)(void); 240 240 241 extern NSRange (*wkExtractWordDefinitionTokenRangeFromContextualString)(NSString *contextString, NSRange range, NSDictionary **options);242 243 241 extern CFStringRef (*wkCopyDefaultSearchProviderDisplayName)(void); 244 242 -
trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.mm
r176112 r176164 111 111 bool (*wkExecutableWasLinkedOnOrBeforeSnowLeopard)(void); 112 112 113 NSRange (*wkExtractWordDefinitionTokenRangeFromContextualString)(NSString *contextString, NSRange range, NSDictionary **options);114 115 113 CFStringRef (*wkCopyDefaultSearchProviderDisplayName)(void); 116 114 -
trunk/Source/WebKit/mac/ChangeLog
r176153 r176164 1 2014-11-16 Tim Horton <timothy_horton@apple.com> 2 3 Use TextIndicator instead of the built in Lookup highlight 4 https://bugs.webkit.org/show_bug.cgi?id=138775 5 <rdar://problem/18953982> 6 7 Reviewed by Anders Carlsson. 8 9 * WebCoreSupport/WebSystemInterface.mm: 10 (InitWebCoreSystemInterface): 11 Remove a WKSI import. 12 13 * WebView/WebActionMenuController.mm: 14 (-[WebActionMenuController _lookupText:]): 15 (-[WebActionMenuController _createActionMenuItemForTag:]): 16 Make use of the new Lookup SPI header. 17 Disable the Lookup item if lookup is not available. 18 1 19 2014-11-15 Tim Horton <timothy_horton@apple.com> 2 20 -
trunk/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm
r176112 r176164 136 136 INIT(RecommendedScrollerStyle); 137 137 INIT(ExecutableWasLinkedOnOrBeforeSnowLeopard); 138 INIT(ExtractWordDefinitionTokenRangeFromContextualString);139 138 INIT(CopyDefaultSearchProviderDisplayName); 140 139 INIT(Cursor); -
trunk/Source/WebKit/mac/WebView/WebActionMenuController.mm
r176153 r176164 48 48 #import <WebCore/FrameView.h> 49 49 #import <WebCore/HTMLConverter.h> 50 #import <WebCore/LookupSPI.h> 50 51 #import <WebCore/NSSharingServicePickerSPI.h> 51 52 #import <WebCore/NSSharingServiceSPI.h> … … 564 565 textBaselineOrigin = [_webView.window convertRectToScreen:NSMakeRect(textBaselineOrigin.x, textBaselineOrigin.y, 0, 0)].origin; 565 566 566 WKShowWordDefinitionWindow(popupInfo.attributedString.get(), textBaselineOrigin, popupInfo.options.get());567 [getLULookupDefinitionModuleClass() showDefinitionForTerm:popupInfo.attributedString.get() atLocation:textBaselineOrigin options:popupInfo.options.get()]; 567 568 } 568 569 … … 690 691 NSString *title = nil; 691 692 NSImage *image = nil; 693 bool enabled = true; 692 694 693 695 switch (tag) { … … 720 722 title = WEB_UI_STRING_KEY("Look Up", "Look Up (action menu item)", "action menu item"); 721 723 image = [NSImage imageNamed:@"NSActionMenuLookup"]; 724 enabled = getLULookupDefinitionModuleClass(); 722 725 break; 723 726 … … 782 785 [item setTarget:self]; 783 786 [item setTag:tag]; 787 [item setEnabled:enabled]; 784 788 return item; 785 789 } -
trunk/Source/WebKit2/ChangeLog
r176156 r176164 1 2014-11-16 Tim Horton <timothy_horton@apple.com> 2 3 Use TextIndicator instead of the built in Lookup highlight 4 https://bugs.webkit.org/show_bug.cgi?id=138775 5 <rdar://problem/18953982> 6 7 Reviewed by Anders Carlsson. 8 9 In order to make the yellow highlight for Lookup more accurately match the 10 painted content of the web page (in light of e.g. Web fonts, and interesting 11 text features that only WebKit implements and cannot round-trip through 12 NSAttributedString), use a TextIndicator instead of the built-in Lookup 13 highlight where possible. 14 15 * Configurations/BaseTarget.xcconfig: 16 Make it possible to include headers from private frameworks. This matches WebCore. 17 18 * Shared/DictionaryPopupInfo.cpp: 19 (WebKit::DictionaryPopupInfo::encode): 20 (WebKit::DictionaryPopupInfo::decode): 21 * Shared/DictionaryPopupInfo.h: 22 Include the attributed string inside the DictionaryPopupInfo, instead of 23 as a secondary argument to DidPerformDictionaryLookup. 24 Add a TextIndicator to DictionaryPopupInfo, which can be used to highlight 25 the text in the UI process. 26 27 * UIProcess/API/mac/WKView.mm: 28 (-[WKView dealloc]): 29 (-[WKView viewDidMoveToWindow]): 30 (-[WKView _dictionaryLookupPopoverWillClose:]): 31 (-[WKView _setTextIndicator:fadeOut:animate:animationCompletionHandler:]): 32 (-[WKView _setTextIndicator:fadeOut:animate:]): 33 (-[WKView initWithFrame:context:configuration:webView:]): 34 (+[WKView hideWordDefinitionWindow]): 35 * UIProcess/API/mac/WKViewInternal.h: 36 Adopt the Lookup SPI header. 37 If we have the requisite API, register the notification that Lookup sends 38 when the popover closes, and hook that up to hide the text indicator. 39 Add a version of _setTextIndicator: that takes an animation completion handler. 40 41 * UIProcess/PageClient.h: 42 * UIProcess/WebPageProxy.h: 43 * UIProcess/WebPageProxy.messages.in: 44 * UIProcess/ios/WebPageProxyIOS.mm: 45 (WebKit::WebPageProxy::didPerformDictionaryLookup): 46 * UIProcess/mac/WebPageProxyMac.mm: 47 (WebKit::WebPageProxy::didPerformDictionaryLookup): 48 Adjust to the new didPerformDictionaryLookup signature. 49 50 * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm: 51 (InitWebCoreSystemInterface): 52 Remove a WKSI import. 53 54 * UIProcess/mac/PageClientImpl.h: 55 * UIProcess/mac/PageClientImpl.mm: 56 (WebKit::PageClientImpl::didPerformDictionaryLookup): 57 If we have the requisite API, disable Lookup's built-in highlight and 58 present a TextIndicator instead. 59 We currently have to run the animations serially (first bounce the TextIndicator, 60 then animate in the Lookup popover) because the act of adding the Lookup popover 61 blocks us from getting any animation events for the TextIndicator, and breaks 62 the bounce. We could also fix this by using a threaded animation for the TextIndicator, 63 but it's not clear that it's safe to do so. 64 65 (WebKit::PageClientImpl::dismissDictionaryLookupPanel): 66 When explicitly dismissing the Lookup panel, also hide the text indicator. 67 68 * UIProcess/mac/TextIndicatorWindow.h: 69 * UIProcess/mac/TextIndicatorWindow.mm: 70 (WebKit::TextIndicatorWindow::setTextIndicator): 71 Store the completion handler. 72 73 (WebKit::TextIndicatorWindow::bounceAnimationDidEnd): 74 Call the completion handler when the animation completes. 75 76 * UIProcess/mac/WKActionMenuController.mm: 77 (-[WKActionMenuController _createActionMenuItemForTag:]): 78 Disable the Lookup item if lookup is not available. 79 80 * WebProcess/Plugins/PDF/PDFPlugin.mm: 81 (WebKit::PDFPlugin::showDefinitionForAttributedString): 82 Adjust to the new didPerformDictionaryLookup signature. 83 Since PDFPlugin can't trivially repaint the required part of the PDF, 84 we don't build a TextIndicator. This will result in PDFPlugin continuing 85 to use Lookup's built-in highlight. 86 87 * WebProcess/WebPage/mac/WebPageMac.mm: 88 (WebKit::WebPage::performDictionaryLookupForRange): 89 Build a TextIndicator from the Lookup range and pass it along with 90 the DictionaryPopupInfo. 91 1 92 2014-11-15 David Kilzer <ddkilzer@apple.com> 2 93 -
trunk/Source/WebKit2/Configurations/BaseTarget.xcconfig
r168550 r176164 30 30 HEADER_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); 31 31 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 ;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 -iframework $(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks; 33 33 OTHER_CPLUSPLUSFLAGS = $(OTHER_CFLAGS); 34 34 -
trunk/Source/WebKit2/Shared/DictionaryPopupInfo.cpp
r163886 r176164 38 38 { 39 39 encoder << origin; 40 encoder << textIndicator; 40 41 41 42 #if PLATFORM(COCOA) … … 44 45 if (hadOptions) 45 46 IPC::encode(encoder, options.get()); 47 48 encoder << attributedString; 46 49 #endif 47 50 } … … 51 54 if (!decoder.decode(result.origin)) 52 55 return false; 56 57 if (!decoder.decode(result.textIndicator)) 58 return false; 59 53 60 #if PLATFORM(COCOA) 54 61 bool hadOptions; … … 59 66 return false; 60 67 } 68 69 if (!decoder.decode(result.attributedString)) 70 return false; 61 71 #endif 62 72 return true; -
trunk/Source/WebKit2/Shared/DictionaryPopupInfo.h
r163886 r176164 27 27 #define DictionaryPopupInfo_h 28 28 29 #include "TextIndicator.h" 29 30 #include <WebCore/FloatPoint.h> 30 31 31 32 #if PLATFORM(COCOA) 33 #include "AttributedString.h" 32 34 #include <wtf/RetainPtr.h> 33 35 #endif 34 36 35 37 namespace IPC { 36 class ArgumentDecoder;37 class ArgumentEncoder;38 class ArgumentDecoder; 39 class ArgumentEncoder; 38 40 } 39 41 … … 45 47 46 48 WebCore::FloatPoint origin; 49 TextIndicator::Data textIndicator; 47 50 #if PLATFORM(COCOA) 48 51 RetainPtr<CFDictionaryRef> options; 52 AttributedString attributedString; 49 53 #endif 50 54 }; -
trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm
r175985 r176164 89 89 #import <WebCore/KeyboardEvent.h> 90 90 #import <WebCore/LocalizedStrings.h> 91 #import <WebCore/LookupSPI.h> 91 92 #import <WebCore/NSViewSPI.h> 92 93 #import <WebCore/PlatformEventFactoryMac.h> … … 325 326 326 327 [[NSNotificationCenter defaultCenter] removeObserver:self name:NSApplicationWillTerminateNotification object:NSApp]; 328 329 if (canDisableLookupIndicator()) 330 [[NSNotificationCenter defaultCenter] removeObserver:self name:getLUNotificationPopoverWillClose() object:nil]; 327 331 328 332 WebContext::statistics().wkViewCount--; … … 2554 2558 _data->_flagsChangedEventMonitor = nil; 2555 2559 2556 WKHideWordDefinitionWindow(); 2560 if (getLULookupDefinitionModuleClass()) 2561 [getLULookupDefinitionModuleClass() hideDefinition]; 2557 2562 [self _dismissActionMenuPopovers]; 2558 2563 } … … 2688 2693 { 2689 2694 _data->_page->process().context().applicationWillTerminate(); 2695 } 2696 2697 - (void)_dictionaryLookupPopoverWillClose:(NSNotification *)notification 2698 { 2699 [self _setTextIndicator:nil fadeOut:NO animate:NO]; 2690 2700 } 2691 2701 … … 3058 3068 } 3059 3069 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 3061 3071 { 3062 3072 if (!textIndicator) { … … 3068 3078 _data->_textIndicatorWindow = std::make_unique<TextIndicatorWindow>(self); 3069 3079 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:[] {}]; 3071 3086 } 3072 3087 … … 3560 3575 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:NSApp]; 3561 3576 3577 if (canDisableLookupIndicator()) 3578 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_dictionaryLookupPopoverWillClose:) name:getLUNotificationPopoverWillClose() object:nil]; 3579 3562 3580 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000 3563 3581 if ([self respondsToSelector:@selector(setActionMenu:)]) { … … 3807 3825 + (void)hideWordDefinitionWindow 3808 3826 { 3809 WKHideWordDefinitionWindow(); 3827 if (!getLULookupDefinitionModuleClass()) 3828 return; 3829 [getLULookupDefinitionModuleClass() hideDefinition]; 3810 3830 } 3811 3831 -
trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h
r175973 r176164 82 82 - (NSRect)_convertToUserSpace:(NSRect)rect; 83 83 - (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; 84 85 85 86 - (void)_setAcceleratedCompositingModeRootLayer:(CALayer *)rootLayer; -
trunk/Source/WebKit2/UIProcess/PageClient.h
r175966 r176164 224 224 virtual void pluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus) = 0; 225 225 virtual void setPluginComplexTextInputState(uint64_t pluginComplexTextInputIdentifier, PluginComplexTextInputState) = 0; 226 virtual void didPerformDictionaryLookup(const AttributedString&, constDictionaryPopupInfo&) = 0;226 virtual void didPerformDictionaryLookup(const DictionaryPopupInfo&) = 0; 227 227 virtual void dismissDictionaryLookupPanel() = 0; 228 228 virtual void dismissActionMenuPopovers() = 0; -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r176136 r176164 1175 1175 1176 1176 // Dictionary. 1177 void didPerformDictionaryLookup(const AttributedString&, constDictionaryPopupInfo&);1177 void didPerformDictionaryLookup(const DictionaryPopupInfo&); 1178 1178 #endif 1179 1179 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in
r176136 r176164 298 298 #if PLATFORM(COCOA) 299 299 # Dictionary support. 300 DidPerformDictionaryLookup(WebKit:: AttributedString text, WebKit::DictionaryPopupInfo dictionaryPopupInfo)300 DidPerformDictionaryLookup(WebKit::DictionaryPopupInfo dictionaryPopupInfo) 301 301 302 302 # Keyboard input support messages -
trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm
r176097 r176164 770 770 } 771 771 772 void WebPageProxy::didPerformDictionaryLookup(const AttributedString&, constDictionaryPopupInfo&)772 void WebPageProxy::didPerformDictionaryLookup(const DictionaryPopupInfo&) 773 773 { 774 774 notImplemented(); -
trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h
r175966 r176164 137 137 virtual void makeFirstResponder(); 138 138 139 virtual void didPerformDictionaryLookup(const AttributedString&, constDictionaryPopupInfo&);139 virtual void didPerformDictionaryLookup(const DictionaryPopupInfo&); 140 140 virtual void dismissDictionaryLookupPanel(); 141 141 virtual void dismissActionMenuPopovers(); -
trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm
r175973 r176164 59 59 #import <WebCore/Image.h> 60 60 #import <WebCore/KeyboardEvent.h> 61 #import <WebCore/LookupSPI.h> 61 62 #import <WebCore/NotImplemented.h> 62 63 #import <WebCore/SharedBuffer.h> … … 530 531 } 531 532 532 void PageClientImpl::didPerformDictionaryLookup(const AttributedString& text, const DictionaryPopupInfo& dictionaryPopupInfo) 533 { 534 RetainPtr<NSAttributedString> attributedString = text.string; 533 void PageClientImpl::didPerformDictionaryLookup(const DictionaryPopupInfo& dictionaryPopupInfo) 534 { 535 if (!getLULookupDefinitionModuleClass()) 536 return; 537 535 538 NSPoint textBaselineOrigin = dictionaryPopupInfo.origin; 536 539 … … 539 542 textBaselineOrigin = [m_wkView.window convertRectToScreen:NSMakeRect(textBaselineOrigin.x, textBaselineOrigin.y, 0, 0)].origin; 540 543 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()]; 542 556 } 543 557 544 558 void PageClientImpl::dismissDictionaryLookupPanel() 545 559 { 560 if (!getLULookupDefinitionModuleClass()) 561 return; 562 546 563 // 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); 548 566 } 549 567 -
trunk/Source/WebKit2/UIProcess/mac/TextIndicatorWindow.h
r175476 r176164 30 30 31 31 #import "WebKitSystemInterface.h" 32 #import <functional> 32 33 #import <wtf/Noncopyable.h> 33 34 #import <wtf/RefPtr.h> … … 49 50 ~TextIndicatorWindow(); 50 51 51 void setTextIndicator(PassRefPtr<TextIndicator>, bool fadeOut, bool animate );52 void setTextIndicator(PassRefPtr<TextIndicator>, bool fadeOut, bool animate, std::function<void ()> animationCompletionHandler); 52 53 53 54 private: … … 71 72 RunLoop::Timer<TextIndicatorWindow> m_startFadeOutTimer; 72 73 RetainPtr<WKTextIndicatorWindowAnimation> m_fadeOutAnimation; 74 75 std::function<void ()> m_bounceAnimationCompletionHandler; 73 76 }; 74 77 -
trunk/Source/WebKit2/UIProcess/mac/TextIndicatorWindow.mm
r175476 r176164 121 121 } 122 122 123 void TextIndicatorWindow::setTextIndicator(PassRefPtr<TextIndicator> textIndicator, bool fadeOut, bool animate )123 void TextIndicatorWindow::setTextIndicator(PassRefPtr<TextIndicator> textIndicator, bool fadeOut, bool animate, std::function<void ()> animationCompletionHandler) 124 124 { 125 125 if (m_textIndicator == textIndicator) … … 155 155 156 156 if (animate) { 157 m_bounceAnimationCompletionHandler = WTF::move(animationCompletionHandler); 157 158 // Start the bounce animation. 158 159 m_bounceAnimationContext = WKWindowBounceAnimationContextCreate(m_textIndicatorWindow.get()); … … 231 232 WKWindowBounceAnimationContextDestroy(m_bounceAnimationContext); 232 233 m_bounceAnimationContext = 0; 234 m_bounceAnimationCompletionHandler(); 233 235 } 234 236 -
trunk/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm
r176153 r176164 46 46 #import <WebCore/GeometryUtilities.h> 47 47 #import <WebCore/LocalizedStrings.h> 48 #import <WebCore/LookupSPI.h> 48 49 #import <WebCore/NSSharingServiceSPI.h> 49 50 #import <WebCore/NSSharingServicePickerSPI.h> … … 757 758 NSString *title = nil; 758 759 NSImage *image = nil; 760 bool enabled = true; 759 761 760 762 switch (tag) { … … 812 814 title = WEB_UI_STRING_KEY("Look Up", "Look Up (action menu item)", "action menu item"); 813 815 image = [NSImage imageNamed:@"NSActionMenuLookup"]; 816 enabled = getLULookupDefinitionModuleClass(); 814 817 break; 815 818 … … 851 854 [item setTarget:self]; 852 855 [item setTag:tag]; 856 [item setEnabled:enabled]; 853 857 return item; 854 858 } -
trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm
r175966 r176164 451 451 } 452 452 453 void WebPageProxy::didPerformDictionaryLookup(const AttributedString& text, constDictionaryPopupInfo& dictionaryPopupInfo)454 { 455 m_pageClient.didPerformDictionaryLookup( text,dictionaryPopupInfo);453 void WebPageProxy::didPerformDictionaryLookup(const DictionaryPopupInfo& dictionaryPopupInfo) 454 { 455 m_pageClient.didPerformDictionaryLookup(dictionaryPopupInfo); 456 456 } 457 457 -
trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm
r173272 r176164 1700 1700 DictionaryPopupInfo dictionaryPopupInfo; 1701 1701 dictionaryPopupInfo.origin = convertFromPDFViewToRootView(IntPoint(point)); 1702 1703 AttributedString attributedString; 1704 attributedString.string = string; 1705 1706 webFrame()->page()->send(Messages::WebPageProxy::DidPerformDictionaryLookup(attributedString, dictionaryPopupInfo)); 1702 dictionaryPopupInfo.attributedString.string = string; 1703 1704 webFrame()->page()->send(Messages::WebPageProxy::DidPerformDictionaryLookup(dictionaryPopupInfo)); 1707 1705 } 1708 1706 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm
r176112 r176164 127 127 INIT(RecommendedScrollerStyle); 128 128 INIT(ExecutableWasLinkedOnOrBeforeSnowLeopard); 129 INIT(ExtractWordDefinitionTokenRangeFromContextualString);130 129 INIT(CopyDefaultSearchProviderDisplayName); 131 130 INIT(Cursor); -
trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm
r176137 r176164 549 549 }]; 550 550 551 AttributedString attributedString; 552 attributedString.string = scaledNSAttributedString; 553 554 send(Messages::WebPageProxy::DidPerformDictionaryLookup(attributedString, dictionaryPopupInfo)); 551 RefPtr<TextIndicator> textIndicator = TextIndicator::createWithRange(range); 552 if (!textIndicator) 553 return; 554 555 dictionaryPopupInfo.textIndicator = textIndicator->data(); 556 dictionaryPopupInfo.attributedString.string = scaledNSAttributedString; 557 558 send(Messages::WebPageProxy::DidPerformDictionaryLookup(dictionaryPopupInfo)); 555 559 } 556 560
Note:
See TracChangeset
for help on using the changeset viewer.