- Revision
- 270332
- Author
- [email protected]
- Date
- 2020-12-01 16:54:31 -0800 (Tue, 01 Dec 2020)
Log Message
[iOS] Support image extraction interactions for accessibility
https://bugs.webkit.org/show_bug.cgi?id=219398
<rdar://problem/70744914>
Reviewed by Devin Rousso.
Adds support for a new accessibility feature related to images. Refer to the bug for more details.
* Shared/ios/InteractionInformationRequest.cpp:
(WebKit::InteractionInformationRequest::encode const):
(WebKit::InteractionInformationRequest::decode):
(WebKit::InteractionInformationRequest::isValidForRequest const):
* Shared/ios/InteractionInformationRequest.h:
Add a new flag to request image data via position information. This flag works similarly to the existing
`includeSnapshot` flag, except that it only grabs data when the hit-tested node is an image. As such, a position
information request with the `includeSnapshot` flag set is valid for an identical request with this new
`includeImageData` flag set, but not vice versa.
* SourcesCocoa.txt:
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
Add various extension points for new WebKitAdditions snippets.
(-[WKContentView setUpInteraction]):
(-[WKContentView cleanUpInteraction]):
Call new methods to set up and tear down the image extraction interaction (defined in WebKitAdditions).
(-[WKContentView _webTouchEventsRecognized:]):
Upon starting a new gesture, reset the active (or pending) image extraction interaction, if appropriate.
(-[WKContentView gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]):
Allow the image extraction gesture to fire alongside any other gesture.
(-[WKContentView _dragInteraction:prepareForSession:completion:]):
(-[WKContentView _contextMenuInteraction:configurationForMenuAtLocation:completion:]):
These existing interactions may conflict with pending image extraction interactions. Luckily, since these
interactions are both asynchronous, we're able to defer them until any pending image extraction request has
finished, to determine whether or not they should commence. In both cases, image extraction should take
precedence over dragging and context menus.
* UIProcess/ios/WKImageExtractionGestureRecognizer.h:
* UIProcess/ios/WKImageExtractionGestureRecognizer.mm:
Add a new long press gesture recognizer that fires on a very short (100ms) delay. This gesture is used to
preflight image extraction requests ahead of the other long press gestures (in particular, context menus), such
that these other gestures should be minimally impacted by the time required to perform image extraction.
This is still a long press gesture instead of a regular gesture recognizer, since preflighting image extraction
requests could be expensive if performed during every single gesture (i.e. scrolling, taps, etc).
(-[WKImageExtractionGestureRecognizer initWithDelegate:]):
(-[WKImageExtractionGestureRecognizer setState:]):
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::imagePositionInformation):
Modified Paths
Added Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (270331 => 270332)
--- trunk/Source/WebKit/ChangeLog 2020-12-02 00:44:23 UTC (rev 270331)
+++ trunk/Source/WebKit/ChangeLog 2020-12-02 00:54:31 UTC (rev 270332)
@@ -1,3 +1,67 @@
+2020-12-01 Wenson Hsieh <[email protected]>
+
+ [iOS] Support image extraction interactions for accessibility
+ https://bugs.webkit.org/show_bug.cgi?id=219398
+ <rdar://problem/70744914>
+
+ Reviewed by Devin Rousso.
+
+ Adds support for a new accessibility feature related to images. Refer to the bug for more details.
+
+ * Shared/ios/InteractionInformationRequest.cpp:
+ (WebKit::InteractionInformationRequest::encode const):
+ (WebKit::InteractionInformationRequest::decode):
+ (WebKit::InteractionInformationRequest::isValidForRequest const):
+ * Shared/ios/InteractionInformationRequest.h:
+
+ Add a new flag to request image data via position information. This flag works similarly to the existing
+ `includeSnapshot` flag, except that it only grabs data when the hit-tested node is an image. As such, a position
+ information request with the `includeSnapshot` flag set is valid for an identical request with this new
+ `includeImageData` flag set, but not vice versa.
+
+ * SourcesCocoa.txt:
+ * UIProcess/ios/WKContentViewInteraction.h:
+ * UIProcess/ios/WKContentViewInteraction.mm:
+
+ Add various extension points for new WebKitAdditions snippets.
+
+ (-[WKContentView setUpInteraction]):
+ (-[WKContentView cleanUpInteraction]):
+
+ Call new methods to set up and tear down the image extraction interaction (defined in WebKitAdditions).
+
+ (-[WKContentView _webTouchEventsRecognized:]):
+
+ Upon starting a new gesture, reset the active (or pending) image extraction interaction, if appropriate.
+
+ (-[WKContentView gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]):
+
+ Allow the image extraction gesture to fire alongside any other gesture.
+
+ (-[WKContentView _dragInteraction:prepareForSession:completion:]):
+ (-[WKContentView _contextMenuInteraction:configurationForMenuAtLocation:completion:]):
+
+ These existing interactions may conflict with pending image extraction interactions. Luckily, since these
+ interactions are both asynchronous, we're able to defer them until any pending image extraction request has
+ finished, to determine whether or not they should commence. In both cases, image extraction should take
+ precedence over dragging and context menus.
+
+ * UIProcess/ios/WKImageExtractionGestureRecognizer.h:
+ * UIProcess/ios/WKImageExtractionGestureRecognizer.mm:
+
+ Add a new long press gesture recognizer that fires on a very short (100ms) delay. This gesture is used to
+ preflight image extraction requests ahead of the other long press gestures (in particular, context menus), such
+ that these other gestures should be minimally impacted by the time required to perform image extraction.
+
+ This is still a long press gesture instead of a regular gesture recognizer, since preflighting image extraction
+ requests could be expensive if performed during every single gesture (i.e. scrolling, taps, etc).
+
+ (-[WKImageExtractionGestureRecognizer initWithDelegate:]):
+ (-[WKImageExtractionGestureRecognizer setState:]):
+ * WebKit.xcodeproj/project.pbxproj:
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::imagePositionInformation):
+
2020-12-01 Per Arne Vollan <[email protected]>
[macCatalyst] Embedded YouTube videos fail to play
Modified: trunk/Source/WebKit/Shared/ios/InteractionInformationRequest.cpp (270331 => 270332)
--- trunk/Source/WebKit/Shared/ios/InteractionInformationRequest.cpp 2020-12-02 00:44:23 UTC (rev 270331)
+++ trunk/Source/WebKit/Shared/ios/InteractionInformationRequest.cpp 2020-12-02 00:54:31 UTC (rev 270332)
@@ -40,6 +40,7 @@
encoder << includeLinkIndicator;
encoder << includeCaretContext;
encoder << includeHasDoubleClickHandler;
+ encoder << includeImageData;
encoder << linkIndicatorShouldHaveLegacyMargins;
}
@@ -60,6 +61,9 @@
if (!decoder.decode(result.includeHasDoubleClickHandler))
return false;
+ if (!decoder.decode(result.includeImageData))
+ return false;
+
if (!decoder.decode(result.linkIndicatorShouldHaveLegacyMargins))
return false;
@@ -80,6 +84,10 @@
if (other.includeHasDoubleClickHandler && !includeHasDoubleClickHandler)
return false;
+ // If `includeSnapshot` is set, then we will include data for images as well.
+ if (other.includeImageData && !includeImageData && !includeSnapshot)
+ return false;
+
if (other.linkIndicatorShouldHaveLegacyMargins != linkIndicatorShouldHaveLegacyMargins)
return false;
Modified: trunk/Source/WebKit/Shared/ios/InteractionInformationRequest.h (270331 => 270332)
--- trunk/Source/WebKit/Shared/ios/InteractionInformationRequest.h 2020-12-02 00:44:23 UTC (rev 270331)
+++ trunk/Source/WebKit/Shared/ios/InteractionInformationRequest.h 2020-12-02 00:54:31 UTC (rev 270332)
@@ -43,6 +43,7 @@
bool includeLinkIndicator { false };
bool includeCaretContext { false };
bool includeHasDoubleClickHandler { true };
+ bool includeImageData { false };
bool linkIndicatorShouldHaveLegacyMargins { false };
Modified: trunk/Source/WebKit/SourcesCocoa.txt (270331 => 270332)
--- trunk/Source/WebKit/SourcesCocoa.txt 2020-12-02 00:44:23 UTC (rev 270331)
+++ trunk/Source/WebKit/SourcesCocoa.txt 2020-12-02 00:54:31 UTC (rev 270332)
@@ -462,6 +462,7 @@
UIProcess/ios/WKGeolocationProviderIOS.mm
UIProcess/ios/WKGeolocationProviderIOSObjCSecurityOrigin.mm
UIProcess/ios/WKHighlightLongPressGestureRecognizer.mm
+UIProcess/ios/WKImageExtractionGestureRecognizer.mm
UIProcess/ios/WKKeyboardScrollingAnimator.mm
UIProcess/ios/WKMouseDeviceObserver.mm
UIProcess/ios/WKMouseGestureRecognizer.mm
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (270331 => 270332)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h 2020-12-02 00:44:23 UTC (rev 270331)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h 2020-12-02 00:54:31 UTC (rev 270332)
@@ -118,6 +118,10 @@
@class _UILookupGestureRecognizer;
@class _UIHighlightView;
+#if USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/WKContentViewInteractionAdditionsBefore.h>
+#endif
+
typedef void (^UIWKAutocorrectionCompletionHandler)(UIWKAutocorrectionRects *rectsForInput);
typedef void (^UIWKAutocorrectionContextHandler)(UIWKAutocorrectionContext *autocorrectionContext);
typedef void (^UIWKDictationContextHandler)(NSString *selectedText, NSString *beforeText, NSString *afterText);
@@ -424,6 +428,17 @@
#endif
Vector<BlockPtr<void()>> _actionsToPerformAfterResettingSingleTapGestureRecognizer;
+
+#if ENABLE(IMAGE_EXTRACTION)
+ RetainPtr<WKImageExtractionGestureRecognizer> _imageExtractionGestureRecognizer;
+ WebKit::ImageExtractionState _imageExtractionState;
+ CGRect _imageExtractionInteractionBounds;
+ Vector<BlockPtr<void()>> _actionsToPerformAfterPendingImageExtraction;
+#endif
+
+#if USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/WKContentViewInteractionAdditionsAfter.h>
+#endif
}
@end
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (270331 => 270332)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2020-12-02 00:44:23 UTC (rev 270331)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2020-12-02 00:54:31 UTC (rev 270332)
@@ -138,6 +138,10 @@
#import <wtf/cocoa/VectorCocoa.h>
#import <wtf/text/TextStream.h>
+#if USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/WKContentViewInteractionAdditionsBefore.mm>
+#endif
+
#if ENABLE(DRAG_SUPPORT)
#import <WebCore/DragData.h>
#import <WebCore/DragItem.h>
@@ -892,6 +896,10 @@
_page->process().updateTextCheckerState();
_page->setScreenIsBeingCaptured([[[self window] screen] isCaptured]);
+#if ENABLE(IMAGE_EXTRACTION)
+ [self _setUpImageExtraction];
+#endif
+
_hasSetUpInteractions = YES;
}
@@ -1045,6 +1053,10 @@
_dataListTextSuggestions = nil;
#endif
+#if ENABLE(IMAGE_EXTRACTION)
+ [self _tearDownImageExtraction];
+#endif
+
_hasSetUpInteractions = NO;
_suppressSelectionAssistantReasons = { };
@@ -1508,6 +1520,10 @@
[self doAfterPositionInformationUpdate:[assistant = WeakObjCPtr<WKActionSheetAssistant>(_actionSheetAssistant.get())] (WebKit::InteractionInformationAtPosition information) {
[assistant interactionDidStartWithPositionInformation:information];
} forRequest:positionInformationRequest];
+
+#if ENABLE(IMAGE_EXTRACTION)
+ [self _cancelImageExtractionIfNeeded:_lastInteractionLocation];
+#endif
}
#if ENABLE(TOUCH_EVENTS)
@@ -2171,6 +2187,11 @@
if (isSamePair(gestureRecognizer, otherGestureRecognizer, _doubleTapGestureRecognizer.get(), _doubleTapGestureRecognizerForDoubleClick.get()))
return YES;
+#if ENABLE(IMAGE_EXTRACTION)
+ if (gestureRecognizer == _imageExtractionGestureRecognizer)
+ return YES;
+#endif
+
return NO;
}
@@ -8104,12 +8125,31 @@
[self cleanUpDragSourceSessionState];
- _dragDropInteractionState.prepareForDragSession(session, completion);
+ auto prepareForSession = [weakSelf = WeakObjCPtr<WKContentView>(self), session = retainPtr(session), completion = makeBlockPtr(completion)] {
+ auto strongSelf = weakSelf.get();
+ if (!strongSelf)
+ return;
- auto dragOrigin = WebCore::roundedIntPoint([session locationInView:self]);
- _page->requestDragStart(dragOrigin, WebCore::roundedIntPoint([self convertPoint:dragOrigin toView:self.window]), self._allowedDragSourceActions);
+#if ENABLE(IMAGE_EXTRACTION)
+ if (strongSelf->_imageExtractionState == WebKit::ImageExtractionState::Active) {
+ RELEASE_LOG(DragAndDrop, "Drag session failed: %p (deferring to active image extraction)", session.get());
+ completion();
+ return;
+ }
+#endif
- RELEASE_LOG(DragAndDrop, "Drag session requested: %p at origin: {%d, %d}", session, dragOrigin.x(), dragOrigin.y());
+ strongSelf->_dragDropInteractionState.prepareForDragSession(session.get(), completion.get());
+
+ auto dragOrigin = WebCore::roundedIntPoint([session locationInView:strongSelf.get()]);
+ strongSelf->_page->requestDragStart(dragOrigin, WebCore::roundedIntPoint([strongSelf convertPoint:dragOrigin toView:[strongSelf window]]), [strongSelf _allowedDragSourceActions]);
+ RELEASE_LOG(DragAndDrop, "Drag session requested: %p at origin: {%d, %d}", session.get(), dragOrigin.x(), dragOrigin.y());
+ };
+
+#if ENABLE(IMAGE_EXTRACTION)
+ [self _doAfterPendingImageExtraction:prepareForSession];
+#else
+ prepareForSession();
+#endif
}
- (NSArray<UIDragItem *> *)dragInteraction:(UIDragInteraction *)interaction itemsForBeginningSession:(id <UIDragSession>)session
@@ -8995,6 +9035,10 @@
#endif // ENABLE(ATTACHMENT_ELEMENT)
+#if USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/WKContentViewInteractionAdditionsAfter.mm>
+#endif
+
@end
@implementation WKContentView (WKTesting)
@@ -9437,24 +9481,43 @@
if (!self.webView.configuration._longPressActionsEnabled)
return completion(nil);
- [_webView _didShowContextMenu];
-
- _showLinkPreviews = true;
- if (NSNumber *value = [[NSUserDefaults standardUserDefaults] objectForKey:webkitShowLinkPreviewsPreferenceKey])
- _showLinkPreviews = value.boolValue;
+ auto getConfigurationAndContinue = [weakSelf = WeakObjCPtr<WKContentView>(self), interaction = retainPtr(interaction), completion = makeBlockPtr(completion)] {
+ auto strongSelf = weakSelf.get();
+ if (!strongSelf)
+ return;
- const auto position = [interaction locationInView:self];
- WebKit::InteractionInformationRequest request { WebCore::roundedIntPoint(position) };
- request.includeSnapshot = true;
- request.includeLinkIndicator = true;
- request.linkIndicatorShouldHaveLegacyMargins = !self._shouldUseContextMenus;
+#if ENABLE(IMAGE_EXTRACTION)
+ if (strongSelf->_imageExtractionState == WebKit::ImageExtractionState::Active) {
+ completion(nil);
+ return;
+ }
+#endif
- [self doAfterPositionInformationUpdate:[weakSelf = WeakObjCPtr<WKContentView>(self), completion = makeBlockPtr(completion)] (WebKit::InteractionInformationAtPosition) {
- auto strongSelf = weakSelf.get();
- if (!strongSelf)
- return completion(nil);
- [strongSelf continueContextMenuInteraction:completion.get()];
- } forRequest:request];
+ [strongSelf->_webView _didShowContextMenu];
+
+ strongSelf->_showLinkPreviews = true;
+ if (NSNumber *value = [[NSUserDefaults standardUserDefaults] objectForKey:webkitShowLinkPreviewsPreferenceKey])
+ strongSelf->_showLinkPreviews = value.boolValue;
+
+ const auto position = [interaction locationInView:strongSelf.get()];
+ WebKit::InteractionInformationRequest request { WebCore::roundedIntPoint(position) };
+ request.includeSnapshot = true;
+ request.includeLinkIndicator = true;
+ request.linkIndicatorShouldHaveLegacyMargins = ![strongSelf _shouldUseContextMenus];
+
+ [strongSelf doAfterPositionInformationUpdate:[weakSelf = WeakObjCPtr<WKContentView>(strongSelf.get()), completion] (WebKit::InteractionInformationAtPosition) {
+ if (auto strongSelf = weakSelf.get())
+ [strongSelf continueContextMenuInteraction:completion.get()];
+ else
+ completion(nil);
+ } forRequest:request];
+ };
+
+#if ENABLE(IMAGE_EXTRACTION)
+ [self _doAfterPendingImageExtraction:getConfigurationAndContinue];
+#else
+ getConfigurationAndContinue();
+#endif
}
- (void)continueContextMenuInteraction:(void(^)(UIContextMenuConfiguration *))continueWithContextMenuConfiguration
Copied: trunk/Source/WebKit/UIProcess/ios/WKImageExtractionGestureRecognizer.h (from rev 270331, trunk/Source/WebKit/Shared/ios/InteractionInformationRequest.h) (0 => 270332)
--- trunk/Source/WebKit/UIProcess/ios/WKImageExtractionGestureRecognizer.h (rev 0)
+++ trunk/Source/WebKit/UIProcess/ios/WKImageExtractionGestureRecognizer.h 2020-12-02 00:54:31 UTC (rev 270332)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+#pragma once
+
+#if PLATFORM(IOS_FAMILY) && ENABLE(IMAGE_EXTRACTION)
+
+#include <UIKit/UIKit.h>
+
+@class WKImageExtractionGestureRecognizer;
+
+@protocol WKImageExtractionGestureRecognizerDelegate <UIGestureRecognizerDelegate>
+- (void)imageExtractionGestureDidBegin:(WKImageExtractionGestureRecognizer *)gesture;
+@end
+
+@interface WKImageExtractionGestureRecognizer : UILongPressGestureRecognizer
+
+- (instancetype)initWithImageExtractionGestureDelegate:(UIView <WKImageExtractionGestureRecognizerDelegate> *)delegate;
+
+@end
+
+#endif // PLATFORM(IOS_FAMILY) && ENABLE(IMAGE_EXTRACTION)
Copied: trunk/Source/WebKit/UIProcess/ios/WKImageExtractionGestureRecognizer.mm (from rev 270331, trunk/Source/WebKit/Shared/ios/InteractionInformationRequest.h) (0 => 270332)
--- trunk/Source/WebKit/UIProcess/ios/WKImageExtractionGestureRecognizer.mm (rev 0)
+++ trunk/Source/WebKit/UIProcess/ios/WKImageExtractionGestureRecognizer.mm 2020-12-02 00:54:31 UTC (rev 270332)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+#include "config.h"
+#include "WKImageExtractionGestureRecognizer.h"
+
+#if PLATFORM(IOS_FAMILY) && ENABLE(IMAGE_EXTRACTION)
+
+@implementation WKImageExtractionGestureRecognizer {
+ __weak UIView <WKImageExtractionGestureRecognizerDelegate> *_imageExtractionDelegate;
+}
+
+- (instancetype)initWithImageExtractionGestureDelegate:(UIView <WKImageExtractionGestureRecognizerDelegate> *)delegate
+{
+ if (!(self = [super init]))
+ return nil;
+
+ _imageExtractionDelegate = delegate;
+ self.delegate = delegate;
+ self.minimumPressDuration = 0.1;
+ self.allowableMovement = 0;
+ self.name = @"Image extraction";
+ return self;
+}
+
+- (void)setState:(UIGestureRecognizerState)state
+{
+ auto previousState = self.state;
+ super.state = state;
+
+ auto newState = self.state;
+ if (previousState != newState && newState == UIGestureRecognizerStateBegan)
+ [_imageExtractionDelegate imageExtractionGestureDidBegin:self];
+}
+
+@end
+
+#endif // PLATFORM(IOS_FAMILY) && ENABLE(IMAGE_EXTRACTION)
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (270331 => 270332)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2020-12-02 00:44:23 UTC (rev 270331)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2020-12-02 00:54:31 UTC (rev 270332)
@@ -1934,6 +1934,7 @@
F48D2A8521583A7E00C6752B /* AppKitSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = F48D2A8421583A0200C6752B /* AppKitSPI.h */; };
F496A4311F58A272004C1757 /* DragDropInteractionState.h in Headers */ = {isa = PBXBuildFile; fileRef = F496A42F1F58A272004C1757 /* DragDropInteractionState.h */; };
F4A6D6BC254CA3E900B65FAA /* SharedDisplayListHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = F4A6D6BB254CA3E900B65FAA /* SharedDisplayListHandle.h */; };
+ F4BA33F225757E89000A3CE8 /* WKImageExtractionGestureRecognizer.h in Headers */ = {isa = PBXBuildFile; fileRef = F4BA33F025757E89000A3CE8 /* WKImageExtractionGestureRecognizer.h */; };
F4CB09E5225D5A0900891487 /* WebsiteMediaSourcePolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = F4CB09E4225D5A0300891487 /* WebsiteMediaSourcePolicy.h */; };
F4D5F51D206087A10038BBA8 /* WKTextInputListViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = F4D5F519206087A00038BBA8 /* WKTextInputListViewController.h */; };
F4D5F51F206087A10038BBA8 /* WKQuickboardListViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = F4D5F51B206087A10038BBA8 /* WKQuickboardListViewController.h */; };
@@ -5602,6 +5603,8 @@
F4A6D6BB254CA3E900B65FAA /* SharedDisplayListHandle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SharedDisplayListHandle.h; sourceTree = "<group>"; };
F4AC655E22A3140E00A05607 /* WebPreferencesDefaultValuesIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebPreferencesDefaultValuesIOS.mm; path = ios/WebPreferencesDefaultValuesIOS.mm; sourceTree = "<group>"; };
F4B378D021DDBBAB0095A378 /* WebUndoStepID.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebUndoStepID.h; sourceTree = "<group>"; };
+ F4BA33F025757E89000A3CE8 /* WKImageExtractionGestureRecognizer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WKImageExtractionGestureRecognizer.h; path = ios/WKImageExtractionGestureRecognizer.h; sourceTree = "<group>"; };
+ F4BA33F125757E89000A3CE8 /* WKImageExtractionGestureRecognizer.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = WKImageExtractionGestureRecognizer.mm; path = ios/WKImageExtractionGestureRecognizer.mm; sourceTree = "<group>"; };
F4CB09E4225D5A0300891487 /* WebsiteMediaSourcePolicy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebsiteMediaSourcePolicy.h; sourceTree = "<group>"; };
F4D5F519206087A00038BBA8 /* WKTextInputListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKTextInputListViewController.h; path = ios/forms/WKTextInputListViewController.h; sourceTree = "<group>"; };
F4D5F51A206087A10038BBA8 /* WKTextInputListViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKTextInputListViewController.mm; path = ios/forms/WKTextInputListViewController.mm; sourceTree = "<group>"; };
@@ -7279,6 +7282,8 @@
0FCB4E4118BBE044000FCFC9 /* WKGeolocationProviderIOSObjCSecurityOrigin.mm */,
F4DB54E42319E733009E3155 /* WKHighlightLongPressGestureRecognizer.h */,
F4DB54E52319E733009E3155 /* WKHighlightLongPressGestureRecognizer.mm */,
+ F4BA33F025757E89000A3CE8 /* WKImageExtractionGestureRecognizer.h */,
+ F4BA33F125757E89000A3CE8 /* WKImageExtractionGestureRecognizer.mm */,
933DF82D1B3BC09000AEA9E3 /* WKImagePreviewViewController.h */,
933DF82F1B3BC0B400AEA9E3 /* WKImagePreviewViewController.mm */,
2DD5E127210ADC7A00DB6012 /* WKKeyboardScrollingAnimator.h */,
@@ -12055,6 +12060,7 @@
5123CF1C133D260A0056F800 /* WKIconDatabaseCG.h in Headers */,
BCCF6AC312C91F34008F9C35 /* WKImage.h in Headers */,
BCCF6ACA12C91F59008F9C35 /* WKImageCG.h in Headers */,
+ F4BA33F225757E89000A3CE8 /* WKImageExtractionGestureRecognizer.h in Headers */,
933DF82E1B3BC09000AEA9E3 /* WKImagePreviewViewController.h in Headers */,
9321D5861A38EE3C008052BE /* WKImmediateActionController.h in Headers */,
9321D58A1A38F196008052BE /* WKImmediateActionTypes.h in Headers */,
Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (270331 => 270332)
--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2020-12-02 00:44:23 UTC (rev 270331)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2020-12-02 00:54:31 UTC (rev 270332)
@@ -2634,7 +2634,7 @@
info.imageURL = element.document().completeURL(renderImage.cachedImage()->url().string());
info.isAnimatedImage = image->isAnimated();
- if (!request.includeSnapshot)
+ if (!request.includeSnapshot && !request.includeImageData)
return;
FloatSize screenSizeInPixels = screenSize();