Title: [176740] branches/safari-600.3-branch/Source

Diff

Modified: branches/safari-600.3-branch/Source/WebCore/ChangeLog (176739 => 176740)


--- branches/safari-600.3-branch/Source/WebCore/ChangeLog	2014-12-03 20:30:18 UTC (rev 176739)
+++ branches/safari-600.3-branch/Source/WebCore/ChangeLog	2014-12-03 20:35:24 UTC (rev 176740)
@@ -1,5 +1,23 @@
 2014-12-03  Dana Burkart  <dburk...@apple.com>
 
+        Merge r176684. <rdar://problem/18944696>
+
+    2014-12-02  Beth Dakin  <bda...@apple.com>
+
+            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.
+
+            New SPI headers.
+            * WebCore.xcodeproj/project.pbxproj:
+            * platform/spi/mac/NSMenuSPI.h: Added.
+            * platform/spi/mac/QuickLookMacSPI.h: Added.
+
+2014-12-03  Dana Burkart  <dburk...@apple.com>
+
         Fix merge-related build failure.
 
         * rendering/RenderBlock.cpp:

Modified: branches/safari-600.3-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj (176739 => 176740)


--- branches/safari-600.3-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2014-12-03 20:30:18 UTC (rev 176739)
+++ branches/safari-600.3-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2014-12-03 20:35:24 UTC (rev 176740)
@@ -3286,6 +3286,8 @@
 		9362640B0DE1137D009D5A00 /* CSSReflectionDirection.h in Headers */ = {isa = PBXBuildFile; fileRef = 9362640A0DE1137D009D5A00 /* CSSReflectionDirection.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		9370918D1416D86B00477333 /* textarearesizecor...@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 9370918C1416D86B00477333 /* textarearesizecor...@2x.png */; };
 		9377ABA015DEFEEF0031FD04 /* Pagination.h in Headers */ = {isa = PBXBuildFile; fileRef = 9377AB9F15DEFEEF0031FD04 /* Pagination.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		937F4CCC1A2D48C100BB39F5 /* QuickLookMacSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 937F4CCB1A2D48C100BB39F5 /* QuickLookMacSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		937F4CCE1A2D4B0100BB39F5 /* NSMenuSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 937F4CCD1A2D4B0100BB39F5 /* NSMenuSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		937FF3D51A1012D6008EBA31 /* DictionaryLookup.h in Headers */ = {isa = PBXBuildFile; fileRef = 937FF3D41A1012D6008EBA31 /* DictionaryLookup.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		937FF3D71A10131B008EBA31 /* DictionaryLookup.mm in Sources */ = {isa = PBXBuildFile; fileRef = 937FF3D61A10131B008EBA31 /* DictionaryLookup.mm */; };
 		9380F47309A11AB4001FDB34 /* Widget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9380F47109A11AB4001FDB34 /* Widget.cpp */; };
@@ -10453,6 +10455,8 @@
 		936DD03A09CEAC270056AE8C /* Range.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Range.idl; sourceTree = "<group>"; };
 		9370918C1416D86B00477333 /* textarearesizecor...@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "textarearesizecor...@2x.png"; sourceTree = "<group>"; };
 		9377AB9F15DEFEEF0031FD04 /* Pagination.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Pagination.h; sourceTree = "<group>"; };
+		937F4CCB1A2D48C100BB39F5 /* QuickLookMacSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QuickLookMacSPI.h; sourceTree = "<group>"; };
+		937F4CCD1A2D4B0100BB39F5 /* NSMenuSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSMenuSPI.h; sourceTree = "<group>"; };
 		937FF3D41A1012D6008EBA31 /* DictionaryLookup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DictionaryLookup.h; sourceTree = "<group>"; };
 		937FF3D61A10131B008EBA31 /* DictionaryLookup.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DictionaryLookup.mm; sourceTree = "<group>"; };
 		9380F47109A11AB4001FDB34 /* Widget.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Widget.cpp; sourceTree = "<group>"; };
@@ -17648,9 +17652,11 @@
 			children = (
 				2D59F1BE1A0044C6001F3D29 /* DataDetectorsSPI.h */,
 				2D413F601A187A3F0041A521 /* LookupSPI.h */,
+				937F4CCD1A2D4B0100BB39F5 /* NSMenuSPI.h */,
 				2DCB837719F99BBA00A7FBE4 /* NSSharingServicePickerSPI.h */,
 				2DCB837819F99BBA00A7FBE4 /* NSSharingServiceSPI.h */,
 				9348428119F1A9190009D5AE /* NSViewSPI.h */,
+				937F4CCB1A2D48C100BB39F5 /* QuickLookMacSPI.h */,
 			);
 			path = mac;
 			sourceTree = "<group>";
