Changeset 88927 in webkit


Ignore:
Timestamp:
Jun 15, 2011 7:30:22 AM (13 years ago)
Author:
podivilov@chromium.org
Message:

2011-06-15 Pavel Podivilov <podivilov@chromium.org>

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 <podivilov@chromium.org>

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):
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r88924 r88927  
     12011-06-15  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: script links are displayed with original line number in pretty-print mode.
     6        https://bugs.webkit.org/show_bug.cgi?id=62282
     7
     8        * inspector/debugger/script-formatter-expected.txt:
     9        * inspector/debugger/script-formatter.html:
     10
    1112011-06-15  Kent Tamura  <tkent@chromium.org>
    212
  • trunk/LayoutTests/inspector/debugger/script-formatter-expected.txt

    r85321 r88927  
     1CONSOLE MESSAGE: line 24: Test message.
    12Tests the script formatting functionality.
    23
     
    3132    1)  (script-formatter.html:1)
    3233Script execution resumed.
     34
     35Running: testConsoleMessagesForFormattedScripts
     36script-formatter.html:24
     37script-formatter.html:32
    3338Debugger was disabled.
    3439
  • trunk/LayoutTests/inspector/debugger/script-formatter.html

    r87071 r88927  
    1818    var x = 0;
    1919    return 0;
     20}
     21
     22function f3()
     23{
     24    console.log("Test message.");
    2025}
    2126
     
    152157                // There should be no breakpoint in f1 since script is pretty-printed now.
    153158                InspectorTest.evaluateInPageWithTimeout("f1()");
    154 
    155159                InspectorTest.setBreakpoint(panel.visibleView, 24, "", true);
    156160                InspectorTest.waitUntilPaused(pausedInF2);
     
    161165            {
    162166                InspectorTest.captureStackTrace(callFrames);
     167                panel._toggleFormatSourceFiles();
     168                InspectorTest.resumeExecution(next);
     169            }
     170        },
     171
     172        function testConsoleMessagesForFormattedScripts(next)
     173        {
     174            function dumpConsoleMessageURLs()
     175            {
     176                var messages = WebInspector.console.messages;
     177                for (var i = 0; i < messages.length; ++i) {
     178                    var element = messages[i].toMessageElement();
     179                    var anchor = element.query("//*//a[contains(@class, 'console-message-url')]");
     180                    InspectorTest.addResult(anchor.textContent);
     181                }
     182            }
     183            InspectorTest.evaluateInPage("f3()", didEvaluate);
     184
     185            function didEvaluate()
     186            {
     187                dumpConsoleMessageURLs();
     188                InspectorTest.addSniffer(panel, "formatAnchorText", InspectorTest.runAfterPendingDispatches.bind(InspectorTest, didFormatAnchorText));
     189                panel._toggleFormatSourceFiles();
     190            }
     191
     192            function didFormatAnchorText()
     193            {
     194                dumpConsoleMessageURLs();
    163195                next();
    164196            }
  • trunk/Source/WebCore/ChangeLog

    r88925 r88927  
     12011-06-15  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: script links are displayed with original line number in pretty-print mode.
     6        https://bugs.webkit.org/show_bug.cgi?id=62282
     7
     8        * inspector/front-end/DebuggerPresentationModel.js:
     9        (WebInspector.DebuggerPresentationModel):
     10        (WebInspector.DebuggerPresentationModel.prototype.registerAnchor):
     11        (WebInspector.DebuggerPresentationModel.prototype._updateAnchor.didGetUILocation):
     12        (WebInspector.DebuggerPresentationModel.prototype._updateAnchor):
     13        (WebInspector.DebuggerPresentationModel.prototype.setFormatSourceFiles):
     14        (WebInspector.DebuggerPresentationModel.prototype._debuggerReset):
     15        * inspector/front-end/NetworkPanel.js:
     16        (WebInspector.NetworkPanel.prototype.showAnchorLocation):
     17        (WebInspector.NetworkPanel.prototype._showResource):
     18        * inspector/front-end/Panel.js:
     19        (WebInspector.Panel.prototype.createAnchor):
     20        (WebInspector.Panel.prototype.formatAnchorText):
     21        * inspector/front-end/ResourcesPanel.js:
     22        (WebInspector.ResourcesPanel.prototype.showAnchorLocation):
     23        * inspector/front-end/ScriptsPanel.js:
     24        (WebInspector.ScriptsPanel.prototype.createAnchor.):
     25        (WebInspector.ScriptsPanel.prototype.createAnchor):
     26        (WebInspector.ScriptsPanel.prototype.showAnchorLocation.didGetUILocation):
     27        (WebInspector.ScriptsPanel.prototype.showAnchorLocation):
     28        * inspector/front-end/inspector.js:
     29        (WebInspector._showAnchorLocation):
     30        (WebInspector.linkifyResourceAsNode):
     31
    1322011-06-14  Hans Wennborg  <hans@chromium.org>
    233
  • trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js

    r88344 r88927  
    3333    this._sourceFiles = {};
    3434    this._messages = [];
     35    this._anchors = [];
    3536    this._breakpointsByDebuggerId = {};
    3637    this._breakpointsWithoutSourceFile = {};
     
    100101    {
    101102        this._sourceFiles[sourceFileId].requestContent(callback);
     103    },
     104
     105    registerAnchor: function(sourceURL, sourceId, lineNumber, columnNumber, updateHandler)
     106    {
     107        var anchor = { sourceURL: sourceURL, sourceId: sourceId, lineNumber: lineNumber, columnNumber: columnNumber, updateHandler: updateHandler };
     108        this._anchors.push(anchor);
     109        this._updateAnchor(anchor);
     110    },
     111
     112    _updateAnchor: function(anchor)
     113    {
     114        var sourceFile = this._sourceFileForScript(anchor.sourceURL, anchor.sourceId);
     115        if (!sourceFile)
     116            return;
     117
     118        function didGetUILocation(sourceFileId, lineNumber)
     119        {
     120            anchor.updateHandler(sourceFile.url, lineNumber);
     121        }
     122        this.scriptLocationToUILocation(anchor.sourceURL, anchor.sourceId, anchor.lineNumber, anchor.columnNumber, didGetUILocation);
    102123    },
    103124
     
    247268            this._addConsoleMessage(messages[i]);
    248269
     270        for (var i = 0; i < this._anchors.length; ++i)
     271            this._updateAnchor(this._anchors[i]);
     272
    249273        if (WebInspector.debuggerModel.callFrames)
    250274            this._debuggerPaused();
     
    616640    {
    617641        this._reset();
     642        this._anchors = [];
    618643        this._presentationCallFrames = [];
    619644        this._selectedCallFrameIndex = 0;
  • trunk/Source/WebCore/inspector/front-end/NetworkPanel.js

    r88705 r88927  
    804804    showAnchorLocation: function(anchor)
    805805    {
    806         this._showResource(this._resourcesByURL[anchor.href], anchor.getAttribute("line_number") - 1);
    807     },
    808 
    809     _showResource: function(resource, line)
     806        this._showResource(this._resourcesByURL[anchor.href]);
     807    },
     808
     809    _showResource: function(resource)
    810810    {
    811811        if (!resource)
  • trunk/Source/WebCore/inspector/front-end/Panel.js

    r88805 r88927  
    389389    },
    390390
     391    createAnchor: function(url, lineNumber, classes, tooltipText)
     392    {
     393        var linkText = this.formatAnchorText(url, lineNumber);
     394        var anchor = WebInspector.linkifyURLAsNode(url, linkText, classes, false, tooltipText);
     395        if (lineNumber !== undefined)
     396            anchor.setAttribute("line_number", lineNumber);
     397        return anchor;
     398    },
     399
     400    formatAnchorText: function(url, lineNumber)
     401    {
     402        var text = WebInspector.displayNameForURL(url);
     403        if (lineNumber !== undefined)
     404            text += ":" + (lineNumber + 1);
     405        return text;
     406    },
     407
    391408    canShowAnchorLocation: function(anchor)
    392409    {
  • trunk/Source/WebCore/inspector/front-end/ResourcesPanel.js

    r87681 r88927  
    351351            return;
    352352        }
    353         var lineNumber = parseInt(anchor.getAttribute("line_number"));
    354         this.showResource(resource, lineNumber !== NaN ? lineNumber - 1 : undefined);
     353        var lineNumber = anchor.hasAttribute("line_number") ? parseInt(anchor.getAttribute("line_number")) : undefined;
     354        this.showResource(resource, lineNumber);
    355355    },
    356356
  • trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js

    r88916 r88927  
    522522    },
    523523
     524    createAnchor: function(url, lineNumber, classes, tooltipText)
     525    {
     526        var anchor = WebInspector.Panel.prototype.createAnchor.call(this, url, lineNumber, classes, tooltipText);
     527        if (lineNumber !== undefined) {
     528            function updateAnchor(url, lineNumber)
     529            {
     530                anchor.textContent = this.formatAnchorText(url, lineNumber)
     531            }
     532            this._presentationModel.registerAnchor(url, null, lineNumber, 0, updateAnchor.bind(this));
     533        }
     534        return anchor;
     535    },
     536
    524537    canShowAnchorLocation: function(anchor)
    525538    {
     
    529542    showAnchorLocation: function(anchor)
    530543    {
    531         var anchorLineNumber = parseInt(anchor.getAttribute("line_number"));
    532         var hasAnchorLineNumber = anchorLineNumber !== NaN;
    533         var lineNumber = hasAnchorLineNumber ? anchorLineNumber - 1 : 0;
     544        var anchorLineNumber = anchor.hasAttribute("line_number") ? parseInt(anchor.getAttribute("line_number")) : 0;
    534545
    535546        function didGetUILocation(sourceFileId, lineNumber)
    536547        {
    537             if (hasAnchorLineNumber)
     548            if (anchor.hasAttribute("line_number"))
    538549                this._showSourceLine(sourceFileId, lineNumber);
    539550            else
    540551                this._showSourceFrameAndAddToHistory(sourceFileId);
    541552        }
    542         this._presentationModel.scriptLocationToUILocation(anchor.href, null, lineNumber, 0, didGetUILocation.bind(this));
     553        this._presentationModel.scriptLocationToUILocation(anchor.href, null, anchorLineNumber, 0, didGetUILocation.bind(this));
    543554    },
    544555
  • trunk/Source/WebCore/inspector/front-end/inspector.js

    r88920 r88927  
    11731173WebInspector._showAnchorLocation = function(anchor)
    11741174{
    1175     var preferedPanel = this.panels[anchor.getAttribute("preferred_panel") || "scripts"];
     1175    var preferedPanel = this.panels[anchor.getAttribute("preferred_panel")];
    11761176    if (WebInspector._showAnchorLocationInPanel(anchor, preferedPanel))
    11771177        return true;
     
    12761276}
    12771277
    1278 WebInspector.linkifyResourceAsNode = function(url, preferredPanel, lineNumber, classes, tooltipText)
    1279 {
    1280     var linkText = WebInspector.displayNameForURL(url);
    1281     if (lineNumber)
    1282         linkText += ":" + lineNumber;
    1283     var node = WebInspector.linkifyURLAsNode(url, linkText, classes, false, tooltipText);
    1284     node.setAttribute("line_number", lineNumber);
     1278WebInspector.linkifyResourceAsNode = function(url, preferredPanel, oneBasedLineNumber, classes, tooltipText)
     1279{
     1280    preferredPanel = preferredPanel || "scripts";
     1281    // FIXME(62725): stack trace line/column numbers are one-based.
     1282    var lineNumber = oneBasedLineNumber ? oneBasedLineNumber - 1 : undefined;
     1283    var node = this.panels[preferredPanel].createAnchor(url, lineNumber, classes, tooltipText);
    12851284    node.setAttribute("preferred_panel", preferredPanel);
    12861285    return node;
Note: See TracChangeset for help on using the changeset viewer.