Bug 1620504 - part 14: Clean up warnings in InsertNodeTransaction r=m_kato

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Masayuki Nakano 2020-03-10 14:17:53 +00:00
parent 4d2733ee86
commit 605bafef7b

View File

@ -11,7 +11,7 @@
#include "mozilla/dom/Selection.h" // for Selection
#include "nsAString.h"
#include "nsDebug.h" // for NS_ENSURE_TRUE, etc.
#include "nsDebug.h" // for NS_WARNING, etc.
#include "nsError.h" // for NS_ERROR_NULL_POINTER, etc.
#include "nsIContent.h" // for nsIContent
#include "nsMemory.h" // for nsMemory
@ -99,22 +99,25 @@ InsertNodeTransaction::DoTransaction() {
if (NS_WARN_IF(rv == NS_ERROR_EDITOR_DESTROYED)) {
return EditorBase::ToGenericNSResult(rv);
}
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
"EditorBase::MarkElementDirty() failed, but ignored");
}
ErrorResult error;
container->InsertBefore(*contentToInsert, refChild, error);
error.WouldReportJSException();
if (NS_WARN_IF(error.Failed())) {
if (error.Failed()) {
NS_WARNING("nsINode::InsertBefore() failed");
return error.StealNSResult();
}
if (!editorBase->AsHTMLEditor() && contentToInsert->IsText()) {
uint32_t length = contentToInsert->AsText()->TextLength();
if (length > 0) {
error = MOZ_KnownLive(editorBase->AsTextEditor())
->DidInsertText(length, 0, length);
if (NS_WARN_IF(error.Failed())) {
return error.StealNSResult();
nsresult rv = MOZ_KnownLive(editorBase->AsTextEditor())
->DidInsertText(length, 0, length);
if (NS_FAILED(rv)) {
NS_WARNING("TextEditor::DidInsertText() failed");
return rv;
}
}
}
@ -133,15 +136,14 @@ InsertNodeTransaction::DoTransaction() {
DebugOnly<bool> advanced = afterInsertedNode.AdvanceOffset();
NS_WARNING_ASSERTION(advanced,
"Failed to advance offset after the inserted node");
selection->Collapse(afterInsertedNode, error);
if (NS_WARN_IF(error.Failed())) {
error.SuppressException();
}
IgnoredErrorResult ignoredError;
selection->Collapse(afterInsertedNode, ignoredError);
NS_WARNING_ASSERTION(!ignoredError.Failed(),
"Selection::Collapse() failed, but ignored");
return NS_OK;
}
NS_IMETHODIMP
InsertNodeTransaction::UndoTransaction() {
NS_IMETHODIMP InsertNodeTransaction::UndoTransaction() {
if (NS_WARN_IF(!mEditorBase) || NS_WARN_IF(!mContentToInsert) ||
NS_WARN_IF(!mPointToInsert.IsSet())) {
return NS_ERROR_NOT_INITIALIZED;
@ -156,10 +158,8 @@ InsertNodeTransaction::UndoTransaction() {
// just removed from the DOM tree, this always fails.
ErrorResult error;
mPointToInsert.GetContainer()->RemoveChild(*mContentToInsert, error);
if (NS_WARN_IF(error.Failed())) {
return error.StealNSResult();
}
return NS_OK;
NS_WARNING("nsINode::RemoveChild() failed");
return error.StealNSResult();
}
} // namespace mozilla