Bug 100403 - contenteditable incorrectly swaps nodes on deletion
Summary: contenteditable incorrectly swaps nodes on deletion
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: HasReduction
Depends on:
Blocks:
 
Reported: 2012-10-25 12:00 PDT by Elliott Sprehn
Modified: 2022-07-26 21:50 PDT (History)
9 users (show)

See Also:


Attachments
Reduction (408 bytes, text/html)
2012-10-25 12:01 PDT, Elliott Sprehn
no flags Details
Patch (5.30 KB, patch)
2012-12-23 19:59 PST, Sukolsak Sakshuwong
no flags Details | Formatted Diff | Diff
Patch (5.31 KB, patch)
2012-12-23 20:07 PST, Sukolsak Sakshuwong
no flags Details | Formatted Diff | Diff
Patch (6.10 KB, patch)
2012-12-23 23:36 PST, Sukolsak Sakshuwong
rniwa: review+
webkit.review.bot: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Elliott Sprehn 2012-10-25 12:00:33 PDT
In some cases if there's no whitespace between paragraphs contenteditable will swap nodes around in the wrong order.

For example given the below with the caret at the pipe:

X|
Y
Z

If you then hit delete you end up with:

ZY

Downstream bug: http://code.google.com/p/chromium/issues/detail?id=157925
Comment 1 Elliott Sprehn 2012-10-25 12:01:47 PDT
Created attachment 170706 [details]
Reduction
Comment 2 Sukolsak Sakshuwong 2012-12-23 19:59:47 PST
Created attachment 180635 [details]
Patch
Comment 3 Sukolsak Sakshuwong 2012-12-23 20:07:34 PST
Created attachment 180637 [details]
Patch
Comment 4 Ryosuke Niwa 2012-12-23 22:31:21 PST
Comment on attachment 180637 [details]
Patch

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

> Source/WebCore/editing/DeleteSelectionCommand.cpp:484
> +                    updatePositionForNodeRemoval(m_downstreamEnd, children[i].get());
> +                    removeNode(children[i]);

You shouldn't have to call updatePositionForNodeRemoval. DeleteSelectionCommand::removeNode should automatically take care of that.
Comment 5 Sukolsak Sakshuwong 2012-12-23 23:36:18 PST
Created attachment 180650 [details]
Patch
Comment 6 WebKit Review Bot 2012-12-24 06:36:08 PST
Comment on attachment 180650 [details]
Patch

Rejecting attachment 180650 [details] from commit-queue.

New failing tests:
editing/execCommand/format-block-contenteditable-false.html
editing/deleting/delete-3865854-fix.html
editing/execCommand/5469868.html
editing/execCommand/5190926.html
editing/execCommand/delete-selection-has-style.html
editing/pasteboard/testcase-9507.html
editing/deleting/delete-at-paragraph-boundaries-002.html
editing/pasteboard/paste-text-009.html
editing/execCommand/create-list-from-range-selection.html
editing/pasteboard/paste-text-015.html
editing/deleting/delete-and-cleanup.html
editing/deleting/delete-select-all-003.html
editing/pasteboard/block-wrappers-necessary.html
editing/pasteboard/paste-4039777-fix.html
editing/pasteboard/paste-text-008.html
editing/pasteboard/paste-without-nesting.html
editing/deleting/delete-3959464-fix.html
editing/execCommand/4916541.html
editing/deleting/delete-at-paragraph-boundaries-001.html
svg/custom/bug78838.html
editing/execCommand/inline-style-after-indentoutdent.html
editing/style/4916887.html
editing/deleting/deleting-line-break-preserves-underline-color.html
editing/pasteboard/copy-paste-bidi.html
Full output: http://queues.webkit.org/results/15496480
Comment 7 WebKit Review Bot 2012-12-30 05:55:59 PST
Comment on attachment 180650 [details]
Patch

Attachment 180650 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/15594429

New failing tests:
editing/execCommand/format-block-contenteditable-false.html
editing/deleting/delete-3865854-fix.html
editing/execCommand/5469868.html
editing/execCommand/5190926.html
editing/execCommand/delete-selection-has-style.html
editing/pasteboard/testcase-9507.html
editing/deleting/delete-at-paragraph-boundaries-002.html
editing/pasteboard/paste-text-009.html
editing/execCommand/create-list-from-range-selection.html
editing/pasteboard/paste-text-015.html
editing/deleting/delete-and-cleanup.html
editing/deleting/delete-select-all-003.html
editing/pasteboard/block-wrappers-necessary.html
editing/pasteboard/paste-4039777-fix.html
editing/pasteboard/paste-text-008.html
editing/pasteboard/paste-without-nesting.html
editing/deleting/delete-3959464-fix.html
editing/execCommand/4916541.html
editing/deleting/delete-at-paragraph-boundaries-001.html
svg/custom/bug78838.html
editing/execCommand/inline-style-after-indentoutdent.html
editing/style/4916887.html
editing/deleting/deleting-line-break-preserves-underline-color.html
editing/pasteboard/copy-paste-bidi.html
Comment 8 Build Bot 2013-01-04 17:57:17 PST
Comment on attachment 180650 [details]
Patch

Attachment 180650 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/15699448

New failing tests:
editing/execCommand/format-block-contenteditable-false.html
editing/deleting/delete-3865854-fix.html
editing/execCommand/5469868.html
editing/execCommand/5190926.html
editing/execCommand/delete-selection-has-style.html
editing/pasteboard/testcase-9507.html
editing/deleting/delete-at-paragraph-boundaries-002.html
editing/pasteboard/paste-text-009.html
editing/execCommand/create-list-from-range-selection.html
editing/pasteboard/paste-text-015.html
editing/deleting/delete-and-cleanup.html
editing/deleting/delete-select-all-003.html
editing/pasteboard/block-wrappers-necessary.html
editing/pasteboard/paste-4039777-fix.html
editing/pasteboard/paste-text-008.html
editing/pasteboard/paste-without-nesting.html
editing/deleting/delete-3959464-fix.html
editing/execCommand/4916541.html
editing/deleting/delete-at-paragraph-boundaries-001.html
svg/custom/bug78838.html
editing/execCommand/inline-style-after-indentoutdent.html
editing/style/4916887.html
editing/deleting/deleting-line-break-preserves-underline-color.html
editing/pasteboard/copy-paste-bidi.html
Comment 9 Ahmad Saleem 2022-07-26 13:27:16 PDT
I am unable to reproduce this bug using attached reduction in Safari 15.6 on macOS 12.5, it behaves same across all browsers and does not fix up results like mentioned in Comment 0 and the content remain where it is. Only "X" get removed and it is across all browsers (Chrome Canary 106, Firefox Nightly 104 and Safari 15.6). Thanks!
Comment 10 Ryosuke Niwa 2022-07-26 21:50:59 PDT
Oh yeah, I fixed this bug years ago.