[Web Inspector] Fix Sort by Initiator functionality of Network Panel.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Feb 2013 06:26:04 +0000 (06:26 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Feb 2013 06:26:04 +0000 (06:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=109135.

Patch by Pan Deng <pan.deng@intel.com> on 2013-02-20
Reviewed by Pavel Feldman.

A refactor for request initiator types, and the sort by Initiator functionality
was changed to sort by url and line number that displayed in initiator cell.

No new tests.

* inspector/front-end/NetworkPanel.js:
(WebInspector.NetworkDataGridNode.prototype._refreshInitiatorCell): save initiator displayedURL and displayedLineNumber
(WebInspector.NetworkDataGridNode.InitiatorComparator):
* inspector/front-end/NetworkRequest.js:

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

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

index 29fe985a0089af173346ab9488fdda1ddb8359d4..ceb83fb8143680c2df5e2d76f54e145c31bc230b 100644 (file)
@@ -1,3 +1,20 @@
+2013-02-20  Pan Deng  <pan.deng@intel.com>
+
+        [Web Inspector] Fix Sort by Initiator functionality of Network Panel.
+        https://bugs.webkit.org/show_bug.cgi?id=109135.
+
+        Reviewed by Pavel Feldman.
+
+        A refactor for request initiator types, and the sort by Initiator functionality 
+        was changed to sort by url and line number that displayed in initiator cell.
+
+        No new tests.
+
+        * inspector/front-end/NetworkPanel.js:
+        (WebInspector.NetworkDataGridNode.prototype._refreshInitiatorCell): save initiator displayedURL and displayedLineNumber
+        (WebInspector.NetworkDataGridNode.InitiatorComparator):
+        * inspector/front-end/NetworkRequest.js:
+
 2013-02-20  Eric Seidel  <eric@webkit.org>
 
         WebVTTParser copies character buffer more often than necessary
index e2c12702fe3d39aedc4756c4cabfce059a89791c..f762e37503ba79956f2de1f8a1ee6891a627b753 100644 (file)
@@ -2183,16 +2183,20 @@ WebInspector.NetworkDataGridNode.prototype = {
         this._initiatorCell.removeStyleClass("network-script-initiated");
         delete this._initiatorCell.request;
         this._initiatorCell.title = "";
+        delete this._displayedInitiatorURL;
+        delete this._displayedInitiatorLineNumber;
 
         var initiator = this._request.initiator;
-        if ((initiator && initiator.type !== "other") || this._request.redirectSource) {
+        var initiatorTypes = WebInspector.NetworkRequest.InitiatorType;
+        if ((initiator && initiator.type !== initiatorTypes.Other) || this._request.redirectSource) {
             this._initiatorCell.removeChildren();
             var redirectSource = this._request.redirectSource;
             if (redirectSource) {
                 this._initiatorCell.title = redirectSource.url;
                 this._initiatorCell.appendChild(WebInspector.linkifyRequestAsNode(redirectSource));
                 this._appendSubtitle(this._initiatorCell, WebInspector.UIString("Redirect"));
-            } else if (initiator.type === "script") {
+                this._displayedInitiatorURL = redirectSource.url;
+            } else if (initiator.type === initiatorTypes.Script) {
                 var topFrame = initiator.stackTrace[0];
                 // This could happen when request loading was triggered by console.
                 if (!topFrame.url) {
@@ -2206,10 +2210,14 @@ WebInspector.NetworkDataGridNode.prototype = {
                 this._appendSubtitle(this._initiatorCell, WebInspector.UIString("Script"));
                 this._initiatorCell.addStyleClass("network-script-initiated");
                 this._initiatorCell.request = this._request;
-            } else { // initiator.type === "parser"
+                this._displayedInitiatorURL = WebInspector.displayNameForURL(topFrame.url);
+                this._displayedInitiatorLineNumber = topFrame.lineNumber;
+            } else { // initiator.type === initiatorTypes.Parser
                 this._initiatorCell.title = initiator.url + ":" + initiator.lineNumber;
                 this._initiatorCell.appendChild(WebInspector.linkifyResourceAsNode(initiator.url, initiator.lineNumber - 1));
                 this._appendSubtitle(this._initiatorCell, WebInspector.UIString("Parser"));
+                this._displayedInitiatorURL = WebInspector.displayNameForURL(initiator.url);
+                this._displayedInitiatorLineNumber = initiator.lineNumber;
             }
         } else {
             this._initiatorCell.addStyleClass("network-dim-cell");
@@ -2386,17 +2394,18 @@ WebInspector.NetworkDataGridNode.SizeComparator = function(a, b)
 
 WebInspector.NetworkDataGridNode.InitiatorComparator = function(a, b)
 {
-    if (!a._request.initiator || a._request.initiator.type === "Other")
-        return -1;
-    if (!b._request.initiator || b._request.initiator.type === "Other")
+    var initiatorTypes = WebInspector.NetworkRequest.InitiatorType;
+    if (!a._request.initiator || a._request.initiator.type === initiatorTypes.Other)
+        return -1;    
+    if (!b._request.initiator || b._request.initiator.type === initiatorTypes.Other)
         return 1;
 
-    if (a._request.initiator.url < b._request.initiator.url)
+    if (a._displayedInitiatorURL < b._displayedInitiatorURL)
         return -1;
-    if (a._request.initiator.url > b._request.initiator.url)
+    if (a._displayedInitiatorURL > b._displayedInitiatorURL)
         return 1;
 
-    return a._request.initiator.lineNumber - b._request.initiator.lineNumber;
+    return a._displayedInitiatorLineNumber - b._displayedInitiatorLineNumber;
 }
 
 WebInspector.NetworkDataGridNode.RequestCookiesCountComparator = function(a, b)
index 73895a0f6d64c389253807dd1f3f3c2388a484ca..ab4ed86d6339b6c2829938432468a7349e986791 100644 (file)
@@ -67,6 +67,12 @@ WebInspector.NetworkRequest.Events = {
     ResponseHeadersChanged: "ResponseHeadersChanged",
 }
 
+WebInspector.NetworkRequest.InitiatorType = {
+    Parser: "parser",
+    Script: "script",
+    Other: "other",
+}
+
 WebInspector.NetworkRequest.prototype = {
     /**
      * @return {NetworkAgent.RequestId}