@@ -23442,6 +23448,7 @@
 				93309DD7099E64920056E581 /* AppendNodeCommand.h in Headers */,
 				1A8F6BBD0DB55CDC001DB794 /* ApplicationCache.h in Headers */,
 				1A8F6BBF0DB55CDC001DB794 /* ApplicationCacheGroup.h in Headers */,
+				937F4CCC1A2D48C100BB39F5 /* QuickLookMacSPI.h in Headers */,
 				24F54EAD101FE914000AE741 /* ApplicationCacheHost.h in Headers */,
 				1A8F6BC10DB55CDC001DB794 /* ApplicationCacheResource.h in Headers */,
 				1A2AAC590DC2A3B100A20D9A /* ApplicationCacheStorage.h in Headers */,
@@ -26057,6 +26064,7 @@
 				E4E9B1191810916F003ACCDF /* SimpleLineLayoutResolver.h in Headers */,
 				C5A1EA7D152BCF08004D00B6 /* SimplifyMarkupCommand.h in Headers */,
 				31741AAD16636609008A5B7E /* SimulatedClickOptions.h in Headers */,
+				937F4CCE1A2D4B0100BB39F5 /* NSMenuSPI.h in Headers */,
 				FD00D7A514A3F61900734011 /* SincResampler.h in Headers */,
 				51327D6011A33A2B004F9D65 /* SinkDocument.h in Headers */,
 				49E911CD0EF86D47009D0CAF /* SkewTransformOperation.h in Headers */,

Added: branches/safari-600.3-branch/Source/WebCore/platform/spi/mac/NSMenuSPI.h (0 => 176740)


--- branches/safari-600.3-branch/Source/WebCore/platform/spi/mac/NSMenuSPI.h	                        (rev 0)
+++ branches/safari-600.3-branch/Source/WebCore/platform/spi/mac/NSMenuSPI.h	2014-12-03 20:35:24 UTC (rev 176740)
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "QuickLookMacSPI.h"
+
+#if USE(APPLE_INTERNAL_SDK) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101002
+
+#import <AppKit/NSMenu_Private.h>
+
+#else
+
+#import <AppKit/NSMenu.h>
+
+@interface NSMenuItem (Private)
++ (QLPreviewMenuItem *)standardQuickLookMenuItem;
+@end
+
+#endif

Added: branches/safari-600.3-branch/Source/WebCore/platform/spi/mac/QuickLookMacSPI.h (0 => 176740)


--- branches/safari-600.3-branch/Source/WebCore/platform/spi/mac/QuickLookMacSPI.h	                        (rev 0)
+++ branches/safari-600.3-branch/Source/WebCore/platform/spi/mac/QuickLookMacSPI.h	2014-12-03 20:35:24 UTC (rev 176740)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if USE(APPLE_INTERNAL_SDK)
+
+#import <QuickLookUI/QLPreviewItem.h>
+#import <QuickLookUI/QLPreviewMenuItem.h>
+
+#else
+
+@protocol QLPreviewItem <NSObject>
+@end
+
+@protocol QLPreviewMenuItemDelegate <NSObject>
+@optional
+
+- (NSView *)menuItem:(NSMenuItem *)menuItem viewAtScreenPoint:(NSPoint)screenPoint;
+- (id<QLPreviewItem>)menuItem:(NSMenuItem *)menuItem previewItemAtPoint:(NSPoint)point;
+- (NSRectEdge)menuItem:(NSMenuItem *)menuItem preferredEdgeForPoint:(NSPoint)point;
+
+@end
+
+@interface QLPreviewMenuItem : NSObject
+@end
+
+@interface QLPreviewMenuItem (Details)
+typedef NS_ENUM(NSInteger, QLPreviewStyle) {
+    QLPreviewStyleStandaloneWindow,
+    QLPreviewStylePopover
+};
+
+@property (assign) id<QLPreviewMenuItemDelegate> delegate;
+@property QLPreviewStyle previewStyle;
+@end
+
+#endif

Modified: branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog (176739 => 176740)


--- branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog	2014-12-03 20:30:18 UTC (rev 176739)
+++ branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog	2014-12-03 20:35:24 UTC (rev 176740)
@@ -1,5 +1,31 @@
 2014-12-03  Dana Burkart  <dburk...@apple.com>
 
