From 32d89118c35e24f126af905617ec03e7962f3c89 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Fri, 24 Nov 2017 23:17:38 +0900 Subject: [PATCH] Bug 1420415 - TextEditor::CreateBRImpl() needs to make pointToInsertBrNode store mOffset before calling EditorBase::CreateNode() r=m_kato When TextEditor::CreateBRImpl() splits a text node before inserting new
element, it initializes pointToInsertBrNode only with the right text node. Then, it refers its Offset() after inserting new
node before the point. Therefore, the offset is computed with the new DOM tree. So, adding 1 to the offset is redundant only in this case. So, before calling CreateNode(), it needs to make pointToInsertBrNode store offset with calling its Offset(). Note that this ugly code will be replaced with patches for bug 1408227. Additionally, this doesn't use AutoEditorDOMPointChildInvalidator because it's not available in 58 but we need to uplift this patch. Finally, I'm not sure how to check this in automated tests. Therefore, this patch doesn't include automated tests. MozReview-Commit-ID: IaQBonoGawR --HG-- extra : rebase_source : a89559932f27d98a02baf3e207c6be3c2a545aad --- editor/libeditor/TextEditor.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/editor/libeditor/TextEditor.cpp b/editor/libeditor/TextEditor.cpp index c0a3e31862e6..aa8ac98ce407 100644 --- a/editor/libeditor/TextEditor.cpp +++ b/editor/libeditor/TextEditor.cpp @@ -466,6 +466,9 @@ TextEditor::CreateBRImpl(nsCOMPtr* aInOutParent, pointToInsertBrNode.Set(node); Unused << newLeftNode; } + // Lock the offset of pointToInsertBrNode because it'll be referred after + // inserting a new
node before it. + Unused << pointToInsertBrNode.Offset(); // create br brNode = CreateNode(nsGkAtoms::br, pointToInsertBrNode); if (NS_WARN_IF(!brNode)) {