Changeset 53051 in webkit


Ignore:
Timestamp:
Jan 10, 2010 11:06:59 AM (14 years ago)
Author:
pfeldman@chromium.org
Message:

2010-01-10 Pavel Feldman <pfeldman@chromium.org>

Reviewed by Timothy Hatcher.

Web Inspector: Do not repaint line numbers while editing within line.

https://bugs.webkit.org/show_bug.cgi?id=33427

Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r53050 r53051  
     12010-01-10  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Reviewed by Timothy Hatcher.
     4
     5        Web Inspector: Do not repaint line numbers while editing within line.
     6
     7        https://bugs.webkit.org/show_bug.cgi?id=33427
     8
     9        * inspector/front-end/TextEditor.js:
     10        (WebInspector.TextEditor.prototype._textChanged):
     11        (WebInspector.TextEditor.prototype._selectionChanged):
     12        (WebInspector.TextEditor.prototype._repaintAll):
     13        (WebInspector.TextEditor.prototype._paintLines):
     14        (WebInspector.TextEditor.prototype._paintLinesContinuation):
     15        (WebInspector.TextEditor.prototype._paintLineNumbers):
     16        (WebInspector.TextEditor.prototype._updateCursor):
     17        (WebInspector.TextEditor.prototype._copy):
     18
    1192010-01-10  Adam Barth  <abarth@webkit.org>
    220
  • trunk/WebCore/inspector/front-end/TextEditor.js

    r52945 r53051  
    145145        this._invalidateHighlight(newRange.startLine);
    146146        this._updateSize(newRange.startLine, Math.max(newRange.endLine, oldRange.endLine));
     147        if (oldRange.linesCount !== newRange.linesCount)
     148            this._paintLineNumbers();
    147149        this._paint();
    148150    },
     
    151153    _selectionChanged: function(oldRange, newRange)
    152154    {
     155        if (oldRange.isEmpty() && newRange.isEmpty() && oldRange.startLine === newRange.startLine) {
     156            // Nothing to repaint.
     157            return;
     158        }
    153159        this._invalidateLines(oldRange.startLine, oldRange.endLine + 1);
    154160        this._invalidateLines(newRange.startLine, newRange.endLine + 1);
     
    198204    {
    199205        this._invalidateLines(0, this._textModel.linesCount);
     206        this._paintLineNumbers();
    200207        this._paint();
    201208        this._updateCursor(this._selection.endLine, this._selection.endColumn);
     
    243250            this._ctx.fillStyle = "rgb(255,255,0)";
    244251            var height = (lastLine - firstLine) * this._lineHeight;
    245             this._ctx.fillRect(0, this._lineHeight * firstLine - this._scrollTop, this._canvas.width, height);
     252            this._ctx.fillRect(this._lineNumberOffset - 1, this._lineHeight * firstLine - this._scrollTop, this._canvas.width - this._lineNumberOffset + 1, height);
    246253            setTimeout(this._paintLinesContinuation.bind(this, firstLine, lastLine), 100);
    247254        } else
     
    250257
    251258    _paintLinesContinuation: function(firstLine, lastLine) {
    252         // Clear all.
    253         var height = (lastLine - firstLine) * this._lineHeight;
    254         this._ctx.fillStyle = "rgb(255,255,255)";
    255         this._ctx.fillRect(0, this._lineHeight * firstLine - this._scrollTop, this._canvas.width, height);
    256 
    257         lastLine = Math.min(lastLine, this._textModel.linesCount);
    258 
    259         // Paint line numbers and separator.
    260         this._ctx.fillStyle = "rgb(235,235,235)";
    261         this._ctx.fillRect(this._lineNumberOffset - 2, 0, 1, this._canvas.width);
    262         this._ctx.fillStyle = "rgb(155,155,155)";
    263         for (var i = firstLine; i < lastLine; ++i)
    264            this._ctx.fillText(i + 1, (this._lineNumberDigits - this._decimalDigits(i + 1) + 1) * this._digitWidth, this._lineHeight * (i + 1) - this._scrollTop);
    265 
    266259        // Clip editor area.
    267260        this._ctx.save();
     
    269262        this._ctx.rect(this._lineNumberOffset - 1, 0, this._canvas.width - this._lineNumberOffset + 1, this._canvas.height);
    270263        this._ctx.clip();
     264
     265        // First clear the region, then update last line to fit model (this clears removed lines from the end of the document).
     266        var height = (lastLine - firstLine) * this._lineHeight;
     267        // Do not clear region when paintCurrentLine is likely to do all the necessary work.
     268        if (firstLine + 1 != lastLine || this._selection.endLine != firstLine) {
     269            this._ctx.fillStyle = "rgb(255,255,255)";
     270            this._ctx.fillRect(0, this._lineHeight * firstLine - this._scrollTop, this._canvas.width, height);
     271        }
     272        lastLine = Math.min(lastLine, this._textModel.linesCount);
    271273
    272274        if (this._selection.startLine === this._selection.endLine && firstLine <= this._selection.startLine && this._selection.startLine < lastLine)
     
    310312        }
    311313        this._ctx.restore();
     314    },
     315
     316    _paintLineNumbers: function()
     317    {
     318        this._ctx.font = this._font;
     319        this._ctx.textBaseline = "bottom";
     320
     321        this._ctx.fillStyle = "rgb(255,255,255)";
     322        this._ctx.fillRect(0, 0, this._lineNumberOffset - 3, this._canvas.height);
     323
     324        this._ctx.fillStyle = "rgb(235,235,235)";
     325        this._ctx.fillRect(this._lineNumberOffset - 2, 0, 1, this._canvas.height);
     326
     327        var firstLine = Math.min(this._textModel.linesCount, Math.floor(this._scrollTop / this._lineHeight) - 1);
     328        var lastLine = Math.min(this._textModel.linesCount, Math.ceil((this._scrollTop + this._canvas.height) / this._lineHeight) + 1);
     329
     330        this._ctx.fillStyle = "rgb(155,155,155)";
     331        for (var i = firstLine; i < lastLine; ++i)
     332           this._ctx.fillText(i + 1, (this._lineNumberDigits - this._decimalDigits(i + 1) + 1) * this._digitWidth, this._lineHeight * (i + 1) - this._scrollTop);
    312333    },
    313334
     
    550571    _updateCursor: function(line, column)
    551572    {
    552         if (line > this._textModel.linesCount)
     573        if (line >= this._textModel.linesCount)
    553574            return;
    554575        var offset = this._columnToOffset(line, column);
     
    623644        e.preventDefault();
    624645        e.clipboardData.clearData();
    625         e.clipboardData.setData("text/plain", text);
     646        e.clipboardData.setData("Text", text);
    626647    },
    627648
Note: See TracChangeset for help on using the changeset viewer.