Web Inspector: rename distanceToWindow to distance
authoryurys@chromium.org <yurys@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Dec 2012 09:26:02 +0000 (09:26 +0000)
committeryurys@chromium.org <yurys@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Dec 2012 09:26:02 +0000 (09:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=105823

Reviewed by Pavel Feldman.

PerformanceTests:

Updated heap profiler performance test after renaming distanceToWindow to distance.

* inspector/heap-snapshot-performance-test.js:

Source/WebCore:

Renamed distanceToWindow to distance. Introduced a method on HeapSnapshot
that allows to check if given node should be displayed to the user as having
distance 1.

* inspector/front-end/HeapSnapshot.js:
(WebInspector.HeapSnapshotEdge.prototype.serialize):
(WebInspector.HeapSnapshotRetainerEdge.prototype.serialize):
(WebInspector.HeapSnapshotNode.prototype.distance):
(WebInspector.HeapSnapshotNode.prototype.serialize):
(WebInspector.HeapSnapshot.prototype._init):
(WebInspector.HeapSnapshot.prototype.dispose):
(WebInspector.HeapSnapshot.prototype.canHaveDistanceOne):
(WebInspector.HeapSnapshot.prototype._calculateDistances):
(WebInspector.HeapSnapshot.prototype._bfs):
(WebInspector.HeapSnapshot.prototype._buildAggregates):
* inspector/front-end/HeapSnapshotDataGrids.js:
(WebInspector.HeapSnapshotRetainmentDataGrid):
(WebInspector.HeapSnapshotRetainmentDataGrid.prototype._sortFields):
(WebInspector.HeapSnapshotConstructorsDataGrid):
(WebInspector.HeapSnapshotConstructorsDataGrid.prototype._sortFields):
* inspector/front-end/HeapSnapshotGridNodes.js:
(WebInspector.HeapSnapshotGenericObjectNode):
(WebInspector.HeapSnapshotGenericObjectNode.prototype.get data):
(WebInspector.HeapSnapshotObjectNode):
(WebInspector.HeapSnapshotObjectNode.prototype.comparator):
(WebInspector.HeapSnapshotObjectNode.prototype._enhanceData):
(WebInspector.HeapSnapshotInstanceNode.prototype.comparator):
(WebInspector.HeapSnapshotConstructorNode):
(WebInspector.HeapSnapshotConstructorNode.prototype.comparator):
(WebInspector.HeapSnapshotConstructorNode.prototype.get data):
* inspector/front-end/JSHeapSnapshot.js:
(WebInspector.JSHeapSnapshot.prototype.canHaveDistanceOne):

LayoutTests:

Updated tests after renaming distanceToWindow to distance.

* inspector/profiler/heap-snapshot-summary-sorting-fields.html:
* inspector/profiler/heap-snapshot-summary-sorting-instances.html:
* inspector/profiler/heap-snapshot-summary-sorting.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@138528 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/inspector/profiler/heap-snapshot-summary-sorting-fields.html
LayoutTests/inspector/profiler/heap-snapshot-summary-sorting-instances.html
LayoutTests/inspector/profiler/heap-snapshot-summary-sorting.html
PerformanceTests/ChangeLog
PerformanceTests/inspector/heap-snapshot-performance-test.js
Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/HeapSnapshot.js
Source/WebCore/inspector/front-end/HeapSnapshotDataGrids.js
Source/WebCore/inspector/front-end/HeapSnapshotGridNodes.js
Source/WebCore/inspector/front-end/JSHeapSnapshot.js

index ff01d5d..b66c912 100644 (file)
@@ -1,3 +1,16 @@
+2012-12-28  Yury Semikhatsky  <yurys@chromium.org>
+
+        Web Inspector: rename distanceToWindow to distance
+        https://bugs.webkit.org/show_bug.cgi?id=105823
+
+        Reviewed by Pavel Feldman.
+
+        Updated tests after renaming distanceToWindow to distance.
+
+        * inspector/profiler/heap-snapshot-summary-sorting-fields.html:
+        * inspector/profiler/heap-snapshot-summary-sorting-instances.html:
+        * inspector/profiler/heap-snapshot-summary-sorting.html:
+
 2012-12-28  Andrey Lushnikov  <lushnikov@chromium.com>
 
         Web Inspector: refactor DefaultTextEditor's private methods
index 820dbe0..a32ed45 100644 (file)
@@ -65,7 +65,7 @@ function test()
                 var columnName = columns[currentColumn].identifier;
                 var contents = windowRow.children.map(function(obj) { return JSON.stringify(obj.data[columnName]); });
                 InspectorTest.assertEquals(instanceCount, contents.length, "column contents");
-                var sortTypes = { object: "text", distanceToWindow: "number", count: "number", shallowSize: "size", retainedSize: "size" };
+                var sortTypes = { object: "text", distance: "number", count: "number", shallowSize: "size", retainedSize: "size" };
                 InspectorTest.assertEquals(true, !!sortTypes[columns[currentColumn].identifier], "sort by identifier");
                 InspectorTest.checkArrayIsSorted(contents, sortTypes[columns[currentColumn].identifier], columns[currentColumn].sort);
 
index 4b3c84a..0a25559 100644 (file)
@@ -59,7 +59,7 @@ function test()
                 InspectorTest.assertEquals(true, !!row, "\"B\" row");
                 var contents = row.children.map(function(obj) { return JSON.stringify(obj.data[columnName]); });
                 InspectorTest.assertEquals(instanceCount, contents.length, "column contents");
-                var sortTypes = { object: "text", distanceToWindow: "number", count: "number", shallowSize: "size", retainedSize: "size" };
+                var sortTypes = { object: "text", distance: "number", count: "number", shallowSize: "size", retainedSize: "size" };
                 InspectorTest.assertEquals(true, !!sortTypes[columns[currentColumn].identifier], "sort by identifier");
                 InspectorTest.checkArrayIsSorted(contents, sortTypes[columns[currentColumn].identifier], columns[currentColumn].sort);
 
index d6c1235..adaf269 100644 (file)
@@ -49,7 +49,7 @@ function test()
                 columns[currentColumn] = newColumnState;
                 var contents = InspectorTest.columnContents(columns[currentColumn]);
                 InspectorTest.assertEquals(true, !!contents.length, "column contents");
-                var sortTypes = { object: "text", distanceToWindow: "number", count: "number", shallowSize: "size", retainedSize: "size" };
+                var sortTypes = { object: "text", distance: "number", count: "number", shallowSize: "size", retainedSize: "size" };
                 InspectorTest.assertEquals(true, !!sortTypes[columns[currentColumn].identifier], "sort by identifier");
                 InspectorTest.checkArrayIsSorted(contents, sortTypes[columns[currentColumn].identifier], columns[currentColumn].sort);
 
index 739b9df..d0d753b 100644 (file)
@@ -1,3 +1,14 @@
+2012-12-28  Yury Semikhatsky  <yurys@chromium.org>
+
+        Web Inspector: rename distanceToWindow to distance
+        https://bugs.webkit.org/show_bug.cgi?id=105823
+
+        Reviewed by Pavel Feldman.
+
+        Updated heap profiler performance test after renaming distanceToWindow to distance.
+
+        * inspector/heap-snapshot-performance-test.js:
+
 2012-12-18  Hayato Ito  <hayato@chromium.org>
 
         Use element.webkitCreateShadowRoot instead of WebKitShadowRoot in PerformanceTests.
index 642c76d..2286486 100644 (file)
@@ -7,7 +7,7 @@ function test()
     InspectorTest.measureFunction(WebInspector.HeapSnapshot.prototype, "_calculateFlags");
     InspectorTest.measureFunction(WebInspector.HeapSnapshot.prototype, "_buildAggregates");
     InspectorTest.measureFunction(WebInspector.HeapSnapshot.prototype, "_calculateClassesRetainedSize");
-    InspectorTest.measureFunction(WebInspector.HeapSnapshot.prototype, "_calculateObjectToWindowDistance");
+    InspectorTest.measureFunction(WebInspector.HeapSnapshot.prototype, "_calculateDistances");
     InspectorTest.measureFunction(WebInspector.HeapSnapshot.prototype, "_calculateRetainedSizes");
     InspectorTest.measureFunction(WebInspector.HeapSnapshot.prototype, "_markDetachedDOMTreeNodes");
     InspectorTest.measureFunction(WebInspector.HeapSnapshot.prototype, "_markQueriableHeapObjects");
index 93fa0d8..e0aa23c 100644 (file)
@@ -1,3 +1,43 @@
+2012-12-28  Yury Semikhatsky  <yurys@chromium.org>
+
+        Web Inspector: rename distanceToWindow to distance
+        https://bugs.webkit.org/show_bug.cgi?id=105823
+
+        Reviewed by Pavel Feldman.
+
+        Renamed distanceToWindow to distance. Introduced a method on HeapSnapshot
+        that allows to check if given node should be displayed to the user as having
+        distance 1.
+
+        * inspector/front-end/HeapSnapshot.js:
+        (WebInspector.HeapSnapshotEdge.prototype.serialize):
+        (WebInspector.HeapSnapshotRetainerEdge.prototype.serialize):
+        (WebInspector.HeapSnapshotNode.prototype.distance):
+        (WebInspector.HeapSnapshotNode.prototype.serialize):
+        (WebInspector.HeapSnapshot.prototype._init):
+        (WebInspector.HeapSnapshot.prototype.dispose):
+        (WebInspector.HeapSnapshot.prototype.canHaveDistanceOne):
+        (WebInspector.HeapSnapshot.prototype._calculateDistances):
+        (WebInspector.HeapSnapshot.prototype._bfs):
+        (WebInspector.HeapSnapshot.prototype._buildAggregates):
+        * inspector/front-end/HeapSnapshotDataGrids.js:
+        (WebInspector.HeapSnapshotRetainmentDataGrid):
+        (WebInspector.HeapSnapshotRetainmentDataGrid.prototype._sortFields):
+        (WebInspector.HeapSnapshotConstructorsDataGrid):
+        (WebInspector.HeapSnapshotConstructorsDataGrid.prototype._sortFields):
+        * inspector/front-end/HeapSnapshotGridNodes.js:
+        (WebInspector.HeapSnapshotGenericObjectNode):
+        (WebInspector.HeapSnapshotGenericObjectNode.prototype.get data):
+        (WebInspector.HeapSnapshotObjectNode):
+        (WebInspector.HeapSnapshotObjectNode.prototype.comparator):
+        (WebInspector.HeapSnapshotObjectNode.prototype._enhanceData):
+        (WebInspector.HeapSnapshotInstanceNode.prototype.comparator):
+        (WebInspector.HeapSnapshotConstructorNode):
+        (WebInspector.HeapSnapshotConstructorNode.prototype.comparator):
+        (WebInspector.HeapSnapshotConstructorNode.prototype.get data):
+        * inspector/front-end/JSHeapSnapshot.js:
+        (WebInspector.JSHeapSnapshot.prototype.canHaveDistanceOne):
+
 2012-12-28  Andrey Lushnikov  <lushnikov@chromium.com>
 
         Web Inspector: refactor DefaultTextEditor's private methods
index d89692d..2487d8f 100644 (file)
@@ -112,7 +112,7 @@ WebInspector.HeapSnapshotEdge.prototype = {
             node: node.serialize(),
             nodeIndex: this.nodeIndex(),
             type: this.type(),
-            distanceToWindow: node.distanceToWindow()
+            distance: node.distance()
         };
     },
 
