Changeset 55352 in webkit


Ignore:
Timestamp:
Feb 27, 2010 2:48:18 AM (14 years ago)
Author:
pfeldman@chromium.org
Message:

2010-02-27 Pavel Feldman <pfeldman@chromium.org>

Reviewed by Timothy Hatcher.

Web Inspector: REGRESSION: hangs when scrolling in Resource pane.

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

  • inspector/front-end/TextEditorHighlighter.js: (WebInspector.TextEditorHighlighter): (WebInspector.TextEditorHighlighter.prototype.highlight): (WebInspector.TextEditorHighlighter.prototype._highlightInChunks): (WebInspector.TextEditorHighlighter.prototype._highlightLines):
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r55351 r55352  
     12010-02-27  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Reviewed by Timothy Hatcher.
     4
     5        Web Inspector: REGRESSION: hangs when scrolling in Resource pane.
     6
     7        https://bugs.webkit.org/show_bug.cgi?id=35216
     8
     9        * inspector/front-end/TextEditorHighlighter.js:
     10        (WebInspector.TextEditorHighlighter):
     11        (WebInspector.TextEditorHighlighter.prototype.highlight):
     12        (WebInspector.TextEditorHighlighter.prototype._highlightInChunks):
     13        (WebInspector.TextEditorHighlighter.prototype._highlightLines):
     14
    1152010-02-27  Xan Lopez  <xlopez@igalia.com>
    216
  • trunk/WebCore/inspector/front-end/TextEditorHighlighter.js

    r55248 r55352  
    3636    this._damageCallback = damageCallback;
    3737    this._lastHighlightedLine = 0;
     38    this._lastHighlightedColumn = 0;
    3839}
    3940
     
    6263
    6364        // Do small highlight synchronously. This will provide instant highlight on PageUp / PageDown, gentle scrolling.
    64         var toLine = Math.min(this._lastHighlightedLine + 200, endLine);
    65         this._highlightInChunks(this._lastHighlightedLine, toLine);
     65        this._highlightInChunks(endLine);
    6666
    6767        // Schedule tail highlight if necessary.
    68         if (endLine > toLine)
    69             this._highlightTimer = setTimeout(this._highlightInChunks.bind(this, toLine, endLine), 100);
     68        if (this._lastHighlightedLine < endLine)
     69            this._highlightTimer = setTimeout(this._highlightInChunks.bind(this, endLine), 100);
    7070    },
    7171
    72     _highlightInChunks: function(startLine, endLine)
     72    _highlightInChunks: function(endLine)
    7373    {
    7474        delete this._highlightTimer;
     
    8080        if (this._requestedEndLine !== endLine) {
    8181            // User keeps updating the job in between of our timer ticks. Just reschedule self, don't eat CPU (they must be scrolling).
    82             this._highlightTimer = setTimeout(this._highlightInChunks.bind(this, startLine, this._requestedEndLine), 100);
     82            this._highlightTimer = setTimeout(this._highlightInChunks.bind(this, this._requestedEndLine), 100);
    8383            return;
    8484        }
    8585
    86         // Highlight 500 lines chunk.
    87         var toLine = Math.min(startLine + 500, this._requestedEndLine);
    88         this._highlightLines(startLine, toLine);
     86        this._highlightLines(this._requestedEndLine);
    8987
    9088        // Schedule tail highlight if necessary.
    91         if (toLine < this._requestedEndLine)
    92             this._highlightTimer = setTimeout(this._highlightInChunks.bind(this, toLine, this._requestedEndLine), 10);
     89        if (this._lastHighlightedLine < this._requestedEndLine)
     90            this._highlightTimer = setTimeout(this._highlightInChunks.bind(this, this._requestedEndLine), 10);
    9391    },
    9492
    95     _highlightLines: function(startLine, endLine)
     93    _highlightLines: function(endLine)
    9694    {
    9795        // Tokenizer is stateless and reused accross viewers, restore its condition before highlight and save it after.
    9896        this._tokenizer.condition = this._tokenizerCondition;
    99         for (var i = startLine; i < endLine; ++i)
    100             this._highlightLine(i);
    101         this._lastHighlightedLine = endLine;
     97        var tokensCount = 0;
     98        for (var lineNumber = this._lastHighlightedLine; lineNumber < endLine; ++lineNumber) {
     99            var line = this._textModel.line(lineNumber);
     100            this._tokenizer.line = line;
     101            var attributes = this._textModel.getAttribute(lineNumber, "highlight") || {};
     102
     103            // Highlight line.
     104            do {
     105                var newColumn = this._tokenizer.nextToken(this._lastHighlightedColumn);
     106                var tokenType = this._tokenizer.tokenType;
     107                if (tokenType)
     108                    attributes[this._lastHighlightedColumn] = { length: newColumn - this._lastHighlightedColumn, tokenType: tokenType, subTokenizer: this._tokenizer.subTokenizer };
     109                this._lastHighlightedColumn = newColumn;
     110                if (++tokensCount > 1000)
     111                    break;
     112            } while (this._lastHighlightedColumn < line.length)
     113
     114            this._textModel.setAttribute(lineNumber, "highlight", attributes);
     115            if (this._lastHighlightedColumn < line.length) {
     116                // Too much work for single chunk - exit.
     117                break;
     118            } else
     119                this._lastHighlightedColumn = 0;
     120        }
     121
     122        this._damageCallback(this._lastHighlightedLine, lineNumber);
    102123        this._tokenizerCondition = this._tokenizer.condition;
    103 
    104         this._damageCallback(startLine, endLine);
    105     },
    106 
    107     _highlightLine: function(lineNumber) {
    108         var line = this._textModel.line(lineNumber);
    109         var attributes = {};
    110         this._tokenizer.line = line;
    111         var column = 0;
    112         do {
    113             var newColumn = this._tokenizer.nextToken(column);
    114             var tokenType = this._tokenizer.tokenType;
    115             if (tokenType)
    116                 attributes[column] = { length: newColumn - column, tokenType: tokenType, subTokenizer: this._tokenizer.subTokenizer };
    117             column = newColumn;
    118         } while (column < line.length)
    119         this._textModel.setAttribute(lineNumber, "highlight", attributes);
     124        this._lastHighlightedLine = lineNumber;
    120125    }
    121126}
Note: See TracChangeset for help on using the changeset viewer.