Changeset 112444 in webkit


Ignore:
Timestamp:
Mar 28, 2012 2:41:34 PM (12 years ago)
Author:
rniwa@webkit.org
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.
Location:
trunk
Files:
2 deleted
14 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r112441 r112444  
     12012-03-27  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Deleting a paragraph of text should not add elements for typing style
     4        https://bugs.webkit.org/show_bug.cgi?id=82401
     5
     6        Reviewed by Enrica Casucci.
     7
     8        Rebaselined the tests per behavior changes. Also renamed 19653-3.html to deleting-text-rests-typing-style.html
     9        which tests this behavioral change.
     10
     11        * editing/deleting/delete-and-cleanup-expected.txt:
     12        * editing/deleting/delete-and-cleanup.html: Elements added for typing styles have been removed.
     13        * editing/deleting/delete-br-012-expected.txt: Ditto.
     14        * editing/deleting/delete-select-all-001-expected.txt: Ditto.
     15        * editing/execCommand/19653-3-expected.txt: Removed.
     16        * editing/execCommand/19653-3.html: Removed.
     17        * editing/execCommand/apply-style-text-decoration-crash-expected.txt:
     18        * editing/execCommand/delete-image-in-anchor-expected.txt: Ditto.
     19        * editing/execCommand/deleting-text-rests-typing-style-expected.txt: Copied from LayoutTests/editing/execCommand/19653-3-expected.txt.
     20        * editing/execCommand/deleting-text-rests-typing-style.html: Copied from LayoutTests/editing/execCommand/19653-3.html.
     21        * editing/inserting/5994480-2-expected.txt:
     22        * editing/inserting/5994480-2.html: Ditto; converted this test to a dump-as-markup test for clarity.
     23        * editing/pasteboard/paste-text-with-style-2-expected.txt: Elements added for typing styles have been removed.
     24        * editing/style/block-style-005-expected.txt:  Ditto.
     25        * editing/pasteboard/select-element-1-expected.txt: Editing delegate dump changed but the final result remains intact.
     26
    1272012-03-28  Ojan Vafai  <ojan@chromium.org>
    228
  • trunk/LayoutTests/editing/deleting/delete-and-cleanup-expected.txt

    r101629 r112444  
    55PASS confirmedMarkup is '<div id="mydiv"><br></div>'
    66PASS confirmedMarkup is '<br>'
    7 PASS confirmedMarkup is '<b><i><br></i></b>'
    8 PASS confirmedMarkup is '<b><div style="border: solid red"><i><br></i></div></b>'
     7PASS confirmedMarkup is '<b><br></b>'
     8PASS confirmedMarkup is '<b><div style="border: solid red"><br></div></b>'
    99PASS confirmedMarkup is '<br>'
    1010PASS confirmedMarkup is '<br>'
  • trunk/LayoutTests/editing/deleting/delete-and-cleanup.html

    r101622 r112444  
    3838testDelete("div", "<div id=\"mydiv\">Hello</div>", "<div id=\"mydiv\"><br></div>");
    3939testDelete("div", "<div><div>Hello</div></div>", "<br>");
    40 testDelete("div", "<div><b><div><i>Hello</i></div></b></div>", "<b><i><br></i></b>");
    41 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>");
     40testDelete("div", "<div><b><div><i>Hello</i></div></b></div>", "<b><br></b>");
     41testDelete("div", "<div><b><div style=\"border: solid red\"><i>Hello</i></div></b></div>", "<b><div style=\"border: solid red\"><br></div></b>");
    4242testDelete("div", "<div>Hello</div><div>world</div>", "<br>");
    4343testDelete("div", "<div>Hello</div><div>world</div>", "<br>");
  • trunk/LayoutTests/editing/deleting/delete-br-012-expected.txt

    r93001 r112444  
    1616|   id="test"
    1717|   style="border-style:solid; border-color:blue;"
    18 |   <font>
    19 |     size="5"
    20 |     <#selection-caret>
    21 |     <br>
     18|   <#selection-caret>
     19|   <br>
    2220|   "
    2321"
  • trunk/LayoutTests/editing/deleting/delete-select-all-001-expected.txt

    r93001 r112444  
    11
    2 execDeleteCommand: <font size="3"><br></font>
     2execDeleteCommand: <br>
  • trunk/LayoutTests/editing/execCommand/apply-style-text-decoration-crash-expected.txt

    r67967 r112444  
    22
    33
    4 
  • trunk/LayoutTests/editing/execCommand/delete-image-in-anchor-expected.txt

    r93001 r112444  
    22
    33BEFORE: <a href="../resources/abe.png"><img style="display:block; margin:0px auto 10px; text-align:center;width: 60px; height: 60px;" src="../resources/abe.png" border="0"></a> <br>
    4 AFTER: <div style="text-align: center;"><font color="#0000ee"><u><br></u></font></div> <br>
     4AFTER: <a href="../resources/abe.png"><br></a> <br>
  • trunk/LayoutTests/editing/execCommand/deleting-text-rests-typing-style-expected.txt

    r112320 r112444  
    1 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.
    2 <div id="one"><b>Bold</b></div><div id="two"><br></div>
     1This tests deleting a bold paragraph, then changing the selection and moving it back to the spot
     2where that paragraph was deleted and typing more. The new test should not be bolded.
     3| <div>
     4|   id="one"
     5|   "Not bold<#selection-caret>"
     6| <div>
     7|   id="two"
     8|   <br>
  • trunk/LayoutTests/editing/execCommand/deleting-text-rests-typing-style.html

    r112320 r112444  
    1 <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>
     1<div id="description">This tests deleting a bold paragraph, then changing the selection and moving it back to the spot
     2where that paragraph was deleted and typing more. The new test should not be bolded.</div>
    23<div id="edit1" contentEditable="true"><div id="one"><b>Bold</b><br></div><div id="two"><br></div></div>
     4<script src="../../resources/dump-as-markup.js"></script>
     5<script>
     6Markup.description(document.getElementById('description').textContent);
    37
    4 <script>
    5 if (window.layoutTestController)
    6     window.layoutTestController.dumpAsText();
    78one = document.getElementById("one");
    89window.getSelection().setBaseAndExtent(one, 0, one, one.childNodes.length);
     
    1213window.getSelection().modify("move", "backward", "character");
    1314
    14 document.execCommand("InsertText", false, "Bold");
     15document.execCommand("InsertText", false, "Not bold");
    1516
    16 if (window.layoutTestController)
    17     document.body.innerText = document.getElementById("description1").innerText + "\n" + edit1.innerHTML;
     17Markup.dump(document.getElementById('edit1'));
    1818</script>
  • trunk/LayoutTests/editing/inserting/5994480-2-expected.txt

    r109397 r112444  
    1 <font face="Lucida Grande"><span style="font-size: 11px;"><br></span></font>
     1This tests to see if deleting an input element that starts at the start of a block adds an extra placeholder.
     2You should see a single placeholder in the block below.
     3| <br>
  • trunk/LayoutTests/editing/inserting/5994480-2.html

    r34799 r112444  
    1 <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>
     1<div id="description">This tests to see if deleting an input element that starts at the start of a block adds an extra placeholder.
     2You should see a single placeholder in the block below.</div>
    23<div id="edit" contentEditable="true"><input type="text"><br></div>
     4<script src="../../resources/dump-as-markup.js"></script>
    35<script>
    4 if (window.layoutTestController)
    5     window.layoutTestController.dumpAsText();
     6Markup.description(document.getElementById('description').textContent);
     7
    68edit = document.getElementById("edit");
    79edit.focus();
     
    911document.execCommand("SelectAll");
    1012document.execCommand("Delete");
    11 if (window.layoutTestController)
    12     document.body.innerText = edit.innerHTML;
     13
     14Markup.dump('edit');
    1315</script>
  • trunk/LayoutTests/editing/pasteboard/paste-text-with-style-2-expected.txt

    r93001 r112444  
    1717|         color="red"
    1818|         "hello world<#selection-caret>"
    19 | <font>
    20 |   color="#ff0000"
    21 |   <b>
    22 |     <i>
    23 |       <u>
    24 |         <br>
     19| <br>
  • trunk/LayoutTests/editing/pasteboard/select-element-1-expected.txt

    r96264 r112444  
    66EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    77EDITING DELEGATE: shouldDeleteDOMRange:range from 1 of DIV > BODY > HTML > #document to 2 of DIV > BODY > HTML > #document
    8 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
     8EDITING 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
    99EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    1010EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
  • trunk/LayoutTests/editing/style/block-style-005-expected.txt

    r93001 r112444  
    77execTypeCharacterCommand: <div id="test" class="editing">x</div><div id="test" class="editing"><br></div><div id="test" class="editing">x</div>
    88execFontSizeCommand: <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>
    9 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>
     9execDeleteCommand: <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>
  • trunk/Source/WebCore/ChangeLog

    r112439 r112444  
     12012-03-27  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Deleting a paragraph of text should not add elements for typing style
     4        https://bugs.webkit.org/show_bug.cgi?id=82401
     5
     6        Reviewed by Enrica Casucci.
     7
     8        This behavior was explicitly supported by DeleteSelectionCommand but it doesn't match TextEdit or Firefox.
     9        We're changing our behavior to match TextEdit and Firefox in this patch.
     10
     11        The behavior is tested by an existing test, which was renamed to deleting-text-rests-typing-style.html in this patch.
     12
     13        Test: editing/execCommand/deleting-text-rests-typing-style.html
     14
     15        * editing/DeleteSelectionCommand.cpp:
     16        (WebCore::DeleteSelectionCommand::calculateTypingStyleAfterDelete):
     17
    1182012-03-28  Michal Mocny  <mmocny@google.com>
    219
  • trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp

    r109818 r112444  
    689689    if (m_typingStyle->isEmpty())
    690690        m_typingStyle = 0;
    691     VisiblePosition visibleEnd(m_endingPosition);
    692     if (m_typingStyle &&
    693         isStartOfParagraph(visibleEnd) &&
    694         isEndOfParagraph(visibleEnd) &&
    695         lineBreakExistsAtVisiblePosition(visibleEnd)) {
    696         // Apply style to the placeholder that is now holding open the empty paragraph.
    697         // This makes sure that the paragraph has the right height, and that the paragraph
    698         // takes on the right style and retains it even if you move the selection away and
    699         // then move it back (which will clear typing style).
    700 
    701         setEndingSelection(visibleEnd);
    702         applyStyle(m_typingStyle.get(), EditActionUnspecified);
    703         // applyStyle can destroy the placeholder that was at m_endingPosition if it needs to
    704         // move it, but it will set an endingSelection() at [movedPlaceholder, 0] if it does so.
    705         m_endingPosition = endingSelection().start();
    706         m_typingStyle = 0;
    707     }
    708691    // This is where we've deleted all traces of a style but not a whole paragraph (that's handled above).
    709692    // In this case if we start typing, the new characters should have the same style as the just deleted ones,
Note: See TracChangeset for help on using the changeset viewer.