Bug 1798214 - Make HTMLeditor::AdjustCaretPositionAndEnsurePaddingBRElement invalidate child after inserting <br> element of the insertion point r=m_kato

It keeps using the insertion point after inserting `<br>` 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 `<br>` element.

1. https://searchfox.org/mozilla-central/rev/7b5f4b93ca3e96f9fb9b5793b58080c1e44bd4f6/editor/libeditor/HTMLEditRules.cpp#7606,7631

Differential Revision: https://phabricator.services.mozilla.com/D161246
This commit is contained in:
Masayuki Nakano 2022-11-07 02:33:35 +00:00
parent 2688f5b8c9
commit ba5d192b11

View file

@ -9431,6 +9431,7 @@ nsresult HTMLEditor::AdjustCaretPositionAndEnsurePaddingBRElement(
if (HTMLEditUtils::IsInvisibleBRElement(*previousEditableContent) &&
!EditorUtils::IsPaddingBRElementForEmptyLastLine(
*previousEditableContent)) {
AutoEditorDOMPointChildInvalidator lockOffset(point);
Result<CreateElementResult, nsresult> insertPaddingBRElementResult =
InsertPaddingBRElementForEmptyLastLineWithTransaction(point);
if (MOZ_UNLIKELY(insertPaddingBRElementResult.isErr())) {