⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 242386 in webkit


Ignore:
Timestamp:
Mar 4, 2019, 1:48:04 PM (7 years ago)
Author:
commit-queue@webkit.org
Message:

ITMLKit Inspector: Data Bindings / Associated Data for nodes
https://bugs.webkit.org/show_bug.cgi?id=195290
<rdar://problem/48304019>

Patch by Joseph Pecoraro <Joseph Pecoraro> on 2019-03-04
Reviewed by Devin Rousso.

Source/JavaScriptCore:

  • inspector/protocol/DOM.json:

Source/WebCore:

  • inspector/agents/InspectorDOMAgent.h:
  • inspector/agents/InspectorDOMAgent.cpp:

(WebCore::InspectorDOMAgent::getDataBindingsForNode):
(WebCore::InspectorDOMAgent::getAssociatedDataForNode):
Stub these for web pages, they will only be used for ITMLKit right now.

Source/WebInspectorUI:

  • Localizations/en.lproj/localizedStrings.js:

New title and empty message strings.

  • UserInterface/Views/DOMNodeDetailsSidebarPanel.css:

(.sidebar > .panel.dom-node-details .details-section.dom-node-associated-data > .content .row):

  • UserInterface/Views/DOMNodeDetailsSidebarPanel.js:

(WI.DOMNodeDetailsSidebarPanel.prototype.initialLayout):
(WI.DOMNodeDetailsSidebarPanel.prototype.layout):
(WI.DOMNodeDetailsSidebarPanel.prototype._refreshDataBindings):
(WI.DOMNodeDetailsSidebarPanel.prototype._refreshAssociatedData):
(WI.DOMNodeDetailsSidebarPanel.prototype._attributesChanged):
New Node sections only enabled for ITMLKit WI.sharedApp.hasExtraDomains.

  • UserInterface/Views/ObjectTreeView.js:

(WI.ObjectTreeView):
Provide a way, like TreeElement/View to access the ObjectTreeView from an element.

