Title: [89492] trunk
Revision
89492
Author
[email protected]
Date
2011-06-22 16:18:57 -0700 (Wed, 22 Jun 2011)

Log Message

2011-06-22  Annie Sullivan  <[email protected]>

        Reviewed by Ryosuke Niwa.

        REGRESSION: Hitting enter in the middle of this span causes the cursor to go to the end of the span
        https://bugs.webkit.org/show_bug.cgi?id=61594

        Adds two layout tests to verify that hitting enter in the middle of the span splits the span correctly
        and places the cursor in the correct position.

        * editing/inserting/return-key-before-br-in-span-expected.txt: Added.
        * editing/inserting/return-key-before-br-in-span.html: Added.
        * editing/inserting/return-key-middle-of-span-expected.txt: Added.
        * editing/inserting/return-key-middle-of-span.html: Added.
2011-06-22  Annie Sullivan  <[email protected]>

        Reviewed by Ryosuke Niwa.

        REGRESSION: Hitting enter in the middle of this span causes the cursor to go to the end of the span
        https://bugs.webkit.org/show_bug.cgi?id=61594

        When the tree is split at the cursor in InsertParagraphSeparatorCommand, it is possible for the position
        split at to be at the end of a text node. The code assumes the position is at the start of the node, so
        pass the correct node into splitTreeToNode() in that case.

        Tests: editing/inserting/return-key-before-br-in-span.html
               editing/inserting/return-key-middle-of-span.html

        * editing/InsertParagraphSeparatorCommand.cpp:
        (WebCore::InsertParagraphSeparatorCommand::doApply):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (89491 => 89492)


--- trunk/LayoutTests/ChangeLog	2011-06-22 23:09:17 UTC (rev 89491)
+++ trunk/LayoutTests/ChangeLog	2011-06-22 23:18:57 UTC (rev 89492)
@@ -1,3 +1,18 @@
+2011-06-22  Annie Sullivan  <[email protected]>
+
+        Reviewed by Ryosuke Niwa.
+
+        REGRESSION: Hitting enter in the middle of this span causes the cursor to go to the end of the span
+        https://bugs.webkit.org/show_bug.cgi?id=61594
+
+        Adds two layout tests to verify that hitting enter in the middle of the span splits the span correctly
+        and places the cursor in the correct position.
+
+        * editing/inserting/return-key-before-br-in-span-expected.txt: Added.
+        * editing/inserting/return-key-before-br-in-span.html: Added.
+        * editing/inserting/return-key-middle-of-span-expected.txt: Added.
+        * editing/inserting/return-key-middle-of-span.html: Added.
+
 2011-06-22  Jessie Berlin  <[email protected]>
 
         Add more "CONSOLE MESSAGE: line 0: SVG animation pause API missing!" tests to the WK2

Added: trunk/LayoutTests/editing/inserting/return-key-before-br-in-span-expected.txt (0 => 89492)


--- trunk/LayoutTests/editing/inserting/return-key-before-br-in-span-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/inserting/return-key-before-br-in-span-expected.txt	2011-06-22 23:18:57 UTC (rev 89492)
@@ -0,0 +1,10 @@
+This sets the selection to the end of the first line, and hits the enter key.
+Expected behavior: a div is created around the second line, and the cursor is placed at the start of the second line. See bug 61594.
+| <span>
+|   id="wrapper"
+|   "First line"
+| <div>
+|   <span>
+|     <#selection-caret>
+|     <br>
+|     "Second line"

Added: trunk/LayoutTests/editing/inserting/return-key-before-br-in-span.html (0 => 89492)


--- trunk/LayoutTests/editing/inserting/return-key-before-br-in-span.html	                        (rev 0)
+++ trunk/LayoutTests/editing/inserting/return-key-before-br-in-span.html	2011-06-22 23:18:57 UTC (rev 89492)
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div contenteditable id="root"><span id="wrapper">First line<br>Second line</span></div>
+<script src=""
+<script>
+Markup.description("This sets the selection to the end of the first line, and hits the enter key.\n"
+    + "Expected behavior: a div is created around the second line, and the cursor is placed at the "
+    + "start of the second line. See bug 61594.");
+var sel = window.getSelection();
+sel.setPosition(document.getElementById("wrapper"), 1);
+document.execCommand("InsertParagraph", false, null);
+Markup.dump(root);
+</script>
+</html>