+        Merge r176684. <rdar://problem/18944696>
+
+    2014-12-02  Beth Dakin  <bda...@apple.com>
+
+            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.
+
+            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.
+
+2014-12-03  Dana Burkart  <dburk...@apple.com>
+
         Merge r176681. <rdar://problem/19067172>
 
     2014-12-02  Timothy Horton  <timothy_hor...@apple.com>

Modified: branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebActionMenuController.mm (176739 => 176740)


--- branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebActionMenuController.mm	2014-12-03 20:30:18 UTC (rev 176739)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebActionMenuController.mm	2014-12-03 20:35:24 UTC (rev 176740)
@@ -55,10 +55,12 @@
 #import <WebCore/HTMLConverter.h>
 #import <WebCore/LocalizedStrings.h>
 #import <WebCore/LookupSPI.h>
+#import <WebCore/NSMenuSPI.h>
 #import <WebCore/NSSharingServicePickerSPI.h>
 #import <WebCore/NSSharingServiceSPI.h>
 #import <WebCore/NSViewSPI.h>
 #import <WebCore/Page.h>
+#import <WebCore/QuickLookMacSPI.h>
 #import <WebCore/Range.h>
 #import <WebCore/RenderElement.h>
 #import <WebCore/RenderObject.h>
@@ -71,19 +73,12 @@
 #import <objc/objc.h>
 
 SOFT_LINK_FRAMEWORK_IN_UMBRELLA(Quartz, QuickLookUI)
-SOFT_LINK_CLASS(QuickLookUI, QLPreviewBubble)
+SOFT_LINK_CLASS(QuickLookUI, QLPreviewMenuItem)
 
 SOFT_LINK_FRAMEWORK_IN_UMBRELLA(Quartz, ImageKit)
 SOFT_LINK_CLASS(ImageKit, IKSlideshow)
 
-@class QLPreviewBubble;
-@interface NSObject (WKQLPreviewBubbleDetails)
-@property (copy) NSArray * controls;
-@property NSSize maximumSize;
-@property NSRectEdge preferredEdge;
-@property (retain) IBOutlet NSWindow* parentWindow;
-- (void)showPreviewItem:(id)previewItem itemFrame:(NSRect)frame;
-- (void)setAutomaticallyCloseWithMask:(NSEventMask)autocloseMask filterMask:(NSEventMask)filterMask block:(void (^)(void))block;
+@interface WebActionMenuController () <QLPreviewMenuItemDelegate>
 @end
 
 using namespace WebCore;
@@ -283,39 +278,14 @@
     return view->contentsToWindow(node->pixelSnappedBoundingBox());
 }
 
-- (void)_quickLookURLFromActionMenu:(id)sender
-{
-    if (!_webView)
-        return;
-
-    NSURL *url = ""
-    if (!url)
-        return;
-
-    Node* node = _hitTestResult.innerNode();
-    if (!node)
-        return;
-
-    NSRect itemFrame = elementBoundingBoxInWindowCoordinatesFromNode(node);
-    NSSize maximumPreviewSize = NSMakeSize(_webView.bounds.size.width * 0.75, _webView.bounds.size.height * 0.75);
-
-    RetainPtr<QLPreviewBubble> bubble = adoptNS([[getQLPreviewBubbleClass() alloc] init]);
-    [bubble setParentWindow:_webView.window];
-    [bubble setMaximumSize:maximumPreviewSize];
-    [bubble setPreferredEdge:NSMaxYEdge];
-    [bubble setControls:@[ ]];
-    NSEventMask filterMask = NSAnyEventMask & ~(NSAppKitDefinedMask | NSSystemDefinedMask | NSApplicationDefinedMask | NSMouseEnteredMask | NSMouseExitedMask);
-    NSEventMask autocloseMask = NSLeftMouseDownMask | NSRightMouseDownMask | NSKeyDownMask;
-    [bubble setAutomaticallyCloseWithMask:autocloseMask filterMask:filterMask block:[bubble] {
-        [bubble close];
-    }];
-    [bubble showPreviewItem:url itemFrame:itemFrame];
-}
-
 - (NSArray *)_defaultMenuItemsForLink
 {
     RetainPtr<NSMenuItem> openLinkItem = [self _createActionMenuItemForTag:WebActionMenuItemTagOpenLinkInDefaultBrowser];
-    RetainPtr<NSMenuItem> previewLinkItem = [self _createActionMenuItemForTag:WebActionMenuItemTagPreviewLink];
+
+    RetainPtr<QLPreviewMenuItem> previewLinkItem = [NSMenuItem standardQuickLookMenuItem];
+    [previewLinkItem setPreviewStyle:QLPreviewStylePopover];
+    [previewLinkItem setDelegate:self];
+
     RetainPtr<NSMenuItem> readingListItem = [self _createActionMenuItemForTag:WebActionMenuItemTagAddLinkToSafariReadingList];
 
     return @[ openLinkItem.get(), previewLinkItem.get(), [NSMenuItem separatorItem], readingListItem.get() ];
@@ -749,6 +719,26 @@
     return _webView.window;
 }
 
