Action menu items should have tags
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 20 Oct 2014 23:25:51 +0000 (23:25 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 20 Oct 2014 23:25:51 +0000 (23:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=137898

Reviewed by Anders Carlsson.

* Shared/API/c/WKActionMenuItemTypes.h: Added.
* UIProcess/API/mac/WKView.mm:
(-[WKView _defaultMenuItemsForLink]):
* WebKit2.xcodeproj/project.pbxproj:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@174913 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/API/c/WKActionMenuItemTypes.h [new file with mode: 0644]
Source/WebKit2/UIProcess/API/mac/WKView.mm
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj

index 458d5b3..9823517 100644 (file)
@@ -1,5 +1,17 @@
 2014-10-20  Beth Dakin  <bdakin@apple.com>
 
+        Action menu items should have tags
+        https://bugs.webkit.org/show_bug.cgi?id=137898
+
+        Reviewed by Anders Carlsson.
+
+        * Shared/API/c/WKActionMenuItemTypes.h: Added.
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView _defaultMenuItemsForLink]):
+        * WebKit2.xcodeproj/project.pbxproj:
+
+2014-10-20  Beth Dakin  <bdakin@apple.com>
+
         Add support for action menus
         https://bugs.webkit.org/show_bug.cgi?id=137891
         rdar://problem/18451638
diff --git a/Source/WebKit2/Shared/API/c/WKActionMenuItemTypes.h b/Source/WebKit2/Shared/API/c/WKActionMenuItemTypes.h
new file mode 100644 (file)
index 0000000..77cb370
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+#ifndef WKActionMenuItemTypes_h
+#define WKActionMenuItemTypes_h
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+    kWKContextActionItemTagNoAction = 0,
+    kWKContextActionItemTagOpenLinkInDefaultBrowser,
+    kWKContextActionItemTagPreviewLink,
+    kWKContextActionItemTagAddLinkToSafariReadingList
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKActionMenuItemTypes_h */
index ef10aba..66d5c1c 100644 (file)
@@ -56,6 +56,7 @@
 #import "ViewGestureController.h"
 #import "ViewSnapshotStore.h"
 #import "WKAPICast.h"
+#import "WKActionMenuItemTypes.h"
 #import "WKFullScreenWindowController.h"
 #import "WKPrintingView.h"
 #import "WKProcessPoolInternal.h"
@@ -3680,16 +3681,19 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path)
     RetainPtr<NSMenuItem> openLinkItem = adoptNS([[NSMenuItem alloc] initWithTitle:@"Open" action:@selector(_openURLFromActionMenu:) keyEquivalent:@""]);
     [openLinkItem setImage:[[NSBundle bundleForClass:[WKView class]] imageForResource:@"OpenInNewWindowTemplate"]];
     [openLinkItem setTarget:self];
+    [openLinkItem setTag:kWKContextActionItemTagOpenLinkInDefaultBrowser];
     [menuItems addObject:openLinkItem.get()];
 
     RetainPtr<NSMenuItem> previewLinkItem = adoptNS([[NSMenuItem alloc] initWithTitle:@"Preview" action:@selector(_quickLookURLFromActionMenu:) keyEquivalent:@""]);
     [previewLinkItem setImage:[NSImage imageNamed:NSImageNameQuickLookTemplate]];
     [previewLinkItem setTarget:self];
+    [previewLinkItem setTag:kWKContextActionItemTagPreviewLink];
     [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];
+    [readingListItem setTag:kWKContextActionItemTagAddLinkToSafariReadingList];
     [menuItems addObject:readingListItem.get()];
 
     // FIXME: Required to work around <rdar://18684207>.
index 7641fc0..25adef1 100644 (file)
                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 */; };
+               934B724419F5B9BE00AE96D6 /* WKActionMenuItemTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 934B724319F5B9BE00AE96D6 /* WKActionMenuItemTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
                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, ); }; };
                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>"; };
+               934B724319F5B9BE00AE96D6 /* WKActionMenuItemTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKActionMenuItemTypes.h; 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>"; };
                                BC4075D5124FEFFA0068F20A /* cf */,
                                BCCF6AC412C91F3B008F9C35 /* cg */,
                                BC4075D6124FF0000068F20A /* mac */,
+                               934B724319F5B9BE00AE96D6 /* WKActionMenuItemTypes.h */,
                                BC4075D7124FF0270068F20A /* WKArray.cpp */,
                                BC4075D8124FF0270068F20A /* WKArray.h */,
                                BCDDB316124EBD130048D13C /* WKBase.h */,
                                5179556E162877B300FA43B6 /* NetworkProcessProxy.h in Headers */,
                                513A163D163088F6005D7D22 /* NetworkProcessProxyMessages.h in Headers */,
                                BCF4DE23168E4BD500C94AFC /* NetworkProcessSupplement.h in Headers */,
+                               934B724419F5B9BE00AE96D6 /* WKActionMenuItemTypes.h in Headers */,
                                51FD18B61651FBAD00DBE1CE /* NetworkResourceLoader.h in Headers */,
                                E152551B17011819003D7ADB /* NetworkResourceLoaderMessages.h in Headers */,
                                51CBBA10165219B6005BE8FD /* NetworkResourceLoadParameters.h in Headers */,