Changeset 116847 in webkit


Ignore:
Timestamp:
May 12, 2012 3:17:18 AM (12 years ago)
Author:
yurys@chromium.org
Message:

Web Inspector: allow showing arbitrary range of nodes in heap snapshot view
https://bugs.webkit.org/show_bug.cgi?id=86230

Reviewed by Pavel Feldman.

Source/WebCore:

Test: inspector/profiler/heap-snapshot-summary-show-ranges.html

It was only possible to expand heap snapshot node children sequentially starting
from the first child and then pressing either "Show next X items" or "Show all X items".
This change makes it possible to show any range of children.

  • inspector/front-end/HeapSnapshot.js:

(WebInspector.HeapSnapshotFilteredOrderedIterator):
(WebInspector.HeapSnapshotFilteredOrderedIterator.prototype.serializeItemsRange):
(WebInspector.HeapSnapshotFilteredOrderedIterator.prototype.sortAll):
(WebInspector.HeapSnapshotFilteredOrderedIterator.prototype.sortAndRewind):
(WebInspector.HeapSnapshotEdgesProvider.prototype.serializeItem):
(WebInspector.HeapSnapshotNodesProvider.prototype.serializeItem):

  • inspector/front-end/HeapSnapshotGridNodes.js:

(WebInspector.HeapSnapshotGridNode):
(WebInspector.HeapSnapshotGridNode.prototype._populate.sorted):
(WebInspector.HeapSnapshotGridNode.prototype._populate):
(WebInspector.HeapSnapshotGridNode.prototype._populateChildren.serializeNextChunk):
(WebInspector.HeapSnapshotGridNode.prototype._populateChildren.insertRetrievedChild):
(WebInspector.HeapSnapshotGridNode.prototype._populateChildren.insertShowMoreButton):
(WebInspector.HeapSnapshotGridNode.prototype._populateChildren.childrenRetrieved):
(WebInspector.HeapSnapshotGridNode.prototype._populateChildren):
(WebInspector.HeapSnapshotGridNode.prototype._saveChildren):
(WebInspector.HeapSnapshotGridNode.prototype.sort.afterSort):
(WebInspector.HeapSnapshotGridNode.prototype.sort):
(WebInspector.HeapSnapshotDiffNodesProvider):
(WebInspector.HeapSnapshotDiffNodesProvider.prototype.serializeItemsRange):
(WebInspector.HeapSnapshotDiffNodesProvider.prototype.serializeItemsRange.didReceiveDeletedItems):
(WebInspector.HeapSnapshotDiffNodesProvider.prototype.serializeItemsRange.didReceiveAddedItems):
(WebInspector.HeapSnapshotDiffNodesProvider.prototype.sortAndRewind):

  • inspector/front-end/HeapSnapshotProxy.js:

(WebInspector.HeapSnapshotWorker):
(WebInspector.HeapSnapshotProviderProxy.prototype.serializeItemsRange):

  • inspector/front-end/ShowMoreDataGridNode.js:

(WebInspector.ShowMoreDataGridNode):
(WebInspector.ShowMoreDataGridNode.prototype._showNextChunk):
(WebInspector.ShowMoreDataGridNode.prototype._showAll):
(WebInspector.ShowMoreDataGridNode.prototype._updateLabels):
(WebInspector.ShowMoreDataGridNode.prototype.setStartPosition):
(WebInspector.ShowMoreDataGridNode.prototype.setEndPosition):

  • inspector/front-end/utilities.js:

LayoutTests:

  • inspector/profiler/heap-snapshot-comparison-show-all.html:
  • inspector/profiler/heap-snapshot-containment-show-all.html:
  • inspector/profiler/heap-snapshot-dominators-show-all.html:
  • inspector/profiler/heap-snapshot-summary-show-all.html:
  • inspector/profiler/heap-snapshot-summary-show-ranges-expected.txt: Added.
  • inspector/profiler/heap-snapshot-summary-show-ranges.html: Added. Test that

showing overlapping and disjoint ranges of node children will leave the node
in a valid state.

  • platform/mac/Skipped: Skip the test on platforms that don't support heap profiling.
  • platform/qt/Skipped:
  • platform/win/Skipped:
  • platform/wincairo/Skipped:
Location:
trunk
Files:
2 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r116846 r116847  
     12012-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
    1212012-05-12  Pavel Feldman  <pfeldman@chromium.org>
    222
  • trunk/LayoutTests/inspector/profiler/heap-snapshot-comparison-show-all.html

    r115189 r116847  
    5252                    var maybeNumber = parseInt(words[i], 10);
    5353                    if (!isNaN(maybeNumber))
    54                         InspectorTest.assertEquals(countA + countB, maybeNumber, buttonsNode.showAll.textContent);
     54                        InspectorTest.assertEquals(countA + countB - row._dataGrid.defaultPopulateCount(), maybeNumber, buttonsNode.showAll.textContent);
    5555                }
    5656                InspectorTest.clickShowMoreButton("showAll", buttonsNode, step4);
  • trunk/LayoutTests/inspector/profiler/heap-snapshot-containment-show-all.html

    r114271 r116847  
    3636                    var maybeNumber = parseInt(words[i], 10);
    3737                    if (!isNaN(maybeNumber))
    38                         InspectorTest.assertEquals(instanceCount, maybeNumber, buttonsNode.showAll.textContent);
     38                        InspectorTest.assertEquals(instanceCount - row._dataGrid.defaultPopulateCount(), maybeNumber, buttonsNode.showAll.textContent);
    3939                }
    4040                InspectorTest.clickShowMoreButton("showAll", buttonsNode, step4);
  • trunk/LayoutTests/inspector/profiler/heap-snapshot-dominators-show-all.html

    r114271 r116847  
    3636                    var maybeNumber = parseInt(words[i], 10);
    3737                    if (!isNaN(maybeNumber))
    38                         InspectorTest.assertEquals(instanceCount, maybeNumber, buttonsNode.showAll.textContent);
     38                        InspectorTest.assertEquals(instanceCount - row._dataGrid.defaultPopulateCount(), maybeNumber, buttonsNode.showAll.textContent);
    3939                }
    4040                InspectorTest.clickShowMoreButton("showAll", buttonsNode, step4);
  • trunk/LayoutTests/inspector/profiler/heap-snapshot-summary-show-all.html

    r114271 r116847  
    4040                    var maybeNumber = parseInt(words[i], 10);
    4141                    if (!isNaN(maybeNumber))
    42                         InspectorTest.assertEquals(instanceCount, maybeNumber, buttonsNode.showAll.textContent);
     42                        InspectorTest.assertEquals(instanceCount - row._dataGrid.defaultPopulateCount(), maybeNumber, buttonsNode.showAll.textContent);
    4343                }
    4444                InspectorTest.clickShowMoreButton("showAll", buttonsNode, step4);
  • trunk/LayoutTests/platform/mac/Skipped

    r116784 r116847  
    283283inspector/profiler/heap-snapshot-inspect-dom-wrapper.html
    284284inspector/profiler/heap-snapshot-comparison-dom-groups-change.html
     285inspector/profiler/heap-snapshot-summary-show-ranges.html
    285286
    286287# Skipping newly added tests while I'm finding out what is wrong.
  • trunk/LayoutTests/platform/qt/Skipped

    r116784 r116847  
    270270inspector/profiler/heap-snapshot-inspect-dom-wrapper.html
    271271inspector/profiler/heap-snapshot-comparison-dom-groups-change.html
     272inspector/profiler/heap-snapshot-summary-show-ranges.html
    272273
    273274# https://bugs.webkit.org/show_bug.cgi?id=40300
  • trunk/LayoutTests/platform/win/Skipped

    r116592 r116847  
    12581258inspector/profiler/heap-snapshot-inspect-dom-wrapper.html
    12591259inspector/profiler/heap-snapshot-comparison-dom-groups-change.html
     1260inspector/profiler/heap-snapshot-summary-show-ranges.html
    12601261
    12611262# https://bugs.webkit.org/show_bug.cgi?id=40300
  • trunk/LayoutTests/platform/wincairo/Skipped

    r116563 r116847  
    17701770inspector/profiler/heap-snapshot-inspect-dom-wrapper.html
    17711771inspector/profiler/heap-snapshot-comparison-dom-groups-change.html
     1772inspector/profiler/heap-snapshot-summary-show-ranges.html
    17721773
    17731774# https://bugs.webkit.org/show_bug.cgi?id=40300
  • trunk/Source/WebCore/ChangeLog

    r116846 r116847  
     12012-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
    1502012-05-12  Pavel Feldman  <pfeldman@chromium.org>
    251
  • trunk/Source/WebCore/inspector/front-end/HeapSnapshot.js

    r116771 r116847  
    13481348    this._position = 0;
    13491349    this._currentComparator = null;
    1350     this._lastComparator = null;
     1350    this._sortedPrefixLength = 0;
    13511351}
    13521352
     
    14361436    },
    14371437
    1438     serializeSubsequentItems: function(count)
     1438    /**
     1439     * @param {number} begin
     1440     * @param {number} end
     1441     */
     1442    serializeItemsRange: function(begin, end)
    14391443    {
    14401444        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;
    14411457        var result = new Array(count);
    1442         if (this._lastComparator !== this._currentComparator)
    1443             this.sort(this._currentComparator, this._position, this._iterationOrder.length - 1, count);
    14441458        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);
    14461460        result.length = i;
    1447         result.hasNext = this.hasNext();
    14481461        result.totalLength = this._iterationOrder.length;
     1462
     1463        result.startPosition = startPosition;
     1464        result.endPosition = this._position;
    14491465        return result;
    14501466    },
    14511467
     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
    14521477    sortAndRewind: function(comparator)
    14531478    {
    1454         this._lastComparator = this._currentComparator;
    14551479        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();
    14601482    }
    14611483}
     
    14771499
    14781500WebInspector.HeapSnapshotEdgesProvider.prototype = {
    1479     _serialize: function(edge)
     1501    serializeItem: function(edge)
    14801502    {
    14811503        return {
    14821504            name: edge.name,
    14831505            propertyAccessor: edge.toString(),
    1484             node: WebInspector.HeapSnapshotNodesProvider.prototype._serialize(edge.node),
     1506            node: WebInspector.HeapSnapshotNodesProvider.prototype.serializeItem(edge.node),
    14851507            nodeIndex: edge.nodeIndex,
    14861508            type: edge.type,
     
    15721594
    15731595WebInspector.HeapSnapshotNodesProvider.prototype = {
    1574     _serialize: function(node)
     1596    serializeItem: function(node)
    15751597    {
    15761598        return {
  • trunk/Source/WebCore/inspector/front-end/HeapSnapshotGridNodes.js

    r116768 r116847  
    4545    this._dataGrid = tree;
    4646    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 = [];
    4754    this.addEventListener("populate", this._populate, this);
    4855}
     
    107114    {
    108115        this.removeEventListener("populate", this._populate, this);
    109         function sorted(ignored)
     116        function sorted()
    110117        {
    111118            this._populateChildren();
     
    115122
    116123    /**
    117      * @param {?number} howMany
    118      * @param {?number} atIndex
     124     * @param {?number} fromPosition
     125     * @param {?number} toPosition
    119126     */
    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                }
    130148            }
    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);
    140155        }
    141156        function childrenRetrieved(items)
    142157        {
    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);
    151233                    }
    152234                }
    153                 this.insertChild(this._createChildNode(item), atIndex++);
    154235            }
     236
     237            // TODO: fix this.
    155238            this._instanceCount += items.length;
    156             if (part < howMany) {
    157                 setTimeout(callSerialize.bind(this), 0);
     239            if (firstNotSerializedPosition < toPosition) {
     240                setTimeout(serializeNextChunk.bind(this), 0);
    158241                return;
    159242            }
    160243
    161             if (items.hasNext)
    162                 this.insertChild(new WebInspector.ShowMoreDataGridNode(this._populateChildren.bind(this), this._dataGrid.defaultPopulateCount(), length), atIndex++);
    163244            if (afterPopulate)
    164245                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);
    172249    },
    173250
    174251    _saveChildren: function()
    175252    {
    176         this._savedChildren = {};
     253        this._savedChildren = null;
    177254        for (var i = 0, childrenCount = this.children.length; i < childrenCount; ++i) {
    178255            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;
    181261        }
    182262    },
     
    185265    {
    186266        this._dataGrid.recursiveSortingEnter();
    187         function afterSort(sorted)
    188         {
    189             if (!sorted) {
    190                 this._dataGrid.recursiveSortingLeave();
    191                 return;
    192             }
     267        function afterSort()
     268        {
    193269            this._saveChildren();
    194270            this.removeChildren();
     271            this._retrievedChildrenRanges = [];
    195272
    196273            function afterPopulate()
     
    205282            var instanceCount = this._instanceCount;
    206283            this._instanceCount = 0;
    207             this._populateChildren(instanceCount, null, afterPopulate.bind(this));
     284            this._populateChildren(0, instanceCount, afterPopulate.bind(this));
    208285        }
    209286        this._provider.sortAndRewind(this.comparator(), afterSort.bind(this));
     
    694771    this._addedCount = addedCount;
    695772    this._removedCount = removedCount;
    696     this._serializedItemsCount = 0;
    697773}
    698774
     
    709785    },
    710786
    711     serializeSubsequentItems: function(count, callback)
     787    serializeItemsRange: function(beginPosition, endPosition, callback)
    712788    {
    713789        function didReceiveAllItems(items)
    714790        {
    715             this._serializedItemsCount += items.length;
    716791            items.totalLength = this._addedCount + this._removedCount;
    717792            callback(items);
     
    720795        function didReceiveDeletedItems(addedItems, items)
    721796        {
     797            if (!addedItems.length)
     798                addedItems.startPosition = this._addedCount + items.startPosition;
    722799            for (var i = 0; i < items.length; i++) {
    723800                items[i].isAddedNotRemoved = false;
    724801                addedItems.push(items[i]);
    725802            }
    726             addedItems.hasNext = items.hasNext;
     803            addedItems.endPosition = this._addedCount + items.endPosition;
    727804            didReceiveAllItems.call(this, addedItems);
    728805        }
     
    732809            for (var i = 0; i < items.length; i++)
    733810                items[i].isAddedNotRemoved = true;
    734             if (items.length < count)
    735                 return this._deletedNodesProvider.serializeSubsequentItems(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));
    736813
    737814            items.totalLength = this._addedCount + this._removedCount;
    738             if (!items.hasNext)
    739                 items.hasNext = !!this._removedCount;
    740815            didReceiveAllItems.call(this, items);
    741816        }
    742817
    743         if (this._serializedItemsCount < this._addedCount)
    744             this._addedNodesProvider.serializeSubsequentItems(count, didReceiveAddedItems.bind(this));
     818        if (beginPosition < this._addedCount)
     819            this._addedNodesProvider.serializeItemsRange(beginPosition, endPosition, didReceiveAddedItems.bind(this));
    745820        else
    746             this._deletedNodesProvider.serializeSubsequentItems(count, didReceiveDeletedItems.bind(this, []));
     821            this._deletedNodesProvider.serializeItemsRange(beginPosition - this._addedCount, endPosition - this._addedCount, didReceiveDeletedItems.bind(this, []));
    747822    },
    748823
    749824    sortAndRewind: function(comparator, callback)
    750825    {
    751         this._serializedItemsCount = 0;
    752 
    753         function afterSort(ignored)
     826        function afterSort()
    754827        {
    755828            this._deletedNodesProvider.sortAndRewind(comparator, callback);
  • trunk/Source/WebCore/inspector/front-end/HeapSnapshotProxy.js

    r115189 r116847  
    125125    this._previousCallbacks = [];
    126126    // 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();
    128128    this._worker.addEventListener("message", this._messageReceived, this);
    129129}
     
    492492    },
    493493
    494     serializeSubsequentItems: function(count, callback)
    495     {
    496         this.callMethod(callback, "serializeSubsequentItems", count);
     494    serializeItemsRange: function(startPosition, endPosition, callback)
     495    {
     496        this.callMethod(callback, "serializeItemsRange", startPosition, endPosition);
    497497    },
    498498
  • trunk/Source/WebCore/inspector/front-end/ShowMoreDataGridNode.js

    r114649 r116847  
    3232 * @constructor
    3333 * @extends {WebInspector.DataGridNode}
     34 * @param {function(number, number)} callback
     35 * @param {number} startPosition
     36 * @param {number} endPosition
     37 * @param {number} chunkSize
    3438 */
    35 WebInspector.ShowMoreDataGridNode = function(callback, nextCount, allCount)
     39WebInspector.ShowMoreDataGridNode = function(callback, startPosition, endPosition, chunkSize)
    3640{
    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;
    4346
    4447    this.showNext = document.createElement("button");
    4548    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);
    4850
    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);
    5554
    56     WebInspector.DataGridNode.call(this, {summaryRow:true}, false);
     55    this._updateLabels();
    5756    this.selectable = false;
    5857}
    5958
    6059WebInspector.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
    6178    createCells: function()
    6279    {
     
    8097
    8198    /**
     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    /**
    82117     * @override
    83118     * @return {number}
  • trunk/Source/WebCore/inspector/front-end/utilities.js

    r115961 r116847  
    219219});
    220220
     221Object.defineProperty(Uint32Array.prototype, "sort", {
     222   value: Array.prototype.sort
     223});
     224
    221225(function() {
    222226var partition = {
Note: See TracChangeset for help on using the changeset viewer.