Changeset 246867 in webkit


Ignore:
Timestamp:
Jun 26, 2019 6:28:57 PM (5 years ago)
Author:
dino@apple.com
Message:

Add type to UIImage symbol mapping for _WKElementAction
https://bugs.webkit.org/show_bug.cgi?id=199255

Reviewed by Sam Weinig.

Moving some code in from WebKitAdditions now
that the API is public.

  • UIProcess/API/Cocoa/_WKElementAction.mm:

(+[_WKElementAction imageForElementActionType:]):
(elementActionTypeToUIActionIdentifier):
(uiActionIdentifierToElementActionType):

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r246865 r246867  
     12019-06-26  Dean Jackson  <dino@apple.com>
     2
     3        Add type to UIImage symbol mapping for _WKElementAction
     4        https://bugs.webkit.org/show_bug.cgi?id=199255
     5
     6        Reviewed by Sam Weinig.
     7
     8        Moving some code in from WebKitAdditions now
     9        that the API is public.
     10
     11        * UIProcess/API/Cocoa/_WKElementAction.mm:
     12        (+[_WKElementAction imageForElementActionType:]):
     13        (elementActionTypeToUIActionIdentifier):
     14        (uiActionIdentifierToElementActionType):
     15
    1162019-06-26  Dean Jackson  <dino@apple.com>
    217
  • trunk/Source/WebKit/UIProcess/API/Cocoa/_WKElementAction.mm

    r246865 r246867  
    3939#import <wtf/text/WTFString.h>
    4040
    41 #if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/WKElementActionAdditions.h>)
    42 #include <WebKitAdditions/WKElementActionAdditions.h>
    43 #endif
    44 
    4541#if HAVE(SAFARI_SERVICES_FRAMEWORK)
    4642#import <SafariServices/SSReadingList.h>
     
    194190}
    195191
    196 #if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/WKElementActionAdditions.mm>)
    197 #include <WebKitAdditions/WKElementActionAdditions.mm>
    198 #else
     192#if USE(UICONTEXTMENU)
    199193+ (UIImage *)imageForElementActionType:(_WKElementActionType)actionType
    200194{
    201     return nil;
    202 }
    203 #endif
    204 
    205 #if USE(UICONTEXTMENU)
     195    switch (actionType) {
     196    case _WKElementActionTypeCustom:
     197        return nil;
     198    case _WKElementActionTypeOpen:
     199        return [UIImage systemImageNamed:@"safari"];
     200    case _WKElementActionTypeCopy:
     201        return [UIImage systemImageNamed:@"doc.on.doc"];
     202    case _WKElementActionTypeSaveImage:
     203        return [UIImage systemImageNamed:@"square.and.arrow.down"];
     204    case _WKElementActionTypeAddToReadingList:
     205        return [UIImage systemImageNamed:@"eyeglasses"];
     206    case _WKElementActionTypeOpenInDefaultBrowser:
     207        return [UIImage systemImageNamed:@"safari"];
     208    case _WKElementActionTypeOpenInExternalApplication:
     209        return [UIImage systemImageNamed:@"arrow.up.right.square"];
     210    case _WKElementActionTypeShare:
     211        return [UIImage systemImageNamed:@"square.and.arrow.up"];
     212    case _WKElementActionTypeOpenInNewTab:
     213        return [UIImage systemImageNamed:@"plus.square.on.square"];
     214    case _WKElementActionTypeOpenInNewWindow:
     215        return [UIImage systemImageNamed:@"square.grid.2x2"];
     216    case _WKElementActionTypeDownload:
     217        return [UIImage systemImageNamed:@"arrow.down.circle"];
     218    }
     219}
     220
    206221static UIActionIdentifier elementActionTypeToUIActionIdentifier(_WKElementActionType actionType)
    207222{
     
    215230    case _WKElementActionTypeSaveImage:
    216231        return WKElementActionTypeSaveImageIdentifier;
    217 #if !defined(TARGET_OS_IOS) || TARGET_OS_IOS
    218232    case _WKElementActionTypeAddToReadingList:
    219233        return WKElementActionTypeAddToReadingListIdentifier;
     
    222236    case _WKElementActionTypeOpenInExternalApplication:
    223237        return WKElementActionTypeOpenInExternalApplicationIdentifier;
    224 #endif
    225238    case _WKElementActionTypeShare:
    226239        return WKElementActionTypeShareIdentifier;
     
    244257    if ([identifier isEqualToString:WKElementActionTypeSaveImageIdentifier])
    245258        return _WKElementActionTypeSaveImage;
    246 #if !defined(TARGET_OS_IOS) || TARGET_OS_IOS
    247259    if ([identifier isEqualToString:WKElementActionTypeAddToReadingListIdentifier])
    248260        return _WKElementActionTypeAddToReadingList;
     
    251263    if ([identifier isEqualToString:WKElementActionTypeOpenInExternalApplicationIdentifier])
    252264        return _WKElementActionTypeOpenInExternalApplication;
    253 #endif
    254265    if ([identifier isEqualToString:WKElementActionTypeShareIdentifier])
    255266        return _WKElementActionTypeShare;
     
    285296}
    286297#else
     298+ (UIImage *)imageForElementActionType:(_WKElementActionType)actionType
     299{
     300    return nil;
     301}
     302
    287303+ (_WKElementActionType)elementActionTypeForUIActionIdentifier:(UIActionIdentifier)identifier
    288304{
     
    294310    return nil;
    295311}
    296 #endif
     312#endif // USE(UICONTEXTMENU)
    297313
    298314@end
Note: See TracChangeset for help on using the changeset viewer.