Diff
Modified: trunk/Source/WebKit/ChangeLog (260763 => 260764)
--- trunk/Source/WebKit/ChangeLog 2020-04-27 17:05:09 UTC (rev 260763)
+++ trunk/Source/WebKit/ChangeLog 2020-04-27 17:13:19 UTC (rev 260764)
@@ -1,3 +1,51 @@
+2020-04-27 Alex Christensen <[email protected]>
+
+ Reduce use of WebPageProxy::VoidCallback
+ https://bugs.webkit.org/show_bug.cgi?id=210944
+
+ Reviewed by Darin Adler.
+
+ Use sendWithAsyncReply and CompletionHandler<void()> instead.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _executeEditCommand:argument:completion:]):
+ * UIProcess/Cocoa/WebViewImpl.mm:
+ (WebKit::WebViewImpl::becomeFirstResponder):
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::setInitialFocus):
+ (WebKit::WebPageProxy::executeEditCommand):
+ * UIProcess/WebPageProxy.h:
+ (WebKit::WebPageProxy::focusNextFocusedElement):
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView pasteWithCompletionHandler:]):
+ (-[WKContentView moveByOffset:]):
+ (-[WKContentView _selectPositionAtPoint:stayingWithinFocusedElement:completionHandler:]):
+ (-[WKContentView selectPositionAtBoundary:inDirection:fromPoint:completionHandler:]):
+ (-[WKContentView moveSelectionAtBoundary:inDirection:completionHandler:]):
+ (-[WKContentView selectTextWithGranularity:atPoint:completionHandler:]):
+ (-[WKContentView _becomeFirstResponderWithSelectionMovingForward:completionHandler:]):
+ (-[WKContentView accessoryTab:]):
+ (-[WKContentView executeEditCommandWithCallback:]):
+ * UIProcess/ios/WebPageProxyIOS.mm:
+ (WebKit::WebPageProxy::selectTextWithGranularityAtPoint):
+ (WebKit::WebPageProxy::selectPositionAtBoundaryWithDirection):
+ (WebKit::WebPageProxy::moveSelectionAtBoundaryWithDirection):
+ (WebKit::WebPageProxy::selectPositionAtPoint):
+ (WebKit::WebPageProxy::moveSelectionByOffset):
+ (WebKit::WebPageProxy::focusNextFocusedElement):
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::executeEditCommandWithCallback):
+ (WebKit::WebPage::setInitialFocus):
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/WebPage.messages.in:
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::WebPage::moveSelectionByOffset):
+ (WebKit::WebPage::selectPositionAtPoint):
+ (WebKit::WebPage::selectPositionAtBoundaryWithDirection):
+ (WebKit::WebPage::moveSelectionAtBoundaryWithDirection):
+ (WebKit::WebPage::selectTextWithGranularityAtPoint):
+ (WebKit::WebPage::focusNextFocusedElement):
+
2020-04-27 Per Arne Vollan <[email protected]>
Unreviewed sandbox compile fix.
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (260763 => 260764)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2020-04-27 17:05:09 UTC (rev 260763)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2020-04-27 17:13:19 UTC (rev 260764)
@@ -1616,9 +1616,9 @@
- (void)_executeEditCommand:(NSString *)command argument:(NSString *)argument completion:(void (^)(BOOL))completion
{
- _page->executeEditCommand(command, argument, [capturedCompletionBlock = makeBlockPtr(completion)](WebKit::CallbackBase::Error error) {
+ _page->executeEditCommand(command, argument, [capturedCompletionBlock = makeBlockPtr(completion)] {
if (capturedCompletionBlock)
- capturedCompletionBlock(error == WebKit::CallbackBase::Error::None);
+ capturedCompletionBlock(YES);
});
}
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (260763 => 260764)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2020-04-27 17:05:09 UTC (rev 260763)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2020-04-27 17:13:19 UTC (rev 260764)
@@ -1581,7 +1581,7 @@
NSEvent *keyboardEvent = nil;
if ([event type] == NSEventTypeKeyDown || [event type] == NSEventTypeKeyUp)
keyboardEvent = event;
- m_page->setInitialFocus(direction == NSSelectingNext, keyboardEvent != nil, NativeWebKeyboardEvent(keyboardEvent, false, false, { }), [](WebKit::CallbackBase::Error) { });
+ m_page->setInitialFocus(direction == NSSelectingNext, keyboardEvent != nil, NativeWebKeyboardEvent(keyboardEvent, false, false, { }), [] { });
}
return true;
}
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (260763 => 260764)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-04-27 17:05:09 UTC (rev 260763)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2020-04-27 17:13:19 UTC (rev 260764)
@@ -2165,15 +2165,16 @@
return pageClient().viewSize();
}
-void WebPageProxy::setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent& keyboardEvent, WTF::Function<void (CallbackBase::Error)>&& callbackFunction)
+void WebPageProxy::setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent& keyboardEvent, CompletionHandler<void()>&& callbackFunction)
{
if (!hasRunningProcess()) {
- callbackFunction(CallbackBase::Error::OwnerWasInvalidated);
+ callbackFunction();
return;
}
- auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::setInitialFocus"_s));
- send(Messages::WebPage::SetInitialFocus(forward, isKeyboardEventValid, keyboardEvent, callbackID));
+ sendWithAsyncReply(Messages::WebPage::SetInitialFocus(forward, isKeyboardEventValid, keyboardEvent), [callbackFunction = WTFMove(callbackFunction), backgroundActivity = m_process->throttler().backgroundActivity("WebPageProxy::setInitialFocus"_s)] () mutable {
+ callbackFunction();
+ });
}
void WebPageProxy::clearSelection()
@@ -2299,10 +2300,10 @@
return pasteCommandNames->contains(commandName);
}
-void WebPageProxy::executeEditCommand(const String& commandName, const String& argument, WTF::Function<void(CallbackBase::Error)>&& callbackFunction)
+void WebPageProxy::executeEditCommand(const String& commandName, const String& argument, CompletionHandler<void()>&& callbackFunction)
{
if (!hasRunningProcess()) {
- callbackFunction(CallbackBase::Error::Unknown);
+ callbackFunction();
return;
}
@@ -2309,8 +2310,9 @@
if (isPasteCommandName(commandName))
willPerformPasteCommand();
- auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::executeEditCommand"_s));
- send(Messages::WebPage::ExecuteEditCommandWithCallback(commandName, argument, callbackID));
+ sendWithAsyncReply(Messages::WebPage::ExecuteEditCommandWithCallback(commandName, argument), [callbackFunction = WTFMove(callbackFunction), backgroundActivity = m_process->throttler().backgroundActivity("WebPageProxy::executeEditCommand"_s)] () mutable {
+ callbackFunction();
+ });
}
void WebPageProxy::executeEditCommand(const String& commandName, const String& argument)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (260763 => 260764)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2020-04-27 17:05:09 UTC (rev 260763)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2020-04-27 17:13:19 UTC (rev 260764)
@@ -641,7 +641,7 @@
void viewWillStartLiveResize();
void viewWillEndLiveResize();
- void setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent&, WTF::Function<void (CallbackBase::Error)>&&);
+ void setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent&, CompletionHandler<void()>&&);
void clearSelection();
void restoreSelectionInFocusedEditableElement();
@@ -674,6 +674,7 @@
void selectAll();
void executeEditCommand(const String& commandName, const String& argument = String());
+ void executeEditCommand(const String& commandName, const String& argument, CompletionHandler<void()>&&);
void validateCommand(const String& commandName, WTF::Function<void (const String&, bool, int32_t, CallbackBase::Error)>&&);
const EditorState& editorState() const { return m_editorState; }
@@ -701,8 +702,7 @@
void activateMediaStreamCaptureInPage();
bool isMediaStreamCaptureMuted() const { return m_mutedState & WebCore::MediaProducer::MediaStreamCaptureIsMuted; }
void setMediaStreamCaptureMuted(bool);
- void executeEditCommand(const String& commandName, const String& argument, WTF::Function<void(CallbackBase::Error)>&&);
-
+
void requestFontAttributesAtSelectionStart(Function<void(const WebCore::FontAttributes&, CallbackBase::Error)>&&);
void fontAttributesCallback(const WebCore::FontAttributes&, CallbackID);
@@ -756,11 +756,11 @@
void selectWithTwoTouches(const WebCore::IntPoint from, const WebCore::IntPoint to, uint32_t gestureType, uint32_t gestureState, WTF::Function<void (const WebCore::IntPoint&, uint32_t, uint32_t, uint32_t, CallbackBase::Error)>&&);
void extendSelection(WebCore::TextGranularity);
void selectWordBackward();
- void moveSelectionByOffset(int32_t offset, WTF::Function<void (CallbackBase::Error)>&&);
- void selectTextWithGranularityAtPoint(const WebCore::IntPoint, WebCore::TextGranularity, bool isInteractingWithFocusedElement, WTF::Function<void(CallbackBase::Error)>&&);
- void selectPositionAtPoint(const WebCore::IntPoint, bool isInteractingWithFocusedElement, WTF::Function<void(CallbackBase::Error)>&&);
- void selectPositionAtBoundaryWithDirection(const WebCore::IntPoint, WebCore::TextGranularity, WebCore::SelectionDirection, bool isInteractingWithFocusedElement, WTF::Function<void(CallbackBase::Error)>&&);
- void moveSelectionAtBoundaryWithDirection(WebCore::TextGranularity, WebCore::SelectionDirection, WTF::Function<void(CallbackBase::Error)>&&);
+ void moveSelectionByOffset(int32_t offset, CompletionHandler<void()>&&);
+ void selectTextWithGranularityAtPoint(const WebCore::IntPoint, WebCore::TextGranularity, bool isInteractingWithFocusedElement, CompletionHandler<void()>&&);
+ void selectPositionAtPoint(const WebCore::IntPoint, bool isInteractingWithFocusedElement, CompletionHandler<void()>&&);
+ void selectPositionAtBoundaryWithDirection(const WebCore::IntPoint, WebCore::TextGranularity, WebCore::SelectionDirection, bool isInteractingWithFocusedElement, CompletionHandler<void()>&&);
+ void moveSelectionAtBoundaryWithDirection(WebCore::TextGranularity, WebCore::SelectionDirection, CompletionHandler<void()>&&);
void beginSelectionInDirection(WebCore::SelectionDirection, WTF::Function<void (uint64_t, CallbackBase::Error)>&&);
void updateSelectionWithExtentPoint(const WebCore::IntPoint, bool isInteractingWithFocusedElement, RespectSelectionAnchor, WTF::Function<void(uint64_t, CallbackBase::Error)>&&);
void updateSelectionWithExtentPointAndBoundary(const WebCore::IntPoint, WebCore::TextGranularity, bool isInteractingWithFocusedElement, WTF::Function<void(uint64_t, CallbackBase::Error)>&&);
@@ -778,7 +778,7 @@
void stopInteraction();
void performActionOnElement(uint32_t action);
void saveImageToLibrary(const SharedMemory::Handle& imageHandle, uint64_t imageSize);
- void focusNextFocusedElement(bool isForward, WTF::Function<void (CallbackBase::Error)>&& = [] (auto) { });
+ void focusNextFocusedElement(bool isForward, CompletionHandler<void()>&& = [] { });
void setFocusedElementValue(const String&);
void setFocusedElementValueAsNumber(double);
void setFocusedElementSelectedIndex(uint32_t index, bool allowMultipleSelection = false);
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (260763 => 260764)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2020-04-27 17:05:09 UTC (rev 260763)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2020-04-27 17:13:19 UTC (rev 260764)
@@ -2832,7 +2832,7 @@
- (void)pasteWithCompletionHandler:(void (^)(void))completionHandler
{
- _page->executeEditCommand("Paste"_s, { }, [completion = makeBlockPtr(completionHandler)] (auto) {
+ _page->executeEditCommand("Paste"_s, { }, [completion = makeBlockPtr(completionHandler)] {
if (completion)
completion();
});
@@ -3920,7 +3920,7 @@
[self beginSelectionChange];
RetainPtr<WKContentView> view = self;
- _page->moveSelectionByOffset(offset, [view](WebKit::CallbackBase::Error) {
+ _page->moveSelectionByOffset(offset, [view] {
[view endSelectionChange];
});
}
@@ -4011,7 +4011,7 @@
UIWKSelectionCompletionHandler selectionHandler = [completionHandler copy];
RetainPtr<WKContentView> view = self;
- _page->selectPositionAtPoint(WebCore::IntPoint(point), stayingWithinFocusedElement, [view, selectionHandler](WebKit::CallbackBase::Error error) {
+ _page->selectPositionAtPoint(WebCore::IntPoint(point), stayingWithinFocusedElement, [view, selectionHandler]() {
selectionHandler();
view->_usingGestureForSelection = NO;
[selectionHandler release];
@@ -4024,7 +4024,7 @@
UIWKSelectionCompletionHandler selectionHandler = [completionHandler copy];
RetainPtr<WKContentView> view = self;
- _page->selectPositionAtBoundaryWithDirection(WebCore::IntPoint(point), toWKTextGranularity(granularity), toWKSelectionDirection(direction), self._hasFocusedElement, [view, selectionHandler](WebKit::CallbackBase::Error error) {
+ _page->selectPositionAtBoundaryWithDirection(WebCore::IntPoint(point), toWKTextGranularity(granularity), toWKSelectionDirection(direction), self._hasFocusedElement, [view, selectionHandler]() {
selectionHandler();
view->_usingGestureForSelection = NO;
[selectionHandler release];
@@ -4037,7 +4037,7 @@
UIWKSelectionCompletionHandler selectionHandler = [completionHandler copy];
RetainPtr<WKContentView> view = self;
- _page->moveSelectionAtBoundaryWithDirection(toWKTextGranularity(granularity), toWKSelectionDirection(direction), [view, selectionHandler](WebKit::CallbackBase::Error error) {
+ _page->moveSelectionAtBoundaryWithDirection(toWKTextGranularity(granularity), toWKSelectionDirection(direction), [view, selectionHandler] {
selectionHandler();
view->_usingGestureForSelection = NO;
[selectionHandler release];
@@ -4051,7 +4051,7 @@
UIWKSelectionCompletionHandler selectionHandler = [completionHandler copy];
RetainPtr<WKContentView> view = self;
- _page->selectTextWithGranularityAtPoint(WebCore::IntPoint(point), toWKTextGranularity(granularity), self._hasFocusedElement, [view, selectionHandler](WebKit::CallbackBase::Error error) {
+ _page->selectTextWithGranularityAtPoint(WebCore::IntPoint(point), toWKTextGranularity(granularity), self._hasFocusedElement, [view, selectionHandler] {
selectionHandler();
view->_usingGestureForSelection = NO;
--view->_suppressNonEditableSingleTapTextInteractionCount;
@@ -4272,7 +4272,7 @@
- (void)_becomeFirstResponderWithSelectionMovingForward:(BOOL)selectingForward completionHandler:(void (^)(BOOL didBecomeFirstResponder))completionHandler
{
constexpr bool isKeyboardEventValid = false;
- _page->setInitialFocus(selectingForward, isKeyboardEventValid, { }, [protectedSelf = retainPtr(self), completionHandler = makeBlockPtr(completionHandler)] (auto) {
+ _page->setInitialFocus(selectingForward, isKeyboardEventValid, { }, [protectedSelf = retainPtr(self), completionHandler = makeBlockPtr(completionHandler)] {
completionHandler([protectedSelf becomeFirstResponder]);
});
}
@@ -4336,7 +4336,7 @@
_isChangingFocusUsingAccessoryTab = YES;
[self beginSelectionChange];
- _page->focusNextFocusedElement(isNext, [protectedSelf = retainPtr(self)] (WebKit::CallbackBase::Error) {
+ _page->focusNextFocusedElement(isNext, [protectedSelf = retainPtr(self)] {
[protectedSelf endSelectionChange];
[protectedSelf reloadInputViews];
protectedSelf->_isChangingFocusUsingAccessoryTab = NO;
@@ -5407,7 +5407,7 @@
// or not to know whether to tell WebKit to treat this command as user initiated or not.
[self beginSelectionChange];
RetainPtr<WKContentView> view = self;
- _page->executeEditCommand(commandName, { }, [view](WebKit::CallbackBase::Error) {
+ _page->executeEditCommand(commandName, { }, [view] {
[view endSelectionChange];
});
}
Modified: trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm (260763 => 260764)
--- trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm 2020-04-27 17:05:09 UTC (rev 260763)
+++ trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm 2020-04-27 17:13:19 UTC (rev 260764)
@@ -505,48 +505,52 @@
return autocorrectionApplied;
}
-void WebPageProxy::selectTextWithGranularityAtPoint(const WebCore::IntPoint point, WebCore::TextGranularity granularity, bool isInteractingWithFocusedElement, WTF::Function<void(CallbackBase::Error)>&& callbackFunction)
+void WebPageProxy::selectTextWithGranularityAtPoint(const WebCore::IntPoint point, WebCore::TextGranularity granularity, bool isInteractingWithFocusedElement, CompletionHandler<void()>&& callbackFunction)
{
if (!hasRunningProcess()) {
- callbackFunction(CallbackBase::Error::Unknown);
+ callbackFunction();
return;
}
- auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::selectTextWithGranularityAtPoint"_s));
- m_process->send(Messages::WebPage::SelectTextWithGranularityAtPoint(point, static_cast<uint32_t>(granularity), isInteractingWithFocusedElement, callbackID), m_webPageID);
+ sendWithAsyncReply(Messages::WebPage::SelectTextWithGranularityAtPoint(point, static_cast<uint32_t>(granularity), isInteractingWithFocusedElement), [callbackFunction = WTFMove(callbackFunction), backgroundActivity = m_process->throttler().backgroundActivity("WebPageProxy::selectTextWithGranularityAtPoint"_s)] () mutable {
+ callbackFunction();
+ });
}
-void WebPageProxy::selectPositionAtBoundaryWithDirection(const WebCore::IntPoint point, WebCore::TextGranularity granularity, WebCore::SelectionDirection direction, bool isInteractingWithFocusedElement, WTF::Function<void(CallbackBase::Error)>&& callbackFunction)
+void WebPageProxy::selectPositionAtBoundaryWithDirection(const WebCore::IntPoint point, WebCore::TextGranularity granularity, WebCore::SelectionDirection direction, bool isInteractingWithFocusedElement, CompletionHandler<void()>&& callbackFunction)
{
if (!hasRunningProcess()) {
- callbackFunction(CallbackBase::Error::Unknown);
+ callbackFunction();
return;
}
- auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::selectPositionAtBoundaryWithDirection"_s));
- m_process->send(Messages::WebPage::SelectPositionAtBoundaryWithDirection(point, static_cast<uint32_t>(granularity), static_cast<uint32_t>(direction), isInteractingWithFocusedElement, callbackID), m_webPageID);
+ sendWithAsyncReply(Messages::WebPage::SelectPositionAtBoundaryWithDirection(point, static_cast<uint32_t>(granularity), static_cast<uint32_t>(direction), isInteractingWithFocusedElement), [callbackFunction = WTFMove(callbackFunction), backgroundActivity = m_process->throttler().backgroundActivity("WebPageProxy::selectPositionAtBoundaryWithDirection"_s)] () mutable {
+ callbackFunction();
+ });
}
-void WebPageProxy::moveSelectionAtBoundaryWithDirection(WebCore::TextGranularity granularity, WebCore::SelectionDirection direction, WTF::Function<void(CallbackBase::Error)>&& callbackFunction)
+void WebPageProxy::moveSelectionAtBoundaryWithDirection(WebCore::TextGranularity granularity, WebCore::SelectionDirection direction, CompletionHandler<void()>&& callbackFunction)
{
if (!hasRunningProcess()) {
- callbackFunction(CallbackBase::Error::Unknown);
+ callbackFunction();
return;
}
- auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::moveSelectionAtBoundaryWithDirection"_s));
- m_process->send(Messages::WebPage::MoveSelectionAtBoundaryWithDirection(static_cast<uint32_t>(granularity), static_cast<uint32_t>(direction), callbackID), m_webPageID);
+ sendWithAsyncReply(Messages::WebPage::MoveSelectionAtBoundaryWithDirection(static_cast<uint32_t>(granularity), static_cast<uint32_t>(direction)), [callbackFunction = WTFMove(callbackFunction), backgroundActivity = m_process->throttler().backgroundActivity("WebPageProxy::moveSelectionAtBoundaryWithDirection"_s)] () mutable {
+ callbackFunction();
+ });
}
-void WebPageProxy::selectPositionAtPoint(const WebCore::IntPoint point, bool isInteractingWithFocusedElement, WTF::Function<void(CallbackBase::Error)>&& callbackFunction)
+void WebPageProxy::selectPositionAtPoint(const WebCore::IntPoint point, bool isInteractingWithFocusedElement, CompletionHandler<void()>&& callbackFunction)
{
if (!hasRunningProcess()) {
- callbackFunction(CallbackBase::Error::Unknown);
+ callbackFunction();
return;
}
- auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::selectPositionAtPoint"_s));
- m_process->send(Messages::WebPage::SelectPositionAtPoint(point, isInteractingWithFocusedElement, callbackID), m_webPageID);
+ sendWithAsyncReply(Messages::WebPage::SelectPositionAtPoint(point, isInteractingWithFocusedElement), [callbackFunction = WTFMove(callbackFunction), backgroundActivity = m_process->throttler().backgroundActivity("WebPageProxy::selectPositionAtPoint"_s)] () mutable {
+ callbackFunction();
+ });
}
void WebPageProxy::beginSelectionInDirection(WebCore::SelectionDirection direction, WTF::Function<void (uint64_t, CallbackBase::Error)>&& callbackFunction)
@@ -795,15 +799,16 @@
m_process->send(Messages::WebPage::CancelAutoscroll(), m_webPageID);
}
-void WebPageProxy::moveSelectionByOffset(int32_t offset, WTF::Function<void (CallbackBase::Error)>&& callbackFunction)
+void WebPageProxy::moveSelectionByOffset(int32_t offset, CompletionHandler<void()>&& callbackFunction)
{
if (!hasRunningProcess()) {
- callbackFunction(CallbackBase::Error::Unknown);
+ callbackFunction();
return;
}
- auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::moveSelectionByOffset"_s));
- m_process->send(Messages::WebPage::MoveSelectionByOffset(offset, callbackID), m_webPageID);
+ sendWithAsyncReply(Messages::WebPage::MoveSelectionByOffset(offset), [callbackFunction = WTFMove(callbackFunction), backgroundActivity = m_process->throttler().backgroundActivity("WebPageProxy::moveSelectionByOffset"_s)] () mutable {
+ callbackFunction();
+ });
}
void WebPageProxy::interpretKeyEvent(const EditorState& state, bool isCharEvent, CompletionHandler<void(bool)>&& completionHandler)
@@ -1050,15 +1055,16 @@
pageClient().disableInspectorNodeSearch();
}
-void WebPageProxy::focusNextFocusedElement(bool isForward, WTF::Function<void(CallbackBase::Error)>&& callbackFunction)
+void WebPageProxy::focusNextFocusedElement(bool isForward, CompletionHandler<void()>&& callbackFunction)
{
if (!hasRunningProcess()) {
- callbackFunction(CallbackBase::Error::Unknown);
+ callbackFunction();
return;
}
- auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::focusNextFocusedElement"_s));
- process().send(Messages::WebPage::FocusNextFocusedElement(isForward, callbackID), m_webPageID);
+ sendWithAsyncReply(Messages::WebPage::FocusNextFocusedElement(isForward), [callbackFunction = WTFMove(callbackFunction), backgroundActivity = m_process->throttler().backgroundActivity("WebPageProxy::focusNextFocusedElement"_s)] () mutable {
+ callbackFunction();
+ });
}
void WebPageProxy::setFocusedElementValue(const String& value)
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (260763 => 260764)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2020-04-27 17:05:09 UTC (rev 260763)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2020-04-27 17:13:19 UTC (rev 260764)
@@ -1119,10 +1119,10 @@
frame.editor().applyStyleToSelection(changes.createEditingStyle(), EditAction::SetFont, Editor::ColorFilterMode::InvertColor);
}
-void WebPage::executeEditCommandWithCallback(const String& commandName, const String& argument, CallbackID callbackID)
+void WebPage::executeEditCommandWithCallback(const String& commandName, const String& argument, CompletionHandler<void()>&& completionHandler)
{
executeEditCommand(commandName, argument);
- send(Messages::WebPageProxy::VoidCallback(callbackID));
+ completionHandler();
}
void WebPage::selectAll()
@@ -3142,10 +3142,10 @@
view->willEndLiveResize();
}
-void WebPage::setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent& event, CallbackID callbackID)
+void WebPage::setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent& event, CompletionHandler<void()>&& completionHandler)
{
if (!m_page)
- return;
+ return completionHandler();
SetForScope<bool> userIsInteractingChange { m_userIsInteracting, true };
@@ -3156,13 +3156,12 @@
PlatformKeyboardEvent platformEvent(platform(event));
platformEvent.disambiguateKeyDownEvent(PlatformEvent::RawKeyDown);
m_page->focusController().setInitialFocus(forward ? FocusDirectionForward : FocusDirectionBackward, &KeyboardEvent::create(platformEvent, &frame.windowProxy()).get());
-
- send(Messages::WebPageProxy::VoidCallback(callbackID));
+ completionHandler();
return;
}
m_page->focusController().setInitialFocus(forward ? FocusDirectionForward : FocusDirectionBackward, nullptr);
- send(Messages::WebPageProxy::VoidCallback(callbackID));
+ completionHandler();
}
void WebPage::setCanStartMediaTimerFired()
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (260763 => 260764)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2020-04-27 17:05:09 UTC (rev 260763)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2020-04-27 17:13:19 UTC (rev 260764)
@@ -641,7 +641,7 @@
void disabledAdaptationsDidChange(const OptionSet<WebCore::DisabledAdaptations>&);
void viewportPropertiesDidChange(const WebCore::ViewportArguments&);
- void executeEditCommandWithCallback(const String&, const String& argument, CallbackID);
+ void executeEditCommandWithCallback(const String&, const String& argument, CompletionHandler<void()>&&);
void selectAll();
void textInputContextsInRect(WebCore::FloatRect, CompletionHandler<void(const Vector<WebCore::ElementContext>&)>&&);
@@ -689,11 +689,11 @@
void selectWithTwoTouches(const WebCore::IntPoint& from, const WebCore::IntPoint& to, uint32_t gestureType, uint32_t gestureState, CallbackID);
void extendSelection(uint32_t granularity);
void selectWordBackward();
- void moveSelectionByOffset(int32_t offset, CallbackID);
- void selectTextWithGranularityAtPoint(const WebCore::IntPoint&, uint32_t granularity, bool isInteractingWithFocusedElement, CallbackID);
- void selectPositionAtBoundaryWithDirection(const WebCore::IntPoint&, uint32_t granularity, uint32_t direction, bool isInteractingWithFocusedElement, CallbackID);
- void moveSelectionAtBoundaryWithDirection(uint32_t granularity, uint32_t direction, CallbackID);
- void selectPositionAtPoint(const WebCore::IntPoint&, bool isInteractingWithFocusedElement, CallbackID);
+ void moveSelectionByOffset(int32_t offset, CompletionHandler<void()>&&);
+ void selectTextWithGranularityAtPoint(const WebCore::IntPoint&, uint32_t granularity, bool isInteractingWithFocusedElement, CompletionHandler<void()>&&);
+ void selectPositionAtBoundaryWithDirection(const WebCore::IntPoint&, uint32_t granularity, uint32_t direction, bool isInteractingWithFocusedElement, CompletionHandler<void()>&&);
+ void moveSelectionAtBoundaryWithDirection(uint32_t granularity, uint32_t direction, CompletionHandler<void()>&&);
+ void selectPositionAtPoint(const WebCore::IntPoint&, bool isInteractingWithFocusedElement, CompletionHandler<void()>&&);
void beginSelectionInDirection(uint32_t direction, CallbackID);
void updateSelectionWithExtentPoint(const WebCore::IntPoint&, bool isInteractingWithFocusedElement, RespectSelectionAnchor, CallbackID);
void updateSelectionWithExtentPointAndBoundary(const WebCore::IntPoint&, uint32_t granularity, bool isInteractingWithFocusedElement, CallbackID);
@@ -710,7 +710,7 @@
void startInteractionWithElementContextOrPosition(Optional<WebCore::ElementContext>&&, WebCore::IntPoint&&);
void stopInteraction();
void performActionOnElement(uint32_t action);
- void focusNextFocusedElement(bool isForward, CallbackID);
+ void focusNextFocusedElement(bool isForward, CompletionHandler<void()>&&);
void autofillLoginCredentials(const String&, const String&);
void setFocusedElementValue(const String&);
void setFocusedElementValueAsNumber(double);
@@ -1429,7 +1429,7 @@
void reload(uint64_t navigationID, uint32_t reloadOptions, SandboxExtension::Handle&&);
void goToBackForwardItem(uint64_t navigationID, const WebCore::BackForwardItemIdentifier&, WebCore::FrameLoadType, WebCore::ShouldTreatAsContinuingLoad, Optional<WebsitePoliciesData>&&);
void tryRestoreScrollPosition();
- void setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent&, CallbackID);
+ void setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent&, CompletionHandler<void()>&&);
void updateIsInWindow(bool isInitialState = false);
void visibilityDidChange();
void setActivityState(OptionSet<WebCore::ActivityState::Flag>, ActivityStateChangeID, const Vector<CallbackID>& callbackIDs);
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (260763 => 260764)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2020-04-27 17:05:09 UTC (rev 260763)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2020-04-27 17:13:19 UTC (rev 260764)
@@ -21,7 +21,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
messages -> WebPage LegacyReceiver {
- SetInitialFocus(bool forward, bool isKeyboardEventValid, WebKit::WebKeyboardEvent event, WebKit::CallbackID callbackID)
+ SetInitialFocus(bool forward, bool isKeyboardEventValid, WebKit::WebKeyboardEvent event) -> () Async
SetActivityState(OptionSet<WebCore::ActivityState::Flag> activityState, WebKit::ActivityStateChangeID activityStateChangeID, Vector<WebKit::CallbackID> callbackIDs)
SetLayerHostingMode(enum:uint8_t WebKit::LayerHostingMode layerHostingMode)
@@ -43,7 +43,7 @@
ViewWillStartLiveResize()
ViewWillEndLiveResize()
- ExecuteEditCommandWithCallback(String name, String argument, WebKit::CallbackID callbackID)
+ ExecuteEditCommandWithCallback(String name, String argument) -> () Async
KeyEvent(WebKit::WebKeyboardEvent event)
MouseEvent(WebKit::WebMouseEvent event)
#if PLATFORM(IOS_FAMILY)
@@ -68,11 +68,11 @@
SelectWithTwoTouches(WebCore::IntPoint from, WebCore::IntPoint to, uint32_t gestureType, uint32_t gestureState, WebKit::CallbackID callbackID)
ExtendSelection(uint32_t granularity)
SelectWordBackward()
- MoveSelectionByOffset(int32_t offset, WebKit::CallbackID callbackID)
- SelectTextWithGranularityAtPoint(WebCore::IntPoint point, uint32_t granularity, bool isInteractingWithFocusedElement, WebKit::CallbackID callbackID)
- SelectPositionAtBoundaryWithDirection(WebCore::IntPoint point, uint32_t granularity, uint32_t direction, bool isInteractingWithFocusedElement, WebKit::CallbackID callbackID)
- MoveSelectionAtBoundaryWithDirection(uint32_t granularity, uint32_t direction, WebKit::CallbackID callbackID)
- SelectPositionAtPoint(WebCore::IntPoint point, bool isInteractingWithFocusedElement, WebKit::CallbackID callbackID)
+ MoveSelectionByOffset(int32_t offset) -> () Async
+ SelectTextWithGranularityAtPoint(WebCore::IntPoint point, uint32_t granularity, bool isInteractingWithFocusedElement) -> () Async
+ SelectPositionAtBoundaryWithDirection(WebCore::IntPoint point, uint32_t granularity, uint32_t direction, bool isInteractingWithFocusedElement) -> () Async
+ MoveSelectionAtBoundaryWithDirection(uint32_t granularity, uint32_t direction) -> () Async
+ SelectPositionAtPoint(WebCore::IntPoint point, bool isInteractingWithFocusedElement) -> () Async
BeginSelectionInDirection(uint32_t direction, WebKit::CallbackID callbackID)
UpdateSelectionWithExtentPoint(WebCore::IntPoint point, bool isInteractingWithFocusedElement, enum:bool WebKit::RespectSelectionAnchor respectSelectionAnchor, WebKit::CallbackID callbackID)
UpdateSelectionWithExtentPointAndBoundary(WebCore::IntPoint point, uint32_t granularity, bool isInteractingWithFocusedElement, WebKit::CallbackID callbackID)
@@ -89,7 +89,7 @@
StartInteractionWithElementContextOrPosition(Optional<WebCore::ElementContext> elementContext, WebCore::IntPoint point)
StopInteraction()
PerformActionOnElement(uint32_t action)
- FocusNextFocusedElement(bool isForward, WebKit::CallbackID callbackID)
+ FocusNextFocusedElement(bool isForward) -> () Async
SetFocusedElementValue(String value)
AutofillLoginCredentials(String username, String password)
SetFocusedElementValueAsNumber(double value)
Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (260763 => 260764)
--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2020-04-27 17:05:09 UTC (rev 260763)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2020-04-27 17:13:19 UTC (rev 260764)
@@ -1836,7 +1836,7 @@
frame.selection().setSelectedRange(Range::create(*frame.document(), startPosition, position).ptr(), position.affinity(), WebCore::FrameSelection::ShouldCloseTyping::Yes, UserTriggered);
}
-void WebPage::moveSelectionByOffset(int32_t offset, CallbackID callbackID)
+void WebPage::moveSelectionByOffset(int32_t offset, CompletionHandler<void()>&& completionHandler)
{
Frame& frame = m_page->focusController().focusedOrMainFrame();
@@ -1852,7 +1852,7 @@
}
if (position.isNotNull() && startPosition != position)
frame.selection().setSelectedRange(Range::create(*frame.document(), position, position).ptr(), position.affinity(), WebCore::FrameSelection::ShouldCloseTyping::Yes, UserTriggered);
- send(Messages::WebPageProxy::VoidCallback(callbackID));
+ completionHandler();
}
void WebPage::startAutoscrollAtPosition(const WebCore::FloatPoint& positionInWindow)
@@ -2073,7 +2073,7 @@
return frame.visiblePositionForPoint(constrainedPoint);
}
-void WebPage::selectPositionAtPoint(const WebCore::IntPoint& point, bool isInteractingWithFocusedElement, CallbackID callbackID)
+void WebPage::selectPositionAtPoint(const WebCore::IntPoint& point, bool isInteractingWithFocusedElement, CompletionHandler<void()>&& completionHandler)
{
SetForScope<bool> userIsInteractingChange { m_userIsInteracting, true };
@@ -2084,10 +2084,10 @@
if (position.isNotNull())
frame.selection().setSelectedRange(Range::create(*frame.document(), position, position).ptr(), position.affinity(), WebCore::FrameSelection::ShouldCloseTyping::Yes, UserTriggered);
- send(Messages::WebPageProxy::VoidCallback(callbackID));
+ completionHandler();
}
-void WebPage::selectPositionAtBoundaryWithDirection(const WebCore::IntPoint& point, uint32_t granularity, uint32_t direction, bool isInteractingWithFocusedElement, CallbackID callbackID)
+void WebPage::selectPositionAtBoundaryWithDirection(const WebCore::IntPoint& point, uint32_t granularity, uint32_t direction, bool isInteractingWithFocusedElement, CompletionHandler<void()>&& completionHandler)
{
auto& frame = m_page->focusController().focusedOrMainFrame();
VisiblePosition position = visiblePositionInFocusedNodeForPoint(frame, point, isInteractingWithFocusedElement);
@@ -2097,10 +2097,10 @@
if (position.isNotNull())
frame.selection().setSelectedRange(Range::create(*frame.document(), position, position).ptr(), UPSTREAM, WebCore::FrameSelection::ShouldCloseTyping::Yes, UserTriggered);
}
- send(Messages::WebPageProxy::VoidCallback(callbackID));
+ completionHandler();
}
-void WebPage::moveSelectionAtBoundaryWithDirection(uint32_t granularity, uint32_t direction, CallbackID callbackID)
+void WebPage::moveSelectionAtBoundaryWithDirection(uint32_t granularity, uint32_t direction, CompletionHandler<void()>&& completionHandler)
{
Frame& frame = m_page->focusController().focusedOrMainFrame();
@@ -2111,7 +2111,7 @@
if (position.isNotNull())
frame.selection().setSelectedRange(Range::create(*frame.document(), position, position).ptr(), isForward? UPSTREAM : DOWNSTREAM, WebCore::FrameSelection::ShouldCloseTyping::Yes, UserTriggered);
}
- send(Messages::WebPageProxy::VoidCallback(callbackID));
+ completionHandler();
}
RefPtr<Range> WebPage::rangeForGranularityAtPoint(Frame& frame, const WebCore::IntPoint& point, uint32_t granularity, bool isInteractingWithFocusedElement)
@@ -2157,7 +2157,7 @@
m_page->focusController().setFocusedFrame(result.innerNodeFrame());
}
-void WebPage::selectTextWithGranularityAtPoint(const WebCore::IntPoint& point, uint32_t granularity, bool isInteractingWithFocusedElement, CallbackID callbackID)
+void WebPage::selectTextWithGranularityAtPoint(const WebCore::IntPoint& point, uint32_t granularity, bool isInteractingWithFocusedElement, CompletionHandler<void()>&& completionHandler)
{
setFocusedFrameBeforeSelectingTextAtLocation(point);
@@ -2166,7 +2166,7 @@
if (range)
frame.selection().setSelectedRange(range.get(), UPSTREAM, WebCore::FrameSelection::ShouldCloseTyping::Yes, UserTriggered);
m_initialSelection = range;
- send(Messages::WebPageProxy::VoidCallback(callbackID));
+ completionHandler();
}
void WebPage::beginSelectionInDirection(uint32_t direction, CallbackID callbackID)
@@ -3068,7 +3068,7 @@
return nextElement;
}
-void WebPage::focusNextFocusedElement(bool isForward, CallbackID callbackID)
+void WebPage::focusNextFocusedElement(bool isForward, CompletionHandler<void()>&& completionHandler)
{
Element* nextElement = nextAssistableElement(m_focusedElement.get(), *m_page, isForward);
m_userIsInteracting = true;
@@ -3075,7 +3075,7 @@
if (nextElement)
nextElement->focus();
m_userIsInteracting = false;
- send(Messages::WebPageProxy::VoidCallback(callbackID));
+ completionHandler();
}
void WebPage::getFocusedElementInformation(FocusedElementInformation& information)