Title: [88927] trunk
Revision
88927
Author
[email protected]
Date
2011-06-15 07:30:22 -0700 (Wed, 15 Jun 2011)

Log Message

2011-06-15  Pavel Podivilov  <[email protected]>

        Reviewed by Yury Semikhatsky.

        Web Inspector: script links are displayed with original line number in pretty-print mode.
        https://bugs.webkit.org/show_bug.cgi?id=62282

        * inspector/debugger/script-formatter-expected.txt:
        * inspector/debugger/script-formatter.html:
2011-06-15  Pavel Podivilov  <[email protected]>

        Reviewed by Yury Semikhatsky.

        Web Inspector: script links are displayed with original line number in pretty-print mode.
        https://bugs.webkit.org/show_bug.cgi?id=62282

        * inspector/front-end/DebuggerPresentationModel.js:
        (WebInspector.DebuggerPresentationModel):
        (WebInspector.DebuggerPresentationModel.prototype.registerAnchor):
        (WebInspector.DebuggerPresentationModel.prototype._updateAnchor.didGetUILocation):
        (WebInspector.DebuggerPresentationModel.prototype._updateAnchor):
        (WebInspector.DebuggerPresentationModel.prototype.setFormatSourceFiles):
        (WebInspector.DebuggerPresentationModel.prototype._debuggerReset):
        * inspector/front-end/NetworkPanel.js:
        (WebInspector.NetworkPanel.prototype.showAnchorLocation):
        (WebInspector.NetworkPanel.prototype._showResource):
        * inspector/front-end/Panel.js:
        (WebInspector.Panel.prototype.createAnchor):
        (WebInspector.Panel.prototype.formatAnchorText):
        * inspector/front-end/ResourcesPanel.js:
        (WebInspector.ResourcesPanel.prototype.showAnchorLocation):
        * inspector/front-end/ScriptsPanel.js:
        (WebInspector.ScriptsPanel.prototype.createAnchor.):
        (WebInspector.ScriptsPanel.prototype.createAnchor):
        (WebInspector.ScriptsPanel.prototype.showAnchorLocation.didGetUILocation):
        (WebInspector.ScriptsPanel.prototype.showAnchorLocation):
        * inspector/front-end/inspector.js:
        (WebInspector._showAnchorLocation):
        (WebInspector.linkifyResourceAsNode):

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (88926 => 88927)


--- trunk/LayoutTests/ChangeLog	2011-06-15 14:21:50 UTC (rev 88926)
+++ trunk/LayoutTests/ChangeLog	2011-06-15 14:30:22 UTC (rev 88927)
@@ -1,3 +1,13 @@
+2011-06-15  Pavel Podivilov  <[email protected]>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: script links are displayed with original line number in pretty-print mode.
+        https://bugs.webkit.org/show_bug.cgi?id=62282
+
+        * inspector/debugger/script-formatter-expected.txt:
+        * inspector/debugger/script-formatter.html:
+
 2011-06-15  Kent Tamura  <[email protected]>
 
         [Chromium] Test expectation update for r88757 and r88901.

Modified: trunk/LayoutTests/inspector/debugger/script-formatter-expected.txt (88926 => 88927)


--- trunk/LayoutTests/inspector/debugger/script-formatter-expected.txt	2011-06-15 14:21:50 UTC (rev 88926)
+++ trunk/LayoutTests/inspector/debugger/script-formatter-expected.txt	2011-06-15 14:30:22 UTC (rev 88927)
@@ -1,3 +1,4 @@
+CONSOLE MESSAGE: line 24: Test message.
 Tests the script formatting functionality.
 
 Debugger was enabled.
@@ -30,5 +31,9 @@
     0) f2 (script-formatter.html:17)
     1)  (script-formatter.html:1)
 Script execution resumed.
+
+Running: testConsoleMessagesForFormattedScripts
+script-formatter.html:24
+script-formatter.html:32
 Debugger was disabled.
 

Modified: trunk/LayoutTests/inspector/debugger/script-formatter.html (88926 => 88927)


--- trunk/LayoutTests/inspector/debugger/script-formatter.html	2011-06-15 14:21:50 UTC (rev 88926)
+++ trunk/LayoutTests/inspector/debugger/script-formatter.html	2011-06-15 14:30:22 UTC (rev 88927)
@@ -19,6 +19,11 @@
     return 0;
 }
 
