Skip to content

Commit

Permalink
Adopt DDMacAction instead of DDAction on macOS
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=223145
<rdar://problem/70127512>

Reviewed by Megan Gardner.

Source/WebCore/PAL:

* pal/spi/mac/DataDetectorsSPI.h:

Source/WebKit:

* Platform/mac/MenuUtilities.mm:
(WebKit::actionForMenuItem):
(WebKit::menuItemForTelephoneNumber):
(WebKit::menuForTelephoneNumber):
Adopt the new class name, when available.

Source/WTF:

* wtf/PlatformHave.h:


Canonical link: https://commits.webkit.org/235247@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274380 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
hortont424 committed Mar 13, 2021
1 parent 32481e0 commit 9482e84
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 20 deletions.
10 changes: 10 additions & 0 deletions Source/WTF/ChangeLog
@@ -1,3 +1,13 @@
2021-03-13 Tim Horton <timothy_horton@apple.com>

Adopt DDMacAction instead of DDAction on macOS
https://bugs.webkit.org/show_bug.cgi?id=223145
<rdar://problem/70127512>

Reviewed by Megan Gardner.

* wtf/PlatformHave.h:

2021-03-12 Lauro Moura <lmoura@igalia.com>

REGRESSION(r274327) [GLIB] 2D Canvas tests timing out after enabling GPUProces in testing
Expand Down
1 change: 1 addition & 0 deletions Source/WTF/wtf/PlatformHave.h
Expand Up @@ -916,6 +916,7 @@

#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 120000
#define HAVE_STATIC_FONT_REGISTRY 1
#define HAVE_DATA_DETECTORS_MAC_ACTION 1
#endif

#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 120000) \
Expand Down
10 changes: 10 additions & 0 deletions Source/WebCore/PAL/ChangeLog
@@ -1,3 +1,13 @@
2021-03-13 Tim Horton <timothy_horton@apple.com>

Adopt DDMacAction instead of DDAction on macOS
https://bugs.webkit.org/show_bug.cgi?id=223145
<rdar://problem/70127512>

Reviewed by Megan Gardner.

* pal/spi/mac/DataDetectorsSPI.h:

2021-03-12 Myles C. Maxfield <mmaxfield@apple.com>

[macOS] MobileAsset fonts are broken in Reader mode in Safari
Expand Down
13 changes: 12 additions & 1 deletion Source/WebCore/PAL/pal/spi/mac/DataDetectorsSPI.h
Expand Up @@ -39,6 +39,10 @@
#import <DataDetectors/DDActionsManager.h>
#import <DataDetectors/DDHighlightDrawing.h>

#if HAVE(DATA_DETECTORS_MAC_ACTION)
#import <DataDetectors/DDMacAction.h>
#endif

#else // !USE(APPLE_INTERNAL_SDK)

@interface DDActionContext : NSObject <NSCopying, NSSecureCoding>
Expand Down Expand Up @@ -98,19 +102,26 @@ WTF_EXTERN_C_END
typedef struct __DDHighlight *DDHighlightRef;
typedef NSUInteger DDHighlightStyle;

#if !HAVE(DATA_DETECTORS_MAC_ACTION)
@interface DDAction : NSObject

@property (readonly) NSString *actionUTI;

@end
#endif

SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(DataDetectors)
SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(DataDetectorsCore)

SOFT_LINK_CLASS_OPTIONAL(DataDetectors, DDAction)
SOFT_LINK_CLASS_OPTIONAL(DataDetectors, DDActionContext)
SOFT_LINK_CLASS_OPTIONAL(DataDetectors, DDActionsManager)

#if HAVE(DATA_DETECTORS_MAC_ACTION)
SOFT_LINK_CLASS_OPTIONAL(DataDetectors, DDMacAction)
#else
SOFT_LINK_CLASS_OPTIONAL(DataDetectors, DDAction)
#endif

