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.
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.
Created attachment 28914 [details]
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.
ok, marking as a dupe of 19701
*** This bug has been marked as a duplicate of 19701 ***