Title: [112444] trunk
Revision
112444
Author
[email protected]
Date
2012-03-28 14:41:34 -0700 (Wed, 28 Mar 2012)

Log Message

Deleting a paragraph of text should not add elements for typing style
https://bugs.webkit.org/show_bug.cgi?id=82401

Reviewed by Enrica Casucci.

Source/WebCore: 

This behavior was explicitly supported by DeleteSelectionCommand but it doesn't match TextEdit or Firefox.
We're changing our behavior to match TextEdit and Firefox in this patch.

The behavior is tested by an existing test, which was renamed to deleting-text-rests-typing-style.html in this patch.

Test: editing/execCommand/deleting-text-rests-typing-style.html

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

LayoutTests: 

Rebaselined the tests per behavior changes. Also renamed 19653-3.html to deleting-text-rests-typing-style.html
which tests this behavioral change.

* editing/deleting/delete-and-cleanup-expected.txt:
* editing/deleting/delete-and-cleanup.html: Elements added for typing styles have been removed.
* editing/deleting/delete-br-012-expected.txt: Ditto.
* editing/deleting/delete-select-all-001-expected.txt: Ditto.
* editing/execCommand/19653-3-expected.txt: Removed.
* editing/execCommand/19653-3.html: Removed.
* editing/execCommand/apply-style-text-decoration-crash-expected.txt:
* editing/execCommand/delete-image-in-anchor-expected.txt: Ditto.
* editing/execCommand/deleting-text-rests-typing-style-expected.txt: Copied from LayoutTests/editing/execCommand/19653-3-expected.txt.
* editing/execCommand/deleting-text-rests-typing-style.html: Copied from LayoutTests/editing/execCommand/19653-3.html.
* editing/inserting/5994480-2-expected.txt:
* editing/inserting/5994480-2.html: Ditto; converted this test to a dump-as-markup test for clarity.
* editing/pasteboard/paste-text-with-style-2-expected.txt: Elements added for typing styles have been removed.
* editing/style/block-style-005-expected.txt:  Ditto.
* editing/pasteboard/select-element-1-expected.txt: Editing delegate dump changed but the final result remains intact.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (112443 => 112444)


--- trunk/LayoutTests/ChangeLog	2012-03-28 21:33:16 UTC (rev 112443)
+++ trunk/LayoutTests/ChangeLog	2012-03-28 21:41:34 UTC (rev 112444)
@@ -1,3 +1,29 @@
+2012-03-27  Ryosuke Niwa  <[email protected]>
+
+        Deleting a paragraph of text should not add elements for typing style
+        https://bugs.webkit.org/show_bug.cgi?id=82401
+
+        Reviewed by Enrica Casucci.
+
+        Rebaselined the tests per behavior changes. Also renamed 19653-3.html to deleting-text-rests-typing-style.html
+        which tests this behavioral change.
+
+        * editing/deleting/delete-and-cleanup-expected.txt:
+        * editing/deleting/delete-and-cleanup.html: Elements added for typing styles have been removed.
+        * editing/deleting/delete-br-012-expected.txt: Ditto.
+        * editing/deleting/delete-select-all-001-expected.txt: Ditto.
+        * editing/execCommand/19653-3-expected.txt: Removed.
+        * editing/execCommand/19653-3.html: Removed.
+        * editing/execCommand/apply-style-text-decoration-crash-expected.txt:
+        * editing/execCommand/delete-image-in-anchor-expected.txt: Ditto.
+        * editing/execCommand/deleting-text-rests-typing-style-expected.txt: Copied from LayoutTests/editing/execCommand/19653-3-expected.txt.
+        * editing/execCommand/deleting-text-rests-typing-style.html: Copied from LayoutTests/editing/execCommand/19653-3.html.
+        * editing/inserting/5994480-2-expected.txt:
+        * editing/inserting/5994480-2.html: Ditto; converted this test to a dump-as-markup test for clarity.
+        * editing/pasteboard/paste-text-with-style-2-expected.txt: Elements added for typing styles have been removed.
+        * editing/style/block-style-005-expected.txt:  Ditto.
+        * editing/pasteboard/select-element-1-expected.txt: Editing delegate dump changed but the final result remains intact.
+
 2012-03-28  Ojan Vafai  <[email protected]>
 
         More Chromium rebaselines from the expected failures tab in garden-o-matic.

Modified: trunk/LayoutTests/editing/deleting/delete-and-cleanup-expected.txt (112443 => 112444)


