Changeset 116847 in webkit
- Timestamp:
- May 12, 2012 3:17:18 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r116846 r116847 1 2012-05-11 Yury Semikhatsky <yurys@chromium.org> 2 3 Web Inspector: allow showing arbitrary range of nodes in heap snapshot view 4 https://bugs.webkit.org/show_bug.cgi?id=86230 5 6 Reviewed by Pavel Feldman. 7 8 * inspector/profiler/heap-snapshot-comparison-show-all.html: 9 * inspector/profiler/heap-snapshot-containment-show-all.html: 10 * inspector/profiler/heap-snapshot-dominators-show-all.html: 11 * inspector/profiler/heap-snapshot-summary-show-all.html: 12 * inspector/profiler/heap-snapshot-summary-show-ranges-expected.txt: Added. 13 * inspector/profiler/heap-snapshot-summary-show-ranges.html: Added. Test that 14 showing overlapping and disjoint ranges of node children will leave the node 15 in a valid state. 16 * platform/mac/Skipped: Skip the test on platforms that don't support heap profiling. 17 * platform/qt/Skipped: 18 * platform/win/Skipped: 19 * platform/wincairo/Skipped: 20 1 21 2012-05-12 Pavel Feldman <pfeldman@chromium.org> 2 22 -
trunk/LayoutTests/inspector/profiler/heap-snapshot-comparison-show-all.html
r115189 r116847 52 52 var maybeNumber = parseInt(words[i], 10); 53 53 if (!isNaN(maybeNumber)) 54 InspectorTest.assertEquals(countA + countB , maybeNumber, buttonsNode.showAll.textContent);54 InspectorTest.assertEquals(countA + countB - row._dataGrid.defaultPopulateCount(), maybeNumber, buttonsNode.showAll.textContent); 55 55 } 56 56 InspectorTest.clickShowMoreButton("showAll", buttonsNode, step4); -
trunk/LayoutTests/inspector/profiler/heap-snapshot-containment-show-all.html
r114271 r116847 36 36 var maybeNumber = parseInt(words[i], 10); 37 37 if (!isNaN(maybeNumber)) 38 InspectorTest.assertEquals(instanceCount , maybeNumber, buttonsNode.showAll.textContent);38 InspectorTest.assertEquals(instanceCount - row._dataGrid.defaultPopulateCount(), maybeNumber, buttonsNode.showAll.textContent); 39 39 } 40 40 InspectorTest.clickShowMoreButton("showAll", buttonsNode, step4); -
trunk/LayoutTests/inspector/profiler/heap-snapshot-dominators-show-all.html
r114271 r116847 36 36 var maybeNumber = parseInt(words[i], 10); 37 37 if (!isNaN(maybeNumber)) 38 InspectorTest.assertEquals(instanceCount , maybeNumber, buttonsNode.showAll.textContent);38 InspectorTest.assertEquals(instanceCount - row._dataGrid.defaultPopulateCount(), maybeNumber, buttonsNode.showAll.textContent); 39 39 } 40 40 InspectorTest.clickShowMoreButton("showAll", buttonsNode, step4); -
trunk/LayoutTests/inspector/profiler/heap-snapshot-summary-show-all.html
r114271 r116847 40 40 var maybeNumber = parseInt(words[i], 10); 41 41 if (!isNaN(maybeNumber)) 42 InspectorTest.assertEquals(instanceCount , maybeNumber, buttonsNode.showAll.textContent);42 InspectorTest.assertEquals(instanceCount - row._dataGrid.defaultPopulateCount(), maybeNumber, buttonsNode.showAll.textContent); 43 43 } 44 44 InspectorTest.clickShowMoreButton("showAll", buttonsNode, step4); -
trunk/LayoutTests/platform/mac/Skipped
r116784 r116847 283 283 inspector/profiler/heap-snapshot-inspect-dom-wrapper.html 284 284 inspector/profiler/heap-snapshot-comparison-dom-groups-change.html 285 inspector/profiler/heap-snapshot-summary-show-ranges.html 285 286 286 287 # Skipping newly added tests while I'm finding out what is wrong. -
trunk/LayoutTests/platform/qt/Skipped
r116784 r116847 270 270 inspector/profiler/heap-snapshot-inspect-dom-wrapper.html 271 271 inspector/profiler/heap-snapshot-comparison-dom-groups-change.html 272 inspector/profiler/heap-snapshot-summary-show-ranges.html 272 273 273 274 # https://bugs.webkit.org/show_bug.cgi?id=40300 -
trunk/LayoutTests/platform/win/Skipped
r116592 r116847 1258 1258 inspector/profiler/heap-snapshot-inspect-dom-wrapper.html 1259 1259 inspector/profiler/heap-snapshot-comparison-dom-groups-change.html 1260 inspector/profiler/heap-snapshot-summary-show-ranges.html 1260 1261 1261 1262 # https://bugs.webkit.org/show_bug.cgi?id=40300 -
trunk/LayoutTests/platform/wincairo/Skipped
r116563 r116847 1770 1770 inspector/profiler/heap-snapshot-inspect-dom-wrapper.html 1771 1771 inspector/profiler/heap-snapshot-comparison-dom-groups-change.html 1772 inspector/profiler/heap-snapshot-summary-show-ranges.html 1772 1773 1773 1774 # https://bugs.webkit.org/show_bug.cgi?id=40300 -
trunk/Source/WebCore/ChangeLog
r116846 r116847 1 2012-05-11 Yury Semikhatsky <yurys@chromium.org> 2 3 Web Inspector: allow showing arbitrary range of nodes in heap snapshot view 4 https://bugs.webkit.org/show_bug.cgi?id=86230 5 6 Reviewed by Pavel Feldman. 7 8 Test: inspector/profiler/heap-snapshot-summary-show-ranges.html 9 10 It was only possible to expand heap snapshot node children sequentially starting 11 from the first child and then pressing either "Show next X items" or "Show all X items". 12 This change makes it possible to show any range of children. 13 14 * inspector/front-end/HeapSnapshot.js: 15 (WebInspector.HeapSnapshotFilteredOrderedIterator): 16 (WebInspector.HeapSnapshotFilteredOrderedIterator.prototype.serializeItemsRange): 17 (WebInspector.HeapSnapshotFilteredOrderedIterator.prototype.sortAll): 18 (WebInspector.HeapSnapshotFilteredOrderedIterator.prototype.sortAndRewind): 19 (WebInspector.HeapSnapshotEdgesProvider.prototype.serializeItem): 20 (WebInspector.HeapSnapshotNodesProvider.prototype.serializeItem): 21 * inspector/front-end/HeapSnapshotGridNodes.js: 22 (WebInspector.HeapSnapshotGridNode): 23 (WebInspector.HeapSnapshotGridNode.prototype._populate.sorted): 24 (WebInspector.HeapSnapshotGridNode.prototype._populate): 25 (WebInspector.HeapSnapshotGridNode.prototype._populateChildren.serializeNextChunk): 26 (WebInspector.HeapSnapshotGridNode.prototype._populateChildren.insertRetrievedChild): 27 (WebInspector.HeapSnapshotGridNode.prototype._populateChildren.insertShowMoreButton): 28 (WebInspector.HeapSnapshotGridNode.prototype._populateChildren.childrenRetrieved): 29 (WebInspector.HeapSnapshotGridNode.prototype._populateChildren): 30 (WebInspector.HeapSnapshotGridNode.prototype._saveChildren): 31 (WebInspector.HeapSnapshotGridNode.prototype.sort.afterSort): 32 (WebInspector.HeapSnapshotGridNode.prototype.sort): 33 (WebInspector.HeapSnapshotDiffNodesProvider): 34 (WebInspector.HeapSnapshotDiffNodesProvider.prototype.serializeItemsRange): 35 (WebInspector.HeapSnapshotDiffNodesProvider.prototype.serializeItemsRange.didReceiveDeletedItems): 36 (WebInspector.HeapSnapshotDiffNodesProvider.prototype.serializeItemsRange.didReceiveAddedItems): 37 (WebInspector.HeapSnapshotDiffNodesProvider.prototype.sortAndRewind): 38 * inspector/front-end/HeapSnapshotProxy.js: 39 (WebInspector.HeapSnapshotWorker): 40 (WebInspector.HeapSnapshotProviderProxy.prototype.serializeItemsRange): 41 * inspector/front-end/ShowMoreDataGridNode.js: 42 (WebInspector.ShowMoreDataGridNode): 43 (WebInspector.ShowMoreDataGridNode.prototype._showNextChunk): 44 (WebInspector.ShowMoreDataGridNode.prototype._showAll): 45 (WebInspector.ShowMoreDataGridNode.prototype._updateLabels): 46 (WebInspector.ShowMoreDataGridNode.prototype.setStartPosition): 47 (WebInspector.ShowMoreDataGridNode.prototype.setEndPosition): 48 * inspector/front-end/utilities.js: 49 1 50 2012-05-12 Pavel Feldman <pfeldman@chromium.org> 2 51 -
trunk/Source/WebCore/inspector/front-end/HeapSnapshot.js
r116771 r116847 1348 1348 this._position = 0; 1349 1349 this._currentComparator = null; 1350 this._ lastComparator = null;1350 this._sortedPrefixLength = 0; 1351 1351 } 1352 1352 … … 1436 1436 }, 1437 1437 1438 serializeSubsequentItems: function(count) 1438 /** 1439 * @param {number} begin 1440 * @param {number} end 1441 */ 1442 serializeItemsRange: function(begin, end) 1439 1443 { 1440 1444 this._createIterationOrder(); 1445 if (begin > end) 1446 throw new Error("Start position > end position: " + begin + " > " + end); 1447 if (end >= this._iterationOrder.length) 1448 end = this._iterationOrder.length; 1449 if (this._sortedPrefixLength < end) { 1450 this.sort(this._currentComparator, this._sortedPrefixLength, this._iterationOrder.length - 1, end - this._sortedPrefixLength); 1451 this._sortedPrefixLength = end; 1452 } 1453 1454 this._position = begin; 1455 var startPosition = this._position; 1456 var count = end - begin; 1441 1457 var result = new Array(count); 1442 if (this._lastComparator !== this._currentComparator)1443 this.sort(this._currentComparator, this._position, this._iterationOrder.length - 1, count);1444 1458 for (var i = 0 ; i < count && this.hasNext(); ++i, this.next()) 1445 result[i] = this. _serialize(this.item);1459 result[i] = this.serializeItem(this.item); 1446 1460 result.length = i; 1447 result.hasNext = this.hasNext();1448 1461 result.totalLength = this._iterationOrder.length; 1462 1463 result.startPosition = startPosition; 1464 result.endPosition = this._position; 1449 1465 return result; 1450 1466 }, 1451 1467 1468 sortAll: function() 1469 { 1470 this._createIterationOrder(); 1471 if (this._sortedPrefixLength === this._iterationOrder.length) 1472 return; 1473 this.sort(this._currentComparator, this._sortedPrefixLength, this._iterationOrder.length - 1, this._iterationOrder.length); 1474 this._sortedPrefixLength = this._iterationOrder.length; 1475 }, 1476 1452 1477 sortAndRewind: function(comparator) 1453 1478 { 1454 this._lastComparator = this._currentComparator;1455 1479 this._currentComparator = comparator; 1456 var result = this._lastComparator !== this._currentComparator; 1457 if (result) 1458 this.first(); 1459 return result; 1480 this._sortedPrefixLength = 0; 1481 this.first(); 1460 1482 } 1461 1483 } … … 1477 1499 1478 1500 WebInspector.HeapSnapshotEdgesProvider.prototype = { 1479 _serialize: function(edge)1501 serializeItem: function(edge) 1480 1502 { 1481 1503 return { 1482 1504 name: edge.name, 1483 1505 propertyAccessor: edge.toString(), 1484 node: WebInspector.HeapSnapshotNodesProvider.prototype. _serialize(edge.node),1506 node: WebInspector.HeapSnapshotNodesProvider.prototype.serializeItem(edge.node), 1485 1507 nodeIndex: edge.nodeIndex, 1486 1508 type: edge.type, … … 1572 1594 1573 1595 WebInspector.HeapSnapshotNodesProvider.prototype = { 1574 _serialize: function(node)1596 serializeItem: function(node) 1575 1597 { 1576 1598 return { -
trunk/Source/WebCore/inspector/front-end/HeapSnapshotGridNodes.js
r116768 r116847 45 45 this._dataGrid = tree; 46 46 this._instanceCount = 0; 47 48 this._savedChildren = null; 49 /** 50 * List of position ranges for all visible nodes: [startPos1, endPos1),...,[startPosN, endPosN) 51 * Position is an item position in the provider. 52 */ 53 this._retrievedChildrenRanges = []; 47 54 this.addEventListener("populate", this._populate, this); 48 55 } … … 107 114 { 108 115 this.removeEventListener("populate", this._populate, this); 109 function sorted( ignored)116 function sorted() 110 117 { 111 118 this._populateChildren(); … … 115 122 116 123 /** 117 * @param {?number} howMany118 * @param {?number} atIndex124 * @param {?number} fromPosition 125 * @param {?number} toPosition 119 126 */ 120 _populateChildren: function(howMany, atIndex, afterPopulate) 121 { 122 howMany = howMany || this._dataGrid.defaultPopulateCount(); 123 atIndex = atIndex || this.children.length; 124 var haveSavedChildren = !!this._savedChildren; 125 if (haveSavedChildren) { 126 haveSavedChildren = false; 127 for (var c in this._savedChildren) { 128 haveSavedChildren = true; 129 break; 127 _populateChildren: function(fromPosition, toPosition, afterPopulate) 128 { 129 fromPosition = fromPosition || 0; 130 toPosition = toPosition || fromPosition + this._dataGrid.defaultPopulateCount(); 131 var firstNotSerializedPosition = fromPosition; 132 function serializeNextChunk() 133 { 134 if (firstNotSerializedPosition >= toPosition) 135 return; 136 var end = Math.min(firstNotSerializedPosition + this._dataGrid.defaultPopulateCount(), toPosition); 137 this._provider.serializeItemsRange(firstNotSerializedPosition, end, childrenRetrieved.bind(this)); 138 firstNotSerializedPosition = end; 139 } 140 function insertRetrievedChild(item, insertionIndex) 141 { 142 if (this._savedChildren) { 143 var hash = this._childHashForEntity(item); 144 if (hash in this._savedChildren) { 145 this.insertChild(this._savedChildren[hash], insertionIndex); 146 return; 147 } 130 148 } 131 } 132 133 var part = 0; 134 function callSerialize() 135 { 136 if (part >= howMany) 137 return; 138 part += this._dataGrid.defaultPopulateCount(); 139 this._provider.serializeSubsequentItems(this._dataGrid.defaultPopulateCount(), childrenRetrieved.bind(this)); 149 this.insertChild(this._createChildNode(item), insertionIndex); 150 } 151 function insertShowMoreButton(from, to, insertionIndex) 152 { 153 var button = new WebInspector.ShowMoreDataGridNode(this._populateChildren.bind(this), from, to, this._dataGrid.defaultPopulateCount()); 154 this.insertChild(button, insertionIndex); 140 155 } 141 156 function childrenRetrieved(items) 142 157 { 143 var length = items.totalLength; 144 for (var i = 0, l = items.length; i < l; ++i) { 145 var item = items[i]; 146 if (haveSavedChildren) { 147 var hash = this._childHashForEntity(item); 148 if (hash in this._savedChildren) { 149 this.insertChild(this._savedChildren[hash], atIndex++); 150 continue; 158 var itemIndex = 0; 159 var itemPosition = items.startPosition; 160 var insertionIndex = 0; 161 162 if (!this._retrievedChildrenRanges.length) { 163 if (items.startPosition > 0) { 164 this._retrievedChildrenRanges.push({from: 0, to: 0}); 165 insertShowMoreButton.call(this, 0, items.startPosition, insertionIndex); 166 } 167 this._retrievedChildrenRanges.push({from: items.startPosition, to: items.endPosition}); 168 for (var i = 0, l = items.length; i < l; ++i) 169 insertRetrievedChild.call(this, items[i], insertionIndex++); 170 if (items.endPosition < items.totalLength) 171 insertShowMoreButton.call(this, items.endPosition, items.totalLength, insertionIndex++); 172 } else { 173 var rangeIndex = 0; 174 var found = false; 175 var range; 176 while (rangeIndex < this._retrievedChildrenRanges.length) { 177 range = this._retrievedChildrenRanges[rangeIndex]; 178 if (range.to >= itemPosition) { 179 found = true; 180 break; 181 } 182 insertionIndex += range.to - range.from; 183 // Skip the button if there is one. 184 if (range.to < items.totalLength) 185 insertionIndex += 1; 186 ++rangeIndex; 187 } 188 189 if (!found || items.startPosition < range.from) { 190 // Update previous button. 191 this.children[insertionIndex - 1].setEndPosition(items.startPosition); 192 insertShowMoreButton.call(this, items.startPosition, found ? range.from : items.totalLength, insertionIndex); 193 range = {from: items.startPosition, to: items.startPosition}; 194 if (!found) 195 rangeIndex = this._retrievedChildrenRanges.length; 196 this._retrievedChildrenRanges.splice(rangeIndex, 0, range); 197 } else { 198 insertionIndex += itemPosition - range.from; 199 } 200 // At this point insertionIndex is always an index before button or between nodes. 201 // Also it is always true here that range.from <= itemPosition <= range.to 202 203 // Stretch the range right bound to include all new items. 204 while (range.to < items.endPosition) { 205 // Skip already added nodes. 206 var skipCount = range.to - itemPosition; 207 insertionIndex += skipCount; 208 itemIndex += skipCount; 209 itemPosition = range.to; 210 211 // We're at the position before button: ...<?node>x<button> 212 var nextRange = this._retrievedChildrenRanges[rangeIndex + 1]; 213 var newEndOfRange = nextRange ? nextRange.from : items.totalLength; 214 if (newEndOfRange > items.endPosition) 215 newEndOfRange = items.endPosition; 216 while (itemPosition < newEndOfRange) { 217 insertRetrievedChild.call(this, items[itemIndex++], insertionIndex++); 218 ++itemPosition; 219 } 220 // Merge with the next range. 221 if (nextRange && newEndOfRange === nextRange.from) { 222 range.to = nextRange.to; 223 // Remove "show next" button if there is one. 224 this.removeChild(this.children[insertionIndex]); 225 this._retrievedChildrenRanges.splice(rangeIndex + 1, 1); 226 } else { 227 range.to = newEndOfRange; 228 // Remove or update next button. 229 if (newEndOfRange === items.totalLength) 230 this.removeChild(this.children[insertionIndex]); 231 else 232 this.children[insertionIndex].setStartPosition(items.endPosition); 151 233 } 152 234 } 153 this.insertChild(this._createChildNode(item), atIndex++);154 235 } 236 237 // TODO: fix this. 155 238 this._instanceCount += items.length; 156 if ( part < howMany) {157 setTimeout( callSerialize.bind(this), 0);239 if (firstNotSerializedPosition < toPosition) { 240 setTimeout(serializeNextChunk.bind(this), 0); 158 241 return; 159 242 } 160 243 161 if (items.hasNext)162 this.insertChild(new WebInspector.ShowMoreDataGridNode(this._populateChildren.bind(this), this._dataGrid.defaultPopulateCount(), length), atIndex++);163 244 if (afterPopulate) 164 245 afterPopulate(); 165 function notify() 166 { 167 this.dispatchEventToListeners("populate complete"); 168 } 169 setTimeout(notify.bind(this), 0); 170 } 171 setTimeout(callSerialize.bind(this), 0); 246 this.dispatchEventToListeners("populate complete"); 247 } 248 setTimeout(serializeNextChunk.bind(this), 0); 172 249 }, 173 250 174 251 _saveChildren: function() 175 252 { 176 this._savedChildren = {};253 this._savedChildren = null; 177 254 for (var i = 0, childrenCount = this.children.length; i < childrenCount; ++i) { 178 255 var child = this.children[i]; 179 if (child.expanded) 180 this._savedChildren[this._childHashForNode(child)] = child; 256 if (!child.expanded) 257 continue; 258 if (!this._savedChildren) 259 this._savedChildren = {}; 260 this._savedChildren[this._childHashForNode(child)] = child; 181 261 } 182 262 }, … … 185 265 { 186 266 this._dataGrid.recursiveSortingEnter(); 187 function afterSort(sorted) 188 { 189 if (!sorted) { 190 this._dataGrid.recursiveSortingLeave(); 191 return; 192 } 267 function afterSort() 268 { 193 269 this._saveChildren(); 194 270 this.removeChildren(); 271 this._retrievedChildrenRanges = []; 195 272 196 273 function afterPopulate() … … 205 282 var instanceCount = this._instanceCount; 206 283 this._instanceCount = 0; 207 this._populateChildren( instanceCount, null, afterPopulate.bind(this));284 this._populateChildren(0, instanceCount, afterPopulate.bind(this)); 208 285 } 209 286 this._provider.sortAndRewind(this.comparator(), afterSort.bind(this)); … … 694 771 this._addedCount = addedCount; 695 772 this._removedCount = removedCount; 696 this._serializedItemsCount = 0;697 773 } 698 774 … … 709 785 }, 710 786 711 serialize SubsequentItems: function(count, callback)787 serializeItemsRange: function(beginPosition, endPosition, callback) 712 788 { 713 789 function didReceiveAllItems(items) 714 790 { 715 this._serializedItemsCount += items.length;716 791 items.totalLength = this._addedCount + this._removedCount; 717 792 callback(items); … … 720 795 function didReceiveDeletedItems(addedItems, items) 721 796 { 797 if (!addedItems.length) 798 addedItems.startPosition = this._addedCount + items.startPosition; 722 799 for (var i = 0; i < items.length; i++) { 723 800 items[i].isAddedNotRemoved = false; 724 801 addedItems.push(items[i]); 725 802 } 726 addedItems. hasNext = items.hasNext;803 addedItems.endPosition = this._addedCount + items.endPosition; 727 804 didReceiveAllItems.call(this, addedItems); 728 805 } … … 732 809 for (var i = 0; i < items.length; i++) 733 810 items[i].isAddedNotRemoved = true; 734 if (items. length < count)735 return this._deletedNodesProvider.serialize SubsequentItems(count - items.length, didReceiveDeletedItems.bind(this, items));811 if (items.endPosition < endPosition) 812 return this._deletedNodesProvider.serializeItemsRange(0, endPosition - items.endPosition, didReceiveDeletedItems.bind(this, items)); 736 813 737 814 items.totalLength = this._addedCount + this._removedCount; 738 if (!items.hasNext)739 items.hasNext = !!this._removedCount;740 815 didReceiveAllItems.call(this, items); 741 816 } 742 817 743 if ( this._serializedItemsCount< this._addedCount)744 this._addedNodesProvider.serialize SubsequentItems(count, didReceiveAddedItems.bind(this));818 if (beginPosition < this._addedCount) 819 this._addedNodesProvider.serializeItemsRange(beginPosition, endPosition, didReceiveAddedItems.bind(this)); 745 820 else 746 this._deletedNodesProvider.serialize SubsequentItems(count, didReceiveDeletedItems.bind(this, []));821 this._deletedNodesProvider.serializeItemsRange(beginPosition - this._addedCount, endPosition - this._addedCount, didReceiveDeletedItems.bind(this, [])); 747 822 }, 748 823 749 824 sortAndRewind: function(comparator, callback) 750 825 { 751 this._serializedItemsCount = 0; 752 753 function afterSort(ignored) 826 function afterSort() 754 827 { 755 828 this._deletedNodesProvider.sortAndRewind(comparator, callback); -
trunk/Source/WebCore/inspector/front-end/HeapSnapshotProxy.js
r115189 r116847 125 125 this._previousCallbacks = []; 126 126 // There is no support for workers in Chromium DRT. 127 this._worker = typeof InspectorTest === "undefined" ? new WebInspector.HeapSnapshotRealWorker() :new WebInspector.HeapSnapshotFakeWorker();127 this._worker = /*typeof InspectorTest === "undefined" ? new WebInspector.HeapSnapshotRealWorker() :*/ new WebInspector.HeapSnapshotFakeWorker(); 128 128 this._worker.addEventListener("message", this._messageReceived, this); 129 129 } … … 492 492 }, 493 493 494 serialize SubsequentItems: function(count, callback)495 { 496 this.callMethod(callback, "serialize SubsequentItems", count);494 serializeItemsRange: function(startPosition, endPosition, callback) 495 { 496 this.callMethod(callback, "serializeItemsRange", startPosition, endPosition); 497 497 }, 498 498 -
trunk/Source/WebCore/inspector/front-end/ShowMoreDataGridNode.js
r114649 r116847 32 32 * @constructor 33 33 * @extends {WebInspector.DataGridNode} 34 * @param {function(number, number)} callback 35 * @param {number} startPosition 36 * @param {number} endPosition 37 * @param {number} chunkSize 34 38 */ 35 WebInspector.ShowMoreDataGridNode = function(callback, nextCount, allCount)39 WebInspector.ShowMoreDataGridNode = function(callback, startPosition, endPosition, chunkSize) 36 40 { 37 function populate(count) 38 { 39 var index = this.parent.children.indexOf(this); 40 this.parent.removeChild(this); 41 callback(count, index); 42 } 41 WebInspector.DataGridNode.call(this, {summaryRow:true}, false); 42 this._callback = callback; 43 this._startPosition = startPosition; 44 this._endPosition = endPosition; 45 this._chunkSize = chunkSize; 43 46 44 47 this.showNext = document.createElement("button"); 45 48 this.showNext.setAttribute("type", "button"); 46 this.showNext.textContent = WebInspector.UIString("Show next %d", nextCount); 47 this.showNext.addEventListener("click", populate.bind(this, nextCount), false); 49 this.showNext.addEventListener("click", this._showNextChunk.bind(this), false); 48 50 49 if (allCount) { 50 this.showAll = document.createElement("button"); 51 this.showAll.setAttribute("type", "button"); 52 this.showAll.textContent = WebInspector.UIString("Show all %d", allCount); 53 this.showAll.addEventListener("click", populate.bind(this, allCount), false); 54 } 51 this.showAll = document.createElement("button"); 52 this.showAll.setAttribute("type", "button"); 53 this.showAll.addEventListener("click", this._showAll.bind(this), false); 55 54 56 WebInspector.DataGridNode.call(this, {summaryRow:true}, false);55 this._updateLabels(); 57 56 this.selectable = false; 58 57 } 59 58 60 59 WebInspector.ShowMoreDataGridNode.prototype = { 60 _showNextChunk: function() 61 { 62 this._callback(this._startPosition, this._startPosition + this._chunkSize); 63 }, 64 65 _showAll: function() 66 { 67 this._callback(this._startPosition, this._endPosition); 68 }, 69 70 _updateLabels: function() 71 { 72 var totalSize = this._endPosition - this._startPosition; 73 var nextChunkSize = Math.min(this._chunkSize, totalSize); 74 this.showNext.textContent = WebInspector.UIString("Show next %d", nextChunkSize); 75 this.showAll.textContent = WebInspector.UIString("Show all %d", totalSize); 76 }, 77 61 78 createCells: function() 62 79 { … … 80 97 81 98 /** 99 * @param {number} from 100 */ 101 setStartPosition: function(from) 102 { 103 this._startPosition = from; 104 this._updateLabels(); 105 }, 106 107 /** 108 * @param {number} to 109 */ 110 setEndPosition: function(to) 111 { 112 this._endPosition = to; 113 this._updateLabels(); 114 }, 115 116 /** 82 117 * @override 83 118 * @return {number} -
trunk/Source/WebCore/inspector/front-end/utilities.js
r115961 r116847 219 219 }); 220 220 221 Object.defineProperty(Uint32Array.prototype, "sort", { 222 value: Array.prototype.sort 223 }); 224 221 225 (function() { 222 226 var partition = {
Note: See TracChangeset
for help on using the changeset viewer.