WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
230580
[Cocoa] Add SPI to select a tab created by _WKInspectorExtension
https://bugs.webkit.org/show_bug.cgi?id=230580
Summary
[Cocoa] Add SPI to select a tab created by _WKInspectorExtension
Blaze Burg
Reported
2021-09-21 15:49:06 PDT
.
Attachments
Patch v1.0 - depends on patch from 230573
(38.24 KB, patch)
2021-09-21 15:59 PDT
,
Blaze Burg
no flags
Details
Formatted Diff
Diff
Patch v1.1
(17.29 KB, patch)
2021-09-21 16:29 PDT
,
Blaze Burg
no flags
Details
Formatted Diff
Diff
Patch v1.1
(38.03 KB, patch)
2021-09-21 16:35 PDT
,
Blaze Burg
no flags
Details
Formatted Diff
Diff
Patch v1.2
(38.27 KB, patch)
2021-09-22 08:29 PDT
,
Blaze Burg
no flags
Details
Formatted Diff
Diff
Patch v1.3
(56.30 KB, patch)
2021-09-27 09:29 PDT
,
Blaze Burg
no flags
Details
Formatted Diff
Diff
Patch v1.3 (rebase)
(41.04 KB, patch)
2021-09-27 09:45 PDT
,
Blaze Burg
no flags
Details
Formatted Diff
Diff
Patch v1.5 (for landing)
(42.00 KB, patch)
2021-09-28 12:17 PDT
,
Blaze Burg
no flags
Details
Formatted Diff
Diff
Show Obsolete
(6)
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2021-09-21 15:49:24 PDT
<
rdar://problem/83372851
>
Blaze Burg
Comment 2
2021-09-21 15:59:19 PDT
Created
attachment 438874
[details]
Patch v1.0 - depends on patch from 230573
Blaze Burg
Comment 3
2021-09-21 16:29:56 PDT
Created
attachment 438883
[details]
Patch v1.1
Blaze Burg
Comment 4
2021-09-21 16:35:23 PDT
Created
attachment 438885
[details]
Patch v1.1
Devin Rousso
Comment 5
2021-09-21 16:53:25 PDT
Comment on
attachment 438874
[details]
Patch v1.0 - depends on patch from 230573 View in context:
https://bugs.webkit.org/attachment.cgi?id=438874&action=review
> Source/WebInspectorUI/UserInterface/Controllers/WebInspectorExtensionController.js:164 > + WI.tabBrowser.showTabForContentView(tabContentView, {
Do we want to propagate the result of this (i.e. add a `return`)? You use `Expected<bool, Inspector::ExtensionError>`, so I'm guessing yes? If not, can we switch to just a `std::optional<Inspector::ExtensionError>` instead?
> Source/WebKit/UIProcess/API/Cocoa/_WKInspectorExtensionHost.h:76 > + * This will open the associated Web Inspector if it is not already open.
This contradicts the comment inside the implementation(s).
Patrick Angle
Comment 6
2021-09-21 17:21:01 PDT
Comment on
attachment 438885
[details]
Patch v1.1 View in context:
https://bugs.webkit.org/attachment.cgi?id=438885&action=review
> Source/WebKit/UIProcess/API/Cocoa/_WKInspectorExtensionHost.h:61 > + * @discussion This method has no effect if the extensionTabIdentifier is invalid.
NIT: extra space in "the extensionTabIdentifier"
> Source/WebKit/UIProcess/Inspector/WebInspectorUIExtensionControllerProxy.cpp:190 > +void WebInspectorUIExtensionControllerProxy::showExtensionTab(const Inspector::ExtensionTabID& extensionTabIdentifier, CompletionHandler<void(Expected<bool, Inspector::ExtensionError>)>&& completionHandler)
+1 to Devin's question on this signature and friends wrt the completion handler's `bool`. Looking at the frontend implementation, it looks like you return an error if the tab can't be found to be shown, so an optional is probably correct here.
> Source/WebKit/UIProcess/Inspector/WebInspectorUIExtensionControllerProxy.h:63 > + void showExtensionTab(const Inspector::ExtensionTabID&, CompletionHandler<void(Expected<bool, Inspector::ExtensionError>)>&&);
DITTO: WebInspectorUIExtensionControllerProxy.cpp:190
Blaze Burg
Comment 7
2021-09-21 19:23:12 PDT
Comment on
attachment 438874
[details]
Patch v1.0 - depends on patch from 230573 View in context:
https://bugs.webkit.org/attachment.cgi?id=438874&action=review
>> Source/WebInspectorUI/UserInterface/Controllers/WebInspectorExtensionController.js:164 >> + WI.tabBrowser.showTabForContentView(tabContentView, { > > Do we want to propagate the result of this (i.e. add a `return`)? You use `Expected<bool, Inspector::ExtensionError>`, so I'm guessing yes? If not, can we switch to just a `std::optional<Inspector::ExtensionError>` instead?
I suppose there are some rare situations where returning false from WI.TabBrowser.showTabForContentView *is* meaningful, namely that the contentView argument is invalid. This seems like more of an internal assertion than something that makes sense at the Cocoa API / NSError level. There is an early return in WI.WebInspectorExtensionController.showExtensionTab() in the case that we can't find the extension contentView in the mapping from tabID -> contentView. As for Expected vs std::optional, see my other comment.
>> Source/WebKit/UIProcess/API/Cocoa/_WKInspectorExtensionHost.h:76 >> + * This will open the associated Web Inspector if it is not already open. > > This contradicts the comment inside the implementation(s).
This comment is incorrect, will remove.
Blaze Burg
Comment 8
2021-09-21 19:27:26 PDT
(In reply to Patrick Angle from
comment #6
)
> Comment on
attachment 438885
[details]
> Patch v1.1 > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=438885&action=review
> > > Source/WebKit/UIProcess/Inspector/WebInspectorUIExtensionControllerProxy.cpp:190 > > +void WebInspectorUIExtensionControllerProxy::showExtensionTab(const Inspector::ExtensionTabID& extensionTabIdentifier, CompletionHandler<void(Expected<bool, Inspector::ExtensionError>)>&& completionHandler) > > +1 to Devin's question on this signature and friends wrt the completion > handler's `bool`. Looking at the frontend implementation, it looks like you > return an error if the tab can't be found to be shown, so an optional is > probably correct here.
When I wrote the majority of this class, I found Expected to be a great template for representing a return value with an optional error. The only hiccup is that it doesn't work with `void` as the return type, such as showExtensionTab. In that case I prefer to use Expected<bool, InspectorExtensionError>, rather than making this plumbing even harder to follow by using two different template classes to encode an optional error.
Blaze Burg
Comment 9
2021-09-22 08:29:48 PDT
Created
attachment 438952
[details]
Patch v1.2 Latest patch v1.2 addresses all comments to date.
Patrick Angle
Comment 10
2021-09-22 09:25:25 PDT
Comment on
attachment 438952
[details]
Patch v1.2 View in context:
https://bugs.webkit.org/attachment.cgi?id=438952&action=review
> Source/WebKit/UIProcess/API/Cocoa/_WKInspectorExtensionHost.h:58 > + * This will open the associated Web Inspector if it is not already open.
I'm still not sure this is accurate, given that the implementation says it is considered an error to call this method prior to at least creating the frontend.
Blaze Burg
Comment 11
2021-09-27 09:19:54 PDT
Comment on
attachment 438952
[details]
Patch v1.2 View in context:
https://bugs.webkit.org/attachment.cgi?id=438952&action=review
>> Source/WebKit/UIProcess/API/Cocoa/_WKInspectorExtensionHost.h:58 >> + * This will open the associated Web Inspector if it is not already open. > > I'm still not sure this is accurate, given that the implementation says it is considered an error to call this method prior to at least creating the frontend.
Yeah, this is inaccurate. The completion handler will never resolve until the frontend finishes loading. I will remove the comment.
Blaze Burg
Comment 12
2021-09-27 09:29:17 PDT
Created
attachment 439361
[details]
Patch v1.3
Blaze Burg
Comment 13
2021-09-27 09:45:31 PDT
Created
attachment 439364
[details]
Patch v1.3 (rebase)
Devin Rousso
Comment 14
2021-09-27 11:12:16 PDT
Comment on
attachment 439364
[details]
Patch v1.3 (rebase) View in context:
https://bugs.webkit.org/attachment.cgi?id=439364&action=review
r=me
> Source/WebKit/UIProcess/API/Cocoa/_WKInspector.mm:276 > + // It is an error to call this method prior to creating a frontend (i.e., with -connect or -show).
might be worth adding this to the header doc too?
> Source/WebKit/UIProcess/API/Cocoa/_WKInspector.mm:282 > + _inspector->extensionController()->showExtensionTab(extensionTabIdentifier, [protectedSelf = retainPtr(self), capturedBlock = makeBlockPtr(completionHandler)] (Expected<bool, Inspector::ExtensionError> result) mutable {
should `result` have a `&`? btw are you sure that `Expected` doesn't work with `void`? i see code that should make it work 🤔
> Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm:223 > + // It is an error to call this method prior to creating a frontend (i.e., with -connect or -show).
ditto
> Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm:230 > + if (!result) {
ditto
Blaze Burg
Comment 15
2021-09-28 11:56:47 PDT
Comment on
attachment 439364
[details]
Patch v1.3 (rebase) View in context:
https://bugs.webkit.org/attachment.cgi?id=439364&action=review
>> Source/WebKit/UIProcess/API/Cocoa/_WKInspector.mm:282 >> + _inspector->extensionController()->showExtensionTab(extensionTabIdentifier, [protectedSelf = retainPtr(self), capturedBlock = makeBlockPtr(completionHandler)] (Expected<bool, Inspector::ExtensionError> result) mutable { > > should `result` have a `&`? > > btw are you sure that `Expected` doesn't work with `void`? i see code that should make it work 🤔
result should be &&. Expected<void, E> will require work outside the scope of this patch. I filed <
https://bugs.webkit.org/show_bug.cgi?id=230907
> to track its resolution and added a FIXME.
Blaze Burg
Comment 16
2021-09-28 12:17:15 PDT
Created
attachment 439505
[details]
Patch v1.5 (for landing)
EWS
Comment 17
2021-09-28 14:28:15 PDT
Committed
r283196
(
242243@main
): <
https://commits.webkit.org/242243@main
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 439505
[details]
.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug