Bug 177042 - Web Inspector: RemoteObject.resolveNode should return a Promise
Summary: Web Inspector: RemoteObject.resolveNode should return a Promise
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Matt Baker
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-09-16 18:11 PDT by Matt Baker
Modified: 2017-09-27 12:25 PDT (History)
4 users (show)

See Also:


Attachments
Patch (20.93 KB, patch)
2017-09-16 18:33 PDT, Matt Baker
no flags Details | Formatted Diff | Diff
Patch (20.94 KB, patch)
2017-09-18 11:37 PDT, Matt Baker
no flags Details | Formatted Diff | Diff
Patch for landing (20.98 KB, patch)
2017-09-18 15:42 PDT, Matt Baker
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Baker 2017-09-16 18:11:01 PDT
.
Comment 1 Matt Baker 2017-09-16 18:33:17 PDT
Created attachment 321020 [details]
Patch
Comment 2 Joseph Pecoraro 2017-09-18 11:25:53 PDT
Comment on attachment 321020 [details]
Patch

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

> Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js:138
> -    static resolveNode(node, objectGroup, callback)
> +    static resolveNode(node, objectGroup)
>      {
> -        DOMAgent.resolveNode(node.id, objectGroup, function(error, object) {
> -            if (!callback)
> -                return;
> +        return new Promise((resolve, reject) => {
> +            DOMAgent.resolveNode(node.id, objectGroup, function(error, object) {
> +                if (error || !object) {
> +                    reject(error || "Could not resolve DOM node.");
> +                    return;
> +                }
>  
> -            if (error || !object)
> -                callback(null);
> -            else
> -                callback(WI.RemoteObject.fromPayload(object, WI.mainTarget));
> +                resolve(WI.RemoteObject.fromPayload(object, WI.mainTarget));
> +            });

I'm a little confused by this. DOMAgent.resolveNode can produce a promise, lets use that promise (which handles errors) instead of creating our own:

    return DOMAgent.resolveNode(node.id, objectGroup)
        .then(({object}) => WI.RemoteObject.fromPayload(object, WI.mainTarget));

> Source/WebInspectorUI/UserInterface/Views/BoxModelDetailsSectionRow.js:408
> +            function toggleInlineStyleProperty(property, value) {

Name: inspectedPage_node_toggleInlineStyleProperty

> Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js:313
> +            function dimensions() {

This should be named:

    inspectedPage_node_dimensions

Since we are running this code on the `inspectedPage` and the this value is a `node`.

> Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.js:508
> +        function injectStyleAndToggleClass() {

Same thing here:

    inspectedPage_node_injectStyleAndToggleClass
Comment 3 Matt Baker 2017-09-18 11:37:09 PDT
Created attachment 321117 [details]
Patch
Comment 4 Joseph Pecoraro 2017-09-18 14:25:36 PDT
Comment on attachment 321117 [details]
Patch

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

rs=me

> Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.js:508
> +        function injectStyleAndToggleClass() {

Style: Name of this should have "inspectedPage_node_" prefix.
Comment 5 Matt Baker 2017-09-18 15:42:30 PDT
Created attachment 321141 [details]
Patch for landing
Comment 6 WebKit Commit Bot 2017-09-18 16:14:51 PDT
Comment on attachment 321141 [details]
Patch for landing

Clearing flags on attachment: 321141

Committed r222188: <http://trac.webkit.org/changeset/222188>
Comment 7 WebKit Commit Bot 2017-09-18 16:14:53 PDT
All reviewed patches have been landed.  Closing bug.
Comment 8 Radar WebKit Bug Importer 2017-09-27 12:25:06 PDT
<rdar://problem/34693236>