Closed Bug 1247483 Opened 8 years ago Closed 8 years ago

undo/redo doesn't work after copy/pasting a table [contenteditable]

Categories

(Core :: DOM: Editor, defect)

47 Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla47
Tracking Status
firefox47 --- fixed

People

(Reporter: cyril.auburtin, Assigned: wchen)

References

Details

(Whiteboard: dom-triaged)

Attachments

(1 file, 1 obsolete file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.13 Safari/537.36

Steps to reproduce:

in http://output.jsbin.com/cacarew/5 select the whole first table with the mouse, ten copy it (ctrl+c), then place the cursor after the 3 dots, and paste it (ctrl+v)

after that undo (ctrl+z) will remove the second row of the pasted table, the first row remains, redo (ctrl+y) won't work

it actually corrupt/lose the whole undo history after pasting the table

possibly related: https://bugzilla.mozilla.org/show_bug.cgi?id=1015433


Actual results:

pasted <table> isn't undo-able, undo history is lost


Expected results:

it should have worked like any other html content pasted, being undo/redo-able
Component: Untriaged → Editor
Product: Firefox → Core
In nsHTMLEditor::ReplaceOrphanedStructure, we loop over |aNodeArray| removing nodes and checking if it is a descendant of the replacement node. If it is not, then the loop breaks but we continue to append the replacement node onto the list. I don't understand the overall picture of what this code is trying to do but that part looks wrong. It results in the same element being in |aNodeArray| twice (the replacement node is one of the nodes in the list). This results in creating multiple InsertNodeTxn for the same node. When we undo, the first transaction for the node will succeed, but the next one will fail (because the node is no longer a child).
Whiteboard: dom-triaged
Attachment #8718628 - Flags: review?(ehsan)
Comment on attachment 8718628 [details] [diff] [review]
Only replace nodes in nsHTMLEditor::ReplaceOrphanedStructure if all nodes in node list are descendants of replacement node

Review of attachment 8718628 [details] [diff] [review]:
-----------------------------------------------------------------

Please add a test too.  Thanks!
Attachment #8718628 - Flags: review?(ehsan) → review+
Added test
Assignee: nobody → wchen
Attachment #8718628 - Attachment is obsolete: true
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
https://hg.mozilla.org/mozilla-central/rev/542d4cda794b
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla47
Depends on: 1306532
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: