Changeset 55352 in webkit
- Timestamp:
- Feb 27, 2010 2:48:18 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r55351 r55352 1 2010-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 1 15 2010-02-27 Xan Lopez <xlopez@igalia.com> 2 16 -
trunk/WebCore/inspector/front-end/TextEditorHighlighter.js
r55248 r55352 36 36 this._damageCallback = damageCallback; 37 37 this._lastHighlightedLine = 0; 38 this._lastHighlightedColumn = 0; 38 39 } 39 40 … … 62 63 63 64 // 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); 66 66 67 67 // 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); 70 70 }, 71 71 72 _highlightInChunks: function( startLine,endLine)72 _highlightInChunks: function(endLine) 73 73 { 74 74 delete this._highlightTimer; … … 80 80 if (this._requestedEndLine !== endLine) { 81 81 // 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); 83 83 return; 84 84 } 85 85 86 // Highlight 500 lines chunk. 87 var toLine = Math.min(startLine + 500, this._requestedEndLine); 88 this._highlightLines(startLine, toLine); 86 this._highlightLines(this._requestedEndLine); 89 87 90 88 // Schedule tail highlight if necessary. 91 if (t oLine < this._requestedEndLine)92 this._highlightTimer = setTimeout(this._highlightInChunks.bind(this, t oLine, this._requestedEndLine), 10);89 if (this._lastHighlightedLine < this._requestedEndLine) 90 this._highlightTimer = setTimeout(this._highlightInChunks.bind(this, this._requestedEndLine), 10); 93 91 }, 94 92 95 _highlightLines: function( startLine,endLine)93 _highlightLines: function(endLine) 96 94 { 97 95 // Tokenizer is stateless and reused accross viewers, restore its condition before highlight and save it after. 98 96 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); 102 123 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; 120 125 } 121 126 }
Note: See TracChangeset
for help on using the changeset viewer.