Diff
Modified: branches/safari-534.51-branch/LayoutTests/ChangeLog (91508 => 91509)
--- branches/safari-534.51-branch/LayoutTests/ChangeLog 2011-07-21 21:48:32 UTC (rev 91508)
+++ branches/safari-534.51-branch/LayoutTests/ChangeLog 2011-07-21 21:50:10 UTC (rev 91509)
@@ -1,5 +1,24 @@
2011-07-21 Lucas Forschler <[email protected]>
+ Merged 89492.
+
+ 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-07-21 Lucas Forschler <[email protected]>
+
Merged 89474.
2011-06-22 Matthew Delaney <[email protected]>
Copied: branches/safari-534.51-branch/LayoutTests/editing/inserting/return-key-before-br-in-span-expected.txt (from rev 89492, trunk/LayoutTests/editing/inserting/return-key-before-br-in-span-expected.txt) (0 => 91509)
--- branches/safari-534.51-branch/LayoutTests/editing/inserting/return-key-before-br-in-span-expected.txt (rev 0)
+++ branches/safari-534.51-branch/LayoutTests/editing/inserting/return-key-before-br-in-span-expected.txt 2011-07-21 21:50:10 UTC (rev 91509)
@@ -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"
Copied: branches/safari-534.51-branch/LayoutTests/editing/inserting/return-key-before-br-in-span.html (from rev 89492, trunk/LayoutTests/editing/inserting/return-key-before-br-in-span.html) (0 => 91509)
--- branches/safari-534.51-branch/LayoutTests/editing/inserting/return-key-before-br-in-span.html (rev 0)
+++ branches/safari-534.51-branch/LayoutTests/editing/inserting/return-key-before-br-in-span.html 2011-07-21 21:50:10 UTC (rev 91509)
@@ -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>
Copied: branches/safari-534.51-branch/LayoutTests/editing/inserting/return-key-middle-of-span-expected.txt (from rev 89492, trunk/LayoutTests/editing/inserting/return-key-middle-of-span-expected.txt) (0 => 91509)
--- branches/safari-534.51-branch/LayoutTests/editing/inserting/return-key-middle-of-span-expected.txt (rev 0)
+++ branches/safari-534.51-branch/LayoutTests/editing/inserting/return-key-middle-of-span-expected.txt 2011-07-21 21:50:10 UTC (rev 91509)
@@ -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"
Copied: branches/safari-534.51-branch/LayoutTests/editing/inserting/return-key-middle-of-span.html (from rev 89492, trunk/LayoutTests/editing/inserting/return-key-middle-of-span.html) (0 => 91509)
--- branches/safari-534.51-branch/LayoutTests/editing/inserting/return-key-middle-of-span.html (rev 0)
+++ branches/safari-534.51-branch/LayoutTests/editing/inserting/return-key-middle-of-span.html 2011-07-21 21:50:10 UTC (rev 91509)
@@ -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: branches/safari-534.51-branch/Source/WebCore/ChangeLog (91508 => 91509)
--- branches/safari-534.51-branch/Source/WebCore/ChangeLog 2011-07-21 21:48:32 UTC (rev 91508)
+++ branches/safari-534.51-branch/Source/WebCore/ChangeLog 2011-07-21 21:50:10 UTC (rev 91509)
@@ -1,5 +1,26 @@
2011-07-21 Lucas Forschler <[email protected]>
+ Merged 89492.
+
+ 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-07-21 Lucas Forschler <[email protected]>
+
Merged 89474.
2011-06-22 Matthew Delaney <[email protected]>
Modified: branches/safari-534.51-branch/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp (91508 => 91509)
--- branches/safari-534.51-branch/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp 2011-07-21 21:48:32 UTC (rev 91508)
+++ branches/safari-534.51-branch/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp 2011-07-21 21:50:10 UTC (rev 91509)
@@ -347,7 +347,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)