Diff
Modified: trunk/Source/WebKit/ChangeLog (272704 => 272705)
--- trunk/Source/WebKit/ChangeLog 2021-02-11 04:49:47 UTC (rev 272704)
+++ trunk/Source/WebKit/ChangeLog 2021-02-11 05:23:52 UTC (rev 272705)
@@ -1,3 +1,15 @@
+2021-02-10 Ryan Haddad <[email protected]>
+
+ Unreviewed, reverting r272702.
+
+ Caused assertion failure on macOS debug WK2 bots
+
+ Reverted changeset:
+
+ "Stop using GenericCallback from WebPageProxy"
+ https://bugs.webkit.org/show_bug.cgi?id=221653
+ https://trac.webkit.org/changeset/272702
+
2021-02-10 Alex Christensen <[email protected]>
Stop using GenericCallback from WebPageProxy
Modified: trunk/Source/WebKit/UIProcess/API/APIAttachment.cpp (272704 => 272705)
--- trunk/Source/WebKit/UIProcess/API/APIAttachment.cpp 2021-02-11 04:49:47 UTC (rev 272704)
+++ trunk/Source/WebKit/UIProcess/API/APIAttachment.cpp 2021-02-11 05:23:52 UTC (rev 272705)
@@ -49,15 +49,15 @@
{
}
-void Attachment::updateAttributes(CompletionHandler<void()>&& callback)
+void Attachment::updateAttributes(Function<void(WebKit::CallbackBase::Error)>&& callback)
{
if (!m_webPage) {
- callback();
+ callback(WebKit::CallbackBase::Error::OwnerWasInvalidated);
return;
}
if (m_webPage->willUpdateAttachmentAttributes(*this) == WebKit::WebPageProxy::ShouldUpdateAttachmentAttributes::No) {
- callback();
+ callback(WebKit::CallbackBase::Error::None);
return;
}
Modified: trunk/Source/WebKit/UIProcess/API/APIAttachment.h (272704 => 272705)
--- trunk/Source/WebKit/UIProcess/API/APIAttachment.h 2021-02-11 04:49:47 UTC (rev 272704)
+++ trunk/Source/WebKit/UIProcess/API/APIAttachment.h 2021-02-11 05:23:52 UTC (rev 272705)
@@ -55,7 +55,7 @@
enum class InsertionState : uint8_t { NotInserted, Inserted };
const WTF::String& identifier() const { return m_identifier; }
- void updateAttributes(CompletionHandler<void()>&&);
+ void updateAttributes(Function<void(WebKit::CallbackBase::Error)>&&);
void invalidate();
bool isValid() const { return !!m_webPage; }
Modified: trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp (272704 => 272705)
--- trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp 2021-02-11 04:49:47 UTC (rev 272704)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp 2021-02-11 05:23:52 UTC (rev 272705)
@@ -2534,36 +2534,36 @@
}
#endif
-static CompletionHandler<void(const String&)> toStringCallback(void* context, void(*callback)(WKStringRef, WKErrorRef, void*))
+static WTF::Function<void (const String&, WebKit::CallbackBase::Error)> toGenericCallbackFunction(void* context, void (*callback)(WKStringRef, WKErrorRef, void*))
{
- return [context, callback] (const String& returnValue) {
- callback(toAPI(API::String::create(returnValue).ptr()), nullptr, context);
+ return [context, callback](const String& returnValue, WebKit::CallbackBase::Error error) {
+ callback(toAPI(API::String::create(returnValue).ptr()), error != WebKit::CallbackBase::Error::None ? toAPI(API::Error::create().ptr()) : 0, context);
};
}
void WKPageRenderTreeExternalRepresentation(WKPageRef pageRef, void* context, WKPageRenderTreeExternalRepresentationFunction callback)
{
- toImpl(pageRef)->getRenderTreeExternalRepresentation(toStringCallback(context, callback));
+ toImpl(pageRef)->getRenderTreeExternalRepresentation(toGenericCallbackFunction(context, callback));
}
void WKPageGetSourceForFrame(WKPageRef pageRef, WKFrameRef frameRef, void* context, WKPageGetSourceForFrameFunction callback)
{
- toImpl(pageRef)->getSourceForFrame(toImpl(frameRef), toStringCallback(context, callback));
+ toImpl(pageRef)->getSourceForFrame(toImpl(frameRef), toGenericCallbackFunction(context, callback));
}
void WKPageGetContentsAsString(WKPageRef pageRef, void* context, WKPageGetContentsAsStringFunction callback)
{
- toImpl(pageRef)->getContentsAsString(ContentAsStringIncludesChildFrames::No, toStringCallback(context, callback));
+ toImpl(pageRef)->getContentsAsString(ContentAsStringIncludesChildFrames::No, toGenericCallbackFunction(context, callback));
}
void WKPageGetBytecodeProfile(WKPageRef pageRef, void* context, WKPageGetBytecodeProfileFunction callback)
{
- toImpl(pageRef)->getBytecodeProfile(toStringCallback(context, callback));
+ toImpl(pageRef)->getBytecodeProfile(toGenericCallbackFunction(context, callback));
}
void WKPageGetSamplingProfilerOutput(WKPageRef pageRef, void* context, WKPageGetSamplingProfilerOutputFunction callback)
{
- toImpl(pageRef)->getSamplingProfilerOutput(toStringCallback(context, callback));
+ toImpl(pageRef)->getSamplingProfilerOutput(toGenericCallbackFunction(context, callback));
}
void WKPageGetSelectionAsWebArchiveData(WKPageRef pageRef, void* context, WKPageGetSelectionAsWebArchiveDataFunction callback)
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/APIAttachmentCocoa.mm (272704 => 272705)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/APIAttachmentCocoa.mm 2021-02-11 04:49:47 UTC (rev 272704)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/APIAttachmentCocoa.mm 2021-02-11 05:23:52 UTC (rev 272705)
@@ -187,7 +187,7 @@
return;
setFileWrapperAndUpdateContentType(fileWrapper, contentType);
- m_webPage->updateAttachmentAttributes(*this, [] { });
+ m_webPage->updateAttachmentAttributes(*this, [] (auto) { });
}
void Attachment::setFileWrapperGenerator(Function<RetainPtr<NSFileWrapper>(void)>&& fileWrapperGenerator)
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (272704 => 272705)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2021-02-11 04:49:47 UTC (rev 272704)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2021-02-11 05:23:52 UTC (rev 272705)
@@ -2313,9 +2313,9 @@
auto identifier = createCanonicalUUIDString();
auto attachment = API::Attachment::create(identifier, *_page);
attachment->setFileWrapperAndUpdateContentType(fileWrapper, contentType);
- _page->insertAttachment(attachment.copyRef(), [capturedHandler = makeBlockPtr(completionHandler)] {
+ _page->insertAttachment(attachment.copyRef(), [capturedHandler = makeBlockPtr(completionHandler)] (WebKit::CallbackBase::Error error) {
if (capturedHandler)
- capturedHandler(true);
+ capturedHandler(error == WebKit::CallbackBase::Error::None);
});
#if HAVE(QUICKLOOK_THUMBNAILING)
_page->requestThumbnailWithFileWrapper(fileWrapper, identifier);
@@ -2561,15 +2561,25 @@
- (void)_getContentsAsStringWithCompletionHandler:(void (^)(NSString *, NSError *))completionHandler
{
- _page->getContentsAsString(WebKit::ContentAsStringIncludesChildFrames::No, [handler = makeBlockPtr(completionHandler)](String string) {
- handler(string, nil);
+ auto handler = makeBlockPtr(completionHandler);
+
+ _page->getContentsAsString(WebKit::ContentAsStringIncludesChildFrames::No, [handler](String string, WebKit::CallbackBase::Error error) {
+ if (error != WebKit::CallbackBase::Error::None) {
+ // FIXME: Pipe a proper error in from the WebPageProxy.
+ handler(nil, [NSError errorWithDomain:WKErrorDomain code:static_cast<int>(error) userInfo:nil]);
+ } else
+ handler(string, nil);
});
}
- (void)_getContentsOfAllFramesAsStringWithCompletionHandler:(void (^)(NSString *))completionHandler
{
- _page->getContentsAsString(WebKit::ContentAsStringIncludesChildFrames::Yes, [handler = makeBlockPtr(completionHandler)](String string) {
- handler(string);
+ auto handler = makeBlockPtr(completionHandler);
+ _page->getContentsAsString(WebKit::ContentAsStringIncludesChildFrames::Yes, [handler](String string, WebKit::CallbackBase::Error error) {
+ if (error != WebKit::CallbackBase::Error::None)
+ handler(nil);
+ else
+ handler(string);
});
}
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKAttachment.mm (272704 => 272705)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKAttachment.mm 2021-02-11 04:49:47 UTC (rev 272704)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKAttachment.mm 2021-02-11 05:23:52 UTC (rev 272705)
@@ -32,7 +32,6 @@
#import <WebCore/MIMETypeRegistry.h>
#import <WebCore/SharedBuffer.h>
#import <wtf/BlockPtr.h>
-#import <wtf/CompletionHandler.h>
#if PLATFORM(IOS_FAMILY)
#import <MobileCoreServices/MobileCoreServices.h>
@@ -140,9 +139,14 @@
// from the SPI client, the corresponding file path of the data is unknown, if it even exists at all.
_attachment->setFilePath({ });
_attachment->setFileWrapperAndUpdateContentType(fileWrapper, contentType);
- _attachment->updateAttributes([capturedBlock = makeBlockPtr(completionHandler)] {
- if (capturedBlock)
+ _attachment->updateAttributes([capturedBlock = makeBlockPtr(completionHandler)] (auto error) {
+ if (!capturedBlock)
+ return;
+
+ if (error == WebKit::CallbackBase::Error::None)
capturedBlock(nil);
+ else
+ capturedBlock([NSError errorWithDomain:WKErrorDomain code:UnspecifiedAttachmentErrorCode userInfo:nil]);
});
}
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (272704 => 272705)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2021-02-11 04:49:47 UTC (rev 272704)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2021-02-11 05:23:52 UTC (rev 272705)
@@ -3162,7 +3162,9 @@
void WebViewImpl::startSpeaking()
{
ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
- m_page->getSelectionOrContentsAsString([](const String& string) {
+ m_page->getSelectionOrContentsAsString([](const String& string, WebKit::CallbackBase::Error error) {
+ if (error != WebKit::CallbackBase::Error::None)
+ return;
if (!string)
return;
Modified: trunk/Source/WebKit/UIProcess/GenericCallback.h (272704 => 272705)
--- trunk/Source/WebKit/UIProcess/GenericCallback.h 2021-02-11 04:49:47 UTC (rev 272704)
+++ trunk/Source/WebKit/UIProcess/GenericCallback.h 2021-02-11 05:23:52 UTC (rev 272705)
@@ -146,6 +146,14 @@
#endif
};
+template<typename APIReturnValueType, typename InternalReturnValueType = typename APITypeInfo<APIReturnValueType>::ImplType*>
+static typename GenericCallback<InternalReturnValueType>::CallbackFunction toGenericCallbackFunction(void* context, void (*callback)(APIReturnValueType, WKErrorRef, void*))
+{
+ return [context, callback](InternalReturnValueType returnValue, CallbackBase::Error error) {
+ callback(toAPI(returnValue), error != CallbackBase::Error::None ? toAPI(API::Error::create().ptr()) : 0, context);
+ };
+}
+
typedef GenericCallback<> VoidCallback;
template<typename T>
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (272704 => 272705)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-02-11 04:49:47 UTC (rev 272704)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-02-11 05:23:52 UTC (rev 272705)
@@ -2016,13 +2016,11 @@
auto activityStateChangeID = m_activityStateChangeWantsSynchronousReply ? takeNextActivityStateChangeID() : static_cast<ActivityStateChangeID>(ActivityStateChangeAsynchronous);
- if (changed || activityStateChangeID != ActivityStateChangeAsynchronous || !m_nextActivityStateChangeCallbacks.isEmpty()) {
- sendWithAsyncReply(Messages::WebPage::SetActivityState(m_activityState, activityStateChangeID), [callbacks = std::exchange(m_nextActivityStateChangeCallbacks, { })] () mutable {
- for (auto& callback : callbacks)
- callback();
- });
- }
+ if (changed || activityStateChangeID != ActivityStateChangeAsynchronous || !m_nextActivityStateChangeCallbacks.isEmpty())
+ send(Messages::WebPage::SetActivityState(m_activityState, activityStateChangeID, m_nextActivityStateChangeCallbacks));
+ m_nextActivityStateChangeCallbacks.clear();
+
// This must happen after the SetActivityState message is sent, to ensure the page visibility event can fire.
updateThrottleState();
@@ -4079,19 +4077,39 @@
});
}
-void WebPageProxy::getRenderTreeExternalRepresentation(CompletionHandler<void(const String&)>&& callback)
+void WebPageProxy::getRenderTreeExternalRepresentation(WTF::Function<void (const String&, CallbackBase::Error)>&& callbackFunction)
{
- sendWithAsyncReply(Messages::WebPage::GetRenderTreeExternalRepresentation(), WTFMove(callback));
+ if (!hasRunningProcess()) {
+ callbackFunction(String(), CallbackBase::Error::Unknown);
+ return;
+ }
+
+ auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::getRenderTreeExternalRepresentation"_s));
+ send(Messages::WebPage::GetRenderTreeExternalRepresentation(callbackID));
}
-void WebPageProxy::getSourceForFrame(WebFrameProxy* frame, CompletionHandler<void(const String&)>&& callback)
+void WebPageProxy::getSourceForFrame(WebFrameProxy* frame, WTF::Function<void (const String&, CallbackBase::Error)>&& callbackFunction)
{
- sendWithAsyncReply(Messages::WebPage::GetSourceForFrame(frame->frameID()), WTFMove(callback));
+ if (!hasRunningProcess()) {
+ callbackFunction(String(), CallbackBase::Error::Unknown);
+ return;
+ }
+
+ auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::getSourceForFrame"_s));
+ m_loadDependentStringCallbackIDs.add(callbackID);
+ send(Messages::WebPage::GetSourceForFrame(frame->frameID(), callbackID));
}
-void WebPageProxy::getContentsAsString(ContentAsStringIncludesChildFrames includesChildFrames, CompletionHandler<void(const String&)>&& callback)
+void WebPageProxy::getContentsAsString(ContentAsStringIncludesChildFrames includesChildFrames, WTF::Function<void(const String&, CallbackBase::Error)>&& callbackFunction)
{
- sendWithAsyncReply(Messages::WebPage::GetContentsAsString(includesChildFrames), WTFMove(callback));
+ if (!hasRunningProcess()) {
+ callbackFunction(String(), CallbackBase::Error::Unknown);
+ return;
+ }
+
+ auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::getContentsAsString"_s));
+ m_loadDependentStringCallbackIDs.add(callbackID);
+ send(Messages::WebPage::GetContentsAsString(includesChildFrames, callbackID));
}
#if PLATFORM(COCOA)
@@ -4111,14 +4129,28 @@
sendWithAsyncReply(Messages::WebPage::GetAllFrames(), WTFMove(completionHandler));
}
-void WebPageProxy::getBytecodeProfile(CompletionHandler<void(const String&)>&& callback)
+void WebPageProxy::getBytecodeProfile(WTF::Function<void (const String&, CallbackBase::Error)>&& callbackFunction)
{
- sendWithAsyncReply(Messages::WebPage::GetBytecodeProfile(), WTFMove(callback));
+ if (!hasRunningProcess()) {
+ callbackFunction(String(), CallbackBase::Error::Unknown);
+ return;
+ }
+
+ auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::getBytecodeProfile"_s));
+ m_loadDependentStringCallbackIDs.add(callbackID);
+ send(Messages::WebPage::GetBytecodeProfile(callbackID));
}
-void WebPageProxy::getSamplingProfilerOutput(CompletionHandler<void(const String&)>&& callback)
+void WebPageProxy::getSamplingProfilerOutput(WTF::Function<void (const String&, CallbackBase::Error)>&& callbackFunction)
{
- sendWithAsyncReply(Messages::WebPage::GetSamplingProfilerOutput(), WTFMove(callback));
+ if (!hasRunningProcess()) {
+ callbackFunction(String(), CallbackBase::Error::Unknown);
+ return;
+ }
+
+ auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::getSamplingProfilerOutput"_s));
+ m_loadDependentStringCallbackIDs.add(callbackID);
+ send(Messages::WebPage::GetSamplingProfilerOutput(callbackID));
}
static CompletionHandler<void(const IPC::DataReference& data)> toAPIDataCallback(CompletionHandler<void(API::Data*)>&& callback)
@@ -4135,9 +4167,15 @@
}
#endif
-void WebPageProxy::getSelectionOrContentsAsString(CompletionHandler<void(const String&)>&& callback)
+void WebPageProxy::getSelectionOrContentsAsString(WTF::Function<void (const String&, CallbackBase::Error)>&& callbackFunction)
{
- sendWithAsyncReply(Messages::WebPage::GetSelectionOrContentsAsString(), callback);
+ if (!hasRunningProcess()) {
+ callbackFunction(String(), CallbackBase::Error::Unknown);
+ return;
+ }
+
+ auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::getSelectionOrContentsAsString"_s));
+ send(Messages::WebPage::GetSelectionOrContentsAsString(callbackID));
}
void WebPageProxy::getSelectionAsWebArchiveData(CompletionHandler<void(API::Data*)>&& callback)
@@ -4542,6 +4580,15 @@
m_provisionalPage = nullptr;
}
+void WebPageProxy::clearLoadDependentCallbacks()
+{
+ HashSet<CallbackID> loadDependentStringCallbackIDs = WTFMove(m_loadDependentStringCallbackIDs);
+ for (auto& callbackID : loadDependentStringCallbackIDs) {
+ if (auto callback = m_callbacks.take<StringCallback>(callbackID))
+ callback->invalidate();
+ }
+}
+
#if ENABLE(RESOURCE_LOAD_STATISTICS)
static OptionSet<CrossSiteNavigationDataTransfer::Flag> checkIfNavigationContainsDataTransfer(const SecurityOriginData requesterOrigin, const ResourceRequest& currentRequest)
{
@@ -4616,6 +4663,8 @@
pageClient().resetSecureInputState();
#endif
+ clearLoadDependentCallbacks();
+
frame->didCommitLoad(mimeType, webCertificateInfo, containsPluginDocument);
if (frame->isMainFrame()) {
@@ -4778,6 +4827,8 @@
if (frame->isMainFrame() && navigationID)
navigation = navigationState().navigation(navigationID);
+ clearLoadDependentCallbacks();
+
auto transaction = m_pageLoadState.transaction();
bool isMainFrame = frame->isMainFrame();
@@ -7063,6 +7114,45 @@
}
}
+void WebPageProxy::voidCallback(CallbackID callbackID)
+{
+ auto callback = m_callbacks.take<VoidCallback>(callbackID);
+ if (!callback) {
+ // FIXME: Log error or assert.
+ return;
+ }
+
+ callback->performCallback();
+}
+
+void WebPageProxy::stringCallback(const String& resultString, CallbackID callbackID)
+{
+ auto callback = m_callbacks.take<StringCallback>(callbackID);
+ if (!callback) {
+ // FIXME: Log error or assert.
+ // this can validly happen if a load invalidated the callback, though
+ return;
+ }
+
+ m_loadDependentStringCallbackIDs.remove(callbackID);
+
+ callback->performCallbackWithReturnValue(resultString.impl());
+}
+
+void WebPageProxy::invalidateStringCallback(CallbackID callbackID)
+{
+ auto callback = m_callbacks.take<StringCallback>(callbackID);
+ if (!callback) {
+ // FIXME: Log error or assert.
+ // this can validly happen if a load invalidated the callback, though
+ return;
+ }
+
+ m_loadDependentStringCallbackIDs.remove(callbackID);
+
+ callback->invalidate();
+}
+
void WebPageProxy::editorStateChanged(const EditorState& editorState)
{
updateEditorState(editorState);
@@ -7466,6 +7556,9 @@
break;
}
+ m_callbacks.invalidate(error);
+ m_loadDependentStringCallbackIDs.clear();
+
for (auto& editCommand : std::exchange(m_editCommandSet, { }))
editCommand->invalidate();
@@ -9140,7 +9233,7 @@
#endif
-void WebPageProxy::installActivityStateChangeCompletionHandler(CompletionHandler<void()>&& completionHandler)
+void WebPageProxy::installActivityStateChangeCompletionHandler(Function<void()>&& completionHandler)
{
if (!hasRunningProcess()) {
completionHandler();
@@ -9147,7 +9240,11 @@
return;
}
- m_nextActivityStateChangeCallbacks.append(WTFMove(completionHandler));
+ auto voidCallback = VoidCallback::create([completionHandler = WTFMove(completionHandler)] (auto) {
+ completionHandler();
+ }, m_process->throttler().backgroundActivity("WebPageProxy::installActivityStateChangeCompletionHandler"_s));
+ auto callbackID = m_callbacks.put(WTFMove(voidCallback));
+ m_nextActivityStateChangeCallbacks.append(callbackID);
}
void WebPageProxy::imageOrMediaDocumentSizeChanged(const WebCore::IntSize& newSize)
@@ -9521,20 +9618,32 @@
return m_attachmentIdentifierToAttachmentMap.get(identifier);
}
-void WebPageProxy::insertAttachment(Ref<API::Attachment>&& attachment, CompletionHandler<void()>&& callback)
+void WebPageProxy::insertAttachment(Ref<API::Attachment>&& attachment, Function<void(CallbackBase::Error)>&& callback)
{
+ if (!hasRunningProcess()) {
+ callback(CallbackBase::Error::OwnerWasInvalidated);
+ return;
+ }
+
auto attachmentIdentifier = attachment->identifier();
- sendWithAsyncReply(Messages::WebPage::InsertAttachment(attachmentIdentifier, attachment->fileSizeForDisplay(), attachment->fileName(), attachment->contentType()), WTFMove(callback));
+ auto callbackID = m_callbacks.put(WTFMove(callback), m_process->throttler().backgroundActivity("WebPageProxy::insertAttachment"_s));
+ send(Messages::WebPage::InsertAttachment(attachmentIdentifier, attachment->fileSizeForDisplay(), attachment->fileName(), attachment->contentType(), callbackID));
m_attachmentIdentifierToAttachmentMap.set(attachmentIdentifier, WTFMove(attachment));
}
-void WebPageProxy::updateAttachmentAttributes(const API::Attachment& attachment, CompletionHandler<void()>&& callback)
+void WebPageProxy::updateAttachmentAttributes(const API::Attachment& attachment, Function<void(CallbackBase::Error)>&& callback)
{
+ if (!hasRunningProcess()) {
+ callback(CallbackBase::Error::OwnerWasInvalidated);
+ return;
+ }
+
IPC::SharedBufferDataReference dataReference;
if (auto data = ""
dataReference = { *data };
- sendWithAsyncReply(Messages::WebPage::UpdateAttachmentAttributes(attachment.identifier(), attachment.fileSizeForDisplay(), attachment.contentType(), attachment.fileName(), WTFMove(dataReference)), WTFMove(callback));
+ auto callbackID = m_callbacks.put(WTFMove(callback), m_process->throttler().backgroundActivity("WebPageProxy::updateAttachmentAttributes"_s));
+ send(Messages::WebPage::UpdateAttachmentAttributes(attachment.identifier(), attachment.fileSizeForDisplay(), attachment.contentType(), attachment.fileName(), WTFMove(dataReference), callbackID));
}
#if HAVE(QUICKLOOK_THUMBNAILING)
@@ -9690,7 +9799,7 @@
pageClient().didInsertAttachment(attachment.get(), source);
if (!attachment->isEmpty() && hasEnclosingImage)
- updateAttachmentAttributes(attachment.get(), [] { });
+ updateAttachmentAttributes(attachment.get(), [] (auto) { });
}
void WebPageProxy::didRemoveAttachmentWithIdentifier(const String& identifier)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (272704 => 272705)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2021-02-11 04:49:47 UTC (rev 272704)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2021-02-11 05:23:52 UTC (rev 272705)
@@ -380,6 +380,8 @@
enum class UndoOrRedo : bool;
enum class WebContentMode : uint8_t;
+typedef GenericCallback<const String&> StringCallback;
+
#if HAVE(VISIBILITY_PROPAGATION_VIEW)
using LayerHostingContextID = uint32_t;
#endif
@@ -762,7 +764,7 @@
void updateSelectionWithExtentPoint(const WebCore::IntPoint, bool isInteractingWithFocusedElement, RespectSelectionAnchor, CompletionHandler<void(bool)>&&);
void updateSelectionWithExtentPointAndBoundary(const WebCore::IntPoint, WebCore::TextGranularity, bool isInteractingWithFocusedElement, CompletionHandler<void(bool)>&&);
void requestAutocorrectionData(const String& textForAutocorrection, CompletionHandler<void(WebAutocorrectionData)>&&);
- void applyAutocorrection(const String& correction, const String& originalText, CompletionHandler<void(const String&)>&&);
+ void applyAutocorrection(const String& correction, const String& originalText, WTF::Function<void (const String&, CallbackBase::Error)>&&);
bool applyAutocorrection(const String& correction, const String& originalText);
void requestAutocorrectionContext();
void handleAutocorrectionContext(const WebAutocorrectionContext&);
@@ -1112,12 +1114,12 @@
void didFailToFindString(const String&);
void didFindStringMatches(const String&, const Vector<Vector<WebCore::IntRect>>& matchRects, int32_t firstIndexAfterSelection);
- void getContentsAsString(ContentAsStringIncludesChildFrames, CompletionHandler<void(const String&)>&&);
+ void getContentsAsString(ContentAsStringIncludesChildFrames, WTF::Function<void(const String&, CallbackBase::Error)>&&);
#if PLATFORM(COCOA)
void getContentsAsAttributedString(CompletionHandler<void(const WebCore::AttributedString&)>&&);
#endif
- void getBytecodeProfile(CompletionHandler<void(const String&)>&&);
- void getSamplingProfilerOutput(CompletionHandler<void(const String&)>&&);
+ void getBytecodeProfile(WTF::Function<void (const String&, CallbackBase::Error)>&&);
+ void getSamplingProfilerOutput(WTF::Function<void (const String&, CallbackBase::Error)>&&);
#if ENABLE(MHTML)
void getContentsAsMHTMLData(CompletionHandler<void(API::Data*)>&&);
@@ -1124,10 +1126,10 @@
#endif
void getMainResourceDataOfFrame(WebFrameProxy*, CompletionHandler<void(API::Data*)>&&);
void getResourceDataFromFrame(WebFrameProxy&, API::URL*, CompletionHandler<void(API::Data*)>&&);
- void getRenderTreeExternalRepresentation(CompletionHandler<void(const String&)>&&);
- void getSelectionOrContentsAsString(CompletionHandler<void(const String&)>&&);
+ void getRenderTreeExternalRepresentation(WTF::Function<void (const String&, CallbackBase::Error)>&&);
+ void getSelectionOrContentsAsString(WTF::Function<void (const String&, CallbackBase::Error)>&&);
void getSelectionAsWebArchiveData(CompletionHandler<void(API::Data*)>&&);
- void getSourceForFrame(WebFrameProxy*, CompletionHandler<void(const String&)>&&);
+ void getSourceForFrame(WebFrameProxy*, WTF::Function<void (const String&, CallbackBase::Error)>&&);
void getWebArchiveOfFrame(WebFrameProxy*, CompletionHandler<void(API::Data*)>&&);
void runJavaScriptInMainFrame(WebCore::RunJavaScriptParameters&&, CompletionHandler<void(Expected<RefPtr<API::SerializedScriptValue>, WebCore::ExceptionDetails>&&)>&&);
void runJavaScriptInFrameInScriptWorld(WebCore::RunJavaScriptParameters&&, Optional<WebCore::FrameIdentifier>, API::ContentWorld&, CompletionHandler<void(Expected<RefPtr<API::SerializedScriptValue>, WebCore::ExceptionDetails>&&)>&&);
@@ -1475,7 +1477,7 @@
bool scrollingUpdatesDisabledForTesting();
- void installActivityStateChangeCompletionHandler(CompletionHandler<void()>&&);
+ void installActivityStateChangeCompletionHandler(Function<void()>&&);
#if USE(UNIFIED_TEXT_CHECKING)
void checkTextOfParagraph(const String& text, OptionSet<WebCore::TextCheckingType> checkingTypes, int32_t insertionPoint, CompletionHandler<void(Vector<WebCore::TextCheckingResult>&&)>&&);
@@ -1613,8 +1615,8 @@
#if ENABLE(ATTACHMENT_ELEMENT)
RefPtr<API::Attachment> attachmentForIdentifier(const String& identifier) const;
- void insertAttachment(Ref<API::Attachment>&&, CompletionHandler<void()>&&);
- void updateAttachmentAttributes(const API::Attachment&, CompletionHandler<void()>&&);
+ void insertAttachment(Ref<API::Attachment>&&, Function<void(CallbackBase::Error)>&&);
+ void updateAttachmentAttributes(const API::Attachment&, Function<void(CallbackBase::Error)>&&);
void serializedAttachmentDataForIdentifiers(const Vector<String>&, CompletionHandler<void(Vector<WebCore::SerializedAttachmentData>&&)>&&);
void registerAttachmentIdentifier(const String&);
void didInvalidateDataForAttachment(API::Attachment&);
@@ -2151,6 +2153,10 @@
void discardQueuedMouseEvents();
void didReceiveEvent(uint32_t opaqueType, bool handled);
+
+ void voidCallback(CallbackID);
+ void stringCallback(const String&, CallbackID);
+ void invalidateStringCallback(CallbackID);
#if PLATFORM(MAC)
void didUpdateRenderingAfterCommittingLoad();
void fontAtSelectionCallback(const FontInfo&, double, bool, CallbackID);
@@ -2227,6 +2233,8 @@
RetainPtr<NSArray> m_dataDetectionResults;
#endif
+ void clearLoadDependentCallbacks();
+
void performDragControllerAction(DragControllerAction, WebCore::DragData&, const String& dragStorageName, SandboxExtension::Handle&&, SandboxExtension::HandleArray&&);
void updateBackingStoreDiscardableState();
@@ -2476,6 +2484,9 @@
std::unique_ptr<WebAuthenticatorCoordinatorProxy> m_credentialsMessenger;
#endif
+ CallbackMap m_callbacks;
+ HashSet<CallbackID> m_loadDependentStringCallbackIDs;
+
HashSet<WebEditCommandProxy*> m_editCommandSet;
#if PLATFORM(COCOA)
@@ -2753,7 +2764,7 @@
OptionSet<WebCore::ActivityState::Flag> m_potentiallyChangedActivityStateFlags;
bool m_activityStateChangeWantsSynchronousReply { false };
- Vector<CompletionHandler<void()>> m_nextActivityStateChangeCallbacks;
+ Vector<CallbackID> m_nextActivityStateChangeCallbacks;
WebCore::MediaProducer::MediaStateFlags m_mediaState { WebCore::MediaProducer::IsNotPlaying };
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (272704 => 272705)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2021-02-11 04:49:47 UTC (rev 272704)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2021-02-11 05:23:52 UTC (rev 272705)
@@ -162,6 +162,10 @@
# Forms messages
WillSubmitForm(WebCore::FrameIdentifier frameID, WebCore::FrameIdentifier sourceFrameID, Vector<std::pair<String, String>> textFieldValues, uint64_t listenerID, WebKit::UserData userData)
+ # Callback messages
+ VoidCallback(WebKit::CallbackID callbackID)
+ StringCallback(String resultString, WebKit::CallbackID callbackID)
+ InvalidateStringCallback(WebKit::CallbackID callbackID)
#if PLATFORM(IOS_FAMILY)
InterpretKeyEvent(struct WebKit::EditorState state, bool isCharEvent) -> (bool handled) Synchronous
DidReceivePositionInformation(struct WebKit::InteractionInformationAtPosition information)
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (272704 => 272705)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2021-02-11 04:49:47 UTC (rev 272704)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2021-02-11 05:23:52 UTC (rev 272705)
@@ -3226,7 +3226,10 @@
- (void)_shareForWebView:(id)sender
{
RetainPtr<WKContentView> view = self;
- _page->getSelectionOrContentsAsString([view](const String& string) {
+ _page->getSelectionOrContentsAsString([view](const String& string, WebKit::CallbackBase::Error error) {
+ if (error != WebKit::CallbackBase::Error::None)
+ return;
+
if (!view->_textInteractionAssistant || !string || view->_page->editorState().isMissingPostLayoutData)
return;
@@ -3802,7 +3805,9 @@
#endif
RetainPtr<WKContentView> view = self;
- _page->getSelectionOrContentsAsString([view](const String& string) {
+ _page->getSelectionOrContentsAsString([view](const String& string, WebKit::CallbackBase::Error error) {
+ if (error != WebKit::CallbackBase::Error::None)
+ return;
if (!string)
return;
@@ -3814,7 +3819,9 @@
{
RetainPtr<WKContentView> view = self;
RetainPtr<WKWebView> webView = _webView.get();
- _page->getSelectionOrContentsAsString([view, webView](const String& string) {
+ _page->getSelectionOrContentsAsString([view, webView](const String& string, WebKit::CallbackBase::Error error) {
+ if (error != WebKit::CallbackBase::Error::None)
+ return;
[webView _accessibilityDidGetSpeakSelectionContent:string];
if ([view respondsToSelector:@selector(accessibilitySpeakSelectionSetContent:)])
[view accessibilitySpeakSelectionSetContent:string];
@@ -4380,7 +4387,7 @@
return;
}
- _page->applyAutocorrection(correction, input, [view = retainPtr(self), completion = makeBlockPtr(completionHandler)](auto& string) {
+ _page->applyAutocorrection(correction, input, [view = retainPtr(self), completion = makeBlockPtr(completionHandler)](auto& string, auto error) {
if (completion)
completion(!string.isNull() ? [WKAutocorrectionRects autocorrectionRectsWithFirstCGRect:view->_autocorrectionData.textFirstRect lastCGRect:view->_autocorrectionData.textLastRect] : nil);
});
Modified: trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm (272704 => 272705)
--- trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm 2021-02-11 04:49:47 UTC (rev 272704)
+++ trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm 2021-02-11 05:23:52 UTC (rev 272705)
@@ -430,9 +430,15 @@
sendWithAsyncReply(Messages::WebPage::RequestAutocorrectionData(textForAutocorrection), WTFMove(callback));
}
-void WebPageProxy::applyAutocorrection(const String& correction, const String& originalText, CompletionHandler<void(const String&)>&& callback)
+void WebPageProxy::applyAutocorrection(const String& correction, const String& originalText, WTF::Function<void (const String&, CallbackBase::Error)>&& callbackFunction)
{
- sendWithAsyncReply(Messages::WebPage::ApplyAutocorrection(correction, originalText), WTFMove(callback));
+ if (!hasRunningProcess()) {
+ callbackFunction(String(), CallbackBase::Error::Unknown);
+ return;
+ }
+
+ auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::applyAutocorrection"_s));
+ m_process->send(Messages::WebPage::ApplyAutocorrection(correction, originalText, callbackID), m_webPageID);
}
bool WebPageProxy::applyAutocorrection(const String& correction, const String& originalText)
Modified: trunk/Source/WebKit/UIProcess/mac/WKTextFinderClient.mm (272704 => 272705)
--- trunk/Source/WebKit/UIProcess/mac/WKTextFinderClient.mm 2021-02-11 04:49:47 UTC (rev 272704)
+++ trunk/Source/WebKit/UIProcess/mac/WKTextFinderClient.mm 2021-02-11 05:23:52 UTC (rev 272705)
@@ -243,7 +243,7 @@
{
void (^copiedCompletionHandler)(NSString *) = Block_copy(completionHandler);
- _page->getSelectionOrContentsAsString([copiedCompletionHandler] (const String& string) {
+ _page->getSelectionOrContentsAsString([copiedCompletionHandler] (const String& string, WebKit::CallbackBase::Error) {
copiedCompletionHandler(string);
Block_release(copiedCompletionHandler);
});
Modified: trunk/Source/WebKit/WebProcess/Notifications/NotificationPermissionRequestManager.h (272704 => 272705)
--- trunk/Source/WebKit/WebProcess/Notifications/NotificationPermissionRequestManager.h 2021-02-11 04:49:47 UTC (rev 272704)
+++ trunk/Source/WebKit/WebProcess/Notifications/NotificationPermissionRequestManager.h 2021-02-11 05:23:52 UTC (rev 272705)
@@ -29,6 +29,7 @@
#include <WebCore/NotificationClient.h>
#include <WebCore/NotificationPermissionCallback.h>
#include <WebCore/SecurityOriginHash.h>
+#include <WebCore/VoidCallback.h>
#include <wtf/HashMap.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebNotificationClient.h (272704 => 272705)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebNotificationClient.h 2021-02-11 04:49:47 UTC (rev 272704)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebNotificationClient.h 2021-02-11 05:23:52 UTC (rev 272705)
@@ -33,6 +33,7 @@
namespace WebCore {
class NotificationPermissionCallback;
class ScriptExecutionContext;
+class VoidCallback;
} // namespace WebCore
namespace WebKit {
Modified: trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp (272704 => 272705)
--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp 2021-02-11 04:49:47 UTC (rev 272704)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp 2021-02-11 05:23:52 UTC (rev 272705)
@@ -385,7 +385,7 @@
return m_layerTreeHost->createDisplayRefreshMonitor(displayID);
}
-void DrawingAreaCoordinatedGraphics::activityStateDidChange(OptionSet<ActivityState::Flag> changed, ActivityStateChangeID, CompletionHandler<void()>&& completionHandler)
+void DrawingAreaCoordinatedGraphics::activityStateDidChange(OptionSet<ActivityState::Flag> changed, ActivityStateChangeID, const Vector<CallbackID>&)
{
if (changed & ActivityState::IsVisible) {
if (m_webPage.isVisible())
@@ -393,7 +393,6 @@
else
suspendPainting();
}
- completionHandler();
}
void DrawingAreaCoordinatedGraphics::attachViewOverlayGraphicsLayer(GraphicsLayer* viewOverlayRootLayer)
Modified: trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h (272704 => 272705)
--- trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h 2021-02-11 04:49:47 UTC (rev 272704)
+++ trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h 2021-02-11 05:23:52 UTC (rev 272705)
@@ -77,7 +77,7 @@
RefPtr<WebCore::DisplayRefreshMonitor> createDisplayRefreshMonitor(WebCore::PlatformDisplayID) override;
- void activityStateDidChange(OptionSet<WebCore::ActivityState::Flag>, ActivityStateChangeID, CompletionHandler<void()>&&) override;
+ void activityStateDidChange(OptionSet<WebCore::ActivityState::Flag>, ActivityStateChangeID, const Vector<CallbackID>& /* callbackIDs */) override;
void attachViewOverlayGraphicsLayer(WebCore::GraphicsLayer*) override;
// IPC message handlers.
Modified: trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.h (272704 => 272705)
--- trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.h 2021-02-11 04:49:47 UTC (rev 272704)
+++ trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.h 2021-02-11 05:23:52 UTC (rev 272705)
@@ -121,7 +121,7 @@
virtual void dispatchAfterEnsuringUpdatedScrollPosition(WTF::Function<void ()>&&);
- virtual void activityStateDidChange(OptionSet<WebCore::ActivityState::Flag>, ActivityStateChangeID, CompletionHandler<void()>&& completionHandler) { completionHandler(); };
+ virtual void activityStateDidChange(OptionSet<WebCore::ActivityState::Flag>, ActivityStateChangeID, const Vector<CallbackID>&) { }
virtual void setLayerHostingMode(LayerHostingMode) { }
virtual bool markLayersVolatileImmediatelyIfPossible() { return true; }
Modified: trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h (272704 => 272705)
--- trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h 2021-02-11 04:49:47 UTC (rev 272704)
+++ trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.h 2021-02-11 05:23:52 UTC (rev 272705)
@@ -106,7 +106,7 @@
void mainFrameContentSizeChanged(const WebCore::IntSize&) override;
- void activityStateDidChange(OptionSet<WebCore::ActivityState::Flag> changed, ActivityStateChangeID, CompletionHandler<void()>&&) override;
+ void activityStateDidChange(OptionSet<WebCore::ActivityState::Flag> changed, ActivityStateChangeID, const Vector<CallbackID>& callbackIDs) override;
bool addMilestonesToDispatch(OptionSet<WebCore::LayoutMilestone>) override;
Modified: trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm (272704 => 272705)
--- trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm 2021-02-11 04:49:47 UTC (rev 272704)
+++ trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm 2021-02-11 05:23:52 UTC (rev 272705)
@@ -483,7 +483,7 @@
m_connection->sendMessage(WTFMove(m_commitEncoder), { });
}
-void RemoteLayerTreeDrawingArea::activityStateDidChange(OptionSet<WebCore::ActivityState::Flag>, ActivityStateChangeID activityStateChangeID, CompletionHandler<void()>&& callback)
+void RemoteLayerTreeDrawingArea::activityStateDidChange(OptionSet<WebCore::ActivityState::Flag>, ActivityStateChangeID activityStateChangeID, const Vector<CallbackID>& callbackIDs)
{
// FIXME: Should we suspend painting while not visible, like TiledCoreAnimationDrawingArea? Probably.
@@ -495,7 +495,8 @@
// FIXME: We may want to match behavior in TiledCoreAnimationDrawingArea by firing these callbacks after the next compositing flush, rather than immediately after
// handling an activity state change.
- callback();
+ for (auto& callbackID : callbackIDs)
+ m_webPage.send(Messages::WebPageProxy::VoidCallback(callbackID));
}
void RemoteLayerTreeDrawingArea::addTransactionCallbackID(CallbackID callbackID)
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (272704 => 272705)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2021-02-11 04:49:47 UTC (rev 272704)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2021-02-11 05:23:52 UTC (rev 272705)
@@ -923,7 +923,7 @@
setSizeToContentAutoSizeMaximumSize(parameters.sizeToContentAutoSizeMaximumSize);
if (m_activityState != parameters.activityState)
- setActivityState(parameters.activityState, ActivityStateChangeAsynchronous, [] { });
+ setActivityState(parameters.activityState, ActivityStateChangeAsynchronous, Vector<CallbackID>());
if (m_layerHostingMode != parameters.layerHostingMode)
setLayerHostingMode(parameters.layerHostingMode);
@@ -3362,7 +3362,7 @@
}
}
-void WebPage::setActivityState(OptionSet<ActivityState::Flag> activityState, ActivityStateChangeID activityStateChangeID, CompletionHandler<void()>&& callback)
+void WebPage::setActivityState(OptionSet<ActivityState::Flag> activityState, ActivityStateChangeID activityStateChangeID, const Vector<CallbackID>& callbackIDs)
{
LOG_WITH_STREAM(ActivityState, stream << "WebPage " << identifier().toUInt64() << " setActivityState to " << activityState);
@@ -3381,7 +3381,7 @@
for (auto* pluginView : m_pluginViews)
pluginView->activityStateDidChange(changed);
- m_drawingArea->activityStateDidChange(changed, activityStateChangeID, WTFMove(callback));
+ m_drawingArea->activityStateDidChange(changed, activityStateChangeID, callbackIDs);
WebProcess::singleton().pageActivityStateDidChange(m_identifier, changed);
if (changed & ActivityState::IsInWindow)
@@ -3608,12 +3608,12 @@
runJavaScript(webFrame, WTFMove(parameters), worldData.first, WTFMove(completionHandler));
}
-void WebPage::getContentsAsString(ContentAsStringIncludesChildFrames includeChildFrames, CompletionHandler<void(const String&)>&& callback)
+void WebPage::getContentsAsString(ContentAsStringIncludesChildFrames includeChildFrames, CallbackID callbackID)
{
switch (includeChildFrames) {
case ContentAsStringIncludesChildFrames::No: {
String resultString = m_mainFrame->contentsAsString();
- callback(resultString);
+ send(Messages::WebPageProxy::StringCallback(resultString, callbackID));
break;
}
case ContentAsStringIncludesChildFrames::Yes: {
@@ -3627,7 +3627,7 @@
}
}
- callback(builder.toString());
+ send(Messages::WebPageProxy::StringCallback(builder.toString(), callbackID));
break;
}
}
@@ -3640,9 +3640,10 @@
}
#endif
-void WebPage::getRenderTreeExternalRepresentation(CompletionHandler<void(const String&)>&& callback)
+void WebPage::getRenderTreeExternalRepresentation(CallbackID callbackID)
{
- callback(renderTreeExternalRepresentation());
+ String resultString = renderTreeExternalRepresentation();
+ send(Messages::WebPageProxy::StringCallback(resultString, callbackID));
}
static Frame* frameWithSelection(Page* page)
@@ -3671,22 +3672,22 @@
callback(dataReference);
}
-void WebPage::getSelectionOrContentsAsString(CompletionHandler<void(const String&)>&& callback)
+void WebPage::getSelectionOrContentsAsString(CallbackID callbackID)
{
WebFrame* focusedOrMainFrame = WebFrame::fromCoreFrame(m_page->focusController().focusedOrMainFrame());
String resultString = focusedOrMainFrame->selectionAsString();
if (resultString.isEmpty())
resultString = focusedOrMainFrame->contentsAsString();
- callback(resultString);
+ send(Messages::WebPageProxy::StringCallback(resultString, callbackID));
}
-void WebPage::getSourceForFrame(FrameIdentifier frameID, CompletionHandler<void(const String&)>&& callback)
+void WebPage::getSourceForFrame(FrameIdentifier frameID, CallbackID callbackID)
{
String resultString;
if (WebFrame* frame = WebProcess::singleton().webFrame(frameID))
resultString = frame->source();
- callback(resultString);
+ send(Messages::WebPageProxy::StringCallback(resultString, callbackID));
}
void WebPage::getMainResourceDataOfFrame(FrameIdentifier frameID, CompletionHandler<void(const IPC::SharedBufferDataReference&)>&& callback)
@@ -6437,29 +6438,33 @@
}
}
-void WebPage::getBytecodeProfile(CompletionHandler<void(const String&)>&& callback)
+void WebPage::getBytecodeProfile(CallbackID callbackID)
{
- if (LIKELY(!commonVM().m_perBytecodeProfiler))
- return callback({ });
+ if (LIKELY(!commonVM().m_perBytecodeProfiler)) {
+ send(Messages::WebPageProxy::StringCallback(String(), callbackID));
+ return;
+ }
String result = commonVM().m_perBytecodeProfiler->toJSON();
ASSERT(result.length());
- callback(result);
+ send(Messages::WebPageProxy::StringCallback(result, callbackID));
}
-void WebPage::getSamplingProfilerOutput(CompletionHandler<void(const String&)>&& callback)
+void WebPage::getSamplingProfilerOutput(CallbackID callbackID)
{
#if ENABLE(SAMPLING_PROFILER)
SamplingProfiler* samplingProfiler = commonVM().samplingProfiler();
- if (!samplingProfiler)
- return callback({ });
+ if (!samplingProfiler) {
+ send(Messages::WebPageProxy::InvalidateStringCallback(callbackID));
+ return;
+ }
StringPrintStream result;
samplingProfiler->reportTopFunctions(result);
samplingProfiler->reportTopBytecodes(result);
- callback(result.toString());
+ send(Messages::WebPageProxy::StringCallback(result.toString(), callbackID));
#else
- callback({ });
+ send(Messages::WebPageProxy::InvalidateStringCallback(callbackID));
#endif
}
@@ -6905,14 +6910,14 @@
#if ENABLE(ATTACHMENT_ELEMENT)
-void WebPage::insertAttachment(const String& identifier, Optional<uint64_t>&& fileSize, const String& fileName, const String& contentType, CompletionHandler<void()>&& callback)
+void WebPage::insertAttachment(const String& identifier, Optional<uint64_t>&& fileSize, const String& fileName, const String& contentType, CallbackID callbackID)
{
auto& frame = m_page->focusController().focusedOrMainFrame();
frame.editor().insertAttachment(identifier, WTFMove(fileSize), fileName, contentType);
- callback();
+ send(Messages::WebPageProxy::VoidCallback(callbackID));
}
-void WebPage::updateAttachmentAttributes(const String& identifier, Optional<uint64_t>&& fileSize, const String& contentType, const String& fileName, const IPC::DataReference& enclosingImageData, CompletionHandler<void()>&& callback)
+void WebPage::updateAttachmentAttributes(const String& identifier, Optional<uint64_t>&& fileSize, const String& contentType, const String& fileName, const IPC::DataReference& enclosingImageData, CallbackID callbackID)
{
if (auto attachment = attachmentElementWithIdentifier(identifier)) {
attachment->document().updateLayout();
@@ -6919,7 +6924,7 @@
attachment->updateAttributes(WTFMove(fileSize), contentType, fileName);
attachment->updateEnclosingImageWithData(contentType, SharedBuffer::create(enclosingImageData.data(), enclosingImageData.size()));
}
- callback();
+ send(Messages::WebPageProxy::VoidCallback(callbackID));
}
void WebPage::updateAttachmentIcon(const String& identifier, const ShareableBitmap::Handle& qlThumbnailHandle)
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (272704 => 272705)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2021-02-11 04:49:47 UTC (rev 272704)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2021-02-11 05:23:52 UTC (rev 272705)
@@ -753,7 +753,7 @@
void replaceDictatedText(const String& oldText, const String& newText);
void replaceSelectedText(const String& oldText, const String& newText);
void requestAutocorrectionData(const String& textForAutocorrection, CompletionHandler<void(WebAutocorrectionData)>&& reply);
- void applyAutocorrection(const String& correction, const String& originalText, CompletionHandler<void(const String&)>&&);
+ void applyAutocorrection(const String& correction, const String& originalText, CallbackID);
void syncApplyAutocorrection(const String& correction, const String& originalText, CompletionHandler<void(bool)>&&);
void requestAutocorrectionContext();
void getPositionInformation(const InteractionInformationRequest&, CompletionHandler<void(InteractionInformationAtPosition&&)>&&);
@@ -1149,8 +1149,8 @@
Ref<WebCore::DocumentLoader> createDocumentLoader(WebCore::Frame&, const WebCore::ResourceRequest&, const WebCore::SubstituteData&);
void updateCachedDocumentLoader(WebDocumentLoader&, WebCore::Frame&);
- void getBytecodeProfile(CompletionHandler<void(const String&)>&&);
- void getSamplingProfilerOutput(CompletionHandler<void(const String&)>&&);
+ void getBytecodeProfile(CallbackID);
+ void getSamplingProfilerOutput(CallbackID);
#if ENABLE(SERVICE_CONTROLS) || ENABLE(TELEPHONE_NUMBER_DETECTION)
void handleTelephoneNumberClick(const String& number, const WebCore::IntPoint&);
@@ -1253,8 +1253,8 @@
void showContactPicker(const WebCore::ContactsRequestData&, CompletionHandler<void(Optional<Vector<WebCore::ContactInfo>>&&)>&&);
#if ENABLE(ATTACHMENT_ELEMENT)
- void insertAttachment(const String& identifier, Optional<uint64_t>&& fileSize, const String& fileName, const String& contentType, CompletionHandler<void()>&&);
- void updateAttachmentAttributes(const String& identifier, Optional<uint64_t>&& fileSize, const String& contentType, const String& fileName, const IPC::DataReference& enclosingImageData, CompletionHandler<void()>&&);
+ void insertAttachment(const String& identifier, Optional<uint64_t>&& fileSize, const String& fileName, const String& contentType, CallbackID);
+ void updateAttachmentAttributes(const String& identifier, Optional<uint64_t>&& fileSize, const String& contentType, const String& fileName, const IPC::DataReference& enclosingImageData, CallbackID);
void updateAttachmentIcon(const String& identifier, const ShareableBitmap::Handle& qlThumbnailHandle);
#endif
@@ -1515,7 +1515,7 @@
void setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent&, CompletionHandler<void()>&&);
void updateIsInWindow(bool isInitialState = false);
void visibilityDidChange();
- void setActivityState(OptionSet<WebCore::ActivityState::Flag>, ActivityStateChangeID, CompletionHandler<void()>&&);
+ void setActivityState(OptionSet<WebCore::ActivityState::Flag>, ActivityStateChangeID, const Vector<CallbackID>& callbackIDs);
void validateCommand(const String&, CompletionHandler<void(bool, int32_t)>&&);
void executeEditCommand(const String&, const String&);
void setEditable(bool);
@@ -1580,7 +1580,7 @@
void viewWillStartLiveResize();
void viewWillEndLiveResize();
- void getContentsAsString(ContentAsStringIncludesChildFrames, CompletionHandler<void(const String&)>&&);
+ void getContentsAsString(ContentAsStringIncludesChildFrames, CallbackID);
#if PLATFORM(COCOA)
void getContentsAsAttributedString(CompletionHandler<void(const WebCore::AttributedString&)>&&);
#endif
@@ -1589,10 +1589,10 @@
#endif
void getMainResourceDataOfFrame(WebCore::FrameIdentifier, CompletionHandler<void(const IPC::SharedBufferDataReference&)>&&);
void getResourceDataFromFrame(WebCore::FrameIdentifier, const String& resourceURL, CompletionHandler<void(const IPC::SharedBufferDataReference&)>&&);
- void getRenderTreeExternalRepresentation(CompletionHandler<void(const String&)>&&);
- void getSelectionOrContentsAsString(CompletionHandler<void(const String&)>&&);
+ void getRenderTreeExternalRepresentation(CallbackID);
+ void getSelectionOrContentsAsString(CallbackID);
void getSelectionAsWebArchiveData(CompletionHandler<void(const IPC::DataReference&)>&&);
- void getSourceForFrame(WebCore::FrameIdentifier, CompletionHandler<void(const String&)>&&);
+ void getSourceForFrame(WebCore::FrameIdentifier, CallbackID);
void getWebArchiveOfFrame(WebCore::FrameIdentifier, CompletionHandler<void(const IPC::DataReference&)>&&);
void runJavaScript(WebFrame*, WebCore::RunJavaScriptParameters&&, ContentWorldIdentifier, CompletionHandler<void(const IPC::DataReference&, const Optional<WebCore::ExceptionDetails>&)>&&);
void runJavaScriptInFrameInScriptWorld(WebCore::RunJavaScriptParameters&&, Optional<WebCore::FrameIdentifier>, const std::pair<ContentWorldIdentifier, String>& worldData, CompletionHandler<void(const IPC::DataReference&, const Optional<WebCore::ExceptionDetails>&)>&&);
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (272704 => 272705)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2021-02-11 04:49:47 UTC (rev 272704)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2021-02-11 05:23:52 UTC (rev 272705)
@@ -22,7 +22,7 @@
messages -> WebPage LegacyReceiver {
SetInitialFocus(bool forward, bool isKeyboardEventValid, WebKit::WebKeyboardEvent event) -> () Async
- SetActivityState(OptionSet<WebCore::ActivityState::Flag> activityState, WebKit::ActivityStateChangeID activityStateChangeID) -> () Async
+ SetActivityState(OptionSet<WebCore::ActivityState::Flag> activityState, WebKit::ActivityStateChangeID activityStateChangeID, Vector<WebKit::CallbackID> callbackIDs)
SetLayerHostingMode(enum:uint8_t WebKit::LayerHostingMode layerHostingMode)
SetBackgroundColor(Optional<WebCore::Color> color)
@@ -82,7 +82,7 @@
ReplaceDictatedText(String oldText, String newText)
ReplaceSelectedText(String oldText, String newText)
RequestAutocorrectionData(String textForAutocorrection) -> (struct WebKit::WebAutocorrectionData data) Async
- ApplyAutocorrection(String correction, String originalText) -> (String string) Async
+ ApplyAutocorrection(String correction, String originalText, WebKit::CallbackID callbackID)
SyncApplyAutocorrection(String correction, String originalText) -> (bool autocorrectionApplied) Synchronous
RequestAutocorrectionContext()
RequestEvasionRectsAboveSelection() -> (Vector<WebCore::FloatRect> rects) Async
@@ -204,7 +204,7 @@
RestoreSelectionInFocusedEditableElement()
# Callbacks.
- GetContentsAsString(enum:bool WebKit::ContentAsStringIncludesChildFrames inChildFrames) -> (String string) Async
+ GetContentsAsString(enum:bool WebKit::ContentAsStringIncludesChildFrames inChildFrames, WebKit::CallbackID callbackID)
GetAllFrames() -> (struct WebKit::FrameTreeNodeData mainFrame) Async
#if PLATFORM(COCOA)
GetContentsAsAttributedString() -> (struct WebCore::AttributedString result) Async
@@ -214,10 +214,10 @@
#endif
GetMainResourceDataOfFrame(WebCore::FrameIdentifier frameID) -> (IPC::SharedBufferDataReference dataReference) Async
GetResourceDataFromFrame(WebCore::FrameIdentifier frameID, String resourceURL) -> (IPC::SharedBufferDataReference dataReference) Async
- GetRenderTreeExternalRepresentation() -> (String string) Async
- GetSelectionOrContentsAsString() -> (String string) Async
+ GetRenderTreeExternalRepresentation(WebKit::CallbackID callbackID)
+ GetSelectionOrContentsAsString(WebKit::CallbackID callbackID)
GetSelectionAsWebArchiveData() -> (IPC::DataReference data) Async
- GetSourceForFrame(WebCore::FrameIdentifier frameID) -> (String string) Async
+ GetSourceForFrame(WebCore::FrameIdentifier frameID, WebKit::CallbackID callbackID)
GetWebArchiveOfFrame(WebCore::FrameIdentifier frameID) -> (IPC::DataReference dataReference) Async
RunJavaScriptInFrameInScriptWorld(struct WebCore::RunJavaScriptParameters parameters, Optional<WebCore::FrameIdentifier> frameID, std::pair<WebKit::ContentWorldIdentifier, String> world) -> (IPC::DataReference resultData, Optional<WebCore::ExceptionDetails> details) Async
@@ -487,9 +487,9 @@
SetScrollPinningBehavior(uint32_t pinning)
SetScrollbarOverlayStyle(Optional<uint32_t> scrollbarStyle)
- GetBytecodeProfile() -> (String string) Async
+ GetBytecodeProfile(WebKit::CallbackID callbackID)
- GetSamplingProfilerOutput() -> (String string) Async
+ GetSamplingProfilerOutput(WebKit::CallbackID callbackID)
TakeSnapshot(WebCore::IntRect snapshotRect, WebCore::IntSize bitmapSize, uint32_t options) -> (WebKit::ShareableBitmap::Handle image) Async
#if PLATFORM(MAC)
@@ -565,8 +565,8 @@
SetIsSuspended(bool suspended)
#if ENABLE(ATTACHMENT_ELEMENT)
- InsertAttachment(String identifier, Optional<uint64_t> fileSize, String fileName, String contentType) -> () Async
- UpdateAttachmentAttributes(String identifier, Optional<uint64_t> fileSize, String contentType, String fileName, IPC::SharedBufferDataReference enclosingImageData) -> () Async
+ InsertAttachment(String identifier, Optional<uint64_t> fileSize, String fileName, String contentType, WebKit::CallbackID callbackID)
+ UpdateAttachmentAttributes(String identifier, Optional<uint64_t> fileSize, String contentType, String fileName, IPC::SharedBufferDataReference enclosingImageData, WebKit::CallbackID callbackID)
UpdateAttachmentIcon(String identifier, WebKit::ShareableBitmap::Handle qlThumbnailHandle)
#endif
Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (272704 => 272705)
--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2021-02-11 04:49:47 UTC (rev 272704)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2021-02-11 05:23:52 UTC (rev 272705)
@@ -2351,9 +2351,9 @@
reply({ WTFMove(rootViewSelectionRects) , (__bridge UIFont *)font });
}
-void WebPage::applyAutocorrection(const String& correction, const String& originalText, CompletionHandler<void(const String&)>&& callback)
+void WebPage::applyAutocorrection(const String& correction, const String& originalText, CallbackID callbackID)
{
- callback(applyAutocorrectionInternal(correction, originalText) ? correction : String());
+ send(Messages::WebPageProxy::StringCallback(applyAutocorrectionInternal(correction, originalText) ? correction : String(), callbackID));
}
Seconds WebPage::eventThrottlingDelay() const
Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h (272704 => 272705)
--- trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h 2021-02-11 04:49:47 UTC (rev 272704)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h 2021-02-11 05:23:52 UTC (rev 272705)
@@ -82,7 +82,7 @@
bool shouldUseTiledBackingForFrameView(const WebCore::FrameView&) const override;
- void activityStateDidChange(OptionSet<WebCore::ActivityState::Flag> changed, ActivityStateChangeID, CompletionHandler<void()>&&) override;
+ void activityStateDidChange(OptionSet<WebCore::ActivityState::Flag> changed, ActivityStateChangeID, const Vector<CallbackID>&) override;
void attachViewOverlayGraphicsLayer(WebCore::GraphicsLayer*) override;
@@ -151,7 +151,7 @@
double m_transientZoomScale { 1 };
WebCore::FloatPoint m_transientZoomOrigin;
- Vector<CompletionHandler<void()>> m_nextActivityStateChangeCallbacks;
+ Vector<CallbackID> m_nextActivityStateChangeCallbackIDs;
ActivityStateChangeID m_activityStateChangeID { ActivityStateChangeAsynchronous };
RefPtr<WebCore::GraphicsLayer> m_viewOverlayRootLayer;
Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm (272704 => 272705)
--- trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm 2021-02-11 04:49:47 UTC (rev 272704)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm 2021-02-11 05:23:52 UTC (rev 272705)
@@ -498,8 +498,9 @@
if (m_activityStateChangeID != ActivityStateChangeAsynchronous)
m_webPage.send(Messages::WebPageProxy::DidUpdateActivityState());
- for (auto& callback : std::exchange(m_nextActivityStateChangeCallbacks, { }))
- callback();
+ for (auto& callbackID : m_nextActivityStateChangeCallbackIDs)
+ m_webPage.send(Messages::WebPageProxy::VoidCallback(callbackID));
+ m_nextActivityStateChangeCallbackIDs.clear();
m_activityStateChangeID = ActivityStateChangeAsynchronous;
}
@@ -530,9 +531,9 @@
} forPhase:kCATransactionPhasePostCommit];
}
-void TiledCoreAnimationDrawingArea::activityStateDidChange(OptionSet<ActivityState::Flag> changed, ActivityStateChangeID activityStateChangeID, CompletionHandler<void()>&& nextActivityStateChangeCallback)
+void TiledCoreAnimationDrawingArea::activityStateDidChange(OptionSet<ActivityState::Flag> changed, ActivityStateChangeID activityStateChangeID, const Vector<CallbackID>& nextActivityStateChangeCallbackIDs)
{
- m_nextActivityStateChangeCallbacks.append(WTFMove(nextActivityStateChangeCallback));
+ m_nextActivityStateChangeCallbackIDs.appendVector(nextActivityStateChangeCallbackIDs);
m_activityStateChangeID = std::max(m_activityStateChangeID, activityStateChangeID);
if (changed & ActivityState::IsVisible) {
@@ -542,7 +543,7 @@
suspendPainting();
}
- if (m_activityStateChangeID != ActivityStateChangeAsynchronous || !m_nextActivityStateChangeCallbacks.isEmpty()) {
+ if (m_activityStateChangeID != ActivityStateChangeAsynchronous || !m_nextActivityStateChangeCallbackIDs.isEmpty()) {
m_shouldHandleActivityStateChangeCallbacks = true;
triggerRenderingUpdate();
}