Bug 35372 - Backspace/delete at start of table cell shouldn't step out of cell
Summary: Backspace/delete at start of table cell shouldn't step out of cell
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Shezan Baig
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-24 18:01 PST by Julie Parent
Modified: 2013-03-14 21:27 PDT (History)
6 users (show)

See Also:


Attachments
additional inconsistencies (767 bytes, text/html)
2013-03-13 08:45 PDT, Shezan Baig
no flags Details
Patch (8.81 KB, patch)
2013-03-13 13:50 PDT, Shezan Baig
no flags Details | Formatted Diff | Diff
Patch (with review comments) (8.73 KB, patch)
2013-03-14 20:55 PDT, Shezan Baig
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Julie Parent 2010-02-24 18:01:04 PST
Repro steps:
1. Given a contentEditable table, like <div contentEditable><table border=1><tr><td>1</td><td>2</td></tr><t<tr><td>3</td><td>4</td></tr></table></div>
2. Put cursor at the start of a cell, like before the 2
3. Hit backspace/delete

Result:
Focus moves to previous cell.

Expected Result:
Nop.  This is consistent with IE, FF, Word, TextEdit.

Note: if in the first cell, steps out of the table.  This is also inconsistent with other editors, and also should be a nop.
Comment 1 Shezan Baig 2013-03-13 08:45:14 PDT
Created attachment 192930 [details]
additional inconsistencies

Added attachment showing additional inconsistencies.  I think these issues can all be fixed if we adopted the "Backspacing at the start of a table cell does nothing" clause in https://dvcs.w3.org/hg/editing/raw-file/tip/editing.html#the-delete-command
Comment 2 Shezan Baig 2013-03-13 13:50:49 PDT
Created attachment 192988 [details]
Patch
Comment 3 Ryosuke Niwa 2013-03-13 16:39:18 PDT
Comment on attachment 192988 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=192988&action=review

> Source/WebCore/editing/TypingCommand.cpp:470
> +        Node* enclosingTableCell = enclosingNodeOfType(visibleStart.deepEquivalent(), &isTableCell);
> +        if (enclosingTableCell && visibleStart == firstPositionInNode(enclosingTableCell))

This checks whether selection start is at the beginning of table cell or not, not whether the cell is empty or not.
With this, we're going to make select all + delete no-op.
Comment 4 Shezan Baig 2013-03-13 19:19:32 PDT
Comment on attachment 192988 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=192988&action=review

>> Source/WebCore/editing/TypingCommand.cpp:470
>> +        if (enclosingTableCell && visibleStart == firstPositionInNode(enclosingTableCell))
> 
> This checks whether selection start is at the beginning of table cell or not, not whether the cell is empty or not.
> With this, we're going to make select all + delete no-op.

I don't quite follow.  If we select all, then the selection will be VisibleSelection::RangeSelection, and will be handled at line 436.  In our case, we have VisibleSelection::CaretSelection, so visibleStart == visibleEnd in this case
Comment 5 Ryosuke Niwa 2013-03-14 20:23:59 PDT
Comment on attachment 192988 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=192988&action=review

> LayoutTests/editing/deleting/backspace-at-table-cell-beginning.html:11
> +                    + "a table-cell is a no-op.  The first dump verifies "
> +                    + "that the caret stays before 'abc', and doesn't select "
> +                    + "the nested table.  The second dump verifies that the "
> +                    + "caret stays before 'def'.");

Wrong indentation. + should be indented by exactly 4 spaces.
By the way, I usually prefer putting this description in p with id=description and then do:
Markup.description(document.getElementById('description').textContent);
There's an added benefit that we can automate this in the future.

> LayoutTests/editing/deleting/forward-delete-at-table-cell-ending.html:12
> +Markup.description("This test verifies that forward delete at the end of a "
> +                    + "table-cell is a no-op.  The first dump verifies that "
> +                    + "the caret stays after 'abc'.  The second dump verifies "
> +                    + "that the caret stays after 'def', and doesn't select "
> +                    + "the nested table.");

Ditto about the wrong indentation.
Comment 6 Shezan Baig 2013-03-14 20:55:22 PDT
Created attachment 193227 [details]
Patch (with review comments)
Comment 7 WebKit Review Bot 2013-03-14 21:27:42 PDT
Comment on attachment 193227 [details]
Patch (with review comments)

Clearing flags on attachment: 193227

Committed r145871: <http://trac.webkit.org/changeset/145871>
Comment 8 WebKit Review Bot 2013-03-14 21:27:46 PDT
All reviewed patches have been landed.  Closing bug.