Changeset 53051 in webkit
- Timestamp:
- Jan 10, 2010 11:06:59 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r53050 r53051 1 2010-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 1 19 2010-01-10 Adam Barth <abarth@webkit.org> 2 20 -
trunk/WebCore/inspector/front-end/TextEditor.js
r52945 r53051 145 145 this._invalidateHighlight(newRange.startLine); 146 146 this._updateSize(newRange.startLine, Math.max(newRange.endLine, oldRange.endLine)); 147 if (oldRange.linesCount !== newRange.linesCount) 148 this._paintLineNumbers(); 147 149 this._paint(); 148 150 }, … … 151 153 _selectionChanged: function(oldRange, newRange) 152 154 { 155 if (oldRange.isEmpty() && newRange.isEmpty() && oldRange.startLine === newRange.startLine) { 156 // Nothing to repaint. 157 return; 158 } 153 159 this._invalidateLines(oldRange.startLine, oldRange.endLine + 1); 154 160 this._invalidateLines(newRange.startLine, newRange.endLine + 1); … … 198 204 { 199 205 this._invalidateLines(0, this._textModel.linesCount); 206 this._paintLineNumbers(); 200 207 this._paint(); 201 208 this._updateCursor(this._selection.endLine, this._selection.endColumn); … … 243 250 this._ctx.fillStyle = "rgb(255,255,0)"; 244 251 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); 246 253 setTimeout(this._paintLinesContinuation.bind(this, firstLine, lastLine), 100); 247 254 } else … … 250 257 251 258 _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 266 259 // Clip editor area. 267 260 this._ctx.save(); … … 269 262 this._ctx.rect(this._lineNumberOffset - 1, 0, this._canvas.width - this._lineNumberOffset + 1, this._canvas.height); 270 263 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); 271 273 272 274 if (this._selection.startLine === this._selection.endLine && firstLine <= this._selection.startLine && this._selection.startLine < lastLine) … … 310 312 } 311 313 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); 312 333 }, 313 334 … … 550 571 _updateCursor: function(line, column) 551 572 { 552 if (line > this._textModel.linesCount)573 if (line >= this._textModel.linesCount) 553 574 return; 554 575 var offset = this._columnToOffset(line, column); … … 623 644 e.preventDefault(); 624 645 e.clipboardData.clearData(); 625 e.clipboardData.setData(" text/plain", text);646 e.clipboardData.setData("Text", text); 626 647 }, 627 648
Note: See TracChangeset
for help on using the changeset viewer.