Changeset 93398 in webkit
- Timestamp:
- Aug 19, 2011 5:50:29 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r93397 r93398 1 2011-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 1 15 2011-08-19 Anton Muhin <antonm@chromium.org> 2 16 -
trunk/Source/WebCore/inspector/Inspector.json
r93396 r93398 872 872 ], 873 873 "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."883 874 } 884 875 ], … … 1099 1090 "name": "getAttributes", 1100 1091 "parameters": [ 1101 { "name": "nodeId s", "type": "array", "items": { "$ref": "NodeId" }, "description": "Ids of the nodesto 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." } 1105 1096 ], 1106 1097 "description": "Returns attributes for the specified nodes." -
trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp
r93396 r93398 1081 1081 } 1082 1082 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 } 1083 void 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); 1098 1090 } 1099 1091 -
trunk/Source/WebCore/inspector/InspectorDOMAgent.h
r93396 r93398 129 129 void cancelSearch(ErrorString*); 130 130 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); 132 132 void setInspectModeEnabled(ErrorString*, bool enabled); 133 133 void requestNode(ErrorString*, const String& objectId, int* nodeId); -
trunk/Source/WebCore/inspector/front-end/DOMAgent.js
r93396 r93398 447 447 _loadNodeAttributes: function() 448 448 { 449 function callback(node Attributes)449 function callback(nodeId, attributes) 450 450 { 451 if (! nodeAttributes)451 if (!attributes) 452 452 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); 457 456 this.dispatchEventToListeners(WebInspector.DOMAgent.Events.AttrModified, node); 458 457 } … … 461 460 delete this._loadNodeAttributesTimeout; 462 461 463 var nodeIds = [];464 462 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))); 467 464 this._attributeLoadNodeIds = {}; 468 465 },
Note: See TracChangeset
for help on using the changeset viewer.