Title: [140421] trunk
Revision
140421
Author
[email protected]
Date
2013-01-22 06:43:38 -0800 (Tue, 22 Jan 2013)

Log Message

Web Inspector: do not highlight really long lines in DTE.
https://bugs.webkit.org/show_bug.cgi?id=107531

Patch by Andrey Lushnikov <[email protected]> on 2013-01-22
Reviewed by Pavel Feldman.

Source/WebCore:

Improve TextEditorHighlighter.orderedRangesPerLine method to return
only ranges that start before particular column.

Test: inspector/editor/text-editor-long-line.html

* inspector/front-end/TextEditorHighlighter.js:
(WebInspector.TextEditorHighlighter):
(WebInspector.TextEditorHighlighter.prototype.setHighlightLineLimit):
(WebInspector.TextEditorHighlighter.prototype.orderedRangesPerLine.comparator):
(WebInspector.TextEditorHighlighter.prototype.orderedRangesPerLine):

LayoutTests:

Layout test to verify that Default Text Editor does not spend time for
highlighting really long lines of code.

* inspector/editor/highlighter-long-line.html: Correct highlighter defaults in initialization.
* inspector/editor/text-editor-long-line-expected.txt: Added.
* inspector/editor/text-editor-long-line.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (140420 => 140421)


--- trunk/LayoutTests/ChangeLog	2013-01-22 14:40:50 UTC (rev 140420)
+++ trunk/LayoutTests/ChangeLog	2013-01-22 14:43:38 UTC (rev 140421)
@@ -1,3 +1,17 @@
+2013-01-22  Andrey Lushnikov  <[email protected]>
+
+        Web Inspector: do not highlight really long lines in DTE.
+        https://bugs.webkit.org/show_bug.cgi?id=107531
+
+        Reviewed by Pavel Feldman.
+
+        Layout test to verify that Default Text Editor does not spend time for
+        highlighting really long lines of code.
+
+        * inspector/editor/highlighter-long-line.html: Correct highlighter defaults in initialization.
+        * inspector/editor/text-editor-long-line-expected.txt: Added.
+        * inspector/editor/text-editor-long-line.html: Added.
+
 2013-01-22  Thiago Marcos P. Santos  <[email protected]>
 
         [EFL][Chromium] Unreviewed gardening.

Modified: trunk/LayoutTests/inspector/editor/highlighter-long-line.html (140420 => 140421)


--- trunk/LayoutTests/inspector/editor/highlighter-long-line.html	2013-01-22 14:40:50 UTC (rev 140420)
+++ trunk/LayoutTests/inspector/editor/highlighter-long-line.html	2013-01-22 14:43:38 UTC (rev 140421)
@@ -11,6 +11,7 @@
     var highlighter = new WebInspector.TextEditorHighlighter(textModel, function() {});
     highlighter.mimeType = "text/_javascript_";
     highlighter.highlightChunkLimit = Number.MAX_VALUE; // Synchronous.
+    highlighter.setHighlightLineLimit(Number.MAX_VALUE);
 
     var src = "" asdf */ ";
     var comments = 1;

Added: trunk/LayoutTests/inspector/editor/text-editor-long-line-expected.txt (0 => 140421)


--- trunk/LayoutTests/inspector/editor/text-editor-long-line-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/editor/text-editor-long-line-expected.txt	2013-01-22 14:43:38 UTC (rev 140421)
@@ -0,0 +1,6 @@
+This test checks that text editor doesn't paint highlight for too long lines.
+
+
+<div class="inner-container" tabindex="0">
+<div class="webkit-line-content"><span class="webkit-_javascript_-comment">/* START */</span> <span class="webkit-_javascript_-keyword">this</span>.<span class="webkit-_javascript_-ident">field</span> = <span class="webkit-_javascript_-string">"foo"</span>; <span class="webkit-_javascript_-comment">/* comment */</span> <span class="webkit-_javascript_-keyword">function</span> <span class="webkit-_javascript_-ident">bar</span>() <span class="webkit-block-start">{</span> <span class="webkit-_javascript_-keyword">return</span> <span class="webkit-_javascript_-keyword">null</span>; <span class="webkit-block-end">}</span><span class="webkit-_javascript_-keyword">this</span>.<span class="webkit-_javascript_-ident">field</span> = <span class="webkit-_javascript_-string">"foo"</span>; <span class="webkit-_javascript_-comment">/* comment */</span> function bar() { return null; }this.field = "foo"; /* comment */ function bar() { return null; }this.field = "foo"; /* comment */ function bar() { return null; }this.field = "foo"; /* comment */ function bar() { return null; }this.field = "foo"; /* comment */ function bar() { return null; }this.field = "foo"; /* comment */ function bar() { return null; }this.field = "foo"; /* comment */ function bar() { return null; }this.field = "foo"; /* comment */ function bar() { return null; }this.field = "foo"; /* comment */ function bar() { return null; }this.field = "foo"; /* comment */ function bar() { return null; }this.field = "foo"; /* comment */ function bar() { return null; }this.field = "foo"; /* comment */ function bar() { return null; }this.field = "foo"; /* comment */ function bar() { return null; }this.field = "foo"; /* comment */ function bar() { return null; }this.field = "foo"; /* comment */ function bar() { return null; }this.field = "foo"; /* comment */ function bar() { return null; }this.field = "foo"; /* comment */ function bar() { return null; }this.field = "foo"; /* comment */ function bar() { return null; }this.field = "foo"; /* comment */ function bar() { return null; }this.field = "foo"; /* comment */ function bar() { return null; }this.field = "foo"; /* comment */ function bar() { return null; }this.field = "foo"; /* comment */ function bar() { return null; }this.field = "foo"; /* comment */ function bar() { return null; }this.field = "foo"; /* comment */ function bar() { return null; }this.field = "foo"; /* comment */ function bar() { return null; }this.field = "foo"; /* comment */ function bar() { return null; }this.field = "foo"; /* comment */ function bar() { return null; }this.field = "foo"; /* comment */ function bar() { return null; }this.field = "foo"; /* comment */ function bar() { return null; }this.field = "foo"; /* comment */ function bar() { return null; }this.field = "foo"; /* comment */ function bar() { return null; }/* FINISH */</div></div>
+

