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

Changeset 176684 in webkit


Ignore:
Timestamp:
Dec 2, 2014, 12:36:08 PM (12 years ago)
Author:
Beth Dakin
Message:

Should use standardQuickLookMenuItem for apps that don't implement customizations
https://bugs.webkit.org/show_bug.cgi?id=139193
-and corresponding-
rdar://problem/18944696

Reviewed by Anders Carlsson.

Source/WebCore:

New SPI headers.

  • WebCore.xcodeproj/project.pbxproj:
  • platform/spi/mac/NSMenuSPI.h: Added.
  • platform/spi/mac/QuickLookMacSPI.h: Added.

Source/WebKit/mac:

Use [NSMenuItem standardQuickLookMenuItem].

  • WebView/WebActionMenuController.mm:

(-[WebActionMenuController _defaultMenuItemsForLink]):

Delegate methods to set up the standardQuickLookMenuItem.
(-[WebActionMenuController menuItem:viewAtScreenPoint:]):
(-[WebActionMenuController menuItem:previewItemAtPoint:]):
(-[WebActionMenuController menuItem:preferredEdgeForPoint:]):

Remove all of the old QLPreviewBubble code.
(-[WebActionMenuController _createActionMenuItemForTag:]):
(-[WebActionMenuController _quickLookURLFromActionMenu:]): Deleted.

Source/WebKit2:

New SPI will allow clients to opt-out of the standardQuickLookMenuItem. By
default, opt in.

  • UIProcess/API/Cocoa/WKViewPrivate.h:
  • UIProcess/API/mac/WKView.mm:

(-[WKView _shouldUseStandardQuickLookPreview]):

  • UIProcess/mac/WKActionMenuController.mm:

Use [NSMenuItem standardQuickLookMenuItem] unless the client has requested
otherwise.
(-[WKActionMenuController _defaultMenuItemsForLink]):

Delegate methods to set up the standardQuickLookMenuItem.
(-[WKActionMenuController menuItem:viewAtScreenPoint:]):
(-[WKActionMenuController menuItem:previewItemAtPoint:]):
(-[WKActionMenuController menuItem:preferredEdgeForPoint:]):

