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

Changeset 176737 in webkit


Ignore:
Timestamp:
Dec 3, 2014, 12:15:51 PM (12 years ago)
Author:
dburkart@apple.com
Message:

Merged r176680. rdar://problems/19067172

Location:
branches/safari-600.3-branch/Source/WebKit
Files:
1 added
7 edited

Legend:

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

    r175302 r176737  
     12014-12-03  Dana Burkart  <dburkart@apple.com>
     2
     3        Merge r176680. <rdar://problem/19067172>
     4
     5    2014-12-02  Tim Horton  <timothy_horton@apple.com>
     6
     7            Implement Lookup transition from selection for Legacy WebKit
     8            https://bugs.webkit.org/show_bug.cgi?id=139180
     9            <rdar://problem/19067172>
     10
     11            Reviewed by Beth Dakin.
     12
     13            * WebKit.xcodeproj/project.pbxproj:
     14            Add mac/WebView/DictionaryPopupInfo.h.
     15
     16
    1172014-10-28  Dana Burkart  <dburkart@apple.com>
    218
  • branches/safari-600.3-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r175306 r176737  
    8686                2DD632C219E5D1F0002E9C7B /* WebSelectionServiceController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DD632C019E5D1F0002E9C7B /* WebSelectionServiceController.h */; };
    8787                2DD632C319E5D1F0002E9C7B /* WebSelectionServiceController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DD632C119E5D1F0002E9C7B /* WebSelectionServiceController.mm */; };
     88                2DF064A91A2DD53C00DBB354 /* DictionaryPopupInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DF064A81A2DD53C00DBB354 /* DictionaryPopupInfo.h */; };
    8889                312E2FE514E48182007CCA18 /* WebNotification.h in Headers */ = {isa = PBXBuildFile; fileRef = 312E2FE314E48182007CCA18 /* WebNotification.h */; settings = {ATTRIBUTES = (Private, ); }; };
    8990                312E2FE614E48182007CCA18 /* WebNotification.mm in Sources */ = {isa = PBXBuildFile; fileRef = 312E2FE414E48182007CCA18 /* WebNotification.mm */; };
     
    542543                2DD632C019E5D1F0002E9C7B /* WebSelectionServiceController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSelectionServiceController.h; sourceTree = "<group>"; };
    543544                2DD632C119E5D1F0002E9C7B /* WebSelectionServiceController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebSelectionServiceController.mm; sourceTree = "<group>"; };
     545                2DF064A81A2DD53C00DBB354 /* DictionaryPopupInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DictionaryPopupInfo.h; sourceTree = "<group>"; };
    544546                312E2FE314E48182007CCA18 /* WebNotification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebNotification.h; sourceTree = "<group>"; };
    545547                312E2FE414E48182007CCA18 /* WebNotification.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebNotification.mm; sourceTree = "<group>"; };
     
    12951297                                51E94C0706C02CA300A9B09E /* PDF */,
    12961298                                A10C1D79182030190036883A /* ios */,
     1299                                2DF064A81A2DD53C00DBB354 /* DictionaryPopupInfo.h */,
    12971300                                935D44E219F9AFF000FB5306 /* WebActionMenuController.h */,
    12981301                                935D44E319F9AFF000FB5306 /* WebActionMenuController.mm */,
     
    18151818                                9398106D0824BF01008DF038 /* WebKitErrorsPrivate.h in Headers */,
    18161819                                CD8BFCE815531224005AFB25 /* WebKitFullScreenListener.h in Headers */,
     1820                                2DF064A91A2DD53C00DBB354 /* DictionaryPopupInfo.h in Headers */,
    18171821                                9398101D0824BF01008DF038 /* WebKitLogging.h in Headers */,
    18181822                                9398101E0824BF01008DF038 /* WebKitNSStringExtras.h in Headers */,
  • branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog

    r176663 r176737  
     12014-12-03  Dana Burkart  <dburkart@apple.com>
     2
     3        Merge r176680. <rdar://problem/19067172>
     4
     5    2014-12-02  Tim Horton  <timothy_horton@apple.com>
     6
     7            Implement Lookup transition from selection for Legacy WebKit
     8            https://bugs.webkit.org/show_bug.cgi?id=139180
     9            <rdar://problem/19067172>
     10
     11            Reviewed by Beth Dakin.
     12
     13            * WebView/DictionaryPopupInfo.h: Added.
     14            Split DictionaryPopupInfo out into its own file.
     15
     16            * WebView/WebActionMenuController.mm:
     17            (-[WebActionMenuController _lookupText:]):
     18            Hand the DictionaryPopupInfo to WebView, which will show the TextIndicator and invoke Lookup.
     19
     20            (performDictionaryLookupForSelection):
     21            (performDictionaryLookupForRange):
     22            Plumb the transition style through these helpers.
     23            Create a TextIndicator from the selection range.
     24
     25            * WebView/WebHTMLView.mm:
     26            (-[WebHTMLView _lookUpInDictionaryFromMenu:]):
     27            Make use of TextIndicator (and DictionaryPopupInfo, and the new
     28            _showDictionaryLookupPopup on WebView) to add a transition from blue
     29            when performing Lookup from the context menu.
     30
     31            (-[WebHTMLView quickLookWithEvent:]):
     32            Remove our TextIndicator whenever a normal three-finger-tap event
     33            comes through, as it will have its own indication.
     34
     35            * WebView/WebView.mm:
     36            (-[WebView _commonInitializationWithFrameName:groupName:]):
     37            (-[WebView _dictionaryLookupPopoverWillClose:]):
     38            Register for the LUNotificationPopoverWillClose notification and remove
     39            our TextIndicator when it is called, just like in WebKit2.
     40            Deregistration is already handled in _close.
     41
     42            (-[WebView _showDictionaryLookupPopup:]):
     43            Just like WebKit2, show our TextIndicator and tell Lookup not to show its own,
     44            if the relevant API is available.
     45
     46            * WebView/WebViewInternal.h:
     47
     48
    1492014-12-02  Dana Burkart  <dburkart@apple.com>
    250
  • branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebActionMenuController.mm

    r176662 r176737  
    3131#import "DOMNodeInternal.h"
    3232#import "DOMRangeInternal.h"
     33#import "DictionaryPopupInfo.h"
    3334#import "WebDocumentInternal.h"
    3435#import "WebElementDictionary.h"
     
    8889using namespace WebCore;
    8990
    90 struct DictionaryPopupInfo {
    91     NSPoint origin;
    92     RetainPtr<NSDictionary> options;
    93     RetainPtr<NSAttributedString> attributedString;
    94 };
    95 
    9691@implementation WebActionMenuController
    9792
     
    635630
    636631    DictionaryPopupInfo popupInfo = performDictionaryLookupForSelection(frame, frame->selection().selection());
    637     if (!popupInfo.attributedString)
    638         return;
    639 
    640     NSPoint textBaselineOrigin = popupInfo.origin;
    641 
    642     // Convert to screen coordinates.
    643     textBaselineOrigin = [_webView.window convertRectToScreen:NSMakeRect(textBaselineOrigin.x, textBaselineOrigin.y, 0, 0)].origin;
    644 
    645     [getLULookupDefinitionModuleClass() showDefinitionForTerm:popupInfo.attributedString.get() atLocation:textBaselineOrigin options:popupInfo.options.get()];
     632    [_webView _showDictionaryLookupPopup:popupInfo];
    646633}
    647634
     
    683670    RefPtr<Range> selectedRange = rangeForDictionaryLookupForSelection(selection, &options);
    684671    if (selectedRange)
    685         popupInfo = performDictionaryLookupForRange(frame, *selectedRange, options);
     672        popupInfo = performDictionaryLookupForRange(frame, *selectedRange, options, TextIndicatorPresentationTransition::BounceAndCrossfade);
    686673    return popupInfo;
    687674}
    688675
    689 static DictionaryPopupInfo performDictionaryLookupForRange(Frame* frame, Range& range, NSDictionary *options)
     676static DictionaryPopupInfo performDictionaryLookupForRange(Frame* frame, Range& range, NSDictionary *options, TextIndicatorPresentationTransition presentationTransition)
    690677{
    691678    DictionaryPopupInfo popupInfo;
     
    723710
    724711    popupInfo.attributedString = scaledNSAttributedString.get();
     712    popupInfo.textIndicator = TextIndicator::createWithRange(range, presentationTransition);
    725713    return popupInfo;
    726714}
  • branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebHTMLView.mm

    r176662 r176737  
    3535#import "DOMNodeInternal.h"
    3636#import "DOMRangeInternal.h"
     37#import "DictionaryPopupInfo.h"
    3738#import "WebActionMenuController.h"
    3839#import "WebArchive.h"
     
    115116#import <WebCore/Text.h>
    116117#import <WebCore/TextAlternativeWithRange.h>
     118#import <WebCore/TextIndicator.h>
    117119#import <WebCore/TextUndoInsertionMarkupMac.h>
    118120#import <WebCore/WebCoreObjCExtras.h>
     
    56835685    NSRect rect = coreFrame->selection().selectionBounds();
    56845686
    5685     NSDictionary *attributes = [attrString fontAttributesInRange:NSMakeRange(0,1)];
     5687    NSDictionary *attributes = [attrString fontAttributesInRange:NSMakeRange(0, 1)];
    56865688    NSFont *font = [attributes objectForKey:NSFontAttributeName];
    56875689    if (font)
    5688         rect.origin.y += [font ascender];
    5689 
    5690     [self showDefinitionForAttributedString:attrString atPoint:rect.origin];
     5690        rect.origin.y += [font descender];
     5691
     5692    DictionaryPopupInfo info;
     5693    info.attributedString = attrString;
     5694    info.origin = coreFrame->view()->contentsToWindow(enclosingIntRect(rect)).location();
     5695    info.textIndicator = TextIndicator::createWithSelectionInFrame(*coreFrame, TextIndicatorPresentationTransition::BounceAndCrossfade);
     5696    [[self _webView] _showDictionaryLookupPopup:info];
     5697}
     5698
     5699- (void)quickLookWithEvent:(NSEvent *)event
     5700{
     5701    [[self _webView] _setTextIndicator:nullptr fadeOut:NO animationCompletionHandler:[] { }];
     5702    [super quickLookWithEvent:event];
    56915703}
    56925704#endif // !PLATFORM(IOS)
  • branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebView.mm

    r176663 r176737  
    3636#import "DOMNodeInternal.h"
    3737#import "DOMRangeInternal.h"
     38#import "DictionaryPopupInfo.h"
    3839#import "WebAlternativeTextClient.h"
    3940#import "WebApplicationCache.h"
     
    209210#import "WebNSPrintOperationExtras.h"
    210211#import "WebPDFView.h"
     212#import <WebCore/LookupSPI.h>
    211213#import <WebCore/NSViewSPI.h>
     214#import <WebCore/SoftLinking.h>
    212215#import <WebCore/TextIndicator.h>
    213216#import <WebCore/TextIndicatorWindow.h>
     
    291294#if ENABLE(GAMEPAD)
    292295#import <WebCore/HIDGamepadProvider.h>
     296#endif
     297
     298#if PLATFORM(MAC)
     299SOFT_LINK_CONSTANT_MAY_FAIL(Lookup, LUNotificationPopoverWillClose, NSString *)
     300SOFT_LINK_CONSTANT_MAY_FAIL(Lookup, LUTermOptionDisableSearchTermIndicator, NSString *)
    293301#endif
    294302
     
    10251033#if !PLATFORM(IOS)
    10261034    [self _registerDraggedTypes];
     1035
     1036    if (canLoadLUNotificationPopoverWillClose())
     1037        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_dictionaryLookupPopoverWillClose:) name:getLUNotificationPopoverWillClose() object:nil];
    10271038#endif
    10281039
     
    85558566}
    85568567
    8557 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
     8568#if PLATFORM(MAC)
     8569#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
    85588570- (void)prepareForMenu:(NSMenu *)menu withEvent:(NSEvent *)event
    85598571{
     
    85798591    [_private->actionMenuController didCloseMenu:menu withEvent:event];
    85808592}
     8593
     8594- (WebActionMenuController *)_actionMenuController
     8595{
     8596    return _private->actionMenuController;
     8597}
     8598#endif // __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
    85818599
    85828600- (void)_setTextIndicator:(TextIndicator *)textIndicator fadeOut:(BOOL)fadeOut animationCompletionHandler:(std::function<void ()>)completionHandler
     
    85988616}
    85998617
    8600 - (WebActionMenuController *)_actionMenuController
    8601 {
    8602     return _private->actionMenuController;
    8603 }
    8604 #endif // PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
     8618- (void)_showDictionaryLookupPopup:(const DictionaryPopupInfo&)dictionaryPopupInfo
     8619{
     8620    if (!dictionaryPopupInfo.attributedString)
     8621        return;
     8622
     8623    NSPoint textBaselineOrigin = dictionaryPopupInfo.origin;
     8624
     8625    // Convert to screen coordinates.
     8626    textBaselineOrigin = [self.window convertRectToScreen:NSMakeRect(textBaselineOrigin.x, textBaselineOrigin.y, 0, 0)].origin;
     8627
     8628    if (canLoadLUTermOptionDisableSearchTermIndicator()) {
     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.get() fadeOut:NO animationCompletionHandler:[dictionaryPopupInfo, textBaselineOrigin, mutableOptions] {
     8634            [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.get() atLocation:textBaselineOrigin options:mutableOptions.get()];
     8635        }];
     8636    } else
     8637        [getLULookupDefinitionModuleClass() showDefinitionForTerm:dictionaryPopupInfo.attributedString.get() atLocation:textBaselineOrigin options:dictionaryPopupInfo.options.get()];
     8638}
     8639
     8640- (void)_dictionaryLookupPopoverWillClose:(NSNotification *)notification
     8641{
     8642    [self _setTextIndicator:nullptr fadeOut:NO animationCompletionHandler:[] { }];
     8643}
     8644#endif // PLATFORM(MAC)
    86058645
    86068646@end
  • branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebViewInternal.h

    r176662 r176737  
    5959}
    6060
     61struct DictionaryPopupInfo;
    6162class WebSelectionServiceController;
    6263#endif
     
    259260- (void)_setTextIndicator:(WebCore::TextIndicator*)textIndicator fadeOut:(BOOL)fadeOut animationCompletionHandler:(std::function<void ()>)completionHandler;
    260261- (void)_clearTextIndicator;
     262- (void)_showDictionaryLookupPopup:(const DictionaryPopupInfo&)dictionaryPopupInfo;
    261263#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
    262264- (WebActionMenuController *)_actionMenuController;
Note: See TracChangeset for help on using the changeset viewer.