Bug 1423097 - part 3: Fix new orange caused by an existing bug of EditorBase::DeleteSelectionAndCreateElement() r=m_kato

Even after EditorBase::DeleteSelectionAndCreateElement() creates a new element,
it tries to collapse selection with |pointToInsert| which is outdated after
inserting new element.

So, it should recompute the caret position with new DOM tree.

MozReview-Commit-ID: DKh2uhItIol

--HG--
extra : rebase_source : c0c30e1c809784af64e87596b471c472350857a8
This commit is contained in:
Masayuki Nakano 2017-12-07 13:57:35 +09:00
Родитель bab72d08e8
Коммит ed66480149
1 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -4490,11 +4490,13 @@ EditorBase::DeleteSelectionAndCreateElement(nsAtom& aTag)
RefPtr<Element> newElement = CreateNode(&aTag, pointToInsert);
// We want the selection to be just after the new node
DebugOnly<bool> advanced = pointToInsert.AdvanceOffset();
EditorRawDOMPoint afterNewElement(newElement);
MOZ_ASSERT(afterNewElement.IsSetAndValid());
DebugOnly<bool> advanced = afterNewElement.AdvanceOffset();
NS_WARNING_ASSERTION(advanced,
"Failed to move offset next to the new element");
ErrorResult error;
selection->Collapse(pointToInsert, error);
selection->Collapse(afterNewElement, error);
if (NS_WARN_IF(error.Failed())) {
// XXX Even if it succeeded to create new element, this returns error
// when Selection.Collapse() fails something. This could occur with