Title: [101760] trunk
Revision
101760
Author
[email protected]
Date
2011-12-02 01:06:09 -0800 (Fri, 02 Dec 2011)

Log Message

Web Inspector: use object properties, not element attributes to pass preferred panel/line/request id in linkified anchors
https://bugs.webkit.org/show_bug.cgi?id=73556

Reviewed by Pavel Feldman.

Source/WebCore:

* inspector/front-end/AuditFormatters.js:
(WebInspector.AuditFormatters.resourceLink):
* inspector/front-end/ConsoleMessage.js:
(WebInspector.ConsoleMessageImpl.prototype._formatMessage.else.else.linkifier):
(WebInspector.ConsoleMessageImpl.prototype._formatMessage):
* inspector/front-end/DebuggerPresentationModel.js:
(WebInspector.DebuggerPresentationModel.Linkifier.prototype.linkifyLocation):
(WebInspector.DebuggerPresentationModel.Linkifier.prototype._updateAnchor):
* inspector/front-end/NetworkPanel.js:
(WebInspector.NetworkPanel.prototype._resourceByAnchor):
(WebInspector.NetworkDataGridNode.prototype._refreshInitiatorCell):
* inspector/front-end/ResourceUtils.js:
(WebInspector.linkifyStringAsFragment):
(WebInspector.linkifyResourceAsNode):
(WebInspector.linkifyRequestAsNode):
* inspector/front-end/ResourcesPanel.js:
(WebInspector.ResourcesPanel.prototype.showAnchorLocation):
* inspector/front-end/inspector.js:
(WebInspector._showAnchorLocation):

LayoutTests:

* inspector/extensions/extensions-audits-expected.txt:
* inspector/extensions/extensions-audits.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (101759 => 101760)


--- trunk/LayoutTests/ChangeLog	2011-12-02 08:58:21 UTC (rev 101759)
+++ trunk/LayoutTests/ChangeLog	2011-12-02 09:06:09 UTC (rev 101760)
@@ -1,3 +1,13 @@
+2011-12-01  Andrey Kosyakov  <[email protected]>
+
+        Web Inspector: use object properties, not element attributes to pass preferred panel/line/request id in linkified anchors
+        https://bugs.webkit.org/show_bug.cgi?id=73556
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/extensions/extensions-audits-expected.txt:
+        * inspector/extensions/extensions-audits.html:
+
 2011-12-02  Pavel Feldman  <[email protected]>
 
         Web Inspector: refactor InspectorBackendDispatcher so that it does not use JSON-serialized command templates.

Modified: trunk/LayoutTests/inspector/extensions/extensions-audits-api-expected.txt (101759 => 101760)


--- trunk/LayoutTests/inspector/extensions/extensions-audits-api-expected.txt	2011-12-02 08:58:21 UTC (rev 101759)
+++ trunk/LayoutTests/inspector/extensions/extensions-audits-api-expected.txt	2011-12-02 09:06:09 UTC (rev 101760)
@@ -16,7 +16,6 @@
     createURL : <function>
     createSnippet : <function>
     createText : <function>
-    createResourceLink : <function>
     addResult : <function>
     createResult : <function>
     done : <function>
@@ -25,6 +24,7 @@
         Warning : "warning"
         Severe : "severe"
     }
