Changeset 84619 in webkit
- Timestamp:
- Apr 22, 2011 5:32:14 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r84617 r84619 1 2011-04-22 Mikhail Naganov <mnaganov@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: [Chromium] Refactor code prior to moving detailed heap snapshots into workers. 6 https://bugs.webkit.org/show_bug.cgi?id=59189 7 8 * inspector/profiler/detailed-heapshots-comparison-sorting.html: 9 * inspector/profiler/detailed-heapshots-test.js: 10 (initialize_DetailedHeapshotTest): 11 (initialize_DetailedHeapshotTest.): 12 * inspector/profiler/heap-snapshot-expected.txt: 13 * inspector/profiler/heap-snapshot.html: 14 1 15 2011-04-22 Csaba Osztrogonác <ossy@webkit.org> 2 16 -
trunk/LayoutTests/inspector/profiler/detailed-heapshots-comparison-sorting.html
r83581 r84619 27 27 function step1() 28 28 { 29 InspectorTest.switchToView("Comparison", next);29 InspectorTest.switchToView("Comparison", step2); 30 30 } 31 31 -
trunk/LayoutTests/inspector/profiler/detailed-heapshots-test.js
r83850 r84619 170 170 function sortingComplete() 171 171 { 172 InspectorTest._currentGrid().removeEventListener("sorting complete", sortingComplete, this); 172 173 InspectorTest.assertEquals(column.identifier, this._currentGrid().sortColumnIdentifier, "unexpected sorting"); 173 174 column.sort = this._currentGrid().sortOrder; … … 178 179 setTimeout(callCallback, 0); 179 180 } 180 InspectorTest._ prepareForRecursiveSort(sortingComplete.bind(this));181 InspectorTest._currentGrid().addEventListener("sorting complete", sortingComplete, this); 181 182 this._currentGrid()._clickInHeaderCell(event); 182 183 }; … … 295 296 } 296 297 row.addEventListener("populate complete", populateComplete, this); 297 row.expand(); 298 (function expand() 299 { 300 if (row.hasChildren) 301 row.expand(); 302 else 303 setTimeout(expand, 0); 304 })(); 298 305 }; 299 306 … … 359 366 return; 360 367 } 361 InspectorTest._prepareForRecursiveSort(callback, view.views[index].grid); 368 var grid = view.views[index].grid; 369 function sortingComplete() 370 { 371 grid.removeEventListener("sorting complete", sortingComplete, this); 372 setTimeout(callback, 0); 373 } 374 view.views[index].grid.addEventListener("sorting complete", sortingComplete, this); 362 375 view._changeView({target: {selectedIndex: index}}); 363 376 }; … … 393 406 }; 394 407 395 InspectorTest._prepareForRecursiveSort = function(callback, grid)396 {397 if (InspectorTest._recursiveSortCallback)398 console.error("Didn't finished with previous sorting");399 InspectorTest._recursiveSortCallback = callback;400 InspectorTest._recursiveSortDepth = 0;401 grid = grid || InspectorTest._currentGrid();402 grid.addEventListener("start sorting", InspectorTest._recursiveSortEnter, InspectorTest);403 grid.addEventListener("sorting complete", InspectorTest._recursiveSortLeave, InspectorTest);404 InspectorTest._recursiveSortGrid = grid;405 };406 407 InspectorTest._recursiveSortEnter = function()408 {409 ++InspectorTest._recursiveSortDepth;410 if (isNaN(InspectorTest._recursiveSortDepth))411 console.error("Wasn't prepared to track sorting");412 };413 414 InspectorTest._recursiveSortLeave = function()415 {416 if (!--InspectorTest._recursiveSortDepth) {417 var callback = InspectorTest._recursiveSortCallback;418 delete InspectorTest._recursiveSortCallback;419 InspectorTest._recursiveSortGrid.removeEventListener("start sorting", InspectorTest._recursiveSortEnter, InspectorTest);420 InspectorTest._recursiveSortGrid.removeEventListener("sorting complete", InspectorTest._recursiveSortLeave, InspectorTest);421 setTimeout(callback, 0);422 }423 if (!(InspectorTest._recursiveSortDepth >= 0))424 console.error("Bad sort nesting");425 };426 427 408 InspectorTest._snapshotViewShown = function() 428 409 { … … 430 411 var callback = InspectorTest._takeAndOpenSnapshotCallback; 431 412 InspectorTest._takeAndOpenSnapshotCallback = null; 432 callback(); 433 } 434 }; 435 436 }; 413 var dataGrid = this.dataGrid; 414 function sortingComplete() 415 { 416 dataGrid.removeEventListener("sorting complete", sortingComplete, null); 417 callback(); 418 } 419 dataGrid.addEventListener("sorting complete", sortingComplete, null); 420 } 421 }; 422 423 }; -
trunk/LayoutTests/inspector/profiler/heap-snapshot-expected.txt
r81946 r84619 14 14 Running: heapSnapshotSimpleTest 15 15 16 Running: heapSnapshotIdsTest17 18 16 Running: heapSnapshotRetainersTest 19 17 -
trunk/LayoutTests/inspector/profiler/heap-snapshot.html
r82230 r84619 93 93 InspectorTest.assertEquals(6, snapshot.nodeCount, "node count"); 94 94 InspectorTest.assertEquals(20, snapshot.totalSize, "total size"); 95 next();96 },97 98 function heapSnapshotIdsTest(next)99 {100 var snapshot = new WebInspector.HeapSnapshot(InspectorTest.createHeapSnapshotMock());101 InspectorTest.assertEquals(false, snapshot.hasId(0), "has id 0");102 for (var i = 1; i <= 6; ++i)103 InspectorTest.assertEquals(true, snapshot.hasId(i), "has id " + i);104 InspectorTest.assertEquals(false, snapshot.hasId(7), "has id 7");105 InspectorTest.assertEquals(false, snapshot.hasId(100), "has id 100");106 95 next(); 107 96 }, -
trunk/Source/WebCore/ChangeLog
r84618 r84619 1 2011-04-22 Mikhail Naganov <mnaganov@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: [Chromium] Refactor code prior to moving detailed heap snapshots into workers. 6 https://bugs.webkit.org/show_bug.cgi?id=59189 7 8 * WebCore.gypi: 9 * WebCore.vcproj/WebCore.vcproj: 10 * inspector/front-end/BinarySearch.js: Added. 11 * inspector/front-end/DetailedHeapshotGridNodes.js: 12 (WebInspector.HeapSnapshotGridNode.prototype._populate.sorted): 13 (WebInspector.HeapSnapshotGridNode.prototype._populate): 14 (WebInspector.HeapSnapshotGridNode.prototype.populateChildren): 15 (WebInspector.HeapSnapshotGridNode.prototype.sort.afterSort.afterPopulate): 16 (WebInspector.HeapSnapshotGridNode.prototype.sort.afterSort): 17 (WebInspector.HeapSnapshotGridNode.prototype.sort): 18 (WebInspector.HeapSnapshotObjectNode): 19 (WebInspector.HeapSnapshotObjectNode.prototype._createChildNode): 20 (WebInspector.HeapSnapshotInstanceNode.prototype._createChildNode): 21 (WebInspector.HeapSnapshotInstanceNode.prototype._enhanceData): 22 (WebInspector.HeapSnapshotInstanceNode.prototype.get isDeletedNode): 23 (WebInspector.HeapSnapshotDiffNode.prototype.calculateDiff.diffCalculated): 24 (WebInspector.HeapSnapshotDiffNode.prototype.calculateDiff.baseIdsReceived): 25 (WebInspector.HeapSnapshotDiffNode.prototype.get data): 26 * inspector/front-end/DetailedHeapshotView.js: 27 (WebInspector.HeapSnapshotSortableDataGrid.prototype.sortingChanged.sort): 28 (WebInspector.HeapSnapshotSortableDataGrid.prototype.sortingChanged): 29 (WebInspector.HeapSnapshotSortableDataGrid.prototype._performSorting): 30 (WebInspector.HeapSnapshotSortableDataGrid.prototype.recursiveSortingEnter): 31 (WebInspector.HeapSnapshotSortableDataGrid.prototype.recursiveSortingLeave): 32 (WebInspector.HeapSnapshotContainmentDataGrid): 33 (WebInspector.HeapSnapshotContainmentDataGrid.prototype._defaultPopulateCount.100.setDataSource): 34 (WebInspector.HeapSnapshotContainmentDataGrid.prototype.sortingChanged): 35 (WebInspector.HeapSnapshotDiffDataGrid.prototype.setBaseDataSource): 36 (WebInspector.HeapSnapshotDiffDataGrid.prototype.populateChildren.baseAggregatesReceived.aggregatesReceived.addNodeIfNonZeroDiff): 37 (WebInspector.HeapSnapshotDiffDataGrid.prototype.populateChildren.baseAggregatesReceived.aggregatesReceived): 38 (WebInspector.HeapSnapshotDiffDataGrid.prototype.populateChildren): 39 (WebInspector.HeapSnapshotDominatorsDataGrid): 40 (WebInspector.HeapSnapshotDominatorsDataGrid.prototype._defaultPopulateCount.25.setDataSource): 41 (WebInspector.HeapSnapshotDominatorsDataGrid.prototype.sortingChanged): 42 (WebInspector.HeapSnapshotRetainingPathsList.prototype._performSorting): 43 (WebInspector.DetailedHeapshotView.prototype._changeBase.baseProfileLoaded): 44 (WebInspector.DetailedHeapshotView.prototype._changeBase): 45 (WebInspector.DetailedHeapshotView.prototype._changeView): 46 (WebInspector.DetailedHeapshotView.prototype._showStringContentPopup.displayString): 47 (WebInspector.DetailedHeapshotView.prototype._showStringContentPopup): 48 * inspector/front-end/HeapSnapshot.js: 49 (WebInspector.HeapSnapshot.prototype.dispose): 50 (WebInspector.HeapSnapshot.prototype.pushBaseNodeIds): 51 (WebInspector.HeapSnapshotFilteredOrderedIterator.prototype.serializeNextItems): 52 (WebInspector.HeapSnapshotFilteredOrderedIterator.prototype.sortAndRewind): 53 (WebInspector.HeapSnapshotEdgesProvider.prototype._serialize): 54 (WebInspector.HeapSnapshotNodesProvider.prototype._serialize): 55 (WebInspector.HeapSnapshotsDiff.prototype.calculate): 56 (WebInspector.HeapSnapshotsDiff.prototype.pushBaseIds): 57 (WebInspector.HeapSnapshotsDiff.prototype.pushBaseSelfSizes): 58 * inspector/front-end/HeapSnapshotProxy.js: 59 (WebInspector.HeapSnapshotProxy.prototype.createEdgesProvider): 60 (WebInspector.HeapSnapshotProxy.prototype.createNodesProvider): 61 (WebInspector.HeapSnapshotProxy.prototype.pushBaseIds): 62 (WebInspector.HeapSnapshotProviderProxy): 63 (WebInspector.HeapSnapshotProviderProxy.prototype.serializeNextItems): 64 (WebInspector.HeapSnapshotProviderProxy.prototype.sortAndRewind): 65 (WebInspector.HeapSnapshotsDiffProxy.prototype.pushBaseIds): 66 (WebInspector.HeapSnapshotsDiffProxy.prototype.pushBaseSelfSizes): 67 * inspector/front-end/PleaseWaitMessage.js: 68 (WebInspector.PleaseWaitMessage.prototype.showAndWaitFor): 69 (WebInspector.PleaseWaitMessage.prototype.unlistenAndHide): 70 * inspector/front-end/WebKit.qrc: 71 * inspector/front-end/inspector.html: 72 * inspector/front-end/utilities.js: 73 1 74 2011-04-22 Mikhail Naganov <mnaganov@chromium.org> 2 75 -
trunk/Source/WebCore/WebCore.gypi
r84527 r84619 6186 6186 'inspector/front-end/AuditRules.js', 6187 6187 'inspector/front-end/AuditsPanel.js', 6188 'inspector/front-end/BinarySearch.js', 6188 6189 'inspector/front-end/BottomUpProfileDataGridTree.js', 6189 6190 'inspector/front-end/BreakpointsSidebarPane.js', -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r84527 r84619 67218 67218 </File> 67219 67219 <File 67220 RelativePath="..\inspector\front-end\BinarySearch.js" 67221 > 67222 </File> 67223 <File 67220 67224 RelativePath="..\inspector\front-end\BottomUpProfileDataGridTree.js" 67221 67225 > -
trunk/Source/WebCore/inspector/front-end/DetailedHeapshotGridNodes.js
r83850 r84619 48 48 _populate: function(event) 49 49 { 50 WebInspector.PleaseWaitMessage.prototype.startAction(this.dataGrid.element, doPopulate.bind(this)); 51 52 function doPopulate() 53 { 54 this.removeEventListener("populate", this._populate, this); 55 function sorted(ignored) 56 { 57 this.populateChildren(); 58 } 59 this._provider.sortAndRewind(this.comparator(), sorted.bind(this)); 60 } 50 this.removeEventListener("populate", this._populate, this); 51 function sorted(ignored) 52 { 53 this.populateChildren(); 54 } 55 WebInspector.PleaseWaitMessage.prototype.showAndWaitFor(this.dataGrid.element, this, "populate complete"); 56 this._provider.sortAndRewind(this.comparator(), sorted.bind(this)); 61 57 }, 62 58 … … 81 77 } 82 78 83 function childrenRetrieved(items, hasNext, length) 84 { 79 function childrenRetrieved(items) 80 { 81 var hasNext = items.hasNext; 82 var length = items.totalLength; 85 83 for (var i = 0, l = items.length; i < l; ++i) { 86 84 var item = items[i]; … … 108 106 } 109 107 } 110 provider. getNextItems(howMany, childrenRetrieved.bind(this));108 provider.serializeNextItems(howMany, childrenRetrieved.bind(this)); 111 109 }, 112 110 … … 123 121 sort: function() 124 122 { 125 function doSort() 126 { 127 function afterSort(sorted) 123 WebInspector.PleaseWaitMessage.prototype.showAndWaitFor(this.dataGrid.element, this.dataGrid, "sorting complete"); 124 this.dataGrid.recursiveSortingEnter(); 125 function afterSort(sorted) 126 { 127 if (!sorted) { 128 this.dataGrid.recursiveSortingLeave(); 129 return; 130 } 131 this._saveChildren(); 132 this.removeChildren(); 133 134 function afterPopulate() 128 135 { 129 if (!sorted) 130 return; 131 this._saveChildren(); 132 this.removeChildren(); 133 134 function afterPopulate() 135 { 136 for (var i = 0, l = this.children.length; i < l; ++i) { 137 var child = this.children[i]; 138 if (child.expanded) 139 child.sort(); 140 } 141 this.dataGrid.dispatchEventToListeners("sorting complete"); 136 for (var i = 0, l = this.children.length; i < l; ++i) { 137 var child = this.children[i]; 138 if (child.expanded) 139 child.sort(); 142 140 } 143 this. populateChildren(this._provider, null, null, afterPopulate.bind(this));141 this.dataGrid.recursiveSortingLeave(); 144 142 } 145 this._provider.sortAndRewind(this.comparator(), afterSort.bind(this)); 146 } 147 this.dataGrid.dispatchEventToListeners("start sorting"); 148 WebInspector.PleaseWaitMessage.prototype.startAction(this.dataGrid.element, doSort.bind(this)); 143 this.populateChildren(this._provider, null, null, afterPopulate.bind(this)); 144 } 145 this._provider.sortAndRewind(this.comparator(), afterSort.bind(this)); 149 146 } 150 147 }; … … 258 255 WebInspector.HeapSnapshotGenericObjectNode.prototype.__proto__ = WebInspector.HeapSnapshotGridNode.prototype; 259 256 260 WebInspector.HeapSnapshotObjectNode = function(tree, edge)257 WebInspector.HeapSnapshotObjectNode = function(tree, isFromBaseSnapshot, edge) 261 258 { 262 259 WebInspector.HeapSnapshotGenericObjectNode.call(this, tree, edge.node); 263 260 this._referenceName = edge.name; 264 261 this._referenceType = edge.type; 265 this._provider = this._createProvider(tree.snapshot, edge.nodeIndex); 262 this._isFromBaseSnapshot = isFromBaseSnapshot; 263 this._provider = this._createProvider(!isFromBaseSnapshot ? tree.snapshot : tree.baseSnapshot, edge.nodeIndex); 266 264 this._updateHasChildren(); 267 265 } … … 270 268 _createChildNode: function(item) 271 269 { 272 return new WebInspector.HeapSnapshotObjectNode(this.dataGrid, item);270 return new WebInspector.HeapSnapshotObjectNode(this.dataGrid, this._isFromBaseSnapshot, item); 273 271 }, 274 272 … … 357 355 _createChildNode: function(item) 358 356 { 359 return new WebInspector.HeapSnapshotObjectNode(this.dataGrid, item);357 return new WebInspector.HeapSnapshotObjectNode(this.dataGrid, this._isDeletedNode, item); 360 358 }, 361 359 … … 415 413 } 416 414 return data; 415 }, 416 417 get isDeletedNode() 418 { 419 return this._isDeletedNode; 417 420 } 418 421 } … … 529 532 function diffCalculated(diffResult) 530 533 { 531 this._diff = diffResult; 534 this._addedCount = diffResult.addedCount; 535 this._removedCount = diffResult.removedCount; 536 this._countDelta = diffResult.countDelta; 537 this._addedSize = diffResult.addedSize; 538 this._removedSize = diffResult.removedSize; 539 this._sizeDelta = diffResult.sizeDelta; 532 540 this._baseIndexes = null; 533 541 this._indexes = null; 534 callback(this._ diff.addedSize === 0 && this._diff.removedSize === 0);542 callback(this._addedSize === 0 && this._removedSize === 0); 535 543 } 536 544 function baseSelfSizesReceived(baseSelfSizes) … … 541 549 function baseIdsReceived(baseIds) 542 550 { 543 diff.pushBaseIds( dataGrid.baseSnapshot.uid,baseIds);551 diff.pushBaseIds(baseIds); 544 552 dataGrid.snapshot.pushBaseIds(dataGrid.baseSnapshot.uid, this._name, baseIds); 545 553 dataGrid.baseSnapshot.nodeFieldValuesByIndex("selfSize", this._baseIndexes, baseSelfSizesReceived.bind(this)); … … 639 647 var data = {object: this._name}; 640 648 641 data["addedCount"] = this._diff.addedCount; 642 data["removedCount"] = this._diff.removedCount; 643 var countDelta = this._diff.countDelta; 644 data["countDelta"] = WebInspector.UIString("%s%d", this._signForDelta(countDelta), Math.abs(countDelta)); 645 data["addedSize"] = Number.bytesToString(this._diff.addedSize); 646 data["removedSize"] = Number.bytesToString(this._diff.removedSize); 647 var sizeDelta = this._diff.sizeDelta; 648 data["sizeDelta"] = WebInspector.UIString("%s%s", this._signForDelta(sizeDelta), Number.bytesToString(Math.abs(sizeDelta))); 649 data["addedCount"] = this._addedCount; 650 data["removedCount"] = this._removedCount; 651 data["countDelta"] = WebInspector.UIString("%s%d", this._signForDelta(this._countDelta), Math.abs(this._countDelta)); 652 data["addedSize"] = Number.bytesToString(this._addedSize); 653 data["removedSize"] = Number.bytesToString(this._removedSize); 654 data["sizeDelta"] = WebInspector.UIString("%s%s", this._signForDelta(this._sizeDelta), Number.bytesToString(Math.abs(this._sizeDelta))); 649 655 650 656 return data; -
trunk/Source/WebCore/inspector/front-end/DetailedHeapshotView.js
r83850 r84619 29 29 */ 30 30 31 WebInspector.HeapSnapshotContainmentDataGrid = function()32 {33 var columns = {34 object: { title: WebInspector.UIString("Object"), disclosure: true, sortable: true, sort: "ascending" },35 shallowSize: { title: WebInspector.UIString("Shallow Size"), width: "90px", sortable: true },36 retainedSize: { title: WebInspector.UIString("Retained Size"), width: "90px", sortable: true }37 };38 WebInspector.DataGrid.call(this, columns);39 this.addEventListener("sorting changed", this.sort, this);40 }41 42 WebInspector.HeapSnapshotContainmentDataGrid.prototype = {43 _defaultPopulateCount: 100,44 45 setDataSource: function(snapshotView, snapshot)46 {47 this.snapshotView = snapshotView;48 this.snapshot = snapshot;49 this.snapshotNodeIndex = this.snapshot.rootNodeIndex;50 this._provider = this._createProvider(snapshot, this.snapshotNodeIndex);51 this.sort();52 }53 };54 55 MixInSnapshotNodeFunctions(WebInspector.HeapSnapshotObjectNode.prototype, WebInspector.HeapSnapshotContainmentDataGrid.prototype);56 WebInspector.HeapSnapshotContainmentDataGrid.prototype.__proto__ = WebInspector.DataGrid.prototype;57 58 31 WebInspector.HeapSnapshotSortableDataGrid = function(columns) 59 32 { … … 90 63 } 91 64 92 this._performSorting(SortByTwoFields); 65 WebInspector.PleaseWaitMessage.prototype.showAndWaitFor(this.element, this, "sorting complete"); 66 function sort() 67 { 68 this._performSorting(SortByTwoFields); 69 } 70 setTimeout(sort.bind(this), 0); 93 71 }, 94 72 95 73 _performSorting: function(sortFunction) 96 74 { 97 this. dispatchEventToListeners("start sorting");75 this.recursiveSortingEnter(); 98 76 var children = this.children; 99 77 this.removeChildren(); … … 105 83 child.sort(); 106 84 } 107 this.dispatchEventToListeners("sorting complete"); 85 this.recursiveSortingLeave(); 86 }, 87 88 recursiveSortingEnter: function() 89 { 90 if (!("_recursiveSortingDepth" in this)) 91 this._recursiveSortingDepth = 1; 92 else 93 ++this._recursiveSortingDepth; 94 }, 95 96 recursiveSortingLeave: function() 97 { 98 if (!("_recursiveSortingDepth" in this)) 99 return; 100 if (!--this._recursiveSortingDepth) { 101 delete this._recursiveSortingDepth; 102 this.dispatchEventToListeners("sorting complete"); 103 } 108 104 } 109 105 }; 110 106 111 107 WebInspector.HeapSnapshotSortableDataGrid.prototype.__proto__ = WebInspector.DataGrid.prototype; 108 109 WebInspector.HeapSnapshotContainmentDataGrid = function() 110 { 111 var columns = { 112 object: { title: WebInspector.UIString("Object"), disclosure: true, sortable: true, sort: "ascending" }, 113 shallowSize: { title: WebInspector.UIString("Shallow Size"), width: "90px", sortable: true }, 114 retainedSize: { title: WebInspector.UIString("Retained Size"), width: "90px", sortable: true } 115 }; 116 WebInspector.HeapSnapshotSortableDataGrid.call(this, columns); 117 } 118 119 WebInspector.HeapSnapshotContainmentDataGrid.prototype = { 120 _defaultPopulateCount: 100, 121 122 setDataSource: function(snapshotView, snapshot) 123 { 124 this.snapshotView = snapshotView; 125 this.snapshot = snapshot; 126 this.snapshotNodeIndex = this.snapshot.rootNodeIndex; 127 this._provider = this._createProvider(snapshot, this.snapshotNodeIndex); 128 this.sort(); 129 }, 130 131 sortingChanged: function() 132 { 133 this.sort(); 134 } 135 }; 136 137 MixInSnapshotNodeFunctions(WebInspector.HeapSnapshotObjectNode.prototype, WebInspector.HeapSnapshotContainmentDataGrid.prototype); 138 WebInspector.HeapSnapshotContainmentDataGrid.prototype.__proto__ = WebInspector.HeapSnapshotSortableDataGrid.prototype; 112 139 113 140 WebInspector.HeapSnapshotConstructorsDataGrid = function() … … 197 224 this.baseSnapshot = baseSnapshot; 198 225 this.removeChildren(); 199 if (this.baseSnapshot === this.snapshot) 200 return; 226 if (this.baseSnapshot === this.snapshot) { 227 this.dispatchEventToListeners("sorting complete"); 228 return; 229 } 201 230 this.populateChildren(); 202 231 }, … … 209 238 { 210 239 var nodeCount = 0; 211 function addNodeIfNonZeroDiff(node, zeroDiff) 240 var nodes = []; 241 for (var clss in baseClasses) 242 nodes.push(new WebInspector.HeapSnapshotDiffNode(this, clss, baseClasses[clss], classes[clss])); 243 for (clss in classes) { 244 if (!(clss in baseClasses)) 245 nodes.push(new WebInspector.HeapSnapshotDiffNode(this, clss, null, classes[clss])); 246 } 247 nodeCount = nodes.length; 248 function addNodeIfNonZeroDiff(boundNode, zeroDiff) 212 249 { 213 250 if (!zeroDiff) 214 this.appendChild( node);251 this.appendChild(boundNode); 215 252 if (!--nodeCount) 216 253 this.sortingChanged(); 217 254 } 218 for (var clss in baseClasses) { 219 var node = new WebInspector.HeapSnapshotDiffNode(this, clss, baseClasses[clss], classes[clss]); 220 ++nodeCount; 255 for (var i = 0, l = nodes.length; i < l; ++i) { 256 var node = nodes[i]; 221 257 node.calculateDiff(this, addNodeIfNonZeroDiff.bind(this, node)); 222 }223 for (clss in classes) {224 if (!(clss in baseClasses)) {225 var node = new WebInspector.HeapSnapshotDiffNode(this, clss, null, classes[clss]);226 ++nodeCount;227 node.calculateDiff(this, addNodeIfNonZeroDiff.bind(this, node));228 }229 258 } 230 259 } … … 244 273 retainedSize: { title: WebInspector.UIString("Retained Size"), width: "90px", sort: "descending", sortable: true } 245 274 }; 246 WebInspector.DataGrid.call(this, columns); 247 this.addEventListener("sorting changed", this.sort, this); 275 WebInspector.HeapSnapshotSortableDataGrid.call(this, columns); 248 276 } 249 277 … … 258 286 this._provider = this._createProvider(snapshot, this.snapshotNodeIndex); 259 287 this.sort(); 288 }, 289 290 sortingChanged: function() 291 { 292 this.sort(); 260 293 } 261 294 }; 262 295 263 296 MixInSnapshotNodeFunctions(WebInspector.HeapSnapshotDominatorObjectNode.prototype, WebInspector.HeapSnapshotDominatorsDataGrid.prototype); 264 WebInspector.HeapSnapshotDominatorsDataGrid.prototype.__proto__ = WebInspector. DataGrid.prototype;297 WebInspector.HeapSnapshotDominatorsDataGrid.prototype.__proto__ = WebInspector.HeapSnapshotSortableDataGrid.prototype; 265 298 266 299 WebInspector.HeapSnapshotRetainingPathsList = function() … … 373 406 return sortFunction(nodeA.data, nodeB.data); 374 407 } 375 408 this.recursiveSortingEnter(); 376 409 this.sortNodes(DataExtractorWrapper); 410 this.recursiveSortingLeave(); 377 411 } 378 412 }; … … 724 758 delete this._baseProfileWrapper; 725 759 this.baseProfile._lastShown = Date.now(); 726 WebInspector.PleaseWaitMessage.prototype.startAction(this.currentView.element, showDiffData.bind(this)); 727 } 728 729 function showDiffData() 730 { 760 WebInspector.PleaseWaitMessage.prototype.showAndWaitFor(this.currentView.element, this.diffDataGrid, "sorting complete"); 731 761 this.diffDataGrid.setBaseDataSource(this.baseProfileWrapper); 732 762 } … … 806 836 } else { 807 837 this.baseSelectElement.addStyleClass("hidden"); 808 if (!this.dataGrid.snapshotView) 809 WebInspector.PleaseWaitMessage.prototype.startAction(this.currentView.element, loadData.bind(this)); 810 } 811 812 function loadData() 813 { 814 this.dataGrid.setDataSource(this, this.profileWrapper); 838 if (!this.dataGrid.snapshotView) { 839 WebInspector.PleaseWaitMessage.prototype.showAndWaitFor(this.currentView.element, this.dataGrid, "sorting complete"); 840 this.dataGrid.setDataSource(this, this.profileWrapper); 841 } 815 842 } 816 843 … … 868 895 _showStringContentPopup: function(span) 869 896 { 870 var snapshotNode = new WebInspector.HeapSnapshotNode(this.profileWrapper, span.snapshotNodeIndex);871 897 var stringContentElement = document.createElement("span"); 872 898 stringContentElement.className = "monospace console-formatted-string"; 873 899 stringContentElement.style.whiteSpace = "pre"; 874 stringContentElement.textContent = "\"" + snapshotNode.name + "\""; 900 875 901 var popover = new WebInspector.Popover(stringContentElement); 876 popover.show(span); 902 function displayString(names) 903 { 904 if (names.length > 0) { 905 stringContentElement.textContent = "\"" + names[0] + "\""; 906 popover.show(span); 907 } 908 } 909 this.profileWrapper.nodeFieldValuesByIndex("name", [span.snapshotNodeIndex], displayString); 877 910 return popover; 878 911 }, -
trunk/Source/WebCore/inspector/front-end/HeapSnapshot.js
r83850 r84619 527 527 delete this._nodes; 528 528 delete this._strings; 529 delete this._idsList;530 529 delete this._retainers; 531 530 delete this._retainerIndex; … … 578 577 { 579 578 return this.rootNode.retainedSize; 580 },581 582 hasId: function(id)583 {584 return this.nodeIds.binaryIndexOf(id, this._numbersComparator) >= 0;585 },586 587 get nodeIds()588 {589 if (!this._idsList)590 this._buildIdsList();591 return this._idsList;592 579 }, 593 580 … … 690 677 691 678 this._aggregatesWithIndexes = true; 692 },693 694 _buildIdsList: function()695 {696 var count = 0;697 for (var nodesIter = this._allNodes; nodesIter.hasNext(); nodesIter.next(), ++count);698 this._idsList = new Array(count);699 count = 0;700 for (nodesIter = this._allNodes; nodesIter.hasNext(); nodesIter.next(), ++count)701 this._idsList[count] = nodesIter.node.id;702 this._idsList.sort(this._numbersComparator);703 679 }, 704 680 … … 776 752 }, 777 753 778 updateBaseNodeIds: function(baseSnapshotId, className, nodeIds)754 pushBaseNodeIds: function(baseSnapshotId, className, nodeIds) 779 755 { 780 756 if (!this._baseNodeIds) … … 852 828 ++this._position; 853 829 }, 830 831 serializeNextItems: function(count) 832 { 833 var result = new Array(count); 834 for (var i = 0 ; i < count && this.hasNext(); ++i, this.next()) 835 result[i] = this._serialize(this.item); 836 result.length = i; 837 result.hasNext = this.hasNext(); 838 result.totalLength = this.length; 839 return result; 840 }, 841 842 sortAndRewind: function(comparator) 843 { 844 var result = this.sort(comparator); 845 if (result) 846 this.first(); 847 return result; 848 } 854 849 } 855 850 … … 867 862 868 863 WebInspector.HeapSnapshotEdgesProvider.prototype = { 864 _serialize: function(edge) 865 { 866 return {name: edge.name, node: WebInspector.HeapSnapshotNodesProvider.prototype._serialize(edge.node), nodeIndex: edge.nodeIndex, type: edge.type}; 867 }, 868 869 869 sort: function(comparator) 870 870 { … … 950 950 951 951 WebInspector.HeapSnapshotNodesProvider.prototype = { 952 _serialize: function(node) 953 { 954 return {id: node.id, name: node.name, nodeIndex: node.nodeIndex, retainedSize: node.retainedSize, selfSize: node.selfSize, type: node.type}; 955 }, 956 952 957 sort: function(comparator) 953 958 { … … 1154 1159 1155 1160 WebInspector.HeapSnapshotsDiff.prototype = { 1156 set baseIds(baseIds)1157 {1158 this._baseIds = baseIds;1159 },1160 1161 set baseSelfSizes(baseSelfSizes)1162 {1163 this._baseSelfSizes = baseSelfSizes;1164 },1165 1166 1161 calculate: function() 1167 1162 { 1168 var indexes = this._snapshot.aggregates(true)[this._className].idxs; 1163 var aggregates = this._snapshot.aggregates(true)[this._className]; 1164 var indexes = aggregates ? aggregates.idxs : []; 1169 1165 var i = 0, l = this._baseIds.length; 1170 1166 var j = 0, m = indexes.length; 1171 1167 var diff = { addedCount: 0, removedCount: 0, addedSize: 0, removedSize: 0 }; 1172 1168 1173 var nodeB = new WebInspector.HeapSnapshotNode(this._snapshot );1169 var nodeB = new WebInspector.HeapSnapshotNode(this._snapshot, indexes[j]); 1174 1170 while (i < l && j < m) { 1175 1171 var nodeAId = this._baseIds[i]; … … 1200 1196 diff.sizeDelta = diff.addedSize - diff.removedSize; 1201 1197 return diff; 1198 }, 1199 1200 pushBaseIds: function(baseIds) 1201 { 1202 this._baseIds = baseIds; 1203 }, 1204 1205 pushBaseSelfSizes: function(baseSelfSizes) 1206 { 1207 this._baseSelfSizes = baseSelfSizes; 1202 1208 } 1203 1209 }; -
trunk/Source/WebCore/inspector/front-end/HeapSnapshotProxy.js
r83850 r84619 53 53 }, 54 54 55 _extractEdgeData: function(edge)56 {57 return {name: edge.name, node: this._extractNodeData(edge.node), nodeIndex: edge.nodeIndex, type: edge.type};58 },59 60 _extractNodeData: function(node)61 {62 return {id: node.id, name: node.name, nodeIndex: node.nodeIndex, retainedSize: node.retainedSize, selfSize: node.selfSize, type: node.type};63 },64 65 55 createDiff: function(className) 66 56 { … … 76 66 return new WebInspector.HeapSnapshotEdgesProvider(this._snapshot, nodeIndex, filter); 77 67 } 78 return new WebInspector.HeapSnapshotProviderProxy(createProvider.bind(this) , this._extractEdgeData.bind(this));68 return new WebInspector.HeapSnapshotProviderProxy(createProvider.bind(this)); 79 69 }, 80 70 … … 87 77 return new WebInspector.HeapSnapshotNodesProvider(this._snapshot, filter); 88 78 } 89 return new WebInspector.HeapSnapshotProviderProxy(createProvider.bind(this) , this._extractNodeData.bind(this));79 return new WebInspector.HeapSnapshotProviderProxy(createProvider.bind(this)); 90 80 }, 91 81 … … 141 131 }, 142 132 143 nodeIds: function(callback)144 {145 this._invokeGetter("nodeIds", callback);146 },147 148 133 pushJSONChunk: function(chunk) 149 134 { … … 155 140 pushBaseIds: function(snapshotId, className, nodeIds) 156 141 { 157 this._snapshot. updateBaseNodeIds(snapshotId, className, nodeIds);142 this._snapshot.pushBaseNodeIds(snapshotId, className, nodeIds); 158 143 }, 159 144 … … 194 179 }; 195 180 196 WebInspector.HeapSnapshotProviderProxy = function(createProvider , extractData)181 WebInspector.HeapSnapshotProviderProxy = function(createProvider) 197 182 { 198 183 this._provider = createProvider(); 199 this._extractData = extractData;200 184 } 201 185 202 186 WebInspector.HeapSnapshotProviderProxy.prototype = { 203 getNextItems: function(count, callback) 204 { 205 function returnResult() 206 { 207 var result = new Array(count); 208 for (var i = 0 ; i < count && this._provider.hasNext(); ++i, this._provider.next()) 209 result[i] = this._extractData(this._provider.item); 210 result.length = i; 211 callback(result, this._provider.hasNext(), this._provider.length); 187 serializeNextItems: function(count, callback) 188 { 189 function returnResult() 190 { 191 callback(this._provider.serializeNextItems(count)); 212 192 } 213 193 setTimeout(returnResult.bind(this), 0); … … 227 207 function returnResult() 228 208 { 229 var result = this._provider.sort(comparator); 230 if (result) 231 this._provider.first(); 232 callback(result); 209 callback(this._provider.sortAndRewind(comparator)); 233 210 } 234 211 setTimeout(returnResult.bind(this), 0); … … 276 253 }, 277 254 278 pushBaseIds: function(base SnapshotId, baseIds)279 { 280 this._diff. baseIds = baseIds;255 pushBaseIds: function(baseIds) 256 { 257 this._diff.pushBaseIds(baseIds); 281 258 }, 282 259 283 260 pushBaseSelfSizes: function(baseSelfSizes) 284 261 { 285 this._diff. baseSelfSizes = baseSelfSizes;286 } 287 }; 262 this._diff.pushBaseSelfSizes(baseSelfSizes); 263 } 264 }; -
trunk/Source/WebCore/inspector/front-end/PleaseWaitMessage.js
r83718 r84619 82 82 }, 83 83 84 s tartAction: function(element, actionCallback, cancelCallback)84 showAndWaitFor: function(element, listenObject, listenEvent) 85 85 { 86 86 var instance = WebInspector.PleaseWaitMessage.prototype.instance; 87 87 var message = instance.element; 88 if (message.parentNode === element) { 89 setTimeout(actionCallback, 0); 88 if (message.parentNode === element) 90 89 return; 91 }92 93 function doAction()94 {95 try {96 actionCallback();97 } finally {98 if (message.parentNode)99 message.parentNode.removeChild(message);100 }101 }102 90 103 WebInspector.PleaseWaitMessage.prototype.show(element, cancelCallback); 104 setTimeout(doAction, 0); 91 listenObject.addEventListener(listenEvent, WebInspector.PleaseWaitMessage.prototype.unlistenAndHide.bind(instance, listenObject, listenEvent), instance); 92 WebInspector.PleaseWaitMessage.prototype.show(element); 93 }, 94 95 unlistenAndHide: function(listenObject, listenEvent) 96 { 97 var instance = WebInspector.PleaseWaitMessage.prototype.instance; 98 listenObject.removeEventListener(listenEvent, WebInspector.PleaseWaitMessage.prototype.unlistenAndHide, instance); 99 WebInspector.PleaseWaitMessage.prototype.hide(); 105 100 } 106 101 }; -
trunk/Source/WebCore/inspector/front-end/WebKit.qrc
r83864 r84619 9 9 <file>AuditRules.js</file> 10 10 <file>AuditsPanel.js</file> 11 <file>BinarySearch.js</file> 11 12 <file>BottomUpProfileDataGridTree.js</file> 12 13 <file>BreakpointsSidebarPane.js</file> -
trunk/Source/WebCore/inspector/front-end/inspector.html
r83962 r84619 40 40 <link rel="stylesheet" type="text/css" href="textViewer.css"> 41 41 <script type="text/javascript" src="utilities.js"></script> 42 <script type="text/javascript" src="BinarySearch.js"></script> 42 43 <script type="text/javascript" src="treeoutline.js"></script> 43 44 <script type="text/javascript" src="inspector.js"></script> -
trunk/Source/WebCore/inspector/front-end/utilities.js
r84614 r84619 775 775 } 776 776 777 function binarySearch(object, array, comparator)778 {779 var first = 0;780 var last = array.length - 1;781 782 while (first <= last) {783 var mid = (first + last) >> 1;784 var c = comparator(object, array[mid]);785 if (c > 0)786 first = mid + 1;787 else if (c < 0)788 last = mid - 1;789 else790 return mid;791 }792 793 // Return the nearest lesser index, "-1" means "0, "-2" means "1", etc.794 return -(first + 1);795 }796 797 Object.defineProperty(Array.prototype, "binaryIndexOf", { value: function(value, comparator)798 {799 var result = binarySearch(value, this, comparator);800 return result >= 0 ? result : -1;801 }});802 803 function insertionIndexForObjectInListSortedByFunction(anObject, aList, aFunction)804 {805 var index = binarySearch(anObject, aList, aFunction);806 if (index < 0)807 // See binarySearch implementation.808 return -index - 1;809 else {810 // Return the first occurance of an item in the list.811 while (index > 0 && aFunction(anObject, aList[index - 1]) === 0)812 index--;813 return index;814 }815 }816 817 777 String.sprintf = function(format) 818 778 {
Note: See TracChangeset
for help on using the changeset viewer.