Web Inspector: Don't include error message text in the editor buffer.
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Dec 2012 17:41:01 +0000 (17:41 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Dec 2012 17:41:01 +0000 (17:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=103932

Reviewed by Alexander Pavlov.

Source/WebCore:

Skip entire decoration content when collecting dirty regions.

* inspector/front-end/DefaultTextEditor.js:
(WebInspector.TextEditorMainPanel.prototype._collectLinesFromDOM):

LayoutTests:

* inspector/editor/editor-test.js:
(initialize_EditorTests.InspectorTest.getLineElement):
(initialize_EditorTests):
* inspector/editor/text-editor-type-over-decoration-expected.txt: Added.
* inspector/editor/text-editor-type-over-decoration.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@136703 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/inspector/editor/editor-test.js
LayoutTests/inspector/editor/text-editor-type-over-decoration-expected.txt [new file with mode: 0644]
LayoutTests/inspector/editor/text-editor-type-over-decoration.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/DefaultTextEditor.js

index 78f55b44fa2d5172ee46f834ebe4d21cb6a10a36..e5d8b78634cad713703a7d9e7e305b3909da139a 100644 (file)
@@ -1,3 +1,16 @@
+2012-12-05  Pavel Feldman  <pfeldman@chromium.org>
+
+        Web Inspector: Don't include error message text in the editor buffer.
+        https://bugs.webkit.org/show_bug.cgi?id=103932
+
+        Reviewed by Alexander Pavlov.
+
+        * inspector/editor/editor-test.js:
+        (initialize_EditorTests.InspectorTest.getLineElement):
+        (initialize_EditorTests):
+        * inspector/editor/text-editor-type-over-decoration-expected.txt: Added.
+        * inspector/editor/text-editor-type-over-decoration.html: Added.
+
 2012-12-05  Zan Dobersek  <zandobersek@gmail.com>
 
         Unreviewed GTK gardening.
index 2518ce1c5c1175b6f282a7ddfc1ff7c85c58758e..d0993ca3649ff01bf9d5e2df157b6f9e5e5d63f7 100644 (file)
@@ -50,4 +50,9 @@ InspectorTest.dumpEditorDOM = function(textEditor)
     }
 };
 
+InspectorTest.getLineElement = function(textEditor, lineNumber)
+{
+    return textEditor._mainPanel.chunkForLine(lineNumber).expandedLineRow(lineNumber);
+};
+
 }
diff --git a/LayoutTests/inspector/editor/text-editor-type-over-decoration-expected.txt b/LayoutTests/inspector/editor/text-editor-type-over-decoration-expected.txt
new file mode 100644 (file)
index 0000000..2ece065
--- /dev/null
@@ -0,0 +1,26 @@
+This test checks that typing over the decoration does not collect decoration text as a part of damaged DOM.
+
+Chunk model
+Chunk [0] 0:10 (expanded)
+Editor DOM
+[0]       <div class="webkit-line-content">0</div>
+[1]       <div class="webkit-line-content">1</div>
+[2]       <div class="webkit-line-content">2</div>
+[3]       <div class="webkit-line-content">3</div>
+[4]       <div class="webkit-line-content">4</div>
+[5:6]     <div class="webkit-line-content">5<div class="webkit-line-decorations"><span>Decoration content</span></div></div>
+[6]       <div class="webkit-line-content">6</div>
+[7]       <div class="webkit-line-content">7</div>
+[8]       <div class="webkit-line-content">8</div>
+[9]       <div class="webkit-line-content">9</div>
+Editor DOM
+[0]       <div class="webkit-line-content">0</div>
+[1]       <div class="webkit-line-content">1</div>
+[2]       <div class="webkit-line-content">2</div>
+[3]       <div class="webkit-line-content">3</div>
+[4]       <div class="webkit-line-content">4a5</div>
+[5]       <div class="webkit-line-content">6</div>
+[6]       <div class="webkit-line-content">7</div>
+[7]       <div class="webkit-line-content">8</div>
+[8]       <div class="webkit-line-content">9</div>
+
diff --git a/LayoutTests/inspector/editor/text-editor-type-over-decoration.html b/LayoutTests/inspector/editor/text-editor-type-over-decoration.html
new file mode 100644 (file)
index 0000000..cd4a05d
--- /dev/null
@@ -0,0 +1,35 @@
+<html>
+<head>
+<script src="../../http/tests/inspector/inspector-test.js"></script>
+<script src="editor-test.js?foo=143"></script>
+<script>
+
+function test()
+{
+    var textEditor = InspectorTest.createTestEditor(10);
+    var textModel = textEditor._textModel;
+
+    InspectorTest.dumpEditorChunks(textEditor);
+    var decorationElement = document.createElement("span");
+    decorationElement.textContent = "Decoration content";
+    textEditor.addDecoration(5, decorationElement);
+    InspectorTest.dumpEditorDOM(textEditor);
+
+    // Insert Enter before the decoration
+    var lineRowElement = InspectorTest.getLineElement(textEditor, 5);
+    lineRowElement.parentElement.insertBefore(document.createTextNode("a"), lineRowElement);
+    textEditor._mainPanel._applyDomUpdates({start:4, end:5});
+    InspectorTest.dumpEditorDOM(textEditor);
+    InspectorTest.completeTest();
+}
+
+</script>
+</head>
+
+<body onload="runTest()">
+<p>
+This test checks that typing over the decoration does not collect decoration text as a part of damaged DOM.
+</p>
+
+</body>
+</html>
index 0446458b8171d461bd42d959d61e2a77f672612a..c91adf23a9358100a8f12da0359a037cd0fab156 100644 (file)
@@ -1,3 +1,15 @@
+2012-12-05  Pavel Feldman  <pfeldman@chromium.org>
+
+        Web Inspector: Don't include error message text in the editor buffer.
+        https://bugs.webkit.org/show_bug.cgi?id=103932
+
+        Reviewed by Alexander Pavlov.
+
+        Skip entire decoration content when collecting dirty regions.
+        
+        * inspector/front-end/DefaultTextEditor.js:
+        (WebInspector.TextEditorMainPanel.prototype._collectLinesFromDOM):
+
 2012-12-05  Joshua Bell  <jsbell@chromium.org>
 
         IndexedDB: Replace use of ScriptExecutionContext::Task (Part 2)
index 458e54552a9aa947d2642dd7ee2c5141b2bdfacd..8a37bc497c3b963eb6f5843344fa757384774b2d 100644 (file)
@@ -2492,8 +2492,12 @@ WebInspector.TextEditorMainPanel.prototype = {
         var textContents = [];
         var hasContent = false;
         for (var node = from ? from.nextSibling : this._container; node && node !== to; node = node.traverseNextNode(this._container)) {
-            if (node._isDecorationsElement)
-                continue;
+            if (node._isDecorationsElement) {
+                // Skip all children of the decoration container.
+                node = node.nextSibling;
+                if (!node || node === to)
+                    break;
+            }
             hasContent = true;
             if (node.nodeName.toLowerCase() === "br")
                 textContents.push("\n");