Bug 1629474 - Avoid warnings when initializing empty editors. r=masayuki

Differential Revision: https://phabricator.services.mozilla.com/D70669

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Cameron McCormack 2020-04-13 08:55:41 +00:00
Родитель 9bfcce4383
Коммит 9e9b510199
1 изменённых файлов: 7 добавлений и 2 удалений

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

@ -139,11 +139,18 @@ nsresult TextEditor::Init(Document& aDoc, Element* aRoot,
return NS_ERROR_FAILURE;
}
// We set mInitSucceeded here rather than at the end of the function,
// since InitEditorContentAndSelection() can perform some transactions
// and can warn if mInitSucceeded is still false.
MOZ_ASSERT(!mInitSucceeded, "TextEditor::Init() shouldn't be nested");
mInitSucceeded = true;
rv = InitEditorContentAndSelection();
if (NS_FAILED(rv)) {
NS_WARNING("TextEditor::InitEditorContentAndSelection() failed");
// XXX Sholdn't we expose `NS_ERROR_EDITOR_DESTROYED` even though this
// is a public method?
mInitSucceeded = false;
return EditorBase::ToGenericNSResult(rv);
}
@ -151,8 +158,6 @@ nsresult TextEditor::Init(Document& aDoc, Element* aRoot,
// we're initializing the editor.
ClearUndoRedo();
EnableUndoRedo();
MOZ_ASSERT(!mInitSucceeded, "TextEditor::Init() shouldn't be nested");
mInitSucceeded = true;
return NS_OK;
}