Changeset 233885 in webkit


Ignore:
Timestamp:
Jul 17, 2018 1:48:49 AM (6 years ago)
Author:
jfernandez@igalia.com
Message:

Delete content of a single cell table should not delete the whole table
https://bugs.webkit.org/show_bug.cgi?id=173117

Reviewed by Ryosuke Niwa.

Source/WebCore:

We should not extend selection looking for special elements if the
delete operation has been triggered by a caret based selection.

This change is based on a recent [1] resolution of the Editing TF,
which acknowledges that behavior of single-cell tables must be the
same that multi-cell tables and even if the last character is
deleted, we should not delete the whole table structure.

A different case would be when the user actively selects the whole
content of a table; in this case, as we do in multi-cell tables,
the structure of single-cell tables should be deleted together
with the content.

[1] https://github.com/w3c/editing/issues/163

Tests: editing/deleting/backspace-delete-last-char-in-table.html

editing/deleting/forward-delete-last-char-in-table.html
editing/deleting/select-and-delete-last-char-in-table.html

  • editing/TypingCommand.cpp:

(WebCore::TypingCommand::deleteKeyPressed):
(WebCore::TypingCommand::forwardDeleteKeyPressed):

LayoutTests:

Tests to verify that single-cell tables are not deleted when their
last character is deleted, unless it was previously selected by
the user.

Changes two expected files to adapt them to the new logic.

  • LayoutTests/editing/deleting/deleting-relative-positioned-special-element-expected.txt: The paragraph is not deleted, even if it's empty. The paragraphs above are not merged, which was the goal of the test.
  • editing/deleting/delete-last-char-in-table-expected.txt: The table is not removed, even if it's empty. The formatted elements are deleted, which was the goal of the test.
  • editing/deleting/backspace-delete-last-char-in-table-expected.txt: Added.
  • editing/deleting/backspace-delete-last-char-in-table.html: Added.
  • editing/deleting/forward-delete-last-char-in-table-expected.txt: Added.
  • editing/deleting/forward-delete-last-char-in-table.html: Added.
  • editing/deleting/select-and-delete-last-char-in-table-expected.txt: Added.
  • editing/deleting/select-and-delete-last-char-in-table.html: Added.
Location:
trunk
Files:
6 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r233882 r233885  
     12018-07-17  Javier Fernandez  <jfernandez@igalia.com>
     2
     3        Delete content of a single cell table should not delete the whole table
     4        https://bugs.webkit.org/show_bug.cgi?id=173117
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Tests to verify that single-cell tables are not deleted when their
     9        last character is deleted, unless it was previously selected by
     10        the user.
     11
     12        Changes two expected files to adapt them to the new logic.
     13
     14        * LayoutTests/editing/deleting/deleting-relative-positioned-special-element-expected.txt: The paragraph is not deleted, even if it's empty. The paragraphs above are not merged, which was the goal of the test.
     15        * editing/deleting/delete-last-char-in-table-expected.txt: The table is not removed, even if it's empty. The formatted elements are deleted, which was the goal of the test.
     16        * editing/deleting/backspace-delete-last-char-in-table-expected.txt: Added.
     17        * editing/deleting/backspace-delete-last-char-in-table.html: Added.
     18        * editing/deleting/forward-delete-last-char-in-table-expected.txt: Added.
     19        * editing/deleting/forward-delete-last-char-in-table.html: Added.
     20        * editing/deleting/select-and-delete-last-char-in-table-expected.txt: Added.
     21        * editing/deleting/select-and-delete-last-char-in-table.html: Added.
     22
    1232018-07-16  Simon Fraser  <simon.fraser@apple.com>
    224
  • trunk/LayoutTests/editing/deleting/delete-last-char-in-table-expected.txt

    r87466 r233885  
    33
    44PASS
    5 execDeleteCommand: <br>
     5execDeleteCommand: <table style="border-collapse:collapse"><tbody><tr><td id="cursor"><br></td></tr></tbody></table>
  • trunk/LayoutTests/editing/deleting/deleting-relative-positioned-special-element-expected.txt

    r231630 r233885  
    1515| <p>
    1616|   "1"
    17 | <#selection-caret>
    18 | <br>
     17| <p>
     18|   id="paragraphToDelete"
     19|   <#selection-caret>
     20|   <br>
    1921| <p>
    2022|   "3"
  • trunk/Source/WebCore/ChangeLog

    r233883 r233885  
     12018-07-17  Javier Fernandez  <jfernandez@igalia.com>
     2
     3        Delete content of a single cell table should not delete the whole table
     4        https://bugs.webkit.org/show_bug.cgi?id=173117
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        We should not extend selection looking for special elements if the
     9        delete operation has been triggered by a caret based selection.
     10
     11        This change is based on a recent [1] resolution of the Editing TF,
     12        which acknowledges that behavior of single-cell tables must be the
     13        same that multi-cell tables and even if the last character is
     14        deleted, we should not delete the whole table structure.
     15
     16        A different case would be when the user actively selects the whole
     17        content of a table; in this case, as we do in multi-cell tables,
     18        the structure of single-cell tables should be deleted together
     19        with the content.
     20
     21        [1] https://github.com/w3c/editing/issues/163
     22
     23        Tests: editing/deleting/backspace-delete-last-char-in-table.html
     24               editing/deleting/forward-delete-last-char-in-table.html
     25               editing/deleting/select-and-delete-last-char-in-table.html
     26
     27        * editing/TypingCommand.cpp:
     28        (WebCore::TypingCommand::deleteKeyPressed):
     29        (WebCore::TypingCommand::forwardDeleteKeyPressed):
     30
    1312018-07-16  Megan Gardner  <megan_gardner@apple.com>
    232
  • trunk/Source/WebCore/editing/TypingCommand.cpp

    r225117 r233885  
    650650    VisibleSelection selectionToDelete;
    651651    VisibleSelection selectionAfterUndo;
     652    bool expandForSpecialElements = !endingSelection().isCaret();
    652653
    653654    switch (endingSelection().selectionType()) {
     
    761762    if (m_openedByBackwardDelete)
    762763        setStartingSelection(selectionAfterUndo);
    763     CompositeEditCommand::deleteSelection(selectionToDelete, m_smartDelete);
     764    CompositeEditCommand::deleteSelection(selectionToDelete, m_smartDelete, /* mergeBlocksAfterDelete*/ true, /* replace*/ false, expandForSpecialElements, /*sanitizeMarkup*/ true);
    764765    setSmartDelete(false);
    765766    typingAddedToOpenCommand(DeleteKey);
     
    775776    VisibleSelection selectionToDelete;
    776777    VisibleSelection selectionAfterUndo;
     778    bool expandForSpecialElements = !endingSelection().isCaret();
    777779
    778780    switch (endingSelection().selectionType()) {
     
    863865    // make undo select what was deleted
    864866    setStartingSelection(selectionAfterUndo);
    865     CompositeEditCommand::deleteSelection(selectionToDelete, m_smartDelete);
     867    CompositeEditCommand::deleteSelection(selectionToDelete, m_smartDelete, /* mergeBlocksAfterDelete*/ true, /* replace*/ false, expandForSpecialElements, /*sanitizeMarkup*/ true);
    866868    setSmartDelete(false);
    867869    typingAddedToOpenCommand(ForwardDeleteKey);
Note: See TracChangeset for help on using the changeset viewer.