--- trunk/LayoutTests/editing/deleting/delete-and-cleanup-expected.txt	2012-03-28 21:33:16 UTC (rev 112443)
+++ trunk/LayoutTests/editing/deleting/delete-and-cleanup-expected.txt	2012-03-28 21:41:34 UTC (rev 112444)
@@ -4,8 +4,8 @@
 PASS confirmedMarkup is '<br>'
 PASS confirmedMarkup is '<div id="mydiv"><br></div>'
 PASS confirmedMarkup is '<br>'
-PASS confirmedMarkup is '<b><i><br></i></b>'
-PASS confirmedMarkup is '<b><div style="border: solid red"><i><br></i></div></b>'
+PASS confirmedMarkup is '<b><br></b>'
+PASS confirmedMarkup is '<b><div style="border: solid red"><br></div></b>'
 PASS confirmedMarkup is '<br>'
 PASS confirmedMarkup is '<br>'
 PASS confirmedMarkup is '<p><br></p>'

Modified: trunk/LayoutTests/editing/deleting/delete-and-cleanup.html (112443 => 112444)


--- trunk/LayoutTests/editing/deleting/delete-and-cleanup.html	2012-03-28 21:33:16 UTC (rev 112443)
+++ trunk/LayoutTests/editing/deleting/delete-and-cleanup.html	2012-03-28 21:41:34 UTC (rev 112444)
@@ -37,8 +37,8 @@
 testDelete("div", "<div>Hello</div>", "<br>");
 testDelete("div", "<div id=\"mydiv\">Hello</div>", "<div id=\"mydiv\"><br></div>");
 testDelete("div", "<div><div>Hello</div></div>", "<br>");
-testDelete("div", "<div><b><div><i>Hello</i></div></b></div>", "<b><i><br></i></b>");
-testDelete("div", "<div><b><div style=\"border: solid red\"><i>Hello</i></div></b></div>", "<b><div style=\"border: solid red\"><i><br></i></div></b>");
+testDelete("div", "<div><b><div><i>Hello</i></div></b></div>", "<b><br></b>");
+testDelete("div", "<div><b><div style=\"border: solid red\"><i>Hello</i></div></b></div>", "<b><div style=\"border: solid red\"><br></div></b>");
 testDelete("div", "<div>Hello</div><div>world</div>", "<br>");
 testDelete("div", "<div>Hello</div><div>world</div>", "<br>");
 testDelete("div", "<div><p>Hello</p></div><p>world</p></div>", "<p><br></p>");

Modified: trunk/LayoutTests/editing/deleting/delete-br-012-expected.txt (112443 => 112444)


--- trunk/LayoutTests/editing/deleting/delete-br-012-expected.txt	2012-03-28 21:33:16 UTC (rev 112443)
+++ trunk/LayoutTests/editing/deleting/delete-br-012-expected.txt	2012-03-28 21:41:34 UTC (rev 112444)
@@ -15,10 +15,8 @@
 | <div>
 |   id="test"
 |   style="border-style:solid; border-color:blue;"
-|   <font>
-|     size="5"
-|     <#selection-caret>
-|     <br>
+|   <#selection-caret>
+|   <br>
 |   "
 "
 | "

Modified: trunk/LayoutTests/editing/deleting/delete-select-all-001-expected.txt (112443 => 112444)


--- trunk/LayoutTests/editing/deleting/delete-select-all-001-expected.txt	2012-03-28 21:33:16 UTC (rev 112443)
+++ trunk/LayoutTests/editing/deleting/delete-select-all-001-expected.txt	2012-03-28 21:41:34 UTC (rev 112444)
@@ -1,2 +1,2 @@
 
-execDeleteCommand: <font size="3"><br></font>
+execDeleteCommand: <br>

Deleted: trunk/LayoutTests/editing/execCommand/19653-3-expected.txt (112443 => 112444)


--- trunk/LayoutTests/editing/execCommand/19653-3-expected.txt	2012-03-28 21:33:16 UTC (rev 112443)
+++ trunk/LayoutTests/editing/execCommand/19653-3-expected.txt	2012-03-28 21:41:34 UTC (rev 112444)
@@ -1,2 +0,0 @@
-This tests deleting a Bold paragraph, then changing the selection and moving it back to the spot where that paragraph was deleted and typing more. The new text should be Bold, too.
-<div id="one"><b>Bold</b></div><div id="two"><br></div>

