Add more _WKElementActionTypes and provide API to create with custom types
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Apr 2019 22:24:53 +0000 (22:24 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Apr 2019 22:24:53 +0000 (22:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197117
<rdar://problem/50059548>

Reviewed by Tim Horton.

We were missing a few obvious types that are well-known
browser actions, and/or should be visible in share sheets.
Also, clean up the API for constructing new types.

* UIProcess/API/Cocoa/_WKElementAction.h: Add new types for opening
in new tabs, windows and downloading.
* UIProcess/API/Cocoa/_WKElementAction.mm:
(+[_WKElementAction elementActionWithType:title:actionHandler:]): New constructor
with type, title and action.
(+[_WKElementAction elementActionWithType:]): Call new method.

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/_WKElementAction.h
Source/WebKit/UIProcess/API/Cocoa/_WKElementAction.mm

index 63d8421..8cda674 100644 (file)
@@ -1,3 +1,22 @@
+2019-04-19  Dean Jackson  <dino@apple.com>
+
+        Add more _WKElementActionTypes and provide API to create with custom types
+        https://bugs.webkit.org/show_bug.cgi?id=197117
+        <rdar://problem/50059548>
+
+        Reviewed by Tim Horton.
+
+        We were missing a few obvious types that are well-known
+        browser actions, and/or should be visible in share sheets.
+        Also, clean up the API for constructing new types.
+
+        * UIProcess/API/Cocoa/_WKElementAction.h: Add new types for opening
+        in new tabs, windows and downloading.
+        * UIProcess/API/Cocoa/_WKElementAction.mm:
+        (+[_WKElementAction elementActionWithType:title:actionHandler:]): New constructor
+        with type, title and action.
+        (+[_WKElementAction elementActionWithType:]): Call new method.
+
 2019-04-18  Daniel Bates  <dabates@apple.com>
 
         Use existing KeyEventCodesIOS constants instead of duplicating them
index 9f54cd7..15885ea 100644 (file)
@@ -42,15 +42,18 @@ typedef NS_ENUM(NSInteger, _WKElementActionType) {
     _WKElementActionTypeOpenInDefaultBrowser WK_API_AVAILABLE(ios(9_0)),
     _WKElementActionTypeOpenInExternalApplication WK_API_AVAILABLE(ios(9_0)),
 #endif
-    _WKElementActionTypeShare WK_API_AVAILABLE(ios(10.0)),
+    _WKElementActionTypeShare WK_API_AVAILABLE(macos(10.12), ios(10.0)),
+    _WKElementActionTypeOpenInNewTab WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)),
+    _WKElementActionTypeOpenInNewWindow WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)),
+    _WKElementActionTypeDownload WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)),
 } WK_API_AVAILABLE(macos(10.10), ios(8.0));
 
 WK_CLASS_AVAILABLE(macos(10.10), ios(8.0))
 @interface _WKElementAction : NSObject
 
 + (instancetype)elementActionWithType:(_WKElementActionType)type;
++ (instancetype)elementActionWithType:(_WKElementActionType)type title:(NSString *)title actionHandler:(WKElementActionHandler)actionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
 + (instancetype)elementActionWithType:(_WKElementActionType)type customTitle:(NSString *)title;
-
 + (instancetype)elementActionWithTitle:(NSString *)title actionHandler:(WKElementActionHandler)handler;
 
 - (void)runActionWithElementInfo:(_WKActivatedElementInfo *)info WK_API_AVAILABLE(ios(9_0));
index 1ed754c..8068ee5 100644 (file)
@@ -89,6 +89,11 @@ static void addToReadingList(NSURL *targetURL, NSString *title)
 }
 #endif
 
++ (instancetype)elementActionWithType:(_WKElementActionType)type title:(NSString *)title actionHandler:(WKElementActionHandler)actionHandler
+{
+    return [_WKElementAction _elementActionWithType:type title:title actionHandler:actionHandler];
+}
+
 + (instancetype)_elementActionWithType:(_WKElementActionType)type title:(NSString *)title actionHandler:(WKElementActionHandler)actionHandler
 {
     WKElementActionHandlerInternal handler = ^(WKActionSheetAssistant *, _WKActivatedElementInfo *actionInfo) { actionHandler(actionInfo); };