Changeset 176680 in webkit
- Timestamp:
- Dec 2, 2014, 11:38:05 AM (12 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 1 added
- 7 edited
-
ChangeLog (modified) (1 diff)
-
WebKit.xcodeproj/project.pbxproj (modified) (4 diffs)
-
mac/ChangeLog (modified) (1 diff)
-
mac/WebView/DictionaryPopupInfo.h (added)
-
mac/WebView/WebActionMenuController.mm (modified) (5 diffs)
-
mac/WebView/WebHTMLView.mm (modified) (3 diffs)
-
mac/WebView/WebView.mm (modified) (7 diffs)
-
mac/WebView/WebViewInternal.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r176614 r176680 1 2014-12-02 Tim Horton <timothy_horton@apple.com> 2 3 Implement Lookup transition from selection for Legacy WebKit 4 https://bugs.webkit.org/show_bug.cgi?id=139180 5 <rdar://problem/19067172> 6 7 Reviewed by Beth Dakin. 8 9 * WebKit.xcodeproj/project.pbxproj: 10 Add mac/WebView/DictionaryPopupInfo.h. 11 1 12 2014-12-01 Anders Carlsson <andersca@apple.com> 2 13 -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r176551 r176680 86 86 2DD632C219E5D1F0002E9C7B /* WebSelectionServiceController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DD632C019E5D1F0002E9C7B /* WebSelectionServiceController.h */; }; 87 87 2DD632C319E5D1F0002E9C7B /* WebSelectionServiceController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DD632C119E5D1F0002E9C7B /* WebSelectionServiceController.mm */; }; 88 2DF064A91A2DD53C00DBB354 /* DictionaryPopupInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DF064A81A2DD53C00DBB354 /* DictionaryPopupInfo.h */; }; 88 89 312E2FE514E48182007CCA18 /* WebNotification.h in Headers */ = {isa = PBXBuildFile; fileRef = 312E2FE314E48182007CCA18 /* WebNotification.h */; settings = {ATTRIBUTES = (Private, ); }; }; 89 90 312E2FE614E48182007CCA18 /* WebNotification.mm in Sources */ = {isa = PBXBuildFile; fileRef = 312E2FE414E48182007CCA18 /* WebNotification.mm */; }; … … 537 538 2DD632C019E5D1F0002E9C7B /* WebSelectionServiceController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSelectionServiceController.h; sourceTree = "<group>"; }; 538 539 2DD632C119E5D1F0002E9C7B /* WebSelectionServiceController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebSelectionServiceController.mm; sourceTree = "<group>"; }; 540 2DF064A81A2DD53C00DBB354 /* DictionaryPopupInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DictionaryPopupInfo.h; sourceTree = "<group>"; }; 539 541 312E2FE314E48182007CCA18 /* WebNotification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebNotification.h; sourceTree = "<group>"; }; 540 542 312E2FE414E48182007CCA18 /* WebNotification.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebNotification.mm; sourceTree = "<group>"; }; … … 1287 1289 51E94C0706C02CA300A9B09E /* PDF */, 1288 1290 A10C1D79182030190036883A /* ios */, 1291 2DF064A81A2DD53C00DBB354 /* DictionaryPopupInfo.h */, 1289 1292 935D44E219F9AFF000FB5306 /* WebActionMenuController.h */, 1290 1293 935D44E319F9AFF000FB5306 /* WebActionMenuController.mm */, … … 1802 1805 9398106D0824BF01008DF038 /* WebKitErrorsPrivate.h in Headers */, 1803 1806 CD8BFCE815531224005AFB25 /* WebKitFullScreenListener.h in Headers */, 1807 2DF064A91A2DD53C00DBB354 /* DictionaryPopupInfo.h in Headers */, 1804 1808 9398101D0824BF01008DF038 /* WebKitLogging.h in Headers */, 1805 1809 9398101E0824BF01008DF038 /* WebKitNSStringExtras.h in Headers */, -
trunk/Source/WebKit/mac/ChangeLog
r176670 r176680 1 2014-12-02 Tim Horton <timothy_horton@apple.com> 2 3 Implement Lookup transition from selection for Legacy WebKit 4 https://bugs.webkit.org/show_bug.cgi?id=139180 5 <rdar://problem/19067172> 6 7 Reviewed by Beth Dakin. 8 9 * WebView/DictionaryPopupInfo.h: Added. 10 Split DictionaryPopupInfo out into its own file. 11 12 * WebView/WebActionMenuController.mm: 13 (-[WebActionMenuController _lookupText:]): 14 Hand the DictionaryPopupInfo to WebView, which will show the TextIndicator and invoke Lookup. 15 16 (performDictionaryLookupForSelection): 17 (performDictionaryLookupForRange): 18 Plumb the transition style through these helpers. 19 Create a TextIndicator from the selection range. 20 21 * WebView/WebHTMLView.mm: 22 (-[WebHTMLView _lookUpInDictionaryFromMenu:]): 23 Make use of TextIndicator (and DictionaryPopupInfo, and the new 24 _showDictionaryLookupPopup on WebView) to add a transition from blue 25 when performing Lookup from the context menu. 26 27 (-[WebHTMLView quickLookWithEvent:]): 28 Remove our TextIndicator whenever a normal three-finger-tap event 29 comes through, as it will have its own indication. 30 31 * WebView/WebView.mm: 32 (-[WebView _commonInitializationWithFrameName:groupName:]): 33 (-[WebView _dictionaryLookupPopoverWillClose:]): 34 Register for the LUNotificationPopoverWillClose notification and remove 35 our TextIndicator when it is called, just like in WebKit2. 36 Deregistration is already handled in _close. 37 38 (-[WebView _showDictionaryLookupPopup:]): 39 Just like WebKit2, show our TextIndicator and tell Lookup not to show its own, 40 if the relevant API is available. 41 42 * WebView/WebViewInternal.h: 43 1 44 2014-12-02 Anders Carlsson <andersca@apple.com> 2 45 -
trunk/Source/WebKit/mac/WebView/WebActionMenuController.mm
r176608 r176680 31 31 #import "DOMNodeInternal.h" 32 32 #import "DOMRangeInternal.h" 33 #import "DictionaryPopupInfo.h" 33 34 #import "WebDocumentInternal.h" 34 35 #import "WebElementDictionary.h" … … 87 88 using namespace WebCore; 88 89 89 struct DictionaryPopupInfo {90 NSPoint origin;91 RetainPtr<NSDictionary> options;92 RetainPtr<NSAttributedString> attributedString;93 };94 95 90 @implementation WebActionMenuController 96 91 … … 634 629 635 630 DictionaryPopupInfo popupInfo = performDictionaryLookupForSelection(frame, frame->selection().selection()); 636 if (!popupInfo.attributedString) 637 return; 638 639 NSPoint textBaselineOrigin = popupInfo.origin; 640 641 // Convert to screen coordinates. 642 textBaselineOrigin = [_webView.window convertRectToScreen:NSMakeRect(textBaselineOrigin.x, textBaselineOrigin.y, 0, 0)].origin; 643 644 [getLULookupDefinitionModuleClass() showDefinitionForTerm:popupInfo.attributedString.get() atLocation:textBaselineOrigin options:popupInfo.options.get()]; 631 [_webView _showDictionaryLookupPopup:popupInfo]; 645 632 } 646 633 … … 682 669 RefPtr<Range> selectedRange = rangeForDictionaryLookupForSelection(selection, &options); 683 670 if (selectedRange) 684 popupInfo = performDictionaryLookupForRange(frame, *selectedRange, options );671 popupInfo = performDictionaryLookupForRange(frame, *selectedRange, options, TextIndicatorPresentationTransition::BounceAndCrossfade); 685 672 return popupInfo; 686 673 } 687 674 688 static DictionaryPopupInfo performDictionaryLookupForRange(Frame* frame, Range& range, NSDictionary *options )675 static DictionaryPopupInfo performDictionaryLookupForRange(Frame* frame, Range& range, NSDictionary *options, TextIndicatorPresentationTransition presentationTransition) 689 676 { 690 677 DictionaryPopupInfo popupInfo; … … 722 709 723 710 popupInfo.attributedString = scaledNSAttributedString.get(); 711 popupInfo.textIndicator = TextIndicator::createWithRange(range, presentationTransition); 724 712 return popupInfo; 725 713 } -
trunk/Source/WebKit/mac/WebView/WebHTMLView.mm
r176608 r176680 35 35 #import "DOMNodeInternal.h" 36 36 #import "DOMRangeInternal.h" 37 #import "DictionaryPopupInfo.h" 37 38 #import "WebActionMenuController.h" 38 39 #import "WebArchive.h" … … 116 117 #import <WebCore/Text.h> 117 118 #import <WebCore/TextAlternativeWithRange.h> 119 #import <WebCore/TextIndicator.h> 118 120 #import <WebCore/TextUndoInsertionMarkupMac.h> 119 121 #import <WebCore/WebCoreObjCExtras.h> … … 5635 5637 NSRect rect = coreFrame->selection().selectionBounds(); 5636 5638 5637 NSDictionary *attributes = [attrString fontAttributesInRange:NSMakeRange(0, 1)];5639 NSDictionary *attributes = [attrString fontAttributesInRange:NSMakeRange(0, 1)]; 5638 5640 NSFont *font = [attributes objectForKey:NSFontAttributeName]; 5639 5641 if (font) 5640 rect.origin.y += [font ascender]; 5641 5642 [self showDefinitionForAttributedString:attrString atPoint:rect.origin]; 5642 rect.origin.y += [font descender]; 5643 5644 DictionaryPopupInfo info; 5645 info.attributedString = attrString; 5646 info.origin = coreFrame->view()->contentsToWindow(enclosingIntRect(rect)).location(); 5647 info.textIndicator = TextIndicator::createWithSelectionInFrame(*coreFrame, TextIndicatorPresentationTransition::BounceAndCrossfade); 5648 [[self _webView] _showDictionaryLookupPopup:info]; 5649 } 5650 5651 - (void)quickLookWithEvent:(NSEvent *)event 5652 { 5653 [[self _webView] _setTextIndicator:nullptr fadeOut:NO animationCompletionHandler:[] { }]; 5654 [super quickLookWithEvent:event]; 5643 5655 } 5644 5656 #endif // !PLATFORM(IOS) -
trunk/Source/WebKit/mac/WebView/WebView.mm
r176670 r176680 36 36 #import "DOMNodeInternal.h" 37 37 #import "DOMRangeInternal.h" 38 #import "DictionaryPopupInfo.h" 38 39 #import "WebAlternativeTextClient.h" 39 40 #import "WebApplicationCache.h" … … 213 214 #import "WebNSPrintOperationExtras.h" 214 215 #import "WebPDFView.h" 216 #import <WebCore/LookupSPI.h> 215 217 #import <WebCore/NSViewSPI.h> 218 #import <WebCore/SoftLinking.h> 216 219 #import <WebCore/TextIndicator.h> 217 220 #import <WebCore/TextIndicatorWindow.h> … … 284 287 #if ENABLE(GAMEPAD) 285 288 #import <WebCore/HIDGamepadProvider.h> 289 #endif 290 291 #if PLATFORM(MAC) 292 SOFT_LINK_CONSTANT_MAY_FAIL(Lookup, LUNotificationPopoverWillClose, NSString *) 293 SOFT_LINK_CONSTANT_MAY_FAIL(Lookup, LUTermOptionDisableSearchTermIndicator, NSString *) 286 294 #endif 287 295 … … 1022 1030 #if !PLATFORM(IOS) 1023 1031 [self _registerDraggedTypes]; 1032 1033 if (canLoadLUNotificationPopoverWillClose()) 1034 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_dictionaryLookupPopoverWillClose:) name:getLUNotificationPopoverWillClose() object:nil]; 1024 1035 #endif 1025 1036 … … 8551 8562 } 8552 8563 8553 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000 8564 #if PLATFORM(MAC) 8565 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000 8554 8566 - (void)prepareForMenu:(NSMenu *)menu withEvent:(NSEvent *)event 8555 8567 { … … 8575 8587 [_private->actionMenuController didCloseMenu:menu withEvent:event]; 8576 8588 } 8589 8590 - (WebActionMenuController *)_actionMenuController 8591 { 8592 return _private->actionMenuController; 8593 } 8594 #endif // __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000 8577 8595 8578 8596 - (void)_setTextIndicator:(TextIndicator *)textIndicator fadeOut:(BOOL)fadeOut animationCompletionHandler:(std::function<void ()>)completionHandler … … 8594 8612 } 8595 8613 8596 - (WebActionMenuController *)_actionMenuController 8597 { 8598 return _private->actionMenuController; 8599 } 8600 #endif // PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000 8614 - (void)_showDictionaryLookupPopup:(const DictionaryPopupInfo&)dictionaryPopupInfo 8615 { 8616 if (!dictionaryPopupInfo.attributedString) 8617 return; 8618 8619 NSPoint textBaselineOrigin = dictionaryPopupInfo.origin; 8620 8621 // Convert to screen coordinates. 8622 textBaselineOrigin = [self.window convertRectToScreen:NSMakeRect(textBaselineOrigin.x, textBaselineOrigin.y, 0, 0)].origin; 8623 8624 if (canLoadLUTermOptionDisableSearchTermIndicator()) { 8625 RetainPtr<NSMutableDictionary> mutableOptions = adoptNS([dictionaryPopupInfo.options mutableCopy]); 8626 if (!mutableOptions) 8627 mutableOptions = adoptNS([[NSMutableDictionary alloc] init]); 8628 [mutableOptions setObject:@YES forKey:getLUTermOptionDisableSearchTermIndicator()]; 8629 [self _setTextIndicator:dictionaryPopupInfo.textIndicator.get() fadeOut:NO animationCompletionHandler:[dictionaryPopupInfo, textBaselineOrigin, mutableOptions] { 8630 [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.get() atLocation:textBaselineOrigin options:mutableOptions.get()]; 8631 }]; 8632 } else 8633 [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.get() atLocation:textBaselineOrigin options:dictionaryPopupInfo.options.get()]; 8634 } 8635 8636 - (void)_dictionaryLookupPopoverWillClose:(NSNotification *)notification 8637 { 8638 [self _setTextIndicator:nullptr fadeOut:NO animationCompletionHandler:[] { }]; 8639 } 8640 #endif // PLATFORM(MAC) 8601 8641 8602 8642 @end -
trunk/Source/WebKit/mac/WebView/WebViewInternal.h
r176608 r176680 60 60 } 61 61 62 struct DictionaryPopupInfo; 62 63 class WebSelectionServiceController; 63 64 #endif … … 260 261 - (void)_setTextIndicator:(WebCore::TextIndicator*)textIndicator fadeOut:(BOOL)fadeOut animationCompletionHandler:(std::function<void ()>)completionHandler; 261 262 - (void)_clearTextIndicator; 263 - (void)_showDictionaryLookupPopup:(const DictionaryPopupInfo&)dictionaryPopupInfo; 262 264 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000 263 265 - (WebActionMenuController *)_actionMenuController;
Note:
See TracChangeset
for help on using the changeset viewer.