Deleted: trunk/LayoutTests/editing/execCommand/19653-3.html (112443 => 112444)


--- trunk/LayoutTests/editing/execCommand/19653-3.html	2012-03-28 21:33:16 UTC (rev 112443)
+++ trunk/LayoutTests/editing/execCommand/19653-3.html	2012-03-28 21:41:34 UTC (rev 112444)
@@ -1,18 +0,0 @@
-<div id="description1">This tests deleting a Bold paragraph, then changing the selection and moving it back to the spot where that paragraph was deleted and typing more. The new text should be Bold, too.</div>
-<div id="edit1" contentEditable="true"><div id="one"><b>Bold</b><br></div><div id="two"><br></div></div>
-
-<script>
-if (window.layoutTestController)
-    window.layoutTestController.dumpAsText();
-_one_ = document.getElementById("one");
-window.getSelection().setBaseAndExtent(one, 0, one, one.childNodes.length);
-document.execCommand("Delete");
-
-window.getSelection().modify("move", "forward", "character");
-window.getSelection().modify("move", "backward", "character");
-
-document.execCommand("InsertText", false, "Bold");
-
-if (window.layoutTestController)
-    document.body.innerText = document.getElementById("description1").innerText + "\n" + edit1.innerHTML;
-</script>

Modified: trunk/LayoutTests/editing/execCommand/apply-style-text-decoration-crash-expected.txt (112443 => 112444)


--- trunk/LayoutTests/editing/execCommand/apply-style-text-decoration-crash-expected.txt	2012-03-28 21:33:16 UTC (rev 112443)
+++ trunk/LayoutTests/editing/execCommand/apply-style-text-decoration-crash-expected.txt	2012-03-28 21:41:34 UTC (rev 112444)
@@ -1,4 +1,3 @@
 PASS
 
 
-

Modified: trunk/LayoutTests/editing/execCommand/delete-image-in-anchor-expected.txt (112443 => 112444)


--- trunk/LayoutTests/editing/execCommand/delete-image-in-anchor-expected.txt	2012-03-28 21:33:16 UTC (rev 112443)
+++ trunk/LayoutTests/editing/execCommand/delete-image-in-anchor-expected.txt	2012-03-28 21:41:34 UTC (rev 112444)
@@ -1,4 +1,4 @@
 
 
 BEFORE: <a href="" style="display:block; margin:0px auto 10px; text-align:center;width: 60px; height: 60px;" src="" border="0"></a> <br>
-AFTER: <div style="text-align: center;"><font color="#0000ee"><u><br></u></font></div> <br>
+AFTER: <a href="" <br>

Copied: trunk/LayoutTests/editing/execCommand/deleting-text-rests-typing-style-expected.txt (from rev 112320, trunk/LayoutTests/editing/execCommand/19653-3-expected.txt) (0 => 112444)


--- trunk/LayoutTests/editing/execCommand/deleting-text-rests-typing-style-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/execCommand/deleting-text-rests-typing-style-expected.txt	2012-03-28 21:41:34 UTC (rev 112444)
@@ -0,0 +1,8 @@
+This tests deleting a bold paragraph, then changing the selection and moving it back to the spot
+where that paragraph was deleted and typing more. The new test should not be bolded.
+| <div>
+|   id="one"
+|   "Not bold<#selection-caret>"
+| <div>
+|   id="two"
+|   <br>

Copied: trunk/LayoutTests/editing/execCommand/deleting-text-rests-typing-style.html (from rev 112320, trunk/LayoutTests/editing/execCommand/19653-3.html) (0 => 112444)


--- trunk/LayoutTests/editing/execCommand/deleting-text-rests-typing-style.html	                        (rev 0)
+++ trunk/LayoutTests/editing/execCommand/deleting-text-rests-typing-style.html	2012-03-28 21:41:34 UTC (rev 112444)
@@ -0,0 +1,18 @@
+<div id="description">This tests deleting a bold paragraph, then changing the selection and moving it back to the spot
+where that paragraph was deleted and typing more. The new test should not be bolded.</div>
+<div id="edit1" contentEditable="true"><div id="one"><b>Bold</b><br></div><div id="two"><br></div></div>
+<script src=""
+<script>
+Markup.description(document.getElementById('description').textContent);
+
+_one_ = document.getElementById("one");
+window.getSelection().setBaseAndExtent(one, 0, one, one.childNodes.length);
+document.execCommand("Delete");
+
+window.getSelection().modify("move", "forward", "character");
+window.getSelection().modify("move", "backward", "character");
+
+document.execCommand("InsertText", false, "Not bold");
+
+Markup.dump(document.getElementById('edit1'));
+</script>

