Skip to content

Commit

Permalink
DevTools: mapify WI.DOMNode._markers
Browse files Browse the repository at this point in the history
BUG=none
TBR=dgozman, pfeldman

Review URL: https://codereview.chromium.org/1816233002

Cr-Commit-Position: refs/heads/master@{#382427}
  • Loading branch information
aslushnikov authored and Commit bot committed Mar 21, 2016
1 parent 6f82ec1 commit 5938d5e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,8 @@ InspectorTest.dumpElementsTree = function(rootNode, depth, resultsArray)
function dumpMap(name, map)
{
var result = [];
for (var id in map)
result.push(id + "=" + map[id]);
for (var id of map.keys())
result.push(id + "=" + map.get(id));
if (!result.length)
return "";
return name + ":[" + result.join(",") + "]";
Expand Down
23 changes: 8 additions & 15 deletions third_party/WebKit/Source/devtools/front_end/sdk/DOMModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ WebInspector.DOMNode = function(domModel, doc, isInShadowTree, payload)
if (payload.attributes)
this._setAttributesPayload(payload.attributes);

this._markers = {};
/** @type {!Map<string, ?>} */
this._markers = new Map();
this._subtreeMarkerCount = 0;

this._childNodeCount = payload.childNodeCount || 0;
Expand Down Expand Up @@ -795,22 +796,22 @@ WebInspector.DOMNode.prototype = {
setMarker: function(name, value)
{
if (value === null) {
if (!this._markers.hasOwnProperty(name))
if (!this._markers.has(name))
return;

delete this._markers[name];
this._markers.delete(name);
for (var node = this; node; node = node.parentNode)
--node._subtreeMarkerCount;
for (var node = this; node; node = node.parentNode)
this._domModel.dispatchEventToListeners(WebInspector.DOMModel.Events.MarkersChanged, node);
return;
}

if (this.parentNode && !this._markers.hasOwnProperty(name)) {
if (this.parentNode && !this._markers.has(name)) {
for (var node = this; node; node = node.parentNode)
++node._subtreeMarkerCount;
}
this._markers[name] = value;
this._markers.set(name, value);
for (var node = this; node; node = node.parentNode)
this._domModel.dispatchEventToListeners(WebInspector.DOMModel.Events.MarkersChanged, node);
},
Expand All @@ -822,15 +823,7 @@ WebInspector.DOMNode.prototype = {
*/
marker: function(name)
{
return this._markers[name] || null;
},

/**
* @return {!Array<string>}
*/
markers: function()
{
return Object.values(this._markers);
return this._markers.get(name) || null;
},

/**
Expand All @@ -845,7 +838,7 @@ WebInspector.DOMNode.prototype = {
{
if (!node._subtreeMarkerCount)
return;
for (var marker in node._markers)
for (var marker of node._markers.keys())
visitor(node, marker);
if (!node._children)
return;
Expand Down

0 comments on commit 5938d5e

Please sign in to comment.