Diff
Modified: trunk/Source/WebKit/ChangeLog (271161 => 271162)
--- trunk/Source/WebKit/ChangeLog 2021-01-05 18:43:00 UTC (rev 271161)
+++ trunk/Source/WebKit/ChangeLog 2021-01-05 18:44:30 UTC (rev 271162)
@@ -1,5 +1,30 @@
2021-01-05 Alex Christensen <[email protected]>
+ Use sendWithAsyncReply instead of ValidateCommandCallback
+ https://bugs.webkit.org/show_bug.cgi?id=220124
+
+ Reviewed by Chris Dumez.
+
+ * UIProcess/API/C/WKPage.cpp:
+ (WKPageValidateCommand):
+ * UIProcess/Cocoa/WebViewImpl.mm:
+ (WebKit::WebViewImpl::validateUserInterfaceItem):
+ * UIProcess/WebCookieManagerProxy.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::validateCommand):
+ (WebKit::WebPageProxy::validateCommandCallback): Deleted.
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebPageProxy.messages.in:
+ * UIProcess/WebProcessPool.cpp:
+ (WebKit::WebProcessPool::~WebProcessPool):
+ * UIProcess/WebProcessPool.h:
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::validateCommand):
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/WebPage.messages.in:
+
+2021-01-05 Alex Christensen <[email protected]>
+
Use sendWithAsyncReply instead of FontAttributesCallback
https://bugs.webkit.org/show_bug.cgi?id=220123
Modified: trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp (271161 => 271162)
--- trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp 2021-01-05 18:43:00 UTC (rev 271161)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp 2021-01-05 18:44:30 UTC (rev 271162)
@@ -2610,8 +2610,9 @@
void WKPageValidateCommand(WKPageRef pageRef, WKStringRef command, void* context, WKPageValidateCommandCallback callback)
{
- toImpl(pageRef)->validateCommand(toImpl(command)->string(), [context, callback](const String& commandName, bool isEnabled, int32_t state, WebKit::CallbackBase::Error error) {
- callback(toAPI(API::String::create(commandName).ptr()), isEnabled, state, error != WebKit::CallbackBase::Error::None ? toAPI(API::Error::create().ptr()) : 0, context);
+ auto commandName = toImpl(command)->string();
+ toImpl(pageRef)->validateCommand(commandName, [context, callback, commandName](bool isEnabled, int32_t state) {
+ callback(toAPI(API::String::create(commandName).ptr()), isEnabled, state, nullptr, context);
});
}
Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp (271161 => 271162)
--- trunk/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp 2021-01-05 18:43:00 UTC (rev 271161)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp 2021-01-05 18:44:30 UTC (rev 271162)
@@ -3646,7 +3646,7 @@
g_return_if_fail(command);
GRefPtr<GTask> task = adoptGRef(g_task_new(webView, cancellable, callback, userData));
- getPage(webView).validateCommand(String::fromUTF8(command), [task = WTFMove(task)](const String&, bool isEnabled, int32_t, WebKit::CallbackBase::Error) {
+ getPage(webView).validateCommand(String::fromUTF8(command), [task = WTFMove(task)](bool isEnabled, int32_t) {
g_task_return_boolean(task.get(), isEnabled);
});
}
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (271161 => 271162)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2021-01-05 18:43:00 UTC (rev 271161)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2021-01-05 18:44:30 UTC (rev 271162)
@@ -3129,15 +3129,10 @@
// If we are not already awaiting validation for this command, start the asynchronous validation process.
// FIXME: Theoretically, there is a race here; when we get the answer it might be old, from a previous time
// we asked for the same command; there is no guarantee the answer is still valid.
- auto weakThis = makeWeakPtr(*this);
- m_page->validateCommand(commandName, [weakThis](const String& commandName, bool isEnabled, int32_t state, WebKit::CallbackBase::Error error) {
+ m_page->validateCommand(commandName, [weakThis = makeWeakPtr(*this), commandName](bool isEnabled, int32_t state) {
if (!weakThis)
return;
- // If the process exits before the command can be validated, we'll be called back with an error.
- if (error != WebKit::CallbackBase::Error::None)
- return;
-
weakThis->setUserInterfaceItemState(commandName, isEnabled, state);
});
}
Modified: trunk/Source/WebKit/UIProcess/WebCookieManagerProxy.h (271161 => 271162)
--- trunk/Source/WebKit/UIProcess/WebCookieManagerProxy.h 2021-01-05 18:43:00 UTC (rev 271161)
+++ trunk/Source/WebKit/UIProcess/WebCookieManagerProxy.h 2021-01-05 18:44:30 UTC (rev 271162)
@@ -52,10 +52,6 @@
class WebProcessPool;
class WebProcessProxy;
-typedef GenericCallback<API::Array*> ArrayCallback;
-typedef GenericCallback<WebCore::HTTPCookieAcceptPolicy> HTTPCookieAcceptPolicyCallback;
-typedef GenericCallback<const Vector<WebCore::Cookie>&> GetCookiesCallback;
-
class WebCookieManagerProxy : public API::ObjectImpl<API::Object::Type::CookieManager>, private IPC::MessageReceiver {
public:
static Ref<WebCookieManagerProxy> create(NetworkProcessProxy& networkProcess) { return adoptRef(*new WebCookieManagerProxy(networkProcess)); }
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (271161 => 271162)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-01-05 18:43:00 UTC (rev 271161)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-01-05 18:44:30 UTC (rev 271162)
@@ -2204,15 +2204,12 @@
send(Messages::WebPage::RestoreSelectionInFocusedEditableElement());
}
-void WebPageProxy::validateCommand(const String& commandName, WTF::Function<void (const String&, bool, int32_t, CallbackBase::Error)>&& callbackFunction)
+void WebPageProxy::validateCommand(const String& commandName, CompletionHandler<void(bool, int32_t)>&& callbackFunction)
{
- if (!hasRunningProcess()) {
- callbackFunction(String(), false, 0, CallbackBase::Error::Unknown);
- return;
- }
+ if (!hasRunningProcess())
+ return callbackFunction(false, 0);
- auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::validateCommand"_s));
- send(Messages::WebPage::ValidateCommand(commandName, callbackID));
+ sendWithAsyncReply(Messages::WebPage::ValidateCommand(commandName), WTFMove(callbackFunction));
}
void WebPageProxy::increaseListLevel()
@@ -7186,17 +7183,6 @@
callback->performCallbackWithReturnValue(pageRects, totalScaleFactorForPrinting, computedPageMargin);
}
-void WebPageProxy::validateCommandCallback(const String& commandName, bool isEnabled, int state, CallbackID callbackID)
-{
- auto callback = m_callbacks.take<ValidateCommandCallback>(callbackID);
- if (!callback) {
- // FIXME: Log error or assert.
- return;
- }
-
- callback->performCallbackWithReturnValue(commandName.impl(), isEnabled, state);
-}
-
void WebPageProxy::unsignedCallback(uint64_t result, CallbackID callbackID)
{
auto callback = m_callbacks.take<UnsignedCallback>(callbackID);
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (271161 => 271162)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2021-01-05 18:43:00 UTC (rev 271161)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2021-01-05 18:44:30 UTC (rev 271162)
@@ -395,8 +395,6 @@
};
#endif
-typedef GenericCallback<const String&, bool, int32_t> ValidateCommandCallback;
-
#if ENABLE(APPLICATION_MANIFEST)
typedef GenericCallback<const Optional<WebCore::ApplicationManifest>&> ApplicationManifestCallback;
#endif
@@ -691,7 +689,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)>&&);
+ void validateCommand(const String& commandName, CompletionHandler<void(bool, int32_t)>&&);
const EditorState& editorState() const { return m_editorState; }
bool canDelete() const { return hasSelectedRange() && isContentEditable(); }
@@ -2155,7 +2153,6 @@
void stringCallback(const String&, CallbackID);
void invalidateStringCallback(CallbackID);
void computedPagesCallback(const Vector<WebCore::IntRect>&, double totalScaleFactorForPrinting, const WebCore::FloatBoxExtent& computedPageMargin, CallbackID);
- void validateCommandCallback(const String&, bool, int, CallbackID);
void unsignedCallback(uint64_t, CallbackID);
#if ENABLE(APPLICATION_MANIFEST)
void applicationManifestCallback(const Optional<WebCore::ApplicationManifest>&, CallbackID);
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (271161 => 271162)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2021-01-05 18:43:00 UTC (rev 271161)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2021-01-05 18:44:30 UTC (rev 271162)
@@ -169,7 +169,6 @@
BoolCallback(bool result, WebKit::CallbackID callbackID)
InvalidateStringCallback(WebKit::CallbackID callbackID)
ComputedPagesCallback(Vector<WebCore::IntRect> pageRects, double totalScaleFactorForPrinting, WebCore::RectEdges<float> computedPageMargin, WebKit::CallbackID callbackID)
- ValidateCommandCallback(String command, bool isEnabled, int32_t state, WebKit::CallbackID callbackID)
UnsignedCallback(uint64_t result, WebKit::CallbackID callbackID)
#if ENABLE(APPLICATION_MANIFEST)
ApplicationManifestCallback(Optional<WebCore::ApplicationManifest> manifest, WebKit::CallbackID callbackID)
Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (271161 => 271162)
--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2021-01-05 18:43:00 UTC (rev 271161)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2021-01-05 18:44:30 UTC (rev 271162)
@@ -344,8 +344,6 @@
supplement->clearProcessPool();
}
- invalidateCallbackMap(m_dictionaryCallbacks, CallbackBase::Error::OwnerWasInvalidated);
-
platformInvalidateContext();
#ifndef NDEBUG
Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.h (271161 => 271162)
--- trunk/Source/WebKit/UIProcess/WebProcessPool.h 2021-01-05 18:43:00 UTC (rev 271161)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.h 2021-01-05 18:44:30 UTC (rev 271162)
@@ -109,8 +109,6 @@
struct NetworkProcessCreationParameters;
struct WebProcessCreationParameters;
struct WebProcessDataStoreParameters;
-
-typedef GenericCallback<API::Dictionary*> DictionaryCallback;
#if PLATFORM(COCOA)
int networkProcessLatencyQOS();
@@ -665,8 +663,6 @@
bool m_processTerminationEnabled { true };
- HashMap<uint64_t, RefPtr<DictionaryCallback>> m_dictionaryCallbacks;
-
bool m_memoryCacheDisabled { false };
bool m_javaScriptConfigurationFileEnabled { false };
String m_javaScriptConfigurationDirectory;
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (271161 => 271162)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2021-01-05 18:43:00 UTC (rev 271161)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2021-01-05 18:44:30 UTC (rev 271162)
@@ -2948,7 +2948,7 @@
return m_page->focusController().relinquishFocusToChrome(FocusDirection::Backward);
}
-void WebPage::validateCommand(const String& commandName, CallbackID callbackID)
+void WebPage::validateCommand(const String& commandName, CompletionHandler<void(bool, int32_t)>&& completionHandler)
{
bool isEnabled = false;
int32_t state = 0;
@@ -2961,7 +2961,7 @@
isEnabled = command.isSupported() && command.isEnabled();
}
- send(Messages::WebPageProxy::ValidateCommandCallback(commandName, isEnabled, state, callbackID));
+ completionHandler(isEnabled, state);
}
void WebPage::executeEditCommand(const String& commandName, const String& argument)
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (271161 => 271162)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2021-01-05 18:43:00 UTC (rev 271161)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2021-01-05 18:44:30 UTC (rev 271162)
@@ -1487,7 +1487,7 @@
void updateIsInWindow(bool isInitialState = false);
void visibilityDidChange();
void setActivityState(OptionSet<WebCore::ActivityState::Flag>, ActivityStateChangeID, const Vector<CallbackID>& callbackIDs);
- void validateCommand(const String&, CallbackID);
+ void validateCommand(const String&, CompletionHandler<void(bool, int32_t)>&&);
void executeEditCommand(const String&, const String&);
void setEditable(bool);
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (271161 => 271162)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2021-01-05 18:43:00 UTC (rev 271161)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2021-01-05 18:44:30 UTC (rev 271162)
@@ -252,7 +252,7 @@
TryClose() -> (bool shouldClose) Async
SetEditable(bool editable)
- ValidateCommand(String name, WebKit::CallbackID callbackID)
+ ValidateCommand(String name) -> (bool isEnabled, int32_t state) Async
ExecuteEditCommand(String name, String argument)
IncreaseListLevel()