Added: trunk/LayoutTests/editing/inserting/return-key-middle-of-span-expected.txt (0 => 89492)


--- trunk/LayoutTests/editing/inserting/return-key-middle-of-span-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/inserting/return-key-middle-of-span-expected.txt	2011-06-22 23:18:57 UTC (rev 89492)
@@ -0,0 +1,10 @@
+This sets the selection to the middle of the first line, and hits the enter key.
+Expected behavior: the text node is split at the cursor. The span is cloned, and everything that was split out is placed inside the clone in a new div which is a child of the root. See bug 61594.
+| <span>
+|   id="wrapper"
+|   "First"
+| <div>
+|   <span>
+|     "<#selection-caret> line"
+|     <br>
+|     "Second line"

Added: trunk/LayoutTests/editing/inserting/return-key-middle-of-span.html (0 => 89492)


--- trunk/LayoutTests/editing/inserting/return-key-middle-of-span.html	                        (rev 0)
+++ trunk/LayoutTests/editing/inserting/return-key-middle-of-span.html	2011-06-22 23:18:57 UTC (rev 89492)
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div contenteditable id="root"><span id="wrapper">First line<br>Second line</span></div>
+<script src=""
+<script>
+Markup.description("This sets the selection to the middle of the first line, and hits the enter key.\n"
+    + "Expected behavior: the text node is split at the cursor. The span is cloned, and everything "
+    + "that was split out is placed inside the clone in a new div which is a child of the root. See bug 61594.");
+var sel = window.getSelection();
+sel.setPosition(document.getElementById("wrapper").firstChild, 5);
+document.execCommand("InsertParagraph", false, null);
+Markup.dump(root);
+</script>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (89491 => 89492)


--- trunk/Source/WebCore/ChangeLog	2011-06-22 23:09:17 UTC (rev 89491)
+++ trunk/Source/WebCore/ChangeLog	2011-06-22 23:18:57 UTC (rev 89492)
@@ -1,3 +1,20 @@
+2011-06-22  Annie Sullivan  <[email protected]>
+
+        Reviewed by Ryosuke Niwa.
+
+        REGRESSION: Hitting enter in the middle of this span causes the cursor to go to the end of the span
+        https://bugs.webkit.org/show_bug.cgi?id=61594
+
+        When the tree is split at the cursor in InsertParagraphSeparatorCommand, it is possible for the position
+        split at to be at the end of a text node. The code assumes the position is at the start of the node, so
+        pass the correct node into splitTreeToNode() in that case.
+
+        Tests: editing/inserting/return-key-before-br-in-span.html
+               editing/inserting/return-key-middle-of-span.html
+
+        * editing/InsertParagraphSeparatorCommand.cpp:
+        (WebCore::InsertParagraphSeparatorCommand::doApply):
+
 2011-06-22  Rob Buis  <[email protected]>
 
         Reviewed by Nikolas Zimmermann.

Modified: trunk/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp (89491 => 89492)


--- trunk/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp	2011-06-22 23:09:17 UTC (rev 89491)
+++ trunk/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp	2011-06-22 23:18:57 UTC (rev 89492)
@@ -356,7 +356,11 @@
         if (insertionPosition.containerNode() == startBlock)
             n = insertionPosition.computeNodeAfterPosition();
         else {
-            splitTreeToNode(insertionPosition.containerNode(), startBlock);
+            Node* splitTo = insertionPosition.containerNode();
+            if (splitTo->isTextNode() && insertionPosition.offsetInContainerNode() >= caretMaxOffset(splitTo))
+              splitTo = splitTo->traverseNextNode(startBlock);
+            ASSERT(splitTo);
+            splitTreeToNode(splitTo, startBlock);
 
             for (n = startBlock->firstChild(); n; n = n->nextSibling()) {
                 if (comparePositions(VisiblePosition(insertionPosition), positionBeforeNode(n)) <= 0)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to