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

Diff

Modified: branches/safari-600.3-branch/Source/WebCore/ChangeLog (175118 => 175119)


--- branches/safari-600.3-branch/Source/WebCore/ChangeLog	2014-10-23 13:15:58 UTC (rev 175118)
+++ branches/safari-600.3-branch/Source/WebCore/ChangeLog	2014-10-23 15:50:11 UTC (rev 175119)
@@ -1,3 +1,22 @@
+2014-10-23  Matthew Hanson  <[email protected]>
+
+        Merge r174908. <rdar://problem/18694470>
+
+    2014-10-20  Beth Dakin  <[email protected]>
+    
+            Add support for action menus
+            https://bugs.webkit.org/show_bug.cgi?id=137891
+            rdar://problem/18451638
+            rdar://problem/18694470
+    
+            Reviewed by Anders Carlsson.
+    
+            New SPI that is needed for this.
+            * WebCore.exp.in:
+            * WebCore.xcodeproj/project.pbxproj:
+            * platform/spi/mac: Added.
+            * platform/spi/mac/NSViewSPI.h: Added.
+    
 2014-10-23  Babak Shafiei  <[email protected]>
 
         Merge r174040.

Modified: branches/safari-600.3-branch/Source/WebCore/WebCore.exp.in (175118 => 175119)


--- branches/safari-600.3-branch/Source/WebCore/WebCore.exp.in	2014-10-23 13:15:58 UTC (rev 175118)
+++ branches/safari-600.3-branch/Source/WebCore/WebCore.exp.in	2014-10-23 15:50:11 UTC (rev 175119)
@@ -982,6 +982,7 @@
 __ZN7WebCore22createFragmentFromTextERNS_5RangeERKN3WTF6StringE
 __ZN7WebCore22externalRepresentationEPNS_5FrameEj
 __ZN7WebCore22externalRepresentationEPNS_7ElementEj
+__ZN7WebCore22protocolIsInHTTPFamilyERKN3WTF6StringE
 __ZN7WebCore22systemMarketingVersionEv
 __ZN7WebCore22throwSequenceTypeErrorERN3JSC9ExecStateE
 __ZN7WebCore22userPreferredLanguagesEv

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


--- branches/safari-600.3-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2014-10-23 13:15:58 UTC (rev 175118)
+++ branches/safari-600.3-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2014-10-23 15:50:11 UTC (rev 175119)
@@ -3241,6 +3241,7 @@
 		9343CB8212F25E510033C5EE /* TextCodecUTF8.h in Headers */ = {isa = PBXBuildFile; fileRef = 9343CB8012F25E510033C5EE /* TextCodecUTF8.h */; };
 		93442C9E0D2B335C00338FF9 /* HTMLTableRowsCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 93442C9D0D2B335C00338FF9 /* HTMLTableRowsCollection.h */; };
 		93442CA00D2B336000338FF9 /* HTMLTableRowsCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93442C9F0D2B336000338FF9 /* HTMLTableRowsCollection.cpp */; };