+function f3()
+{
+    console.log("Test message.");
+}
+
 var test = function()
 {
     var panel = WebInspector.panels.scripts;
@@ -151,7 +156,6 @@
             {
                 // There should be no breakpoint in f1 since script is pretty-printed now.
                 InspectorTest.evaluateInPageWithTimeout("f1()");
-
                 InspectorTest.setBreakpoint(panel.visibleView, 24, "", true);
                 InspectorTest.waitUntilPaused(pausedInF2);
                 InspectorTest.evaluateInPageWithTimeout("f2()");
@@ -160,6 +164,34 @@
             function pausedInF2(callFrames)
             {
                 InspectorTest.captureStackTrace(callFrames);
+                panel._toggleFormatSourceFiles();
+                InspectorTest.resumeExecution(next);
+            }
+        },
+
+        function testConsoleMessagesForFormattedScripts(next)
+        {
+            function dumpConsoleMessageURLs()
+            {
+                var messages = WebInspector.console.messages;
+                for (var i = 0; i < messages.length; ++i) {
+                    var element = messages[i].toMessageElement();
+                    var anchor = element.query("//*//a[contains(@class, 'console-message-url')]");
+                    InspectorTest.addResult(anchor.textContent);
+                }
+            }
+            InspectorTest.evaluateInPage("f3()", didEvaluate);
+
+            function didEvaluate()
+            {
+                dumpConsoleMessageURLs();
+                InspectorTest.addSniffer(panel, "formatAnchorText", InspectorTest.runAfterPendingDispatches.bind(InspectorTest, didFormatAnchorText));
+                panel._toggleFormatSourceFiles();
+            }
+
+            function didFormatAnchorText()
+            {
+                dumpConsoleMessageURLs();
                 next();
             }
         }

Modified: trunk/Source/WebCore/ChangeLog (88926 => 88927)


--- trunk/Source/WebCore/ChangeLog	2011-06-15 14:21:50 UTC (rev 88926)
+++ trunk/Source/WebCore/ChangeLog	2011-06-15 14:30:22 UTC (rev 88927)
@@ -1,3 +1,34 @@
+2011-06-15  Pavel Podivilov  <[email protected]>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: script links are displayed with original line number in pretty-print mode.
+        https://bugs.webkit.org/show_bug.cgi?id=62282
+
+        * inspector/front-end/DebuggerPresentationModel.js:
+        (WebInspector.DebuggerPresentationModel):
+        (WebInspector.DebuggerPresentationModel.prototype.registerAnchor):
+        (WebInspector.DebuggerPresentationModel.prototype._updateAnchor.didGetUILocation):
+        (WebInspector.DebuggerPresentationModel.prototype._updateAnchor):
+        (WebInspector.DebuggerPresentationModel.prototype.setFormatSourceFiles):
+        (WebInspector.DebuggerPresentationModel.prototype._debuggerReset):
+        * inspector/front-end/NetworkPanel.js:
+        (WebInspector.NetworkPanel.prototype.showAnchorLocation):
+        (WebInspector.NetworkPanel.prototype._showResource):
+        * inspector/front-end/Panel.js:
+        (WebInspector.Panel.prototype.createAnchor):
+        (WebInspector.Panel.prototype.formatAnchorText):
+        * inspector/front-end/ResourcesPanel.js:
+        (WebInspector.ResourcesPanel.prototype.showAnchorLocation):
+        * inspector/front-end/ScriptsPanel.js:
+        (WebInspector.ScriptsPanel.prototype.createAnchor.):
+        (WebInspector.ScriptsPanel.prototype.createAnchor):
+        (WebInspector.ScriptsPanel.prototype.showAnchorLocation.didGetUILocation):
+        (WebInspector.ScriptsPanel.prototype.showAnchorLocation):
+        * inspector/front-end/inspector.js:
+        (WebInspector._showAnchorLocation):
+        (WebInspector.linkifyResourceAsNode):
+
 2011-06-14  Hans Wennborg  <[email protected]>
 
         Reviewed by Tony Gentilcore.

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


--- trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js	2011-06-15 14:21:50 UTC (rev 88926)
+++ trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js	2011-06-15 14:30:22 UTC (rev 88927)
@@ -32,6 +32,7 @@
 {
     this._sourceFiles = {};
     this._messages = [];
+    this._anchors = [];
     this._breakpointsByDebuggerId = {};
     this._breakpointsWithoutSourceFile = {};
 
@@ -101,6 +102,26 @@
         this._sourceFiles[sourceFileId].requestContent(callback);
     },
 
+    registerAnchor: function(sourceURL, sourceId, lineNumber, columnNumber, updateHandler)
+    {
+        var anchor = { sourceURL: sourceURL, sourceId: sourceId, lineNumber: lineNumber, columnNumber: columnNumber, updateHandler: updateHandler };
+        this._anchors.push(anchor);
+        this._updateAnchor(anchor);
+    },
+
+    _updateAnchor: function(anchor)
+    {
+        var sourceFile = this._sourceFileForScript(anchor.sourceURL, anchor.sourceId);
+        if (!sourceFile)
+            return;
+
+        function didGetUILocation(sourceFileId, lineNumber)
+        {
+            anchor.updateHandler(sourceFile.url, lineNumber);
+        }
+        this.scriptLocationToUILocation(anchor.sourceURL, anchor.sourceId, anchor.lineNumber, anchor.columnNumber, didGetUILocation);
+    },
+
     _parsedScriptSource: function(event)
     {
         this._addScript(event.data);
@@ -246,6 +267,9 @@
         for (var i = 0; i < messages.length; ++i)
             this._addConsoleMessage(messages[i]);
 
+        for (var i = 0; i < this._anchors.length; ++i)
+            this._updateAnchor(this._anchors[i]);
+
         if (WebInspector.debuggerModel.callFrames)
             this._debuggerPaused();
     },
@@ -615,6 +639,7 @@
     _debuggerReset: function()
     {
         this._reset();
+        this._anchors = [];
         this._presentationCallFrames = [];
         this._selectedCallFrameIndex = 0;
     }

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


--- trunk/Source/WebCore/inspector/front-end/NetworkPanel.js	2011-06-15 14:21:50 UTC (rev 88926)
+++ trunk/Source/WebCore/inspector/front-end/NetworkPanel.js	2011-06-15 14:30:22 UTC (rev 88927)
@@ -803,10 +803,10 @@
 
     showAnchorLocation: function(anchor)
     {
-        this._showResource(this._resourcesByURL[anchor.href], anchor.getAttribute("line_number") - 1);
+        this._showResource(this._resourcesByURL[anchor.href]);
     },
 
-    _showResource: function(resource, line)
+    _showResource: function(resource)
     {
         if (!resource)
             return;

Modified: trunk/Source/WebCore/inspector/front-end/Panel.js (88926 => 88927)


--- trunk/Source/WebCore/inspector/front-end/Panel.js	2011-06-15 14:21:50 UTC (rev 88926)
+++ trunk/Source/WebCore/inspector/front-end/Panel.js	2011-06-15 14:30:22 UTC (rev 88927)
@@ -388,6 +388,23 @@
             visibleView.resize();
     },
 
+    createAnchor: function(url, lineNumber, classes, tooltipText)
+    {
+        var linkText = this.formatAnchorText(url, lineNumber);
+        var anchor = WebInspector.linkifyURLAsNode(url, linkText, classes, false, tooltipText);
+        if (lineNumber !== undefined)
+            anchor.setAttribute("line_number", lineNumber);
+        return anchor;
+    },
+
+    formatAnchorText: function(url, lineNumber)
+    {
+        var text = WebInspector.displayNameForURL(url);
+        if (lineNumber !== undefined)
+            text += ":" + (lineNumber + 1);
+        return text;
+    },
+
     canShowAnchorLocation: function(anchor)
     {
         return false;

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


--- trunk/Source/WebCore/inspector/front-end/ResourcesPanel.js	2011-06-15 14:21:50 UTC (rev 88926)
+++ trunk/Source/WebCore/inspector/front-end/ResourcesPanel.js	2011-06-15 14:30:22 UTC (rev 88927)
@@ -350,8 +350,8 @@
             }
             return;
         }
