Changeset 80347 in webkit
- Timestamp:
- Mar 4, 2011 6:40:54 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r80346 r80347 1 2011-03-04 Andrey Adaikin <aandrey@google.com> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: [Text editor] Do bisect to find visible chunks 6 https://bugs.webkit.org/show_bug.cgi?id=55685 7 8 * inspector/front-end/TextViewer.js: 9 (WebInspector.TextEditorChunkedPanel.prototype._chunkNumberForLine): 10 (WebInspector.TextEditorChunkedPanel.prototype._findVisibleChunks): 11 (WebInspector.TextEditorChunkedPanel.prototype._repaintAll): 12 (WebInspector.TextEditorGutterChunk.prototype.get offsetTop): 13 (WebInspector.TextEditorMainPanel.prototype._updateHighlightsForRange): 14 (WebInspector.TextEditorMainChunk.prototype.get offsetTop): 15 1 16 2011-03-04 Andrey Adaikin <aandrey@google.com> 2 17 -
trunk/Source/WebCore/inspector/front-end/TextViewer.js
r80346 r80347 388 388 _chunkNumberForLine: function(lineNumber) 389 389 { 390 // Bisect. 391 var from = 0; 392 var to = this._textChunks.length - 1; 393 while (from < to) { 394 var mid = Math.floor((from + to + 1) / 2); 395 if (this._textChunks[mid].startLine <= lineNumber) 396 from = mid; 397 else 398 to = mid - 1; 399 } 400 return from; 390 function compareLineNumbers(value, chunk) 391 { 392 return value < chunk.startLine ? -1 : 1; 393 } 394 var insertBefore = insertionIndexForObjectInListSortedByFunction(lineNumber, this._textChunks, compareLineNumbers); 395 return insertBefore - 1; 401 396 }, 402 397 … … 404 399 { 405 400 return this._textChunks[this._chunkNumberForLine(lineNumber)]; 401 }, 402 403 _findVisibleChunks: function(visibleFrom, visibleTo) 404 { 405 function compareOffsetTops(value, chunk) 406 { 407 return value < chunk.offsetTop ? -1 : 1; 408 } 409 var insertBefore = insertionIndexForObjectInListSortedByFunction(visibleFrom, this._textChunks, compareOffsetTops); 410 411 var from = insertBefore - 1; 412 for (var to = from + 1; to < this._textChunks.length; ++to) { 413 if (this._textChunks[to].offsetTop >= visibleTo) 414 break; 415 } 416 return { start: from, end: to }; 406 417 }, 407 418 … … 419 430 var visibleTo = this.element.scrollTop + this.element.clientHeight; 420 431 421 var offset = 0; 422 var fromIndex = -1; 423 var toIndex = 0; 424 for (var i = 0; i < this._textChunks.length; ++i) { 425 var chunk = this._textChunks[i]; 426 var chunkHeight = chunk.height; 427 if (offset + chunkHeight > visibleFrom && offset < visibleTo) { 428 if (fromIndex === -1) 429 fromIndex = i; 430 toIndex = i + 1; 431 } else { 432 if (offset >= visibleTo) 433 break; 434 } 435 offset += chunkHeight; 436 } 437 438 if (toIndex) 439 this._expandChunks(fromIndex, toIndex); 432 if (visibleTo) { 433 var result = this._findVisibleChunks(visibleFrom, visibleTo); 434 this._expandChunks(result.start, result.end); 435 } 440 436 }, 441 437 … … 651 647 return this._textViewer._totalHeight(this.element); 652 648 return this._textViewer._totalHeight(this._expandedLineRows[0], this._expandedLineRows[this._expandedLineRows.length - 1]); 649 }, 650 651 get offsetTop() 652 { 653 return this._expandedLineRows ? this._expandedLineRows[0].offsetTop : this.element.offsetTop; 653 654 }, 654 655 … … 1342 1343 var visibleTo = this.element.scrollTop + this.element.clientHeight; 1343 1344 1344 var offset = 0; 1345 var lastVisibleLine = 0; 1346 for (var i = 0; i < this._textChunks.length; ++i) { 1347 var chunk = this._textChunks[i]; 1348 var chunkHeight = chunk.height; 1349 if (offset + chunkHeight > visibleFrom && offset < visibleTo) 1350 lastVisibleLine = chunk.startLine + chunk.linesCount; 1351 else if (offset >= visibleTo) 1352 break; 1353 offset += chunkHeight; 1354 } 1345 var result = this._findVisibleChunks(visibleFrom, visibleTo); 1346 var chunk = this._textChunks[result.end - 1]; 1347 var lastVisibleLine = chunk.startLine + chunk.linesCount; 1355 1348 1356 1349 lastVisibleLine = Math.max(lastVisibleLine, range.endLine); … … 1528 1521 }, 1529 1522 1523 get offsetTop() 1524 { 1525 return this._expandedLineRows ? this._expandedLineRows[0].offsetTop : this.element.offsetTop; 1526 }, 1527 1530 1528 _createRow: function(lineNumber) 1531 1529 {
Note: See TracChangeset
for help on using the changeset viewer.