Changeset 117051 in webkit


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

Web Inspector: implement "Reveal in Dominators view" context menu action
https://bugs.webkit.org/show_bug.cgi?id=86455

Reviewed by Pavel Feldman.

Source/WebCore:

Implemented "Reveal in Dominators view" context menu action for objects
in the console.

Test: inspector/profiler/heap-snapshot-reveal-in-dominators-view.html

  • English.lproj/localizedStrings.js:
  • inspector/front-end/HeapSnapshot.js:

(WebInspector.HeapSnapshot.prototype._nodeForSnapshotObjectId):
(WebInspector.HeapSnapshot.prototype.nodeClassName):
(WebInspector.HeapSnapshot.prototype.dominatorIdsForNode):

  • inspector/front-end/HeapSnapshotDataGrids.js:

(WebInspector.HeapSnapshotDominatorsDataGrid):
(WebInspector.HeapSnapshotDominatorsDataGrid.prototype.setDataSource):
(WebInspector.HeapSnapshotDominatorsDataGrid.prototype.sortingChanged):
(WebInspector.HeapSnapshotDominatorsDataGrid.prototype.highlightObjectByHeapSnapshotId.didGetDominators):
(WebInspector.HeapSnapshotDominatorsDataGrid.prototype.highlightObjectByHeapSnapshotId.expandNextDominator):
(WebInspector.HeapSnapshotDominatorsDataGrid.prototype.highlightObjectByHeapSnapshotId):

  • inspector/front-end/HeapSnapshotGridNodes.js:

(WebInspector.HeapSnapshotGridNode.prototype.childForPosition):
(WebInspector.HeapSnapshotGridNode.prototype.expandWithoutPopulate):
(WebInspector.HeapSnapshotGridNode.prototype._populateChildren.childrenRetrieved):
(WebInspector.HeapSnapshotGridNode.prototype._populateChildren):
(WebInspector.HeapSnapshotGridNode.prototype.sort):
(WebInspector.HeapSnapshotDominatorObjectNode.prototype.retrieveChildBySnapshotObjectId):
(WebInspector.HeapSnapshotDominatorObjectNode.prototype.retrieveChildBySnapshotObjectId.didGetNodePosition):
(WebInspector.HeapSnapshotDominatorObjectNode.prototype.retrieveChildBySnapshotObjectId.didPopulateChildren):

  • inspector/front-end/HeapSnapshotProxy.js:

(WebInspector.HeapSnapshotProxy.prototype.dominatorIdsForNode):

  • inspector/front-end/ProfilesPanel.js:

(WebInspector.RevealInHeapSnapshotContextMenuProvider.prototype.populateContextMenu.revealInSummaryView):
(WebInspector.RevealInHeapSnapshotContextMenuProvider.prototype.populateContextMenu.didReceiveHeapObjectId):
(WebInspector.RevealInHeapSnapshotContextMenuProvider.prototype.populateContextMenu):

LayoutTests:

Test that an object can be revealed in the heap snapshot dominators view
by its heap snapshot object id.

  • inspector/profiler/heap-snapshot-reveal-in-dominators-view-expected.txt: Added.
  • inspector/profiler/heap-snapshot-reveal-in-dominators-view.html: Added.
  • inspector/profiler/heap-snapshot-test.js:

(initialize_HeapSnapshotTest):
(initialize_HeapSnapshotTest.):

  • platform/mac/Skipped:
  • platform/qt/Skipped:
  • platform/win/Skipped:
  • platform/wincairo/Skipped:
Location:
trunk
Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r117047 r117051  
     12012-05-15  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Web Inspector: implement "Reveal in Dominators view" context menu action
     4        https://bugs.webkit.org/show_bug.cgi?id=86455
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Test that an object can be revealed in the heap snapshot dominators view
     9        by its heap snapshot object id.
     10
     11        * inspector/profiler/heap-snapshot-reveal-in-dominators-view-expected.txt: Added.
     12        * inspector/profiler/heap-snapshot-reveal-in-dominators-view.html: Added.
     13        * inspector/profiler/heap-snapshot-test.js:
     14        (initialize_HeapSnapshotTest):
     15        (initialize_HeapSnapshotTest.):
     16        * platform/mac/Skipped:
     17        * platform/qt/Skipped:
     18        * platform/win/Skipped:
     19        * platform/wincairo/Skipped:
     20
    1212012-05-15  Zan Dobersek  <zandobersek@gmail.com>
    222
  • trunk/LayoutTests/inspector/profiler/heap-snapshot-test.js

    r116771 r117051  
    426426        "nodes": nodes,
    427427        "edges": edges,
    428         "strings": ["", "A", "B", "a", "(GC roots)"]
     428        "strings": ["", "A", "B", "a", "(GC roots)"],
     429        maxJSObjectId: nextId - 1
    429430    };
    430431    result.snapshot.node_count = result.nodes.length / result.snapshot.meta.node_fields.length;
     
    512513    callback = InspectorTest.safeWrap(callback);
    513514    var uid = InspectorTest._nextUid++;
    514     var profile = { typeId: WebInspector.HeapSnapshotProfileType.TypeId, uid: uid, title: UserInitiatedProfileName + "." + uid };
     515    var snapshot = generator();
     516    var profile = new WebInspector.HeapProfileHeader(UserInitiatedProfileName + "." + uid, uid, snapshot.maxJSObjectId);
     517    delete snapshot.maxJSObjectId;
    515518    function pushGeneratedSnapshot(typeId, uid)
    516519    {
    517         var snapshot = generator();
    518520        snapshot.snapshot.typeId = profile.typeId;
    519521        snapshot.snapshot.title = profile.title;
  • trunk/LayoutTests/platform/mac/Skipped

    r117029 r117051  
    282282inspector/profiler/heap-snapshot-inspect-dom-wrapper.html
    283283inspector/profiler/heap-snapshot-comparison-dom-groups-change.html
     284inspector/profiler/heap-snapshot-reveal-in-dominators-view.html
    284285inspector/profiler/heap-snapshot-summary-show-ranges.html
    285286
  • trunk/LayoutTests/platform/qt/Skipped

    r117040 r117051  
    269269inspector/profiler/heap-snapshot-inspect-dom-wrapper.html
    270270inspector/profiler/heap-snapshot-comparison-dom-groups-change.html
     271inspector/profiler/heap-snapshot-reveal-in-dominators-view.html
    271272inspector/profiler/heap-snapshot-summary-show-ranges.html
    272273
  • trunk/LayoutTests/platform/win/Skipped

    r117029 r117051  
    12571257inspector/profiler/heap-snapshot-inspect-dom-wrapper.html
    12581258inspector/profiler/heap-snapshot-comparison-dom-groups-change.html
     1259inspector/profiler/heap-snapshot-reveal-in-dominators-view.html
    12591260inspector/profiler/heap-snapshot-summary-show-ranges.html
    12601261
  • trunk/LayoutTests/platform/wincairo/Skipped

    r117029 r117051  
    17691769inspector/profiler/heap-snapshot-inspect-dom-wrapper.html
    17701770inspector/profiler/heap-snapshot-comparison-dom-groups-change.html
     1771inspector/profiler/heap-snapshot-reveal-in-dominators-view.html
    17711772inspector/profiler/heap-snapshot-summary-show-ranges.html
    17721773
  • trunk/Source/WebCore/ChangeLog

    r117050 r117051  
     12012-05-15  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Web Inspector: implement "Reveal in Dominators view" context menu action
     4        https://bugs.webkit.org/show_bug.cgi?id=86455
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Implemented "Reveal in Dominators view" context menu action for objects
     9        in the console.
     10
     11        Test: inspector/profiler/heap-snapshot-reveal-in-dominators-view.html
     12
     13        * English.lproj/localizedStrings.js:
     14        * inspector/front-end/HeapSnapshot.js:
     15        (WebInspector.HeapSnapshot.prototype._nodeForSnapshotObjectId):
     16        (WebInspector.HeapSnapshot.prototype.nodeClassName):
     17        (WebInspector.HeapSnapshot.prototype.dominatorIdsForNode):
     18        * inspector/front-end/HeapSnapshotDataGrids.js:
     19        (WebInspector.HeapSnapshotDominatorsDataGrid):
     20        (WebInspector.HeapSnapshotDominatorsDataGrid.prototype.setDataSource):
     21        (WebInspector.HeapSnapshotDominatorsDataGrid.prototype.sortingChanged):
     22        (WebInspector.HeapSnapshotDominatorsDataGrid.prototype.highlightObjectByHeapSnapshotId.didGetDominators):
     23        (WebInspector.HeapSnapshotDominatorsDataGrid.prototype.highlightObjectByHeapSnapshotId.expandNextDominator):
     24        (WebInspector.HeapSnapshotDominatorsDataGrid.prototype.highlightObjectByHeapSnapshotId):
     25        * inspector/front-end/HeapSnapshotGridNodes.js:
     26        (WebInspector.HeapSnapshotGridNode.prototype.childForPosition):
     27        (WebInspector.HeapSnapshotGridNode.prototype.expandWithoutPopulate):
     28        (WebInspector.HeapSnapshotGridNode.prototype._populateChildren.childrenRetrieved):
     29        (WebInspector.HeapSnapshotGridNode.prototype._populateChildren):
     30        (WebInspector.HeapSnapshotGridNode.prototype.sort):
     31        (WebInspector.HeapSnapshotDominatorObjectNode.prototype.retrieveChildBySnapshotObjectId):
     32        (WebInspector.HeapSnapshotDominatorObjectNode.prototype.retrieveChildBySnapshotObjectId.didGetNodePosition):
     33        (WebInspector.HeapSnapshotDominatorObjectNode.prototype.retrieveChildBySnapshotObjectId.didPopulateChildren):
     34        * inspector/front-end/HeapSnapshotProxy.js:
     35        (WebInspector.HeapSnapshotProxy.prototype.dominatorIdsForNode):
     36        * inspector/front-end/ProfilesPanel.js:
     37        (WebInspector.RevealInHeapSnapshotContextMenuProvider.prototype.populateContextMenu.revealInSummaryView):
     38        (WebInspector.RevealInHeapSnapshotContextMenuProvider.prototype.populateContextMenu.didReceiveHeapObjectId):
     39        (WebInspector.RevealInHeapSnapshotContextMenuProvider.prototype.populateContextMenu):
     40
    1412012-05-15  Yury Semikhatsky  <yurys@chromium.org>
    242
  • trunk/Source/WebCore/inspector/front-end/HeapSnapshot.js

    r116857 r117051  
    12871287    },
    12881288
    1289     nodeClassName: function(snapshotObjectId)
     1289    _nodeForSnapshotObjectId: function(snapshotObjectId)
    12901290    {
    12911291        for (var it = this._allNodes; it.hasNext(); it.next()) {
    12921292            if (it.node.id === snapshotObjectId)
    1293                 return it.node.className;
     1293                return it.node;
    12941294        }
    12951295        return null;
     1296    },
     1297
     1298    nodeClassName: function(snapshotObjectId)
     1299    {
     1300        var node = this._nodeForSnapshotObjectId(snapshotObjectId);
     1301        if (node)
     1302            return node.className;
     1303        return null;
     1304    },
     1305
     1306    dominatorIdsForNode: function(snapshotObjectId)
     1307    {
     1308        var node = this._nodeForSnapshotObjectId(snapshotObjectId);
     1309        if (!node)
     1310            return null;
     1311        var result = [];
     1312        while (!node.isRoot) {
     1313            result.push(node.id);
     1314            node.nodeIndex = node.dominatorIndex;
     1315        }
     1316        return result;
    12961317    },
    12971318
  • trunk/Source/WebCore/inspector/front-end/HeapSnapshotDataGrids.js

    r116857 r117051  
    616616    };
    617617    WebInspector.HeapSnapshotSortableDataGrid.call(this, columns);
     618    this._objectIdToSelect = null;
    618619}
    619620
     
    636637        this.setRootNode(new WebInspector.HeapSnapshotDominatorObjectNode(this, fakeNode));
    637638        this.rootNode().sort();
     639
     640        if (this._objectIdToSelect) {
     641            this.highlightObjectByHeapSnapshotId(this._objectIdToSelect);
     642            this._objectIdToSelect = null;
     643        }
    638644    },
    639645
     
    641647    {
    642648        this.rootNode().sort();
     649    },
     650
     651    /**
     652     * @override
     653     * @param {ProfilerAgent.HeapSnapshotObjectId} id
     654     */
     655    highlightObjectByHeapSnapshotId: function(id)
     656    {
     657        if (!this.snapshot) {
     658            this._objectIdToSelect = id;
     659            return;
     660        }
     661
     662        function didGetDominators(dominatorIds)
     663        {
     664            if (!dominatorIds) {
     665                WebInspector.log(WebInspector.UIString("Cannot find corresponding heap snapshot node"));
     666                return;
     667            }
     668            var dominatorNode = this.rootNode();
     669            expandNextDominator.call(this, dominatorIds, dominatorNode);
     670        }
     671
     672        function expandNextDominator(dominatorIds, dominatorNode)
     673        {
     674            if (!dominatorNode) {
     675                console.error("Cannot find dominator node");
     676                return;
     677            }
     678            if (!dominatorIds.length) {
     679                this.highlightNode(dominatorNode);
     680                dominatorNode.element.scrollIntoViewIfNeeded(true);
     681                return;
     682            }
     683            var snapshotObjectId = dominatorIds.pop();
     684            dominatorNode.retrieveChildBySnapshotObjectId(snapshotObjectId, expandNextDominator.bind(this, dominatorIds));
     685        }
     686
     687        this.snapshot.dominatorIdsForNode(parseInt(id, 10), didGetDominators.bind(this));
    643688    }
    644689};
  • trunk/Source/WebCore/inspector/front-end/HeapSnapshotGridNodes.js

    r116857 r117051  
    9898    },
    9999
     100    /**
     101     * @param {number} nodePosition
     102     */
     103    childForPosition: function(nodePosition)
     104    {
     105        var indexOfFirsChildInRange = 0;
     106        for (var i = 0; i < this._retrievedChildrenRanges.length; i++) {
     107           var range = this._retrievedChildrenRanges[i];
     108           if (range.from <= nodePosition && nodePosition < range.to) {
     109               var childIndex = indexOfFirsChildInRange + nodePosition - range.from;
     110               return this.children[childIndex];
     111           }
     112           indexOfFirsChildInRange += range.to - range.from + 1;
     113        }
     114        return null;
     115    },
     116
    100117    _createValueCell: function(columnIdentifier)
    101118    {
     
    129146    },
    130147
     148    expandWithoutPopulate: function(callback)
     149    {
     150        // Make sure default _populate won't be invoked.
     151        this.removeEventListener("populate", this._populate, this);
     152        this.expand();
     153        this._provider.sortAndRewind(this.comparator(), callback);
     154    },
     155
    131156    /**
    132157     * @param {?number} fromPosition
     
    171196                if (items.startPosition > 0) {
    172197                    this._retrievedChildrenRanges.push({from: 0, to: 0});
    173                     insertShowMoreButton.call(this, 0, items.startPosition, insertionIndex);
     198                    insertShowMoreButton.call(this, 0, items.startPosition, insertionIndex++);
    174199                }
    175200                this._retrievedChildrenRanges.push({from: items.startPosition, to: items.endPosition});
     
    292317            this._populateChildren(0, instanceCount, afterPopulate.bind(this));
    293318        }
     319
    294320        this._provider.sortAndRewind(this.comparator(), afterSort.bind(this));
    295321    }
     
    971997
    972998WebInspector.HeapSnapshotDominatorObjectNode.prototype = {
     999    /**
     1000     * @param {number} snapshotObjectId
     1001     * @param {function(?WebInspector.HeapSnapshotDominatorObjectNode)} callback
     1002     */
     1003    retrieveChildBySnapshotObjectId: function(snapshotObjectId, callback)
     1004    {
     1005        function didExpand()
     1006        {
     1007            this._provider.nodePosition(snapshotObjectId, didGetNodePosition.bind(this));
     1008        }
     1009
     1010        function didGetNodePosition(nodePosition)
     1011        {
     1012            if (nodePosition === -1) {
     1013                this.collapse();
     1014                callback(null);
     1015            } else
     1016                this._populateChildren(nodePosition, null, didPopulateChildren.bind(this, nodePosition));
     1017        }
     1018
     1019        function didPopulateChildren(nodePosition)
     1020        {
     1021            var child = this.childForPosition(nodePosition);
     1022            callback(child);
     1023        }
     1024
     1025        this.expandWithoutPopulate(didExpand.bind(this));
     1026    },
     1027
    9731028    _createChildNode: function(item)
    9741029    {
  • trunk/Source/WebCore/inspector/front-end/HeapSnapshotProxy.js

    r117050 r117051  
    428428    },
    429429
     430    dominatorIdsForNode: function(nodeIndex, callback)
     431    {
     432        this.callMethod(callback, "dominatorIdsForNode", nodeIndex);
     433    },
     434
    430435    createEdgesProvider: function(nodeIndex, filter)
    431436    {
  • trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js

    r116959 r117051  
    586586    /**
    587587     * @param {ProfilerAgent.HeapSnapshotObjectId} snapshotObjectId
    588      */
    589     showObject: function(snapshotObjectId)
     588     * @param {string} viewName
     589     */
     590    showObject: function(snapshotObjectId, viewName)
    590591    {
    591592        var heapProfiles = this.getProfiles(WebInspector.HeapSnapshotProfileType.TypeId);
     
    595596            if (profile.maxJSObjectId >= snapshotObjectId) {
    596597                this.showProfile(profile);
    597                 profile._profileView.changeView("Summary", function() {
    598                     if (profile._profileView.dataGrid !==  profile._profileView.constructorsDataGrid)
    599                         return;
     598                profile._profileView.changeView(viewName, function() {
    600599                    profile._profileView.dataGrid.highlightObjectByHeapSnapshotId(snapshotObjectId);
    601600                });
     
    10991098            return;
    11001099
    1101         function revealInSummaryView()
     1100        function revealInView(viewName)
    11021101        {
    1103             ProfilerAgent.getHeapObjectId(objectId, didReceiveHeapObjectId.bind(this));
    1104         }
    1105 
    1106         function didReceiveHeapObjectId(error, result)
     1102            ProfilerAgent.getHeapObjectId(objectId, didReceiveHeapObjectId.bind(this, viewName));
     1103        }
     1104
     1105        function didReceiveHeapObjectId(viewName, error, result)
    11071106        {
    11081107            if (WebInspector.inspectorView.currentPanel() !== WebInspector.panels.profiles)
    11091108                return;
    11101109            if (!error)
    1111                 WebInspector.panels.profiles.showObject(result);
    1112         }
    1113 
    1114         contextMenu.appendItem(WebInspector.UIString("Reveal in Summary View"), revealInSummaryView.bind(this));
     1110                WebInspector.panels.profiles.showObject(result, viewName);
     1111        }
     1112
     1113        contextMenu.appendItem(WebInspector.UIString("Reveal in Dominators View"), revealInView.bind(this, "Dominators"));
     1114        contextMenu.appendItem(WebInspector.UIString("Reveal in Summary View"), revealInView.bind(this, "Summary"));
    11151115    }
    11161116}
Note: See TracChangeset for help on using the changeset viewer.