+#pragma mark QLPreviewMenuItemDelegate implementation
+
+- (NSView *)menuItem:(NSMenuItem *)menuItem viewAtScreenPoint:(NSPoint)screenPoint
+{
+    return _webView;
+}
+
+- (id<QLPreviewItem>)menuItem:(NSMenuItem *)menuItem previewItemAtPoint:(NSPoint)point
+{
+    if (!_webView)
+        return nil;
+
+    return _hitTestResult.absoluteLinkURL();
+}
+
+- (NSRectEdge)menuItem:(NSMenuItem *)menuItem preferredEdgeForPoint:(NSPoint)point
+{
+    return NSMaxYEdge;
+}
+
 #pragma mark Menu Items
 
 - (RetainPtr<NSMenuItem>)_createActionMenuItemForTag:(uint32_t)tag
@@ -765,12 +755,6 @@
         image = [NSImage imageNamed:@"NSActionMenuOpenInNewWindow"];
         break;
 
-    case WebActionMenuItemTagPreviewLink:
-        selector = @selector(_quickLookURLFromActionMenu:);
-        title = WEB_UI_STRING_KEY("Preview", "Preview (action menu item)", "action menu item");
-        image = [NSImage imageNamed:@"NSActionMenuQuickLook"];
-        break;
-
     case WebActionMenuItemTagAddLinkToSafariReadingList:
         selector = @selector(_addToReadingListFromActionMenu:);
         title = WEB_UI_STRING_KEY("Add to Reading List", "Add to Reading List (action menu item)", "action menu item");

Modified: branches/safari-600.3-branch/Source/WebKit2/ChangeLog (176739 => 176740)


--- branches/safari-600.3-branch/Source/WebKit2/ChangeLog	2014-12-03 20:30:18 UTC (rev 176739)
+++ branches/safari-600.3-branch/Source/WebKit2/ChangeLog	2014-12-03 20:35:24 UTC (rev 176740)
@@ -1,5 +1,34 @@
 2014-12-03  Dana Burkart  <dburk...@apple.com>
 
+        Merge r176684. <rdar://problem/18944696>
+
+    2014-12-02  Beth Dakin  <bda...@apple.com>
+
+            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.
+
+            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:]):
+
+2014-12-03  Dana Burkart  <dburk...@apple.com>
+
         Merge r176678. <rdar://problem/19072236>
 
     2014-12-02  Tim Horton  <timothy_hor...@apple.com>

Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h (176739 => 176740)


--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h	2014-12-03 20:30:18 UTC (rev 176739)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h	2014-12-03 20:35:24 UTC (rev 176740)
@@ -126,6 +126,7 @@
 - (void)_setPreviewTitle:(NSString *)previewTitle;
 - (void)_finishPreviewingURL:(NSURL *)url withPreviewView:(NSView *)previewView;
 - (void)_handleClickInPreviewView:(NSView *)previewView URL:(NSURL *)url;
+- (BOOL)_shouldUseStandardQuickLookPreview;
 #endif
 
 - (void)_dismissActionMenuPopovers;

Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm (176739 => 176740)


--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm	2014-12-03 20:30:18 UTC (rev 176739)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm	2014-12-03 20:35:24 UTC (rev 176740)
@@ -4241,6 +4241,11 @@
     [[NSWorkspace sharedWorkspace] openURL:url];
 }
 
+- (BOOL)_shouldUseStandardQuickLookPreview
+{
+    return YES;
+}
+
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
 
 - (void)_setAutomaticallyAdjustsContentInsets:(BOOL)automaticallyAdjustsContentInsets

Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm (176739 => 176740)


--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm	2014-12-03 20:30:18 UTC (rev 176739)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm	2014-12-03 20:35:24 UTC (rev 176740)
@@ -45,20 +45,25 @@
 #import <WebCore/GeometryUtilities.h>
 #import <WebCore/LocalizedStrings.h>
 #import <WebCore/LookupSPI.h>