+		9348428219F1A9190009D5AE /* NSViewSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 9348428119F1A9190009D5AE /* NSViewSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		934907E4125BBBC8007F23A0 /* GraphicsContextCG.h in Headers */ = {isa = PBXBuildFile; fileRef = 934907E3125BBBC8007F23A0 /* GraphicsContextCG.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		934CC10A0EDB223900A658F2 /* ScriptSourceCode.h in Headers */ = {isa = PBXBuildFile; fileRef = 934CC1090EDB223900A658F2 /* ScriptSourceCode.h */; };
 		934D9BA50B8C116B007B42A9 /* WebCoreNSStringExtras.mm in Sources */ = {isa = PBXBuildFile; fileRef = 934D9BA40B8C116B007B42A9 /* WebCoreNSStringExtras.mm */; };
@@ -10383,6 +10384,7 @@
 		9343CB8012F25E510033C5EE /* TextCodecUTF8.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextCodecUTF8.h; sourceTree = "<group>"; };
 		93442C9D0D2B335C00338FF9 /* HTMLTableRowsCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLTableRowsCollection.h; sourceTree = "<group>"; };
 		93442C9F0D2B336000338FF9 /* HTMLTableRowsCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLTableRowsCollection.cpp; sourceTree = "<group>"; };
+		9348428119F1A9190009D5AE /* NSViewSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSViewSPI.h; sourceTree = "<group>"; };
 		934907E3125BBBC8007F23A0 /* GraphicsContextCG.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsContextCG.h; sourceTree = "<group>"; };
 		934CC1090EDB223900A658F2 /* ScriptSourceCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptSourceCode.h; sourceTree = "<group>"; };
 		934D9BA40B8C116B007B42A9 /* WebCoreNSStringExtras.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreNSStringExtras.mm; sourceTree = "<group>"; };
@@ -16219,6 +16221,36 @@
 			path = plugins;
 			sourceTree = "<group>";
 		};
+		65086DA619AC1719009AF46B /* cf */ = {
+			isa = PBXGroup;
+			children = (
+				65086DA719AC1719009AF46B /* CFLocaleSPI.h */,
+				CE8245EF19B671BA00AC0122 /* CFNetworkConnectionCacheSPI.h */,
+				CE8245F119B671D500AC0122 /* CFURLRequestSPI.h */,
+			);
+			path = cf;
+			sourceTree = "<group>";
+		};
+		653EF83619A043AE0052202C /* spi */ = {
+			isa = PBXGroup;
+			children = (
+				65086DA619AC1719009AF46B /* cf */,
+				653EF83719A043AE0052202C /* cocoa */,
+				A172182419DE182B00464D17 /* ios */,
+				9348428019F1A9190009D5AE /* mac */,
+			);
+			path = spi;
+			sourceTree = "<group>";
+		};
+		653EF83719A043AE0052202C /* cocoa */ = {
+			isa = PBXGroup;
+			children = (
+				653EF83819A043AE0052202C /* NSURLFileTypeMappingsSPI.h */,
+				1CF7E26E19D881EF00DD8F98 /* CGFontUnicodeSupportSPI.h */,
+			);
+			path = cocoa;
+			sourceTree = "<group>";
+		};
 		656580EC09D12B20000E61D7 /* Derived Sources */ = {
 			isa = PBXGroup;
 			children = (
@@ -17560,6 +17592,14 @@
 			path = filters;
 			sourceTree = "<group>";
 		};
+		9348428019F1A9190009D5AE /* mac */ = {
+			isa = PBXGroup;
+			children = (
+				9348428119F1A9190009D5AE /* NSViewSPI.h */,
+			);
+			path = mac;
+			sourceTree = "<group>";
+		};
 		93A1EAA20A5634D8006960A0 /* mac */ = {
 			isa = PBXGroup;
 			children = (
@@ -21303,6 +21343,7 @@
 				656B84D70AEA1CE900A095B4 /* network */,
 				516030090CC4245400C8AC25 /* posix */,
 				1A2E6E560CC551E0004A2062 /* sql */,
+				653EF83619A043AE0052202C /* spi */,
 				B2C3D9EC0D006C1D00EF6F26 /* text */,
 				49AE2D94134EE5F90072920A /* CalculationValue.cpp */,
 				49AE2D95134EE5F90072920A /* CalculationValue.h */,
@@ -25956,6 +25997,7 @@
 				0A4844990CA44CB200B7BD48 /* SoftLinking.h in Headers */,
 				4B3043C70AE0370300A82647 /* Sound.h in Headers */,
 				84A81F3E0FC7DFF000955300 /* SourceAlpha.h in Headers */,
+				9348428219F1A9190009D5AE /* NSViewSPI.h in Headers */,
 				CD3A496217A9D01B00274E42 /* SourceBuffer.h in Headers */,
 				CD3A496517A9D01B00274E42 /* SourceBufferList.h in Headers */,
 				CD641EB41818F5ED00EE4C41 /* SourceBufferPrivate.h in Headers */,

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


--- branches/safari-600.3-branch/Source/WebCore/platform/spi/mac/NSViewSPI.h	                        (rev 0)
+++ branches/safari-600.3-branch/Source/WebCore/platform/spi/mac/NSViewSPI.h	2014-10-23 15:50:11 UTC (rev 175119)
@@ -0,0 +1,38 @@
+/*
+ * 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 <AppKit/NSView_Private.h>
+
+#else
+
+#import <AppKit/NSView.h>
+
+@interface NSView (Private)
+@property (strong) NSMenu *actionMenu;
+@end
+
+#endif

Modified: branches/safari-600.3-branch/Source/WebKit2/ChangeLog (175118 => 175119)


--- branches/safari-600.3-branch/Source/WebKit2/ChangeLog	2014-10-23 13:15:58 UTC (rev 175118)
+++ branches/safari-600.3-branch/Source/WebKit2/ChangeLog	2014-10-23 15:50:11 UTC (rev 175119)
@@ -1,3 +1,51 @@
+2014-10-23  Matthew Hanson  <[email protected]>
+
+        Merge r174908. <rdar://problem/18694470>
+
+    2014-10-20  Beth Dakin  <[email protected]>
+    
+            Add support for action menus
+            https://bugs.webkit.org/show_bug.cgi?id=137891
+            rdar://problem/18451638
+            rdar://problem/18694470
+    
+            Reviewed by Anders Carlsson.
+    
+            Temporary artwork needed for menu item.
+            * Resources/OpenInNewWindowTemplate.pdf: Added.
+            * WebKit2.xcodeproj/project.pbxproj:
+    
+            Add a preference that defaults to false for action menu support.
+            * Shared/WebPreferencesDefinitions.h:
+            * UIProcess/API/C/WKPreferences.cpp:
+            (WKPreferencesSetActionMenuSupportEnabled):
+            (WKPreferencesGetActionMenuSupportEnabled):
+            * UIProcess/API/C/WKPreferencesRefPrivate.h:
+    
+            New SPI. WebKit clients can implement this method to customize the action menu.
+            * UIProcess/API/Cocoa/WKViewPrivate.h:
+    
+            Create the action menu if it is supported.
+            * UIProcess/API/mac/WKView.mm:
+            (-[WKView initWithFrame:context:configuration:webView:]):
+    
+            Methods to implement the default menu actions.
+            (-[WKView _openURLFromActionMenu:]):
+            (-[WKView _addToReadingListFromActionMenu:]):
+            (-[WKView _quickLookURLFromActionMenu:]):
+    
+            Add action menus support for links. Populate the menu at the right time.
+            (-[WKView _defaultMenuItemsForLink]):
+            (-[WKView _defaultMenuItems]):
+            (-[WKView prepareForMenu:withEvent:]):
+            (-[WKView _actionMenuItemsForHitTestResult:defaultActionMenuItems:]):
+    
+            New member variable caches the HitTestResult on mouse move.
+            * UIProcess/WebPageProxy.cpp:
+            (WebKit::WebPageProxy::mouseDidMoveOverElement):
+            * UIProcess/WebPageProxy.h:
+            (WebKit::WebPageProxy::activeActionMenuHitTestResult):
+    
 2014-10-23  Babak Shafiei  <[email protected]>
 
         Merge r173694.

Copied: branches/safari-600.3-branch/Source/WebKit2/Resources/OpenInNewWindowTemplate.pdf (from rev 174908, trunk/Source/WebKit2/Resources/OpenInNewWindowTemplate.pdf)


(Binary files differ)

Modified: branches/safari-600.3-branch/Source/WebKit2/Shared/WebPreferencesDefinitions.h (175118 => 175119)


--- branches/safari-600.3-branch/Source/WebKit2/Shared/WebPreferencesDefinitions.h	2014-10-23 13:15:58 UTC (rev 175118)
+++ branches/safari-600.3-branch/Source/WebKit2/Shared/WebPreferencesDefinitions.h	2014-10-23 15:50:11 UTC (rev 175119)
@@ -202,6 +202,7 @@
     macro(ShouldConvertPositionStyleOnCopy, shouldConvertPositionStyleOnCopy, Bool, bool, false) \
     macro(Standalone, standalone, Bool, bool, false) \
     macro(TelephoneNumberParsingEnabled, telephoneNumberParsingEnabled, Bool, bool, false) \
+    macro(ActionMenuSupportEnabled, actionMenuSupportEnabled, Bool, bool, false) \
     macro(AlwaysUseBaselineOfPrimaryFont, alwaysUseBaselineOfPrimaryFont, Bool, bool, false) \
     macro(AllowMultiElementImplicitSubmission, allowMultiElementImplicitSubmission, Bool, bool, false) \
     macro(AlwaysUseAcceleratedOverflowScroll, alwaysUseAcceleratedOverflowScroll, Bool, bool, false) \

Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp (175118 => 175119)


--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp	2014-10-23 13:15:58 UTC (rev 175118)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp	2014-10-23 15:50:11 UTC (rev 175119)
@@ -1246,6 +1246,16 @@
     return toImpl(preferencesRef)->telephoneNumberParsingEnabled();
 }
 
+void WKPreferencesSetActionMenuSupportEnabled(WKPreferencesRef preferencesRef, bool enabled)
+{
+    toImpl(preferencesRef)->setActionMenuSupportEnabled(enabled);
+}
+
+bool WKPreferencesGetActionMenuSupportEnabled(WKPreferencesRef preferencesRef)
+{
+    return toImpl(preferencesRef)->actionMenuSupportEnabled();
+}
+
 void WKPreferencesSetEnableInheritURIQueryComponent(WKPreferencesRef preferencesRef, bool enabled)
 {
     toImpl(preferencesRef)->setEnableInheritURIQueryComponent(enabled);

Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/C/WKPreferencesRefPrivate.h (175118 => 175119)


--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/C/WKPreferencesRefPrivate.h	2014-10-23 13:15:58 UTC (rev 175118)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/C/WKPreferencesRefPrivate.h	2014-10-23 15:50:11 UTC (rev 175119)
@@ -319,6 +319,10 @@
 WK_EXPORT bool WKPreferencesGetTelephoneNumberParsingEnabled(WKPreferencesRef preferencesRef);
 
 // Default to false.
+WK_EXPORT void WKPreferencesSetActionMenuSupportEnabled(WKPreferencesRef, bool);
+WK_EXPORT bool WKPreferencesGetActionMenuSupportEnabled(WKPreferencesRef);
+
+// Default to false.
 WK_EXPORT void WKPreferencesSetEnableInheritURIQueryComponent(WKPreferencesRef preferencesRef, bool enabled);
 WK_EXPORT bool WKPreferencesGetEnableInheritURIQueryComponent(WKPreferencesRef preferencesRef);
 

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


--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h	2014-10-23 13:15:58 UTC (rev 175118)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h	2014-10-23 15:50:11 UTC (rev 175119)
@@ -116,6 +116,8 @@
 // The rect returned is always that of the snapshot, and only if it is the view being manipulated by the swipe. This only works for layer-backed windows.
 - (void)_setDidMoveSwipeSnapshotCallback:(void(^)(CGRect swipeSnapshotRectInWindowCoordinates))callback;
 
+- (NSArray *)_actionMenuItemsForHitTestResult:(WKHitTestResultRef)hitTestResult defaultActionMenuItems:(NSArray *)defaultMenuItems;
+
 #endif
 
 @end

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


--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm	2014-10-23 13:15:58 UTC (rev 175118)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm	2014-10-23 15:50:11 UTC (rev 175119)
@@ -85,6 +85,7 @@
 #import <WebCore/FileSystem.h>
 #import <WebCore/KeyboardEvent.h>
 #import <WebCore/LocalizedStrings.h>
+#import <WebCore/NSViewSPI.h>
 #import <WebCore/PlatformEventFactoryMac.h>
 #import <WebCore/PlatformScreen.h>
 #import <WebCore/Region.h>
@@ -117,6 +118,10 @@
 - (void)_maskRoundedBottomCorners:(NSRect)clipRect;
 @end
 
+@interface NSObject (WKQLPreviewBubbleDetails)
++ (void)presentBubbleForItem:(id)item parentWindow:(NSWindow *)aWindow itemFrame:(NSRect)itemFrame maximumSize:(NSSize)maximumSize preferredEdge:(NSRectEdge)preferredEdge;
+@end
+
 #if USE(ASYNC_NSTEXTINPUTCLIENT)
 @interface NSTextInputContext (WKNSTextInputContextDetails)
 - (void)handleEvent:(NSEvent *)theEvent completionHandler:(void(^)(BOOL handled))completionHandler;
@@ -3525,6 +3530,11 @@
 
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:NSApp];
 
+    if (_data->_page->preferences().actionMenuSupportEnabled() && [self respondsToSelector:@selector(setActionMenu:)]) {
+        RetainPtr<NSMenu> actionMenu = adoptNS([[NSMenu alloc] init]);
+        [self setActionMenu:actionMenu.get()];
+    }
+
     return self;
 }
 
@@ -3622,6 +3632,95 @@
         _data->_gestureController->removeSwipeSnapshot();
 }
 
+- (void)_openURLFromActionMenu:(id)sender
+{
+    WebHitTestResult* hitTestResult = _data->_page->activeActionMenuHitTestResult();
+    if (!hitTestResult)
+        return;
+
+    NSURL *url = "" URLWithString:hitTestResult->absoluteLinkURL()];
+    [[NSWorkspace sharedWorkspace] openURL:url];
+}
+
+- (void)_addToReadingListFromActionMenu:(id)sender
+{
+    WebHitTestResult* hitTestResult = _data->_page->activeActionMenuHitTestResult();
+    if (!hitTestResult)
+        return;
+
+    NSURL *url = "" URLWithString:hitTestResult->absoluteLinkURL()];
+    NSSharingService *service = [NSSharingService sharingServiceNamed:NSSharingServiceNameAddToSafariReadingList];
+    [service performWithItems:@[ url ]];
+}
+
+- (void)_quickLookURLFromActionMenu:(id)sender
+{
+    WebHitTestResult* hitTestResult = _data->_page->activeActionMenuHitTestResult();
+    if (!hitTestResult)
+        return;
+
+    NSRect itemFrame = [self convertRect:hitTestResult->elementBoundingBox() toView:nil];
+    NSSize maximumPreviewSize = NSMakeSize(self.bounds.size.width * 0.75, self.bounds.size.height * 0.75);
+
+    NSURL *url = "" URLWithString:hitTestResult->absoluteLinkURL()];
+    [NSClassFromString(@"QLPreviewBubble") presentBubbleForItem:url parentWindow:self.window itemFrame:itemFrame maximumSize:maximumPreviewSize preferredEdge:NSMaxYEdge];
+}
+
+- (NSArray *)_defaultMenuItemsForLink
+{
+    NSMutableArray *menuItems = [NSMutableArray array];
+
+    WebHitTestResult* hitTestResult = _data->_page->activeActionMenuHitTestResult();
+    if (!hitTestResult)
+        return menuItems;
+
+    if (!WebCore::protocolIsInHTTPFamily(hitTestResult->absoluteLinkURL()))
+        return menuItems;
+
+    RetainPtr<NSMenuItem> openLinkItem = adoptNS([[NSMenuItem alloc] initWithTitle:@"Open" action:@selector(_openURLFromActionMenu:) keyEquivalent:@""]);
+    [openLinkItem setImage:[[NSBundle bundleForClass:[WKView class]] imageForResource:@"OpenInNewWindowTemplate"]];
+    [openLinkItem setTarget:self];
+    [menuItems addObject:openLinkItem.get()];
+
+    RetainPtr<NSMenuItem> previewLinkItem = adoptNS([[NSMenuItem alloc] initWithTitle:@"Preview" action:@selector(_quickLookURLFromActionMenu:) keyEquivalent:@""]);
+    [previewLinkItem setImage:[NSImage imageNamed:NSImageNameQuickLookTemplate]];
+    [previewLinkItem setTarget:self];
+    [menuItems addObject:previewLinkItem.get()];
+
+    RetainPtr<NSMenuItem> readingListItem = adoptNS([[NSMenuItem alloc] initWithTitle:@"Add to Safari Reading List" action:@selector(_addToReadingListFromActionMenu:) keyEquivalent:@""]);
+    [readingListItem setImage:[NSImage imageNamed:NSImageNameBookmarksTemplate]];
+    [readingListItem setTarget:self];
+    [menuItems addObject:readingListItem.get()];
+
+    // FIXME: Required to work around <rdar://18684207>.
+    [menuItems addObject:[NSMenuItem separatorItem]];
+
+    return menuItems;
+}
+
+- (NSArray *)_defaultMenuItems
+{
+    if (WebHitTestResult* hitTestResult = _data->_page->activeActionMenuHitTestResult()) {
+        if (!hitTestResult->absoluteLinkURL().isEmpty())
+            return [self _defaultMenuItemsForLink];
+    }
+
+    return @[];
+}
+
+- (void)prepareForMenu:(NSMenu *)menu withEvent:(NSEvent *)event
+{
+    if (menu != self.actionMenu)
+        return;
+
+    [[self actionMenu] removeAllItems];
+
+    NSArray *menuItems = [self _actionMenuItemsForHitTestResult:toAPI(_data->_page->activeActionMenuHitTestResult()) defaultActionMenuItems:[self _defaultMenuItems]];
+
+    for (NSMenuItem *item in menuItems)
+        [[self actionMenu] addItem:item];
+}
+
 @end
 
 @implementation WKView (Private)
@@ -4089,6 +4188,12 @@
     _data->_gestureController->setDidMoveSwipeSnapshotCallback(callback);
 }
 
+
+- (NSArray *)_actionMenuItemsForHitTestResult:(WKHitTestResultRef)hitTestResult defaultActionMenuItems:(NSArray *)defaultMenuItems
+{
+    return defaultMenuItems;
+}
+
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
 
 - (void)_setAutomaticallyAdjustsContentInsets:(BOOL)automaticallyAdjustsContentInsets

Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp (175118 => 175119)


--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp	2014-10-23 13:15:58 UTC (rev 175118)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp	2014-10-23 15:50:11 UTC (rev 175119)
@@ -3078,6 +3078,8 @@
     if (!decoder.decode(messageDecoder))
         return;
 
+    m_activeActionMenuHitTestResult = WebHitTestResult::create(hitTestResultData);
+
     WebEvent::Modifiers modifiers = static_cast<WebEvent::Modifiers>(opaqueModifiers);
 
     m_uiClient->mouseDidMoveOverElement(this, hitTestResultData, modifiers, userData.get());

Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/WebPageProxy.h (175118 => 175119)


--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/WebPageProxy.h	2014-10-23 13:15:58 UTC (rev 175118)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/WebPageProxy.h	2014-10-23 15:50:11 UTC (rev 175119)
@@ -911,6 +911,8 @@
     bool isShowingNavigationGestureSnapshot() const { return m_isShowingNavigationGestureSnapshot; }
     void removeNavigationGestureSnapshot();
 
+    WebHitTestResult* activeActionMenuHitTestResult() const { return m_activeActionMenuHitTestResult.get(); }
+
 private:
     WebPageProxy(PageClient&, WebProcessProxy&, uint64_t pageID, const WebPageConfiguration&);
     void platformInitialize();
@@ -1355,6 +1357,8 @@
     RefPtr<WebContextMenuProxy> m_activeContextMenu;
     ContextMenuContextData m_activeContextMenuContextData;
 #endif
+    RefPtr<WebHitTestResult> m_activeActionMenuHitTestResult;
+
     RefPtr<WebOpenPanelResultListenerProxy> m_openPanelResultListener;
     GeolocationPermissionRequestManagerProxy m_geolocationPermissionRequestManager;
     NotificationPermissionRequestManagerProxy m_notificationPermissionRequestManager;

Modified: branches/safari-600.3-branch/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (175118 => 175119)


--- branches/safari-600.3-branch/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2014-10-23 13:15:58 UTC (rev 175118)
+++ branches/safari-600.3-branch/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2014-10-23 15:50:11 UTC (rev 175119)
@@ -1087,6 +1087,7 @@
 		909854EC12BC4E17000AD080 /* WebMemorySampler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 905620E812BC248B000799B6 /* WebMemorySampler.cpp */; };
 		909854ED12BC4E18000AD080 /* WebMemorySampler.h in Headers */ = {isa = PBXBuildFile; fileRef = 905620E912BC248B000799B6 /* WebMemorySampler.h */; };
 		909854EE12BC4E18000AD080 /* WebMemorySampler.mac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 905620E512BC2476000799B6 /* WebMemorySampler.mac.mm */; };
+		9348427D19F19BD10009D5AE /* OpenInNewWindowTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 9348427C19F19BD00009D5AE /* OpenInNewWindowTemplate.pdf */; };
 		935EEB9B1277617C003322B8 /* WKBundleBackForwardListItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 935EEB981277616D003322B8 /* WKBundleBackForwardListItem.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		935EEB9E127761AC003322B8 /* WKBundleBackForwardList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 935EEB951277616D003322B8 /* WKBundleBackForwardList.cpp */; };
 		935EEB9F127761AC003322B8 /* WKBundleBackForwardList.h in Headers */ = {isa = PBXBuildFile; fileRef = 935EEB961277616D003322B8 /* WKBundleBackForwardList.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -3145,6 +3146,7 @@
 		905620E512BC2476000799B6 /* WebMemorySampler.mac.mm */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebMemorySampler.mac.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
 		905620E812BC248B000799B6 /* WebMemorySampler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebMemorySampler.cpp; sourceTree = "<group>"; };
 		905620E912BC248B000799B6 /* WebMemorySampler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebMemorySampler.h; sourceTree = "<group>"; };
+		9348427C19F19BD00009D5AE /* OpenInNewWindowTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; name = OpenInNewWindowTemplate.pdf; path = Resources/OpenInNewWindowTemplate.pdf; sourceTree = "<group>"; };
 		935EEB8F1277615D003322B8 /* InjectedBundleBackForwardList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleBackForwardList.cpp; sourceTree = "<group>"; };
 		935EEB901277615D003322B8 /* InjectedBundleBackForwardList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundleBackForwardList.h; sourceTree = "<group>"; };
 		935EEB911277615D003322B8 /* InjectedBundleBackForwardListItem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleBackForwardListItem.cpp; sourceTree = "<group>"; };
@@ -4006,6 +4008,7 @@
 				1C8AE7601992F62F00ABF6EC /* DockRightLegacy.pdf */,
 				8DC2EF5A0486A6940098B216 /* Info.plist */,
 				089C1666FE841158C02AAC07 /* InfoPlist.strings */,
+				9348427C19F19BD00009D5AE /* OpenInNewWindowTemplate.pdf */,
 				E1D26A4C1759634E0095BFD1 /* WebContentProcess.xib */,
 				E133FD891423DD7F00FC7BFB /* WebKit.icns */,
 			);
@@ -8305,6 +8308,7 @@
 				E11D35AE16B63D1B006D23D7 /* com.apple.WebProcess.sb in Resources */,
 				1CBC945E16515ED200D68AAE /* DockBottom.pdf in Resources */,
 				E115C716190F8A2500ECC516 /* com.apple.WebKit.Databases.sb in Resources */,
+				9348427D19F19BD10009D5AE /* OpenInNewWindowTemplate.pdf in Resources */,
 				1CB75C941701E880009F809F /* DockRight.pdf in Resources */,
 				1C8AE7611992F63A00ABF6EC /* DockBottomLegacy.pdf in Resources */,
 				8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to