Diff
Modified: trunk/Source/WTF/ChangeLog (272996 => 272997)
--- trunk/Source/WTF/ChangeLog 2021-02-17 14:16:57 UTC (rev 272996)
+++ trunk/Source/WTF/ChangeLog 2021-02-17 15:49:49 UTC (rev 272997)
@@ -1,3 +1,15 @@
+2021-02-17 Wenson Hsieh <wenson_hs...@apple.com>
+
+ [macOS] Introduce a new context menu item to preview images
+ https://bugs.webkit.org/show_bug.cgi?id=221917
+ <rdar://problem/74363578>
+
+ Reviewed by Darin Adler and Tim Horton.
+
+ Add a new soft-linking macro to optionally link against an umbrella framework.
+
+ * wtf/cocoa/SoftLinking.h:
+
2021-02-16 Sam Weinig <wei...@apple.com>
Add CSS property to enable separated bit on GraphicsLayer
Modified: trunk/Source/WTF/wtf/cocoa/SoftLinking.h (272996 => 272997)
--- trunk/Source/WTF/wtf/cocoa/SoftLinking.h 2021-02-17 14:16:57 UTC (rev 272996)
+++ trunk/Source/WTF/wtf/cocoa/SoftLinking.h 2021-02-17 15:49:49 UTC (rev 272997)
@@ -123,6 +123,13 @@
return frameworkLibrary; \
}
+#define SOFT_LINK_FRAMEWORK_IN_UMBRELLA_OPTIONAL(umbrella, framework) \
+ static void* framework##Library() \
+ { \
+ static void* frameworkLibrary = dlopen("/System/Library/Frameworks/" #umbrella ".framework/Frameworks/" #framework ".framework/" #framework, RTLD_NOW); \
+ return frameworkLibrary; \
+ }
+
#define SOFT_LINK(framework, functionName, resultType, parameterDeclarations, parameterNames) \
WTF_EXTERN_C_BEGIN \
resultType functionName parameterDeclarations; \
Modified: trunk/Source/WebCore/ChangeLog (272996 => 272997)
--- trunk/Source/WebCore/ChangeLog 2021-02-17 14:16:57 UTC (rev 272996)
+++ trunk/Source/WebCore/ChangeLog 2021-02-17 15:49:49 UTC (rev 272997)
@@ -1,3 +1,25 @@
+2021-02-17 Wenson Hsieh <wenson_hs...@apple.com>
+
+ [macOS] Introduce a new context menu item to preview images
+ https://bugs.webkit.org/show_bug.cgi?id=221917
+ <rdar://problem/74363578>
+
+ Reviewed by Darin Adler and Tim Horton.
+
+ Add plumbing for a new context menu tag, `ContextMenuItemTagRevealImage`, which will be used to invoke a special
+ type of QuickLook preview for extracted images when the relevant accessibility features are enabled.
+
+ * page/ContextMenuController.cpp:
+ (WebCore::ContextMenuController::contextMenuItemSelected):
+ (WebCore::ContextMenuController::populate):
+ (WebCore::ContextMenuController::checkOrEnableIfNeeded const):
+ * platform/ContextMenuItem.cpp:
+ (WebCore::isValidContextMenuAction):
+ * platform/ContextMenuItem.h:
+ * platform/LocalizedStrings.h:
+ * platform/cocoa/LocalizedStringsCocoa.mm:
+ (WebCore::contextMenuItemTagRevealImage):
+
2021-02-17 Andres Gonzalez <andresg...@apple.com>
Support aria-errormessage on iOS.
Modified: trunk/Source/WebCore/page/ContextMenuController.cpp (272996 => 272997)
--- trunk/Source/WebCore/page/ContextMenuController.cpp 2021-02-17 14:16:57 UTC (rev 272996)
+++ trunk/Source/WebCore/page/ContextMenuController.cpp 2021-02-17 15:49:49 UTC (rev 272997)
@@ -517,6 +517,10 @@
case ContextMenuItemTagDictationAlternative:
frame->editor().applyDictationAlternative(title);
break;
+ case ContextMenuItemTagRevealImage:
+ // This should be handled at the client layer.
+ ASSERT_NOT_REACHED();
+ break;
default:
break;
}
@@ -810,6 +814,9 @@
ContextMenuItem SelectAllItem(ActionType, ContextMenuItemTagSelectAll, contextMenuItemTagSelectAll());
ContextMenuItem InsertEmojiItem(ActionType, ContextMenuItemTagInsertEmoji, contextMenuItemTagInsertEmoji());
#endif
+#if ENABLE(IMAGE_EXTRACTION)
+ ContextMenuItem RevealImageItem(ActionType, ContextMenuItemTagRevealImage, contextMenuItemTagRevealImage());
+#endif
#if PLATFORM(GTK) || PLATFORM(WIN)
ContextMenuItem ShareMenuItem;
@@ -856,8 +863,13 @@
appendItem(OpenImageInNewWindowItem, m_contextMenu.get());
appendItem(DownloadImageItem, m_contextMenu.get());
- if (imageURL.isLocalFile() || m_context.hitTestResult().image())
+ if (imageURL.isLocalFile() || m_context.hitTestResult().image()) {
appendItem(CopyImageItem, m_contextMenu.get());
+
+#if ENABLE(IMAGE_EXTRACTION)
+ appendItem(RevealImageItem, m_contextMenu.get());
+#endif
+ }
#if PLATFORM(GTK)
appendItem(CopyImageUrlItem, m_contextMenu.get());
#endif
@@ -1450,6 +1462,8 @@
shouldEnable = m_context.hitTestResult().mediaHasAudio();
shouldCheck = shouldEnable && m_context.hitTestResult().mediaMuted();
break;
+ case ContextMenuItemTagRevealImage:
+ break;
}
item.setChecked(shouldCheck);
Modified: trunk/Source/WebCore/platform/ContextMenuItem.cpp (272996 => 272997)
--- trunk/Source/WebCore/platform/ContextMenuItem.cpp 2021-02-17 14:16:57 UTC (rev 272996)
+++ trunk/Source/WebCore/platform/ContextMenuItem.cpp 2021-02-17 15:49:49 UTC (rev 272997)
@@ -246,6 +246,7 @@
case ContextMenuAction::ContextMenuItemTagToggleVideoFullscreen:
case ContextMenuAction::ContextMenuItemTagShareMenu:
case ContextMenuAction::ContextMenuItemTagToggleVideoEnhancedFullscreen:
+ case ContextMenuAction::ContextMenuItemTagRevealImage:
case ContextMenuAction::ContextMenuItemBaseCustomTag:
case ContextMenuAction::ContextMenuItemLastCustomTag:
case ContextMenuAction::ContextMenuItemBaseApplicationTag:
Modified: trunk/Source/WebCore/platform/ContextMenuItem.h (272996 => 272997)
--- trunk/Source/WebCore/platform/ContextMenuItem.h 2021-02-17 14:16:57 UTC (rev 272996)
+++ trunk/Source/WebCore/platform/ContextMenuItem.h 2021-02-17 15:49:49 UTC (rev 272997)
@@ -149,6 +149,7 @@
ContextMenuItemTagAddHighlightToCurrentGroup,
ContextMenuItemTagAddHighlightToNewGroup,
#endif
+ ContextMenuItemTagRevealImage,
ContextMenuItemBaseCustomTag = 5000,
ContextMenuItemLastCustomTag = 5999,
ContextMenuItemBaseApplicationTag = 10000
Modified: trunk/Source/WebCore/platform/LocalizedStrings.h (272996 => 272997)
--- trunk/Source/WebCore/platform/LocalizedStrings.h 2021-02-17 14:16:57 UTC (rev 272996)
+++ trunk/Source/WebCore/platform/LocalizedStrings.h 2021-02-17 15:49:49 UTC (rev 272997)
@@ -350,6 +350,10 @@
WEBCORE_EXPORT String genericTouchIDPromptTitle();
#endif
+#if ENABLE(IMAGE_EXTRACTION)
+ WEBCORE_EXPORT String contextMenuItemTagRevealImage();
+#endif
+
#if USE(GLIB) && defined(GETTEXT_PACKAGE)
#define WEB_UI_STRING(string, description) WebCore::localizedString(_(string))
#define WEB_UI_STRING_KEY(string, key, description) WebCore::localizedString(C_(key, string))
Modified: trunk/Source/WebCore/platform/cocoa/LocalizedStringsCocoa.mm (272996 => 272997)
--- trunk/Source/WebCore/platform/cocoa/LocalizedStringsCocoa.mm 2021-02-17 14:16:57 UTC (rev 272996)
+++ trunk/Source/WebCore/platform/cocoa/LocalizedStringsCocoa.mm 2021-02-17 15:49:49 UTC (rev 272997)
@@ -306,4 +306,11 @@
}
#endif // PLATFORM(MAC)
+#if ENABLE(IMAGE_EXTRACTION)
+String contextMenuItemTagRevealImage()
+{
+ return localizedNSString(@"Reveal Image");
+}
+#endif
+
} // namespace WebCore
Modified: trunk/Source/WebKit/ChangeLog (272996 => 272997)
--- trunk/Source/WebKit/ChangeLog 2021-02-17 14:16:57 UTC (rev 272996)
+++ trunk/Source/WebKit/ChangeLog 2021-02-17 15:49:49 UTC (rev 272997)
@@ -1,3 +1,50 @@
+2021-02-17 Wenson Hsieh <wenson_hs...@apple.com>
+
+ [macOS] Introduce a new context menu item to preview images
+ https://bugs.webkit.org/show_bug.cgi?id=221917
+ <rdar://problem/74363578>
+
+ Reviewed by Darin Adler and Tim Horton.
+
+ Add plumbing to support the `ContextMenuItemTagRevealImage` action, as well as some WebKitAdditions extension
+ points. See below for more details. This patch was mostly written by Devin Rousso, with some adjustments from
+ me.
+
+ * Configurations/WebKit.xcconfig:
+
+ Link against UniformTypeIdentifiers.
+
+ * Shared/API/c/WKContextMenuItemTypes.h:
+ * Shared/API/c/WKSharedAPICast.h:
+ (WebKit::toAPI):
+ (WebKit::toImpl):
+
+ Add `kWKContextMenuItemTagRevealImage`, and add helpers to convert from `WebCore::ContextMenuItemTagRevealImage`
+ to `kWKContextMenuItemTagRevealImage` and vice versa.
+
+ * Shared/ContextMenuContextData.h:
+ (WebKit::ContextMenuContextData::webHitTestResultData):
+
+ Add a non-const version of `webHitTestResultData()`, so that we can generate a `CGImage` using
+ `WebHitTestResultData`'s bitmap data.
+
+ * UIProcess/API/Cocoa/WKMenuItemIdentifiers.mm:
+ * UIProcess/API/Cocoa/WKMenuItemIdentifiersPrivate.h:
+ * UIProcess/API/Cocoa/_WKElementAction.mm:
+ (+[_WKElementAction _elementActionWithType:customTitle:assistant:]):
+ * UIProcess/Cocoa/WebPageProxyCocoa.mm:
+ (WebKit::WebPageProxy::handleContextMenuRevealImage):
+
+ Add a helper method, `handleContextMenuRevealImage`, to handle the new context menu action; additionally,
+ introduce another helper method, `revealExtractedImageInPreviewPanel`, to handle the Mac-specific
+ `QLPreviewPanel` logic when invoking the new item. See WebKitAdditions changes for more detail.
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::contextMenuItemSelected):
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/mac/WebContextMenuProxyMac.mm:
+ (WebKit::menuItemIdentifier):
+
2021-02-17 Per Arne <pvol...@apple.com>
[macOS] Deny access to unused IOKit classes
Modified: trunk/Source/WebKit/Configurations/WebKit.xcconfig (272996 => 272997)
--- trunk/Source/WebKit/Configurations/WebKit.xcconfig 2021-02-17 14:16:57 UTC (rev 272996)
+++ trunk/Source/WebKit/Configurations/WebKit.xcconfig 2021-02-17 15:49:49 UTC (rev 272997)
@@ -114,6 +114,8 @@
WK_UNIFORM_TYPE_IDENTIFIERS_LDFLAGS_iphonesimulator = $(WK_UNIFORM_TYPE_IDENTIFIERS_LDFLAGS$(WK_IOS_14));
WK_UNIFORM_TYPE_IDENTIFIERS_LDFLAGS_maccatalyst = $(WK_UNIFORM_TYPE_IDENTIFIERS_LDFLAGS$(WK_IOS_14));
WK_UNIFORM_TYPE_IDENTIFIERS_LDFLAGS_IOS_SINCE_14 = -framework UniformTypeIdentifiers;
+WK_UNIFORM_TYPE_IDENTIFIERS_LDFLAGS_macosx = $(WK_UNIFORM_TYPE_IDENTIFIERS_LDFLAGS$(WK_MACOS_1200));
+WK_UNIFORM_TYPE_IDENTIFIERS_LDFLAGS_MACOS_SINCE_1200 = -framework UniformTypeIdentifiers;
WK_URL_FORMATTING_LDFLAGS = $(WK_URL_FORMATTING_LDFLAGS_$(WK_HAVE_URL_FORMATTING));
WK_URL_FORMATTING_LDFLAGS_YES = -framework URLFormatting;
Modified: trunk/Source/WebKit/Shared/API/c/WKContextMenuItemTypes.h (272996 => 272997)
--- trunk/Source/WebKit/Shared/API/c/WKContextMenuItemTypes.h 2021-02-17 14:16:57 UTC (rev 272996)
+++ trunk/Source/WebKit/Shared/API/c/WKContextMenuItemTypes.h 2021-02-17 15:49:49 UTC (rev 272997)
@@ -125,6 +125,7 @@
kWKContextMenuItemTagToggleVideoEnhancedFullscreen,
kWKContextMenuItemTagAddHighlightToCurrentGroup,
kWKContextMenuItemTagAddHighlightToNewGroup,
+ kWKContextMenuItemTagRevealImage,
kWKContextMenuItemBaseApplicationTag = 10000
};
typedef uint32_t WKContextMenuItemTag;
Modified: trunk/Source/WebKit/Shared/API/c/WKSharedAPICast.h (272996 => 272997)
--- trunk/Source/WebKit/Shared/API/c/WKSharedAPICast.h 2021-02-17 14:16:57 UTC (rev 272996)
+++ trunk/Source/WebKit/Shared/API/c/WKSharedAPICast.h 2021-02-17 15:49:49 UTC (rev 272997)
@@ -545,6 +545,8 @@
#endif
case WebCore::ContextMenuItemTagShareMenu:
return kWKContextMenuItemTagShareMenu;
+ case WebCore::ContextMenuItemTagRevealImage:
+ return kWKContextMenuItemTagRevealImage;
default:
if (action < WebCore::ContextMenuItemBaseApplicationTag && !(action >= WebCore::ContextMenuItemBaseCustomTag && action <= WebCore::ContextMenuItemLastCustomTag))
LOG_ERROR("ContextMenuAction %i is an unknown tag but is below the allowable custom tag value of %i", action, WebCore::ContextMenuItemBaseApplicationTag);
@@ -745,6 +747,8 @@
case kWKContextMenuItemTagShareMenu:
return WebCore::ContextMenuItemTagShareMenu;
#endif
+ case kWKContextMenuItemTagRevealImage:
+ return WebCore::ContextMenuItemTagRevealImage;
case kWKContextMenuItemTagOpenLinkInThisWindow:
default:
if (tag < kWKContextMenuItemBaseApplicationTag && !(tag >= WebCore::ContextMenuItemBaseCustomTag && tag <= WebCore::ContextMenuItemLastCustomTag))
Modified: trunk/Source/WebKit/Shared/ContextMenuContextData.h (272996 => 272997)
--- trunk/Source/WebKit/Shared/ContextMenuContextData.h 2021-02-17 14:16:57 UTC (rev 272996)
+++ trunk/Source/WebKit/Shared/ContextMenuContextData.h 2021-02-17 15:49:49 UTC (rev 272997)
@@ -58,6 +58,7 @@
const WebCore::IntPoint& menuLocation() const { return m_menuLocation; }
const Vector<WebKit::WebContextMenuItemData>& menuItems() const { return m_menuItems; }
+ WebHitTestResultData& webHitTestResultData() { return m_webHitTestResultData; }
const WebHitTestResultData& webHitTestResultData() const { return m_webHitTestResultData; }
const String& selectedText() const { return m_selectedText; }
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKMenuItemIdentifiers.mm (272996 => 272997)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKMenuItemIdentifiers.mm 2021-02-17 14:16:57 UTC (rev 272996)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKMenuItemIdentifiers.mm 2021-02-17 15:49:49 UTC (rev 272997)
@@ -47,6 +47,7 @@
NSString * const _WKMenuItemIdentifierOpenMediaInNewWindow = @"WKMenuItemIdentifierOpenMediaInNewWindow";
NSString * const _WKMenuItemIdentifierPaste = @"WKMenuItemIdentifierPaste";
NSString * const _WKMenuItemIdentifierReload = @"WKMenuItemIdentifierReload";
+NSString * const _WKMenuItemIdentifierRevealImage = @"WKMenuItemIdentifierRevealImage";
NSString * const _WKMenuItemIdentifierSearchWeb = @"WKMenuItemIdentifierSearchWeb";
NSString * const _WKMenuItemIdentifierShowHideMediaControls = @"WKMenuItemIdentifierShowHideMediaControls";
NSString * const _WKMenuItemIdentifierToggleEnhancedFullScreen = @"WKMenuItemIdentifierToggleEnhancedFullScreen";
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKMenuItemIdentifiersPrivate.h (272996 => 272997)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKMenuItemIdentifiersPrivate.h 2021-02-17 14:16:57 UTC (rev 272996)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKMenuItemIdentifiersPrivate.h 2021-02-17 15:49:49 UTC (rev 272997)
@@ -46,6 +46,7 @@
WK_EXPORT extern NSString * const _WKMenuItemIdentifierOpenMediaInNewWindow WK_API_AVAILABLE(macos(10.14), ios(12.0));
WK_EXPORT extern NSString * const _WKMenuItemIdentifierPaste WK_API_AVAILABLE(macos(10.12), ios(10.0));
WK_EXPORT extern NSString * const _WKMenuItemIdentifierReload WK_API_AVAILABLE(macos(10.12), ios(10.0));
+WK_EXPORT extern NSString * const _WKMenuItemIdentifierRevealImage WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
WK_EXPORT extern NSString * const _WKMenuItemIdentifierSearchWeb WK_API_AVAILABLE(macos(10.12), ios(10.0));
WK_EXPORT extern NSString * const _WKMenuItemIdentifierShowHideMediaControls WK_API_AVAILABLE(macos(10.12), ios(10.0));
WK_EXPORT extern NSString * const _WKMenuItemIdentifierToggleEnhancedFullScreen WK_API_AVAILABLE(macos(10.14), ios(12.0));
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKElementAction.mm (272996 => 272997)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKElementAction.mm 2021-02-17 14:16:57 UTC (rev 272996)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKElementAction.mm 2021-02-17 15:49:49 UTC (rev 272997)
@@ -171,7 +171,7 @@
break;
case _WKElementActionTypeRevealImage:
#if ENABLE(IMAGE_EXTRACTION)
- title = WebCore::localizedNSString(@"Reveal Image");
+ title = WebCore::contextMenuItemTagRevealImage();
handler = ^(WKActionSheetAssistant *assistant, _WKActivatedElementInfo *actionInfo) {
[assistant handleElementActionWithType:type element:actionInfo needsInteraction:YES];
};
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm (272996 => 272997)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm 2021-02-17 14:16:57 UTC (rev 272996)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm 2021-02-17 15:49:49 UTC (rev 272997)
@@ -76,6 +76,10 @@
SOFT_LINK_CLASS(WebContentAnalysis, WebFilterEvaluator);
#endif
+#if USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/WebPageProxyCocoaAdditionsBefore.mm>
+#endif
+
#define MESSAGE_CHECK(assertion) MESSAGE_CHECK_BASE(assertion, process().connection())
#define MESSAGE_CHECK_COMPLETION(assertion, completion) MESSAGE_CHECK_COMPLETION_BASE(assertion, process().connection(), completion)
@@ -577,6 +581,19 @@
return SandboxExtension::HandleArray();
}
+#if ENABLE(IMAGE_EXTRACTION) && ENABLE(CONTEXT_MENUS)
+
+void WebPageProxy::handleContextMenuRevealImage()
+{
+ auto& result = m_activeContextMenuContextData.webHitTestResultData();
+ if (!result.imageBitmap)
+ return;
+
+ revealExtractedImageInPreviewPanel(*result.imageBitmap, result.toolTipText);
+}
+
+#endif // ENABLE(IMAGE_EXTRACTION) && ENABLE(CONTEXT_MENUS)
+
void WebPageProxy::requestActiveNowPlayingSessionInfo(CompletionHandler<void(bool, bool, const String&, double, double, uint64_t)>&& callback)
{
sendWithAsyncReply(Messages::WebPage::RequestActiveNowPlayingSessionInfo(), WTFMove(callback));
@@ -584,5 +601,9 @@
} // namespace WebKit
+#if USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/WebPageProxyCocoaAdditionsAfter.mm>
+#endif
+
#undef MESSAGE_CHECK_COMPLETION
#undef MESSAGE_CHECK
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (272996 => 272997)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-02-17 14:16:57 UTC (rev 272996)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-02-17 15:49:49 UTC (rev 272997)
@@ -6564,91 +6564,112 @@
return;
}
+ struct DownloadInfo {
+ String url;
+ String suggestedFilename;
+ };
+ Optional<DownloadInfo> downloadInfo;
+
+ switch (item.action()) {
#if PLATFORM(COCOA)
- if (item.action() == ContextMenuItemTagSmartCopyPaste) {
+ case ContextMenuItemTagSmartCopyPaste:
setSmartInsertDeleteEnabled(!isSmartInsertDeleteEnabled());
return;
- }
- if (item.action() == ContextMenuItemTagSmartQuotes) {
+
+ case ContextMenuItemTagSmartQuotes:
TextChecker::setAutomaticQuoteSubstitutionEnabled(!TextChecker::state().isAutomaticQuoteSubstitutionEnabled);
m_process->updateTextCheckerState();
return;
- }
- if (item.action() == ContextMenuItemTagSmartDashes) {
+
+ case ContextMenuItemTagSmartDashes:
TextChecker::setAutomaticDashSubstitutionEnabled(!TextChecker::state().isAutomaticDashSubstitutionEnabled);
m_process->updateTextCheckerState();
return;
- }
- if (item.action() == ContextMenuItemTagSmartLinks) {
+
+ case ContextMenuItemTagSmartLinks:
TextChecker::setAutomaticLinkDetectionEnabled(!TextChecker::state().isAutomaticLinkDetectionEnabled);
m_process->updateTextCheckerState();
return;
- }
- if (item.action() == ContextMenuItemTagTextReplacement) {
+
+ case ContextMenuItemTagTextReplacement:
TextChecker::setAutomaticTextReplacementEnabled(!TextChecker::state().isAutomaticTextReplacementEnabled);
m_process->updateTextCheckerState();
return;
- }
- if (item.action() == ContextMenuItemTagCorrectSpellingAutomatically) {
+
+ case ContextMenuItemTagCorrectSpellingAutomatically:
TextChecker::setAutomaticSpellingCorrectionEnabled(!TextChecker::state().isAutomaticSpellingCorrectionEnabled);
m_process->updateTextCheckerState();
- return;
- }
- if (item.action() == ContextMenuItemTagShowSubstitutions) {
+ return;
+
+ case ContextMenuItemTagShowSubstitutions:
TextChecker::toggleSubstitutionsPanelIsShowing();
return;
- }
#endif
- struct DownloadInfo {
- String url;
- String suggestedFilename;
- };
- Optional<DownloadInfo> downloadInfo;
- if (item.action() == ContextMenuItemTagDownloadImageToDisk)
+
+ case ContextMenuItemTagDownloadImageToDisk:
downloadInfo = {{ m_activeContextMenuContextData.webHitTestResultData().absoluteImageURL, { } }};
- if (item.action() == ContextMenuItemTagDownloadLinkToDisk) {
+ break;
+
+ case ContextMenuItemTagDownloadLinkToDisk: {
auto& hitTestResult = m_activeContextMenuContextData.webHitTestResultData();
downloadInfo = {{ hitTestResult.absoluteLinkURL, hitTestResult.linkSuggestedFilename }};
+ break;
}
- if (item.action() == ContextMenuItemTagDownloadMediaToDisk)
+
+ case ContextMenuItemTagDownloadMediaToDisk:
downloadInfo = {{ m_activeContextMenuContextData.webHitTestResultData().absoluteMediaURL, { } }};
- if (downloadInfo) {
- auto& download = m_process->processPool().download(m_websiteDataStore, this, URL(URL(), downloadInfo->url), downloadInfo->suggestedFilename);
- download.setDidStartCallback([this, weakThis = makeWeakPtr(*this)] (auto* download) {
- if (!weakThis || !download)
- return;
- m_navigationClient->contextMenuDidCreateDownload(*this, *download);
- });
- }
- if (item.action() == ContextMenuItemTagCheckSpellingWhileTyping) {
+ break;
+
+ case ContextMenuItemTagCheckSpellingWhileTyping:
TextChecker::setContinuousSpellCheckingEnabled(!TextChecker::state().isContinuousSpellCheckingEnabled);
m_process->updateTextCheckerState();
return;
- }
- if (item.action() == ContextMenuItemTagCheckGrammarWithSpelling) {
+
+ case ContextMenuItemTagCheckGrammarWithSpelling:
TextChecker::setGrammarCheckingEnabled(!TextChecker::state().isGrammarCheckingEnabled);
m_process->updateTextCheckerState();
return;
- }
- if (item.action() == ContextMenuItemTagShowSpellingPanel) {
+
+ case ContextMenuItemTagShowSpellingPanel:
if (!TextChecker::spellingUIIsShowing())
advanceToNextMisspelling(true);
TextChecker::toggleSpellingUIIsShowing();
return;
- }
+
#if ENABLE(APP_HIGHLIGHTS)
- if (item.action() == ContextMenuItemTagAddHighlightToNewGroup) {
- createAppHighlightInSelectedRange(WebCore::CreateNewGroupForHighlight::Yes);
+ case ContextMenuItemTagAddHighlightToNewGroup:
+ createAppHighlightInSelectedRange(CreateNewGroupForHighlight::Yes);
return;
- }
- if (item.action() == ContextMenuItemTagAddHighlightToCurrentGroup) {
- createAppHighlightInSelectedRange(WebCore::CreateNewGroupForHighlight::No);
+
+ case ContextMenuItemTagAddHighlightToCurrentGroup:
+ createAppHighlightInSelectedRange(CreateNewGroupForHighlight::No);
return;
- }
#endif
- if (item.action() == ContextMenuItemTagLearnSpelling || item.action() == ContextMenuItemTagIgnoreSpelling)
+
+ case ContextMenuItemTagLearnSpelling:
+ case ContextMenuItemTagIgnoreSpelling:
++m_pendingLearnOrIgnoreWordMessageCount;
+ break;
+ case ContextMenuItemTagRevealImage:
+#if ENABLE(IMAGE_EXTRACTION)
+ handleContextMenuRevealImage();
+#endif
+ return;
+
+ default:
+ break;
+ }
+
+ if (downloadInfo) {
+ auto& download = m_process->processPool().download(m_websiteDataStore, this, URL(URL(), downloadInfo->url), downloadInfo->suggestedFilename);
+ download.setDidStartCallback([this, weakThis = makeWeakPtr(*this)] (auto* download) {
+ if (!weakThis || !download)
+ return;
+ m_navigationClient->contextMenuDidCreateDownload(*this, *download);
+ });
+ }
+
platformDidSelectItemFromActiveContextMenu(item);
send(Messages::WebPage::DidSelectItemFromActiveContextMenu(item));
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (272996 => 272997)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2021-02-17 14:16:57 UTC (rev 272996)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2021-02-17 15:49:49 UTC (rev 272997)
@@ -112,6 +112,7 @@
#include <WebCore/ViewportArguments.h>
#include <memory>
#include <wtf/CompletionHandler.h>
+#include <wtf/FileSystem.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/Logger.h>
@@ -183,6 +184,10 @@
#include <WebCore/MediaSessionIdentifier.h>
#endif
+#if USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/WebPageProxyAdditionsBefore.h>
+#endif
+
namespace API {
class Attachment;
class ContentWorld;
@@ -1839,6 +1844,11 @@
void dispatchWheelEventWithoutScrolling(const WebWheelEvent&, CompletionHandler<void(bool)>&&);
+#if ENABLE(IMAGE_EXTRACTION) && ENABLE(CONTEXT_MENUS)
+ void handleContextMenuRevealImage();
+ void resetImageExtractionPreview();
+#endif
+
private:
WebPageProxy(PageClient&, WebProcessProxy&, Ref<API::PageConfiguration>&&);
void platformInitialize();
@@ -2894,6 +2904,10 @@
size_t m_suspendMediaPlaybackCounter { 0 };
Optional<WebCore::PrivateClickMeasurement> m_privateClickMeasurement;
+
+#if USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/WebPageProxyAdditionsAfter.h>
+#endif
};
} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm (272996 => 272997)
--- trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm 2021-02-17 14:16:57 UTC (rev 272996)
+++ trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm 2021-02-17 15:49:49 UTC (rev 272997)
@@ -445,6 +445,9 @@
case ContextMenuItemTagReload:
return _WKMenuItemIdentifierReload;
+ case ContextMenuItemTagRevealImage:
+ return _WKMenuItemIdentifierRevealImage;
+
case ContextMenuItemTagSearchWeb:
return _WKMenuItemIdentifierSearchWeb;
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (272996 => 272997)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2021-02-17 14:16:57 UTC (rev 272996)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2021-02-17 15:49:49 UTC (rev 272997)
@@ -1,3 +1,16 @@
+2021-02-17 Wenson Hsieh <wenson_hs...@apple.com>
+
+ [macOS] Introduce a new context menu item to preview images
+ https://bugs.webkit.org/show_bug.cgi?id=221917
+ <rdar://problem/74363578>
+
+ Reviewed by Darin Adler and Tim Horton.
+
+ Legacy WebKit won't be supporting this new context menu action; see other ChangeLog entries for more details.
+
+ * WebView/WebHTMLView.mm:
+ (toTag):
+
2021-02-16 Megan Gardner <megan_gard...@apple.com>
Change App Highlights API to operate in terms of a single serialized highlight at a time
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm (272996 => 272997)
--- trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm 2021-02-17 14:16:57 UTC (rev 272996)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm 2021-02-17 15:49:49 UTC (rev 272997)
@@ -614,6 +614,8 @@
return WebMenuItemTagShareMenu;
case ContextMenuItemTagToggleVideoEnhancedFullscreen:
return WebMenuItemTagToggleVideoEnhancedFullscreen;
+ case ContextMenuItemTagRevealImage:
+ return WTF::nullopt;
case ContextMenuItemBaseCustomTag ... ContextMenuItemLastCustomTag:
// We just pass these through.
Modified: trunk/Tools/ChangeLog (272996 => 272997)
--- trunk/Tools/ChangeLog 2021-02-17 14:16:57 UTC (rev 272996)
+++ trunk/Tools/ChangeLog 2021-02-17 15:49:49 UTC (rev 272997)
@@ -1,3 +1,16 @@
+2021-02-17 Wenson Hsieh <wenson_hs...@apple.com>
+
+ [macOS] Introduce a new context menu item to preview images
+ https://bugs.webkit.org/show_bug.cgi?id=221917
+ <rdar://problem/74363578>
+
+ Reviewed by Darin Adler and Tim Horton.
+
+ Rebaseline an existing API test, since `ContextMenuItemTagRevealImage` is now the last valid enum.
+
+ * TestWebKitAPI/Tests/WebCore/ContextMenuAction.cpp:
+ (TestWebKitAPI::TEST):
+
2021-02-17 Diego Pino Garcia <dp...@igalia.com>
[Flatpak SDK] Script 'webkit-flatpak-run-nightly' expects different format for a built product name
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/ContextMenuAction.cpp (272996 => 272997)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/ContextMenuAction.cpp 2021-02-17 14:16:57 UTC (rev 272996)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/ContextMenuAction.cpp 2021-02-17 15:49:49 UTC (rev 272997)
@@ -37,9 +37,9 @@
EXPECT_TRUE(WTF::isValidEnum<WebCore::ContextMenuAction>(WebCore::ContextMenuAction::ContextMenuItemTagNoAction));
EXPECT_TRUE(WTF::isValidEnum<WebCore::ContextMenuAction>(WebCore::ContextMenuAction::ContextMenuItemTagNoAction + 1));
- EXPECT_TRUE(WTF::isValidEnum<WebCore::ContextMenuAction>(WebCore::ContextMenuAction::ContextMenuItemTagToggleVideoEnhancedFullscreen - 1));
- EXPECT_TRUE(WTF::isValidEnum<WebCore::ContextMenuAction>(WebCore::ContextMenuAction::ContextMenuItemTagToggleVideoEnhancedFullscreen));
- EXPECT_FALSE(WTF::isValidEnum<WebCore::ContextMenuAction>(WebCore::ContextMenuAction::ContextMenuItemTagToggleVideoEnhancedFullscreen + 1));
+ EXPECT_TRUE(WTF::isValidEnum<WebCore::ContextMenuAction>(WebCore::ContextMenuAction::ContextMenuItemTagRevealImage - 1));
+ EXPECT_TRUE(WTF::isValidEnum<WebCore::ContextMenuAction>(WebCore::ContextMenuAction::ContextMenuItemTagRevealImage));
+ EXPECT_FALSE(WTF::isValidEnum<WebCore::ContextMenuAction>(WebCore::ContextMenuAction::ContextMenuItemTagRevealImage + 1));
EXPECT_FALSE(WTF::isValidEnum<WebCore::ContextMenuAction>(WebCore::ContextMenuAction::ContextMenuItemBaseCustomTag - 1));
EXPECT_TRUE(WTF::isValidEnum<WebCore::ContextMenuAction>(WebCore::ContextMenuAction::ContextMenuItemBaseCustomTag));