Web Inspector: Network: display JavaScript stack in case of script initiator.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Dec 2012 10:03:20 +0000 (10:03 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Dec 2012 10:03:20 +0000 (10:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=104899

Patch by Eugene Klyuchnikov <eustas@chromium.org> on 2012-12-18
Reviewed by Vsevolod Vlasov.

Show popup with navigavle stack-trace.

* inspector/front-end/NetworkPanel.js:
(WebInspector.NetworkLogView.prototype._getPopoverAnchor):
Added new target.
(WebInspector.NetworkLogView.prototype._showPopover):
Added case for new target.
(WebInspector.NetworkLogView.prototype._generateScriptInitiatedPopoverContent):
Generates table with stack trace items.
(WebInspector.NetworkDataGridNode.prototype._refreshInitiatorCell):
Added target marker, removed annoying titles.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@138000 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/NetworkPanel.js

index f09b53f..e864c50 100644 (file)
@@ -1,3 +1,22 @@
+2012-12-18  Eugene Klyuchnikov  <eustas@chromium.org>
+
+        Web Inspector: Network: display JavaScript stack in case of script initiator.
+        https://bugs.webkit.org/show_bug.cgi?id=104899
+
+        Reviewed by Vsevolod Vlasov.
+
+        Show popup with navigavle stack-trace.
+
+        * inspector/front-end/NetworkPanel.js:
+        (WebInspector.NetworkLogView.prototype._getPopoverAnchor):
+        Added new target.
+        (WebInspector.NetworkLogView.prototype._showPopover):
+        Added case for new target.
+        (WebInspector.NetworkLogView.prototype._generateScriptInitiatedPopoverContent):
+        Generates table with stack trace items.
+        (WebInspector.NetworkDataGridNode.prototype._refreshInitiatorCell):
+        Added target marker, removed annoying titles.
+
 2012-12-18  Tamas Czene  <tczene@inf.u-szeged.hu>
 
         Style fix to OpenCL SVG Filters
 2012-12-18  Tamas Czene  <tczene@inf.u-szeged.hu>
 
         Style fix to OpenCL SVG Filters
index b19042a..0522313 100644 (file)
@@ -925,10 +925,13 @@ WebInspector.NetworkLogView.prototype = {
         if (!this._allowPopover)
             return;
         var anchor = element.enclosingNodeOrSelfWithClass("network-graph-bar") || element.enclosingNodeOrSelfWithClass("network-graph-label");
         if (!this._allowPopover)
             return;
         var anchor = element.enclosingNodeOrSelfWithClass("network-graph-bar") || element.enclosingNodeOrSelfWithClass("network-graph-label");
-        if (!anchor)
-            return null;
-        var request = anchor.parentElement.request;
-        return request && request.timing ? anchor : null;
+        if (anchor && anchor.parentElement.request && anchor.parentElement.request.timing)
+            return anchor;
+        anchor = element.enclosingNodeOrSelfWithClass("network-script-initiated");
+        if (anchor && anchor.request && anchor.request.initiator)
+            return anchor;
+
+        return null;
     },
 
     /**
     },
 
     /**
@@ -937,9 +940,31 @@ WebInspector.NetworkLogView.prototype = {
      */
     _showPopover: function(anchor, popover)
     {
      */
     _showPopover: function(anchor, popover)
     {
-        var request = anchor.parentElement.request;
-        var tableElement = WebInspector.RequestTimingView.createTimingTable(request);
-        popover.show(tableElement, anchor);
+        var content;
+        if (anchor.hasStyleClass("network-script-initiated"))
+            content = this._generateScriptInitiatedPopoverContent(anchor.request);
+        else
+            content = WebInspector.RequestTimingView.createTimingTable(anchor.parentElement.request);
+        popover.show(content, anchor);
+    },
+
+    /**
+     * @param {!WebInspector.NetworkRequest} request
+     * @return {!Element}
+     */
+    _generateScriptInitiatedPopoverContent: function(request)
+    {
+        var stackTrace = request.initiator.stackTrace;
+        var framesTable = document.createElement("table");
+        for (var i = 0; i < stackTrace.length; ++i) {
+            var stackFrame = stackTrace[i];
+            var row = document.createElement("tr");
+            row.createChild("td").textContent = stackFrame.functionName ? stackFrame.functionName : WebInspector.UIString("(anonymous function)");
+            row.createChild("td").textContent = " @ ";
+            row.createChild("td").appendChild(this._linkifier.linkifyLocation(stackFrame.url, stackFrame.lineNumber - 1, 0));
+            framesTable.appendChild(row);
+        }
+        return framesTable;
     },
 
     _contextMenu: function(event)
     },
 
     _contextMenu: function(event)
@@ -2010,9 +2035,13 @@ WebInspector.NetworkDataGridNode.prototype = {
 
     _refreshInitiatorCell: function()
     {
 
     _refreshInitiatorCell: function()
     {
+        this._initiatorCell.removeStyleClass("network-dim-cell");
+        this._initiatorCell.removeStyleClass("network-script-initiated");
+        delete this._initiatorCell.request;
+        this._initiatorCell.title = null;
+
         var initiator = this._request.initiator;
         if ((initiator && initiator.type !== "other") || this._request.redirectSource) {
         var initiator = this._request.initiator;
         if ((initiator && initiator.type !== "other") || this._request.redirectSource) {
-            this._initiatorCell.removeStyleClass("network-dim-cell");
             this._initiatorCell.removeChildren();
             if (this._request.redirectSource) {
                 var redirectSource = this._request.redirectSource;
             this._initiatorCell.removeChildren();
             if (this._request.redirectSource) {
                 var redirectSource = this._request.redirectSource;
@@ -2027,10 +2056,12 @@ WebInspector.NetworkDataGridNode.prototype = {
                     this._initiatorCell.setTextAndTitle(WebInspector.UIString("Other"));
                     return;
                 }
                     this._initiatorCell.setTextAndTitle(WebInspector.UIString("Other"));
                     return;
                 }
-                this._initiatorCell.title = topFrame.url + ":" + topFrame.lineNumber;
                 var urlElement = this._parentView._linkifier.linkifyLocation(topFrame.url, topFrame.lineNumber - 1, 0);
                 var urlElement = this._parentView._linkifier.linkifyLocation(topFrame.url, topFrame.lineNumber - 1, 0);
+                urlElement.title = null;
                 this._initiatorCell.appendChild(urlElement);
                 this._appendSubtitle(this._initiatorCell, WebInspector.UIString("Script"));
                 this._initiatorCell.appendChild(urlElement);
                 this._appendSubtitle(this._initiatorCell, WebInspector.UIString("Script"));
+                this._initiatorCell.addStyleClass("network-script-initiated");
+                this._initiatorCell.request = this._request;
             } else { // initiator.type === "parser"
                 this._initiatorCell.title = initiator.url + ":" + initiator.lineNumber;
                 this._initiatorCell.appendChild(WebInspector.linkifyResourceAsNode(initiator.url, initiator.lineNumber - 1));
             } else { // initiator.type === "parser"
                 this._initiatorCell.title = initiator.url + ":" + initiator.lineNumber;
                 this._initiatorCell.appendChild(WebInspector.linkifyResourceAsNode(initiator.url, initiator.lineNumber - 1));