Changeset 141244 in webkit
- Timestamp:
- Jan 30, 2013 3:49:40 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r141243 r141244 1 2013-01-30 Andrey Lushnikov <lushnikov@chromium.org> 2 3 Web Inspector: do not repaint all lines in highlight regex API in DTE 4 https://bugs.webkit.org/show_bug.cgi?id=108081 5 6 Reviewed by Pavel Feldman. 7 8 Modify layout test to add a verification that highlight does not 9 repaint more DefaultTextEditor line rows than it needs to. 10 11 * inspector/editor/text-editor-highlight-regexp-expected.txt: 12 * inspector/editor/text-editor-highlight-regexp.html: 13 1 14 2013-01-30 Tien-Ren Chen <trchen@chromium.org> 2 15 -
trunk/LayoutTests/inspector/editor/text-editor-highlight-regexp-expected.txt
r140556 r141244 15 15 16 16 Add highlight for regexp /foo_./ 17 Lines repainted: 2 17 18 18 19 <div class="inner-container" tabindex="0"> … … 25 26 26 27 Remove highlight for regexp /foo_./ 28 Lines repainted: 2 27 29 28 30 <div class="inner-container" tabindex="0"> -
trunk/LayoutTests/inspector/editor/text-editor-highlight-regexp.html
r141111 r141244 20 20 var textEditor = InspectorTest.createTestEditor(); 21 21 textEditor.setText(text.join("\n")); 22 var paintLineCalls = 0; 23 function paintLineCounter() 24 { 25 ++paintLineCalls; 26 } 27 InspectorTest.addSniffer(textEditor._mainPanel, "_paintLine", paintLineCounter, true); 22 28 InspectorTest.addResult("\nBefore highlight"); 23 29 InspectorTest.dumpEditorHTML(textEditor, true); 24 30 var highlightDescriptor = textEditor.highlightRegex("foo_.", "some-css-class"); 25 31 InspectorTest.addResult("\nAdd highlight for regexp /foo_./"); 32 InspectorTest.addResult("Lines repainted: " + paintLineCalls); 33 paintLineCalls = 0; 26 34 InspectorTest.dumpEditorHTML(textEditor, true); 27 35 InspectorTest.addResult("\nRemove highlight for regexp /foo_./"); 28 36 textEditor.removeRegexHighlight(highlightDescriptor); 37 InspectorTest.addResult("Lines repainted: " + paintLineCalls); 29 38 InspectorTest.dumpEditorHTML(textEditor, true); 30 39 next(); -
trunk/Source/WebCore/ChangeLog
r141243 r141244 1 2013-01-30 Andrey Lushnikov <lushnikov@chromium.org> 2 3 Web Inspector: do not repaint all lines in highlight regex API in DTE 4 https://bugs.webkit.org/show_bug.cgi?id=108081 5 6 Reviewed by Pavel Feldman. 7 8 Implement repaintLineRowsAffectedByHighlightDescriptor method that 9 will go through the visible lineRows and repaint only those of them 10 which were outdated by highlight change. 11 12 Improved test: inspector/editor/text-editor-highlight-regexp.html 13 14 * inspector/front-end/DefaultTextEditor.js: 15 (WebInspector.TextEditorMainPanel.prototype.highlightRegex): 16 (WebInspector.TextEditorMainPanel.prototype.removeRegexHighlight): 17 (WebInspector.TextEditorMainPanel.prototype._repaintLineRowsAffectedByHighlightDescriptor): 18 (WebInspector.TextEditorMainPanel.prototype._paintLines): 19 (WebInspector.TextEditorMainPanel.prototype._paintLineRows): 20 1 21 2013-01-30 Tien-Ren Chen <trchen@chromium.org> 2 22 -
trunk/Source/WebCore/inspector/front-end/DefaultTextEditor.js
r141230 r141244 1379 1379 var highlightDescriptor = new WebInspector.TextEditorMainPanel.RegexHighlightDescriptor(new RegExp(regex, "g"), cssClass); 1380 1380 this._highlightDescriptors.push(highlightDescriptor); 1381 this._repaint VisibleChunks();1381 this._repaintLineRowsAffectedByHighlightDescriptor(highlightDescriptor); 1382 1382 return highlightDescriptor; 1383 1383 }, … … 1389 1389 { 1390 1390 this._highlightDescriptors.remove(highlightDescriptor); 1391 this._repaintVisibleChunks(); 1392 }, 1393 1394 _repaintVisibleChunks: function() 1391 this._repaintLineRowsAffectedByHighlightDescriptor(highlightDescriptor); 1392 }, 1393 1394 /** 1395 * @param {WebInspector.TextEditorMainPanel.HighlightDescriptor} highlightDescriptor 1396 */ 1397 _repaintLineRowsAffectedByHighlightDescriptor: function(highlightDescriptor) 1395 1398 { 1396 1399 var visibleFrom = this.scrollTop(); … … 1398 1401 1399 1402 var visibleChunks = this.findVisibleChunks(visibleFrom, visibleTo); 1403 1404 var affectedLineRows = []; 1405 for (var i = visibleChunks.start; i < visibleChunks.end; ++i) { 1406 var chunk = this._textChunks[i]; 1407 if (!chunk.expanded()) 1408 continue; 1409 for (var lineNumber = chunk.startLine; lineNumber < chunk.startLine + chunk.linesCount; ++lineNumber) { 1410 var lineRow = chunk.expandedLineRow(lineNumber); 1411 var line = this._textModel.line(lineNumber); 1412 if (highlightDescriptor.affectsLine(lineNumber, line)) 1413 affectedLineRows.push(lineRow); 1414 } 1415 } 1416 if (affectedLineRows.length === 0) 1417 return; 1400 1418 var selection = this.selection(); 1401 1402 for(var i = visibleChunks.start; i < visibleChunks.end; ++i) { 1403 var chunk = this._textChunks[i]; 1404 this._paintLines(chunk._startLine, chunk._startLine + chunk.linesCount); 1405 } 1419 this._paintLineRows(affectedLineRows); 1406 1420 this._restoreSelection(selection); 1407 1421 }, … … 1796 1810 _paintLines: function(fromLine, toLine, restoreSelection) 1797 1811 { 1812 var lineRows = []; 1798 1813 var chunk; 1799 var selection;1800 var lineRows = [];1801 1814 for (var lineNumber = fromLine; lineNumber < toLine; ++lineNumber) { 1802 1815 if (!chunk || lineNumber < chunk.startLine || lineNumber >= chunk.startLine + chunk.linesCount) … … 1805 1818 if (!lineRow) 1806 1819 continue; 1807 if (restoreSelection && !selection)1808 selection = this.selection();1809 1820 lineRows.push(lineRow); 1810 1821 } 1811 1822 if (lineRows.length === 0) 1823 return; 1824 1825 var selection; 1826 if (restoreSelection) 1827 selection = this.selection(); 1828 1829 this._paintLineRows(lineRows); 1830 1831 if (restoreSelection) 1832 this._restoreSelection(selection); 1833 }, 1834 1835 /** 1836 * @param {Array.<Element>} lineRows 1837 */ 1838 _paintLineRows: function(lineRows) 1839 { 1812 1840 var highlight = {}; 1813 1841 this.beginDomUpdates(); … … 1821 1849 1822 1850 this.endDomUpdates(); 1823 1824 if (restoreSelection)1825 this._restoreSelection(selection);1826 1851 }, 1827 1852
Note: See TracChangeset
for help on using the changeset viewer.