From ba5d192b11ac08f921f22fa181578268c0a85da4 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Mon, 7 Nov 2022 02:33:35 +0000 Subject: [PATCH] Bug 1798214 - Make `HTMLeditor::AdjustCaretPositionAndEnsurePaddingBRElement` invalidate child after inserting `
` element of the insertion point r=m_kato It keeps using the insertion point after inserting `
` element for making empty last line visible. Therefore, referring `IsStartOfContainer` in `HTMLEditUtils::GetPreviousContent` causes the warning of mismating offset and child node. According to the old code [1], `HTMLEditRules` keeps scanning the DOM tree with the offset of the insertion point. Therefore, it should invalidate the child after inserting `
` element. 1. https://searchfox.org/mozilla-central/rev/7b5f4b93ca3e96f9fb9b5793b58080c1e44bd4f6/editor/libeditor/HTMLEditRules.cpp#7606,7631 Differential Revision: https://phabricator.services.mozilla.com/D161246 --- editor/libeditor/HTMLEditSubActionHandler.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/editor/libeditor/HTMLEditSubActionHandler.cpp b/editor/libeditor/HTMLEditSubActionHandler.cpp index d0b174d8cded..c73fb09612b0 100644 --- a/editor/libeditor/HTMLEditSubActionHandler.cpp +++ b/editor/libeditor/HTMLEditSubActionHandler.cpp @@ -9431,6 +9431,7 @@ nsresult HTMLEditor::AdjustCaretPositionAndEnsurePaddingBRElement( if (HTMLEditUtils::IsInvisibleBRElement(*previousEditableContent) && !EditorUtils::IsPaddingBRElementForEmptyLastLine( *previousEditableContent)) { + AutoEditorDOMPointChildInvalidator lockOffset(point); Result insertPaddingBRElementResult = InsertPaddingBRElementForEmptyLastLineWithTransaction(point); if (MOZ_UNLIKELY(insertPaddingBRElementResult.isErr())) {