-        var lineNumber = parseInt(anchor.getAttribute("line_number"));
-        this.showResource(resource, lineNumber !== NaN ? lineNumber - 1 : undefined);
+        var lineNumber = anchor.hasAttribute("line_number") ? parseInt(anchor.getAttribute("line_number")) : undefined;
+        this.showResource(resource, lineNumber);
     },
 
     showResource: function(resource, line)

Modified: trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js (88926 => 88927)


--- trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js	2011-06-15 14:21:50 UTC (rev 88926)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js	2011-06-15 14:30:22 UTC (rev 88927)
@@ -521,6 +521,19 @@
             x.show(this.viewsContainerElement);
     },
 
+    createAnchor: function(url, lineNumber, classes, tooltipText)
+    {
+        var anchor = WebInspector.Panel.prototype.createAnchor.call(this, url, lineNumber, classes, tooltipText);
+        if (lineNumber !== undefined) {
+            function updateAnchor(url, lineNumber)
+            {
+                anchor.textContent = this.formatAnchorText(url, lineNumber)
+            }
+            this._presentationModel.registerAnchor(url, null, lineNumber, 0, updateAnchor.bind(this));
+        }
+        return anchor;
+    },
+
     canShowAnchorLocation: function(anchor)
     {
         return this._debuggerEnabled && this._presentationModel.sourceFileForScriptURL(anchor.href);
@@ -528,18 +541,16 @@
 
     showAnchorLocation: function(anchor)
     {
-        var anchorLineNumber = parseInt(anchor.getAttribute("line_number"));
-        var hasAnchorLineNumber = anchorLineNumber !== NaN;
-        var lineNumber = hasAnchorLineNumber ? anchorLineNumber - 1 : 0;
+        var anchorLineNumber = anchor.hasAttribute("line_number") ? parseInt(anchor.getAttribute("line_number")) : 0;
 
         function didGetUILocation(sourceFileId, lineNumber)
         {
-            if (hasAnchorLineNumber)
+            if (anchor.hasAttribute("line_number"))
                 this._showSourceLine(sourceFileId, lineNumber);
             else
                 this._showSourceFrameAndAddToHistory(sourceFileId);
         }
-        this._presentationModel.scriptLocationToUILocation(anchor.href, null, lineNumber, 0, didGetUILocation.bind(this));
+        this._presentationModel.scriptLocationToUILocation(anchor.href, null, anchorLineNumber, 0, didGetUILocation.bind(this));
     },
 
     _showSourceLine: function(sourceFileId, lineNumber)

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


--- trunk/Source/WebCore/inspector/front-end/inspector.js	2011-06-15 14:21:50 UTC (rev 88926)
+++ trunk/Source/WebCore/inspector/front-end/inspector.js	2011-06-15 14:30:22 UTC (rev 88927)
@@ -1172,7 +1172,7 @@
 
 WebInspector._showAnchorLocation = function(anchor)
 {
-    var preferedPanel = this.panels[anchor.getAttribute("preferred_panel") || "scripts"];
+    var preferedPanel = this.panels[anchor.getAttribute("preferred_panel")];
     if (WebInspector._showAnchorLocationInPanel(anchor, preferedPanel))
         return true;
     if (preferedPanel !== this.panels.resources && WebInspector._showAnchorLocationInPanel(anchor, this.panels.resources))
@@ -1275,13 +1275,12 @@
     return WebInspector.linkifyURLAsNode(url, linkText, classes, isExternal, tooltipText).outerHTML;
 }
 
-WebInspector.linkifyResourceAsNode = function(url, preferredPanel, lineNumber, classes, tooltipText)
+WebInspector.linkifyResourceAsNode = function(url, preferredPanel, oneBasedLineNumber, classes, tooltipText)
 {
-    var linkText = WebInspector.displayNameForURL(url);
-    if (lineNumber)
-        linkText += ":" + lineNumber;
-    var node = WebInspector.linkifyURLAsNode(url, linkText, classes, false, tooltipText);
-    node.setAttribute("line_number", lineNumber);
+    preferredPanel = preferredPanel || "scripts";
+    // FIXME(62725): stack trace line/column numbers are one-based.
+    var lineNumber = oneBasedLineNumber ? oneBasedLineNumber - 1 : undefined;
+    var node = this.panels[preferredPanel].createAnchor(url, lineNumber, classes, tooltipText);
     node.setAttribute("preferred_panel", preferredPanel);
     return node;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to