Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Side by Side Diff: Source/devtools/front_end/HeapSnapshotGridNodes.js

Issue 187703002: DevTools: Prepare for recursive viewport in datagrid (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/devtools/front_end/HeapSnapshotDataGrids.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 * @return {!Element} 85 * @return {!Element}
86 */ 86 */
87 createCell: function(columnIdentifier) 87 createCell: function(columnIdentifier)
88 { 88 {
89 var cell = WebInspector.DataGridNode.prototype.createCell.call(this, col umnIdentifier); 89 var cell = WebInspector.DataGridNode.prototype.createCell.call(this, col umnIdentifier);
90 if (this._searchMatched) 90 if (this._searchMatched)
91 cell.classList.add("highlight"); 91 cell.classList.add("highlight");
92 return cell; 92 return cell;
93 }, 93 },
94 94
95 /**
96 * @override
97 */
95 collapse: function() 98 collapse: function()
96 { 99 {
97 WebInspector.DataGridNode.prototype.collapse.call(this); 100 WebInspector.DataGridNode.prototype.collapse.call(this);
98 this._dataGrid.updateVisibleNodes(); 101 this._dataGrid.updateVisibleNodes();
99 }, 102 },
100 103
104 /**
105 * @override
106 */
101 dispose: function() 107 dispose: function()
102 { 108 {
103 if (this._providerObject) 109 if (this._providerObject)
104 this._providerObject.dispose(); 110 this._providerObject.dispose();
105 for (var node = this.children[0]; node; node = node.traverseNextNode(tru e, this, true)) 111 for (var node = this.children[0]; node; node = node.traverseNextNode(tru e, this, true))
106 if (node.dispose) 112 if (node.dispose)
107 node.dispose(); 113 node.dispose();
108 }, 114 },
109 115
110 _reachableFromWindow: false, 116 _reachableFromWindow: false,
111 117
112 queryObjectContent: function(callback) 118 queryObjectContent: function(callback)
113 { 119 {
114 }, 120 },
115 121
116 /** 122 /**
117 * @override 123 * @override
118 */ 124 */
119 wasDetached: function() 125 wasDetached: function()
120 { 126 {
121 this._dataGrid.nodeWasDetached(this); 127 this._dataGrid.nodeWasDetached(this);
122 }, 128 },
123 129
124 _toPercentString: function(num) 130 _toPercentString: function(num)
125 { 131 {
126 return num.toFixed(0) + "\u2009%"; // \u2009 is a thin space. 132 return num.toFixed(0) + "\u2009%"; // \u2009 is a thin space.
127 }, 133 },
128 134
129 /** 135 /**
136 * @return {!Array.<!WebInspector.DataGridNode>}
137 */
138 allChildren: function()
139 {
140 return this.children;
141 },
142
143 /**
144 * @param {number} index
145 */
146 removeChildByIndex: function(index)
147 {
148 this.removeChild(this.children[index]);
149 },
150
151 /**
130 * @param {number} nodePosition 152 * @param {number} nodePosition
131 * @return {?WebInspector.DataGridNode} 153 * @return {?WebInspector.DataGridNode}
132 */ 154 */
133 childForPosition: function(nodePosition) 155 childForPosition: function(nodePosition)
134 { 156 {
135 var indexOfFirsChildInRange = 0; 157 var indexOfFirstChildInRange = 0;
136 for (var i = 0; i < this._retrievedChildrenRanges.length; i++) { 158 for (var i = 0; i < this._retrievedChildrenRanges.length; i++) {
137 var range = this._retrievedChildrenRanges[i]; 159 var range = this._retrievedChildrenRanges[i];
138 if (range.from <= nodePosition && nodePosition < range.to) { 160 if (range.from <= nodePosition && nodePosition < range.to) {
139 var childIndex = indexOfFirsChildInRange + nodePosition - range.f rom; 161 var childIndex = indexOfFirstChildInRange + nodePosition - range. from;
140 return this.children[childIndex]; 162 return this.allChildren()[childIndex];
141 } 163 }
142 indexOfFirsChildInRange += range.to - range.from + 1; 164 indexOfFirstChildInRange += range.to - range.from + 1;
143 } 165 }
144 return null; 166 return null;
145 }, 167 },
146 168
169 /**
170 * @param {string} columnIdentifier
171 * @return {!Element}
172 */
147 _createValueCell: function(columnIdentifier) 173 _createValueCell: function(columnIdentifier)
148 { 174 {
149 var cell = document.createElement("td"); 175 var cell = document.createElement("td");
150 cell.className = columnIdentifier + "-column"; 176 cell.className = columnIdentifier + "-column";
151 if (this.dataGrid.snapshot.totalSize !== 0) { 177 if (this.dataGrid.snapshot.totalSize !== 0) {
152 var div = document.createElement("div"); 178 var div = document.createElement("div");
153 var valueSpan = document.createElement("span"); 179 var valueSpan = document.createElement("span");
154 valueSpan.textContent = this.data[columnIdentifier]; 180 valueSpan.textContent = this.data[columnIdentifier];
155 div.appendChild(valueSpan); 181 div.appendChild(valueSpan);
156 var percentColumn = columnIdentifier + "-percent"; 182 var percentColumn = columnIdentifier + "-percent";
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 } 296 }
271 insertionIndex += range.to - range.from; 297 insertionIndex += range.to - range.from;
272 // Skip the button if there is one. 298 // Skip the button if there is one.
273 if (range.to < itemsRange.totalLength) 299 if (range.to < itemsRange.totalLength)
274 insertionIndex += 1; 300 insertionIndex += 1;
275 ++rangeIndex; 301 ++rangeIndex;
276 } 302 }
277 303
278 if (!found || itemsRange.startPosition < range.from) { 304 if (!found || itemsRange.startPosition < range.from) {
279 // Update previous button. 305 // Update previous button.
280 this.children[insertionIndex - 1].setEndPosition(itemsRange. startPosition); 306 this.allChildren()[insertionIndex - 1].setEndPosition(itemsR ange.startPosition);
281 insertShowMoreButton.call(this, itemsRange.startPosition, fo und ? range.from : itemsRange.totalLength, insertionIndex); 307 insertShowMoreButton.call(this, itemsRange.startPosition, fo und ? range.from : itemsRange.totalLength, insertionIndex);
282 range = {from: itemsRange.startPosition, to: itemsRange.star tPosition}; 308 range = {from: itemsRange.startPosition, to: itemsRange.star tPosition};
283 if (!found) 309 if (!found)
284 rangeIndex = this._retrievedChildrenRanges.length; 310 rangeIndex = this._retrievedChildrenRanges.length;
285 this._retrievedChildrenRanges.splice(rangeIndex, 0, range); 311 this._retrievedChildrenRanges.splice(rangeIndex, 0, range);
286 } else { 312 } else {
287 insertionIndex += itemPosition - range.from; 313 insertionIndex += itemPosition - range.from;
288 } 314 }
289 // At this point insertionIndex is always an index before button or between nodes. 315 // At this point insertionIndex is always an index before button or between nodes.
290 // Also it is always true here that range.from <= itemPosition < = range.to 316 // Also it is always true here that range.from <= itemPosition < = range.to
(...skipping 12 matching lines...) Expand all
303 if (newEndOfRange > itemsRange.endPosition) 329 if (newEndOfRange > itemsRange.endPosition)
304 newEndOfRange = itemsRange.endPosition; 330 newEndOfRange = itemsRange.endPosition;
305 while (itemPosition < newEndOfRange) { 331 while (itemPosition < newEndOfRange) {
306 insertRetrievedChild.call(this, items[itemIndex++], inse rtionIndex++); 332 insertRetrievedChild.call(this, items[itemIndex++], inse rtionIndex++);
307 ++itemPosition; 333 ++itemPosition;
308 } 334 }
309 // Merge with the next range. 335 // Merge with the next range.
310 if (nextRange && newEndOfRange === nextRange.from) { 336 if (nextRange && newEndOfRange === nextRange.from) {
311 range.to = nextRange.to; 337 range.to = nextRange.to;
312 // Remove "show next" button if there is one. 338 // Remove "show next" button if there is one.
313 this.removeChild(this.children[insertionIndex]); 339 this.removeChildByIndex(insertionIndex);
314 this._retrievedChildrenRanges.splice(rangeIndex + 1, 1); 340 this._retrievedChildrenRanges.splice(rangeIndex + 1, 1);
315 } else { 341 } else {
316 range.to = newEndOfRange; 342 range.to = newEndOfRange;
317 // Remove or update next button. 343 // Remove or update next button.
318 if (newEndOfRange === itemsRange.totalLength) 344 if (newEndOfRange === itemsRange.totalLength)
319 this.removeChild(this.children[insertionIndex]); 345 this.removeChildByIndex(insertionIndex);
320 else 346 else
321 this.children[insertionIndex].setStartPosition(items Range.endPosition); 347 this.allChildren()[insertionIndex].setStartPosition( itemsRange.endPosition);
322 } 348 }
323 } 349 }
324 } 350 }
325 351
326 // TODO: fix this. 352 // TODO: fix this.
327 this._instanceCount += items.length; 353 this._instanceCount += items.length;
328 if (firstNotSerializedPosition < toPosition) { 354 if (firstNotSerializedPosition < toPosition) {
329 serializeNextChunk.call(this); 355 serializeNextChunk.call(this);
330 return; 356 return;
331 } 357 }
332 358
333 if (afterPopulate) 359 if (afterPopulate)
334 afterPopulate(); 360 afterPopulate();
335 this.dispatchEventToListeners(WebInspector.HeapSnapshotGridNode.Even ts.PopulateComplete); 361 this.dispatchEventToListeners(WebInspector.HeapSnapshotGridNode.Even ts.PopulateComplete);
336 } 362 }
337 serializeNextChunk.call(this); 363 serializeNextChunk.call(this);
338 }, 364 },
339 365
340 _saveChildren: function() 366 _saveChildren: function()
341 { 367 {
342 this._savedChildren = null; 368 this._savedChildren = null;
343 for (var i = 0, childrenCount = this.children.length; i < childrenCount; ++i) { 369 var children = this.allChildren();
344 var child = this.children[i]; 370 for (var i = 0, l = children.length; i < l; ++i) {
371 var child = children[i];
345 if (!child.expanded) 372 if (!child.expanded)
346 continue; 373 continue;
347 if (!this._savedChildren) 374 if (!this._savedChildren)
348 this._savedChildren = {}; 375 this._savedChildren = {};
349 this._savedChildren[this._childHashForNode(child)] = child; 376 this._savedChildren[this._childHashForNode(child)] = child;
350 } 377 }
351 }, 378 },
352 379
353 sort: function() 380 sort: function()
354 { 381 {
355 this._dataGrid.recursiveSortingEnter(); 382 this._dataGrid.recursiveSortingEnter();
356 383
357 /** 384 /**
358 * @this {WebInspector.HeapSnapshotGridNode} 385 * @this {WebInspector.HeapSnapshotGridNode}
359 */ 386 */
360 function afterSort() 387 function afterSort()
361 { 388 {
362 this._saveChildren(); 389 this._saveChildren();
363 this.removeChildren(); 390 this.removeChildren();
364 this._retrievedChildrenRanges = []; 391 this._retrievedChildrenRanges = [];
365 392
366 /** 393 /**
367 * @this {WebInspector.HeapSnapshotGridNode} 394 * @this {WebInspector.HeapSnapshotGridNode}
368 */ 395 */
369 function afterPopulate() 396 function afterPopulate()
370 { 397 {
371 for (var i = 0, l = this.children.length; i < l; ++i) { 398 var children = this.allChildren();
372 var child = this.children[i]; 399 for (var i = 0, l = children.length; i < l; ++i) {
400 var child = children[i];
373 if (child.expanded) 401 if (child.expanded)
374 child.sort(); 402 child.sort();
375 } 403 }
376 this._dataGrid.recursiveSortingLeave(); 404 this._dataGrid.recursiveSortingLeave();
377 } 405 }
378 var instanceCount = this._instanceCount; 406 var instanceCount = this._instanceCount;
379 this._instanceCount = 0; 407 this._instanceCount = 0;
380 this._populateChildren(0, instanceCount, afterPopulate.bind(this)); 408 this._populateChildren(0, instanceCount, afterPopulate.bind(this));
381 } 409 }
382 410
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 /** 858 /**
831 * @this {WebInspector.HeapSnapshotConstructorNode} 859 * @this {WebInspector.HeapSnapshotConstructorNode}
832 */ 860 */
833 function didExpand() 861 function didExpand()
834 { 862 {
835 this._provider().nodePosition(snapshotObjectId, didGetNodePosition.b ind(this)); 863 this._provider().nodePosition(snapshotObjectId, didGetNodePosition.b ind(this));
836 } 864 }
837 865
838 /** 866 /**
839 * @this {WebInspector.HeapSnapshotConstructorNode} 867 * @this {WebInspector.HeapSnapshotConstructorNode}
868 * @param {number} nodePosition
840 */ 869 */
841 function didGetNodePosition(nodePosition) 870 function didGetNodePosition(nodePosition)
842 { 871 {
843 if (nodePosition === -1) { 872 if (nodePosition === -1) {
844 this.collapse(); 873 this.collapse();
845 callback(false); 874 callback(false);
846 } else { 875 } else {
847 this._populateChildren(nodePosition, null, didPopulateChildren.b ind(this, nodePosition)); 876 this._populateChildren(nodePosition, null, didPopulateChildren.b ind(this, nodePosition));
848 } 877 }
849 } 878 }
850 879
851 /** 880 /**
852 * @this {WebInspector.HeapSnapshotConstructorNode} 881 * @this {WebInspector.HeapSnapshotConstructorNode}
882 * @param {number} nodePosition
853 */ 883 */
854 function didPopulateChildren(nodePosition) 884 function didPopulateChildren(nodePosition)
855 { 885 {
856 var indexOfFirsChildInRange = 0; 886 var child = this.childForPosition(nodePosition);
857 for (var i = 0; i < this._retrievedChildrenRanges.length; i++) { 887 if (child)
858 var range = this._retrievedChildrenRanges[i]; 888 this._dataGrid.highlightNode(/** @type {!WebInspector.HeapSnapsh otGridNode} */ (child));
859 if (range.from <= nodePosition && nodePosition < range.to) { 889 callback(!!child);
860 var childIndex = indexOfFirsChildInRange + nodePosition - ran ge.from;
861 var instanceNode = this.children[childIndex];
862 this._dataGrid.highlightNode(/** @type {!WebInspector.HeapSna pshotGridNode} */ (instanceNode));
863 callback(true);
864 return;
865 }
866 indexOfFirsChildInRange += range.to - range.from + 1;
867 }
868 callback(false);
869 } 890 }
870 891
871 this.expandWithoutPopulate(didExpand.bind(this)); 892 this.expandWithoutPopulate(didExpand.bind(this));
872 }, 893 },
873 894
874 /** 895 /**
875 * @param {string} columnIdentifier 896 * @param {string} columnIdentifier
876 * @return {!Element} 897 * @return {!Element}
877 */ 898 */
878 createCell: function(columnIdentifier) 899 createCell: function(columnIdentifier)
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 }, 1260 },
1240 1261
1241 _emptyData: function() 1262 _emptyData: function()
1242 { 1263 {
1243 return {}; 1264 return {};
1244 }, 1265 },
1245 1266
1246 __proto__: WebInspector.HeapSnapshotGenericObjectNode.prototype 1267 __proto__: WebInspector.HeapSnapshotGenericObjectNode.prototype
1247 } 1268 }
1248 1269
OLDNEW
« no previous file with comments | « Source/devtools/front_end/HeapSnapshotDataGrids.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698