From 144cd4c4ad2bd9e38339028dece36847e66e8fd1 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Sat, 12 Apr 2025 23:50:26 +0000 Subject: [PATCH] Bug 1959352 - Make `WhiteSpaceVisibilityKeeper::NormalizeWhiteSpacesToSplitTextNodeAt()` return end of its parent when it deletes a last `Text` r=m_kato I'm not sure how to make this appear as an unexpected result. I just found these mistakes when I was debugging bug 1959323 Depends on D244876 Differential Revision: https://phabricator.services.mozilla.com/D244879 --- editor/libeditor/WhiteSpaceVisibilityKeeper.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/editor/libeditor/WhiteSpaceVisibilityKeeper.cpp b/editor/libeditor/WhiteSpaceVisibilityKeeper.cpp index 6f06dac84a18..782a6fa7e561 100644 --- a/editor/libeditor/WhiteSpaceVisibilityKeeper.cpp +++ b/editor/libeditor/WhiteSpaceVisibilityKeeper.cpp @@ -1419,7 +1419,8 @@ WhiteSpaceVisibilityKeeper::NormalizeWhiteSpacesToSplitTextNodeAt( if (NS_WARN_IF(nextSibling && nextSibling->GetParentNode() != parentNode)) { return Err(NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE); } - return EditorDOMPoint(nextSibling); + return nextSibling ? EditorDOMPoint(nextSibling) + : EditorDOMPoint::AtEndOf(*parentNode); } const HTMLEditor::ReplaceWhiteSpacesData replacePrecedingWhiteSpacesData = @@ -1461,7 +1462,8 @@ WhiteSpaceVisibilityKeeper::NormalizeWhiteSpacesToSplitTextNodeAt( if (NS_WARN_IF(nextSibling && nextSibling->GetParentNode() != parentNode)) { return Err(NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE); } - return EditorDOMPoint(nextSibling); + return nextSibling ? EditorDOMPoint(nextSibling) + : EditorDOMPoint::AtEndOf(*parentNode); } Result replaceWhiteSpacesResultOrError = aHTMLEditor.ReplaceTextWithTransaction(textNode, replaceWhiteSpacesData);