- Revision
- 91158
- Author
- [email protected]
- Date
- 2011-07-16 17:33:34 -0700 (Sat, 16 Jul 2011)
Log Message
REGRESSION: Pressing return in a particular document sends the cursor to the end of the document.
https://bugs.webkit.org/show_bug.cgi?id=64140
<rdar://problem/9737491>
Source/WebCore:
Inserting a paragraph separator at a break element, inside an inline, generates redundant markup
and moves the selection at the end of the inserted block.
The fix consists in detecting that the insertion point is a break element and simply inserting another
break element. This solves the problem of the wrong final selection and also produces less redundant
markup.
Reviewed by Simon Fraser.
Test: editing/inserting/insert-paragraph-separator-at-break.html
* editing/InsertParagraphSeparatorCommand.cpp:
(WebCore::InsertParagraphSeparatorCommand::doApply): Modified logic for insertion at a break
element.
LayoutTests:
Added new test to cover this case and updated results for one test that now
produces simpler markup.
Reviewed by Simon Fraser.
* editing/inserting/insert-paragraph-separator-at-break-expected.txt: Added.
* editing/inserting/insert-paragraph-separator-at-break.html: Added.
* platform/mac/editing/inserting/5058163-1-expected.txt:
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (91157 => 91158)
--- trunk/LayoutTests/ChangeLog 2011-07-16 23:29:29 UTC (rev 91157)
+++ trunk/LayoutTests/ChangeLog 2011-07-17 00:33:34 UTC (rev 91158)
@@ -1,3 +1,18 @@
+2011-07-16 Enrica Casucci <[email protected]>
+
+ REGRESSION: Pressing return in a particular document sends the cursor to the end of the document.
+ https://bugs.webkit.org/show_bug.cgi?id=64140
+ <rdar://problem/9737491>
+
+ Added new test to cover this case and updated results for one test that now
+ produces simpler markup.
+
+ Reviewed by Simon Fraser.
+
+ * editing/inserting/insert-paragraph-separator-at-break-expected.txt: Added.
+ * editing/inserting/insert-paragraph-separator-at-break.html: Added.
+ * platform/mac/editing/inserting/5058163-1-expected.txt:
+
2011-07-16 Sergey Glazunov <[email protected]>
DOMWindow::open performs a security check on a wrong window
Added: trunk/LayoutTests/editing/inserting/insert-paragraph-separator-at-break-expected.txt (0 => 91158)
--- trunk/LayoutTests/editing/inserting/insert-paragraph-separator-at-break-expected.txt (rev 0)
+++ trunk/LayoutTests/editing/inserting/insert-paragraph-separator-at-break-expected.txt 2011-07-17 00:33:34 UTC (rev 91158)
@@ -0,0 +1,14 @@
+This test ensures WebKit inserts only a break element when inserting a paragraph at a break element.
+Only one BR should be inserted in this test.
+
+After:
+| <b>
+| "place the cursor between these two lines"
+| <br>
+| <br>
+| <#selection-caret>
+| <br>
+| "and press return"
+| <br>
+| "
+"
Added: trunk/LayoutTests/editing/inserting/insert-paragraph-separator-at-break.html (0 => 91158)
--- trunk/LayoutTests/editing/inserting/insert-paragraph-separator-at-break.html (rev 0)
+++ trunk/LayoutTests/editing/inserting/insert-paragraph-separator-at-break.html 2011-07-17 00:33:34 UTC (rev 91158)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div contenteditable id="test"><b>place the cursor between these two lines<br><br>and press return</b><br>
+</div>
+<script src=""
+<script>
+
+Markup.description('This test ensures WebKit inserts only a break element when inserting a paragraph at a break element.\n'+
+ 'Only one BR should be inserted in this test.');
+
+var elem = document.getElementById('test');
+window.getSelection().setPosition(elem.firstChild, 2);
+document.execCommand("InsertParagraph");
+Markup.dump(elem, "After");
+
+</script>
+</body>
+</html>
Modified: trunk/LayoutTests/platform/mac/editing/inserting/5058163-1-expected.txt (91157 => 91158)
--- trunk/LayoutTests/platform/mac/editing/inserting/5058163-1-expected.txt 2011-07-16 23:29:29 UTC (rev 91157)
+++ trunk/LayoutTests/platform/mac/editing/inserting/5058163-1-expected.txt 2011-07-17 00:33:34 UTC (rev 91158)
@@ -13,15 +13,13 @@
RenderTableCell {TD} at (2,2) size 469x20 [r=0 c=0 rs=1 cs=1]
RenderText {#text} at (1,1) size 467x18
text run at (1,1) width 467: "There should be two empty paragraphs after this table and before the next."
- RenderBlock (anonymous) at (0,26) size 784x18
+ RenderBlock (anonymous) at (0,26) size 784x36
RenderBR {BR} at (0,0) size 0x18
- RenderBlock {DIV} at (0,44) size 784x44
- RenderBlock (anonymous) at (0,0) size 784x18
- RenderBR {BR} at (0,0) size 0x18
- RenderTable {TABLE} at (0,18) size 276x26 [border: (1px solid #AAAAAA)]
- RenderTableSection {TBODY} at (1,1) size 274x24
- RenderTableRow {TR} at (0,2) size 274x20
- RenderTableCell {TD} at (2,2) size 270x20 [r=0 c=0 rs=1 cs=1]
- RenderText {#text} at (1,1) size 268x18
- text run at (1,1) width 268: "And the caret should be in the second one."
-caret: position 0 of child 0 {BR} of child 2 {DIV} of child 2 {DIV} of body
+ RenderBR {BR} at (0,18) size 0x18
+ RenderTable {TABLE} at (0,62) size 276x26 [border: (1px solid #AAAAAA)]
+ RenderTableSection {TBODY} at (1,1) size 274x24
+ RenderTableRow {TR} at (0,2) size 274x20
+ RenderTableCell {TD} at (2,2) size 270x20 [r=0 c=0 rs=1 cs=1]
+ RenderText {#text} at (1,1) size 268x18
+ text run at (1,1) width 268: "And the caret should be in the second one."
+caret: position 0 of child 2 {BR} of child 2 {DIV} of body
Modified: trunk/Source/WebCore/ChangeLog (91157 => 91158)
--- trunk/Source/WebCore/ChangeLog 2011-07-16 23:29:29 UTC (rev 91157)
+++ trunk/Source/WebCore/ChangeLog 2011-07-17 00:33:34 UTC (rev 91158)
@@ -1,3 +1,23 @@
+2011-07-16 Enrica Casucci <[email protected]>
+
+ REGRESSION: Pressing return in a particular document sends the cursor to the end of the document.
+ https://bugs.webkit.org/show_bug.cgi?id=64140
+ <rdar://problem/9737491>
+
+ Inserting a paragraph separator at a break element, inside an inline, generates redundant markup
+ and moves the selection at the end of the inserted block.
+ The fix consists in detecting that the insertion point is a break element and simply inserting another
+ break element. This solves the problem of the wrong final selection and also produces less redundant
+ markup.
+
+ Reviewed by Simon Fraser.
+
+ Test: editing/inserting/insert-paragraph-separator-at-break.html
+
+ * editing/InsertParagraphSeparatorCommand.cpp:
+ (WebCore::InsertParagraphSeparatorCommand::doApply): Modified logic for insertion at a break
+ element.
+
2011-07-16 Pratik Solanki <[email protected]>
SubresourceLoader::didReceiveDataArray can crash when calling m_client->didReceiveData()
Modified: trunk/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp (91157 => 91158)
--- trunk/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp 2011-07-16 23:29:29 UTC (rev 91157)
+++ trunk/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp 2011-07-17 00:33:34 UTC (rev 91158)
@@ -302,6 +302,12 @@
RefPtr<Element> br = createBreakElement(document());
insertNodeAt(br.get(), insertionPosition);
insertionPosition = positionInParentAfterNode(br.get());
+ // If the insertion point is a break element, there is nothing else
+ // we need to do.
+ if (visiblePos.deepEquivalent().anchorNode()->renderer()->isBR()) {
+ setEndingSelection(VisibleSelection(insertionPosition, DOWNSTREAM));
+ return;
+ }
}
// Move downstream. Typing style code will take care of carrying along the