SOFT_LINK_CONSTANT(DataDetectorsCore, DDBinderPhoneNumberKey, CFStringRef)
#if HAVE(DD_HIGHLIGHT_CREATE_WITH_SCALE)
SOFT_LINK(DataDetectors, DDHighlightCreateWithRectsInVisibleRectWithStyleScaleAndDirection, DDHighlightRef, (CFAllocatorRef allocator, CGRect* rects, CFIndex count, CGRect globalVisibleRect, DDHighlightStyle style, Boolean withButton, NSWritingDirection writingDirection, Boolean endsWithEOL, Boolean flipped, CGFloat scale), (allocator, rects, count, globalVisibleRect, style, withButton, writingDirection, endsWithEOL, flipped, scale))
Expand Down
14 changes: 14 additions & 0 deletions Source/WebKit/ChangeLog
@@ -1,3 +1,17 @@
2021-03-13 Tim Horton <timothy_horton@apple.com>

Adopt DDMacAction instead of DDAction on macOS
https://bugs.webkit.org/show_bug.cgi?id=223145
<rdar://problem/70127512>

Reviewed by Megan Gardner.

* Platform/mac/MenuUtilities.mm:
(WebKit::actionForMenuItem):
(WebKit::menuItemForTelephoneNumber):
(WebKit::menuForTelephoneNumber):
Adopt the new class name, when available.

2021-03-12 Jer Noble <jer.noble@apple.com>

[Cocoa][WebM] Hang when reloading page before WebM content is loaded
Expand Down
47 changes: 28 additions & 19 deletions Source/WebKit/Platform/mac/MenuUtilities.mm
Expand Up @@ -49,6 +49,29 @@
return [getTUCallClass() supplementalDialTelephonyCallString];
}

#if HAVE(DATA_DETECTORS_MAC_ACTION)
static DDMacAction *actionForMenuItem(NSMenuItem *item)
#else
static DDAction *actionForMenuItem(NSMenuItem *item)
#endif
{
NSDictionary *representedObject = item.representedObject;
if (![representedObject isKindOfClass:[NSDictionary class]])
return nil;

id action = [representedObject objectForKey:@"DDAction"];

#if HAVE(DATA_DETECTORS_MAC_ACTION)
if (![action isKindOfClass:getDDMacActionClass()])
return nil;
#else
if (![action isKindOfClass:getDDActionClass()])
return nil;
#endif

return action;
}

NSMenuItem *menuItemForTelephoneNumber(const String& telephoneNumber)
{
if (!DataDetectorsLibrary())
Expand All @@ -59,15 +82,8 @@

NSArray *proposedMenuItems = [[getDDActionsManagerClass() sharedManager] menuItemsForValue:(NSString *)telephoneNumber type:getDDBinderPhoneNumberKey() service:nil context:actionContext.get()];
for (NSMenuItem *item in proposedMenuItems) {
NSDictionary *representedObject = item.representedObject;
if (![representedObject isKindOfClass:[NSDictionary class]])
continue;

DDAction *actionObject = [representedObject objectForKey:@"DDAction"];
if (![actionObject isKindOfClass:getDDActionClass()])
continue;

if ([actionObject.actionUTI hasPrefix:@"com.apple.dial"]) {
auto action = actionForMenuItem(item);
if ([action.actionUTI hasPrefix:@"com.apple.dial"]) {
item.title = formattedPhoneNumberString(telephoneNumber);
return item;
}
Expand All @@ -90,17 +106,10 @@

NSArray *proposedMenuItems = [[getDDActionsManagerClass() sharedManager] menuItemsForValue:(NSString *)telephoneNumber type:getDDBinderPhoneNumberKey() service:nil context:actionContext.get()];
for (NSMenuItem *item in proposedMenuItems) {
NSDictionary *representedObject = item.representedObject;
if (![representedObject isKindOfClass:[NSDictionary class]])
continue;

DDAction *actionObject = [representedObject objectForKey:@"DDAction"];
if (![actionObject isKindOfClass:getDDActionClass()])
continue;

if ([actionObject.actionUTI hasPrefix:@"com.apple.dial"])
auto action = actionForMenuItem(item);
if ([action.actionUTI hasPrefix:@"com.apple.dial"])
dialItem = item;
else if ([actionObject.actionUTI hasPrefix:@"com.apple.facetime"])
else if ([action.actionUTI hasPrefix:@"com.apple.facetime"])
[faceTimeItems addObject:item];
}

Expand Down

0 comments on commit 9482e84

Please sign in to comment.