⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 271201 in webkit


Ignore:
Timestamp:
Jan 6, 2021, 9:32:26 AM (6 years ago)
Author:
commit-queue@webkit.org
Message:

Use sendWithAsyncReply instead of iOS-specific GenericCallbacks
https://bugs.webkit.org/show_bug.cgi?id=220346

Patch by Alex Christensen <achristensen@webkit.org> on 2021-01-06
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):

Location:
trunk/Source/WebKit
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r271198 r271201  
     12021-01-06  Alex Christensen  <achristensen@webkit.org>
     2
     3        Use sendWithAsyncReply instead of iOS-specific GenericCallbacks
     4        https://bugs.webkit.org/show_bug.cgi?id=220346
     5
     6        Reviewed by Darin Adler.
     7
     8        * UIProcess/WebPageProxy.h:
     9        * UIProcess/WebPageProxy.messages.in:
     10        * UIProcess/ios/WKContentViewInteraction.mm:
     11        (-[WKContentView _accessibilityRetrieveRectsEnclosingSelectionOffset:withGranularity:]):
     12        (-[WKContentView _accessibilityRetrieveRectsAtSelectionOffset:withText:completionHandler:]):
     13        (selectionChangedWithGesture):
     14        (selectionChangedWithTouch):
     15        (-[WKContentView changeSelectionWithGestureAt:withGesture:withState:withFlags:]):
     16        (-[WKContentView changeSelectionWithTouchAt:withSelectionTouch:baseIsStart:withFlags:]):
     17        (-[WKContentView changeSelectionWithTouchesFrom:to:withGesture:withState:]):
     18        (-[WKContentView updateCurrentFocusedElementInformation:]):
     19        * UIProcess/ios/WebPageProxyIOS.mm:
     20        (WebKit::WebPageProxy::requestFocusedElementInformation):
     21        (WebKit::WebPageProxy::selectWithGesture):
     22        (WebKit::WebPageProxy::updateSelectionWithTouches):
     23        (WebKit::WebPageProxy::selectWithTwoTouches):
     24        (WebKit::WebPageProxy::requestRectsForGranularityWithSelectionOffset):
     25        (WebKit::WebPageProxy::requestRectsAtSelectionOffsetWithText):
     26        (WebKit::WebPageProxy::gestureCallback): Deleted.
     27        (WebKit::WebPageProxy::touchesCallback): Deleted.
     28        (WebKit::WebPageProxy::selectionRectsCallback): Deleted.
     29        (WebKit::WebPageProxy::focusedElementInformationCallback): Deleted.
     30        * WebProcess/WebPage/WebPage.h:
     31        * WebProcess/WebPage/WebPage.messages.in:
     32        * WebProcess/WebPage/ios/WebPageIOS.mm:
     33        (WebKit::WebPage::requestFocusedElementInformation):
     34        (WebKit::WebPage::selectWithGesture):
     35        (WebKit::WebPage::updateSelectionWithTouches):
     36        (WebKit::WebPage::selectWithTwoTouches):
     37        (WebKit::WebPage::getRectsForGranularityWithSelectionOffset):
     38        (WebKit::WebPage::getRectsAtSelectionOffsetWithText):
     39
    1402021-01-06  Per Arne Vollan  <pvollan@apple.com>
    241
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r271187 r271201  
    400400#endif
    401401
    402 #if PLATFORM(IOS_FAMILY)
    403 typedef GenericCallback<const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<SelectionFlags>> GestureCallback;
    404 typedef GenericCallback<const WebCore::IntPoint&, SelectionTouch, OptionSet<SelectionFlags>> TouchesCallback;
    405 typedef GenericCallback<const Vector<WebCore::SelectionRect>&> SelectionRectsCallback;
    406 typedef GenericCallback<const FocusedElementInformation&> FocusedElementInformationCallback;
    407 #endif
    408 
    409402#if PLATFORM(COCOA)
    410403using DrawToPDFCallback = GenericCallback<const IPC::DataReference&>;
     
    762755    void willCommitLayerTree(TransactionID);
    763756
    764     void selectWithGesture(const WebCore::IntPoint, GestureType, GestureRecognizerState, bool isInteractingWithFocusedElement, WTF::Function<void(const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<SelectionFlags>, CallbackBase::Error)>&&);
    765     void updateSelectionWithTouches(const WebCore::IntPoint, SelectionTouch, bool baseIsStart, Function<void(const WebCore::IntPoint&, SelectionTouch, OptionSet<SelectionFlags>, CallbackBase::Error)>&&);
    766     void selectWithTwoTouches(const WebCore::IntPoint from, const WebCore::IntPoint to, GestureType, GestureRecognizerState, Function<void(const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<SelectionFlags>, CallbackBase::Error)>&&);
     757    void selectWithGesture(const WebCore::IntPoint, GestureType, GestureRecognizerState, bool isInteractingWithFocusedElement, CompletionHandler<void(const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<SelectionFlags>)>&&);
     758    void updateSelectionWithTouches(const WebCore::IntPoint, SelectionTouch, bool baseIsStart, CompletionHandler<void(const WebCore::IntPoint&, SelectionTouch, OptionSet<SelectionFlags>)>&&);
     759    void selectWithTwoTouches(const WebCore::IntPoint from, const WebCore::IntPoint to, GestureType, GestureRecognizerState, CompletionHandler<void(const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<SelectionFlags>)>&&);
    767760    void extendSelection(WebCore::TextGranularity, CompletionHandler<void()>&& = { });
    768761    void selectWordBackward();
     
    816809    void setMinimumEffectiveDeviceWidthWithoutViewportConfigurationUpdate(double minimumEffectiveDeviceWidth) { m_viewportConfigurationMinimumEffectiveDeviceWidth = minimumEffectiveDeviceWidth; }
    817810    void setIsScrollingOrZooming(bool);
    818     void requestRectsForGranularityWithSelectionOffset(WebCore::TextGranularity, uint32_t offset, WTF::Function<void(const Vector<WebCore::SelectionRect>&, CallbackBase::Error)>&&);
    819     void requestRectsAtSelectionOffsetWithText(int32_t offset, const String&, WTF::Function<void(const Vector<WebCore::SelectionRect>&, CallbackBase::Error)>&&);
     811    void requestRectsForGranularityWithSelectionOffset(WebCore::TextGranularity, uint32_t offset, CompletionHandler<void(const Vector<WebCore::SelectionRect>&)>&&);
     812    void requestRectsAtSelectionOffsetWithText(int32_t offset, const String&, CompletionHandler<void(const Vector<WebCore::SelectionRect>&)>&&);
    820813    void autofillLoginCredentials(const String& username, const String& password);
    821814    void storeSelectionForAccessibility(bool);
     
    14191412    void suppressNextAutomaticNavigationSnapshot() { m_shouldSuppressNextAutomaticNavigationSnapshot = true; }
    14201413    void recordNavigationSnapshot(WebBackForwardListItem&);
    1421     void requestFocusedElementInformation(Function<void(const FocusedElementInformation&, CallbackBase::Error)>&&);
     1414    void requestFocusedElementInformation(CompletionHandler<void(const FocusedElementInformation&)>&&);
    14221415
    14231416#if PLATFORM(COCOA) || PLATFORM(GTK)
     
    21572150#endif
    21582151#if PLATFORM(IOS_FAMILY)
    2159     void gestureCallback(const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<SelectionFlags>, CallbackID);
    2160     void touchesCallback(const WebCore::IntPoint&, SelectionTouch, OptionSet<SelectionFlags>, CallbackID);
    21612152    void interpretKeyEvent(const EditorState&, bool isCharEvent, CompletionHandler<void(bool)>&&);
    21622153    void showPlaybackTargetPicker(bool hasVideo, const WebCore::IntRect& elementRect, WebCore::RouteSharingPolicy, const String&);
    2163     void selectionRectsCallback(const Vector<WebCore::SelectionRect>&, CallbackID);
    21642154
    21652155    void updateStringForFind(const String&);
     
    22262216    void enableInspectorNodeSearch();
    22272217    void disableInspectorNodeSearch();
    2228     void focusedElementInformationCallback(const FocusedElementInformation&, CallbackID);
    22292218#else
    22302219    void didReleaseAllTouchPoints() { }
  • trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in

    r271187 r271201  
    175175#endif
    176176#if PLATFORM(IOS_FAMILY)
    177     GestureCallback(WebCore::IntPoint point, enum:uint8_t WebKit::GestureType gestureType, enum:uint8_t WebKit::GestureRecognizerState gestureState, OptionSet<WebKit::SelectionFlags> flags, WebKit::CallbackID callbackID)
    178     TouchesCallback(WebCore::IntPoint point, enum:uint8_t WebKit::SelectionTouch touches, OptionSet<WebKit::SelectionFlags> flags, WebKit::CallbackID callbackID)
    179177    InterpretKeyEvent(struct WebKit::EditorState state, bool isCharEvent) -> (bool handled) Synchronous
    180178    DidReceivePositionInformation(struct WebKit::InteractionInformationAtPosition information)
     
    186184    DisableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID)
    187185    HandleSmartMagnificationInformationForPotentialTap(uint64_t requestID, WebCore::FloatRect renderRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale, bool nodeIsRootLevel)
    188     SelectionRectsCallback(Vector<WebCore::SelectionRect> selectionRects, WebKit::CallbackID callbackID);
    189186#endif
    190187#if ENABLE(DATA_DETECTION)
     
    402399    ShowInspectorHighlight(struct WebCore::InspectorOverlay::Highlight highlight)
    403400    HideInspectorHighlight()
    404     FocusedElementInformationCallback(struct WebKit::FocusedElementInformation information, WebKit::CallbackID callbackID)
    405401
    406402    ShowInspectorIndication()
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r271193 r271201  
    37413741- (void)_accessibilityRetrieveRectsEnclosingSelectionOffset:(NSInteger)offset withGranularity:(UITextGranularity)granularity
    37423742{
    3743     RetainPtr<WKContentView> view = self;
    3744     _page->requestRectsForGranularityWithSelectionOffset(toWKTextGranularity(granularity), offset , [view, offset, granularity](const Vector<WebCore::SelectionRect>& selectionRects, WebKit::CallbackBase::Error error) {
    3745         if (error != WebKit::CallbackBase::Error::None)
    3746             return;
     3743    _page->requestRectsForGranularityWithSelectionOffset(toWKTextGranularity(granularity), offset, [view = retainPtr(self), offset, granularity](const Vector<WebCore::SelectionRect>& selectionRects) {
    37473744        if ([view respondsToSelector:@selector(_accessibilityDidGetSelectionRects:withGranularity:atOffset:)])
    37483745            [view _accessibilityDidGetSelectionRects:[view webSelectionRectsForSelectionRects:selectionRects] withGranularity:granularity atOffset:offset];
     
    37583755{
    37593756    RetainPtr<WKContentView> view = self;
    3760     _page->requestRectsAtSelectionOffsetWithText(offset, text, [view, offset, capturedCompletionHandler = makeBlockPtr(completionHandler)](const Vector<WebCore::SelectionRect>& selectionRects, WebKit::CallbackBase::Error error) {
     3757    _page->requestRectsAtSelectionOffsetWithText(offset, text, [view, offset, capturedCompletionHandler = makeBlockPtr(completionHandler)](const Vector<WebCore::SelectionRect>& selectionRects) {
    37613758        if (capturedCompletionHandler)
    37623759            capturedCompletionHandler(selectionRects);
    37633760
    3764         if (error != WebKit::CallbackBase::Error::None)
    3765             return;
    37663761        if ([view respondsToSelector:@selector(_accessibilityDidGetSelectionRects:withGranularity:atOffset:)])
    37673762            [view _accessibilityDidGetSelectionRects:[view webSelectionRectsForSelectionRects:selectionRects] withGranularity:UITextGranularityWord atOffset:offset];
     
    40084003}
    40094004
    4010 static void selectionChangedWithGesture(WKContentView *view, const WebCore::IntPoint& point, WebKit::GestureType gestureType, WebKit::GestureRecognizerState gestureState, OptionSet<WebKit::SelectionFlags> flags, WebKit::CallbackBase::Error error)
    4011 {
    4012     if (error != WebKit::CallbackBase::Error::None)
    4013         return;
     4005static void selectionChangedWithGesture(WKContentView *view, const WebCore::IntPoint& point, WebKit::GestureType gestureType, WebKit::GestureRecognizerState gestureState, OptionSet<WebKit::SelectionFlags> flags)
     4006{
    40144007    [(UIWKTextInteractionAssistant *)[view interactionAssistant] selectionChangedWithGestureAt:(CGPoint)point withGesture:toUIWKGestureType(gestureType) withState:toUIGestureRecognizerState(gestureState) withFlags:toUIWKSelectionFlags(flags)];
    40154008}
    40164009
    4017 static void selectionChangedWithTouch(WKContentView *view, const WebCore::IntPoint& point, WebKit::SelectionTouch touch, OptionSet<WebKit::SelectionFlags> flags, WebKit::CallbackBase::Error error)
    4018 {
    4019     if (error != WebKit::CallbackBase::Error::None)
    4020         return;
     4010static void selectionChangedWithTouch(WKContentView *view, const WebCore::IntPoint& point, WebKit::SelectionTouch touch, OptionSet<WebKit::SelectionFlags> flags)
     4011{
    40214012    [(UIWKTextInteractionAssistant *)[view interactionAssistant] selectionChangedWithTouchAt:(CGPoint)point withSelectionTouch:toUIWKSelectionTouch((WebKit::SelectionTouch)touch) withFlags:toUIWKSelectionFlags(flags)];
    40224013}
     
    40354026{
    40364027    _usingGestureForSelection = YES;
    4037     _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) {
    4038         selectionChangedWithGesture(self, point, gestureType, gestureState, toSelectionFlags(flags) | innerFlags, error);
     4028    _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) {
     4029        selectionChangedWithGesture(self, point, gestureType, gestureState, toSelectionFlags(flags) | innerFlags);
    40394030        if (state == UIGestureRecognizerStateEnded || state == UIGestureRecognizerStateCancelled)
    40404031            _usingGestureForSelection = NO;
     
    40454036{
    40464037    _usingGestureForSelection = YES;
    4047     _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) {
    4048         selectionChangedWithTouch(self, point, touch, toSelectionFlags(flags) | innerFlags, error);
     4038    _page->updateSelectionWithTouches(WebCore::IntPoint(point), toSelectionTouch(touch), baseIsStart, [self, strongSelf = retainPtr(self), flags](const WebCore::IntPoint& point, WebKit::SelectionTouch touch, OptionSet<WebKit::SelectionFlags> innerFlags) {
     4039        selectionChangedWithTouch(self, point, touch, toSelectionFlags(flags) | innerFlags);
    40494040        if (toUIWKSelectionTouch(touch) != UIWKSelectionTouchStarted && toUIWKSelectionTouch(touch) != UIWKSelectionTouchMoved)
    40504041            _usingGestureForSelection = NO;
     
    40554046{
    40564047    _usingGestureForSelection = YES;
    4057     _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) {
    4058         selectionChangedWithGesture(self, point, gestureType, gestureState, flags, error);
     4048    _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) {
     4049        selectionChangedWithGesture(self, point, gestureType, gestureState, flags);
    40594050        if (toUIGestureRecognizerState(gestureState) == UIGestureRecognizerStateEnded || toUIGestureRecognizerState(gestureState) == UIGestureRecognizerStateCancelled)
    40604051            _usingGestureForSelection = NO;
     
    63306321    WeakObjCPtr<WKContentView> weakSelf { self };
    63316322    auto identifierBeforeUpdate = _focusedElementInformation.focusedElementIdentifier;
    6332     _page->requestFocusedElementInformation([callback = WTFMove(callback), identifierBeforeUpdate, weakSelf] (auto& info, auto error) {
    6333         if (!weakSelf || error != WebKit::CallbackBase::Error::None || info.focusedElementIdentifier != identifierBeforeUpdate) {
     6323    _page->requestFocusedElementInformation([callback = WTFMove(callback), identifierBeforeUpdate, weakSelf] (auto& info) {
     6324        if (!weakSelf || info.focusedElementIdentifier != identifierBeforeUpdate) {
    63346325            // If the focused element may have changed in the meantime, don't overwrite focused element information.
    63356326            callback(false);
  • trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm

    r271149 r271201  
    150150}
    151151
    152 void WebPageProxy::gestureCallback(const WebCore::IntPoint& point, GestureType gestureType, GestureRecognizerState gestureState, OptionSet<SelectionFlags> flags, CallbackID callbackID)
    153 {
    154     auto callback = m_callbacks.take<GestureCallback>(callbackID);
    155     if (!callback) {
    156         ASSERT_NOT_REACHED();
    157         return;
    158     }
    159    
    160     callback->performCallbackWithReturnValue(point, gestureType, gestureState, flags);
    161 }
    162 
    163 void WebPageProxy::touchesCallback(const WebCore::IntPoint& point, SelectionTouch touches, OptionSet<SelectionFlags> flags, CallbackID callbackID)
    164 {
    165     auto callback = m_callbacks.take<TouchesCallback>(callbackID);
    166     if (!callback) {
    167         ASSERT_NOT_REACHED();
    168         return;
    169     }
    170 
    171     callback->performCallbackWithReturnValue(point, touches, flags);
    172 }
    173 
    174 void WebPageProxy::selectionRectsCallback(const Vector<WebCore::SelectionRect>& selectionRects, CallbackID callbackID)
    175 {
    176     auto callback = m_callbacks.take<SelectionRectsCallback>(callbackID);
    177     if (!callback) {
    178         ASSERT_NOT_REACHED();
    179         return;
    180     }
    181    
    182     callback->performCallbackWithReturnValue(selectionRects);
    183 }
    184 
    185 void WebPageProxy::focusedElementInformationCallback(const FocusedElementInformation& info, CallbackID callbackID)
    186 {
    187     auto callback = m_callbacks.take<FocusedElementInformationCallback>(callbackID);
    188     if (!callback) {
    189         ASSERT_NOT_REACHED();
    190         return;
    191     }
    192 
    193     callback->performCallbackWithReturnValue(info);
    194 }
    195 
    196 void WebPageProxy::requestFocusedElementInformation(Function<void(const FocusedElementInformation&, CallbackBase::Error)>&& callback)
    197 {
    198     if (!hasRunningProcess()) {
    199         callback({ }, CallbackBase::Error::OwnerWasInvalidated);
    200         return;
    201     }
    202 
    203     auto callbackID = m_callbacks.put(WTFMove(callback), m_process->throttler().backgroundActivity("WebPageProxy::requestFocusedElementInformation"_s));
    204     m_process->send(Messages::WebPage::RequestFocusedElementInformation(callbackID), m_webPageID);
     152void WebPageProxy::requestFocusedElementInformation(CompletionHandler<void(const FocusedElementInformation&)>&& callback)
     153{
     154    if (!hasRunningProcess())
     155        return callback({ });
     156
     157    sendWithAsyncReply(Messages::WebPage::RequestFocusedElementInformation(), WTFMove(callback));
    205158}
    206159
     
    423376}
    424377
    425 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)
    426 {
    427     if (!hasRunningProcess()) {
    428         callbackFunction(WebCore::IntPoint(), GestureType::Loupe, GestureRecognizerState::Possible, { }, CallbackBase::Error::Unknown);
    429         return;
    430     }
    431 
    432     auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::selectWithGesture"_s));
    433     m_process->send(Messages::WebPage::SelectWithGesture(point, gestureType, gestureState, isInteractingWithFocusedElement, callbackID), m_webPageID);
    434 }
    435 
    436 void WebPageProxy::updateSelectionWithTouches(const WebCore::IntPoint point, SelectionTouch touches, bool baseIsStart, Function<void(const WebCore::IntPoint&, SelectionTouch, OptionSet<SelectionFlags>, CallbackBase::Error)>&& callbackFunction)
    437 {
    438     if (!hasRunningProcess()) {
    439         callbackFunction(WebCore::IntPoint(), SelectionTouch::Started, { }, CallbackBase::Error::Unknown);
    440         return;
    441     }
    442 
    443     auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::updateSelectionWithTouches"_s));
    444     m_process->send(Messages::WebPage::UpdateSelectionWithTouches(point, touches, baseIsStart, callbackID), m_webPageID);
     378void WebPageProxy::selectWithGesture(const WebCore::IntPoint point, GestureType gestureType, GestureRecognizerState gestureState, bool isInteractingWithFocusedElement, CompletionHandler<void(const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<WebKit::SelectionFlags>)>&& callback)
     379{
     380    if (!hasRunningProcess())
     381        return callback({ }, GestureType::Loupe, GestureRecognizerState::Possible, { });
     382
     383    sendWithAsyncReply(Messages::WebPage::SelectWithGesture(point, gestureType, gestureState, isInteractingWithFocusedElement), WTFMove(callback));
     384}
     385
     386void WebPageProxy::updateSelectionWithTouches(const WebCore::IntPoint point, SelectionTouch touches, bool baseIsStart, CompletionHandler<void(const WebCore::IntPoint&, SelectionTouch, OptionSet<SelectionFlags>)>&& callback)
     387{
     388    if (!hasRunningProcess())
     389        return callback(WebCore::IntPoint(), SelectionTouch::Started, { });
     390
     391    sendWithAsyncReply(Messages::WebPage::UpdateSelectionWithTouches(point, touches, baseIsStart), WTFMove(callback));
    445392}
    446393   
     
    613560}
    614561
    615 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)
    616 {
    617     if (!hasRunningProcess()) {
    618         callbackFunction(WebCore::IntPoint(), GestureType::Loupe, GestureRecognizerState::Possible, { }, CallbackBase::Error::Unknown);
    619         return;
    620     }
    621 
    622     auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::selectWithTwoTouches"_s));
    623     m_process->send(Messages::WebPage::SelectWithTwoTouches(from, to, gestureType, gestureState, callbackID), m_webPageID);
     562void WebPageProxy::selectWithTwoTouches(const WebCore::IntPoint from, const WebCore::IntPoint to, GestureType gestureType, GestureRecognizerState gestureState, CompletionHandler<void(const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<SelectionFlags>)>&& callback)
     563{
     564    if (!hasRunningProcess())
     565        return callback({ }, GestureType::Loupe, GestureRecognizerState::Possible, { });
     566
     567    sendWithAsyncReply(Messages::WebPage::SelectWithTwoTouches(from, to, gestureType, gestureState), WTFMove(callback));
    624568}
    625569
     
    746690}
    747691
    748 void WebPageProxy::requestRectsForGranularityWithSelectionOffset(WebCore::TextGranularity granularity, uint32_t offset, WTF::Function<void(const Vector<WebCore::SelectionRect>&, CallbackBase::Error)>&& callbackFunction)
    749 {
    750     if (!hasRunningProcess()) {
    751         callbackFunction(Vector<WebCore::SelectionRect>(), CallbackBase::Error::Unknown);
    752         return;
    753     }
    754    
    755     auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::requestRectsForGranularityWithSelectionOffset"_s));
    756     m_process->send(Messages::WebPage::GetRectsForGranularityWithSelectionOffset(granularity, offset, callbackID), m_webPageID);
    757 }
    758 
    759 void WebPageProxy::requestRectsAtSelectionOffsetWithText(int32_t offset, const String& text, WTF::Function<void(const Vector<WebCore::SelectionRect>&, CallbackBase::Error)>&& callbackFunction)
    760 {
    761     if (!hasRunningProcess()) {
    762         callbackFunction(Vector<WebCore::SelectionRect>(), CallbackBase::Error::Unknown);
    763         return;
    764     }
    765    
    766     auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::requestRectsAtSelectionOffsetWithText"_s));
    767     m_process->send(Messages::WebPage::GetRectsAtSelectionOffsetWithText(offset, text, callbackID), m_webPageID);
     692void WebPageProxy::requestRectsForGranularityWithSelectionOffset(WebCore::TextGranularity granularity, uint32_t offset, CompletionHandler<void(const Vector<WebCore::SelectionRect>&)>&& callback)
     693{
     694    if (!hasRunningProcess())
     695        return callback({ });
     696   
     697    sendWithAsyncReply(Messages::WebPage::GetRectsForGranularityWithSelectionOffset(granularity, offset), WTFMove(callback));
     698}
     699
     700void WebPageProxy::requestRectsAtSelectionOffsetWithText(int32_t offset, const String& text, CompletionHandler<void(const Vector<WebCore::SelectionRect>&)>&& callback)
     701{
     702    if (!hasRunningProcess())
     703        return callback({ });
     704   
     705    sendWithAsyncReply(Messages::WebPage::GetRectsAtSelectionOffsetWithText(offset, text), WTFMove(callback));
    768706}
    769707
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r271187 r271201  
    726726
    727727    void blurFocusedElement();
    728     void requestFocusedElementInformation(CallbackID);
    729     void selectWithGesture(const WebCore::IntPoint&, GestureType, GestureRecognizerState, bool isInteractingWithFocusedElement, CallbackID);
    730     void updateSelectionWithTouches(const WebCore::IntPoint&, SelectionTouch, bool baseIsStart, CallbackID);
    731     void selectWithTwoTouches(const WebCore::IntPoint& from, const WebCore::IntPoint& to, GestureType, GestureRecognizerState, CallbackID);
     728    void requestFocusedElementInformation(CompletionHandler<void(const FocusedElementInformation&)>&&);
     729    void selectWithGesture(const WebCore::IntPoint&, GestureType, GestureRecognizerState, bool isInteractingWithFocusedElement, CompletionHandler<void(const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<SelectionFlags>)>&&);
     730    void updateSelectionWithTouches(const WebCore::IntPoint&, SelectionTouch, bool baseIsStart, CompletionHandler<void(const WebCore::IntPoint&, SelectionTouch, OptionSet<SelectionFlags>)>&&);
     731    void selectWithTwoTouches(const WebCore::IntPoint& from, const WebCore::IntPoint& to, GestureType, GestureRecognizerState, CompletionHandler<void(const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<SelectionFlags>)>&&);
    732732    void extendSelection(WebCore::TextGranularity, CompletionHandler<void()>&&);
    733733    void selectWordBackward();
     
    763763    void getSelectionContext(CompletionHandler<void(const String&, const String&, const String&)>&&);
    764764    void handleTwoFingerTapAtPoint(const WebCore::IntPoint&, OptionSet<WebKit::WebEvent::Modifier>, uint64_t requestID);
    765     void getRectsForGranularityWithSelectionOffset(WebCore::TextGranularity, int32_t, CallbackID);
    766     void getRectsAtSelectionOffsetWithText(int32_t, const String&, CallbackID);
     765    void getRectsForGranularityWithSelectionOffset(WebCore::TextGranularity, int32_t, CompletionHandler<void(const Vector<WebCore::SelectionRect>&)>&&);
     766    void getRectsAtSelectionOffsetWithText(int32_t, const String&, CompletionHandler<void(const Vector<WebCore::SelectionRect>&)>&&);
    767767    void storeSelectionForAccessibility(bool);
    768768    void startAutoscrollAtPosition(const WebCore::FloatPoint&);
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in

    r271187 r271201  
    6666    InspectorNodeSearchEndedAtPosition(WebCore::FloatPoint point)
    6767    BlurFocusedElement()
    68     SelectWithGesture(WebCore::IntPoint point, enum:uint8_t WebKit::GestureType gestureType, enum:uint8_t WebKit::GestureRecognizerState gestureState, bool isInteractingWithFocusedElement, WebKit::CallbackID callbackID)
    69     UpdateSelectionWithTouches(WebCore::IntPoint point, enum:uint8_t WebKit::SelectionTouch touches, bool baseIsStart, WebKit::CallbackID callbackID)
    70     SelectWithTwoTouches(WebCore::IntPoint from, WebCore::IntPoint to, enum:uint8_t WebKit::GestureType gestureType, enum:uint8_t WebKit::GestureRecognizerState gestureState, WebKit::CallbackID callbackID)
     68    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
     69    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
     70    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
    7171    ExtendSelection(enum:uint8_t WebCore::TextGranularity granularity) -> () Async
    7272    SelectWordBackward()
     
    109109    HandleTwoFingerTapAtPoint(WebCore::IntPoint point, OptionSet<WebKit::WebEvent::Modifier> modifiers, uint64_t requestID)
    110110    SetForceAlwaysUserScalable(bool userScalable)
    111     GetRectsForGranularityWithSelectionOffset(enum:uint8_t WebCore::TextGranularity granularity, int32_t offset, WebKit::CallbackID callbackID)
    112     GetRectsAtSelectionOffsetWithText(int32_t offset, String text, WebKit::CallbackID callbackID)
     111    GetRectsForGranularityWithSelectionOffset(enum:uint8_t WebCore::TextGranularity granularity, int32_t offset) -> (Vector<WebCore::SelectionRect> rect) Async
     112    GetRectsAtSelectionOffsetWithText(int32_t offset, String text) -> (Vector<WebCore::SelectionRect> rect) Async
    113113    StoreSelectionForAccessibility(bool shouldStore)
    114114    StartAutoscrollAtPosition(WebCore::FloatPoint positionInWindow)
    115115    CancelAutoscroll()
    116     RequestFocusedElementInformation(WebKit::CallbackID callbackID)
     116    RequestFocusedElementInformation() -> (struct WebKit::FocusedElementInformation info) Async
    117117    HardwareKeyboardAvailabilityChanged(bool keyboardIsAttached)
    118118    SetIsShowingInputViewForFocusedElement(bool showingInputView)
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r271149 r271201  
    923923}
    924924
    925 void WebPage::requestFocusedElementInformation(WebKit::CallbackID callbackID)
     925void WebPage::requestFocusedElementInformation(CompletionHandler<void(const FocusedElementInformation&)>&& completionHandler)
    926926{
    927927    FocusedElementInformation info;
     
    929929        getFocusedElementInformation(info);
    930930
    931     send(Messages::WebPageProxy::FocusedElementInformationCallback(info, callbackID));
     931    completionHandler(info);
    932932}
    933933
     
    13401340}
    13411341
    1342 void WebPage::selectWithGesture(const IntPoint& point, GestureType gestureType, GestureRecognizerState gestureState, bool isInteractingWithFocusedElement, CallbackID callbackID)
     1342void WebPage::selectWithGesture(const IntPoint& point, GestureType gestureType, GestureRecognizerState gestureState, bool isInteractingWithFocusedElement, CompletionHandler<void(const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<SelectionFlags>)>&& completionHandler)
    13431343{
    13441344    if (static_cast<GestureRecognizerState>(gestureState) == GestureRecognizerState::Began)
     
    13491349
    13501350    if (position.isNull()) {
    1351         send(Messages::WebPageProxy::GestureCallback(point, gestureType, gestureState, { }, callbackID));
     1351        completionHandler(point, gestureType, gestureState, { });
    13521352        return;
    13531353    }
     
    14691469        frame.selection().setSelectedRange(range, position.affinity(), WebCore::FrameSelection::ShouldCloseTyping::Yes, UserTriggered);
    14701470
    1471     send(Messages::WebPageProxy::GestureCallback(point, gestureType, gestureState, flags, callbackID));
     1471    completionHandler(point, gestureType, gestureState, flags);
    14721472}
    14731473
     
    16881688}
    16891689
    1690 void WebPage::updateSelectionWithTouches(const IntPoint& point, SelectionTouch selectionTouch, bool baseIsStart, CallbackID callbackID)
     1690void WebPage::updateSelectionWithTouches(const IntPoint& point, SelectionTouch selectionTouch, bool baseIsStart, CompletionHandler<void(const WebCore::IntPoint&, SelectionTouch, OptionSet<SelectionFlags>)>&& completionHandler)
    16911691{
    16921692    Frame& frame = m_page->focusController().focusedOrMainFrame();
    16931693    IntPoint pointInDocument = frame.view()->rootViewToContents(point);
    16941694    VisiblePosition position = frame.visiblePositionForPoint(pointInDocument);
    1695     if (position.isNull()) {
    1696         send(Messages::WebPageProxy::TouchesCallback(point, selectionTouch, { }, callbackID));
    1697         return;
    1698     }
     1695    if (position.isNull())
     1696        return completionHandler(point, selectionTouch, { });
    16991697
    17001698    if (shouldDispatchSyntheticMouseEventsWhenModifyingSelection())
     
    17321730        frame.selection().setSelectedRange(range, position.affinity(), WebCore::FrameSelection::ShouldCloseTyping::Yes, UserTriggered);
    17331731
    1734     send(Messages::WebPageProxy::TouchesCallback(point, selectionTouch, flags, callbackID));
    1735 }
    1736 
    1737 void WebPage::selectWithTwoTouches(const WebCore::IntPoint& from, const WebCore::IntPoint& to, GestureType gestureType, GestureRecognizerState gestureState, CallbackID callbackID)
     1732    completionHandler(point, selectionTouch, flags);
     1733}
     1734
     1735void WebPage::selectWithTwoTouches(const WebCore::IntPoint& from, const WebCore::IntPoint& to, GestureType gestureType, GestureRecognizerState gestureState, CompletionHandler<void(const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<SelectionFlags>)>&& completionHandler)
    17381736{
    17391737    Frame& frame = m_page->focusController().focusedOrMainFrame();
     
    17471745
    17481746    // We can use the same callback for the gestures with one point.
    1749     send(Messages::WebPageProxy::GestureCallback(from, gestureType, gestureState, { }, callbackID));
     1747    completionHandler(from, gestureType, gestureState, { });
    17501748}
    17511749
     
    19521950}
    19531951
    1954 void WebPage::getRectsForGranularityWithSelectionOffset(WebCore::TextGranularity granularity, int32_t offset, CallbackID callbackID)
     1952void WebPage::getRectsForGranularityWithSelectionOffset(WebCore::TextGranularity granularity, int32_t offset, CompletionHandler<void(const Vector<WebCore::SelectionRect>&)>&& completionHandler)
    19551953{
    19561954    Frame& frame = m_page->focusController().focusedOrMainFrame();
     
    19611959    auto range = enclosingTextUnitOfGranularity(position, granularity, direction);
    19621960    if (!range || range->collapsed()) {
    1963         send(Messages::WebPageProxy::SelectionRectsCallback({ }, callbackID));
     1961        completionHandler({ });
    19641962        return;
    19651963    }
     
    19671965    auto selectionRects = RenderObject::collectSelectionRectsWithoutUnionInteriorLines(*range);
    19681966    convertContentToRootViewSelectionRects(*frame.view(), selectionRects);
    1969     send(Messages::WebPageProxy::SelectionRectsCallback(selectionRects, callbackID));
     1967    completionHandler(selectionRects);
    19701968}
    19711969
     
    19921990}
    19931991
    1994 void WebPage::getRectsAtSelectionOffsetWithText(int32_t offset, const String& text, CallbackID callbackID)
     1992void WebPage::getRectsAtSelectionOffsetWithText(int32_t offset, const String& text, CompletionHandler<void(const Vector<WebCore::SelectionRect>&)>&& completionHandler)
    19951993{
    19961994    Frame& frame = m_page->focusController().focusedOrMainFrame();
     
    19991997    auto range = makeSimpleRange(startPosition, visiblePositionForPositionWithOffset(startPosition, text.length()));
    20001998    if (!range || range->collapsed()) {
    2001         send(Messages::WebPageProxy::SelectionRectsCallback({ }, callbackID));
     1999        completionHandler({ });
    20022000        return;
    20032001    }
     
    20132011    auto selectionRects = RenderObject::collectSelectionRectsWithoutUnionInteriorLines(*range);
    20142012    convertContentToRootViewSelectionRects(*frame.view(), selectionRects);
    2015     send(Messages::WebPageProxy::SelectionRectsCallback(selectionRects, callbackID));
     2013    completionHandler(selectionRects);
    20162014}
    20172015
Note: See TracChangeset for help on using the changeset viewer.