Title: [152478] trunk
Revision
152478
Author
[email protected]
Date
2013-07-08 19:48:19 -0700 (Mon, 08 Jul 2013)

Log Message

DeleteSelectionCommand does not handle correctly deletion with two consecutive BR element.
https://bugs.webkit.org/show_bug.cgi?id=118457
<rdar://problem/14160912>

Reviewed by Simon Fraser.

Source/WebCore: 

In DeleteSelectionCommand::handleSpecialCareBRDelete we did not
handle correctly the case where we had <br><br> in the markup and
nothing was being deleted. We should consider this like
the case where the <br> is on the line by itself and remove it.

Test: editing/deleting/delete-image-followed-by-two-br.html

* editing/DeleteSelectionCommand.cpp:
(WebCore::DeleteSelectionCommand::handleSpecialCaseBRDelete):

LayoutTests: 

* editing/deleting/delete-image-followed-by-two-br-expected.txt: Added.
* editing/deleting/delete-image-followed-by-two-br.html: Added.
* platform/mac/editing/deleting/delete-br-002-expected.txt: Rebased.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (152477 => 152478)


--- trunk/LayoutTests/ChangeLog	2013-07-09 01:07:22 UTC (rev 152477)
+++ trunk/LayoutTests/ChangeLog	2013-07-09 02:48:19 UTC (rev 152478)
@@ -1,3 +1,15 @@
+2013-07-08  Enrica Casucci  <[email protected]>
+
+        DeleteSelectionCommand does not handle correctly deletion with two consecutive BR element.
+        https://bugs.webkit.org/show_bug.cgi?id=118457
+        <rdar://problem/14160912>
+
+        Reviewed by Simon Fraser.
+
+        * editing/deleting/delete-image-followed-by-two-br-expected.txt: Added.
+        * editing/deleting/delete-image-followed-by-two-br.html: Added.
+        * platform/mac/editing/deleting/delete-br-002-expected.txt: Rebased.
+
 2013-07-08  Alexey Proskuryakov  <[email protected]>
 
         [Mac] Multiple compositing/patterns test fail

Added: trunk/LayoutTests/editing/deleting/delete-image-followed-by-two-br-expected.txt (0 => 152478)


--- trunk/LayoutTests/editing/deleting/delete-image-followed-by-two-br-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/deleting/delete-image-followed-by-two-br-expected.txt	2013-07-09 02:48:19 UTC (rev 152478)
@@ -0,0 +1,4 @@
+We should be able to delete the br and then the image.
+| <br>
+| "This is a line of text.
+"

Added: trunk/LayoutTests/editing/deleting/delete-image-followed-by-two-br.html (0 => 152478)


--- trunk/LayoutTests/editing/deleting/delete-image-followed-by-two-br.html	                        (rev 0)
+++ trunk/LayoutTests/editing/deleting/delete-image-followed-by-two-br.html	2013-07-09 02:48:19 UTC (rev 152478)
@@ -0,0 +1,17 @@
+<script src=""
+<script src="" language="_javascript_" type="text/_javascript_" ></script>
+<script>
+    function editingTest() {
+        moveSelectionForwardByLineCommand();
+        deleteCommand();
+        deleteCommand();
+    }
+</script>
+<div contenteditable="true" id="test">
+    <img width="140" height="140"><br><br>This is a line of text.
+</div>
+<script>
+    runDumpAsTextEditingTest(false);
+    Markup.description("We should be able to delete the br and then the image.");
+    Markup.dump(document.getElementById("test"));
+</script>

Modified: trunk/LayoutTests/platform/mac/editing/deleting/delete-br-002-expected.txt (152477 => 152478)


--- trunk/LayoutTests/platform/mac/editing/deleting/delete-br-002-expected.txt	2013-07-09 01:07:22 UTC (rev 152477)
+++ trunk/LayoutTests/platform/mac/editing/deleting/delete-br-002-expected.txt	2013-07-09 02:48:19 UTC (rev 152478)
@@ -24,7 +24,6 @@
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: shouldDeleteDOMRange:range from 2 of SPAN > DIV > BODY > HTML > #document to 3 of SPAN > DIV > BODY > HTML > #document
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 3 of SPAN > DIV > BODY > HTML > #document to 3 of SPAN > DIV > BODY > HTML > #document toDOMRange:range from 2 of SPAN > DIV > BODY > HTML > #document to 2 of SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
 layer at (0,0) size 800x600

Modified: trunk/Source/WebCore/ChangeLog (152477 => 152478)


--- trunk/Source/WebCore/ChangeLog	2013-07-09 01:07:22 UTC (rev 152477)
+++ trunk/Source/WebCore/ChangeLog	2013-07-09 02:48:19 UTC (rev 152478)
@@ -1,3 +1,21 @@
+2013-07-08  Enrica Casucci  <[email protected]>
+
+        DeleteSelectionCommand does not handle correctly deletion with two consecutive BR element.
+        https://bugs.webkit.org/show_bug.cgi?id=118457
+        <rdar://problem/14160912>
+
+        Reviewed by Simon Fraser.
+
+        In DeleteSelectionCommand::handleSpecialCareBRDelete we did not
+        handle correctly the case where we had <br><br> in the markup and
+        nothing was being deleted. We should consider this like
+        the case where the <br> is on the line by itself and remove it.
+
+        Test: editing/deleting/delete-image-followed-by-two-br.html
+
+        * editing/DeleteSelectionCommand.cpp:
+        (WebCore::DeleteSelectionCommand::handleSpecialCaseBRDelete):
+
 2013-07-08  Radu Stavila  <[email protected]>
 
         NamedFlowCollection getters should return undefined when there's no NamedFlow

Modified: trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp (152477 => 152478)


--- trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp	2013-07-09 01:07:22 UTC (rev 152477)
+++ trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp	2013-07-09 02:48:19 UTC (rev 152478)
@@ -309,7 +309,10 @@
     // Check for special-case where the selection contains only a BR on a line by itself after another BR.
     bool upstreamStartIsBR = nodeAfterUpstreamStart->hasTagName(brTag);
     bool downstreamStartIsBR = nodeAfterDownstreamStart->hasTagName(brTag);
-    bool isBROnLineByItself = upstreamStartIsBR && downstreamStartIsBR && nodeAfterDownstreamStart == nodeAfterUpstreamEnd;
+    // We should consider that the BR is on a line by itself also when we have <br><br>. This test should be true only
+    // when the two elements are siblings and should be false in a case like <div><br></div><br>.
+    bool isBROnLineByItself = upstreamStartIsBR && downstreamStartIsBR && ((nodeAfterDownstreamStart == nodeAfterUpstreamEnd) || (nodeAfterUpstreamEnd && nodeAfterUpstreamEnd->hasTagName(brTag) && nodeAfterUpstreamStart->nextSibling() == nodeAfterUpstreamEnd));
+
     if (isBROnLineByItself) {
         removeNode(nodeAfterDownstreamStart);
         return true;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to