Modified: trunk/LayoutTests/editing/inserting/5994480-2-expected.txt (112443 => 112444)


--- trunk/LayoutTests/editing/inserting/5994480-2-expected.txt	2012-03-28 21:33:16 UTC (rev 112443)
+++ trunk/LayoutTests/editing/inserting/5994480-2-expected.txt	2012-03-28 21:41:34 UTC (rev 112444)
@@ -1 +1,3 @@
-<font face="Lucida Grande"><span style="font-size: 11px;"><br></span></font>
+This tests to see if deleting an input element that starts at the start of a block adds an extra placeholder.
+You should see a single placeholder in the block below.
+| <br>

Modified: trunk/LayoutTests/editing/inserting/5994480-2.html (112443 => 112444)


--- trunk/LayoutTests/editing/inserting/5994480-2.html	2012-03-28 21:33:16 UTC (rev 112443)
+++ trunk/LayoutTests/editing/inserting/5994480-2.html	2012-03-28 21:41:34 UTC (rev 112444)
@@ -1,13 +1,15 @@
-<div id="description">This tests to see if deleting an input element that starts at the start of a block adds an extra placeholder.  You should see a single placeholder in the block below.</div>
+<div id="description">This tests to see if deleting an input element that starts at the start of a block adds an extra placeholder.
+You should see a single placeholder in the block below.</div>
 <div id="edit" contentEditable="true"><input type="text"><br></div>
+<script src=""
 <script>
-if (window.layoutTestController)
-    window.layoutTestController.dumpAsText();
+Markup.description(document.getElementById('description').textContent);
+
 edit = document.getElementById("edit");
 edit.focus();
 
 document.execCommand("SelectAll");
 document.execCommand("Delete");
-if (window.layoutTestController)
-    document.body.innerText = edit.innerHTML;
+
+Markup.dump('edit');
 </script>

Modified: trunk/LayoutTests/editing/pasteboard/paste-text-with-style-2-expected.txt (112443 => 112444)


--- trunk/LayoutTests/editing/pasteboard/paste-text-with-style-2-expected.txt	2012-03-28 21:33:16 UTC (rev 112443)
+++ trunk/LayoutTests/editing/pasteboard/paste-text-with-style-2-expected.txt	2012-03-28 21:41:34 UTC (rev 112444)
@@ -16,9 +16,4 @@
 |       <font>
 |         color="red"
 |         "hello world<#selection-caret>"
-| <font>
-|   color="#ff0000"
-|   <b>
-|     <i>
-|       <u>
-|         <br>
+| <br>

Modified: trunk/LayoutTests/editing/pasteboard/select-element-1-expected.txt (112443 => 112444)


--- trunk/LayoutTests/editing/pasteboard/select-element-1-expected.txt	2012-03-28 21:33:16 UTC (rev 112443)
+++ trunk/LayoutTests/editing/pasteboard/select-element-1-expected.txt	2012-03-28 21:41:34 UTC (rev 112444)
@@ -5,7 +5,7 @@
 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 1 of DIV > BODY > HTML > #document to 2 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: shouldDeleteDOMRange:range from 1 of DIV > BODY > HTML > #document to 2 of DIV > BODY > HTML > #document
-EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of SPAN > FONT > DIV > BODY > HTML > #document to 1 of SPAN > FONT > DIV > BODY > HTML > #document toDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document toDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
 EDITING DELEGATE: shouldEndEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document

Modified: trunk/LayoutTests/editing/style/block-style-005-expected.txt (112443 => 112444)


--- trunk/LayoutTests/editing/style/block-style-005-expected.txt	2012-03-28 21:33:16 UTC (rev 112443)
+++ trunk/LayoutTests/editing/style/block-style-005-expected.txt	2012-03-28 21:41:34 UTC (rev 112444)
@@ -6,4 +6,4 @@
 execInsertParagraphCommand: <div id="test" class="editing">x</div><div id="test" class="editing"><br></div><div id="test" class="editing"><br></div>
 execTypeCharacterCommand: <div id="test" class="editing">x</div><div id="test" class="editing"><br></div><div id="test" class="editing">x</div>
 execFontSizeCommand: <div id="test" class="editing"><font size="7">x</font></div><div id="test" class="editing"><font size="7"><br></font></div><div id="test" class="editing"><font size="7">x</font></div>