+#import <WebCore/NSMenuSPI.h>
 #import <WebCore/NSSharingServiceSPI.h>
 #import <WebCore/NSSharingServicePickerSPI.h>
 #import <WebCore/NSViewSPI.h>
+#import <WebCore/QuickLookMacSPI.h>
 #import <WebCore/SoftLinking.h>
 #import <WebCore/TextIndicator.h>
 #import <WebCore/URL.h>
 
+SOFT_LINK_FRAMEWORK_IN_UMBRELLA(Quartz, QuickLookUI)
+SOFT_LINK_CLASS(QuickLookUI, QLPreviewMenuItem)
+
 SOFT_LINK_FRAMEWORK_IN_UMBRELLA(Quartz, ImageKit)
 SOFT_LINK_CLASS(ImageKit, IKSlideshow)
 
 using namespace WebCore;
 using namespace WebKit;
 
-@interface WKActionMenuController () <NSSharingServiceDelegate, NSSharingServicePickerDelegate, NSPopoverDelegate>
+@interface WKActionMenuController () <NSSharingServiceDelegate, NSSharingServicePickerDelegate, NSPopoverDelegate, QLPreviewMenuItemDelegate>
 - (void)_updateActionMenuItems;
 - (BOOL)_canAddMediaToPhotos;
 - (void)_showTextIndicator;
@@ -388,14 +393,25 @@
 - (NSArray *)_defaultMenuItemsForLink
 {
     RetainPtr<NSMenuItem> openLinkItem = [self _createActionMenuItemForTag:kWKContextActionItemTagOpenLinkInDefaultBrowser];
+
+    BOOL shouldUseStandardQuickLookPreview = [_wkView _shouldUseStandardQuickLookPreview];
+    RetainPtr<NSMenuItem> previewLinkItem;
+    RetainPtr<QLPreviewMenuItem> qlPreviewLinkItem;
+    if (shouldUseStandardQuickLookPreview) {
+        qlPreviewLinkItem = [NSMenuItem standardQuickLookMenuItem];
+        [qlPreviewLinkItem setPreviewStyle:QLPreviewStylePopover];
+        [qlPreviewLinkItem setDelegate:self];
+    } else {
 #if WK_API_ENABLED
-    RetainPtr<NSMenuItem> previewLinkItem = [self _createActionMenuItemForTag:kWKContextActionItemTagPreviewLink];
+        previewLinkItem = [self _createActionMenuItemForTag:kWKContextActionItemTagPreviewLink];
 #else
-    RetainPtr<NSMenuItem> previewLinkItem = [NSMenuItem separatorItem];
+        previewLinkItem = [NSMenuItem separatorItem];
 #endif
+    }
+
     RetainPtr<NSMenuItem> readingListItem = [self _createActionMenuItemForTag:kWKContextActionItemTagAddLinkToSafariReadingList];
 
-    return @[ openLinkItem.get(), previewLinkItem.get(), [NSMenuItem separatorItem], readingListItem.get() ];
+    return @[ openLinkItem.get(), shouldUseStandardQuickLookPreview ? qlPreviewLinkItem.get() : previewLinkItem.get(), [NSMenuItem separatorItem], readingListItem.get() ];
 }
 
 - (void)_openURLFromActionMenu:(id)sender
@@ -931,6 +947,27 @@
     [self _clearPreviewPopover];
 }
 
+#pragma mark QLPreviewMenuItemDelegate implementation
+
+- (NSView *)menuItem:(NSMenuItem *)menuItem viewAtScreenPoint:(NSPoint)screenPoint
+{
+    return _wkView;
+}
+
+- (id<QLPreviewItem>)menuItem:(NSMenuItem *)menuItem previewItemAtPoint:(NSPoint)point
+{
+    if (!_wkView)
+        return nil;
+
+    RefPtr<WebHitTestResult> hitTestResult = [self _webHitTestResult];
+    return [NSURL _web_URLWithWTFString:hitTestResult->absoluteLinkURL()];
+}
+
+- (NSRectEdge)menuItem:(NSMenuItem *)menuItem preferredEdgeForPoint:(NSPoint)point
+{
+    return NSMaxYEdge;
+}
+
 #pragma mark Menu Items
 
 - (RetainPtr<NSMenuItem>)_createActionMenuItemForTag:(uint32_t)tag
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to