Backed out changeset 865c5d292958 (bug 1791224) for causing build bustages at Result.h. CLOSED TREE
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
* 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 "ErrorList.h"
|
||||
#include "HTMLEditor.h"
|
||||
|
||||
#include <string.h>
|
||||
@@ -203,15 +202,13 @@ nsresult HTMLEditor::LoadHTML(const nsAString& aInputString) {
|
||||
EditorDOMPoint pointToPutCaret;
|
||||
for (nsCOMPtr<nsIContent> contentToInsert = documentFragment->GetFirstChild();
|
||||
contentToInsert; contentToInsert = documentFragment->GetFirstChild()) {
|
||||
Result<CreateContentResult, nsresult> insertChildContentNodeResult =
|
||||
CreateContentResult insertChildContentNodeResult =
|
||||
InsertNodeWithTransaction(*contentToInsert, pointToInsert);
|
||||
if (MOZ_UNLIKELY(insertChildContentNodeResult.isErr())) {
|
||||
if (insertChildContentNodeResult.isErr()) {
|
||||
NS_WARNING("EditorBase::InsertNodeWithTransaction() failed");
|
||||
return insertChildContentNodeResult.unwrapErr();
|
||||
}
|
||||
CreateContentResult unwrappedInsertChildContentNodeResult =
|
||||
insertChildContentNodeResult.unwrap();
|
||||
unwrappedInsertChildContentNodeResult.MoveCaretPointTo(
|
||||
insertChildContentNodeResult.MoveCaretPointTo(
|
||||
pointToPutCaret, *this,
|
||||
{SuggestCaret::OnlyIfHasSuggestion,
|
||||
SuggestCaret::OnlyIfTransactionsAllowedToDoIt});
|
||||
@@ -887,17 +884,17 @@ HTMLEditor::HTMLWithContextInserter::InsertContents(
|
||||
EditorDOMPoint pointToPutCaret;
|
||||
for (const OwningNonNull<nsIContent>& child : children) {
|
||||
// MOZ_KnownLive(child) because of bug 1622253
|
||||
Result<CreateContentResult, nsresult> moveChildResult =
|
||||
CreateContentResult moveChildResult =
|
||||
mHTMLEditor.InsertNodeIntoProperAncestorWithTransaction<nsIContent>(
|
||||
MOZ_KnownLive(child), pointToInsert,
|
||||
SplitAtEdges::eDoNotCreateEmptyContainer);
|
||||
if (MOZ_UNLIKELY(moveChildResult.isErr())) {
|
||||
inserted |=
|
||||
moveChildResult.isOk() || moveChildResult.GotUnexpectedDOMTree();
|
||||
if (moveChildResult.isErr()) {
|
||||
// If moving node is moved to different place, we should ignore
|
||||
// this result and keep trying to insert next content node to same
|
||||
// position.
|
||||
if (moveChildResult.inspectErr() ==
|
||||
NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE) {
|
||||
inserted = true;
|
||||
if (moveChildResult.GotUnexpectedDOMTree()) {
|
||||
continue; // the inner `for` loop
|
||||
}
|
||||
NS_WARNING(
|
||||
@@ -906,12 +903,10 @@ HTMLEditor::HTMLWithContextInserter::InsertContents(
|
||||
"ignored");
|
||||
break; // from the inner `for` loop
|
||||
}
|
||||
inserted = true;
|
||||
lastInsertedPoint.Set(child);
|
||||
pointToInsert = lastInsertedPoint.NextPoint();
|
||||
MOZ_ASSERT(pointToInsert.IsSet());
|
||||
CreateContentResult unwrappedMoveChildResult = moveChildResult.unwrap();
|
||||
unwrappedMoveChildResult.MoveCaretPointTo(
|
||||
moveChildResult.MoveCaretPointTo(
|
||||
pointToPutCaret, mHTMLEditor,
|
||||
{SuggestCaret::OnlyIfHasSuggestion,
|
||||
SuggestCaret::OnlyIfTransactionsAllowedToDoIt});
|
||||
@@ -966,22 +961,24 @@ HTMLEditor::HTMLWithContextInserter::InsertContents(
|
||||
}
|
||||
}
|
||||
// MOZ_KnownLive(child) because of bug 1622253
|
||||
Result<CreateContentResult, nsresult> moveChildResult =
|
||||
CreateContentResult moveChildResult =
|
||||
mHTMLEditor
|
||||
.InsertNodeIntoProperAncestorWithTransaction<nsIContent>(
|
||||
MOZ_KnownLive(child), pointToInsert,
|
||||
SplitAtEdges::eDoNotCreateEmptyContainer);
|
||||
if (MOZ_UNLIKELY(moveChildResult.isErr())) {
|
||||
inserted |=
|
||||
moveChildResult.isOk() || moveChildResult.GotUnexpectedDOMTree();
|
||||
if (moveChildResult.isErr()) {
|
||||
// If moving node is moved to different place, we should ignore
|
||||
// this result and keep trying to insert next content node to
|
||||
// same position.
|
||||
if (moveChildResult.inspectErr() ==
|
||||
NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE) {
|
||||
inserted = true;
|
||||
if (moveChildResult.GotUnexpectedDOMTree()) {
|
||||
continue; // the inner `for` loop
|
||||
}
|
||||
if (NS_WARN_IF(moveChildResult.inspectErr() ==
|
||||
NS_ERROR_EDITOR_DESTROYED)) {
|
||||
if (moveChildResult.EditorDestroyed()) {
|
||||
NS_WARNING(
|
||||
"HTMLEditor::InsertNodeIntoProperAncestorWithTransaction() "
|
||||
"caused destroying the editor");
|
||||
return Err(NS_ERROR_EDITOR_DESTROYED);
|
||||
}
|
||||
NS_WARNING(
|
||||
@@ -990,13 +987,10 @@ HTMLEditor::HTMLWithContextInserter::InsertContents(
|
||||
"ignored");
|
||||
break; // from the inner `for` loop
|
||||
}
|
||||
inserted = true;
|
||||
lastInsertedPoint.Set(child);
|
||||
pointToInsert = lastInsertedPoint.NextPoint();
|
||||
MOZ_ASSERT(pointToInsert.IsSet());
|
||||
CreateContentResult unwrappedMoveChildResult =
|
||||
moveChildResult.unwrap();
|
||||
unwrappedMoveChildResult.MoveCaretPointTo(
|
||||
moveChildResult.MoveCaretPointTo(
|
||||
pointToPutCaret, mHTMLEditor,
|
||||
{SuggestCaret::OnlyIfHasSuggestion,
|
||||
SuggestCaret::OnlyIfTransactionsAllowedToDoIt});
|
||||
@@ -1048,21 +1042,23 @@ HTMLEditor::HTMLWithContextInserter::InsertContents(
|
||||
EditorDOMPoint pointToPutCaret;
|
||||
for (const OwningNonNull<nsIContent>& child : children) {
|
||||
// MOZ_KnownLive(child) because of bug 1622253
|
||||
Result<CreateContentResult, nsresult> moveChildResult =
|
||||
CreateContentResult moveChildResult =
|
||||
mHTMLEditor.InsertNodeIntoProperAncestorWithTransaction<nsIContent>(
|
||||
MOZ_KnownLive(child), pointToInsert,
|
||||
SplitAtEdges::eDoNotCreateEmptyContainer);
|
||||
if (MOZ_UNLIKELY(moveChildResult.isErr())) {
|
||||
inserted |=
|
||||
moveChildResult.isOk() || moveChildResult.GotUnexpectedDOMTree();
|
||||
if (moveChildResult.isErr()) {
|
||||
// If moving node is moved to different place, we should ignore
|
||||
// this result and keep trying to insert next content node there.
|
||||
if (moveChildResult.inspectErr() ==
|
||||
NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE) {
|
||||
inserted = true;
|
||||
if (moveChildResult.GotUnexpectedDOMTree()) {
|
||||
continue; // the inner `for` loop
|
||||
}
|
||||
if (NS_WARN_IF(moveChildResult.inspectErr() ==
|
||||
NS_ERROR_EDITOR_DESTROYED)) {
|
||||
return moveChildResult.propagateErr();
|
||||
if (moveChildResult.EditorDestroyed()) {
|
||||
NS_WARNING(
|
||||
"HTMLEditor::InsertNodeIntoProperAncestorWithTransaction() "
|
||||
"caused destroying the editor");
|
||||
return Err(NS_ERROR_EDITOR_DESTROYED);
|
||||
}
|
||||
NS_WARNING(
|
||||
"HTMLEditor::InsertNodeIntoProperAncestorWithTransaction("
|
||||
@@ -1070,12 +1066,10 @@ HTMLEditor::HTMLWithContextInserter::InsertContents(
|
||||
"ignored");
|
||||
break; // from the inner `for` loop
|
||||
}
|
||||
CreateContentResult unwrappedMoveChildResult = moveChildResult.unwrap();
|
||||
inserted = true;
|
||||
lastInsertedPoint.Set(child);
|
||||
pointToInsert = lastInsertedPoint.NextPoint();
|
||||
MOZ_ASSERT(pointToInsert.IsSet());
|
||||
unwrappedMoveChildResult.MoveCaretPointTo(
|
||||
moveChildResult.MoveCaretPointTo(
|
||||
pointToPutCaret, mHTMLEditor,
|
||||
{SuggestCaret::OnlyIfHasSuggestion,
|
||||
SuggestCaret::OnlyIfTransactionsAllowedToDoIt});
|
||||
@@ -1101,14 +1095,14 @@ HTMLEditor::HTMLWithContextInserter::InsertContents(
|
||||
if (!inserted) {
|
||||
// MOZ_KnownLive(content) because 'aArrayOfTopMostChildContents' is
|
||||
// guaranteed to keep it alive.
|
||||
Result<CreateContentResult, nsresult> moveContentResult =
|
||||
const CreateContentResult moveContentResult =
|
||||
mHTMLEditor.InsertNodeIntoProperAncestorWithTransaction<nsIContent>(
|
||||
MOZ_KnownLive(content), pointToInsert,
|
||||
SplitAtEdges::eDoNotCreateEmptyContainer);
|
||||
if (MOZ_LIKELY(moveContentResult.isOk())) {
|
||||
if (moveContentResult.isOk()) {
|
||||
lastInsertedPoint.Set(content);
|
||||
pointToInsert = lastInsertedPoint;
|
||||
nsresult rv = moveContentResult.inspect().SuggestCaretPointTo(
|
||||
nsresult rv = moveContentResult.SuggestCaretPointTo(
|
||||
mHTMLEditor, {SuggestCaret::OnlyIfHasSuggestion,
|
||||
SuggestCaret::OnlyIfTransactionsAllowedToDoIt,
|
||||
SuggestCaret::AndIgnoreTrivialError});
|
||||
@@ -1119,8 +1113,7 @@ HTMLEditor::HTMLWithContextInserter::InsertContents(
|
||||
NS_WARNING_ASSERTION(
|
||||
rv != NS_SUCCESS_EDITOR_BUT_IGNORED_TRIVIAL_ERROR,
|
||||
"CreateContentResult::SuggestCaretPointTo() failed, but ignored");
|
||||
} else if (moveContentResult.inspectErr() ==
|
||||
NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE) {
|
||||
} else if (moveContentResult.GotUnexpectedDOMTree()) {
|
||||
// Moving node is moved to different place, we should keep trying to
|
||||
// insert the next content to same position.
|
||||
} else {
|
||||
@@ -1140,20 +1133,22 @@ HTMLEditor::HTMLWithContextInserter::InsertContents(
|
||||
}
|
||||
const OwningNonNull<nsIContent> oldParentContent =
|
||||
*childContent->GetParent();
|
||||
Result<CreateContentResult, nsresult> moveParentResult =
|
||||
const CreateContentResult moveParentResult =
|
||||
mHTMLEditor
|
||||
.InsertNodeIntoProperAncestorWithTransaction<nsIContent>(
|
||||
oldParentContent, pointToInsert,
|
||||
SplitAtEdges::eDoNotCreateEmptyContainer);
|
||||
if (MOZ_UNLIKELY(moveParentResult.isErr())) {
|
||||
if (moveParentResult.isErr()) {
|
||||
// Moving node is moved to different place, we should keep trying to
|
||||
// insert the next content to same position.
|
||||
if (moveParentResult.inspectErr() ==
|
||||
NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE) {
|
||||
if (moveParentResult.GotUnexpectedDOMTree()) {
|
||||
break; // from the inner `for` loop
|
||||
}
|
||||
if (NS_WARN_IF(moveParentResult.inspectErr() ==
|
||||
NS_ERROR_EDITOR_DESTROYED)) {
|
||||
if (moveParentResult.EditorDestroyed()) {
|
||||
NS_WARNING(
|
||||
"HTMLEditor::InsertNodeInToProperAncestorWithTransaction("
|
||||
"SplitAtEdges::eDoNotCreateEmptyContainer) caused destroying "
|
||||
"the editor");
|
||||
return Err(NS_ERROR_EDITOR_DESTROYED);
|
||||
}
|
||||
NS_WARNING(
|
||||
@@ -1164,7 +1159,7 @@ HTMLEditor::HTMLWithContextInserter::InsertContents(
|
||||
}
|
||||
insertedContextParentContent = oldParentContent;
|
||||
pointToInsert.Set(oldParentContent);
|
||||
nsresult rv = moveParentResult.inspect().SuggestCaretPointTo(
|
||||
nsresult rv = moveParentResult.SuggestCaretPointTo(
|
||||
mHTMLEditor, {SuggestCaret::OnlyIfHasSuggestion,
|
||||
SuggestCaret::OnlyIfTransactionsAllowedToDoIt,
|
||||
SuggestCaret::AndIgnoreTrivialError});
|
||||
|
||||
Reference in New Issue
Block a user