Closed Bug 1247483 Opened 7 years ago Closed 6 years ago

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


(Core :: DOM: Editor, defect)

47 Branch
Not set



Tracking Status
firefox47 --- fixed


(Reporter: cyril.auburtin, Assigned: wchen)



(Whiteboard: dom-triaged)


(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 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:

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
Ever confirmed: true
Closed: 6 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.