Location:
trunk/Source
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r176683 r176684  
     12014-12-02  Beth Dakin  <bdakin@apple.com>
     2
     3        Should use standardQuickLookMenuItem for apps that don't implement customizations
     4        https://bugs.webkit.org/show_bug.cgi?id=139193
     5        -and corresponding-
     6        rdar://problem/18944696
     7
     8        Reviewed by Anders Carlsson.
     9
     10        New SPI headers.
     11        * WebCore.xcodeproj/project.pbxproj:
     12        * platform/spi/mac/NSMenuSPI.h: Added.
     13        * platform/spi/mac/QuickLookMacSPI.h: Added.
     14
    1152014-12-02  Gavin Barraclough  <barraclough@apple.com>
    216
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r176683 r176684  
    32663266                9370918D1416D86B00477333 /* textAreaResizeCorner@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 9370918C1416D86B00477333 /* textAreaResizeCorner@2x.png */; };
    32673267                9377ABA015DEFEEF0031FD04 /* Pagination.h in Headers */ = {isa = PBXBuildFile; fileRef = 9377AB9F15DEFEEF0031FD04 /* Pagination.h */; settings = {ATTRIBUTES = (Private, ); }; };
     3268                937F4CCC1A2D48C100BB39F5 /* QuickLookMacSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 937F4CCB1A2D48C100BB39F5 /* QuickLookMacSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
     3269                937F4CCE1A2D4B0100BB39F5 /* NSMenuSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 937F4CCD1A2D4B0100BB39F5 /* NSMenuSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
    32683270                937FF3D51A1012D6008EBA31 /* DictionaryLookup.h in Headers */ = {isa = PBXBuildFile; fileRef = 937FF3D41A1012D6008EBA31 /* DictionaryLookup.h */; settings = {ATTRIBUTES = (Private, ); }; };
    32693271                937FF3D71A10131B008EBA31 /* DictionaryLookup.mm in Sources */ = {isa = PBXBuildFile; fileRef = 937FF3D61A10131B008EBA31 /* DictionaryLookup.mm */; };
     
    1043610438                9370918C1416D86B00477333 /* textAreaResizeCorner@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "textAreaResizeCorner@2x.png"; sourceTree = "<group>"; };
    1043710439                9377AB9F15DEFEEF0031FD04 /* Pagination.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Pagination.h; sourceTree = "<group>"; };
     10440                937F4CCB1A2D48C100BB39F5 /* QuickLookMacSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QuickLookMacSPI.h; sourceTree = "<group>"; };
     10441                937F4CCD1A2D4B0100BB39F5 /* NSMenuSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSMenuSPI.h; sourceTree = "<group>"; };
    1043810442                937FF3D41A1012D6008EBA31 /* DictionaryLookup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DictionaryLookup.h; sourceTree = "<group>"; };
    1043910443                937FF3D61A10131B008EBA31 /* DictionaryLookup.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DictionaryLookup.mm; sourceTree = "<group>"; };
     
    1761117615                                2D413F601A187A3F0041A521 /* LookupSPI.h */,
    1761217616                                1C6466271A12C3F90094603C /* NSFontSPI.h */,
     17617                                937F4CCD1A2D4B0100BB39F5 /* NSMenuSPI.h */,
    1761317618                                2DCB837719F99BBA00A7FBE4 /* NSSharingServicePickerSPI.h */,
    1761417619                                2DCB837819F99BBA00A7FBE4 /* NSSharingServiceSPI.h */,
    1761517620                                9348428119F1A9190009D5AE /* NSViewSPI.h */,
     17621                                937F4CCB1A2D48C100BB39F5 /* QuickLookMacSPI.h */,
    1761617622                        );
    1761717623                        path = mac;
     
    2342923435                                1A8F6BBD0DB55CDC001DB794 /* ApplicationCache.h in Headers */,
    2343023436                                1A8F6BBF0DB55CDC001DB794 /* ApplicationCacheGroup.h in Headers */,
     23437                                937F4CCC1A2D48C100BB39F5 /* QuickLookMacSPI.h in Headers */,
    2343123438                                24F54EAD101FE914000AE741 /* ApplicationCacheHost.h in Headers */,
    2343223439                                1A8F6BC10DB55CDC001DB794 /* ApplicationCacheResource.h in Headers */,
     
    2607626083                                C5A1EA7D152BCF08004D00B6 /* SimplifyMarkupCommand.h in Headers */,
    2607726084                                31741AAD16636609008A5B7E /* SimulatedClickOptions.h in Headers */,
     26085                                937F4CCE1A2D4B0100BB39F5 /* NSMenuSPI.h in Headers */,
    2607826086                                FD00D7A514A3F61900734011 /* SincResampler.h in Headers */,
    2607926087                                51327D6011A33A2B004F9D65 /* SinkDocument.h in Headers */,
  • trunk/Source/WebKit/mac/ChangeLog

    r176681 r176684  
     12014-12-02  Beth Dakin  <bdakin@apple.com>
     2
     3        Should use standardQuickLookMenuItem for apps that don't implement customizations
     4        https://bugs.webkit.org/show_bug.cgi?id=139193
     5        -and corresponding-
     6        rdar://problem/18944696
     7
     8        Reviewed by Anders Carlsson.
     9
     10        Use [NSMenuItem standardQuickLookMenuItem].
     11        * WebView/WebActionMenuController.mm:
     12        (-[WebActionMenuController _defaultMenuItemsForLink]):
     13
     14        Delegate methods to set up the standardQuickLookMenuItem.
     15        (-[WebActionMenuController menuItem:viewAtScreenPoint:]):
     16        (-[WebActionMenuController menuItem:previewItemAtPoint:]):
     17        (-[WebActionMenuController menuItem:preferredEdgeForPoint:]):
     18
     19        Remove all of the old QLPreviewBubble code.
     20        (-[WebActionMenuController _createActionMenuItemForTag:]):
     21        (-[WebActionMenuController _quickLookURLFromActionMenu:]): Deleted.
     22
    1232014-12-02  Timothy Horton  <timothy_horton@apple.com>
    224
  • trunk/Source/WebKit/mac/WebView/WebActionMenuController.mm

    r176680 r176684  
    5555#import <WebCore/HTMLConverter.h>
    5656#import <WebCore/LookupSPI.h>
     57#import <WebCore/NSMenuSPI.h>
    5758#import <WebCore/NSSharingServicePickerSPI.h>
    5859#import <WebCore/NSSharingServiceSPI.h>
    5960#import <WebCore/NSViewSPI.h>
    6061#import <WebCore/Page.h>
     62#import <WebCore/QuickLookMacSPI.h>
    6163#import <WebCore/Range.h>
    6264#import <WebCore/RenderElement.h>
     
    7173
    7274SOFT_LINK_FRAMEWORK_IN_UMBRELLA(Quartz, QuickLookUI)
    73 SOFT_LINK_CLASS(QuickLookUI, QLPreviewBubble)
     75SOFT_LINK_CLASS(QuickLookUI, QLPreviewMenuItem)
    7476
    7577SOFT_LINK_FRAMEWORK_IN_UMBRELLA(Quartz, ImageKit)
    7678SOFT_LINK_CLASS(ImageKit, IKSlideshow)
    7779
    78 @class QLPreviewBubble;
    79 @interface NSObject (WKQLPreviewBubbleDetails)
    80 @property (copy) NSArray * controls;
    81 @property NSSize maximumSize;
    82 @property NSRectEdge preferredEdge;
    83 @property (retain) IBOutlet NSWindow* parentWindow;
    84 - (void)showPreviewItem:(id)previewItem itemFrame:(NSRect)frame;
    85 - (void)setAutomaticallyCloseWithMask:(NSEventMask)autocloseMask filterMask:(NSEventMask)filterMask block:(void (^)(void))block;
     80@interface WebActionMenuController () <QLPreviewMenuItemDelegate>
    8681@end
    8782
     
    283278}
    284279
    285 - (void)_quickLookURLFromActionMenu:(id)sender
    286 {
    287     if (!_webView)
    288         return;
    289 
    290     NSURL *url = _hitTestResult.absoluteLinkURL();
    291     if (!url)
    292         return;
    293 
    294     Node* node = _hitTestResult.innerNode();
    295     if (!node)
    296         return;
    297 
    298     NSRect itemFrame = elementBoundingBoxInWindowCoordinatesFromNode(node);
    299     NSSize maximumPreviewSize = NSMakeSize(_webView.bounds.size.width * 0.75, _webView.bounds.size.height * 0.75);
    300 
    301     RetainPtr<QLPreviewBubble> bubble = adoptNS([[getQLPreviewBubbleClass() alloc] init]);
    302     [bubble setParentWindow:_webView.window];
    303     [bubble setMaximumSize:maximumPreviewSize];
    304     [bubble setPreferredEdge:NSMaxYEdge];
    305     [bubble setControls:@[ ]];
    306     NSEventMask filterMask = NSAnyEventMask & ~(NSAppKitDefinedMask | NSSystemDefinedMask | NSApplicationDefinedMask | NSMouseEnteredMask | NSMouseExitedMask);
    307     NSEventMask autocloseMask = NSLeftMouseDownMask | NSRightMouseDownMask | NSKeyDownMask;
    308     [bubble setAutomaticallyCloseWithMask:autocloseMask filterMask:filterMask block:[bubble] {
    309         [bubble close];
    310     }];
    311     [bubble showPreviewItem:url itemFrame:itemFrame];
    312 }
    313 
    314280- (NSArray *)_defaultMenuItemsForLink
    315281{
    316282    RetainPtr<NSMenuItem> openLinkItem = [self _createActionMenuItemForTag:WebActionMenuItemTagOpenLinkInDefaultBrowser];
    317     RetainPtr<NSMenuItem> previewLinkItem = [self _createActionMenuItemForTag:WebActionMenuItemTagPreviewLink];
     283
     284    RetainPtr<QLPreviewMenuItem> previewLinkItem = [NSMenuItem standardQuickLookMenuItem];
     285    [previewLinkItem setPreviewStyle:QLPreviewStylePopover];
     286    [previewLinkItem setDelegate:self];
     287
    318288    RetainPtr<NSMenuItem> readingListItem = [self _createActionMenuItemForTag:WebActionMenuItemTagAddLinkToSafariReadingList];
    319289
     
    749719}
    750720
     721#pragma mark QLPreviewMenuItemDelegate implementation
     722
     723- (NSView *)menuItem:(NSMenuItem *)menuItem viewAtScreenPoint:(NSPoint)screenPoint
     724{
     725    return _webView;
     726}
     727
     728- (id<QLPreviewItem>)menuItem:(NSMenuItem *)menuItem previewItemAtPoint:(NSPoint)point
     729{
     730    if (!_webView)
     731        return nil;
     732
     733    return _hitTestResult.absoluteLinkURL();
     734}
     735
     736- (NSRectEdge)menuItem:(NSMenuItem *)menuItem preferredEdgeForPoint:(NSPoint)point
     737{
     738    return NSMaxYEdge;
     739}
     740
    751741#pragma mark Menu Items
    752742
     
    763753        title = WEB_UI_STRING_KEY("Open", "Open (action menu item)", "action menu item");
    764754        image = [NSImage imageNamed:@"NSActionMenuOpenInNewWindow"];
    765         break;
    766 
    767     case WebActionMenuItemTagPreviewLink:
    768         selector = @selector(_quickLookURLFromActionMenu:);
    769         title = WEB_UI_STRING_KEY("Preview", "Preview (action menu item)", "action menu item");
    770         image = [NSImage imageNamed:@"NSActionMenuQuickLook"];
    771755        break;
    772756
  • trunk/Source/WebKit2/ChangeLog

    r176678 r176684  
     12014-12-02  Beth Dakin  <bdakin@apple.com>
     2
     3        Should use standardQuickLookMenuItem for apps that don't implement customizations
     4        https://bugs.webkit.org/show_bug.cgi?id=139193
     5        -and corresponding-
     6        rdar://problem/18944696
     7
     8        Reviewed by Anders Carlsson.
     9
     10        New SPI will allow clients to opt-out of the standardQuickLookMenuItem. By
     11        default, opt in.
     12        * UIProcess/API/Cocoa/WKViewPrivate.h:
     13        * UIProcess/API/mac/WKView.mm:
     14        (-[WKView _shouldUseStandardQuickLookPreview]):
     15        * UIProcess/mac/WKActionMenuController.mm:
     16
     17        Use [NSMenuItem standardQuickLookMenuItem] unless the client has requested
     18        otherwise.
     19        (-[WKActionMenuController _defaultMenuItemsForLink]):
     20
     21        Delegate methods to set up the standardQuickLookMenuItem.
     22        (-[WKActionMenuController menuItem:viewAtScreenPoint:]):
     23        (-[WKActionMenuController menuItem:previewItemAtPoint:]):
     24        (-[WKActionMenuController menuItem:preferredEdgeForPoint:]):
     25
    1262014-12-02  Tim Horton  <timothy_horton@apple.com>
    227
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h

    r176613 r176684  
    128128- (void)_finishPreviewingURL:(NSURL *)url withPreviewView:(NSView *)previewView;
    129129- (void)_handleClickInPreviewView:(NSView *)previewView URL:(NSURL *)url;
     130- (BOOL)_shouldUseStandardQuickLookPreview;
    130131
    131132- (void)_dismissActionMenuPopovers;
  • trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm

    r176678 r176684  
    42474247}
    42484248
     4249- (BOOL)_shouldUseStandardQuickLookPreview
     4250{
     4251    return YES;
     4252}
     4253
    42494254#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
    42504255
  • trunk/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm

    r176613 r176684  
    4646#import <WebCore/LocalizedStrings.h>
    4747#import <WebCore/LookupSPI.h>
     48#import <WebCore/NSMenuSPI.h>
    4849#import <WebCore/NSSharingServiceSPI.h>
    4950#import <WebCore/NSSharingServicePickerSPI.h>
    5051#import <WebCore/NSViewSPI.h>
     52#import <WebCore/QuickLookMacSPI.h>
    5153#import <WebCore/SoftLinking.h>
    5254#import <WebCore/TextIndicator.h>
    5355#import <WebCore/URL.h>
    5456
     57SOFT_LINK_FRAMEWORK_IN_UMBRELLA(Quartz, QuickLookUI)
     58SOFT_LINK_CLASS(QuickLookUI, QLPreviewMenuItem)
     59
    5560SOFT_LINK_FRAMEWORK_IN_UMBRELLA(Quartz, ImageKit)
    5661SOFT_LINK_CLASS(ImageKit, IKSlideshow)
     
    5964using namespace WebKit;
    6065
    61 @interface WKActionMenuController () <NSSharingServiceDelegate, NSSharingServicePickerDelegate, NSPopoverDelegate>
     66@interface WKActionMenuController () <NSSharingServiceDelegate, NSSharingServicePickerDelegate, NSPopoverDelegate, QLPreviewMenuItemDelegate>
    6267- (void)_updateActionMenuItems;
    6368- (BOOL)_canAddMediaToPhotos;
     
    389394{
    390395    RetainPtr<NSMenuItem> openLinkItem = [self _createActionMenuItemForTag:kWKContextActionItemTagOpenLinkInDefaultBrowser];
     396
     397    BOOL shouldUseStandardQuickLookPreview = [_wkView _shouldUseStandardQuickLookPreview];
     398    RetainPtr<NSMenuItem> previewLinkItem;
     399    RetainPtr<QLPreviewMenuItem> qlPreviewLinkItem;
     400    if (shouldUseStandardQuickLookPreview) {
     401        qlPreviewLinkItem = [NSMenuItem standardQuickLookMenuItem];
     402        [qlPreviewLinkItem setPreviewStyle:QLPreviewStylePopover];
     403        [qlPreviewLinkItem setDelegate:self];
     404    } else {
    391405#if WK_API_ENABLED
    392     RetainPtr<NSMenuItem> previewLinkItem = [self _createActionMenuItemForTag:kWKContextActionItemTagPreviewLink];
     406        previewLinkItem = [self _createActionMenuItemForTag:kWKContextActionItemTagPreviewLink];
    393407#else
    394     RetainPtr<NSMenuItem> previewLinkItem = [NSMenuItem separatorItem];
     408        previewLinkItem = [NSMenuItem separatorItem];
    395409#endif
     410    }
     411
    396412    RetainPtr<NSMenuItem> readingListItem = [self _createActionMenuItemForTag:kWKContextActionItemTagAddLinkToSafariReadingList];
    397413
    398     return @[ openLinkItem.get(), previewLinkItem.get(), [NSMenuItem separatorItem], readingListItem.get() ];
     414    return @[ openLinkItem.get(), shouldUseStandardQuickLookPreview ? qlPreviewLinkItem.get() : previewLinkItem.get(), [NSMenuItem separatorItem], readingListItem.get() ];
    399415}
    400416
     
    932948}
    933949
     950#pragma mark QLPreviewMenuItemDelegate implementation
     951
     952- (NSView *)menuItem:(NSMenuItem *)menuItem viewAtScreenPoint:(NSPoint)screenPoint
     953{
     954    return _wkView;
     955}
     956
     957- (id<QLPreviewItem>)menuItem:(NSMenuItem *)menuItem previewItemAtPoint:(NSPoint)point
     958{
     959    if (!_wkView)
     960        return nil;
     961
     962    RefPtr<WebHitTestResult> hitTestResult = [self _webHitTestResult];
     963    return [NSURL _web_URLWithWTFString:hitTestResult->absoluteLinkURL()];
     964}
     965
     966- (NSRectEdge)menuItem:(NSMenuItem *)menuItem preferredEdgeForPoint:(NSPoint)point
     967{
     968    return NSMaxYEdge;
     969}
     970
    934971#pragma mark Menu Items
    935972
Note: See TracChangeset for help on using the changeset viewer.