Modified: trunk/Source/WebCore/inspector/front-end/HeapSnapshotDataGrids.js (114648 => 114649)
--- trunk/Source/WebCore/inspector/front-end/HeapSnapshotDataGrids.js 2012-04-19 17:07:10 UTC (rev 114648)
+++ trunk/Source/WebCore/inspector/front-end/HeapSnapshotDataGrids.js 2012-04-19 17:11:15 UTC (rev 114649)
@@ -31,16 +31,11 @@
/**
* @constructor
* @extends {WebInspector.DataGrid}
- * @param {boolean=} deferNodeContentCreation
*/
-WebInspector.HeapSnapshotSortableDataGrid = function(columns, deferNodeContentCreation)
+WebInspector.HeapSnapshotSortableDataGrid = function(columns)
{
WebInspector.DataGrid.call(this, columns);
this.addEventListener("sorting changed", this.sortingChanged, this);
-
- this._deferNodeContentCreation = deferNodeContentCreation;
- if (deferNodeContentCreation)
- this.scrollContainer.addEventListener("scroll", this._onScroll.bind(this), true);
}
WebInspector.HeapSnapshotSortableDataGrid.prototype = {
@@ -56,10 +51,15 @@
delete this._lastSortAscending;
},
+ nodesForNameFilter: function()
+ {
+ return this.rootNode().children;
+ },
+
changeNameFilter: function(filter)
{
filter = filter.toLowerCase();
- var children = this.rootNode().children;
+ var children = this.nodesForNameFilter();
for (var i = 0, l = children.length; i < l; ++i) {
var node = children[i];
if (node.depth === 0)
@@ -97,88 +97,181 @@
this._performSorting(SortByTwoFields);
},
+ _performSorting: function(sortFunction)
+ {
+ this.recursiveSortingEnter();
+ var children = this._topLevelNodes;
+ this.rootNode().removeChildren();
+ children.sort(sortFunction);
+ for (var i = 0, l = children.length; i < l; ++i) {
+ var child = children[i];
+ this.appendChildAfterSorting(child);
+ if (child.expanded)
+ child.sort();
+ }
+ this.recursiveSortingLeave();
+ this.updateVisibleNodes();
+ },
+
+ appendChildAfterSorting: function(child)
+ {
+ var revealed = child.revealed;
+ this.rootNode().appendChild(child);
+ child.revealed = revealed;
+ },
+
updateVisibleNodes: function()
{
- if (!this._deferNodeContentCreation)
+ },
+
+ recursiveSortingEnter: function()
+ {
+ if (!("_recursiveSortingDepth" in this))
+ this._recursiveSortingDepth = 1;
+ else
+ ++this._recursiveSortingDepth;
+ },
+
+ recursiveSortingLeave: function()
+ {
+ if (!("_recursiveSortingDepth" in this))
return;
+ if (!--this._recursiveSortingDepth) {
+ delete this._recursiveSortingDepth;
+ this.dispatchEventToListeners("sorting complete");
+ }
+ }
+};
+
+WebInspector.HeapSnapshotSortableDataGrid.prototype.__proto__ = WebInspector.DataGrid.prototype;
+
+
+/**
+ * @constructor
+ * @extends {WebInspector.HeapSnapshotSortableDataGrid}
+ */
+WebInspector.HeapSnapshotViewportDataGrid = function(columns)
+{
+ WebInspector.HeapSnapshotSortableDataGrid.call(this, columns);
+ this.scrollContainer.addEventListener("scroll", this._onScroll.bind(this), true);
+ this._topLevelNodes = [];
+ this._topPadding = new WebInspector.HeapSnapshotPaddingNode();
+ this._bottomPadding = new WebInspector.HeapSnapshotPaddingNode();
+}
+
+WebInspector.HeapSnapshotViewportDataGrid.prototype = {
+ nodesForNameFilter: function()
+ {
+ return this._topLevelNodes;
+ },
+
+ appendChildAfterSorting: function(child)
+ {
+ // Do nothing here, it will be added in updateVisibleNodes.
+ },
+
+ updateVisibleNodes: function()
+ {
var scrollTop = this.scrollContainer.scrollTop;
- var rowHeight = 16;
- var height = this.scrollContainer.offsetHeight;
- var visibleRowsCount = Math.round(height / rowHeight) + 1;
+ var viewPortHeight = this.scrollContainer.offsetHeight;
- var children = this.rootNode().children;
+ this._removePaddingRows();
+ var children = this._topLevelNodes;
+
var i = 0;
+ var topPadding = 0;
while (i < children.length) {
if (children[i].revealed) {
- var top = children[i].element.offsetTop;
- if (top >= scrollTop)
+ var newTop = topPadding + children[i].nodeHeight();
+ if (newTop > scrollTop)
break;
+ topPadding = newTop;
}
++i;
}
- while (i < children.length && visibleRowsCount) {
+ this.rootNode().removeChildren();
+ // The height of the view port + invisible top part.
+ var heightToFill = viewPortHeight + (scrollTop - topPadding);
+ var filledHeight = 0;
+ while (i < children.length && filledHeight < heightToFill) {
if (children[i].revealed) {
- children[i].ensureContentCreated();
- --visibleRowsCount;
+ this.rootNode().appendChild(children[i]);
+ filledHeight += children[i].nodeHeight();
}
++i;
}
+
+ var bottomPadding = 0;
+ while (i < children.length) {
+ bottomPadding += children[i].nodeHeight();
+ ++i;
+ }
+
+ this._addPaddingRows(topPadding, bottomPadding);
},
- onResize: function()
+ appendTopLevelNode: function(node)
{
- this.updateVisibleNodes();
+ this._topLevelNodes.push(node);
},
- _onScroll: function(event)
+ _addPaddingRows: function(top, bottom)
{
- this.updateVisibleNodes();
+ if (this._topPadding.element.parentNode !== this.dataTableBody)
+ this.dataTableBody.insertBefore(this._topPadding.element, this.dataTableBody.firstChild);
+ if (this._bottomPadding.element.parentNode !== this.dataTableBody)
+ this.dataTableBody.insertBefore(this._bottomPadding.element, this.dataTableBody.lastChild);
+ this._topPadding.setHeight(top);
+ this._bottomPadding.setHeight(bottom);
},
- _performSorting: function(sortFunction)
+ _removePaddingRows: function()
{
- this.recursiveSortingEnter();
- var children = this.rootNode().children;
- this.rootNode().removeChildren();
- children.sort(sortFunction);
- for (var i = 0, l = children.length; i < l; ++i) {
- var child = children[i];
- var revealed = child.revealed;
- this.rootNode().appendChild(child);
- child.revealed = revealed;
- if (child.expanded)
- child.sort();
- }
- this.recursiveSortingLeave();
- this.updateVisibleNodes();
+ this._bottomPadding.removeFromTable();
+ this._topPadding.removeFromTable();
},
- recursiveSortingEnter: function()
+ onResize: function()
{
- if (!("_recursiveSortingDepth" in this))
- this._recursiveSortingDepth = 1;
- else
- ++this._recursiveSortingDepth;
+ this.updateVisibleNodes();
},
- recursiveSortingLeave: function()
+ _onScroll: function(event)
{
- if (!("_recursiveSortingDepth" in this))
- return;
- if (!--this._recursiveSortingDepth) {
- delete this._recursiveSortingDepth;
- this.dispatchEventToListeners("sorting complete");
- }
+ this.updateVisibleNodes();
}
-};
+}
-WebInspector.HeapSnapshotSortableDataGrid.prototype.__proto__ = WebInspector.DataGrid.prototype;
+WebInspector.HeapSnapshotViewportDataGrid.prototype.__proto__ = WebInspector.HeapSnapshotSortableDataGrid.prototype;
/**
* @constructor
+ */
+WebInspector.HeapSnapshotPaddingNode = function()
+{
+ this.element = document.createElement("tr");
+ this.element.addStyleClass("revealed");
+}
+
+WebInspector.HeapSnapshotPaddingNode.prototype = {
+ setHeight: function(height)
+ {
+ this.element.style.height = height + "px";
+ },
+ removeFromTable: function()
+ {
+ var parent = this.element.parentNode;
+ if (parent)
+ parent.removeChild(this.element);
+ }
+}
+
+
+/**
+ * @constructor
* @extends {WebInspector.HeapSnapshotSortableDataGrid}
* @param {Object=} columns
*/
@@ -288,7 +381,7 @@
/**
* @constructor
- * @extends {WebInspector.HeapSnapshotSortableDataGrid}
+ * @extends {WebInspector.HeapSnapshotViewportDataGrid}
*/
WebInspector.HeapSnapshotConstructorsDataGrid = function()
{
@@ -299,8 +392,9 @@
shallowSize: { title: WebInspector.UIString("Shallow Size"), width: "120px", sortable: true },
retainedSize: { title: WebInspector.UIString("Retained Size"), width: "120px", sort: "descending", sortable: true }
};
- WebInspector.HeapSnapshotSortableDataGrid.call(this, columns, true);
+ WebInspector.HeapSnapshotViewportDataGrid.call(this, columns);
this._profileIndex = -1;
+ this._topLevelNodes = [];
}
WebInspector.HeapSnapshotConstructorsDataGrid.prototype = {
@@ -330,7 +424,7 @@
function aggregatesReceived(key, aggregates)
{
for (var constructor in aggregates)
- this.rootNode().appendChild(new WebInspector.HeapSnapshotConstructorNode(this, constructor, aggregates[constructor], key));
+ this.appendTopLevelNode(new WebInspector.HeapSnapshotConstructorNode(this, constructor, aggregates[constructor], key));
this.sortingChanged();
}
@@ -361,11 +455,11 @@
};
-WebInspector.HeapSnapshotConstructorsDataGrid.prototype.__proto__ = WebInspector.HeapSnapshotSortableDataGrid.prototype;
+WebInspector.HeapSnapshotConstructorsDataGrid.prototype.__proto__ = WebInspector.HeapSnapshotViewportDataGrid.prototype;
/**
* @constructor
- * @extends {WebInspector.HeapSnapshotSortableDataGrid}
+ * @extends {WebInspector.HeapSnapshotViewportDataGrid}
*/
WebInspector.HeapSnapshotDiffDataGrid = function()
{
@@ -378,7 +472,7 @@
removedSize: { title: WebInspector.UIString("Freed Size"), width: "72px", sortable: true },
sizeDelta: { title: "Size Delta", width: "72px", sortable: true }
};
- WebInspector.HeapSnapshotSortableDataGrid.call(this, columns, true);
+ WebInspector.HeapSnapshotViewportDataGrid.call(this, columns);
}
WebInspector.HeapSnapshotDiffDataGrid.prototype = {
@@ -439,7 +533,7 @@
function addNodeIfNonZeroDiff(boundNode, zeroDiff)
{
if (!zeroDiff)
- this.rootNode().appendChild(boundNode);
+ this.appendTopLevelNode(boundNode);
if (!--nodeCount)
this.sortingChanged();
}
@@ -454,7 +548,7 @@
}
};
-WebInspector.HeapSnapshotDiffDataGrid.prototype.__proto__ = WebInspector.HeapSnapshotSortableDataGrid.prototype;
+WebInspector.HeapSnapshotDiffDataGrid.prototype.__proto__ = WebInspector.HeapSnapshotViewportDataGrid.prototype;
/**
* @constructor
Modified: trunk/Source/WebCore/inspector/front-end/HeapSnapshotGridNodes.js (114648 => 114649)
--- trunk/Source/WebCore/inspector/front-end/HeapSnapshotGridNodes.js 2012-04-19 17:07:10 UTC (rev 114648)
+++ trunk/Source/WebCore/inspector/front-end/HeapSnapshotGridNodes.js 2012-04-19 17:11:15 UTC (rev 114649)
@@ -31,21 +31,19 @@
/**
* @constructor
* @extends {WebInspector.DataGridNode}
+ * @param {WebInspector.HeapSnapshotSortableDataGrid} tree
+ * @param {boolean} hasChildren
*/
WebInspector.HeapSnapshotGridNode = function(tree, hasChildren)
{
WebInspector.DataGridNode.call(this, null, hasChildren);
this._defaultPopulateCount = tree._defaultPopulateCount;
this._provider = null;
+ this._dataGrid = tree;
this.addEventListener("populate", this._populate, this);
}
WebInspector.HeapSnapshotGridNode.prototype = {
- ensureContentCreated: function()
- {
- // May be overriden in descendants with lazy content.
- },
-
createCell: function(columnIdentifier)
{
var cell = WebInspector.DataGridNode.prototype.createCell.call(this, columnIdentifier);
@@ -54,6 +52,12 @@
return cell;
},
+ collapse: function()
+ {
+ WebInspector.DataGridNode.prototype.collapse.call(this);
+ this._dataGrid.updateVisibleNodes();
+ },
+
dispose: function()
{
if (this._provider)
@@ -180,11 +184,11 @@
sort: function()
{
- this.dataGrid.recursiveSortingEnter();
+ this._dataGrid.recursiveSortingEnter();
function afterSort(sorted)
{
if (!sorted) {
- this.dataGrid.recursiveSortingLeave();
+ this._dataGrid.recursiveSortingLeave();
return;
}
this._saveChildren();
@@ -197,7 +201,7 @@
if (child.expanded)
child.sort();
}
- this.dataGrid.recursiveSortingLeave();
+ this._dataGrid.recursiveSortingLeave();
}
this.populateChildren(this._provider, null, null, afterPopulate.bind(this));
}
@@ -211,35 +215,6 @@
* @constructor
* @extends {WebInspector.HeapSnapshotGridNode}
*/
-WebInspector.HeapSnapshotLazyGridNode = function(tree, hasChildren)
-{
- WebInspector.HeapSnapshotGridNode.call(this, tree, hasChildren);
- this._deferContentCreation = true;
-}
-
-WebInspector.HeapSnapshotLazyGridNode.prototype = {
- ensureContentCreated: function()
- {
- if (!this._deferContentCreation)
- return;
- this._deferContentCreation = false;
- this.createCells();
- },
-
- createCells: function()
- {
- if (this._deferContentCreation)
- return;
- WebInspector.HeapSnapshotGridNode.prototype.createCells.call(this);
- }
-};
-
-WebInspector.HeapSnapshotLazyGridNode.prototype.__proto__ = WebInspector.HeapSnapshotGridNode.prototype;
-
-/**
- * @constructor
- * @extends {WebInspector.HeapSnapshotGridNode}
- */
WebInspector.HeapSnapshotGenericObjectNode = function(tree, node)
{
WebInspector.HeapSnapshotGridNode.call(this, tree, false);
@@ -441,7 +416,7 @@
_createChildNode: function(item)
{
- return new WebInspector.HeapSnapshotObjectNode(this.dataGrid, this._isFromBaseSnapshot, item, this);
+ return new WebInspector.HeapSnapshotObjectNode(this._dataGrid, this._isFromBaseSnapshot, item, this);
},
_createProvider: function(snapshot, nodeIndex, tree)
@@ -472,8 +447,8 @@
comparator: function()
{
- var sortAscending = this.dataGrid.sortOrder === "ascending";
- var sortColumnIdentifier = this.dataGrid.sortColumnIdentifier;
+ var sortAscending = this._dataGrid.sortOrder === "ascending";
+ var sortColumnIdentifier = this._dataGrid.sortColumnIdentifier;
var sortFields = {
object: ["!edgeName", sortAscending, "retainedSize", false],
count: ["!edgeName", true, "retainedSize", false],
@@ -546,7 +521,7 @@
WebInspector.HeapSnapshotInstanceNode.prototype = {
_createChildNode: function(item)
{
- return new WebInspector.HeapSnapshotObjectNode(this.dataGrid, this._isDeletedNode, item, null);
+ return new WebInspector.HeapSnapshotObjectNode(this._dataGrid, this._isDeletedNode, item, null);
},
_createProvider: function(snapshot, nodeIndex)
@@ -572,8 +547,8 @@
comparator: function()
{
- var sortAscending = this.dataGrid.sortOrder === "ascending";
- var sortColumnIdentifier = this.dataGrid.sortColumnIdentifier;
+ var sortAscending = this._dataGrid.sortOrder === "ascending";
+ var sortColumnIdentifier = this._dataGrid.sortColumnIdentifier;
var sortFields = {
object: ["!edgeName", sortAscending, "retainedSize", false],
distanceToWindow: ["distanceToWindow", sortAscending, "retainedSize", false],
@@ -617,11 +592,11 @@
/**
* @constructor
- * @extends {WebInspector.HeapSnapshotLazyGridNode}
+ * @extends {WebInspector.HeapSnapshotGridNode}
*/
WebInspector.HeapSnapshotConstructorNode = function(tree, className, aggregate, aggregatesKey)
{
- WebInspector.HeapSnapshotLazyGridNode.call(this, tree, aggregate.count > 0);
+ WebInspector.HeapSnapshotGridNode.call(this, tree, aggregate.count > 0);
this._name = className;
this._distanceToWindow = aggregate.distanceToWindow;
this._count = aggregate.count;
@@ -641,7 +616,7 @@
_createChildNode: function(item)
{
- return new WebInspector.HeapSnapshotInstanceNode(this.dataGrid, null, this.dataGrid.snapshot, item);
+ return new WebInspector.HeapSnapshotInstanceNode(this._dataGrid, null, this._dataGrid.snapshot, item);
},
_createNodesProvider: function(snapshot, className, aggregatesKey)
@@ -651,8 +626,8 @@
comparator: function()
{
- var sortAscending = this.dataGrid.sortOrder === "ascending";
- var sortColumnIdentifier = this.dataGrid.sortColumnIdentifier;
+ var sortAscending = this._dataGrid.sortOrder === "ascending";
+ var sortColumnIdentifier = this._dataGrid.sortColumnIdentifier;
var sortFields = {
object: ["id", sortAscending, "retainedSize", false],
distanceToWindow: ["distanceToWindow", true, "retainedSize", false],
@@ -703,7 +678,7 @@
}
};
-WebInspector.HeapSnapshotConstructorNode.prototype.__proto__ = WebInspector.HeapSnapshotLazyGridNode.prototype;
+WebInspector.HeapSnapshotConstructorNode.prototype.__proto__ = WebInspector.HeapSnapshotGridNode.prototype;
/**
* @constructor
@@ -733,11 +708,11 @@
/**
* @constructor
- * @extends {WebInspector.HeapSnapshotLazyGridNode}
+ * @extends {WebInspector.HeapSnapshotGridNode}
*/
WebInspector.HeapSnapshotDiffNode = function(tree, className, baseAggregate, aggregate)
{
- WebInspector.HeapSnapshotLazyGridNode.call(this, tree, true);
+ WebInspector.HeapSnapshotGridNode.call(this, tree, true);
this._name = className;
this._baseIndexes = baseAggregate ? baseAggregate.idxs : [];
this._indexes = aggregate ? aggregate.idxs : [];
@@ -784,9 +759,9 @@
_createChildNode: function(item, provider)
{
if (provider === this._provider._it1)
- return new WebInspector.HeapSnapshotInstanceNode(this.dataGrid, null, provider.snapshot, item);
+ return new WebInspector.HeapSnapshotInstanceNode(this._dataGrid, null, provider.snapshot, item);
else
- return new WebInspector.HeapSnapshotInstanceNode(this.dataGrid, provider.snapshot, null, item);
+ return new WebInspector.HeapSnapshotInstanceNode(this._dataGrid, provider.snapshot, null, item);
},
_createNodesProvider: function(baseSnapshot, snapshot, nodeType, nodeClassName)
@@ -821,8 +796,8 @@
comparator: function()
{
- var sortAscending = this.dataGrid.sortOrder === "ascending";
- var sortColumnIdentifier = this.dataGrid.sortColumnIdentifier;
+ var sortAscending = this._dataGrid.sortOrder === "ascending";
+ var sortColumnIdentifier = this._dataGrid.sortColumnIdentifier;
var sortFields = {
object: ["id", sortAscending, "selfSize", false],
addedCount: ["selfSize", sortAscending, "id", true],
@@ -878,7 +853,7 @@
}
};
-WebInspector.HeapSnapshotDiffNode.prototype.__proto__ = WebInspector.HeapSnapshotLazyGridNode.prototype;
+WebInspector.HeapSnapshotDiffNode.prototype.__proto__ = WebInspector.HeapSnapshotGridNode.prototype;
/**
* @constructor
@@ -894,7 +869,7 @@
WebInspector.HeapSnapshotDominatorObjectNode.prototype = {
_createChildNode: function(item)
{
- return new WebInspector.HeapSnapshotDominatorObjectNode(this.dataGrid, item);
+ return new WebInspector.HeapSnapshotDominatorObjectNode(this._dataGrid, item);
},
_createProvider: function(snapshot, nodeIndex)
@@ -915,8 +890,8 @@
comparator: function()
{
- var sortAscending = this.dataGrid.sortOrder === "ascending";
- var sortColumnIdentifier = this.dataGrid.sortColumnIdentifier;
+ var sortAscending = this._dataGrid.sortOrder === "ascending";
+ var sortColumnIdentifier = this._dataGrid.sortColumnIdentifier;
var sortFields = {
object: ["id", sortAscending, "retainedSize", false],
shallowSize: ["selfSize", sortAscending, "id", true],