Changeset 93398 in webkit


Ignore:
Timestamp:
Aug 19, 2011 5:50:29 AM (13 years ago)
Author:
pfeldman@chromium.org
Message:

Web Inspector: getAttributes should work on a single node, not array.
https://bugs.webkit.org/show_bug.cgi?id=66544

Reviewed by Adam Roben.

  • inspector/Inspector.json:
  • inspector/InspectorDOMAgent.cpp:

(WebCore::InspectorDOMAgent::getAttributes):

  • inspector/InspectorDOMAgent.h:
  • inspector/front-end/DOMAgent.js:

(WebInspector.DOMAgent.prototype._loadNodeAttributes):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r93397 r93398  
     12011-08-19  Pavel Feldman  <pfeldman@google.com>
     2
     3        Web Inspector: getAttributes should work on a single node, not array.
     4        https://bugs.webkit.org/show_bug.cgi?id=66544
     5
     6        Reviewed by Adam Roben.
     7
     8        * inspector/Inspector.json:
     9        * inspector/InspectorDOMAgent.cpp:
     10        (WebCore::InspectorDOMAgent::getAttributes):
     11        * inspector/InspectorDOMAgent.h:
     12        * inspector/front-end/DOMAgent.js:
     13        (WebInspector.DOMAgent.prototype._loadNodeAttributes):
     14
    1152011-08-19  Anton Muhin  <antonm@chromium.org>
    216
  • trunk/Source/WebCore/inspector/Inspector.json

    r93396 r93398  
    872872                ],
    873873                "description": "DOM interaction is implemented in terms of mirror objects that represent the actual DOM nodes. DOMNode is a base node mirror type."
    874             },
    875             {
    876                 "id": "Attributes",
    877                 "type": "object",
    878                 "properties": [
    879                     { "name": "id", "$ref": "NodeId", "description": "Element id to get attributes for." },
    880                     { "name": "attributes", "type": "array", "items": { "type": "string" }, "description": "An interleaved array of node attribute names and values." }
    881                 ],
    882                 "description": "A holder structure for all attributes of a single node."
    883874            }
    884875        ],
     
    10991090                "name": "getAttributes",
    11001091                "parameters": [
    1101                     { "name": "nodeIds", "type": "array", "items": { "$ref": "NodeId" }, "description": "Ids of the nodes to retrieve attibutes for." }
    1102                 ],
    1103                 "returns": [
    1104                     { "name": "attributes", "type": "array", "items": { "type": "Attributes" }, "description": "Attribute holders for the requested nodes." }
     1092                    { "name": "nodeId", "$ref": "NodeId", "description": "Id of the node to retrieve attibutes for." }
     1093                ],
     1094                "returns": [
     1095                    { "name": "attributes", "type": "array", "items": { "type": "string" }, "description": "An interleaved array of node attribute names and values." }
    11051096                ],
    11061097                "description": "Returns attributes for the specified nodes."
  • trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp

    r93396 r93398  
    10811081}
    10821082
    1083 void InspectorDOMAgent::getAttributes(ErrorString*, const RefPtr<InspectorArray>& nodeIds, RefPtr<InspectorArray>* result)
    1084 {
    1085     for (unsigned i = 0, size = nodeIds->length(); i < size; ++i) {
    1086         RefPtr<InspectorValue> nodeIdValue = nodeIds->get(i);
    1087         int nodeId;
    1088         if (!nodeIdValue->asNumber(&nodeId))
    1089             continue;
    1090         Node* node = nodeForId(nodeId);
    1091         if (node && node->isElementNode()) {
    1092             RefPtr<InspectorObject> entry = InspectorObject::create();
    1093             entry->setNumber("nodeId", nodeId);
    1094             entry->setArray("attributes", buildArrayForElementAttributes(static_cast<Element*>(node)));
    1095             (*result)->pushObject(entry.release());
    1096         }
    1097     }
     1083void InspectorDOMAgent::getAttributes(ErrorString* errorString, int nodeId, RefPtr<InspectorArray>* result)
     1084{
     1085    Element* element = assertElement(errorString, nodeId);
     1086    if (!element)
     1087        return;
     1088
     1089    *result = buildArrayForElementAttributes(element);
    10981090}
    10991091
  • trunk/Source/WebCore/inspector/InspectorDOMAgent.h

    r93396 r93398  
    129129    void cancelSearch(ErrorString*);
    130130    void resolveNode(ErrorString*, int nodeId, const String* const objectGroup, RefPtr<InspectorObject>* result);
    131     void getAttributes(ErrorString*, const RefPtr<InspectorArray>& nodeIds, RefPtr<InspectorArray>* result);
     131    void getAttributes(ErrorString*, int nodeId, RefPtr<InspectorArray>* result);
    132132    void setInspectModeEnabled(ErrorString*, bool enabled);
    133133    void requestNode(ErrorString*, const String& objectId, int* nodeId);
  • trunk/Source/WebCore/inspector/front-end/DOMAgent.js

    r93396 r93398  
    447447    _loadNodeAttributes: function()
    448448    {
    449         function callback(nodeAttributes)
     449        function callback(nodeId, attributes)
    450450        {
    451             if (!nodeAttributes)
     451            if (!attributes)
    452452                return;
    453             for (var i = 0; i < nodeAttributes.length; ++i) {
    454                 var entry = nodeAttributes[i];
    455                 var node = this._idToDOMNode[entry.nodeId];
    456                 node._setAttributesPayload(entry.attributes);
     453            var node = this._idToDOMNode[nodeId];
     454            if (node) {
     455                node._setAttributesPayload(attributes);
    457456                this.dispatchEventToListeners(WebInspector.DOMAgent.Events.AttrModified, node);
    458457            }
     
    461460        delete this._loadNodeAttributesTimeout;
    462461
    463         var nodeIds = [];
    464462        for (var nodeId in this._attributeLoadNodeIds)
    465             nodeIds.push(Number(nodeId));
    466         DOMAgent.getAttributes(nodeIds, this._wrapClientCallback(callback.bind(this)));
     463            DOMAgent.getAttributes(parseInt(nodeId), this._wrapClientCallback(callback.bind(this, nodeId)));
    467464        this._attributeLoadNodeIds = {};
    468465    },
Note: See TracChangeset for help on using the changeset viewer.