WebKit Bugzilla
Attachment 372371 Details for
Bug 198974
: Update WebKit API to separately retrieve actions and use context menus
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-198974-20190618132459.patch (text/plain), 15.94 KB, created by
Alex Christensen
on 2019-06-18 13:25:00 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Alex Christensen
Created:
2019-06-18 13:25:00 PDT
Size:
15.94 KB
patch
obsolete
>Subversion Revision: 246519 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 9deb93c6676f93291b25c17e51f394f55ff97d2b..0ef3cfa496e2ee53ae02a657beea13754d1e7869 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,24 @@ >+2019-06-18 Alex Christensen <achristensen@webkit.org> >+ >+ Update WebKit API to separately retrieve actions and use context menus >+ https://bugs.webkit.org/show_bug.cgi?id=198974 >+ <rdar://problem/50735687> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Update API and SPI, and add infrastructure for asynchronously requesting interaction information. >+ >+ * UIProcess/API/Cocoa/WKUIDelegate.h: >+ * UIProcess/API/Cocoa/WKUIDelegatePrivate.h: >+ * UIProcess/ios/WKContentViewInteraction.h: >+ * UIProcess/ios/WKContentViewInteraction.mm: >+ (-[WKContentView ensurePositionInformationIsUpToDate:]): >+ (-[WKContentView ensurePositionInformationIsUpToDate:completionHandler:]): >+ * WebProcess/WebPage/WebPage.h: >+ * WebProcess/WebPage/WebPage.messages.in: >+ * WebProcess/WebPage/ios/WebPageIOS.mm: >+ (WebKit::WebPage::getPositionInformationSync): >+ > 2019-06-17 Alex Christensen <achristensen@webkit.org> > > Fix internal build after r246514 >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegate.h b/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegate.h >index a3544cea470f69cab469de62768b3dafe8c1bca1..27d80ba662a7074c6c9987aaccbcd85b2b835a2d 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegate.h >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegate.h >@@ -39,6 +39,12 @@ NS_ASSUME_NONNULL_BEGIN > @class WKWebViewConfiguration; > @class WKWindowFeatures; > >+#if TARGET_OS_IPHONE >+@class WKContextMenuElementInfo; >+@class UIContextMenuConfiguration; >+@protocol UIContextMenuInteractionCommitAnimating; >+#endif >+ > /*! A class conforming to the WKUIDelegate protocol provides methods for > presenting native UI on behalf of a webpage. > */ >@@ -129,7 +135,7 @@ NS_ASSUME_NONNULL_BEGIN > This method will only be invoked for elements that have default preview in WebKit, which is > limited to links. In the future, it could be invoked for additional elements. > */ >-- (BOOL)webView:(WKWebView *)webView shouldPreviewElement:(WKPreviewElementInfo *)elementInfo WK_API_DEPRECATED("This API will be replaced", ios(10.0, WK_IOS_TBA)); >+- (BOOL)webView:(WKWebView *)webView shouldPreviewElement:(WKPreviewElementInfo *)elementInfo WK_API_DEPRECATED_WITH_REPLACEMENT("webView:contextMenuConfigurationForElement:completionHandler:", ios(10.0, WK_IOS_TBA)); > > /*! @abstract Allows your app to provide a custom view controller to show when the given element is peeked. > @param webView The web view invoking the delegate method. >@@ -144,13 +150,53 @@ NS_ASSUME_NONNULL_BEGIN > Returning nil will result in WebKit's default preview behavior. webView:commitPreviewingViewController: will only be invoked > if a non-nil view controller was returned. > */ >-- (nullable UIViewController *)webView:(WKWebView *)webView previewingViewControllerForElement:(WKPreviewElementInfo *)elementInfo defaultActions:(NSArray<id <WKPreviewActionItem>> *)previewActions WK_API_DEPRECATED("This API will be replaced", ios(10.0, WK_IOS_TBA)); >+- (nullable UIViewController *)webView:(WKWebView *)webView previewingViewControllerForElement:(WKPreviewElementInfo *)elementInfo defaultActions:(NSArray<id <WKPreviewActionItem>> *)previewActions WK_API_DEPRECATED_WITH_REPLACEMENT("webView:contextMenuConfigurationForElement:completionHandler:", ios(10.0, WK_IOS_TBA)); > > /*! @abstract Allows your app to pop to the view controller it created. > @param webView The web view invoking the delegate method. > @param previewingViewController The view controller that is being popped. > */ >-- (void)webView:(WKWebView *)webView commitPreviewingViewController:(UIViewController *)previewingViewController WK_API_DEPRECATED("This API will be replaced", ios(10.0, WK_IOS_TBA)); >+- (void)webView:(WKWebView *)webView commitPreviewingViewController:(UIViewController *)previewingViewController WK_API_DEPRECATED("webView:contextMenuForElement:willCommitWithAnimator:", ios(10.0, WK_IOS_TBA)); >+ >+/** >+ * @abstract Called when a context menu interaction begins. >+ * >+ * @param webView The web view invoking the delegate method. >+ * @param elementInfo The elementInfo for the element the user is touching. >+ * @param completionHandler A completion handler to call once a it has been decided whether or not to show a context menu. >+ * Pass a valid UIContextMenuConfiguration to show a context menu, or pass nil to not show a context menu. >+ */ >+ >+- (void)webView:(WKWebView *)webView contextMenuConfigurationForElement:(WKContextMenuElementInfo *)elementInfo completionHandler:(void (^)(UIContextMenuConfiguration * _Nullable))completionHandler WK_API_AVAILABLE(ios(WK_IOS_TBA)); >+ >+/** >+ * @abstract Called when the context menu configured by the UIContextMenuConfiguration from >+ * webView:contextMenuConfigurationForElement:completionHandler: is committed. >+ * >+ * @param webView The web view invoking the delegate method. >+ * @param elementInfo The elementInfo for the element the user is touching. >+ * @param animator The animator to use for the commit animation. >+ */ >+ >+- (void)webView:(WKWebView *)webView contextMenuForElement:(WKContextMenuElementInfo *)elementInfo willCommitWithAnimator:(id<UIContextMenuInteractionCommitAnimating>)animator WK_API_AVAILABLE(ios(WK_IOS_TBA)); >+ >+/** >+ * @abstract Called when the context menu will be presented. >+ * >+ * @param webView The web view invoking the delegate method. >+ * @param elementInfo The elementInfo for the element the user is touching. >+ */ >+ >+- (void)webView:(WKWebView *)webView contextMenuWillPresentForElement:(WKContextMenuElementInfo *)elementInfo WK_API_AVAILABLE(ios(WK_IOS_TBA)); >+ >+/** >+ * @abstract Called when the context menu ends. >+ * >+ * @param webView The web view invoking the delegate method. >+ * @param elementInfo The elementInfo for the element the user is touching. >+ */ >+ >+- (void)webView:(WKWebView *)webView contextMenuDidEndForElement:(WKContextMenuElementInfo *)elementInfo WK_API_AVAILABLE(ios(WK_IOS_TBA)); > > #endif // TARGET_OS_IPHONE > >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h b/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h >index d66dd6f2c2edf50a97fe07816973949b1277249d..a6c7083ee099fff27bc4edcd72a008b24b2cd3f0 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h >@@ -147,13 +147,13 @@ struct UIEdgeInsets; > - (void)_webView:(WKWebView *)webView didDismissPreviewViewController:(UIViewController *)previewedViewController WK_API_DEPRECATED_WITH_REPLACEMENT("webView:dismissContextMenu:", ios(9.0, WK_IOS_TBA)); > > #if TARGET_OS_IOS >-// This needs to be removed once there is an API version to continue to do callbacks for image element context menus. >+// This must be kept to continue to do callbacks for image element context menus. > - (void)_webView:(WKWebView *)webView contextMenuConfigurationForElement:(WKContextMenuElementInfo *)elementInfo completionHandler:(void(^)(UIContextMenuConfiguration *))completionHandler WK_API_AVAILABLE(ios(WK_IOS_TBA)); > >-// These can be removed once there is an API version. >-- (void)_webView:(WKWebView *)webView contextMenuForElement:(WKContextMenuElementInfo *)elementInfo willCommitWithAnimator:(id<UIContextMenuInteractionCommitAnimating>)animator WK_API_AVAILABLE(ios(WK_IOS_TBA)); >-- (void)_webView:(WKWebView *)webView contextMenuWillPresentForElement:(WKContextMenuElementInfo *)elementInfo WK_API_AVAILABLE(ios(WK_IOS_TBA)); >-- (void)_webView:(WKWebView *)webView contextMenuDidEndForElement:(WKContextMenuElementInfo *)elementInfo WK_API_AVAILABLE(ios(WK_IOS_TBA)); >+// These can be removed once the API version is adopted by all clients. >+- (void)_webView:(WKWebView *)webView contextMenuForElement:(WKContextMenuElementInfo *)elementInfo willCommitWithAnimator:(id<UIContextMenuInteractionCommitAnimating>)animator WK_API_DEPRECATED_WITH_REPLACEMENT("webView:contextMenuForElement:willCommitWithAnimator:", ios(WK_IOS_TBA, WK_IOS_TBA)); >+- (void)_webView:(WKWebView *)webView contextMenuWillPresentForElement:(WKContextMenuElementInfo *)elementInfo WK_API_DEPRECATED_WITH_REPLACEMENT("webView:contextMenuWillPresentForElement:", ios(WK_IOS_TBA, WK_IOS_TBA)); >+- (void)_webView:(WKWebView *)webView contextMenuDidEndForElement:(WKContextMenuElementInfo *)elementInfo WK_API_DEPRECATED_WITH_REPLACEMENT("webView:contextMenuDidEndForElement:", ios(WK_IOS_TBA, WK_IOS_TBA)); > #endif > > - (BOOL)_webView:(WKWebView *)webView showCustomSheetForElement:(_WKActivatedElementInfo *)element WK_API_AVAILABLE(ios(10.0)); >diff --git a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h >index 2718a5400ced1e9de6b566826decf52ff6cba70b..fd77e8ead4b3953dcaec464ae26f092d634df9d2 100644 >--- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h >+++ b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h >@@ -485,7 +485,8 @@ FOR_EACH_PRIVATE_WKCONTENTVIEW_ACTION(DECLARE_WKCONTENTVIEW_ACTION_FOR_WEB_VIEW) > > @property (nonatomic, readonly) WebKit::InteractionInformationAtPosition currentPositionInformation; > - (void)doAfterPositionInformationUpdate:(void (^)(WebKit::InteractionInformationAtPosition))action forRequest:(WebKit::InteractionInformationRequest)request; >-- (BOOL)ensurePositionInformationIsUpToDate:(WebKit::InteractionInformationRequest)request; >+- (BOOL)ensurePositionInformationIsUpToDate:(const WebKit::InteractionInformationRequest&)request; >+- (void)ensurePositionInformationIsUpToDate:(const WebKit::InteractionInformationRequest&)request completionHandler:(CompletionHandler<void(BOOL)>&&)completionHandler; > > #if ENABLE(DATA_INTERACTION) > - (void)_didChangeDragInteractionPolicy; >diff --git a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >index 62b3ae19877aaa18458baa34d8e4ddcd532aea78..9ac66fce137779aee892e6d4accfade5a47ec3f5 100644 >--- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >+++ b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >@@ -1921,7 +1921,7 @@ static inline bool isSamePair(UIGestureRecognizer *a, UIGestureRecognizer *b, UI > [self requestAsynchronousPositionInformationUpdate:request]; > } > >-- (BOOL)ensurePositionInformationIsUpToDate:(WebKit::InteractionInformationRequest)request >+- (BOOL)ensurePositionInformationIsUpToDate:(const WebKit::InteractionInformationRequest&)request > { > if ([self _currentPositionInformationIsValidForRequest:request]) > return YES; >@@ -1933,7 +1933,7 @@ static inline bool isSamePair(UIGestureRecognizer *a, UIGestureRecognizer *b, UI > if ([self _hasValidOutstandingPositionInformationRequest:request]) > return connection->waitForAndDispatchImmediately<Messages::WebPageProxy::DidReceivePositionInformation>(_page->pageID(), 1_s, IPC::WaitForOption::InterruptWaitingIfSyncMessageArrives); > >- bool receivedResponse = _page->process().sendSync(Messages::WebPage::GetPositionInformation(request), Messages::WebPage::GetPositionInformation::Reply(_positionInformation), _page->pageID(), 1_s); >+ bool receivedResponse = _page->process().sendSync(Messages::WebPage::GetPositionInformationSync(request), Messages::WebPage::GetPositionInformationSync::Reply(_positionInformation), _page->pageID(), 1_s); > _hasValidPositionInformation = receivedResponse && _positionInformation.canBeValid; > > // FIXME: We need to clean up these handlers in the event that we are not able to collect data, or if the WebProcess crashes. >@@ -1943,6 +1943,25 @@ static inline bool isSamePair(UIGestureRecognizer *a, UIGestureRecognizer *b, UI > return _hasValidPositionInformation; > } > >+- (void)ensurePositionInformationIsUpToDate:(const WebKit::InteractionInformationRequest&)request completionHandler:(CompletionHandler<void(BOOL)>&&)completionHandler >+{ >+ if ([self _currentPositionInformationIsValidForRequest:request]) >+ return completionHandler(YES); >+ >+ auto* connection = _page->process().connection(); >+ if (!connection) >+ return completionHandler(NO); >+ >+ connection->sendWithAsyncReply(Messages::WebPage::GetPositionInformation(request), [completionHandler = WTFMove(completionHandler), weakSelf = WeakObjCPtr<WKContentView>(self)] (WebKit::InteractionInformationAtPosition&& information) mutable { >+ auto strongSelf = weakSelf.get(); >+ if (!strongSelf) >+ return completionHandler(NO); >+ strongSelf->_positionInformation = information; >+ strongSelf->_hasValidPositionInformation = information.canBeValid; >+ completionHandler(information.canBeValid); >+ }, _page->pageID()); >+} >+ > - (void)requestAsynchronousPositionInformationUpdate:(WebKit::InteractionInformationRequest)request > { > if ([self _currentPositionInformationIsValidForRequest:request]) >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.h b/Source/WebKit/WebProcess/WebPage/WebPage.h >index aa73058f95883bbee08372c29f0ebe47ba2f497c..278f2bc631d2da00a40ad07054d44855fae2b76c 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.h >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.h >@@ -663,6 +663,7 @@ public: > void syncApplyAutocorrection(const String& correction, const String& originalText, CompletionHandler<void(bool)>&&); > void requestAutocorrectionContext(); > void getPositionInformation(const InteractionInformationRequest&, CompletionHandler<void(InteractionInformationAtPosition&&)>&&); >+ void getPositionInformationSync(const InteractionInformationRequest&, CompletionHandler<void(InteractionInformationAtPosition&&)>&&); > void requestPositionInformation(const InteractionInformationRequest&); > void startInteractionWithElementAtPosition(const WebCore::IntPoint&); > void stopInteraction(); >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.messages.in b/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >index 6f9f97243ba4b57bedc3a480f0fd14a28049cc98..f432615149c8a52fe376888bcf3b79c1a41a4407 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >@@ -81,7 +81,8 @@ messages -> WebPage LegacyReceiver { > SyncApplyAutocorrection(String correction, String originalText) -> (bool autocorrectionApplied) Synchronous > RequestAutocorrectionContext() > RequestEvasionRectsAboveSelection() -> (Vector<WebCore::FloatRect> rects) Async >- GetPositionInformation(struct WebKit::InteractionInformationRequest request) -> (struct WebKit::InteractionInformationAtPosition information) Synchronous >+ GetPositionInformationSync(struct WebKit::InteractionInformationRequest request) -> (struct WebKit::InteractionInformationAtPosition information) Synchronous >+ GetPositionInformation(struct WebKit::InteractionInformationRequest request) -> (struct WebKit::InteractionInformationAtPosition information) Async > RequestPositionInformation(struct WebKit::InteractionInformationRequest request) > StartInteractionWithElementAtPosition(WebCore::IntPoint point) > StopInteraction() >diff --git a/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm b/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm >index c6dbee9822d5a87fc4fb47766daed56cc548f385..1be7db931b46e362e692a0a411c89b3e098550e2 100644 >--- a/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm >+++ b/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm >@@ -2458,7 +2458,12 @@ void WebPage::getPositionInformation(const InteractionInformationRequest& reques > if (auto reply = WTFMove(m_pendingSynchronousPositionInformationReply)) > reply(WTFMove(information)); > } >- >+ >+void WebPage::getPositionInformationSync(const InteractionInformationRequest& request, CompletionHandler<void(InteractionInformationAtPosition&&)>&& reply) >+{ >+ return getPositionInformation(request, WTFMove(reply)); >+} >+ > static void focusedElementPositionInformation(WebPage& page, Element& focusedElement, const InteractionInformationRequest& request, InteractionInformationAtPosition& info) > { > const Frame& frame = page.corePage()->focusController().focusedOrMainFrame();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198974
:
372371
|
372391