+    createResourceLink : <function>
 }
 {
     contents : {

Modified: trunk/LayoutTests/inspector/extensions/extensions-audits-expected.txt (101759 => 101760)


--- trunk/LayoutTests/inspector/extensions/extensions-audits-expected.txt	2011-12-02 08:58:21 UTC (rev 101759)
+++ trunk/LayoutTests/inspector/extensions/extensions-audits-expected.txt	2011-12-02 09:06:09 UTC (rev 101760)
@@ -3,7 +3,6 @@
 Started extension.
 Running tests...
 RUNNING TEST: extension_testAudits
-Added audit category.
   Extension audits
     Failed rule (42)
      this rule always fails
@@ -19,7 +18,8 @@
 {
     return 4;
 }
-         error.html:10
+         /path/to/error.html:10
+         extensions-audits.html:20
     Passed rule
      this rule always passes ok
   Extension audits that fail

Modified: trunk/LayoutTests/inspector/extensions/extensions-audits.html (101759 => 101760)


--- trunk/LayoutTests/inspector/extensions/extensions-audits.html	2011-12-02 08:58:21 UTC (rev 101759)
+++ trunk/LayoutTests/inspector/extensions/extensions-audits.html	2011-12-02 09:06:09 UTC (rev 101760)
@@ -9,9 +9,11 @@
 
 function extension_testAudits(nextTest)
 {
+    var pendingOutput = [];
+
     function onStartAuditCategory(results)
     {
-        output("category.onAuditStarted fired");
+        pendingOutput.push("category.onAuditStarted fired");
         results.addResult("Passed rule", "this rule always passes ok", results.Severity.Info);
         results.addResult("Failed rule (42)", "this rule always fails", results.Severity.Severe);
 
@@ -21,27 +23,30 @@
         nestedNode.expanded = true;
         nestedNode.addChild(results.createSnippet("function rand()\n{\n    return 4;\n}"));
         nestedNode.addChild(results.createResourceLink("file:///path/to/error.html", 10));
+        webInspector.inspectedWindow.eval("location.href", function(inspectedPageURL) {
+            nestedNode.addChild(results.createResourceLink(inspectedPageURL, 20));
 
-        results.addResult("Rule with details subtree (1)", "This rule has a lot of details", results.Severity.Warning, node);
-        // Audit normally terminates when number of added rule results is equal to
-        // the rule count declared when adding a category. done() is only for
-        // emergency cases, when we know we won't be able to run the rest of the rules.
-        results.done();
+            results.addResult("Rule with details subtree (1)", "This rule has a lot of details", results.Severity.Warning, node);
+
+            // Audit normally terminates when number of added rule results is equal to
+            // the rule count declared when adding a category. done() is only for
+            // emergency cases, when we know we won't be able to run the rest of the rules.
+            results.done();
+        });
     }
     function onStartAuditFailedCategory()
     {
-        output("failedCategory.onAuditStarted fired, throwing exception");
+        pendingOutput.push("failedCategory.onAuditStarted fired, throwing exception");
         throw "oops!";
     }
     function onStartAuditDisabledCategory(results)
     {
-        output("FAIL: disabledCategory.onAuditStarted fired");
+        pendingOutput.push("FAIL: disabledCategory.onAuditStarted fired");
         results.done();
     }
 
     var category = webInspector.audits.addCategory("Extension audits", 20);
     category.onAuditStarted.addListener(onStartAuditCategory);
-    output("Added audit category.");
 
     var failedCategory = webInspector.audits.addCategory("Extension audits that fail", 2);
     failedCategory.onAuditStarted.addListener(onStartAuditFailedCategory);
@@ -49,8 +54,13 @@
     var disabledCategory = webInspector.audits.addCategory("Disabled extension audits", 2);
     disabledCategory.onAuditStarted.addListener(onStartAuditDisabledCategory);
 
+    function auditsDone()
+    {
+        pendingOutput.sort().forEach(output);
+        nextTest();
+    }
     webInspector.inspectedWindow.eval("", function() {
-        extension_runAudits(nextTest);
+        extension_runAudits(auditsDone);
     });
 }
 

Modified: trunk/Source/WebCore/ChangeLog (101759 => 101760)


--- trunk/Source/WebCore/ChangeLog	2011-12-02 08:58:21 UTC (rev 101759)
+++ trunk/Source/WebCore/ChangeLog	2011-12-02 09:06:09 UTC (rev 101760)
@@ -1,3 +1,30 @@
+2011-12-01  Andrey Kosyakov  <[email protected]>
+
+        Web Inspector: use object properties, not element attributes to pass preferred panel/line/request id in linkified anchors
+        https://bugs.webkit.org/show_bug.cgi?id=73556
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/front-end/AuditFormatters.js:
+        (WebInspector.AuditFormatters.resourceLink):
+        * inspector/front-end/ConsoleMessage.js:
+        (WebInspector.ConsoleMessageImpl.prototype._formatMessage.else.else.linkifier):
+        (WebInspector.ConsoleMessageImpl.prototype._formatMessage):
+        * inspector/front-end/DebuggerPresentationModel.js:
+        (WebInspector.DebuggerPresentationModel.Linkifier.prototype.linkifyLocation):
+        (WebInspector.DebuggerPresentationModel.Linkifier.prototype._updateAnchor):
+        * inspector/front-end/NetworkPanel.js:
+        (WebInspector.NetworkPanel.prototype._resourceByAnchor):
+        (WebInspector.NetworkDataGridNode.prototype._refreshInitiatorCell):
+        * inspector/front-end/ResourceUtils.js:
+        (WebInspector.linkifyStringAsFragment):
+        (WebInspector.linkifyResourceAsNode):
+        (WebInspector.linkifyRequestAsNode):
+        * inspector/front-end/ResourcesPanel.js:
+        (WebInspector.ResourcesPanel.prototype.showAnchorLocation):
+        * inspector/front-end/inspector.js:
+        (WebInspector._showAnchorLocation):
+
 2011-12-02  Pavel Feldman  <[email protected]>
 
         Web Inspector: refactor InspectorBackendDispatcher so that it does not use JSON-serialized command templates.

Modified: trunk/Source/WebCore/inspector/front-end/AuditFormatters.js (101759 => 101760)


--- trunk/Source/WebCore/inspector/front-end/AuditFormatters.js	2011-12-02 08:58:21 UTC (rev 101759)
+++ trunk/Source/WebCore/inspector/front-end/AuditFormatters.js	2011-12-02 09:06:09 UTC (rev 101760)
@@ -94,14 +94,7 @@
 
     resourceLink: function(url, line)
     {
-        var title = url.replace(/.*[\/\\]/, "") + ":" + line;
-        var a = document.createElement("a");
-        a.href = ""
-        a.title = url;
-        a.className = "console-message-url webkit-html-resource-link";
-        a.setAttribute("line_number", line);
-        a.setAttribute("preferred_panel", "scripts");
-        a.textContent = title;
-        return a;
+        // FIXME: use WebInspector.DebuggerPresentationModel.Linkifier
+        return WebInspector.linkifyResourceAsNode(url, line, "console-message-url webkit-html-resource-link");
     }
 };

Modified: trunk/Source/WebCore/inspector/front-end/ConsoleMessage.js (101759 => 101760)


--- trunk/Source/WebCore/inspector/front-end/ConsoleMessage.js	2011-12-02 08:58:21 UTC (rev 101759)
+++ trunk/Source/WebCore/inspector/front-end/ConsoleMessage.js	2011-12-02 09:06:09 UTC (rev 101760)
@@ -101,32 +101,16 @@
         } else if (this.source === WebInspector.ConsoleMessage.MessageSource.Network) {
             if (this._request) {
                 this._stackTrace = this._request.stackTrace;
+                messageText = document.createElement("span");
                 if (this.level === WebInspector.ConsoleMessage.MessageLevel.Error) {
-                    messageText = document.createElement("span");
                     messageText.appendChild(document.createTextNode(this._request.requestMethod + " "));
-                    var anchor = WebInspector.linkifyURLAsNode(this._request.url);
-                    anchor.setAttribute("request_id", this._request.requestId);
-                    anchor.setAttribute("preferred_panel", "network");
-                    messageText.appendChild(anchor);
+                    messageText.appendChild(WebInspector.linkifyRequestAsNode(this._request));
                     if (this._request.failed)
                         messageText.appendChild(document.createTextNode(" " + this._request.localizedFailDescription));
                     else
                         messageText.appendChild(document.createTextNode(" " + this._request.statusCode + " (" + this._request.statusText + ")"));
                 } else {
-                    messageText = document.createElement("span");
-                    
-                    function linkifier(title, url, lineNumber)
-                    {
-                        var isExternal = !this._request;
-                        var anchor = WebInspector.linkifyURLAsNode(url, title, undefined, isExternal);
-                        if (this._request) {
-                            anchor.setAttribute("request_id", this._request.requestId);
-                            anchor.setAttribute("preferred_panel", "network");
-                        }
-                        return anchor;
-                    }
-
-                    var fragment = WebInspector.linkifyStringAsFragmentWithCustomLinkifier(this._messageText, linkifier.bind(this));
+                    var fragment = WebInspector.linkifyStringAsFragmentWithCustomLinkifier(this._messageText, WebInspector.linkifyRequestAsNode.bind(null, this._request, ""));
                     messageText.appendChild(fragment);
                 }
             } else {

Modified: trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js (101759 => 101760)


--- trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js	2011-12-02 08:58:21 UTC (rev 101759)
+++ trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js	2011-12-02 09:06:09 UTC (rev 101760)
@@ -953,26 +953,12 @@
     {
         var rawSourceCode = this._model._rawSourceCodeForScriptWithURL(sourceURL);
         if (!rawSourceCode)
-            return this.linkifyResource(sourceURL, lineNumber, classes);
+            return WebInspector.linkifyResourceAsNode(sourceURL, lineNumber, classes);
 
         return this.linkifyRawSourceCode(rawSourceCode, lineNumber, columnNumber, classes);
     },
 
     /**
-     * @param {string} sourceURL
-     * @param {number} lineNumber
-     * @param {string=} classes
-     */
-    linkifyResource: function(sourceURL, lineNumber, classes)
-    {
-        var linkText = WebInspector.formatLinkText(sourceURL, lineNumber);
-        var anchor = WebInspector.linkifyURLAsNode(sourceURL, linkText, classes, false);
-        anchor.setAttribute("preferred_panel", "resources");
-        anchor.setAttribute("line_number", lineNumber);
-        return anchor;
-    },
-
-    /**
      * @param {WebInspector.RawSourceCode} rawSourceCode
      * @param {number=} lineNumber
      * @param {number=} columnNumber
@@ -1023,7 +1009,7 @@
     _updateAnchor: function(rawSourceCode, anchor)
     {
         var uiLocation = rawSourceCode.sourceMapping.rawLocationToUILocation(anchor.rawLocation);
-        anchor.setAttribute("preferred_panel", "scripts");
+        anchor.preferredPanel = "scripts";
         anchor.uiSourceCode = uiLocation.uiSourceCode;
         anchor.lineNumber = uiLocation.lineNumber;
 

Modified: trunk/Source/WebCore/inspector/front-end/ExtensionAPI.js (101759 => 101760)


--- trunk/Source/WebCore/inspector/front-end/ExtensionAPI.js	2011-12-02 08:58:21 UTC (rev 101759)
+++ trunk/Source/WebCore/inspector/front-end/ExtensionAPI.js	2011-12-02 09:06:09 UTC (rev 101760)
@@ -498,7 +498,6 @@
     this.createURL = bind(this._nodeFactory, null, "url");
     this.createSnippet = bind(this._nodeFactory, null, "snippet");
     this.createText = bind(this._nodeFactory, null, "text");
-    this.createResourceLink = bind(this._nodeFactory, null, "resourceLink");
 }
 
 AuditResultImpl.prototype = {
@@ -534,6 +533,14 @@
         return apiPrivate.audits.Severity;
     },
 
+    createResourceLink: function(url, lineNumber)
+    {
+        return {
+            type: "resourceLink",
+            arguments: [url, lineNumber - 1]
+        };
+    },
+
     _nodeFactory: function(type)
     {
         return {

Modified: trunk/Source/WebCore/inspector/front-end/NetworkPanel.js (101759 => 101760)


--- trunk/Source/WebCore/inspector/front-end/NetworkPanel.js	2011-12-02 08:58:21 UTC (rev 101759)
+++ trunk/Source/WebCore/inspector/front-end/NetworkPanel.js	2011-12-02 09:06:09 UTC (rev 101760)
@@ -1310,13 +1310,7 @@
 
     _resourceByAnchor: function(anchor)
     {
-        var resource;
-        if (anchor.getAttribute("request_id"))
-            resource = this.resourceById(anchor.getAttribute("request_id"));
-        if (!resource)
-            resource = this._networkLogView._resourcesByURL[anchor.href];
-
-        return resource;
+        return anchor.requestId ? this.resourceById(anchor.requestId) : this._networkLogView._resourcesByURL[anchor.href];
     },
 
     canShowAnchorLocation: function(anchor)
@@ -1902,11 +1896,8 @@
             this._initiatorCell.removeChildren();
             if (this._resource.redirectSource) {
                 var redirectSource = this._resource.redirectSource;
-                var anchor = WebInspector.linkifyURLAsNode(redirectSource.url, redirectSource.url, undefined, false);
-                anchor.setAttribute("request_id", redirectSource.requestId);
-                anchor.setAttribute("preferred_panel", "network");
                 this._initiatorCell.title = redirectSource.url;
-                this._initiatorCell.appendChild(anchor);
+                this._initiatorCell.appendChild(WebInspector.linkifyRequestAsNode(redirectSource));
                 this._appendSubtitle(this._initiatorCell, WebInspector.UIString("Redirect"));
             } else if (initiator.type === "script") {
                 var topFrame = initiator.stackTrace[0];

Modified: trunk/Source/WebCore/inspector/front-end/ResourceUtils.js (101759 => 101760)


--- trunk/Source/WebCore/inspector/front-end/ResourceUtils.js	2011-12-02 08:58:21 UTC (rev 101759)
+++ trunk/Source/WebCore/inspector/front-end/ResourceUtils.js	2011-12-02 09:06:09 UTC (rev 101760)
@@ -135,8 +135,8 @@
         var isExternal = !WebInspector.resourceForURL(url);
         var urlNode = WebInspector.linkifyURLAsNode(url, title, undefined, isExternal);
         if (typeof(lineNumber) !== "undefined") {
-            urlNode.setAttribute("line_number", lineNumber);
-            urlNode.setAttribute("preferred_panel", "scripts");
+            urlNode.lineNumber = lineNumber;
+            urlNode.preferredPanel = "scripts";
         }
         
         return urlNode; 
@@ -199,13 +199,24 @@
 {
     var linkText = WebInspector.formatLinkText(url, lineNumber);
     var anchor = WebInspector.linkifyURLAsNode(url, linkText, classes, false, tooltipText);
-    anchor.setAttribute("preferred_panel", "resources");
-    if (typeof lineNumber !== "undefined")
-        anchor.setAttribute("line_number", lineNumber);
+    anchor.preferredPanel = "resources";
+    anchor.lineNumber = lineNumber;
     return anchor;
 }
 
 /**
+ * @param {WebInspector.Resource} request
+ * @param {string=} classes
+ */
+WebInspector.linkifyRequestAsNode = function(request, classes)
+{
+    var anchor = WebInspector.linkifyURLAsNode(request.url);
+    anchor.preferredPanel = "network";
+    anchor.requestId  = request.requestId;
+    return anchor;
+}
+
+/**
  * @return {?string} null if the specified resource MUST NOT have a URL (e.g. "_javascript_:...")
  */
 WebInspector.resourceURLForRelatedNode = function(node, url)

Modified: trunk/Source/WebCore/inspector/front-end/ResourcesPanel.js (101759 => 101760)


--- trunk/Source/WebCore/inspector/front-end/ResourcesPanel.js	2011-12-02 08:58:21 UTC (rev 101759)
+++ trunk/Source/WebCore/inspector/front-end/ResourcesPanel.js	2011-12-02 09:06:09 UTC (rev 101760)
@@ -340,8 +340,7 @@
     showAnchorLocation: function(anchor)
     {
         var resource = WebInspector.resourceForURL(anchor.href);
-        var lineNumber = anchor.hasAttribute("line_number") ? parseInt(anchor.getAttribute("line_number"), 10) : undefined;
-        this.showResource(resource, lineNumber);
+        this.showResource(resource, anchor.lineNumber);
     },
 
     /**

Modified: trunk/Source/WebCore/inspector/front-end/inspector.js (101759 => 101760)


--- trunk/Source/WebCore/inspector/front-end/inspector.js	2011-12-02 08:58:21 UTC (rev 101759)
+++ trunk/Source/WebCore/inspector/front-end/inspector.js	2011-12-02 09:06:09 UTC (rev 101760)
@@ -820,7 +820,7 @@
 {
     if (WebInspector.openAnchorLocationRegistry.dispatch(anchor.href))
         return true;
-    var preferedPanel = this.panels[anchor.getAttribute("preferred_panel") || "resources"];
+    var preferedPanel = this.panels[anchor.preferredPanel || "resources"];
     if (WebInspector._showAnchorLocationInPanel(anchor, preferedPanel))
         return true;
     if (preferedPanel !== this.panels.resources && WebInspector._showAnchorLocationInPanel(anchor, this.panels.resources))
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to