@@ -254,7 +254,7 @@ WebInspector.HeapSnapshotRetainerEdge.prototype = {
             node: node.serialize(),
             nodeIndex: this.nodeIndex(),
             type: this.type(),
-            distanceToWindow: node.distanceToWindow()
+            distance: node.distance()
         };
     },
 
@@ -321,9 +321,9 @@ WebInspector.HeapSnapshotNode.prototype = {
         return true;
     },
 
-    distanceToWindow: function()
+    distance: function()
     {
-        return this._snapshot._distancesToWindow[this.nodeIndex / this._snapshot._nodeFieldCount];
+        return this._snapshot._nodeDistances[this.nodeIndex / this._snapshot._nodeFieldCount];
     },
 
     className: function()
@@ -399,7 +399,7 @@ WebInspector.HeapSnapshotNode.prototype = {
         return {
             id: this.id(),
             name: this.name(),
-            distanceToWindow: this.distanceToWindow(),
+            distance: this.distance(),
             nodeIndex: this.nodeIndex,
             retainedSize: this.retainedSize(),
             selfSize: this.selfSize(),
@@ -569,7 +569,7 @@ WebInspector.HeapSnapshot.prototype = {
         this._markInvisibleEdges();
         this._buildRetainers();
         this._calculateFlags();
-        this._calculateObjectToWindowDistance();
+        this._calculateDistances();
         var result = this._buildPostOrderIndex();
         // Actually it is array that maps node ordinal number to dominator node ordinal number.
         this._dominatorsTree = this._buildDominatorTree(result.postOrderIndex2NodeOrdinal, result.nodeOrdinal2PostOrderIndex);
@@ -670,7 +670,7 @@ WebInspector.HeapSnapshot.prototype = {
         }
         delete this._dominatedNodes;
         delete this._firstDominatedNodeIndex;
-        delete this._distancesToWindow;
+        delete this._nodeDistances;
         delete this._dominatorsTree;
     },
 
@@ -775,7 +775,12 @@ WebInspector.HeapSnapshot.prototype = {
         return this._aggregatesForDiff;
     },
 
-    _calculateObjectToWindowDistance: function()
+    canHaveDistanceOne: function(node)
+    {
+        return true;
+    },
+
+    _calculateDistances: function()
     {
         var nodeFieldCount = this._nodeFieldCount;
         var distances = new Uint32Array(this.nodeCount);
@@ -785,7 +790,7 @@ WebInspector.HeapSnapshot.prototype = {
         var nodesToVisitLength = 0;
         for (var iter = this.rootNode().edges(); iter.hasNext(); iter.next()) {
             var node = iter.edge.node();
-            if (node.isWindow()) {
+            if (this.canHaveDistanceOne(node)) {
                 nodesToVisit[nodesToVisitLength++] = node.nodeIndex;
                 distances[node.nodeIndex / nodeFieldCount] = 1;
             }
@@ -797,7 +802,7 @@ WebInspector.HeapSnapshot.prototype = {
         nodesToVisit[nodesToVisitLength++] = this._rootNodeIndex;
         distances[this._rootNodeIndex / nodeFieldCount] = 1;
         this._bfs(nodesToVisit, nodesToVisitLength, distances);
-        this._distancesToWindow = distances;
+        this._nodeDistances = distances;
     },
 
     _bfs: function(nodesToVisit, nodesToVisitLength, distances)
@@ -813,7 +818,6 @@ WebInspector.HeapSnapshot.prototype = {
         var nodeCount = this.nodeCount;
         var containmentEdgesLength = containmentEdges.length;
         var edgeWeakType = this._edgeWeakType;
-        var edgeShortcutType = this._edgeShortcutType;
 
         var index = 0;
         while (index < nodesToVisitLength) {
@@ -853,7 +857,7 @@ WebInspector.HeapSnapshot.prototype = {
         var selfSizeOffset = this._nodeSelfSizeOffset;
         var nodeTypeOffset = this._nodeTypeOffset;
         var node = this.rootNode();
-        var distancesToWindow = this._distancesToWindow;
+        var nodeDistances = this._nodeDistances;
 
         for (var nodeIndex = 0; nodeIndex < nodesLength; nodeIndex += nodeFieldCount) {
             var nodeOrdinal = nodeIndex / nodeFieldCount;
@@ -871,7 +875,7 @@ WebInspector.HeapSnapshot.prototype = {
                 var nameMatters = nodeType === "object" || nodeType === "native";
                 var value = {
                     count: 1,
-                    distanceToWindow: distancesToWindow[nodeOrdinal],
+                    distance: nodeDistances[nodeOrdinal],
                     self: selfSize,
                     maxRet: 0,
                     type: nodeType,
@@ -883,7 +887,7 @@ WebInspector.HeapSnapshot.prototype = {
                 aggregatesByClassName[node.className()] = value;
             } else {
                 var clss = aggregates[classIndex];
-                clss.distanceToWindow = Math.min(clss.distanceToWindow, distancesToWindow[nodeOrdinal]);
+                clss.distance = Math.min(clss.distance, nodeDistances[nodeOrdinal]);
                 ++clss.count;
                 clss.self += selfSize;
                 clss.idxs.push(nodeIndex);
index 8cd22d6..11b349a 100644 (file)
@@ -467,7 +467,7 @@ WebInspector.HeapSnapshotRetainmentDataGrid = function()
         object: { title: WebInspector.UIString("Object"), disclosure: true, sortable: true },
         shallowSize: { title: WebInspector.UIString("Shallow Size"), width: "120px", sortable: true },
         retainedSize: { title: WebInspector.UIString("Retained Size"), width: "120px", sortable: true },
-        distanceToWindow: { title: WebInspector.UIString("Distance"), width: "80px", sortable: true, sort: "ascending" }
+        distance: { title: WebInspector.UIString("Distance"), width: "80px", sortable: true, sort: "ascending" }
     };
     WebInspector.HeapSnapshotContainmentDataGrid.call(this, columns);
 }
@@ -480,7 +480,7 @@ WebInspector.HeapSnapshotRetainmentDataGrid.prototype = {
             count: ["_count", sortAscending, "_name", true],
             shallowSize: ["_shallowSize", sortAscending, "_name", true],
             retainedSize: ["_retainedSize", sortAscending, "_name", true],
-            distanceToWindow: ["_distanceToWindow", sortAscending, "_name", true]
+            distance: ["_distance", sortAscending, "_name", true]
         }[sortColumn];
     },
 
@@ -502,7 +502,7 @@ WebInspector.HeapSnapshotConstructorsDataGrid = function()
 {
     var columns = {
         object: { title: WebInspector.UIString("Constructor"), disclosure: true, sortable: true },
-        distanceToWindow: { title: WebInspector.UIString("Distance"), width: "90px", sortable: true },
+        distance: { title: WebInspector.UIString("Distance"), width: "90px", sortable: true },
         count: { title: WebInspector.UIString("Objects Count"), width: "90px", sortable: true },
         shallowSize: { title: WebInspector.UIString("Shallow Size"), width: "120px", sortable: true },
         retainedSize: { title: WebInspector.UIString("Retained Size"), width: "120px", sort: "descending", sortable: true }
@@ -519,7 +519,7 @@ WebInspector.HeapSnapshotConstructorsDataGrid.prototype = {
     {
         return {
             object: ["_name", sortAscending, "_count", false],
-            distanceToWindow: ["_distanceToWindow", sortAscending, "_retainedSize", true],
+            distance: ["_distance", sortAscending, "_retainedSize", true],
             count: ["_count", sortAscending, "_name", true],
             shallowSize: ["_shallowSize", sortAscending, "_name", true],
             retainedSize: ["_retainedSize", sortAscending, "_name", true]
index 1c9e97a..650caa2 100644 (file)
@@ -351,7 +351,7 @@ WebInspector.HeapSnapshotGenericObjectNode = function(tree, node)
         return;
     this._name = node.name;
     this._type = node.type;
-    this._distanceToWindow = node.distanceToWindow;
+    this._distance = node.distance;
     this._shallowSize = node.selfSize;
     this._retainedSize = node.retainedSize;
     this.snapshotNodeId = node.id;
@@ -444,7 +444,7 @@ WebInspector.HeapSnapshotGenericObjectNode.prototype = {
             valueStyle += " detached-dom-tree-node";
         data["object"] = { valueStyle: valueStyle, value: value, nodeId: this.snapshotNodeId };
 
-        data["distanceToWindow"] =  this._distanceToWindow;
+        data["distance"] =  this._distance;
         data["shallowSize"] = Number.withThousandsSeparator(this._shallowSize);
         data["retainedSize"] = Number.withThousandsSeparator(this._retainedSize);
         data["shallowSize-percent"] = this._toPercentString(this._shallowSizePercent);
@@ -521,7 +521,7 @@ WebInspector.HeapSnapshotObjectNode = function(tree, isFromBaseSnapshot, edge, p
     WebInspector.HeapSnapshotGenericObjectNode.call(this, tree, edge.node);
     this._referenceName = edge.name;
     this._referenceType = edge.type;
-    this._distanceToWindow = edge.distanceToWindow;
+    this._distance = edge.distance;
     this.showRetainingEdges = tree.showRetainingEdges;
     this._isFromBaseSnapshot = isFromBaseSnapshot;
 
@@ -588,7 +588,7 @@ WebInspector.HeapSnapshotObjectNode.prototype = {
             count: ["!edgeName", true, "retainedSize", false],
             shallowSize: ["selfSize", sortAscending, "!edgeName", true],
             retainedSize: ["retainedSize", sortAscending, "!edgeName", true],
-            distanceToWindow: ["distanceToWindow", sortAscending, "_name", true]
+            distance: ["distance", sortAscending, "_name", true]
         }[sortColumnIdentifier] || ["!edgeName", true, "retainedSize", false];
         return WebInspector.HeapSnapshotFilteredOrderedIterator.prototype.createComparator(sortFields);
     },
@@ -617,7 +617,7 @@ WebInspector.HeapSnapshotObjectNode.prototype = {
         }
         data["object"].nameClass = nameClass;
         data["object"].name = name;
-        data["distanceToWindow"] = this._distanceToWindow;
+        data["distance"] = this._distance;
         return data;
     },
 
@@ -685,7 +685,7 @@ WebInspector.HeapSnapshotInstanceNode.prototype = {
         var sortColumnIdentifier = this._dataGrid.sortColumnIdentifier;
         var sortFields = {
             object: ["!edgeName", sortAscending, "retainedSize", false],
-            distanceToWindow: ["distanceToWindow", sortAscending, "retainedSize", false],
+            distance: ["distance", sortAscending, "retainedSize", false],
             count: ["!edgeName", true, "retainedSize", false],
             addedSize: ["selfSize", sortAscending, "!edgeName", true],
             removedSize: ["selfSize", sortAscending, "!edgeName", true],
@@ -733,7 +733,7 @@ WebInspector.HeapSnapshotConstructorNode = function(tree, className, aggregate,
     WebInspector.HeapSnapshotGridNode.call(this, tree, aggregate.count > 0);
     this._name = className;
     this._aggregatesKey = aggregatesKey;
-    this._distanceToWindow = aggregate.distanceToWindow;
+    this._distance = aggregate.distance;
     this._count = aggregate.count;
     this._shallowSize = aggregate.self;
     this._retainedSize = aggregate.maxRet;
@@ -804,7 +804,7 @@ WebInspector.HeapSnapshotConstructorNode.prototype = {
         var sortColumnIdentifier = this._dataGrid.sortColumnIdentifier;
         var sortFields = {
             object: ["id", sortAscending, "retainedSize", false],
-            distanceToWindow: ["distanceToWindow", true, "retainedSize", false],
+            distance: ["distance", true, "retainedSize", false],
             count: ["id", true, "retainedSize", false],
             shallowSize: ["selfSize", sortAscending, "id", true],
             retainedSize: ["retainedSize", sortAscending, "id", true]
@@ -826,7 +826,7 @@ WebInspector.HeapSnapshotConstructorNode.prototype = {
     {
         var data = { object: this._name };
         data["count"] =  Number.withThousandsSeparator(this._count);
-        data["distanceToWindow"] =  this._distanceToWindow;
+        data["distance"] =  this._distance;
         data["shallowSize"] = Number.withThousandsSeparator(this._shallowSize);
         data["retainedSize"] = Number.withThousandsSeparator(this._retainedSize);
         data["count-percent"] =  this._toPercentString(this._countPercent);
index 9416690..9480ba3 100644 (file)
@@ -102,6 +102,11 @@ WebInspector.JSHeapSnapshot.prototype = {
         this._markPageOwnedNodes();
     },
 
+    canHaveDistanceOne: function(node)
+    {
+        return node.isWindow();
+    },
+
     userObjectsMapAndFlag: function()
     {
         return {
@@ -267,11 +272,6 @@ WebInspector.JSHeapSnapshotNode.prototype = {
         return !!(flags & this._snapshot._nodeFlags.pageObject);
     },
 
-    distanceToWindow: function()
-    {
-        return this._snapshot._distancesToWindow[this.nodeIndex / this._snapshot._nodeFieldCount];
-    },
-
     className: function()
     {
         var type = this.type();