Diff
Modified: trunk/Source/WebKit/ChangeLog (271200 => 271201)
--- trunk/Source/WebKit/ChangeLog 2021-01-06 14:50:09 UTC (rev 271200)
+++ trunk/Source/WebKit/ChangeLog 2021-01-06 17:32:26 UTC (rev 271201)
@@ -1,3 +1,42 @@
+2021-01-06 Alex Christensen <[email protected]>
+
+ Use sendWithAsyncReply instead of iOS-specific GenericCallbacks
+ https://bugs.webkit.org/show_bug.cgi?id=220346
+
+ Reviewed by Darin Adler.
+
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebPageProxy.messages.in:
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView _accessibilityRetrieveRectsEnclosingSelectionOffset:withGranularity:]):
+ (-[WKContentView _accessibilityRetrieveRectsAtSelectionOffset:withText:completionHandler:]):
+ (selectionChangedWithGesture):
+ (selectionChangedWithTouch):
+ (-[WKContentView changeSelectionWithGestureAt:withGesture:withState:withFlags:]):
+ (-[WKContentView changeSelectionWithTouchAt:withSelectionTouch:baseIsStart:withFlags:]):
+ (-[WKContentView changeSelectionWithTouchesFrom:to:withGesture:withState:]):
+ (-[WKContentView updateCurrentFocusedElementInformation:]):
+ * UIProcess/ios/WebPageProxyIOS.mm:
+ (WebKit::WebPageProxy::requestFocusedElementInformation):
+ (WebKit::WebPageProxy::selectWithGesture):
+ (WebKit::WebPageProxy::updateSelectionWithTouches):
+ (WebKit::WebPageProxy::selectWithTwoTouches):
+ (WebKit::WebPageProxy::requestRectsForGranularityWithSelectionOffset):
+ (WebKit::WebPageProxy::requestRectsAtSelectionOffsetWithText):
+ (WebKit::WebPageProxy::gestureCallback): Deleted.
+ (WebKit::WebPageProxy::touchesCallback): Deleted.
+ (WebKit::WebPageProxy::selectionRectsCallback): Deleted.
+ (WebKit::WebPageProxy::focusedElementInformationCallback): Deleted.
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/WebPage.messages.in:
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::WebPage::requestFocusedElementInformation):
+ (WebKit::WebPage::selectWithGesture):
+ (WebKit::WebPage::updateSelectionWithTouches):
+ (WebKit::WebPage::selectWithTwoTouches):
+ (WebKit::WebPage::getRectsForGranularityWithSelectionOffset):
+ (WebKit::WebPage::getRectsAtSelectionOffsetWithText):
+
2021-01-06 Per Arne Vollan <[email protected]>
[iOS] Silence selected sandbox violation reports
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (271200 => 271201)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2021-01-06 14:50:09 UTC (rev 271200)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2021-01-06 17:32:26 UTC (rev 271201)
@@ -399,13 +399,6 @@
typedef GenericCallback<const Optional<WebCore::ApplicationManifest>&> ApplicationManifestCallback;
#endif
-#if PLATFORM(IOS_FAMILY)
-typedef GenericCallback<const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<SelectionFlags>> GestureCallback;
-typedef GenericCallback<const WebCore::IntPoint&, SelectionTouch, OptionSet<SelectionFlags>> TouchesCallback;
-typedef GenericCallback<const Vector<WebCore::SelectionRect>&> SelectionRectsCallback;
-typedef GenericCallback<const FocusedElementInformation&> FocusedElementInformationCallback;
-#endif
-
#if PLATFORM(COCOA)
using DrawToPDFCallback = GenericCallback<const IPC::DataReference&>;
typedef GenericCallback<bool, bool, String, double, double, uint64_t> NowPlayingInfoCallback;
@@ -761,9 +754,9 @@
void setOverrideViewportArguments(const Optional<WebCore::ViewportArguments>&);
void willCommitLayerTree(TransactionID);
- void selectWithGesture(const WebCore::IntPoint, GestureType, GestureRecognizerState, bool isInteractingWithFocusedElement, WTF::Function<void(const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<SelectionFlags>, CallbackBase::Error)>&&);
- void updateSelectionWithTouches(const WebCore::IntPoint, SelectionTouch, bool baseIsStart, Function<void(const WebCore::IntPoint&, SelectionTouch, OptionSet<SelectionFlags>, CallbackBase::Error)>&&);
- void selectWithTwoTouches(const WebCore::IntPoint from, const WebCore::IntPoint to, GestureType, GestureRecognizerState, Function<void(const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<SelectionFlags>, CallbackBase::Error)>&&);
+ void selectWithGesture(const WebCore::IntPoint, GestureType, GestureRecognizerState, bool isInteractingWithFocusedElement, CompletionHandler<void(const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<SelectionFlags>)>&&);
+ void updateSelectionWithTouches(const WebCore::IntPoint, SelectionTouch, bool baseIsStart, CompletionHandler<void(const WebCore::IntPoint&, SelectionTouch, OptionSet<SelectionFlags>)>&&);
+ void selectWithTwoTouches(const WebCore::IntPoint from, const WebCore::IntPoint to, GestureType, GestureRecognizerState, CompletionHandler<void(const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<SelectionFlags>)>&&);
void extendSelection(WebCore::TextGranularity, CompletionHandler<void()>&& = { });
void selectWordBackward();
void moveSelectionByOffset(int32_t offset, CompletionHandler<void()>&&);
@@ -815,8 +808,8 @@
double minimumEffectiveDeviceWidth() const { return m_viewportConfigurationMinimumEffectiveDeviceWidth; }
void setMinimumEffectiveDeviceWidthWithoutViewportConfigurationUpdate(double minimumEffectiveDeviceWidth) { m_viewportConfigurationMinimumEffectiveDeviceWidth = minimumEffectiveDeviceWidth; }
void setIsScrollingOrZooming(bool);
- void requestRectsForGranularityWithSelectionOffset(WebCore::TextGranularity, uint32_t offset, WTF::Function<void(const Vector<WebCore::SelectionRect>&, CallbackBase::Error)>&&);
- void requestRectsAtSelectionOffsetWithText(int32_t offset, const String&, WTF::Function<void(const Vector<WebCore::SelectionRect>&, CallbackBase::Error)>&&);
+ void requestRectsForGranularityWithSelectionOffset(WebCore::TextGranularity, uint32_t offset, CompletionHandler<void(const Vector<WebCore::SelectionRect>&)>&&);
+ void requestRectsAtSelectionOffsetWithText(int32_t offset, const String&, CompletionHandler<void(const Vector<WebCore::SelectionRect>&)>&&);
void autofillLoginCredentials(const String& username, const String& password);
void storeSelectionForAccessibility(bool);
void startAutoscrollAtPosition(const WebCore::FloatPoint& positionInWindow);
@@ -1418,7 +1411,7 @@
void recordAutomaticNavigationSnapshot();
void suppressNextAutomaticNavigationSnapshot() { m_shouldSuppressNextAutomaticNavigationSnapshot = true; }
void recordNavigationSnapshot(WebBackForwardListItem&);
- void requestFocusedElementInformation(Function<void(const FocusedElementInformation&, CallbackBase::Error)>&&);
+ void requestFocusedElementInformation(CompletionHandler<void(const FocusedElementInformation&)>&&);
#if PLATFORM(COCOA) || PLATFORM(GTK)
RefPtr<ViewSnapshot> takeViewSnapshot(Optional<WebCore::IntRect>&&);
@@ -2156,11 +2149,8 @@
void fontAtSelectionCallback(const FontInfo&, double, bool, CallbackID);
#endif
#if PLATFORM(IOS_FAMILY)
- void gestureCallback(const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<SelectionFlags>, CallbackID);
- void touchesCallback(const WebCore::IntPoint&, SelectionTouch, OptionSet<SelectionFlags>, CallbackID);
void interpretKeyEvent(const EditorState&, bool isCharEvent, CompletionHandler<void(bool)>&&);
void showPlaybackTargetPicker(bool hasVideo, const WebCore::IntRect& elementRect, WebCore::RouteSharingPolicy, const String&);
- void selectionRectsCallback(const Vector<WebCore::SelectionRect>&, CallbackID);
void updateStringForFind(const String&);
#endif
@@ -2225,7 +2215,6 @@
void enableInspectorNodeSearch();
void disableInspectorNodeSearch();
- void focusedElementInformationCallback(const FocusedElementInformation&, CallbackID);
#else
void didReleaseAllTouchPoints() { }
#endif // PLATFORM(IOS_FAMILY)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (271200 => 271201)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2021-01-06 14:50:09 UTC (rev 271200)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2021-01-06 17:32:26 UTC (rev 271201)
@@ -174,8 +174,6 @@
ApplicationManifestCallback(Optional<WebCore::ApplicationManifest> manifest, WebKit::CallbackID callbackID)
#endif
#if PLATFORM(IOS_FAMILY)
- GestureCallback(WebCore::IntPoint point, enum:uint8_t WebKit::GestureType gestureType, enum:uint8_t WebKit::GestureRecognizerState gestureState, OptionSet<WebKit::SelectionFlags> flags, WebKit::CallbackID callbackID)
- TouchesCallback(WebCore::IntPoint point, enum:uint8_t WebKit::SelectionTouch touches, OptionSet<WebKit::SelectionFlags> flags, WebKit::CallbackID callbackID)
InterpretKeyEvent(struct WebKit::EditorState state, bool isCharEvent) -> (bool handled) Synchronous
DidReceivePositionInformation(struct WebKit::InteractionInformationAtPosition information)
SaveImageToLibrary(WebKit::SharedMemory::IPCHandle handle)
@@ -185,7 +183,6 @@
DidCompleteSyntheticClick()
DisableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID)
HandleSmartMagnificationInformationForPotentialTap(uint64_t requestID, WebCore::FloatRect renderRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale, bool nodeIsRootLevel)
- SelectionRectsCallback(Vector<WebCore::SelectionRect> selectionRects, WebKit::CallbackID callbackID);
#endif
#if ENABLE(DATA_DETECTION)
SetDataDetectionResult(struct WebKit::DataDetectionResult dataDetectionResult)
@@ -401,7 +398,6 @@
ScrollingNodeScrollDidEndScroll()
ShowInspectorHighlight(struct WebCore::InspectorOverlay::Highlight highlight)
HideInspectorHighlight()
- FocusedElementInformationCallback(struct WebKit::FocusedElementInformation information, WebKit::CallbackID callbackID)
ShowInspectorIndication()
HideInspectorIndication()
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (271200 => 271201)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2021-01-06 14:50:09 UTC (rev 271200)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2021-01-06 17:32:26 UTC (rev 271201)
@@ -3740,10 +3740,7 @@
- (void)_accessibilityRetrieveRectsEnclosingSelectionOffset:(NSInteger)offset withGranularity:(UITextGranularity)granularity
{
- RetainPtr<WKContentView> view = self;
- _page->requestRectsForGranularityWithSelectionOffset(toWKTextGranularity(granularity), offset , [view, offset, granularity](const Vector<WebCore::SelectionRect>& selectionRects, WebKit::CallbackBase::Error error) {
- if (error != WebKit::CallbackBase::Error::None)
- return;
+ _page->requestRectsForGranularityWithSelectionOffset(toWKTextGranularity(granularity), offset, [view = retainPtr(self), offset, granularity](const Vector<WebCore::SelectionRect>& selectionRects) {
if ([view respondsToSelector:@selector(_accessibilityDidGetSelectionRects:withGranularity:atOffset:)])
[view _accessibilityDidGetSelectionRects:[view webSelectionRectsForSelectionRects:selectionRects] withGranularity:granularity atOffset:offset];
});
@@ -3757,12 +3754,10 @@
- (void)_accessibilityRetrieveRectsAtSelectionOffset:(NSInteger)offset withText:(NSString *)text completionHandler:(void (^)(const Vector<WebCore::SelectionRect>& rects))completionHandler
{
RetainPtr<WKContentView> view = self;
- _page->requestRectsAtSelectionOffsetWithText(offset, text, [view, offset, capturedCompletionHandler = makeBlockPtr(completionHandler)](const Vector<WebCore::SelectionRect>& selectionRects, WebKit::CallbackBase::Error error) {
+ _page->requestRectsAtSelectionOffsetWithText(offset, text, [view, offset, capturedCompletionHandler = makeBlockPtr(completionHandler)](const Vector<WebCore::SelectionRect>& selectionRects) {
if (capturedCompletionHandler)
capturedCompletionHandler(selectionRects);
- if (error != WebKit::CallbackBase::Error::None)
- return;
if ([view respondsToSelector:@selector(_accessibilityDidGetSelectionRects:withGranularity:atOffset:)])
[view _accessibilityDidGetSelectionRects:[view webSelectionRectsForSelectionRects:selectionRects] withGranularity:UITextGranularityWord atOffset:offset];
});
@@ -4007,17 +4002,13 @@
}
}
-static void selectionChangedWithGesture(WKContentView *view, const WebCore::IntPoint& point, WebKit::GestureType gestureType, WebKit::GestureRecognizerState gestureState, OptionSet<WebKit::SelectionFlags> flags, WebKit::CallbackBase::Error error)
+static void selectionChangedWithGesture(WKContentView *view, const WebCore::IntPoint& point, WebKit::GestureType gestureType, WebKit::GestureRecognizerState gestureState, OptionSet<WebKit::SelectionFlags> flags)
{
- if (error != WebKit::CallbackBase::Error::None)
- return;
[(UIWKTextInteractionAssistant *)[view interactionAssistant] selectionChangedWithGestureAt:(CGPoint)point withGesture:toUIWKGestureType(gestureType) withState:toUIGestureRecognizerState(gestureState) withFlags:toUIWKSelectionFlags(flags)];
}
-static void selectionChangedWithTouch(WKContentView *view, const WebCore::IntPoint& point, WebKit::SelectionTouch touch, OptionSet<WebKit::SelectionFlags> flags, WebKit::CallbackBase::Error error)
+static void selectionChangedWithTouch(WKContentView *view, const WebCore::IntPoint& point, WebKit::SelectionTouch touch, OptionSet<WebKit::SelectionFlags> flags)
{
- if (error != WebKit::CallbackBase::Error::None)
- return;
[(UIWKTextInteractionAssistant *)[view interactionAssistant] selectionChangedWithTouchAt:(CGPoint)point withSelectionTouch:toUIWKSelectionTouch((WebKit::SelectionTouch)touch) withFlags:toUIWKSelectionFlags(flags)];
}
@@ -4034,8 +4025,8 @@
- (void)changeSelectionWithGestureAt:(CGPoint)point withGesture:(UIWKGestureType)gestureType withState:(UIGestureRecognizerState)state withFlags:(UIWKSelectionFlags)flags
{
_usingGestureForSelection = YES;
- _page->selectWithGesture(WebCore::IntPoint(point), toGestureType(gestureType), toGestureRecognizerState(state), self._hasFocusedElement, [self, strongSelf = retainPtr(self), state, flags](const WebCore::IntPoint& point, WebKit::GestureType gestureType, WebKit::GestureRecognizerState gestureState, OptionSet<WebKit::SelectionFlags> innerFlags, WebKit::CallbackBase::Error error) {
- selectionChangedWithGesture(self, point, gestureType, gestureState, toSelectionFlags(flags) | innerFlags, error);
+ _page->selectWithGesture(WebCore::IntPoint(point), toGestureType(gestureType), toGestureRecognizerState(state), self._hasFocusedElement, [self, strongSelf = retainPtr(self), state, flags](const WebCore::IntPoint& point, WebKit::GestureType gestureType, WebKit::GestureRecognizerState gestureState, OptionSet<WebKit::SelectionFlags> innerFlags) {
+ selectionChangedWithGesture(self, point, gestureType, gestureState, toSelectionFlags(flags) | innerFlags);
if (state == UIGestureRecognizerStateEnded || state == UIGestureRecognizerStateCancelled)
_usingGestureForSelection = NO;
});
@@ -4044,8 +4035,8 @@
- (void)changeSelectionWithTouchAt:(CGPoint)point withSelectionTouch:(UIWKSelectionTouch)touch baseIsStart:(BOOL)baseIsStart withFlags:(UIWKSelectionFlags)flags
{
_usingGestureForSelection = YES;
- _page->updateSelectionWithTouches(WebCore::IntPoint(point), toSelectionTouch(touch), baseIsStart, [self, strongSelf = retainPtr(self), flags](const WebCore::IntPoint& point, WebKit::SelectionTouch touch, OptionSet<WebKit::SelectionFlags> innerFlags, WebKit::CallbackBase::Error error) {
- selectionChangedWithTouch(self, point, touch, toSelectionFlags(flags) | innerFlags, error);
+ _page->updateSelectionWithTouches(WebCore::IntPoint(point), toSelectionTouch(touch), baseIsStart, [self, strongSelf = retainPtr(self), flags](const WebCore::IntPoint& point, WebKit::SelectionTouch touch, OptionSet<WebKit::SelectionFlags> innerFlags) {
+ selectionChangedWithTouch(self, point, touch, toSelectionFlags(flags) | innerFlags);
if (toUIWKSelectionTouch(touch) != UIWKSelectionTouchStarted && toUIWKSelectionTouch(touch) != UIWKSelectionTouchMoved)
_usingGestureForSelection = NO;
});
@@ -4054,8 +4045,8 @@
- (void)changeSelectionWithTouchesFrom:(CGPoint)from to:(CGPoint)to withGesture:(UIWKGestureType)gestureType withState:(UIGestureRecognizerState)gestureState
{
_usingGestureForSelection = YES;
- _page->selectWithTwoTouches(WebCore::IntPoint(from), WebCore::IntPoint(to), toGestureType(gestureType), toGestureRecognizerState(gestureState), [self, strongSelf = retainPtr(self)](const WebCore::IntPoint& point, WebKit::GestureType gestureType, WebKit::GestureRecognizerState gestureState, OptionSet<WebKit::SelectionFlags> flags, WebKit::CallbackBase::Error error) {
- selectionChangedWithGesture(self, point, gestureType, gestureState, flags, error);
+ _page->selectWithTwoTouches(WebCore::IntPoint(from), WebCore::IntPoint(to), toGestureType(gestureType), toGestureRecognizerState(gestureState), [self, strongSelf = retainPtr(self)](const WebCore::IntPoint& point, WebKit::GestureType gestureType, WebKit::GestureRecognizerState gestureState, OptionSet<WebKit::SelectionFlags> flags) {
+ selectionChangedWithGesture(self, point, gestureType, gestureState, flags);
if (toUIGestureRecognizerState(gestureState) == UIGestureRecognizerStateEnded || toUIGestureRecognizerState(gestureState) == UIGestureRecognizerStateCancelled)
_usingGestureForSelection = NO;
});
@@ -6329,8 +6320,8 @@
{
WeakObjCPtr<WKContentView> weakSelf { self };
auto identifierBeforeUpdate = _focusedElementInformation.focusedElementIdentifier;
- _page->requestFocusedElementInformation([callback = WTFMove(callback), identifierBeforeUpdate, weakSelf] (auto& info, auto error) {
- if (!weakSelf || error != WebKit::CallbackBase::Error::None || info.focusedElementIdentifier != identifierBeforeUpdate) {
+ _page->requestFocusedElementInformation([callback = WTFMove(callback), identifierBeforeUpdate, weakSelf] (auto& info) {
+ if (!weakSelf || info.focusedElementIdentifier != identifierBeforeUpdate) {
// If the focused element may have changed in the meantime, don't overwrite focused element information.
callback(false);
return;
Modified: trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm (271200 => 271201)
--- trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm 2021-01-06 14:50:09 UTC (rev 271200)
+++ trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm 2021-01-06 17:32:26 UTC (rev 271201)
@@ -149,61 +149,14 @@
return false;
}
-void WebPageProxy::gestureCallback(const WebCore::IntPoint& point, GestureType gestureType, GestureRecognizerState gestureState, OptionSet<SelectionFlags> flags, CallbackID callbackID)
+void WebPageProxy::requestFocusedElementInformation(CompletionHandler<void(const FocusedElementInformation&)>&& callback)
{
- auto callback = m_callbacks.take<GestureCallback>(callbackID);
- if (!callback) {
- ASSERT_NOT_REACHED();
- return;
- }
-
- callback->performCallbackWithReturnValue(point, gestureType, gestureState, flags);
-}
+ if (!hasRunningProcess())
+ return callback({ });
-void WebPageProxy::touchesCallback(const WebCore::IntPoint& point, SelectionTouch touches, OptionSet<SelectionFlags> flags, CallbackID callbackID)
-{
- auto callback = m_callbacks.take<TouchesCallback>(callbackID);
- if (!callback) {
- ASSERT_NOT_REACHED();
- return;
- }
-
- callback->performCallbackWithReturnValue(point, touches, flags);
+ sendWithAsyncReply(Messages::WebPage::RequestFocusedElementInformation(), WTFMove(callback));
}
-void WebPageProxy::selectionRectsCallback(const Vector<WebCore::SelectionRect>& selectionRects, CallbackID callbackID)
-{
- auto callback = m_callbacks.take<SelectionRectsCallback>(callbackID);
- if (!callback) {
- ASSERT_NOT_REACHED();
- return;
- }
-
- callback->performCallbackWithReturnValue(selectionRects);
-}
-
-void WebPageProxy::focusedElementInformationCallback(const FocusedElementInformation& info, CallbackID callbackID)
-{
- auto callback = m_callbacks.take<FocusedElementInformationCallback>(callbackID);
- if (!callback) {
- ASSERT_NOT_REACHED();
- return;
- }
-
- callback->performCallbackWithReturnValue(info);
-}
-
-void WebPageProxy::requestFocusedElementInformation(Function<void(const FocusedElementInformation&, CallbackBase::Error)>&& callback)
-{
- if (!hasRunningProcess()) {
- callback({ }, CallbackBase::Error::OwnerWasInvalidated);
- return;
- }
-
- auto callbackID = m_callbacks.put(WTFMove(callback), m_process->throttler().backgroundActivity("WebPageProxy::requestFocusedElementInformation"_s));
- m_process->send(Messages::WebPage::RequestFocusedElementInformation(callbackID), m_webPageID);
-}
-
void WebPageProxy::updateVisibleContentRects(const VisibleContentRectUpdateInfo& visibleContentRectUpdate, bool sendEvenIfUnchanged)
{
if (visibleContentRectUpdate == m_lastVisibleContentRectUpdate && !sendEvenIfUnchanged)
@@ -422,26 +375,20 @@
pageClient().layerTreeCommitComplete();
}
-void WebPageProxy::selectWithGesture(const WebCore::IntPoint point, GestureType gestureType, GestureRecognizerState gestureState, bool isInteractingWithFocusedElement, WTF::Function<void(const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<WebKit::SelectionFlags>, CallbackBase::Error)>&& callbackFunction)
+void WebPageProxy::selectWithGesture(const WebCore::IntPoint point, GestureType gestureType, GestureRecognizerState gestureState, bool isInteractingWithFocusedElement, CompletionHandler<void(const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<WebKit::SelectionFlags>)>&& callback)
{
- if (!hasRunningProcess()) {
- callbackFunction(WebCore::IntPoint(), GestureType::Loupe, GestureRecognizerState::Possible, { }, CallbackBase::Error::Unknown);
- return;
- }
+ if (!hasRunningProcess())
+ return callback({ }, GestureType::Loupe, GestureRecognizerState::Possible, { });
- auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::selectWithGesture"_s));
- m_process->send(Messages::WebPage::SelectWithGesture(point, gestureType, gestureState, isInteractingWithFocusedElement, callbackID), m_webPageID);
+ sendWithAsyncReply(Messages::WebPage::SelectWithGesture(point, gestureType, gestureState, isInteractingWithFocusedElement), WTFMove(callback));
}
-void WebPageProxy::updateSelectionWithTouches(const WebCore::IntPoint point, SelectionTouch touches, bool baseIsStart, Function<void(const WebCore::IntPoint&, SelectionTouch, OptionSet<SelectionFlags>, CallbackBase::Error)>&& callbackFunction)
+void WebPageProxy::updateSelectionWithTouches(const WebCore::IntPoint point, SelectionTouch touches, bool baseIsStart, CompletionHandler<void(const WebCore::IntPoint&, SelectionTouch, OptionSet<SelectionFlags>)>&& callback)
{
- if (!hasRunningProcess()) {
- callbackFunction(WebCore::IntPoint(), SelectionTouch::Started, { }, CallbackBase::Error::Unknown);
- return;
- }
+ if (!hasRunningProcess())
+ return callback(WebCore::IntPoint(), SelectionTouch::Started, { });
- auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::updateSelectionWithTouches"_s));
- m_process->send(Messages::WebPage::UpdateSelectionWithTouches(point, touches, baseIsStart, callbackID), m_webPageID);
+ sendWithAsyncReply(Messages::WebPage::UpdateSelectionWithTouches(point, touches, baseIsStart), WTFMove(callback));
}
void WebPageProxy::replaceDictatedText(const String& oldText, const String& newText)
@@ -612,15 +559,12 @@
send(Messages::WebPage::HandleTwoFingerTapAtPoint(point, modifiers, requestID));
}
-void WebPageProxy::selectWithTwoTouches(const WebCore::IntPoint from, const WebCore::IntPoint to, GestureType gestureType, GestureRecognizerState gestureState, Function<void(const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<SelectionFlags>, CallbackBase::Error)>&& callbackFunction)
+void WebPageProxy::selectWithTwoTouches(const WebCore::IntPoint from, const WebCore::IntPoint to, GestureType gestureType, GestureRecognizerState gestureState, CompletionHandler<void(const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<SelectionFlags>)>&& callback)
{
- if (!hasRunningProcess()) {
- callbackFunction(WebCore::IntPoint(), GestureType::Loupe, GestureRecognizerState::Possible, { }, CallbackBase::Error::Unknown);
- return;
- }
+ if (!hasRunningProcess())
+ return callback({ }, GestureType::Loupe, GestureRecognizerState::Possible, { });
- auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::selectWithTwoTouches"_s));
- m_process->send(Messages::WebPage::SelectWithTwoTouches(from, to, gestureType, gestureState, callbackID), m_webPageID);
+ sendWithAsyncReply(Messages::WebPage::SelectWithTwoTouches(from, to, gestureType, gestureState), WTFMove(callback));
}
void WebPageProxy::didReceivePositionInformation(const InteractionInformationAtPosition& info)
@@ -745,26 +689,20 @@
m_process->send(Messages::WebPage::SelectWordBackward(), m_webPageID);
}
-void WebPageProxy::requestRectsForGranularityWithSelectionOffset(WebCore::TextGranularity granularity, uint32_t offset, WTF::Function<void(const Vector<WebCore::SelectionRect>&, CallbackBase::Error)>&& callbackFunction)
+void WebPageProxy::requestRectsForGranularityWithSelectionOffset(WebCore::TextGranularity granularity, uint32_t offset, CompletionHandler<void(const Vector<WebCore::SelectionRect>&)>&& callback)
{
- if (!hasRunningProcess()) {
- callbackFunction(Vector<WebCore::SelectionRect>(), CallbackBase::Error::Unknown);
- return;
- }
+ if (!hasRunningProcess())
+ return callback({ });
- auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::requestRectsForGranularityWithSelectionOffset"_s));
- m_process->send(Messages::WebPage::GetRectsForGranularityWithSelectionOffset(granularity, offset, callbackID), m_webPageID);
+ sendWithAsyncReply(Messages::WebPage::GetRectsForGranularityWithSelectionOffset(granularity, offset), WTFMove(callback));
}
-void WebPageProxy::requestRectsAtSelectionOffsetWithText(int32_t offset, const String& text, WTF::Function<void(const Vector<WebCore::SelectionRect>&, CallbackBase::Error)>&& callbackFunction)
+void WebPageProxy::requestRectsAtSelectionOffsetWithText(int32_t offset, const String& text, CompletionHandler<void(const Vector<WebCore::SelectionRect>&)>&& callback)
{
- if (!hasRunningProcess()) {
- callbackFunction(Vector<WebCore::SelectionRect>(), CallbackBase::Error::Unknown);
- return;
- }
+ if (!hasRunningProcess())
+ return callback({ });
- auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::requestRectsAtSelectionOffsetWithText"_s));
- m_process->send(Messages::WebPage::GetRectsAtSelectionOffsetWithText(offset, text, callbackID), m_webPageID);
+ sendWithAsyncReply(Messages::WebPage::GetRectsAtSelectionOffsetWithText(offset, text), WTFMove(callback));
}
void WebPageProxy::storeSelectionForAccessibility(bool shouldStore)
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (271200 => 271201)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2021-01-06 14:50:09 UTC (rev 271200)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2021-01-06 17:32:26 UTC (rev 271201)
@@ -725,10 +725,10 @@
void inspectorNodeSearchEndedAtPosition(const WebCore::FloatPoint&);
void blurFocusedElement();
- void requestFocusedElementInformation(CallbackID);
- void selectWithGesture(const WebCore::IntPoint&, GestureType, GestureRecognizerState, bool isInteractingWithFocusedElement, CallbackID);
- void updateSelectionWithTouches(const WebCore::IntPoint&, SelectionTouch, bool baseIsStart, CallbackID);
- void selectWithTwoTouches(const WebCore::IntPoint& from, const WebCore::IntPoint& to, GestureType, GestureRecognizerState, CallbackID);
+ void requestFocusedElementInformation(CompletionHandler<void(const FocusedElementInformation&)>&&);
+ void selectWithGesture(const WebCore::IntPoint&, GestureType, GestureRecognizerState, bool isInteractingWithFocusedElement, CompletionHandler<void(const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<SelectionFlags>)>&&);
+ void updateSelectionWithTouches(const WebCore::IntPoint&, SelectionTouch, bool baseIsStart, CompletionHandler<void(const WebCore::IntPoint&, SelectionTouch, OptionSet<SelectionFlags>)>&&);
+ void selectWithTwoTouches(const WebCore::IntPoint& from, const WebCore::IntPoint& to, GestureType, GestureRecognizerState, CompletionHandler<void(const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<SelectionFlags>)>&&);
void extendSelection(WebCore::TextGranularity, CompletionHandler<void()>&&);
void selectWordBackward();
void moveSelectionByOffset(int32_t offset, CompletionHandler<void()>&&);
@@ -762,8 +762,8 @@
void updateSelectionAppearance();
void getSelectionContext(CompletionHandler<void(const String&, const String&, const String&)>&&);
void handleTwoFingerTapAtPoint(const WebCore::IntPoint&, OptionSet<WebKit::WebEvent::Modifier>, uint64_t requestID);
- void getRectsForGranularityWithSelectionOffset(WebCore::TextGranularity, int32_t, CallbackID);
- void getRectsAtSelectionOffsetWithText(int32_t, const String&, CallbackID);
+ void getRectsForGranularityWithSelectionOffset(WebCore::TextGranularity, int32_t, CompletionHandler<void(const Vector<WebCore::SelectionRect>&)>&&);
+ void getRectsAtSelectionOffsetWithText(int32_t, const String&, CompletionHandler<void(const Vector<WebCore::SelectionRect>&)>&&);
void storeSelectionForAccessibility(bool);
void startAutoscrollAtPosition(const WebCore::FloatPoint&);
void cancelAutoscroll();
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (271200 => 271201)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2021-01-06 14:50:09 UTC (rev 271200)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2021-01-06 17:32:26 UTC (rev 271201)
@@ -65,9 +65,9 @@
InspectorNodeSearchMovedToPosition(WebCore::FloatPoint point)
InspectorNodeSearchEndedAtPosition(WebCore::FloatPoint point)
BlurFocusedElement()
- SelectWithGesture(WebCore::IntPoint point, enum:uint8_t WebKit::GestureType gestureType, enum:uint8_t WebKit::GestureRecognizerState gestureState, bool isInteractingWithFocusedElement, WebKit::CallbackID callbackID)
- UpdateSelectionWithTouches(WebCore::IntPoint point, enum:uint8_t WebKit::SelectionTouch touches, bool baseIsStart, WebKit::CallbackID callbackID)
- SelectWithTwoTouches(WebCore::IntPoint from, WebCore::IntPoint to, enum:uint8_t WebKit::GestureType gestureType, enum:uint8_t WebKit::GestureRecognizerState gestureState, WebKit::CallbackID callbackID)
+ SelectWithGesture(WebCore::IntPoint point, enum:uint8_t WebKit::GestureType gestureType, enum:uint8_t WebKit::GestureRecognizerState gestureState, bool isInteractingWithFocusedElement) -> (WebCore::IntPoint point, enum:uint8_t WebKit::GestureType gestureType, enum:uint8_t WebKit::GestureRecognizerState gestureState, OptionSet<WebKit::SelectionFlags> flags) Async
+ UpdateSelectionWithTouches(WebCore::IntPoint point, enum:uint8_t WebKit::SelectionTouch touches, bool baseIsStart) -> (WebCore::IntPoint point, enum:uint8_t WebKit::SelectionTouch touch, OptionSet<WebKit::SelectionFlags> selectionFlags) Async
+ SelectWithTwoTouches(WebCore::IntPoint from, WebCore::IntPoint to, enum:uint8_t WebKit::GestureType gestureType, enum:uint8_t WebKit::GestureRecognizerState gestureState) -> (WebCore::IntPoint point, enum:uint8_t WebKit::GestureType gestureType, enum:uint8_t WebKit::GestureRecognizerState gestureState, OptionSet<WebKit::SelectionFlags> selectionFlags) Async
ExtendSelection(enum:uint8_t WebCore::TextGranularity granularity) -> () Async
SelectWordBackward()
MoveSelectionByOffset(int32_t offset) -> () Async
@@ -108,12 +108,12 @@
SetAllowsMediaDocumentInlinePlayback(bool allows)
HandleTwoFingerTapAtPoint(WebCore::IntPoint point, OptionSet<WebKit::WebEvent::Modifier> modifiers, uint64_t requestID)
SetForceAlwaysUserScalable(bool userScalable)
- GetRectsForGranularityWithSelectionOffset(enum:uint8_t WebCore::TextGranularity granularity, int32_t offset, WebKit::CallbackID callbackID)
- GetRectsAtSelectionOffsetWithText(int32_t offset, String text, WebKit::CallbackID callbackID)
+ GetRectsForGranularityWithSelectionOffset(enum:uint8_t WebCore::TextGranularity granularity, int32_t offset) -> (Vector<WebCore::SelectionRect> rect) Async
+ GetRectsAtSelectionOffsetWithText(int32_t offset, String text) -> (Vector<WebCore::SelectionRect> rect) Async
StoreSelectionForAccessibility(bool shouldStore)
StartAutoscrollAtPosition(WebCore::FloatPoint positionInWindow)
CancelAutoscroll()
- RequestFocusedElementInformation(WebKit::CallbackID callbackID)
+ RequestFocusedElementInformation() -> (struct WebKit::FocusedElementInformation info) Async
HardwareKeyboardAvailabilityChanged(bool keyboardIsAttached)
SetIsShowingInputViewForFocusedElement(bool showingInputView)
UpdateSelectionWithDelta(int64_t locationDelta, int64_t lengthDelta) -> () Async
Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (271200 => 271201)
--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2021-01-06 14:50:09 UTC (rev 271200)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2021-01-06 17:32:26 UTC (rev 271201)
@@ -922,13 +922,13 @@
nodeRespondingToDoubleClick->document().frame()->eventHandler().handleMouseReleaseEvent(PlatformMouseEvent(roundedAdjustedPoint, roundedAdjustedPoint, LeftButton, PlatformEvent::MouseReleased, 2, shiftKey, ctrlKey, altKey, metaKey, WallTime::now(), 0, WebCore::OneFingerTap));
}
-void WebPage::requestFocusedElementInformation(WebKit::CallbackID callbackID)
+void WebPage::requestFocusedElementInformation(CompletionHandler<void(const FocusedElementInformation&)>&& completionHandler)
{
FocusedElementInformation info;
if (m_focusedElement)
getFocusedElementInformation(info);
- send(Messages::WebPageProxy::FocusedElementInformationCallback(info, callbackID));
+ completionHandler(info);
}
#if ENABLE(DRAG_SUPPORT)
@@ -1339,7 +1339,7 @@
return constrainedPoint;
}
-void WebPage::selectWithGesture(const IntPoint& point, GestureType gestureType, GestureRecognizerState gestureState, bool isInteractingWithFocusedElement, CallbackID callbackID)
+void WebPage::selectWithGesture(const IntPoint& point, GestureType gestureType, GestureRecognizerState gestureState, bool isInteractingWithFocusedElement, CompletionHandler<void(const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<SelectionFlags>)>&& completionHandler)
{
if (static_cast<GestureRecognizerState>(gestureState) == GestureRecognizerState::Began)
setFocusedFrameBeforeSelectingTextAtLocation(point);
@@ -1348,7 +1348,7 @@
VisiblePosition position = visiblePositionInFocusedNodeForPoint(frame, point, isInteractingWithFocusedElement);
if (position.isNull()) {
- send(Messages::WebPageProxy::GestureCallback(point, gestureType, gestureState, { }, callbackID));
+ completionHandler(point, gestureType, gestureState, { });
return;
}
Optional<SimpleRange> range;
@@ -1468,7 +1468,7 @@
if (range)
frame.selection().setSelectedRange(range, position.affinity(), WebCore::FrameSelection::ShouldCloseTyping::Yes, UserTriggered);
- send(Messages::WebPageProxy::GestureCallback(point, gestureType, gestureState, flags, callbackID));
+ completionHandler(point, gestureType, gestureState, flags);
}
static Optional<SimpleRange> rangeForPointInRootViewCoordinates(Frame& frame, const IntPoint& pointInRootViewCoordinates, bool baseIsStart)
@@ -1687,15 +1687,13 @@
}
}
-void WebPage::updateSelectionWithTouches(const IntPoint& point, SelectionTouch selectionTouch, bool baseIsStart, CallbackID callbackID)
+void WebPage::updateSelectionWithTouches(const IntPoint& point, SelectionTouch selectionTouch, bool baseIsStart, CompletionHandler<void(const WebCore::IntPoint&, SelectionTouch, OptionSet<SelectionFlags>)>&& completionHandler)
{
Frame& frame = m_page->focusController().focusedOrMainFrame();
IntPoint pointInDocument = frame.view()->rootViewToContents(point);
VisiblePosition position = frame.visiblePositionForPoint(pointInDocument);
- if (position.isNull()) {
- send(Messages::WebPageProxy::TouchesCallback(point, selectionTouch, { }, callbackID));
- return;
- }
+ if (position.isNull())
+ return completionHandler(point, selectionTouch, { });
if (shouldDispatchSyntheticMouseEventsWhenModifyingSelection())
dispatchSyntheticMouseEventsForSelectionGesture(selectionTouch, point);
@@ -1731,10 +1729,10 @@
if (range)
frame.selection().setSelectedRange(range, position.affinity(), WebCore::FrameSelection::ShouldCloseTyping::Yes, UserTriggered);
- send(Messages::WebPageProxy::TouchesCallback(point, selectionTouch, flags, callbackID));
+ completionHandler(point, selectionTouch, flags);
}
-void WebPage::selectWithTwoTouches(const WebCore::IntPoint& from, const WebCore::IntPoint& to, GestureType gestureType, GestureRecognizerState gestureState, CallbackID callbackID)
+void WebPage::selectWithTwoTouches(const WebCore::IntPoint& from, const WebCore::IntPoint& to, GestureType gestureType, GestureRecognizerState gestureState, CompletionHandler<void(const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<SelectionFlags>)>&& completionHandler)
{
Frame& frame = m_page->focusController().focusedOrMainFrame();
auto fromPosition = frame.visiblePositionForPoint(frame.view()->rootViewToContents(from));
@@ -1746,7 +1744,7 @@
}
// We can use the same callback for the gestures with one point.
- send(Messages::WebPageProxy::GestureCallback(from, gestureType, gestureState, { }, callbackID));
+ completionHandler(from, gestureType, gestureState, { });
}
void WebPage::extendSelection(WebCore::TextGranularity granularity, CompletionHandler<void()>&& completionHandler)
@@ -1951,7 +1949,7 @@
reply(WTFMove(rectsToAvoidInRootViewCoordinates));
}
-void WebPage::getRectsForGranularityWithSelectionOffset(WebCore::TextGranularity granularity, int32_t offset, CallbackID callbackID)
+void WebPage::getRectsForGranularityWithSelectionOffset(WebCore::TextGranularity granularity, int32_t offset, CompletionHandler<void(const Vector<WebCore::SelectionRect>&)>&& completionHandler)
{
Frame& frame = m_page->focusController().focusedOrMainFrame();
@@ -1960,13 +1958,13 @@
auto direction = offset < 0 ? SelectionDirection::Backward : SelectionDirection::Forward;
auto range = enclosingTextUnitOfGranularity(position, granularity, direction);
if (!range || range->collapsed()) {
- send(Messages::WebPageProxy::SelectionRectsCallback({ }, callbackID));
+ completionHandler({ });
return;
}
auto selectionRects = RenderObject::collectSelectionRectsWithoutUnionInteriorLines(*range);
convertContentToRootViewSelectionRects(*frame.view(), selectionRects);
- send(Messages::WebPageProxy::SelectionRectsCallback(selectionRects, callbackID));
+ completionHandler(selectionRects);
}
void WebPage::storeSelectionForAccessibility(bool shouldStore)
@@ -1991,7 +1989,7 @@
return findClosestPlainText(range, matchText, { }, characterCount({ range.start, *boundaryPoint }, TextIteratorEmitsCharactersBetweenAllVisiblePositions));
}
-void WebPage::getRectsAtSelectionOffsetWithText(int32_t offset, const String& text, CallbackID callbackID)
+void WebPage::getRectsAtSelectionOffsetWithText(int32_t offset, const String& text, CompletionHandler<void(const Vector<WebCore::SelectionRect>&)>&& completionHandler)
{
Frame& frame = m_page->focusController().focusedOrMainFrame();
auto& selection = m_storedSelectionForAccessibility.isNone() ? frame.selection().selection() : m_storedSelectionForAccessibility;
@@ -1998,7 +1996,7 @@
auto startPosition = visiblePositionForPositionWithOffset(selection.visibleStart(), offset);
auto range = makeSimpleRange(startPosition, visiblePositionForPositionWithOffset(startPosition, text.length()));
if (!range || range->collapsed()) {
- send(Messages::WebPageProxy::SelectionRectsCallback({ }, callbackID));
+ completionHandler({ });
return;
}
@@ -2012,7 +2010,7 @@
auto selectionRects = RenderObject::collectSelectionRectsWithoutUnionInteriorLines(*range);
convertContentToRootViewSelectionRects(*frame.view(), selectionRects);
- send(Messages::WebPageProxy::SelectionRectsCallback(selectionRects, callbackID));
+ completionHandler(selectionRects);
}
VisiblePosition WebPage::visiblePositionInFocusedNodeForPoint(const Frame& frame, const IntPoint& point, bool isInteractingWithFocusedElement)