Bug 210944

Summary: Reduce use of WebPageProxy::VoidCallback
Product: WebKit Reporter: Alex Christensen <achristensen>
Component: New BugsAssignee: Alex Christensen <achristensen>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, darin, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch none

Description Alex Christensen 2020-04-23 16:40:58 PDT
Reduce use of WebPageProxy::VoidCallback
Comment 1 Alex Christensen 2020-04-23 16:51:16 PDT
Created attachment 397401 [details]
Patch
Comment 2 Darin Adler 2020-04-24 11:17:19 PDT
Comment on attachment 397401 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=397401&action=review

> Source/WebKit/UIProcess/WebPageProxy.cpp:2176
> +    sendWithAsyncReply(Messages::WebPage::SetInitialFocus(forward, isKeyboardEventValid, keyboardEvent), [callbackFunction = WTFMove(callbackFunction), backgroundActivity = m_process->throttler().backgroundActivity("WebPageProxy::setInitialFocus"_s)] () mutable {

Why does this need to be "mutable"? Same question about the various other similar cases below.

> Source/WebKit/UIProcess/WebPageProxy.h:782
> +    void focusNextFocusedElement(bool isForward, CompletionHandler<void()>&& = []() { });

I believe our coding style is to omit the () here. There are 10 or more other cases of this in this patch. I suggest removing them all.
Comment 3 Alex Christensen 2020-04-24 13:49:06 PDT
Calling a CompletionHandler deletes its callable immediately after calling, which requires it to be non-const.
Will remove unnecessary ().
Comment 4 Alex Christensen 2020-04-24 13:56:19 PDT
Created attachment 397503 [details]
Patch
Comment 5 Darin Adler 2020-04-25 11:23:14 PDT
Comment on attachment 397503 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=397503&action=review

> Source/WebKit/UIProcess/WebPageProxy.cpp:2314
> +    sendWithAsyncReply(Messages::WebPage::ExecuteEditCommandWithCallback(commandName, argument), [callbackFunction = WTFMove(callbackFunction), backgroundActivity = m_process->throttler().backgroundActivity("WebPageProxy::executeEditCommand"_s)] () mutable {

One last case of () that you didn't delete yet.
Comment 6 Alex Christensen 2020-04-27 10:08:38 PDT
Comment on attachment 397503 [details]
Patch

That is unfortunately necessary because of the mutable in C++ until http://wg21.link/P1102 is accepted.
Comment 7 EWS 2020-04-27 10:13:22 PDT
Committed r260764: <https://trac.webkit.org/changeset/260764>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 397503 [details].
Comment 8 Radar WebKit Bug Importer 2020-04-27 10:14:14 PDT
<rdar://problem/62457381>