Changeset 75795 in webkit


Ignore:
Timestamp:
Jan 14, 2011 7:58:16 AM (13 years ago)
Author:
podivilov@chromium.org
Message:

2011-01-14 Pavel Podivilov <podivilov@chromium.org>

Reviewed by Yury Semikhatsky.

Web Inspector: breakpoint text snippet in breakpoints sidebar pane disappears after reload.
https://bugs.webkit.org/show_bug.cgi?id=52215

  • inspector/front-end/Breakpoint.js: (WebInspector.Breakpoint): (WebInspector.Breakpoint.prototype.populateLabelElement):
  • inspector/front-end/Script.js: (WebInspector.Script.prototype.get linesCount): (WebInspector.Script.prototype.sourceLine): (WebInspector.Script.prototype.sourceLine.didRequestSource): (WebInspector.Script.prototype.set source): (WebInspector.Script.prototype.requestSource.didGetScriptSource): (WebInspector.Script.prototype.requestSource):
  • inspector/front-end/ScriptView.js: (WebInspector.ScriptView.prototype.setupSourceFrameIfNeeded.didRequestSource): (WebInspector.ScriptView.prototype.setupSourceFrameIfNeeded):
  • inspector/front-end/SourceFrame.js: (WebInspector.SourceFrame.prototype._addBreakpoint):
  • inspector/front-end/utilities.js: (String.prototype.findAll):
Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r75794 r75795  
     12011-01-14  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: breakpoint text snippet in breakpoints sidebar pane disappears after reload.
     6        https://bugs.webkit.org/show_bug.cgi?id=52215
     7
     8        * inspector/front-end/Breakpoint.js:
     9        (WebInspector.Breakpoint):
     10        (WebInspector.Breakpoint.prototype.populateLabelElement):
     11        * inspector/front-end/Script.js:
     12        (WebInspector.Script.prototype.get linesCount):
     13        (WebInspector.Script.prototype.sourceLine):
     14        (WebInspector.Script.prototype.sourceLine.didRequestSource):
     15        (WebInspector.Script.prototype.set source):
     16        (WebInspector.Script.prototype.requestSource.didGetScriptSource):
     17        (WebInspector.Script.prototype.requestSource):
     18        * inspector/front-end/ScriptView.js:
     19        (WebInspector.ScriptView.prototype.setupSourceFrameIfNeeded.didRequestSource):
     20        (WebInspector.ScriptView.prototype.setupSourceFrameIfNeeded):
     21        * inspector/front-end/SourceFrame.js:
     22        (WebInspector.SourceFrame.prototype._addBreakpoint):
     23        * inspector/front-end/utilities.js:
     24        (String.prototype.findAll):
     25
    1262011-01-14  Pavel Podivilov  <podivilov@chromium.org>
    227
  • trunk/Source/WebCore/inspector/front-end/Breakpoint.js

    r74798 r75795  
    3838    this._enabled = enabled;
    3939    this._condition = condition || "";
    40     this._sourceText = "";
    4140    this._hit = false;
    4241    this._debuggerModel = debuggerModel;
     
    5554        this.remove();
    5655        WebInspector.debuggerModel.setBreakpoint(this.sourceID, this.line, enabled, this.condition);
    57     },
    58 
    59     get sourceText()
    60     {
    61         return this._sourceText;
    62     },
    63 
    64     set sourceText(text)
    65     {
    66         this._sourceText = text;
    67         this.dispatchEventToListeners("label-changed");
    6856    },
    6957
     
    10088    populateLabelElement: function(element)
    10189    {
    102         var displayName = this.url ? WebInspector.displayNameForURL(this.url) : WebInspector.UIString("(program)");
    103         var labelElement = document.createTextNode(displayName + ":" + this.line);
    104         element.appendChild(labelElement);
     90        function didGetSourceLine(text)
     91        {
     92            var displayName = this.url ? WebInspector.displayNameForURL(this.url) : WebInspector.UIString("(program)");
     93            var labelElement = document.createTextNode(displayName + ":" + this.line);
     94            element.appendChild(labelElement);
    10595
    106         var sourceTextElement = document.createElement("div");
    107         sourceTextElement.textContent = this.sourceText;
    108         sourceTextElement.className = "source-text monospace";
    109         element.appendChild(sourceTextElement);
     96            var sourceTextElement = document.createElement("div");
     97            sourceTextElement.textContent = text;
     98            sourceTextElement.className = "source-text monospace";
     99            element.appendChild(sourceTextElement);
     100        }
     101        var script = this._debuggerModel.scriptForSourceID(this.sourceID);
     102        script.sourceLine(this.line, didGetSourceLine.bind(this));
    110103    },
    111104
  • trunk/Source/WebCore/inspector/front-end/Script.js

    r75794 r75795  
    6969        if (!this.source)
    7070            return 0;
    71         if (this._linesCount)
    72             return this._linesCount;
    73         this._linesCount = 0;
    74         var lastIndex = this.source.indexOf("\n");
    75         while (lastIndex !== -1) {
    76             lastIndex = this.source.indexOf("\n", lastIndex + 1)
    77             this._linesCount++;
     71        if (!this._lineEndings)
     72            this._lineEndings = this._source.findAll("\n");
     73        return this._lineEndings.length + 1;
     74    },
     75
     76    sourceLine: function(lineNumber, callback)
     77    {
     78        function extractSourceLine()
     79        {
     80            lineNumber -= this.startingLine;
     81            callback(this._source.substring(this._lineEndings[lineNumber - 1], this._lineEndings[lineNumber]));
    7882        }
    79         return this._linesCount;
     83
     84        if (this._lineEndings) {
     85            extractSourceLine.call(this);
     86            return;
     87        }
     88
     89        function didRequestSource()
     90        {
     91            this._lineEndings = this._source.findAll("\n");
     92            extractSourceLine.call(this);
     93        }
     94        this.requestSource(didRequestSource.bind(this));
    8095    },
    8196
     
    88103    {
    89104        this._source = source;
     105    },
     106
     107    requestSource: function(callback)
     108    {
     109        if (this._source) {
     110            callback(this._source);
     111            return;
     112        }
     113
     114        function didGetScriptSource(source)
     115        {
     116            this._source = source;
     117            callback(this._source);
     118        }
     119        InspectorBackend.getScriptSource(this.sourceID, didGetScriptSource.bind(this));
    90120    }
    91121}
  • trunk/Source/WebCore/inspector/front-end/ScriptView.js

    r75500 r75795  
    5454        this.attach();
    5555
    56         if (this.script.source)
    57             this._sourceFrameSetupFinished();
    58         else
    59             InspectorBackend.getScriptSource(this.script.sourceID, this._didGetScriptSource.bind(this));
    60     },
    61 
    62     _didGetScriptSource: function(source)
    63     {
    64         this.script.source = source || WebInspector.UIString("<source is not available>");
    65         this._sourceFrameSetupFinished();
    66     },
    67 
    68     _sourceFrameSetupFinished: function()
    69     {
    70         this.sourceFrame.setContent("text/javascript", this._prependWhitespace(this.script.source));
    71         this._sourceFrameSetup = true;
     56        function didRequestSource(source)
     57        {
     58            source = source || WebInspector.UIString("<source is not available>");
     59            this.sourceFrame.setContent("text/javascript", this._prependWhitespace(source));
     60            this._sourceFrameSetup = true;
     61        }
     62        this.script.requestSource(didRequestSource.bind(this));
    7263    },
    7364
  • trunk/Source/WebCore/inspector/front-end/SourceFrame.js

    r75601 r75795  
    433433        breakpoint.addEventListener("removed", this._breakpointRemoved, this);
    434434
    435         breakpoint.sourceText = this._textModel.line(breakpoint.line - 1);
    436435        this._setBreakpointDecoration(breakpoint.line, breakpoint.enabled, !!breakpoint.condition);
    437436    },
  • trunk/Source/WebCore/inspector/front-end/utilities.js

    r75739 r75795  
    387387        return this.indexOf(string) !== -1;
    388388    return this.match(new RegExp(string.escapeForRegExp(), "i"));
     389}
     390
     391String.prototype.findAll = function(string)
     392{
     393    var matches = [];
     394    var i = this.indexOf(string);
     395    while (i !== -1) {
     396        matches.push(i);
     397        i = this.indexOf(string, i + string.length);
     398    }
     399    return matches;
    389400}
    390401
Note: See TracChangeset for help on using the changeset viewer.