Changeset 84619 in webkit


Ignore:
Timestamp:
Apr 22, 2011 5:32:14 AM (13 years ago)
Author:
mnaganov@chromium.org
Message:

2011-04-22 Mikhail Naganov <mnaganov@chromium.org>

Reviewed by Pavel Feldman.

Web Inspector: [Chromium] Refactor code prior to moving detailed heap snapshots into workers.
https://bugs.webkit.org/show_bug.cgi?id=59189

  • WebCore.gypi:
  • WebCore.vcproj/WebCore.vcproj:
  • inspector/front-end/BinarySearch.js: Added.
  • inspector/front-end/DetailedHeapshotGridNodes.js: (WebInspector.HeapSnapshotGridNode.prototype._populate.sorted): (WebInspector.HeapSnapshotGridNode.prototype._populate): (WebInspector.HeapSnapshotGridNode.prototype.populateChildren): (WebInspector.HeapSnapshotGridNode.prototype.sort.afterSort.afterPopulate): (WebInspector.HeapSnapshotGridNode.prototype.sort.afterSort): (WebInspector.HeapSnapshotGridNode.prototype.sort): (WebInspector.HeapSnapshotObjectNode): (WebInspector.HeapSnapshotObjectNode.prototype._createChildNode): (WebInspector.HeapSnapshotInstanceNode.prototype._createChildNode): (WebInspector.HeapSnapshotInstanceNode.prototype._enhanceData): (WebInspector.HeapSnapshotInstanceNode.prototype.get isDeletedNode): (WebInspector.HeapSnapshotDiffNode.prototype.calculateDiff.diffCalculated): (WebInspector.HeapSnapshotDiffNode.prototype.calculateDiff.baseIdsReceived): (WebInspector.HeapSnapshotDiffNode.prototype.get data):
  • inspector/front-end/DetailedHeapshotView.js: (WebInspector.HeapSnapshotSortableDataGrid.prototype.sortingChanged.sort): (WebInspector.HeapSnapshotSortableDataGrid.prototype.sortingChanged): (WebInspector.HeapSnapshotSortableDataGrid.prototype._performSorting): (WebInspector.HeapSnapshotSortableDataGrid.prototype.recursiveSortingEnter): (WebInspector.HeapSnapshotSortableDataGrid.prototype.recursiveSortingLeave): (WebInspector.HeapSnapshotContainmentDataGrid): (WebInspector.HeapSnapshotContainmentDataGrid.prototype._defaultPopulateCount.100.setDataSource): (WebInspector.HeapSnapshotContainmentDataGrid.prototype.sortingChanged): (WebInspector.HeapSnapshotDiffDataGrid.prototype.setBaseDataSource): (WebInspector.HeapSnapshotDiffDataGrid.prototype.populateChildren.baseAggregatesReceived.aggregatesReceived.addNodeIfNonZeroDiff): (WebInspector.HeapSnapshotDiffDataGrid.prototype.populateChildren.baseAggregatesReceived.aggregatesReceived): (WebInspector.HeapSnapshotDiffDataGrid.prototype.populateChildren): (WebInspector.HeapSnapshotDominatorsDataGrid): (WebInspector.HeapSnapshotDominatorsDataGrid.prototype._defaultPopulateCount.25.setDataSource): (WebInspector.HeapSnapshotDominatorsDataGrid.prototype.sortingChanged): (WebInspector.HeapSnapshotRetainingPathsList.prototype._performSorting): (WebInspector.DetailedHeapshotView.prototype._changeBase.baseProfileLoaded): (WebInspector.DetailedHeapshotView.prototype._changeBase): (WebInspector.DetailedHeapshotView.prototype._changeView): (WebInspector.DetailedHeapshotView.prototype._showStringContentPopup.displayString): (WebInspector.DetailedHeapshotView.prototype._showStringContentPopup):
  • inspector/front-end/HeapSnapshot.js: (WebInspector.HeapSnapshot.prototype.dispose): (WebInspector.HeapSnapshot.prototype.pushBaseNodeIds): (WebInspector.HeapSnapshotFilteredOrderedIterator.prototype.serializeNextItems): (WebInspector.HeapSnapshotFilteredOrderedIterator.prototype.sortAndRewind): (WebInspector.HeapSnapshotEdgesProvider.prototype._serialize): (WebInspector.HeapSnapshotNodesProvider.prototype._serialize): (WebInspector.HeapSnapshotsDiff.prototype.calculate): (WebInspector.HeapSnapshotsDiff.prototype.pushBaseIds): (WebInspector.HeapSnapshotsDiff.prototype.pushBaseSelfSizes):
  • inspector/front-end/HeapSnapshotProxy.js: (WebInspector.HeapSnapshotProxy.prototype.createEdgesProvider): (WebInspector.HeapSnapshotProxy.prototype.createNodesProvider): (WebInspector.HeapSnapshotProxy.prototype.pushBaseIds): (WebInspector.HeapSnapshotProviderProxy): (WebInspector.HeapSnapshotProviderProxy.prototype.serializeNextItems): (WebInspector.HeapSnapshotProviderProxy.prototype.sortAndRewind): (WebInspector.HeapSnapshotsDiffProxy.prototype.pushBaseIds): (WebInspector.HeapSnapshotsDiffProxy.prototype.pushBaseSelfSizes):
  • inspector/front-end/PleaseWaitMessage.js: (WebInspector.PleaseWaitMessage.prototype.showAndWaitFor): (WebInspector.PleaseWaitMessage.prototype.unlistenAndHide):
  • inspector/front-end/WebKit.qrc:
  • inspector/front-end/inspector.html:
  • inspector/front-end/utilities.js:

2011-04-22 Mikhail Naganov <mnaganov@chromium.org>

Reviewed by Pavel Feldman.

Web Inspector: [Chromium] Refactor code prior to moving detailed heap snapshots into workers.
https://bugs.webkit.org/show_bug.cgi?id=59189

  • inspector/profiler/detailed-heapshots-comparison-sorting.html:
  • inspector/profiler/detailed-heapshots-test.js: (initialize_DetailedHeapshotTest): (initialize_DetailedHeapshotTest.):
  • inspector/profiler/heap-snapshot-expected.txt:
  • inspector/profiler/heap-snapshot.html:
Location:
trunk
Files:
1 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r84617 r84619  
     12011-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
    1152011-04-22  Csaba Osztrogonác  <ossy@webkit.org>
    216
  • trunk/LayoutTests/inspector/profiler/detailed-heapshots-comparison-sorting.html

    r83581 r84619  
    2727            function step1()
    2828            {
    29                 InspectorTest.switchToView("Comparison", next);
     29                InspectorTest.switchToView("Comparison", step2);
    3030            }
    3131
  • trunk/LayoutTests/inspector/profiler/detailed-heapshots-test.js

    r83850 r84619  
    170170    function sortingComplete()
    171171    {
     172        InspectorTest._currentGrid().removeEventListener("sorting complete", sortingComplete, this);
    172173        InspectorTest.assertEquals(column.identifier, this._currentGrid().sortColumnIdentifier, "unexpected sorting");
    173174        column.sort = this._currentGrid().sortOrder;
     
    178179        setTimeout(callCallback, 0);
    179180    }
    180     InspectorTest._prepareForRecursiveSort(sortingComplete.bind(this));
     181    InspectorTest._currentGrid().addEventListener("sorting complete", sortingComplete, this);
    181182    this._currentGrid()._clickInHeaderCell(event);
    182183};
     
    295296    }
    296297    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    })();
    298305};
    299306
     
    359366        return;
    360367    }
    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);
    362375    view._changeView({target: {selectedIndex: index}});
    363376};
     
    393406};
    394407
    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 
    427408InspectorTest._snapshotViewShown = function()
    428409{
     
    430411        var callback = InspectorTest._takeAndOpenSnapshotCallback;
    431412        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  
    1414Running: heapSnapshotSimpleTest
    1515
    16 Running: heapSnapshotIdsTest
    17 
    1816Running: heapSnapshotRetainersTest
    1917
  • trunk/LayoutTests/inspector/profiler/heap-snapshot.html

    r82230 r84619  
    9393            InspectorTest.assertEquals(6, snapshot.nodeCount, "node count");
    9494            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");
    10695            next();
    10796        },
  • trunk/Source/WebCore/ChangeLog

    r84618 r84619  
     12011-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
    1742011-04-22  Mikhail Naganov  <mnaganov@chromium.org>
    275
  • trunk/Source/WebCore/WebCore.gypi

    r84527 r84619  
    61866186            'inspector/front-end/AuditRules.js',
    61876187            'inspector/front-end/AuditsPanel.js',
     6188            'inspector/front-end/BinarySearch.js',
    61886189            'inspector/front-end/BottomUpProfileDataGridTree.js',
    61896190            'inspector/front-end/BreakpointsSidebarPane.js',
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r84527 r84619  
    6721867218                                </File>
    6721967219                                <File
     67220                                        RelativePath="..\inspector\front-end\BinarySearch.js"
     67221                                        >
     67222                                </File>
     67223                                <File
    6722067224                                        RelativePath="..\inspector\front-end\BottomUpProfileDataGridTree.js"
    6722167225                                        >
  • trunk/Source/WebCore/inspector/front-end/DetailedHeapshotGridNodes.js

    r83850 r84619  
    4848    _populate: function(event)
    4949    {
    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));
    6157    },
    6258
     
    8177        }
    8278       
    83         function childrenRetrieved(items, hasNext, length)
    84         {
     79        function childrenRetrieved(items)
     80        {
     81            var hasNext = items.hasNext;
     82            var length = items.totalLength;
    8583            for (var i = 0, l = items.length; i < l; ++i) {
    8684                var item = items[i];
     
    108106            }
    109107        }
    110         provider.getNextItems(howMany, childrenRetrieved.bind(this));
     108        provider.serializeNextItems(howMany, childrenRetrieved.bind(this));
    111109    },
    112110
     
    123121    sort: function()
    124122    {
    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()
    128135            {
    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();
    142140                }
    143                 this.populateChildren(this._provider, null, null, afterPopulate.bind(this));
     141                this.dataGrid.recursiveSortingLeave();
    144142            }
    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));
    149146    }
    150147};
     
    258255WebInspector.HeapSnapshotGenericObjectNode.prototype.__proto__ = WebInspector.HeapSnapshotGridNode.prototype;
    259256
    260 WebInspector.HeapSnapshotObjectNode = function(tree, edge)
     257WebInspector.HeapSnapshotObjectNode = function(tree, isFromBaseSnapshot, edge)
    261258{
    262259    WebInspector.HeapSnapshotGenericObjectNode.call(this, tree, edge.node);
    263260    this._referenceName = edge.name;
    264261    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);
    266264    this._updateHasChildren();
    267265}
     
    270268    _createChildNode: function(item)
    271269    {
    272         return new WebInspector.HeapSnapshotObjectNode(this.dataGrid, item);
     270        return new WebInspector.HeapSnapshotObjectNode(this.dataGrid, this._isFromBaseSnapshot, item);
    273271    },
    274272
     
    357355    _createChildNode: function(item)
    358356    {
    359         return new WebInspector.HeapSnapshotObjectNode(this.dataGrid, item);
     357        return new WebInspector.HeapSnapshotObjectNode(this.dataGrid, this._isDeletedNode, item);
    360358    },
    361359
     
    415413        }
    416414        return data;
     415    },
     416
     417    get isDeletedNode()
     418    {
     419        return this._isDeletedNode;
    417420    }
    418421}
     
    529532        function diffCalculated(diffResult)
    530533        {
    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;
    532540            this._baseIndexes = null;
    533541            this._indexes = null;
    534             callback(this._diff.addedSize === 0 && this._diff.removedSize === 0);
     542            callback(this._addedSize === 0 && this._removedSize === 0);
    535543        }
    536544        function baseSelfSizesReceived(baseSelfSizes)
     
    541549        function baseIdsReceived(baseIds)
    542550        {
    543             diff.pushBaseIds(dataGrid.baseSnapshot.uid, baseIds);
     551            diff.pushBaseIds(baseIds);
    544552            dataGrid.snapshot.pushBaseIds(dataGrid.baseSnapshot.uid, this._name, baseIds);
    545553            dataGrid.baseSnapshot.nodeFieldValuesByIndex("selfSize", this._baseIndexes, baseSelfSizesReceived.bind(this));
     
    639647        var data = {object: this._name};
    640648
    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)));
    649655
    650656        return data;
  • trunk/Source/WebCore/inspector/front-end/DetailedHeapshotView.js

    r83850 r84619  
    2929 */
    3030
    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 
    5831WebInspector.HeapSnapshotSortableDataGrid = function(columns)
    5932{
     
    9063        }
    9164
    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);
    9371    },
    9472
    9573    _performSorting: function(sortFunction)
    9674    {
    97         this.dispatchEventToListeners("start sorting");
     75        this.recursiveSortingEnter();
    9876        var children = this.children;
    9977        this.removeChildren();
     
    10583                child.sort();
    10684        }
    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        }
    108104    }
    109105};
    110106
    111107WebInspector.HeapSnapshotSortableDataGrid.prototype.__proto__ = WebInspector.DataGrid.prototype;
     108
     109WebInspector.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
     119WebInspector.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
     137MixInSnapshotNodeFunctions(WebInspector.HeapSnapshotObjectNode.prototype, WebInspector.HeapSnapshotContainmentDataGrid.prototype);
     138WebInspector.HeapSnapshotContainmentDataGrid.prototype.__proto__ = WebInspector.HeapSnapshotSortableDataGrid.prototype;
    112139
    113140WebInspector.HeapSnapshotConstructorsDataGrid = function()
     
    197224        this.baseSnapshot = baseSnapshot;
    198225        this.removeChildren();
    199         if (this.baseSnapshot === this.snapshot)
    200             return;
     226        if (this.baseSnapshot === this.snapshot) {
     227            this.dispatchEventToListeners("sorting complete");
     228            return;
     229        }
    201230        this.populateChildren();       
    202231    },
     
    209238            {
    210239                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)
    212249                {
    213250                    if (!zeroDiff)
    214                         this.appendChild(node);
     251                        this.appendChild(boundNode);
    215252                    if (!--nodeCount)
    216253                        this.sortingChanged();
    217254                }
    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];
    221257                    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                     }
    229258                }
    230259            }
     
    244273        retainedSize: { title: WebInspector.UIString("Retained Size"), width: "90px", sort: "descending", sortable: true }
    245274    };
    246     WebInspector.DataGrid.call(this, columns);
    247     this.addEventListener("sorting changed", this.sort, this);
     275    WebInspector.HeapSnapshotSortableDataGrid.call(this, columns);
    248276}
    249277
     
    258286        this._provider = this._createProvider(snapshot, this.snapshotNodeIndex);
    259287        this.sort();
     288    },
     289
     290    sortingChanged: function()
     291    {
     292        this.sort();
    260293    }
    261294};
    262295
    263296MixInSnapshotNodeFunctions(WebInspector.HeapSnapshotDominatorObjectNode.prototype, WebInspector.HeapSnapshotDominatorsDataGrid.prototype);
    264 WebInspector.HeapSnapshotDominatorsDataGrid.prototype.__proto__ = WebInspector.DataGrid.prototype;
     297WebInspector.HeapSnapshotDominatorsDataGrid.prototype.__proto__ = WebInspector.HeapSnapshotSortableDataGrid.prototype;
    265298
    266299WebInspector.HeapSnapshotRetainingPathsList = function()
     
    373406            return sortFunction(nodeA.data, nodeB.data);
    374407        }
    375 
     408        this.recursiveSortingEnter();
    376409        this.sortNodes(DataExtractorWrapper);
     410        this.recursiveSortingLeave();
    377411    }
    378412};
     
    724758            delete this._baseProfileWrapper;
    725759            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");
    731761            this.diffDataGrid.setBaseDataSource(this.baseProfileWrapper);
    732762        }
     
    806836        } else {
    807837            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            }
    815842        }
    816843
     
    868895    _showStringContentPopup: function(span)
    869896    {
    870         var snapshotNode = new WebInspector.HeapSnapshotNode(this.profileWrapper, span.snapshotNodeIndex);
    871897        var stringContentElement = document.createElement("span");
    872898        stringContentElement.className = "monospace console-formatted-string";
    873899        stringContentElement.style.whiteSpace = "pre";
    874         stringContentElement.textContent = "\"" + snapshotNode.name + "\"";
     900
    875901        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);
    877910        return popover;
    878911    },
  • trunk/Source/WebCore/inspector/front-end/HeapSnapshot.js

    r83850 r84619  
    527527        delete this._nodes;
    528528        delete this._strings;
    529         delete this._idsList;
    530529        delete this._retainers;
    531530        delete this._retainerIndex;
     
    578577    {
    579578        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;
    592579    },
    593580
     
    690677
    691678        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);
    703679    },
    704680
     
    776752    },
    777753
    778     updateBaseNodeIds: function(baseSnapshotId, className, nodeIds)
     754    pushBaseNodeIds: function(baseSnapshotId, className, nodeIds)
    779755    {
    780756        if (!this._baseNodeIds)
     
    852828        ++this._position;
    853829    },
     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    }
    854849}
    855850
     
    867862
    868863WebInspector.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
    869869    sort: function(comparator)
    870870    {
     
    950950
    951951WebInspector.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
    952957    sort: function(comparator)
    953958    {
     
    11541159
    11551160WebInspector.HeapSnapshotsDiff.prototype = {
    1156     set baseIds(baseIds)
    1157     {
    1158         this._baseIds = baseIds;
    1159     },
    1160 
    1161     set baseSelfSizes(baseSelfSizes)
    1162     {
    1163         this._baseSelfSizes = baseSelfSizes;
    1164     },
    1165 
    11661161    calculate: function()
    11671162    {
    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 : [];
    11691165        var i = 0, l = this._baseIds.length;
    11701166        var j = 0, m = indexes.length;
    11711167        var diff = { addedCount: 0, removedCount: 0, addedSize: 0, removedSize: 0 };
    11721168           
    1173         var nodeB = new WebInspector.HeapSnapshotNode(this._snapshot);
     1169        var nodeB = new WebInspector.HeapSnapshotNode(this._snapshot, indexes[j]);
    11741170        while (i < l && j < m) {
    11751171            var nodeAId = this._baseIds[i];
     
    12001196        diff.sizeDelta = diff.addedSize - diff.removedSize;
    12011197        return diff;
     1198    },
     1199
     1200    pushBaseIds: function(baseIds)
     1201    {
     1202        this._baseIds = baseIds;
     1203    },
     1204
     1205    pushBaseSelfSizes: function(baseSelfSizes)
     1206    {
     1207        this._baseSelfSizes = baseSelfSizes;
    12021208    }
    12031209};
  • trunk/Source/WebCore/inspector/front-end/HeapSnapshotProxy.js

    r83850 r84619  
    5353    },
    5454
    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 
    6555    createDiff: function(className)
    6656    {
     
    7666            return new WebInspector.HeapSnapshotEdgesProvider(this._snapshot, nodeIndex, filter);
    7767        }
    78         return new WebInspector.HeapSnapshotProviderProxy(createProvider.bind(this), this._extractEdgeData.bind(this));
     68        return new WebInspector.HeapSnapshotProviderProxy(createProvider.bind(this));
    7969    },
    8070
     
    8777            return new WebInspector.HeapSnapshotNodesProvider(this._snapshot, filter);
    8878        }
    89         return new WebInspector.HeapSnapshotProviderProxy(createProvider.bind(this), this._extractNodeData.bind(this));
     79        return new WebInspector.HeapSnapshotProviderProxy(createProvider.bind(this));
    9080    },
    9181
     
    141131    },
    142132
    143     nodeIds: function(callback)
    144     {
    145         this._invokeGetter("nodeIds", callback);
    146     },
    147 
    148133    pushJSONChunk: function(chunk)
    149134    {
     
    155140    pushBaseIds: function(snapshotId, className, nodeIds)
    156141    {
    157         this._snapshot.updateBaseNodeIds(snapshotId, className, nodeIds);
     142        this._snapshot.pushBaseNodeIds(snapshotId, className, nodeIds);
    158143    },
    159144
     
    194179};
    195180
    196 WebInspector.HeapSnapshotProviderProxy = function(createProvider, extractData)
     181WebInspector.HeapSnapshotProviderProxy = function(createProvider)
    197182{
    198183    this._provider = createProvider();
    199     this._extractData = extractData;
    200184}
    201185
    202186WebInspector.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));
    212192        }
    213193        setTimeout(returnResult.bind(this), 0);
     
    227207        function returnResult()
    228208        {
    229             var result = this._provider.sort(comparator);
    230             if (result)
    231                 this._provider.first();
    232             callback(result);
     209            callback(this._provider.sortAndRewind(comparator));
    233210        }
    234211        setTimeout(returnResult.bind(this), 0);
     
    276253    },
    277254
    278     pushBaseIds: function(baseSnapshotId, baseIds)
    279     {
    280         this._diff.baseIds = baseIds;
     255    pushBaseIds: function(baseIds)
     256    {
     257        this._diff.pushBaseIds(baseIds);
    281258    },
    282259
    283260    pushBaseSelfSizes: function(baseSelfSizes)
    284261    {
    285         this._diff.baseSelfSizes = baseSelfSizes;
    286     }
    287 };
     262        this._diff.pushBaseSelfSizes(baseSelfSizes);
     263    }
     264};
  • trunk/Source/WebCore/inspector/front-end/PleaseWaitMessage.js

    r83718 r84619  
    8282    },
    8383
    84     startAction: function(element, actionCallback, cancelCallback)
     84    showAndWaitFor: function(element, listenObject, listenEvent)
    8585    {
    8686        var instance = WebInspector.PleaseWaitMessage.prototype.instance;
    8787        var message = instance.element;
    88         if (message.parentNode === element) {
    89             setTimeout(actionCallback, 0);
     88        if (message.parentNode === element)
    9089            return;
    91         }
    92      
    93         function doAction()
    94         {
    95             try {
    96                 actionCallback();
    97             } finally {
    98                 if (message.parentNode)
    99                     message.parentNode.removeChild(message);
    100             }
    101         }
    10290
    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();
    105100    }
    106101};
  • trunk/Source/WebCore/inspector/front-end/WebKit.qrc

    r83864 r84619  
    99    <file>AuditRules.js</file>
    1010    <file>AuditsPanel.js</file>
     11    <file>BinarySearch.js</file>
    1112    <file>BottomUpProfileDataGridTree.js</file>
    1213    <file>BreakpointsSidebarPane.js</file>
  • trunk/Source/WebCore/inspector/front-end/inspector.html

    r83962 r84619  
    4040    <link rel="stylesheet" type="text/css" href="textViewer.css">
    4141    <script type="text/javascript" src="utilities.js"></script>
     42    <script type="text/javascript" src="BinarySearch.js"></script>
    4243    <script type="text/javascript" src="treeoutline.js"></script>
    4344    <script type="text/javascript" src="inspector.js"></script>
  • trunk/Source/WebCore/inspector/front-end/utilities.js

    r84614 r84619  
    775775}
    776776
    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         else
    790             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 
    817777String.sprintf = function(format)
    818778{
Note: See TracChangeset for help on using the changeset viewer.