/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include"InsertNodeTransaction.h"
#include"EditorBase.h"// for EditorBase #include"EditorDOMPoint.h"// for EditorDOMPoint #include"HTMLEditor.h"// for HTMLEditor #include"TextEditor.h"// for TextEditor
#include"nsAString.h" #include"nsDebug.h"// for NS_WARNING, etc. #include"nsError.h"// for NS_ERROR_NULL_POINTER, etc. #include"nsIContent.h"// for nsIContent #include"nsReadableUtils.h"// for ToNewCString #include"nsString.h"// for nsString
if (!mPointToInsert.IsSetAndValid()) { // It seems that DOM tree has been changed after first DoTransaction() // and current RedoTranaction() call. if (mPointToInsert.GetChild()) {
EditorDOMPoint newPointToInsert(mPointToInsert.GetChild()); if (!newPointToInsert.IsSet()) { // The insertion point has been removed from the DOM tree. // In this case, we should append the node to the container instead.
newPointToInsert.SetToEndOf(mPointToInsert.GetContainer()); if (NS_WARN_IF(!newPointToInsert.IsSet())) { return NS_ERROR_FAILURE;
}
}
mPointToInsert = newPointToInsert;
} else {
mPointToInsert.SetToEndOf(mPointToInsert.GetContainer()); if (NS_WARN_IF(!mPointToInsert.IsSet())) { return NS_ERROR_FAILURE;
}
}
}
IgnoredErrorResult error;
container->InsertBefore(contentToInsert, refChild, error); // InsertBefore() may call MightThrowJSException() even if there is no // error. We don't need the flag here.
error.WouldReportJSException(); if (error.Failed()) {
NS_WARNING("nsINode::InsertBefore() failed"); return error.StealNSResult();
}
if (NS_WARN_IF(!mEditorBase) || NS_WARN_IF(!mContentToInsert) ||
NS_WARN_IF(!mPointToInsert.IsSet())) { return NS_ERROR_NOT_INITIALIZED;
} // XXX If the inserted node has been moved to different container node or // just removed from the DOM tree, this always fails.
OwningNonNull<nsINode> container = *mPointToInsert.GetContainer();
OwningNonNull<nsIContent> contentToInsert = *mContentToInsert;
ErrorResult error;
container->RemoveChild(contentToInsert, error);
NS_WARNING_ASSERTION(!error.Failed(), "nsINode::RemoveChild() failed"); return error.StealNSResult();
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.