Changeset 189052 in webkit
- Timestamp:
- Aug 27, 2015 2:24:27 PM (9 years ago)
- Location:
- trunk/Source
- Files:
-
- 1 added
- 3 deleted
- 32 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r189051 r189052 1 2015-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 1 45 2015-08-27 Jon Davis <jond@apple.com> 2 46 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r189031 r189052 1140 1140 2D5002FB1B56D7990020AAF7 /* PathUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D5002F91B56D7990020AAF7 /* PathUtilities.cpp */; }; 1141 1141 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, ); }; }; 1142 1143 2D58D8551A15F65F00A5F726 /* DataDetection.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D58D8531A15F65F00A5F726 /* DataDetection.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1143 1144 2D58D8561A15F65F00A5F726 /* DataDetection.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D58D8541A15F65F00A5F726 /* DataDetection.mm */; }; … … 8352 8353 2D5002F91B56D7990020AAF7 /* PathUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PathUtilities.cpp; sourceTree = "<group>"; }; 8353 8354 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>"; }; 8354 8356 2D58D8531A15F65F00A5F726 /* DataDetection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataDetection.h; sourceTree = "<group>"; }; 8355 8357 2D58D8541A15F65F00A5F726 /* DataDetection.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DataDetection.mm; sourceTree = "<group>"; }; … … 17978 17980 CECADFC4153778FF00E37068 /* DictationCommand.cpp */, 17979 17981 CECADFC5153778FF00E37068 /* DictationCommand.h */, 17982 2D5646AF1B8F8493003C4994 /* DictionaryPopupInfo.h */, 17980 17983 93309D93099E64910056E581 /* EditAction.h */, 17981 17984 93309D94099E64910056E581 /* EditCommand.cpp */, … … 24375 24378 BC772E131331620C001EC9CE /* CSSLineBoxContainValue.h in Headers */, 24376 24379 A80E6D030A1989CA007FB8C5 /* CSSMediaRule.h in Headers */, 24380 2D5646B01B8F8493003C4994 /* DictionaryPopupInfo.h in Headers */, 24377 24381 F98FFF4511A2676200F548E8 /* CSSOMUtils.h in Headers */, 24378 24382 A80E6D000A1989CA007FB8C5 /* CSSPageRule.h in Headers */, -
trunk/Source/WebCore/editing/mac/DictionaryLookup.h
r188565 r189052 29 29 #if PLATFORM(MAC) 30 30 31 #include "DictionaryPopupInfo.h" 32 #include <functional> 31 33 #include <wtf/PassRefPtr.h> 32 34 33 OBJC_CLASS NSDictionary; 35 OBJC_CLASS NSString; 36 OBJC_CLASS NSView; 34 37 OBJC_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 35 46 36 47 namespace WebCore { … … 40 51 class VisibleSelection; 41 52 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); 53 class DictionaryLookup { 54 public: 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 }; 45 66 46 67 } // namespace WebCore -
trunk/Source/WebCore/editing/mac/DictionaryLookup.mm
r188565 r189052 36 36 #import "HitTestResult.h" 37 37 #import "LookupSPI.h" 38 #import "NSImmediateActionGestureRecognizerSPI.h" 38 39 #import "Page.h" 39 40 #import "Range.h" … … 48 49 #import <wtf/RefPtr.h> 49 50 51 SOFT_LINK_CONSTANT_MAY_FAIL(Lookup, LUTermOptionDisableSearchTermIndicator, NSString *) 52 50 53 namespace WebCore { 51 54 … … 62 65 } 63 66 64 PassRefPtr<Range> rangeForDictionaryLookupForSelection(const VisibleSelection& selection, NSDictionary **options)67 PassRefPtr<Range> DictionaryLookup::rangeForSelection(const VisibleSelection& selection, NSDictionary **options) 65 68 { 66 69 RefPtr<Range> selectedRange = selection.toNormalizedRange(); … … 88 91 } 89 92 90 PassRefPtr<Range> rangeForDictionaryLookupAtHitTestResult(const HitTestResult& hitTestResult, NSDictionary **options)93 PassRefPtr<Range> DictionaryLookup::rangeAtHitTestResult(const HitTestResult& hitTestResult, NSDictionary **options) 91 94 { 92 95 Node* node = hitTestResult.innerNonSharedNode(); … … 114 117 VisibleSelection selection = frame->page()->focusController().focusedOrMainFrame().selection().selection(); 115 118 if (selectionContainsPosition(position, selection)) 116 return rangeForDictionaryLookupForSelection(selection, options);119 return DictionaryLookup::rangeForSelection(selection, options); 117 120 118 121 VisibleSelection selectionAccountingForLineRules = VisibleSelection(position); … … 151 154 } 152 155 153 NSString * dictionaryLookupForPDFSelection(PDFSelection *selection, NSDictionary **options)156 NSString *DictionaryLookup::stringForPDFSelection(PDFSelection *selection, NSDictionary **options) 154 157 { 155 158 // Don't do anything if there is no character at the point. … … 186 189 } 187 190 191 static 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 237 void DictionaryLookup::showPopup(const DictionaryPopupInfo& dictionaryPopupInfo, NSView *view, std::function<void(TextIndicator&)> textIndicatorInstallationCallback) 238 { 239 showPopupOrCreateAnimationController(false, dictionaryPopupInfo, view, textIndicatorInstallationCallback); 240 } 241 242 void DictionaryLookup::hidePopup() 243 { 244 if (!getLULookupDefinitionModuleClass()) 245 return; 246 [getLULookupDefinitionModuleClass() hideDefinition]; 247 } 248 249 PlatformAnimationController DictionaryLookup::animationControllerForPopup(const DictionaryPopupInfo& dictionaryPopupInfo, NSView *view, std::function<void(TextIndicator&)> textIndicatorInstallationCallback) 250 { 251 return showPopupOrCreateAnimationController(true, dictionaryPopupInfo, view, textIndicatorInstallationCallback); 252 } 253 188 254 } // namespace WebCore 189 255 -
trunk/Source/WebCore/page/mac/EventHandlerMac.mm
r188860 r189052 1080 1080 1081 1081 NSDictionary *options = nil; 1082 if (RefPtr<Range> range = rangeForDictionaryLookupAtHitTestResult(result, &options))1082 if (RefPtr<Range> range = DictionaryLookup::rangeAtHitTestResult(result, &options)) 1083 1083 return VisibleSelection(*range); 1084 1084 -
trunk/Source/WebCore/testing/Internals.cpp
r189034 r189052 1270 1270 HitTestResult result = document->frame()->mainFrame().eventHandler().hitTestResultAtPoint(IntPoint(x, y)); 1271 1271 NSDictionary *options = nullptr; 1272 return rangeForDictionaryLookupAtHitTestResult(result, &options);1272 return DictionaryLookup::rangeAtHitTestResult(result, &options); 1273 1273 #else 1274 1274 UNUSED_PARAM(x); -
trunk/Source/WebKit/ChangeLog
r188995 r189052 1 2015-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 1 10 2015-08-26 Brent Fulgham <bfulgham@apple.com> 2 11 -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r186268 r189052 102 102 2DD632C219E5D1F0002E9C7B /* WebSelectionServiceController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DD632C019E5D1F0002E9C7B /* WebSelectionServiceController.h */; }; 103 103 2DD632C319E5D1F0002E9C7B /* WebSelectionServiceController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DD632C119E5D1F0002E9C7B /* WebSelectionServiceController.mm */; }; 104 2DF064A91A2DD53C00DBB354 /* DictionaryPopupInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DF064A81A2DD53C00DBB354 /* DictionaryPopupInfo.h */; };105 104 312E2FE514E48182007CCA18 /* WebNotification.h in Headers */ = {isa = PBXBuildFile; fileRef = 312E2FE314E48182007CCA18 /* WebNotification.h */; settings = {ATTRIBUTES = (Private, ); }; }; 106 105 312E2FE614E48182007CCA18 /* WebNotification.mm in Sources */ = {isa = PBXBuildFile; fileRef = 312E2FE414E48182007CCA18 /* WebNotification.mm */; }; … … 564 563 2DD632C019E5D1F0002E9C7B /* WebSelectionServiceController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSelectionServiceController.h; sourceTree = "<group>"; }; 565 564 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>"; };567 565 312E2FE314E48182007CCA18 /* WebNotification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebNotification.h; sourceTree = "<group>"; }; 568 566 312E2FE414E48182007CCA18 /* WebNotification.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebNotification.mm; sourceTree = "<group>"; }; … … 1322 1320 51E94C0706C02CA300A9B09E /* PDF */, 1323 1321 A10C1D79182030190036883A /* ios */, 1324 2DF064A81A2DD53C00DBB354 /* DictionaryPopupInfo.h */,1325 1322 8373435A0624EE0D00F3B289 /* WebArchive.h */, 1326 1323 8373435B0624EE0D00F3B289 /* WebArchive.mm */, … … 1841 1838 9398106D0824BF01008DF038 /* WebKitErrorsPrivate.h in Headers */, 1842 1839 CD8BFCE815531224005AFB25 /* WebKitFullScreenListener.h in Headers */, 1843 2DF064A91A2DD53C00DBB354 /* DictionaryPopupInfo.h in Headers */,1844 1840 9398101D0824BF01008DF038 /* WebKitLogging.h in Headers */, 1845 1841 9398101E0824BF01008DF038 /* WebKitNSStringExtras.h in Headers */, -
trunk/Source/WebKit/mac/ChangeLog
r189034 r189052 1 2015-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 1 28 2015-08-27 Brian Burg <bburg@apple.com> 2 29 -
trunk/Source/WebKit/mac/WebView/WebHTMLView.mm
r188420 r189052 35 35 #import "DOMNodeInternal.h" 36 36 #import "DOMRangeInternal.h" 37 #import "DictionaryPopupInfo.h"38 37 #import "WebArchive.h" 39 38 #import "WebClipView.h" … … 83 82 #import <WebCore/ContextMenu.h> 84 83 #import <WebCore/ContextMenuController.h> 84 #import <WebCore/DictionaryLookup.h> 85 85 #import <WebCore/Document.h> 86 86 #import <WebCore/DocumentFragment.h> … … 5690 5690 info.attributedString = attrString; 5691 5691 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(); 5693 5694 [[self _webView] _showDictionaryLookupPopup:info]; 5694 5695 } -
trunk/Source/WebKit/mac/WebView/WebImmediateActionController.mm
r188990 r189052 31 31 #import "DOMNodeInternal.h" 32 32 #import "DOMRangeInternal.h" 33 #import "DictionaryPopupInfo.h"34 33 #import "WebElementDictionary.h" 35 34 #import "WebFrameInternal.h" … … 455 454 return nullptr; 456 455 RefPtr<TextIndicator> indicator = TextIndicator::createWithRange(*linkRange, TextIndicatorOptionDefault, TextIndicatorPresentationTransition::FadeIn); 456 indicator->data().textBoundingRectInRootViewCoordinates = [_webView _convertRectFromRootView:indicator->textBoundingRectInRootViewCoordinates()]; 457 457 458 458 _currentActionContext = [actionContext contextForView:_webView altMode:YES interactionStartedHandler:^() { … … 511 511 512 512 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(); 514 516 return popupInfo; 515 517 } … … 529 531 530 532 NSDictionary *options = nil; 531 RefPtr<Range> dictionaryRange = rangeForDictionaryLookupAtHitTestResult(_hitTestResult, &options);533 RefPtr<Range> dictionaryRange = DictionaryLookup::rangeAtHitTestResult(_hitTestResult, &options); 532 534 if (!dictionaryRange) 533 535 return nil; -
trunk/Source/WebKit/mac/WebView/WebView.mm
r188594 r189052 36 36 #import "DOMNodeInternal.h" 37 37 #import "DOMRangeInternal.h" 38 #import "DictionaryPopupInfo.h"39 38 #import "StorageThread.h" 40 39 #import "WebAlternativeTextClient.h" … … 124 123 #import <WebCore/ColorMac.h> 125 124 #import <WebCore/DatabaseManager.h> 125 #import <WebCore/DictionaryLookup.h> 126 126 #import <WebCore/Document.h> 127 127 #import <WebCore/DocumentLoader.h> … … 296 296 #if PLATFORM(MAC) 297 297 SOFT_LINK_CONSTANT_MAY_FAIL(Lookup, LUNotificationPopoverWillClose, NSString *) 298 SOFT_LINK_CONSTANT_MAY_FAIL(Lookup, LUTermOptionDisableSearchTermIndicator, NSString *)299 298 #endif 300 299 … … 8552 8551 return nil; 8553 8552 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 }); 8577 8561 } 8578 8562 #endif // __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000 … … 8598 8582 _private->textIndicatorWindow = std::make_unique<TextIndicatorWindow>(self); 8599 8583 8600 NSRect textBoundingRectInWindowCoordinates = [self convertRect: [self _convertRectFromRootView:textIndicator.textBoundingRectInRootViewCoordinates()]toView:nil];8584 NSRect textBoundingRectInWindowCoordinates = [self convertRect:textIndicator.textBoundingRectInRootViewCoordinates() toView:nil]; 8601 8585 NSRect textBoundingRectInScreenCoordinates = [self.window convertRectToScreen:textBoundingRectInWindowCoordinates]; 8602 8586 _private->textIndicatorWindow->setTextIndicator(textIndicator, NSRectToCGRect(textBoundingRectInScreenCoordinates), lifetime); … … 8616 8600 } 8617 8601 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 8618 8613 - (void)_showDictionaryLookupPopup:(const DictionaryPopupInfo&)dictionaryPopupInfo 8619 8614 { … … 8621 8616 return; 8622 8617 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 }); 8647 8626 } 8648 8627 -
trunk/Source/WebKit/mac/WebView/WebViewInternal.h
r188420 r189052 59 59 class URL; 60 60 struct DictationAlternative; 61 struct DictionaryPopupInfo; 61 62 } 62 63 63 struct DictionaryPopupInfo;64 64 class WebMediaPlaybackTargetPicker; 65 65 class WebSelectionServiceController; … … 270 270 - (void)_clearTextIndicatorWithAnimation:(WebCore::TextIndicatorWindowDismissalAnimation)animation; 271 271 - (void)_setTextIndicatorAnimationProgress:(float)progress; 272 - (void)_showDictionaryLookupPopup:(const DictionaryPopupInfo&)dictionaryPopupInfo;272 - (void)_showDictionaryLookupPopup:(const WebCore::DictionaryPopupInfo&)dictionaryPopupInfo; 273 273 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000 274 - (id)_animationControllerForDictionaryLookupPopupInfo:(const DictionaryPopupInfo&)dictionaryPopupInfo;274 - (id)_animationControllerForDictionaryLookupPopupInfo:(const WebCore::DictionaryPopupInfo&)dictionaryPopupInfo; 275 275 - (WebImmediateActionController *)_immediateActionController; 276 276 #endif -
trunk/Source/WebKit2/CMakeLists.txt
r188900 r189052 218 218 Shared/ChildProcessProxy.cpp 219 219 Shared/ContextMenuContextData.cpp 220 Shared/DictionaryPopupInfo.cpp221 220 Shared/EditorState.cpp 222 221 Shared/FontInfo.cpp -
trunk/Source/WebKit2/ChangeLog
r189034 r189052 1 2015-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 1 46 2015-08-27 Brian Burg <bburg@apple.com> 2 47 -
trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp
r188526 r189052 37 37 #include <WebCore/DatabaseDetails.h> 38 38 #include <WebCore/DictationAlternative.h> 39 #include <WebCore/DictionaryPopupInfo.h> 39 40 #include <WebCore/Editor.h> 40 41 #include <WebCore/FileChooser.h> … … 74 75 #if PLATFORM(COCOA) 75 76 #include "ArgumentCodersCF.h" 77 #include "ArgumentCodersMac.h" 76 78 #endif 77 79 … … 2204 2206 #endif 2205 2207 2208 void 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 2226 bool 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 2206 2256 } // namespace IPC -
trunk/Source/WebKit2/Shared/WebCoreArgumentCoders.h
r188983 r189052 72 72 struct Cookie; 73 73 struct DictationAlternative; 74 struct DictionaryPopupInfo; 74 75 struct FileChooserSettings; 75 76 struct IDBDatabaseMetadata; … … 474 475 }; 475 476 477 template<> struct ArgumentCoder<WebCore::DictionaryPopupInfo> { 478 static void encode(ArgumentEncoder&, const WebCore::DictionaryPopupInfo&); 479 static bool decode(ArgumentDecoder&, WebCore::DictionaryPopupInfo&); 480 }; 481 476 482 #if ENABLE(WIRELESS_PLAYBACK_TARGET) 477 483 template<> struct ArgumentCoder<WebCore::MediaPlaybackTargetContext> { -
trunk/Source/WebKit2/Shared/WebHitTestResult.h
r184780 r189052 22 22 23 23 #include "APIObject.h" 24 #include "DictionaryPopupInfo.h"25 24 #include "SharedMemory.h" 25 #include <WebCore/DictionaryPopupInfo.h> 26 26 #include <WebCore/FloatPoint.h> 27 27 #include <WebCore/IntRect.h> … … 76 76 WebCore::PageOverlay::PageOverlayID detectedDataOriginatingPageOverlay; 77 77 78 DictionaryPopupInfo dictionaryPopupInfo;78 WebCore::DictionaryPopupInfo dictionaryPopupInfo; 79 79 80 80 RefPtr<WebCore::TextIndicator> linkTextIndicator; -
trunk/Source/WebKit2/Shared/mac/ArgumentCodersMac.h
r161148 r189052 28 28 29 29 #include <wtf/RetainPtr.h> 30 31 OBJC_CLASS NSArray; 32 OBJC_CLASS NSAttributedString; 33 OBJC_CLASS NSColor; 34 OBJC_CLASS NSData; 35 OBJC_CLASS NSDate; 36 OBJC_CLASS NSDictionary; 37 OBJC_CLASS NSFont; 38 OBJC_CLASS NSNumber; 39 OBJC_CLASS NSString; 30 40 31 41 namespace IPC { -
trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm
r188718 r189052 84 84 #import <WebCore/ColorMac.h> 85 85 #import <WebCore/DataDetectorsSPI.h> 86 #import <WebCore/DictionaryLookup.h> 86 87 #import <WebCore/DragController.h> 87 88 #import <WebCore/DragData.h> … … 4084 4085 + (void)hideWordDefinitionWindow 4085 4086 { 4086 if (!getLULookupDefinitionModuleClass()) 4087 return; 4088 [getLULookupDefinitionModuleClass() hideDefinition]; 4087 DictionaryLookup::hidePopup(); 4089 4088 } 4090 4089 … … 4677 4676 #endif 4678 4677 ) { 4679 if (Class lookupDefinitionModuleClass = getLULookupDefinitionModuleClass()) 4680 [lookupDefinitionModuleClass hideDefinition]; 4678 DictionaryLookup::hidePopup(); 4681 4679 4682 4680 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000 -
trunk/Source/WebKit2/UIProcess/PageClient.h
r188693 r189052 240 240 virtual void pluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus) = 0; 241 241 virtual void setPluginComplexTextInputState(uint64_t pluginComplexTextInputIdentifier, PluginComplexTextInputState) = 0; 242 virtual void didPerformDictionaryLookup(const DictionaryPopupInfo&) = 0;242 virtual void didPerformDictionaryLookup(const WebCore::DictionaryPopupInfo&) = 0; 243 243 virtual void dismissContentRelativeChildWindows(bool withAnimation = true) = 0; 244 244 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 156 156 class SharedBuffer; 157 157 class TextIndicator; 158 struct DictionaryPopupInfo; 158 159 struct FileChooserSettings; 159 160 struct TextAlternativeWithRange; … … 202 203 struct AttributedString; 203 204 struct ColorSpaceData; 204 struct DictionaryPopupInfo;205 205 struct EditingRange; 206 206 struct EditorState; … … 1296 1296 1297 1297 // Dictionary. 1298 void didPerformDictionaryLookup(const DictionaryPopupInfo&);1298 void didPerformDictionaryLookup(const WebCore::DictionaryPopupInfo&); 1299 1299 #endif 1300 1300 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in
r188693 r189052 309 309 #if PLATFORM(COCOA) 310 310 # Dictionary support. 311 DidPerformDictionaryLookup(struct Web Kit::DictionaryPopupInfo dictionaryPopupInfo)311 DidPerformDictionaryLookup(struct WebCore::DictionaryPopupInfo dictionaryPopupInfo) 312 312 313 313 # Keyboard input support messages -
trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h
r188693 r189052 146 146 virtual void makeFirstResponder() override; 147 147 148 virtual void didPerformDictionaryLookup(const DictionaryPopupInfo&) override;148 virtual void didPerformDictionaryLookup(const WebCore::DictionaryPopupInfo&) override; 149 149 virtual void dismissContentRelativeChildWindows(bool withAnimation = true) override; 150 150 -
trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm
r188693 r189052 29 29 #if PLATFORM(MAC) 30 30 31 #import "AttributedString.h"32 31 #import "ColorSpaceData.h" 33 32 #import "DataReference.h" 34 #import "DictionaryPopupInfo.h"35 33 #import "DownloadProxy.h" 36 34 #import "NativeWebKeyboardEvent.h" … … 54 52 #import <WebCore/BitmapImage.h> 55 53 #import <WebCore/Cursor.h> 54 #import <WebCore/DictionaryLookup.h> 56 55 #import <WebCore/FloatRect.h> 57 56 #import <WebCore/GraphicsContext.h> 58 57 #import <WebCore/Image.h> 59 58 #import <WebCore/KeyboardEvent.h> 60 #import <WebCore/LookupSPI.h>61 59 #import <WebCore/NotImplemented.h> 62 60 #import <WebCore/SharedBuffer.h> … … 86 84 #endif 87 85 88 SOFT_LINK_CONSTANT_MAY_FAIL(Lookup, LUTermOptionDisableSearchTermIndicator, NSString *)89 90 86 using namespace WebCore; 91 87 using namespace WebKit; … … 586 582 void PageClientImpl::didPerformDictionaryLookup(const DictionaryPopupInfo& dictionaryPopupInfo) 587 583 { 588 if (!getLULookupDefinitionModuleClass())589 return;590 591 RetainPtr<NSMutableDictionary> mutableOptions = adoptNS([(NSDictionary *)dictionaryPopupInfo.options.get() mutableCopy]);592 593 584 [m_wkView _prepareForDictionaryLookup]; 594 585 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 }); 614 589 } 615 590 -
trunk/Source/WebKit2/UIProcess/mac/WKImmediateActionController.mm
r188443 r189052 36 36 #import "WebProcessProxy.h" 37 37 #import <WebCore/DataDetectorsSPI.h> 38 #import <WebCore/DictionaryLookup.h> 38 39 #import <WebCore/GeometryUtilities.h> 39 40 #import <WebCore/LookupSPI.h> … … 47 48 SOFT_LINK_FRAMEWORK_IN_UMBRELLA(Quartz, QuickLookUI) 48 49 SOFT_LINK_CLASS(QuickLookUI, QLPreviewMenuItem) 49 SOFT_LINK_CONSTANT_MAY_FAIL(Lookup, LUTermOptionDisableSearchTermIndicator, NSString *)50 50 51 51 using namespace WebCore; … … 462 462 return nil; 463 463 464 if (!getLULookupDefinitionModuleClass())465 return nil;466 467 464 DictionaryPopupInfo dictionaryPopupInfo = _hitTestResultData.dictionaryPopupInfo; 468 if (!dictionaryPopupInfo.attributedString .string)465 if (!dictionaryPopupInfo.attributedString) 469 466 return nil; 470 467 471 468 [_wkView _prepareForDictionaryLookup]; 472 469 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 }); 491 473 } 492 474 -
trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm
r187609 r189052 33 33 #import "ColorSpaceData.h" 34 34 #import "DataReference.h" 35 #import "DictionaryPopupInfo.h"36 35 #import "EditingRange.h" 37 36 #import "EditorState.h" … … 49 48 #import "WebProcessProxy.h" 50 49 #import <WebCore/DictationAlternative.h> 50 #import <WebCore/DictionaryLookup.h> 51 51 #import <WebCore/GraphicsLayer.h> 52 52 #import <WebCore/RuntimeApplicationChecks.h> -
trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
r188895 r189052 1595 1595 BCE81D8C1319F7EF00241910 /* FontInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCE81D8A1319F7EF00241910 /* FontInfo.cpp */; }; 1596 1596 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 */; };1599 1597 BCEE7AD012817988009827DA /* WebProcessProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEE7ACC12817988009827DA /* WebProcessProxyMessageReceiver.cpp */; }; 1600 1598 BCEE7AD112817988009827DA /* WebProcessProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEE7ACD12817988009827DA /* WebProcessProxyMessages.h */; }; … … 3822 3820 BCE81D8A1319F7EF00241910 /* FontInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontInfo.cpp; sourceTree = "<group>"; }; 3823 3821 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>"; };3826 3822 BCE9C0CF1485965D00E33D61 /* WebConnectionToUIProcess.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebConnectionToUIProcess.cpp; sourceTree = "<group>"; }; 3827 3823 BCE9C0D01485965D00E33D61 /* WebConnectionToUIProcess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebConnectionToUIProcess.h; sourceTree = "<group>"; }; … … 4701 4697 5106D7BF18BDBE73000AB166 /* ContextMenuContextData.cpp */, 4702 4698 5106D7C018BDBE73000AB166 /* ContextMenuContextData.h */, 4703 BCE81D96131AE02000241910 /* DictionaryPopupInfo.cpp */,4704 BCE81D97131AE02100241910 /* DictionaryPopupInfo.h */,4705 4699 C517388012DF8F4F00EE3F47 /* DragControllerAction.h */, 4706 4700 0FB659221208B4DB0044816C /* DrawingAreaInfo.h */, … … 7638 7632 1AC75380183BE50F0072CB15 /* DataReference.h in Headers */, 7639 7633 83891B6C1A68C30B0030F386 /* DiagnosticLoggingClient.h in Headers */, 7640 BCE81D99131AE02100241910 /* DictionaryPopupInfo.h in Headers */,7641 7634 518E8F0816B2093700E91429 /* Download.h in Headers */, 7642 7635 518E8F0A16B2093700E91429 /* DownloadAuthenticationClient.h in Headers */, … … 9441 9434 1AC7537F183BE50F0072CB15 /* DataReference.cpp in Sources */, 9442 9435 83891B6D1A68C30B0030F386 /* DiagnosticLoggingClient.mm in Sources */, 9443 BCE81D98131AE02100241910 /* DictionaryPopupInfo.cpp in Sources */,9444 9436 518E8F0716B2093700E91429 /* Download.cpp in Sources */, 9445 9437 518E8F0916B2093700E91429 /* DownloadAuthenticationClient.cpp in Sources */, -
trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm
r187002 r189052 30 30 31 31 #import "ArgumentCoders.h" 32 #import "AttributedString.h"33 32 #import "DataReference.h" 34 #import "DictionaryPopupInfo.h"35 33 #import "PDFAnnotationTextWidgetDetails.h" 36 34 #import "PDFKitImports.h" … … 1721 1719 DictionaryPopupInfo dictionaryPopupInfo; 1722 1720 dictionaryPopupInfo.origin = convertFromPDFViewToRootView(IntPoint(point)); 1723 dictionaryPopupInfo.attributedString .string= string;1721 dictionaryPopupInfo.attributedString = string; 1724 1722 1725 1723 webFrame()->page()->send(Messages::WebPageProxy::DidPerformDictionaryLookup(dictionaryPopupInfo)); … … 1938 1936 } 1939 1937 1940 NSString *lookupText = dictionaryLookupForPDFSelection(selection, options);1938 NSString *lookupText = DictionaryLookup::stringForPDFSelection(selection, options); 1941 1939 if (!lookupText || !lookupText.length) 1942 1940 return @""; -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebContextMenuClientMac.mm
r183547 r189052 29 29 #if ENABLE(CONTEXT_MENUS) 30 30 31 #import "DictionaryPopupInfo.h"32 31 #import "WebCoreArgumentCoders.h" 33 32 #import "WebPage.h" 34 33 #import "WebPageProxyMessages.h" 34 #import <WebCore/DictionaryLookup.h> 35 35 #import <WebCore/FrameView.h> 36 36 #import <WebCore/MainFrame.h> -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
r188828 r189052 31 31 #include "APIInjectedBundlePageUIClient.h" 32 32 #include "APIObject.h" 33 #include "DictionaryPopupInfo.h"34 33 #include "FindController.h" 35 34 #include "GeolocationPermissionRequestManager.h" … … 50 49 #include "UserMediaPermissionRequestManager.h" 51 50 #include <WebCore/DictationAlternative.h> 51 #include <WebCore/DictionaryPopupInfo.h> 52 52 #include <WebCore/DragData.h> 53 53 #include <WebCore/Editor.h> … … 1056 1056 void performDictionaryLookupOfCurrentSelection(); 1057 1057 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); 1059 1059 #if ENABLE(PDFKIT_PLUGIN) 1060 DictionaryPopupInfo dictionaryPopupInfoForSelectionInPDFPlugin(PDFSelection *, PDFPlugin&, NSDictionary **options, WebCore::TextIndicatorPresentationTransition);1060 WebCore::DictionaryPopupInfo dictionaryPopupInfoForSelectionInPDFPlugin(PDFSelection *, PDFPlugin&, NSDictionary **options, WebCore::TextIndicatorPresentationTransition); 1061 1061 #endif 1062 1062 -
trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm
r188990 r189052 31 31 #import "AttributedString.h" 32 32 #import "DataReference.h" 33 #import "DictionaryPopupInfo.h"34 33 #import "EditingRange.h" 35 34 #import "EditorState.h" … … 519 518 Frame* frame = result.innerNonSharedNode() ? result.innerNonSharedNode()->document().frame() : &m_page->focusController().focusedOrMainFrame(); 520 519 NSDictionary *options = nil; 521 RefPtr<Range> range = rangeForDictionaryLookupAtHitTestResult(result, &options);520 RefPtr<Range> range = DictionaryLookup::rangeAtHitTestResult(result, &options); 522 521 if (!range) 523 522 return; … … 529 528 { 530 529 NSDictionary *options = nil; 531 RefPtr<Range> selectedRange = rangeForDictionaryLookupForSelection(selection, &options);530 RefPtr<Range> selectedRange = DictionaryLookup::rangeForSelection(selection, &options); 532 531 if (selectedRange) 533 532 performDictionaryLookupForRange(frame, *selectedRange, options, presentationTransition); … … 557 556 558 557 dictionaryPopupInfo.origin = FloatPoint(rangeRect.x(), rangeRect.y() + (style.fontMetrics().ascent() * pageScaleFactor())); 559 dictionaryPopupInfo.options = (CFDictionaryRef)*options;558 dictionaryPopupInfo.options = *options; 560 559 561 560 NSAttributedString *nsAttributedString = editingAttributedStringFromRange(range, IncludeImagesInAttributedString::No); … … 586 585 587 586 dictionaryPopupInfo.textIndicator = textIndicator->data(); 588 dictionaryPopupInfo.attributedString .string= scaledNSAttributedString;587 dictionaryPopupInfo.attributedString = scaledNSAttributedString; 589 588 590 589 return dictionaryPopupInfo; … … 639 638 640 639 dictionaryPopupInfo.origin = rangeRect.origin; 641 dictionaryPopupInfo.options = (CFDictionaryRef)*options;640 dictionaryPopupInfo.options = *options; 642 641 dictionaryPopupInfo.textIndicator = dataForSelection; 643 dictionaryPopupInfo.attributedString .string= scaledNSAttributedString;642 dictionaryPopupInfo.attributedString = scaledNSAttributedString; 644 643 645 644 return dictionaryPopupInfo; … … 1199 1198 IntPoint point = roundedIntPoint(locationInViewCoordinates); 1200 1199 HitTestResult result = mainFrame.eventHandler().hitTestResultAtPoint(m_page->mainFrame().view()->windowToContents(point)); 1201 return rangeForDictionaryLookupAtHitTestResult(result, options);1200 return DictionaryLookup::rangeAtHitTestResult(result, options); 1202 1201 } 1203 1202
Note: See TracChangeset
for help on using the changeset viewer.