Added: trunk/LayoutTests/inspector/editor/text-editor-long-line.html (0 => 140421)


--- trunk/LayoutTests/inspector/editor/text-editor-long-line.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/editor/text-editor-long-line.html	2013-01-22 14:43:38 UTC (rev 140421)
@@ -0,0 +1,32 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+
+function test()
+{
+    var textEditor = InspectorTest.createTestEditor();
+    textEditor.mimeType = "text/_javascript_";
+    textEditor._mainPanel._highlighter.setHighlightLineLimit(100);
+
+    var src = "" = \"foo\"; /* comment */ function bar() { return null; }";
+    for(var i = 0; i < 5; i++) {
+        src += src;
+    }
+    src = "" START */ " + src + "/* FINISH */";
+    textEditor.setText(src);
+    InspectorTest.dumpEditorHTML(textEditor, true);
+    InspectorTest.completeTest();
+}
+
+</script>
+</head>
+
+<body _onload_="runTest()">
+<p>
+This test checks that text editor doesn't paint highlight for too long lines.
+</p>
+
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (140420 => 140421)


--- trunk/Source/WebCore/ChangeLog	2013-01-22 14:40:50 UTC (rev 140420)
+++ trunk/Source/WebCore/ChangeLog	2013-01-22 14:43:38 UTC (rev 140421)
@@ -1,3 +1,21 @@
+2013-01-22  Andrey Lushnikov  <[email protected]>
+
+        Web Inspector: do not highlight really long lines in DTE.
+        https://bugs.webkit.org/show_bug.cgi?id=107531
+
+        Reviewed by Pavel Feldman.
+
+        Improve TextEditorHighlighter.orderedRangesPerLine method to return
+        only ranges that start before particular column.
+
+        Test: inspector/editor/text-editor-long-line.html
+
+        * inspector/front-end/TextEditorHighlighter.js:
+        (WebInspector.TextEditorHighlighter):
+        (WebInspector.TextEditorHighlighter.prototype.setHighlightLineLimit):
+        (WebInspector.TextEditorHighlighter.prototype.orderedRangesPerLine.comparator):
+        (WebInspector.TextEditorHighlighter.prototype.orderedRangesPerLine):
+
 2013-01-22  Gustavo Noronha Silva  <[email protected]>
 
         [GStreamer][Soup] Let GStreamer provide the buffer data is downloaded to, to avoid copying

Modified: trunk/Source/WebCore/inspector/front-end/DefaultTextEditor.js (140420 => 140421)


--- trunk/Source/WebCore/inspector/front-end/DefaultTextEditor.js	2013-01-22 14:40:50 UTC (rev 140420)
+++ trunk/Source/WebCore/inspector/front-end/DefaultTextEditor.js	2013-01-22 14:43:38 UTC (rev 140421)
@@ -2057,7 +2057,7 @@
                 cssClasses.push(value.cssClass);
             }
 
-            var ranges = this._highlighter.orderedRangesPerLine(lineNumber);
+            var ranges = highlight.ranges;
             this._renderRanges(lineRow, line, ranges);
 
             for(var i = 0; i < metrics.length; ++i)

Modified: trunk/Source/WebCore/inspector/front-end/TextEditorHighlighter.js (140420 => 140421)


--- trunk/Source/WebCore/inspector/front-end/TextEditorHighlighter.js	2013-01-22 14:40:50 UTC (rev 140420)
+++ trunk/Source/WebCore/inspector/front-end/TextEditorHighlighter.js	2013-01-22 14:43:38 UTC (rev 140421)
@@ -38,6 +38,7 @@
     this._tokenizer = WebInspector.SourceTokenizer.Registry.getInstance().getTokenizer("text/html");
     this._damageCallback = damageCallback;
     this._highlightChunkLimit = 1000;
+    this._highlightLineLimit = 500;
 }
 
 WebInspector.TextEditorHighlighter._MaxLineCount = 10000;
@@ -56,20 +57,11 @@
     },
 
     /**
-     * @param {number} lineNumber
-     * @return {Array.<{startColumn: number, endColumn: number, token: string}>}
+     * @param {number} highlightLineLimit
      */
-    orderedRangesPerLine: function(lineNumber)
+    setHighlightLineLimit: function(highlightLineLimit)
     {
-        var syntaxTokenHighligh = this._textModel.getAttribute(lineNumber, "highlight");
-        if (!syntaxTokenHighligh)
-            return [];
-
-        syntaxTokenHighligh.ranges.sort(function(a, b) {
-            return a.startColumn - b.startColumn;
-        });
-
-        return syntaxTokenHighligh.ranges;
+        this._highlightLineLimit = highlightLineLimit;
     },
 
     /**
@@ -196,7 +188,7 @@
                 do {
                     var newColumn = this._tokenizer.nextToken(lastHighlightedColumn);
                     var tokenType = this._tokenizer.tokenType;
-                    if (tokenType)
+                    if (tokenType && lastHighlightedColumn < this._highlightLineLimit)
                         state.ranges.push({
                             startColumn: lastHighlightedColumn,
                             endColumn: newColumn - 1,
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to