-execDeleteCommand: <div id="test" class="editing"><font size="7">x</font></div><div id="test" class="editing"><font size="7"><br></font></div><div id="test" class="editing"><font size="7"><br></font></div>
+execDeleteCommand: <div id="test" class="editing"><font size="7">x</font></div><div id="test" class="editing"><font size="7"><br></font></div><div id="test" class="editing"><br></div>

Deleted: trunk/LayoutTests/platform/chromium-win/editing/inserting/5994480-2-expected.txt (112443 => 112444)


--- trunk/LayoutTests/platform/chromium-win/editing/inserting/5994480-2-expected.txt	2012-03-28 21:33:16 UTC (rev 112443)
+++ trunk/LayoutTests/platform/chromium-win/editing/inserting/5994480-2-expected.txt	2012-03-28 21:41:34 UTC (rev 112444)
@@ -1 +0,0 @@
-<font face="Arial" size="2"><br></font>

Deleted: trunk/LayoutTests/platform/gtk/editing/inserting/5994480-2-expected.txt (112443 => 112444)


--- trunk/LayoutTests/platform/gtk/editing/inserting/5994480-2-expected.txt	2012-03-28 21:33:16 UTC (rev 112443)
+++ trunk/LayoutTests/platform/gtk/editing/inserting/5994480-2-expected.txt	2012-03-28 21:41:34 UTC (rev 112444)
@@ -1 +0,0 @@
-<font face="Liberation Sans"><br></font>

Modified: trunk/Source/WebCore/ChangeLog (112443 => 112444)


--- trunk/Source/WebCore/ChangeLog	2012-03-28 21:33:16 UTC (rev 112443)
+++ trunk/Source/WebCore/ChangeLog	2012-03-28 21:41:34 UTC (rev 112444)
@@ -1,3 +1,20 @@
+2012-03-27  Ryosuke Niwa  <[email protected]>
+
+        Deleting a paragraph of text should not add elements for typing style
+        https://bugs.webkit.org/show_bug.cgi?id=82401
+
+        Reviewed by Enrica Casucci.
+
+        This behavior was explicitly supported by DeleteSelectionCommand but it doesn't match TextEdit or Firefox.
+        We're changing our behavior to match TextEdit and Firefox in this patch.
+
+        The behavior is tested by an existing test, which was renamed to deleting-text-rests-typing-style.html in this patch.
+
+        Test: editing/execCommand/deleting-text-rests-typing-style.html
+
+        * editing/DeleteSelectionCommand.cpp:
+        (WebCore::DeleteSelectionCommand::calculateTypingStyleAfterDelete):
+
 2012-03-28  Michal Mocny  <[email protected]>
 
         [chromium] Add tracing events around CCLayerTreeHostImpl visibility.

Modified: trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp (112443 => 112444)


--- trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp	2012-03-28 21:33:16 UTC (rev 112443)
+++ trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp	2012-03-28 21:41:34 UTC (rev 112444)
@@ -688,23 +688,6 @@
     m_typingStyle->prepareToApplyAt(m_endingPosition);
     if (m_typingStyle->isEmpty())
         m_typingStyle = 0;
-    VisiblePosition visibleEnd(m_endingPosition);
-    if (m_typingStyle && 
-        isStartOfParagraph(visibleEnd) &&
-        isEndOfParagraph(visibleEnd) &&
-        lineBreakExistsAtVisiblePosition(visibleEnd)) {
-        // Apply style to the placeholder that is now holding open the empty paragraph. 
-        // This makes sure that the paragraph has the right height, and that the paragraph 
-        // takes on the right style and retains it even if you move the selection away and
-        // then move it back (which will clear typing style).
-
-        setEndingSelection(visibleEnd);
-        applyStyle(m_typingStyle.get(), EditActionUnspecified);
-        // applyStyle can destroy the placeholder that was at m_endingPosition if it needs to 
-        // move it, but it will set an endingSelection() at [movedPlaceholder, 0] if it does so.
-        m_endingPosition = endingSelection().start();
-        m_typingStyle = 0;
-    }
     // This is where we've deleted all traces of a style but not a whole paragraph (that's handled above).
     // In this case if we start typing, the new characters should have the same style as the just deleted ones,
     // but, if we change the selection, come back and start typing that style should be lost.  Also see 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to