Diff
Modified: trunk/LayoutTests/ChangeLog (141256 => 141257)
--- trunk/LayoutTests/ChangeLog 2013-01-30 12:39:31 UTC (rev 141256)
+++ trunk/LayoutTests/ChangeLog 2013-01-30 12:43:51 UTC (rev 141257)
@@ -1,3 +1,18 @@
+2013-01-30 Andrey Lushnikov <[email protected]>
+
+ Web Inspector: implement highlight range API
+ https://bugs.webkit.org/show_bug.cgi?id=108317
+
+ Reviewed by Pavel Feldman.
+
+ Added test cases to the existed test to cover highlight range
+ functionality.
+
+ * inspector/editor/text-editor-highlight-api-expected.txt: Added.
+ * inspector/editor/text-editor-highlight-api.html: Added.
+ * inspector/editor/text-editor-highlight-regexp-expected.txt: Removed.
+ * inspector/editor/text-editor-highlight-regexp.html: Removed.
+
2013-01-30 Zan Dobersek <[email protected]>
Unreviewed GTK gardening.
Added: trunk/LayoutTests/inspector/editor/text-editor-highlight-api-expected.txt (0 => 141257)
--- trunk/LayoutTests/inspector/editor/text-editor-highlight-api-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/editor/text-editor-highlight-api-expected.txt 2013-01-30 12:43:51 UTC (rev 141257)
@@ -0,0 +1,65 @@
+Test editor highlight regexp API.
+
+
+Before highlight
+
+<div class="inner-container" tabindex="0">
+<div class="webkit-line-content">foo();</div>
+<div class="webkit-line-content">foo_1; foor; foo_;</div>
+<div class="webkit-line-content">foo_</div>
+<div class="webkit-line-content">global_foo</div>
+<div class="webkit-line-content">global_foo2</div>
+<div class="webkit-line-content">some_other_foo_X</div></div>
+
+Running: testHighlightRegex
+
+Add highlight for regexp /foo_./
+Lines repainted: 2
+
+<div class="inner-container" tabindex="0">
+<div class="webkit-line-content">foo();</div>
+<div class="webkit-line-content">foo_1; foor; foo_;<span class="some-css-class text-editor-overlay-highlight" style="left: -1px; width: 37px;"> </span><span class="some-css-class text-editor-overlay-highlight" style="left: 90px; width: 37px;"> </span></div>
+<div class="webkit-line-content">foo_</div>
+<div class="webkit-line-content">global_foo</div>
+<div class="webkit-line-content">global_foo2</div>
+<div class="webkit-line-content">some_other_foo_X<span class="some-css-class text-editor-overlay-highlight" style="left: 76px; width: 37px;"> </span></div></div>
+
+Running: testHighlightRange
+
+Highlighting range from (1, 13) to (3, 16)
+Lines repainted: 3
+
+<div class="inner-container" tabindex="0">
+<div class="webkit-line-content">foo();</div>
+<div class="webkit-line-content">foo_1; foor; foo_;<span class="some-css-class text-editor-overlay-highlight" style="left: -1px; width: 37px;"> </span><span class="some-css-class text-editor-overlay-highlight" style="left: 90px; width: 37px;"> </span><span class="some-other-class text-editor-overlay-highlight" style="left: 90px; width: 37px;"> </span></div>
+<div class="webkit-line-content">foo_<span class="some-other-class text-editor-overlay-highlight" style="left: -1px; width: 30px;"> </span></div>
+<div class="webkit-line-content">global_foo<span class="some-other-class text-editor-overlay-highlight" style="left: -1px; width: 72px;"> </span></div>
+<div class="webkit-line-content">global_foo2</div>
+<div class="webkit-line-content">some_other_foo_X<span class="some-css-class text-editor-overlay-highlight" style="left: 76px; width: 37px;"> </span></div></div>
+
+Running: testRemoveRegexHighlight
+
+Remove highlight for regexp /foo_./
+Lines repainted: 2
+
+<div class="inner-container" tabindex="0">
+<div class="webkit-line-content">foo();</div>
+<div class="webkit-line-content">foo_1; foor; foo_;<span class="some-other-class text-editor-overlay-highlight" style="left: 90px; width: 37px;"> </span></div>
+<div class="webkit-line-content">foo_<span class="some-other-class text-editor-overlay-highlight" style="left: -1px; width: 30px;"> </span></div>
+<div class="webkit-line-content">global_foo<span class="some-other-class text-editor-overlay-highlight" style="left: -1px; width: 72px;"> </span></div>
+<div class="webkit-line-content">global_foo2</div>
+<div class="webkit-line-content">some_other_foo_X</div></div>
+
+Running: testRemoveRangeHighlight
+
+Remove highlight for range (1, 13) to (3, 16)
+Lines repainted: 3
+
+<div class="inner-container" tabindex="0">
+<div class="webkit-line-content">foo();</div>
+<div class="webkit-line-content">foo_1; foor; foo_;</div>
+<div class="webkit-line-content">foo_</div>
+<div class="webkit-line-content">global_foo</div>
+<div class="webkit-line-content">global_foo2</div>
+<div class="webkit-line-content">some_other_foo_X</div></div>
+
Added: trunk/LayoutTests/inspector/editor/text-editor-highlight-api.html (0 => 141257)
--- trunk/LayoutTests/inspector/editor/text-editor-highlight-api.html (rev 0)
+++ trunk/LayoutTests/inspector/editor/text-editor-highlight-api.html 2013-01-30 12:43:51 UTC (rev 141257)
@@ -0,0 +1,81 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+
+function test()
+{
+ var text = [
+ "foo();",
+ "foo_1; foor; foo_;",
+ "foo_",
+ "global_foo",
+ "global_foo2",
+ "some_other_foo_X"
+ ];
+ var textEditor = InspectorTest.createTestEditor();
+ textEditor.setText(text.join("\n"));
+ var paintLineCalls = 0;
+ function paintLineCounter()
+ {
+ ++paintLineCalls;
+ }
+ InspectorTest.addSniffer(textEditor._mainPanel, "_paintLine", paintLineCounter, true);
+ InspectorTest.addResult("\nBefore highlight");
+ InspectorTest.dumpEditorHTML(textEditor, true);
+
+ var rangeHighlightDescriptor;
+ var regexHighlightDescriptor;
+
+ InspectorTest.runTestSuite([
+ function testHighlightRegex(next)
+ {
+ regexHighlightDescriptor = textEditor.highlightRegex("foo_.", "some-css-class");
+ InspectorTest.addResult("\nAdd highlight for regexp /foo_./");
+ InspectorTest.addResult("Lines repainted: " + paintLineCalls);
+ InspectorTest.dumpEditorHTML(textEditor, true);
+ next();
+ },
+
+ function testHighlightRange(next)
+ {
+ InspectorTest.addResult("\nHighlighting range from (1, 13) to (3, 16)");
+ paintLineCalls = 0;
+ rangeHighlightDescriptor = textEditor.highlightRange(new WebInspector.TextRange(1, 13, 3, 16), "some-other-class");
+ InspectorTest.addResult("Lines repainted: " + paintLineCalls);
+ InspectorTest.dumpEditorHTML(textEditor, true);
+ next();
+ },
+
+ function testRemoveRegexHighlight(next)
+ {
+ InspectorTest.addResult("\nRemove highlight for regexp /foo_./");
+ paintLineCalls = 0;
+ textEditor.removeHighlight(regexHighlightDescriptor);
+ InspectorTest.addResult("Lines repainted: " + paintLineCalls);
+ InspectorTest.dumpEditorHTML(textEditor, true);
+ next();
+ },
+
+ function testRemoveRangeHighlight(next)
+ {
+ InspectorTest.addResult("\nRemove highlight for range (1, 13) to (3, 16)");
+ paintLineCalls = 0;
+ textEditor.removeHighlight(rangeHighlightDescriptor);
+ InspectorTest.addResult("Lines repainted: " + paintLineCalls);
+ InspectorTest.dumpEditorHTML(textEditor, true);
+ next();
+ },
+ ]);
+}
+
+</script>
+</head>
+
+<body _onload_="runTest()">
+<p>
+Test editor highlight regexp API.
+</p>
+</body>
+</html>
Deleted: trunk/LayoutTests/inspector/editor/text-editor-highlight-regexp-expected.txt (141256 => 141257)
--- trunk/LayoutTests/inspector/editor/text-editor-highlight-regexp-expected.txt 2013-01-30 12:39:31 UTC (rev 141256)
+++ trunk/LayoutTests/inspector/editor/text-editor-highlight-regexp-expected.txt 2013-01-30 12:43:51 UTC (rev 141257)
@@ -1,37 +0,0 @@
-Test editor highlight regexp API.
-
-
-Running: testHighlightApi
-
-Before highlight
-
-<div class="inner-container" tabindex="0">
-<div class="webkit-line-content">foo();</div>
-<div class="webkit-line-content">foo_1; foor; foo_;</div>
-<div class="webkit-line-content">foo_</div>
-<div class="webkit-line-content">global_foo</div>
-<div class="webkit-line-content">global_foo2</div>
-<div class="webkit-line-content">some_other_foo_X</div></div>
-
-Add highlight for regexp /foo_./
-Lines repainted: 2
-
-<div class="inner-container" tabindex="0">
-<div class="webkit-line-content">foo();</div>
-<div class="webkit-line-content">foo_1; foor; foo_;<span class="some-css-class text-editor-overlay-highlight" style="left: -1px; width: 37px;"> </span><span class="some-css-class text-editor-overlay-highlight" style="left: 90px; width: 37px;"> </span></div>
-<div class="webkit-line-content">foo_</div>
-<div class="webkit-line-content">global_foo</div>
-<div class="webkit-line-content">global_foo2</div>
-<div class="webkit-line-content">some_other_foo_X<span class="some-css-class text-editor-overlay-highlight" style="left: 76px; width: 37px;"> </span></div></div>
-
-Remove highlight for regexp /foo_./
-Lines repainted: 2
-
-<div class="inner-container" tabindex="0">
-<div class="webkit-line-content">foo();</div>
-<div class="webkit-line-content">foo_1; foor; foo_;</div>
-<div class="webkit-line-content">foo_</div>
-<div class="webkit-line-content">global_foo</div>
-<div class="webkit-line-content">global_foo2</div>
-<div class="webkit-line-content">some_other_foo_X</div></div>
-
Deleted: trunk/LayoutTests/inspector/editor/text-editor-highlight-regexp.html (141256 => 141257)
--- trunk/LayoutTests/inspector/editor/text-editor-highlight-regexp.html 2013-01-30 12:39:31 UTC (rev 141256)
+++ trunk/LayoutTests/inspector/editor/text-editor-highlight-regexp.html 2013-01-30 12:43:51 UTC (rev 141257)
@@ -1,52 +0,0 @@
-<html>
-<head>
-<script src=""
-<script src=""
-<script>
-
-function test()
-{
- InspectorTest.runTestSuite([
- function testHighlightApi(next)
- {
- var text = [
- "foo();",
- "foo_1; foor; foo_;",
- "foo_",
- "global_foo",
- "global_foo2",
- "some_other_foo_X"
- ];
- var textEditor = InspectorTest.createTestEditor();
- textEditor.setText(text.join("\n"));
- var paintLineCalls = 0;
- function paintLineCounter()
- {
- ++paintLineCalls;
- }
- InspectorTest.addSniffer(textEditor._mainPanel, "_paintLine", paintLineCounter, true);
- InspectorTest.addResult("\nBefore highlight");
- InspectorTest.dumpEditorHTML(textEditor, true);
- var highlightDescriptor = textEditor.highlightRegex("foo_.", "some-css-class");
- InspectorTest.addResult("\nAdd highlight for regexp /foo_./");
- InspectorTest.addResult("Lines repainted: " + paintLineCalls);
- paintLineCalls = 0;
- InspectorTest.dumpEditorHTML(textEditor, true);
- InspectorTest.addResult("\nRemove highlight for regexp /foo_./");
- textEditor.removeRegexHighlight(highlightDescriptor);
- InspectorTest.addResult("Lines repainted: " + paintLineCalls);
- InspectorTest.dumpEditorHTML(textEditor, true);
- next();
- },
- ]);
-}
-
-</script>
-</head>
-
-<body _onload_="runTest()">
-<p>
-Test editor highlight regexp API.
-</p>
-</body>
-</html>
Modified: trunk/Source/WebCore/ChangeLog (141256 => 141257)
--- trunk/Source/WebCore/ChangeLog 2013-01-30 12:39:31 UTC (rev 141256)
+++ trunk/Source/WebCore/ChangeLog 2013-01-30 12:43:51 UTC (rev 141257)
@@ -1,3 +1,29 @@
+2013-01-30 Andrey Lushnikov <[email protected]>
+
+ Web Inspector: implement highlight range API
+ https://bugs.webkit.org/show_bug.cgi?id=108317
+
+ Reviewed by Pavel Feldman.
+
+ Test: inspector/editor/text-editor-highlight-api.html
+
+ Introduce RangeHighlightDescriptor class and implement Highlight Range
+ api.
+
+ * inspector/front-end/DefaultTextEditor.js:
+ (WebInspector.DefaultTextEditor.prototype.removeHighlight):
+ (WebInspector.DefaultTextEditor.prototype.highlightRange):
+ (WebInspector.TextEditorMainPanel.prototype.removeHighlight):
+ (WebInspector.TextEditorMainPanel.prototype.highlightRange):
+ (WebInspector.TextEditorMainPanel.RangeHighlightDescriptor):
+ (WebInspector.TextEditorMainPanel.RangeHighlightDescriptor.prototype.affectsLine):
+ (WebInspector.TextEditorMainPanel.RangeHighlightDescriptor.prototype.rangesForLine):
+ (WebInspector.TextEditorMainPanel.RangeHighlightDescriptor.prototype.cssClass):
+ (WebInspector.TextEditorMainPanel.TokenHighlighter.prototype._removeHighlight):
+ * inspector/front-end/TextEditor.js:
+ (WebInspector.TextEditor.prototype.highlightRange):
+ (WebInspector.TextEditor.prototype.removeHighlight):
+
2013-01-30 Simon Hausmann <[email protected]>
[Qt] Remove QT4_UNICODE related code paths
Modified: trunk/Source/WebCore/inspector/front-end/DefaultTextEditor.js (141256 => 141257)
--- trunk/Source/WebCore/inspector/front-end/DefaultTextEditor.js 2013-01-30 12:39:31 UTC (rev 141256)
+++ trunk/Source/WebCore/inspector/front-end/DefaultTextEditor.js 2013-01-30 12:43:51 UTC (rev 141257)
@@ -123,12 +123,21 @@
/**
* @param {WebInspector.TextEditorMainPanel.HighlightDescriptor} highlightDescriptor
*/
- removeRegexHighlight: function(highlightDescriptor)
+ removeHighlight: function(highlightDescriptor)
{
- this._mainPanel.removeRegexHighlight(highlightDescriptor);
+ this._mainPanel.removeHighlight(highlightDescriptor);
},
/**
+ * @param {WebInspector.TextRange} range
+ * @param {string} cssClass
+ */
+ highlightRange: function(range, cssClass)
+ {
+ return this._mainPanel.highlightRange(range, cssClass);
+ },
+
+ /**
* @param {string} mimeType
*/
set mimeType(mimeType)
@@ -1388,13 +1397,25 @@
/**
* @param {WebInspector.TextEditorMainPanel.HighlightDescriptor} highlightDescriptor
*/
- removeRegexHighlight: function(highlightDescriptor)
+ removeHighlight: function(highlightDescriptor)
{
this._highlightDescriptors.remove(highlightDescriptor);
this._repaintLineRowsAffectedByHighlightDescriptor(highlightDescriptor);
},
/**
+ * @param {WebInspector.TextRange} range
+ * @param {string} cssClass
+ */
+ highlightRange: function(range, cssClass)
+ {
+ var highlightDescriptor = new WebInspector.TextEditorMainPanel.RangeHighlightDescriptor(range, cssClass);
+ this._highlightDescriptors.push(highlightDescriptor);
+ this._repaintLineRowsAffectedByHighlightDescriptor(highlightDescriptor);
+ return highlightDescriptor;
+ },
+
+ /**
* @param {WebInspector.TextEditorMainPanel.HighlightDescriptor} highlightDescriptor
*/
_repaintLineRowsAffectedByHighlightDescriptor: function(highlightDescriptor)
@@ -2754,6 +2775,56 @@
/**
* @constructor
+ * @implements {WebInspector.TextEditorMainPanel.HighlightDescriptor}
+ * @param {WebInspector.TextRange} range
+ * @param {string} cssClass
+ */
+WebInspector.TextEditorMainPanel.RangeHighlightDescriptor = function(range, cssClass)
+{
+ this._cssClass = cssClass;
+ this._range = range;
+}
+
+WebInspector.TextEditorMainPanel.RangeHighlightDescriptor.prototype = {
+ /**
+ * @param {number} lineNumber
+ * @param {string} line
+ * @return {boolean}
+ */
+ affectsLine: function(lineNumber, line)
+ {
+ return this._range.startLine <= lineNumber && lineNumber <= this._range.endLine && line.length > 0;
+ },
+
+ /**
+ * @param {number} lineNumber
+ * @param {string} line
+ * @return {Array.<{startColumn: number, endColumn: number}>}
+ */
+ rangesForLine: function(lineNumber, line)
+ {
+ if (!this.affectsLine(lineNumber, line))
+ return [];
+
+ var startColumn = lineNumber === this._range.startLine ? this._range.startColumn : 0;
+ var endColumn = lineNumber === this._range.endLine ? Math.max(this._range.endColumn, line.length) : line.length;
+ return [{
+ startColumn: startColumn,
+ endColumn: endColumn
+ }];
+ },
+
+ /**
+ * @return {string}
+ */
+ cssClass: function()
+ {
+ return this._cssClass;
+ }
+}
+
+/**
+ * @constructor
* @param {Element} element
*/
WebInspector.TextEditorMainPanel.ElementMetrics = function(element)
@@ -3099,7 +3170,7 @@
_removeHighlight: function()
{
if (this._selectedWord) {
- this._mainPanel.removeRegexHighlight(this._highlightDescriptor);
+ this._mainPanel.removeHighlight(this._highlightDescriptor);
delete this._selectedWord;
delete this._highlightDescriptor;
}
Modified: trunk/Source/WebCore/inspector/front-end/TextEditor.js (141256 => 141257)
--- trunk/Source/WebCore/inspector/front-end/TextEditor.js 2013-01-30 12:39:31 UTC (rev 141256)
+++ trunk/Source/WebCore/inspector/front-end/TextEditor.js 2013-01-30 12:43:51 UTC (rev 141257)
@@ -68,9 +68,15 @@
highlightRegex: function(regex, cssClass) { },
/**
+ * @param {WebInspector.TextRange} range
+ * @param {string} cssClass
+ */
+ highlightRange: function(range, cssClass) { },
+
+ /**
* @param {WebInspector.TextEditorMainPanel.HighlightDescriptor} highlightDescriptor
*/
- removeRegexHighlight: function(highlightDescriptor) { },
+ removeHighlight: function(highlightDescriptor) { },
/**
* @param {number} lineNumber