Masayuki Nakano 37ef2fd403 Bug 1882818 - Make HTMLEditor paste ancestors under the closest common ancestor in the range r=m_kato
When copying paragraphs in Gecko, some private type data is copied into the
clipboard and our editor refers the private data at pasting such data.  In
this case, `text/_moz_htmlinfo` has 2 integers to specify the range at the
copy.  If selection range ends at end of text followed by an invisible `<br>`
and a block boundary, this is set to the depth of the text node.  Then,
`HTMLWithContextInserter::CollectTopMostChildContentsCompletelyInRange` collects
top most children of the last paragraph in `HTMLWithContextInserter::Run` [1].
Therefore, the last `<div>` in the clipboard is unwrapped at pasting in the
test case.  This patch makes
`FragmentFromPasteCreator::MoveStartAndEndAccordingToHTMLInfo` re-climb up the
tree under the common ancestor of found start/last nodes.

1. https://searchfox.org/mozilla-central/rev/6b1e306175c2284958fb185bab388021e2890ed0/editor/libeditor/HTMLEditorDataTransfer.cpp#646-651

Differential Revision: https://phabricator.services.mozilla.com/D203574
2024-03-07 09:37:50 +00:00
..