Bug 24789 - Select all in an editable document and then delete should put editing back into the same state as a new message
Summary: Select all in an editable document and then delete should put editing back in...
Status: RESOLVED DUPLICATE of bug 19701
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: 528+ (Nightly build)
Hardware: Macintosh OS X 10.5
: P2 Normal
Assignee: Nobody
Keywords: InRadar
Depends on:
Reported: 2009-03-24 16:15 PDT by Adele Peterson
Modified: 2009-03-24 16:45 PDT (History)
4 users (show)

See Also:

experiment (1.06 KB, patch)
2009-03-24 16:20 PDT, Adele Peterson
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adele Peterson 2009-03-24 16:15:30 PDT
Select all in an editable document and then delete should put editing back into the same state as a new message.

Steps to reproduce:
1) Start composing a new rich email in GMail
2) In a separate window, open yahoo.com, select-all and copy
3) Paste the content into the GMail message
4) Select-all in the message and hit delete
5) observe that there is still formatting leftover.  If you send the message to yourself now, and view the original source, you'll see a bunch of spans still in the document.

Comment 1 Adele Peterson 2009-03-24 16:19:34 PDT
I did an experiment in DeleteSelectionCommand to detect if the selection to delete was the whole body, and then to also delete everything in the document.  It worked pretty well, but I think it might be better to reuse some of the code that determined all that extra stuff needed to be copied, and then use the same range that would be copied to decide what to delete.

I'll attach my experimental patch in case anyone's interested.
Comment 2 Adele Peterson 2009-03-24 16:20:01 PDT
Created attachment 28914 [details]
Comment 3 Ojan Vafai 2009-03-24 16:32:50 PDT
This patch seems good to me. Although, it should look at the rootEditableElement, or whatever it's called, instead of the body element so that it also works for contentEditable nodes.

In the long-term, we'll need to be careful that this test still works as we rewire VisiblePositions/Positions. As long as a layout test accompanies the fix though, I think we'd be good.

Would be good to also have tests that test making a selection with the mouse/keyboard that selects all the content of an editable element, then deletes so that we can document that it's either the same or different than select all + delete. It's not clear to me whether it should be the same, but at the very least, we should know if it is and if that behavior changes in the future.
Comment 4 Adele Peterson 2009-03-24 16:45:22 PDT
ok, marking as a dupe of 19701

*** This bug has been marked as a duplicate of 19701 ***