Changeset 271201 in webkit
- Timestamp:
- Jan 6, 2021, 9:32:26 AM (6 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 8 edited
-
ChangeLog (modified) (1 diff)
-
UIProcess/WebPageProxy.h (modified) (6 diffs)
-
UIProcess/WebPageProxy.messages.in (modified) (3 diffs)
-
UIProcess/ios/WKContentViewInteraction.mm (modified) (7 diffs)
-
UIProcess/ios/WebPageProxyIOS.mm (modified) (4 diffs)
-
WebProcess/WebPage/WebPage.h (modified) (2 diffs)
-
WebProcess/WebPage/WebPage.messages.in (modified) (2 diffs)
-
WebProcess/WebPage/ios/WebPageIOS.mm (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r271198 r271201 1 2021-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 1 40 2021-01-06 Per Arne Vollan <pvollan@apple.com> 2 41 -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r271187 r271201 400 400 #endif 401 401 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 #endif408 409 402 #if PLATFORM(COCOA) 410 403 using DrawToPDFCallback = GenericCallback<const IPC::DataReference&>; … … 762 755 void willCommitLayerTree(TransactionID); 763 756 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>)>&&); 767 760 void extendSelection(WebCore::TextGranularity, CompletionHandler<void()>&& = { }); 768 761 void selectWordBackward(); … … 816 809 void setMinimumEffectiveDeviceWidthWithoutViewportConfigurationUpdate(double minimumEffectiveDeviceWidth) { m_viewportConfigurationMinimumEffectiveDeviceWidth = minimumEffectiveDeviceWidth; } 817 810 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>&)>&&); 820 813 void autofillLoginCredentials(const String& username, const String& password); 821 814 void storeSelectionForAccessibility(bool); … … 1419 1412 void suppressNextAutomaticNavigationSnapshot() { m_shouldSuppressNextAutomaticNavigationSnapshot = true; } 1420 1413 void recordNavigationSnapshot(WebBackForwardListItem&); 1421 void requestFocusedElementInformation( Function<void(const FocusedElementInformation&, CallbackBase::Error)>&&);1414 void requestFocusedElementInformation(CompletionHandler<void(const FocusedElementInformation&)>&&); 1422 1415 1423 1416 #if PLATFORM(COCOA) || PLATFORM(GTK) … … 2157 2150 #endif 2158 2151 #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);2161 2152 void interpretKeyEvent(const EditorState&, bool isCharEvent, CompletionHandler<void(bool)>&&); 2162 2153 void showPlaybackTargetPicker(bool hasVideo, const WebCore::IntRect& elementRect, WebCore::RouteSharingPolicy, const String&); 2163 void selectionRectsCallback(const Vector<WebCore::SelectionRect>&, CallbackID);2164 2154 2165 2155 void updateStringForFind(const String&); … … 2226 2216 void enableInspectorNodeSearch(); 2227 2217 void disableInspectorNodeSearch(); 2228 void focusedElementInformationCallback(const FocusedElementInformation&, CallbackID);2229 2218 #else 2230 2219 void didReleaseAllTouchPoints() { } -
trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in
r271187 r271201 175 175 #endif 176 176 #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)179 177 InterpretKeyEvent(struct WebKit::EditorState state, bool isCharEvent) -> (bool handled) Synchronous 180 178 DidReceivePositionInformation(struct WebKit::InteractionInformationAtPosition information) … … 186 184 DisableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID) 187 185 HandleSmartMagnificationInformationForPotentialTap(uint64_t requestID, WebCore::FloatRect renderRect, bool fitEntireRect, double viewportMinimumScale, double viewportMaximumScale, bool nodeIsRootLevel) 188 SelectionRectsCallback(Vector<WebCore::SelectionRect> selectionRects, WebKit::CallbackID callbackID);189 186 #endif 190 187 #if ENABLE(DATA_DETECTION) … … 402 399 ShowInspectorHighlight(struct WebCore::InspectorOverlay::Highlight highlight) 403 400 HideInspectorHighlight() 404 FocusedElementInformationCallback(struct WebKit::FocusedElementInformation information, WebKit::CallbackID callbackID)405 401 406 402 ShowInspectorIndication() -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
r271193 r271201 3741 3741 - (void)_accessibilityRetrieveRectsEnclosingSelectionOffset:(NSInteger)offset withGranularity:(UITextGranularity)granularity 3742 3742 { 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) { 3747 3744 if ([view respondsToSelector:@selector(_accessibilityDidGetSelectionRects:withGranularity:atOffset:)]) 3748 3745 [view _accessibilityDidGetSelectionRects:[view webSelectionRectsForSelectionRects:selectionRects] withGranularity:granularity atOffset:offset]; … … 3758 3755 { 3759 3756 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) { 3761 3758 if (capturedCompletionHandler) 3762 3759 capturedCompletionHandler(selectionRects); 3763 3760 3764 if (error != WebKit::CallbackBase::Error::None)3765 return;3766 3761 if ([view respondsToSelector:@selector(_accessibilityDidGetSelectionRects:withGranularity:atOffset:)]) 3767 3762 [view _accessibilityDidGetSelectionRects:[view webSelectionRectsForSelectionRects:selectionRects] withGranularity:UITextGranularityWord atOffset:offset]; … … 4008 4003 } 4009 4004 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; 4005 static void selectionChangedWithGesture(WKContentView *view, const WebCore::IntPoint& point, WebKit::GestureType gestureType, WebKit::GestureRecognizerState gestureState, OptionSet<WebKit::SelectionFlags> flags) 4006 { 4014 4007 [(UIWKTextInteractionAssistant *)[view interactionAssistant] selectionChangedWithGestureAt:(CGPoint)point withGesture:toUIWKGestureType(gestureType) withState:toUIGestureRecognizerState(gestureState) withFlags:toUIWKSelectionFlags(flags)]; 4015 4008 } 4016 4009 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; 4010 static void selectionChangedWithTouch(WKContentView *view, const WebCore::IntPoint& point, WebKit::SelectionTouch touch, OptionSet<WebKit::SelectionFlags> flags) 4011 { 4021 4012 [(UIWKTextInteractionAssistant *)[view interactionAssistant] selectionChangedWithTouchAt:(CGPoint)point withSelectionTouch:toUIWKSelectionTouch((WebKit::SelectionTouch)touch) withFlags:toUIWKSelectionFlags(flags)]; 4022 4013 } … … 4035 4026 { 4036 4027 _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); 4039 4030 if (state == UIGestureRecognizerStateEnded || state == UIGestureRecognizerStateCancelled) 4040 4031 _usingGestureForSelection = NO; … … 4045 4036 { 4046 4037 _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); 4049 4040 if (toUIWKSelectionTouch(touch) != UIWKSelectionTouchStarted && toUIWKSelectionTouch(touch) != UIWKSelectionTouchMoved) 4050 4041 _usingGestureForSelection = NO; … … 4055 4046 { 4056 4047 _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); 4059 4050 if (toUIGestureRecognizerState(gestureState) == UIGestureRecognizerStateEnded || toUIGestureRecognizerState(gestureState) == UIGestureRecognizerStateCancelled) 4060 4051 _usingGestureForSelection = NO; … … 6330 6321 WeakObjCPtr<WKContentView> weakSelf { self }; 6331 6322 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) { 6334 6325 // If the focused element may have changed in the meantime, don't overwrite focused element information. 6335 6326 callback(false); -
trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
r271149 r271201 150 150 } 151 151 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); 152 void WebPageProxy::requestFocusedElementInformation(CompletionHandler<void(const FocusedElementInformation&)>&& callback) 153 { 154 if (!hasRunningProcess()) 155 return callback({ }); 156 157 sendWithAsyncReply(Messages::WebPage::RequestFocusedElementInformation(), WTFMove(callback)); 205 158 } 206 159 … … 423 376 } 424 377 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); 378 void 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 386 void 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)); 445 392 } 446 393 … … 613 560 } 614 561 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); 562 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) 563 { 564 if (!hasRunningProcess()) 565 return callback({ }, GestureType::Loupe, GestureRecognizerState::Possible, { }); 566 567 sendWithAsyncReply(Messages::WebPage::SelectWithTwoTouches(from, to, gestureType, gestureState), WTFMove(callback)); 624 568 } 625 569 … … 746 690 } 747 691 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); 692 void 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 700 void 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)); 768 706 } 769 707 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r271187 r271201 726 726 727 727 void blurFocusedElement(); 728 void requestFocusedElementInformation(C allbackID);729 void selectWithGesture(const WebCore::IntPoint&, GestureType, GestureRecognizerState, bool isInteractingWithFocusedElement, C allbackID);730 void updateSelectionWithTouches(const WebCore::IntPoint&, SelectionTouch, bool baseIsStart, C allbackID);731 void selectWithTwoTouches(const WebCore::IntPoint& from, const WebCore::IntPoint& to, GestureType, GestureRecognizerState, C allbackID);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>)>&&); 732 732 void extendSelection(WebCore::TextGranularity, CompletionHandler<void()>&&); 733 733 void selectWordBackward(); … … 763 763 void getSelectionContext(CompletionHandler<void(const String&, const String&, const String&)>&&); 764 764 void handleTwoFingerTapAtPoint(const WebCore::IntPoint&, OptionSet<WebKit::WebEvent::Modifier>, uint64_t requestID); 765 void getRectsForGranularityWithSelectionOffset(WebCore::TextGranularity, int32_t, C allbackID);766 void getRectsAtSelectionOffsetWithText(int32_t, const String&, C allbackID);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>&)>&&); 767 767 void storeSelectionForAccessibility(bool); 768 768 void startAutoscrollAtPosition(const WebCore::FloatPoint&); -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in
r271187 r271201 66 66 InspectorNodeSearchEndedAtPosition(WebCore::FloatPoint point) 67 67 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 71 71 ExtendSelection(enum:uint8_t WebCore::TextGranularity granularity) -> () Async 72 72 SelectWordBackward() … … 109 109 HandleTwoFingerTapAtPoint(WebCore::IntPoint point, OptionSet<WebKit::WebEvent::Modifier> modifiers, uint64_t requestID) 110 110 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 113 113 StoreSelectionForAccessibility(bool shouldStore) 114 114 StartAutoscrollAtPosition(WebCore::FloatPoint positionInWindow) 115 115 CancelAutoscroll() 116 RequestFocusedElementInformation( WebKit::CallbackID callbackID)116 RequestFocusedElementInformation() -> (struct WebKit::FocusedElementInformation info) Async 117 117 HardwareKeyboardAvailabilityChanged(bool keyboardIsAttached) 118 118 SetIsShowingInputViewForFocusedElement(bool showingInputView) -
trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
r271149 r271201 923 923 } 924 924 925 void WebPage::requestFocusedElementInformation( WebKit::CallbackID callbackID)925 void WebPage::requestFocusedElementInformation(CompletionHandler<void(const FocusedElementInformation&)>&& completionHandler) 926 926 { 927 927 FocusedElementInformation info; … … 929 929 getFocusedElementInformation(info); 930 930 931 send(Messages::WebPageProxy::FocusedElementInformationCallback(info, callbackID));931 completionHandler(info); 932 932 } 933 933 … … 1340 1340 } 1341 1341 1342 void WebPage::selectWithGesture(const IntPoint& point, GestureType gestureType, GestureRecognizerState gestureState, bool isInteractingWithFocusedElement, C allbackID callbackID)1342 void WebPage::selectWithGesture(const IntPoint& point, GestureType gestureType, GestureRecognizerState gestureState, bool isInteractingWithFocusedElement, CompletionHandler<void(const WebCore::IntPoint&, GestureType, GestureRecognizerState, OptionSet<SelectionFlags>)>&& completionHandler) 1343 1343 { 1344 1344 if (static_cast<GestureRecognizerState>(gestureState) == GestureRecognizerState::Began) … … 1349 1349 1350 1350 if (position.isNull()) { 1351 send(Messages::WebPageProxy::GestureCallback(point, gestureType, gestureState, { }, callbackID));1351 completionHandler(point, gestureType, gestureState, { }); 1352 1352 return; 1353 1353 } … … 1469 1469 frame.selection().setSelectedRange(range, position.affinity(), WebCore::FrameSelection::ShouldCloseTyping::Yes, UserTriggered); 1470 1470 1471 send(Messages::WebPageProxy::GestureCallback(point, gestureType, gestureState, flags, callbackID));1471 completionHandler(point, gestureType, gestureState, flags); 1472 1472 } 1473 1473 … … 1688 1688 } 1689 1689 1690 void WebPage::updateSelectionWithTouches(const IntPoint& point, SelectionTouch selectionTouch, bool baseIsStart, C allbackID callbackID)1690 void WebPage::updateSelectionWithTouches(const IntPoint& point, SelectionTouch selectionTouch, bool baseIsStart, CompletionHandler<void(const WebCore::IntPoint&, SelectionTouch, OptionSet<SelectionFlags>)>&& completionHandler) 1691 1691 { 1692 1692 Frame& frame = m_page->focusController().focusedOrMainFrame(); 1693 1693 IntPoint pointInDocument = frame.view()->rootViewToContents(point); 1694 1694 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, { }); 1699 1697 1700 1698 if (shouldDispatchSyntheticMouseEventsWhenModifyingSelection()) … … 1732 1730 frame.selection().setSelectedRange(range, position.affinity(), WebCore::FrameSelection::ShouldCloseTyping::Yes, UserTriggered); 1733 1731 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, C allbackID callbackID)1732 completionHandler(point, selectionTouch, flags); 1733 } 1734 1735 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) 1738 1736 { 1739 1737 Frame& frame = m_page->focusController().focusedOrMainFrame(); … … 1747 1745 1748 1746 // 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, { }); 1750 1748 } 1751 1749 … … 1952 1950 } 1953 1951 1954 void WebPage::getRectsForGranularityWithSelectionOffset(WebCore::TextGranularity granularity, int32_t offset, C allbackID callbackID)1952 void WebPage::getRectsForGranularityWithSelectionOffset(WebCore::TextGranularity granularity, int32_t offset, CompletionHandler<void(const Vector<WebCore::SelectionRect>&)>&& completionHandler) 1955 1953 { 1956 1954 Frame& frame = m_page->focusController().focusedOrMainFrame(); … … 1961 1959 auto range = enclosingTextUnitOfGranularity(position, granularity, direction); 1962 1960 if (!range || range->collapsed()) { 1963 send(Messages::WebPageProxy::SelectionRectsCallback({ }, callbackID));1961 completionHandler({ }); 1964 1962 return; 1965 1963 } … … 1967 1965 auto selectionRects = RenderObject::collectSelectionRectsWithoutUnionInteriorLines(*range); 1968 1966 convertContentToRootViewSelectionRects(*frame.view(), selectionRects); 1969 send(Messages::WebPageProxy::SelectionRectsCallback(selectionRects, callbackID));1967 completionHandler(selectionRects); 1970 1968 } 1971 1969 … … 1992 1990 } 1993 1991 1994 void WebPage::getRectsAtSelectionOffsetWithText(int32_t offset, const String& text, C allbackID callbackID)1992 void WebPage::getRectsAtSelectionOffsetWithText(int32_t offset, const String& text, CompletionHandler<void(const Vector<WebCore::SelectionRect>&)>&& completionHandler) 1995 1993 { 1996 1994 Frame& frame = m_page->focusController().focusedOrMainFrame(); … … 1999 1997 auto range = makeSimpleRange(startPosition, visiblePositionForPositionWithOffset(startPosition, text.length())); 2000 1998 if (!range || range->collapsed()) { 2001 send(Messages::WebPageProxy::SelectionRectsCallback({ }, callbackID));1999 completionHandler({ }); 2002 2000 return; 2003 2001 } … … 2013 2011 auto selectionRects = RenderObject::collectSelectionRectsWithoutUnionInteriorLines(*range); 2014 2012 convertContentToRootViewSelectionRects(*frame.view(), selectionRects); 2015 send(Messages::WebPageProxy::SelectionRectsCallback(selectionRects, callbackID));2013 completionHandler(selectionRects); 2016 2014 } 2017 2015
Note:
See TracChangeset
for help on using the changeset viewer.