Loading
Bug 1828078 - part 1: Make `HTMLEditUtils::CanNodeContain` handle comment node r=m_kato
`HTMLEditUtils::CanNodeContain` does not handle comment nodes and cdata section nodes (the latter one is available only in XHTML documents, it's treated as a comment node in HTML documents). When copying HTML from Word on Windows, that contains 2 comment nodes at start of pasting body (which does not appear in clipboard viewer, so, Gecko creates them somewhere) and that causes `HTMLEditUtils::CanNodeContain` returns `false` for any parents. Therefore, `HTMLEditor::InsertNodeIntoProperAncestorWithTransaction` returns error and the pasting fails with odd state and unexpectedly split the list item in `HTMLWithContextInserter::InsertContents`. Finally, undoing fails to do some of them and causes destroying the editable nodes. This patch makes `HTMLEditUtils::CanNodeContain` work with comment nodes and cdata section nodes (the latter is treated as a comment node since there is no "cdata" tag definition of `nsHTMLTag`) and `HTMLEditor::InsertNodeIntoProperAncestorWithTransaction` just return "not handled" result for some other types of nodes which cannot be inserted in any elements. Note that the result of pasting from Word is different from Chrome's result. Chrome does not paste such comment nodes (but inserts comment nodes with `insertHTML` command). For now, I don't want to work on fixing this compatibility issue since comment nodes does not cause any known troubles. Therefore, this patch does not contain WPT updates. Differential Revision: https://phabricator.services.mozilla.com/D176766