Bug 24789

Summary: Select all in an editable document and then delete should put editing back into the same state as a new message
Product: WebKit Reporter: Adele Peterson <adele>
Component: HTML EditingAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: eric, jparent, justin.garcia, ojan
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: OS X 10.5   
Attachments:
Description Flags
experiment none

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.

<rdar://problem/6609509>
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]
experiment
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 ***