Location:
trunk/Source
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r242382 r242386  
     12019-03-04  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        ITMLKit Inspector: Data Bindings / Associated Data for nodes
     4        https://bugs.webkit.org/show_bug.cgi?id=195290
     5        <rdar://problem/48304019>
     6
     7        Reviewed by Devin Rousso.
     8
     9        * inspector/protocol/DOM.json:
     10
    1112019-03-04  Yusuke Suzuki  <ysuzuki@apple.com>
    212
  • trunk/Source/JavaScriptCore/inspector/protocol/DOM.json

    r241547 r242386  
    6767                { "name": "pseudoElements", "type": "array", "items": { "$ref": "Node" }, "optional": true, "description": "Pseudo elements associated with this node." },
    6868                { "name": "contentSecurityPolicyHash", "type": "string", "optional": true, "description": "Computed SHA-256 Content Security Policy hash source for given element." }
     69            ]
     70        },
     71        {
     72            "id": "DataBinding",
     73            "type": "object",
     74            "description": "Relationship between data that is associated with a node and the node itself.",
     75            "properties": [
     76                { "name": "binding", "type": "string", "description": "The binding key that is specified." },
     77                { "name": "type", "optional": true, "type": "string", "description": "A more descriptive name for the type of binding that represents this paritcular data relationship" },
     78                { "name": "value", "type": "string", "description": "The value that is resolved to with this data binding relationship." }
    6979            ]
    7080        },
     
    257267        },
    258268        {
     269            "name": "getDataBindingsForNode",
     270            "description": "Returns all data binding relationships between data that is associated with the node and the node itself.",
     271            "parameters": [
     272                { "name": "nodeId", "$ref": "NodeId", "description": "Id of the node to get data bindings for." }
     273            ],
     274            "returns": [
     275                { "name": "dataBindings", "type": "array", "items": { "$ref": "DataBinding"}, "description": "Array of binding relationships between data and node" }
     276            ]
     277        },
     278        {
     279            "name": "getAssociatedDataForNode",
     280            "description": "Returns all data that has been associated with the node and is available for data binding.",
     281            "parameters": [
     282                { "name": "nodeId", "$ref": "NodeId", "description": "Id of the node to get associated data for." }
     283            ],
     284            "returns": [
     285                { "name": "associatedData", "type": "string", "optional": true, "description": "Associated data bound to this node. Sent as a JSON string." }
     286            ]
     287        },
     288        {
    259289            "name": "getEventListenersForNode",
    260290            "description": "Returns event listeners relevant to the node.",
  • trunk/Source/WebCore/ChangeLog

    r242379 r242386  
     12019-03-04  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        ITMLKit Inspector: Data Bindings / Associated Data for nodes
     4        https://bugs.webkit.org/show_bug.cgi?id=195290
     5        <rdar://problem/48304019>
     6
     7        Reviewed by Devin Rousso.
     8
     9        * inspector/agents/InspectorDOMAgent.h:
     10        * inspector/agents/InspectorDOMAgent.cpp:
     11        (WebCore::InspectorDOMAgent::getDataBindingsForNode):
     12        (WebCore::InspectorDOMAgent::getAssociatedDataForNode):
     13        Stub these for web pages, they will only be used for ITMLKit right now.
     14
    1152019-03-04  Daniel Bates  <dabates@apple.com>
    216
  • trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.cpp

    r241547 r242386  
    867867}
    868868
     869void InspectorDOMAgent::getDataBindingsForNode(ErrorString& errorString, int /* nodeId */, RefPtr<JSON::ArrayOf<Inspector::Protocol::DOM::DataBinding>>& /* dataBindings */)
     870{
     871    errorString = "Not supported"_s;
     872}
     873
     874void InspectorDOMAgent::getAssociatedDataForNode(ErrorString& errorString, int /* nodeId */, Optional<String>& /* associatedData */)
     875{
     876    errorString = "Not supported"_s;
     877}
     878
    869879void InspectorDOMAgent::getEventListenersForNode(ErrorString& errorString, int nodeId, const String* objectGroup, RefPtr<JSON::ArrayOf<Inspector::Protocol::DOM::EventListener>>& listenersArray)
    870880{
  • trunk/Source/WebCore/inspector/agents/InspectorDOMAgent.h

    r241495 r242386  
    128128    void setNodeValue(ErrorString&, int nodeId, const String& value) override;
    129129    void getSupportedEventNames(ErrorString&, RefPtr<JSON::ArrayOf<String>>& eventNames) override;
     130    void getDataBindingsForNode(ErrorString&, int nodeId, RefPtr<JSON::ArrayOf<Inspector::Protocol::DOM::DataBinding>>& dataArray) override;
     131    void getAssociatedDataForNode(ErrorString&, int nodeId, Optional<String>& associatedData) override;
    130132    void getEventListenersForNode(ErrorString&, int nodeId, const WTF::String* objectGroup, RefPtr<JSON::ArrayOf<Inspector::Protocol::DOM::EventListener>>& listenersArray) override;
    131133    void setEventListenerDisabled(ErrorString&, int eventListenerId, bool disabled) override;
  • trunk/Source/WebInspectorUI/ChangeLog

    r242374 r242386  
     12019-03-04  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        ITMLKit Inspector: Data Bindings / Associated Data for nodes
     4        https://bugs.webkit.org/show_bug.cgi?id=195290
     5        <rdar://problem/48304019>
     6
     7        Reviewed by Devin Rousso.
     8
     9        * Localizations/en.lproj/localizedStrings.js:
     10        New title and empty message strings.
     11
     12        * UserInterface/Views/DOMNodeDetailsSidebarPanel.css:
     13        (.sidebar > .panel.dom-node-details .details-section.dom-node-associated-data > .content .row):
     14        * UserInterface/Views/DOMNodeDetailsSidebarPanel.js:
     15        (WI.DOMNodeDetailsSidebarPanel.prototype.initialLayout):
     16        (WI.DOMNodeDetailsSidebarPanel.prototype.layout):
     17        (WI.DOMNodeDetailsSidebarPanel.prototype._refreshDataBindings):
     18        (WI.DOMNodeDetailsSidebarPanel.prototype._refreshAssociatedData):
     19        (WI.DOMNodeDetailsSidebarPanel.prototype._attributesChanged):
     20        New Node sections only enabled for ITMLKit `WI.sharedApp.hasExtraDomains`.
     21
     22        * UserInterface/Views/ObjectTreeView.js:
     23        (WI.ObjectTreeView):
     24        Provide a way, like TreeElement/View to access the ObjectTreeView from an element.
     25
    1262019-03-04  Devin Rousso  <drousso@apple.com>
    227
  • trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js

    r242300 r242386  
    130130localizedStrings["Assertion with message: %s"] = "Assertion with message: %s";
    131131localizedStrings["Assertive"] = "Assertive";
     132localizedStrings["Associated Data"] = "Associated Data";
    132133localizedStrings["Async audits are not supported."] = "Async audits are not supported.";
    133134localizedStrings["Attribute"] = "Attribute";
     
    151152localizedStrings["Beacons"] = "Beacons";
    152153localizedStrings["Binary Frame"] = "Binary Frame";
     154localizedStrings["Binding"] = "Binding";
    153155localizedStrings["Block Variables"] = "Block Variables";
    154156localizedStrings["Body:"] = "Body:";
     
    289291localizedStrings["Damping"] = "Damping";
    290292localizedStrings["Data"] = "Data";
     293localizedStrings["Data Bindings"] = "Data Bindings";
    291294localizedStrings["Data returned from the database is too large."] = "Data returned from the database is too large.";
    292295localizedStrings["Database"] = "Database";
     
    639642localizedStrings["No Accessibility Information"] = "No Accessibility Information";
    640643localizedStrings["No Application Cache information available"] = "No Application Cache information available";
     644localizedStrings["No Associated Data"] = "No Associated Data";
    641645localizedStrings["No Attributes"] = "No Attributes";
    642646localizedStrings["No Audits"] = "No Audits";
     
    647651localizedStrings["No Chart Available"] = "No Chart Available";
    648652localizedStrings["No Child Layers"] = "No Child Layers";
     653localizedStrings["No Data Bindings"] = "No Data Bindings";
    649654localizedStrings["No Entries"] = "No Entries";
    650655localizedStrings["No Event Listeners"] = "No Event Listeners";
  • trunk/Source/WebInspectorUI/UserInterface/Views/DOMNodeDetailsSidebarPanel.css

    r239760 r242386  
    6767    }
    6868}
     69
     70.sidebar > .panel.dom-node-details .details-section.dom-node-associated-data > .content .row {
     71    -webkit-margin-start: 6px;
     72    margin-bottom: 4px;
     73}
  • trunk/Source/WebInspectorUI/UserInterface/Views/DOMNodeDetailsSidebarPanel.js

    r236766 r242386  
    102102        this.contentView.element.appendChild(propertiesSection.element);
    103103        this.contentView.element.appendChild(eventListenersSection.element);
     104
     105        if (WI.sharedApp.hasExtraDomains) {
     106            if (InspectorBackend.domains.DOM.getDataBindingsForNode) {
     107                this._dataBindingsSection = new WI.DetailsSection("dom-node-data-bindings", WI.UIString("Data Bindings"), []);
     108                this.contentView.element.appendChild(this._dataBindingsSection.element);
     109            }
     110
     111            if (InspectorBackend.domains.DOM.getAssociatedDataForNode) {
     112                this._associatedDataGrid = new WI.DetailsSectionRow(WI.UIString("No Associated Data"));
     113
     114                let associatedDataGroup = new WI.DetailsSectionGroup([this._associatedDataGrid]);
     115
     116                let associatedSection = new WI.DetailsSection("dom-node-associated-data", WI.UIString("Associated Data"), [associatedDataGroup]);
     117                this.contentView.element.appendChild(associatedSection.element);
     118            }
     119        }
    104120
    105121        if (this._accessibilitySupported()) {
     
    149165        this._refreshProperties();
    150166        this._refreshEventListeners();
     167        this._refreshDataBindings();
     168        this._refreshAssociatedData();
    151169        this._refreshAccessibility();
    152170    }
     
    229247
    230248        let domNode = this.domNode;
    231         RuntimeAgent.releaseObjectGroup(WI.DOMNodeDetailsSidebarPanel.PropertiesObjectGroupName);
    232 
    233         WI.RemoteObject.resolveNode(domNode, WI.DOMNodeDetailsSidebarPanel.PropertiesObjectGroupName).then((object) => {
     249
     250        const objectGroup = "dom-node-details-sidebar-properties-object-group";
     251        RuntimeAgent.releaseObjectGroup(objectGroup);
     252
     253        WI.RemoteObject.resolveNode(domNode, objectGroup).then((object) => {
    234254            // Bail if the DOM node changed while we were waiting for the async response.
    235255            if (this.domNode !== domNode)
     
    410430
    411431        domNode.getEventListeners(eventListenersCallback.bind(this));
     432    }
     433
     434    _refreshDataBindings()
     435    {
     436        if (!this._dataBindingsSection)
     437            return;
     438
     439        let domNode = this.domNode;
     440        if (!domNode)
     441            return;
     442
     443        DOMAgent.getDataBindingsForNode(this.domNode.id).then(({dataBindings}) => {
     444            if (this.domNode !== domNode)
     445                return;
     446
     447            if (!dataBindings.length) {
     448                let emptyRow = new WI.DetailsSectionRow(WI.UIString("No Data Bindings"));
     449                emptyRow.showEmptyMessage();
     450                this._dataBindingsSection.groups = [new WI.DetailsSectionGroup([emptyRow])];
     451                return;
     452            }
     453
     454            let groups = [];
     455            for (let {binding, type, value} of dataBindings) {
     456                groups.push(new WI.DetailsSectionGroup([
     457                    new WI.DetailsSectionSimpleRow(WI.UIString("Binding"), binding),
     458                    new WI.DetailsSectionSimpleRow(WI.UIString("Type"), type),
     459                    new WI.DetailsSectionSimpleRow(WI.UIString("Value"), value),
     460                ]));
     461            }
     462            this._dataBindingsSection.groups = groups;
     463        });
     464    }
     465
     466    _refreshAssociatedData()
     467    {
     468        if (!this._associatedDataGrid)
     469            return;
     470
     471        const objectGroup = "dom-node-details-sidebar-associated-data-object-group";
     472        RuntimeAgent.releaseObjectGroup(objectGroup);
     473
     474        let domNode = this.domNode;
     475        if (!domNode)
     476            return;
     477
     478        DOMAgent.getAssociatedDataForNode(domNode.id).then(({associatedData}) => {
     479            if (this.domNode !== domNode)
     480                return;
     481
     482            if (!associatedData) {
     483                this._associatedDataGrid.showEmptyMessage();
     484                return;
     485            }
     486
     487            let expression = associatedData;
     488            const options = {
     489                objectGroup,
     490                doNotPauseOnExceptionsAndMuteConsole: true,
     491            };
     492            WI.runtimeManager.evaluateInInspectedWindow(expression, options, (result, wasThrown) => {
     493                console.assert(!wasThrown);
     494
     495                if (!result) {
     496                    this._associatedDataGrid.showEmptyMessage();
     497                    return;
     498                }
     499
     500                this._associatedDataGrid.hideEmptyMessage();
     501
     502                const propertyPath = null;
     503                const forceExpanding = true;
     504                let element = WI.FormattedValue.createObjectTreeOrFormattedValueForRemoteObject(result, propertyPath, forceExpanding);
     505
     506                let objectTree = element.__objectTree;
     507                if (objectTree) {
     508                    objectTree.showOnlyProperties();
     509                    objectTree.expand();
     510                }
     511
     512                this._associatedDataGrid.element.appendChild(element);
     513            });
     514        });
    412515    }
    413516
     
    768871        this._refreshAttributes();
    769872        this._refreshAccessibility();
     873        this._refreshDataBindings();
    770874    }
    771875
     
    847951    Node: "node",
    848952};
    849 
    850 WI.DOMNodeDetailsSidebarPanel.PropertiesObjectGroupName = "dom-node-details-sidebar-properties-object-group";
  • trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreeView.js

    r242076 r242386  
    5252
    5353        this._element = document.createElement("div");
     54        this._element.__objectTree = this;
    5455        this._element.className = "object-tree";
    5556
Note: See TracChangeset for help on using the changeset viewer.