--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -1450,17 +1450,20 @@ HTMLEditRules::WillLoadHTML(Selection* a
NS_ENSURE_TRUE(aSelection && aCancel, NS_ERROR_NULL_POINTER);
*aCancel = false;
// Delete mBogusNode if it exists. If we really need one,
// it will be added during post-processing in AfterEditInner().
if (mBogusNode) {
- mTextEditor->DeleteNode(mBogusNode);
+ if (NS_WARN_IF(!mHTMLEditor)) {
+ return NS_ERROR_UNEXPECTED;
+ }
+ mHTMLEditor->DeleteNode(mBogusNode);
mBogusNode = nullptr;
}
return NS_OK;
}
nsresult
HTMLEditRules::WillInsertBreak(Selection& aSelection,
@@ -3794,17 +3797,20 @@ HTMLEditRules::WillCSSIndent(Selection*
// Not a list item.
else {
if (curNode && IsBlockNode(*curNode)) {
ChangeIndentation(*curNode->AsElement(), Change::plus);
curQuote = nullptr;
} else {
if (!curQuote) {
// First, check that our element can contain a div.
- if (!mTextEditor->CanContainTag(*curParent, *nsGkAtoms::div)) {
+ if (NS_WARN_IF(!mHTMLEditor)) {
+ return NS_ERROR_UNEXPECTED;
+ }
+ if (!mHTMLEditor->CanContainTag(*curParent, *nsGkAtoms::div)) {
return NS_OK; // cancelled
}
rv = SplitAsNeeded(*nsGkAtoms::div, curParent, offset);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_STATE(mHTMLEditor);
curQuote = mHTMLEditor->CreateNode(nsGkAtoms::div, curParent,
offset);
@@ -4022,17 +4028,20 @@ HTMLEditRules::WillHTMLIndent(Selection*
// One reason it might not go in prio blockquote is if we are now
// in a different table cell.
if (curQuote && InDifferentTableElements(curQuote, curNode)) {
curQuote = nullptr;
}
if (!curQuote) {
// First, check that our element can contain a blockquote.
- if (!mTextEditor->CanContainTag(*curParent, *nsGkAtoms::blockquote)) {
+ if (NS_WARN_IF(!mHTMLEditor)) {
+ return NS_ERROR_UNEXPECTED;
+ }
+ if (!mHTMLEditor->CanContainTag(*curParent, *nsGkAtoms::blockquote)) {
return NS_OK; // cancelled
}
rv = SplitAsNeeded(*nsGkAtoms::blockquote, curParent, offset);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_STATE(mHTMLEditor);
curQuote = mHTMLEditor->CreateNode(nsGkAtoms::blockquote, curParent,
offset);
@@ -4766,17 +4775,17 @@ HTMLEditRules::WillAlign(Selection& aSel
}
// Clear out curDiv so that we don't put nodes after this one into it
}
// Need to make a div to put things in if we haven't already, or if this
// node doesn't go in div we used earlier.
if (!curDiv || transitionList[i]) {
// First, check that our element can contain a div.
- if (!mTextEditor->CanContainTag(*curParent, *nsGkAtoms::div)) {
+ if (!htmlEditor->CanContainTag(*curParent, *nsGkAtoms::div)) {
// Cancelled
return NS_OK;
}
rv = SplitAsNeeded(*nsGkAtoms::div, curParent, offset);
NS_ENSURE_SUCCESS(rv, rv);
curDiv = htmlEditor->CreateNode(nsGkAtoms::div, curParent, offset);
NS_ENSURE_STATE(curDiv);
@@ -6385,17 +6394,20 @@ HTMLEditRules::ReturnInParagraph(Selecti
TextEditUtils::HasMozAttr(GetAsDOMNode(sibling))) {
NS_ENSURE_STATE(mHTMLEditor);
newBRneeded = true;
offset++;
}
} else {
if (doesCRCreateNewP) {
nsCOMPtr<nsIDOMNode> tmp;
- rv = mTextEditor->SplitNode(aNode, aOffset, getter_AddRefs(tmp));
+ if (NS_WARN_IF(!mHTMLEditor)) {
+ return NS_ERROR_UNEXPECTED;
+ }
+ rv = mHTMLEditor->SplitNode(aNode, aOffset, getter_AddRefs(tmp));
NS_ENSURE_SUCCESS(rv, rv);
selNode = tmp;
}
newBRneeded = true;
offset++;
}
} else {
@@ -6607,17 +6619,17 @@ HTMLEditRules::ReturnInListItem(Selectio
nsCOMPtr<nsINode> list = aListItem.GetParentNode();
int32_t itemOffset = list ? list->IndexOf(&aListItem) : -1;
nsIAtom* listAtom = nodeAtom == nsGkAtoms::dt ? nsGkAtoms::dd
: nsGkAtoms::dt;
nsCOMPtr<Element> newListItem =
htmlEditor->CreateNode(listAtom, list, itemOffset + 1);
NS_ENSURE_STATE(newListItem);
- rv = mTextEditor->DeleteNode(&aListItem);
+ rv = htmlEditor->DeleteNode(&aListItem);
NS_ENSURE_SUCCESS(rv, rv);
rv = aSelection.Collapse(newListItem, 0);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
nsCOMPtr<Element> brNode;
@@ -8861,17 +8873,17 @@ HTMLEditRules::DocumentModifiedWorker()
RefPtr<Selection> selection = htmlEditor->GetSelection();
if (!selection) {
return;
}
// Delete our bogus node, if we have one, since the document might not be
// empty any more.
if (mBogusNode) {
- mTextEditor->DeleteNode(mBogusNode);
+ htmlEditor->DeleteNode(mBogusNode);
mBogusNode = nullptr;
}
// Try to recreate the bogus node if needed.
CreateBogusNodeIfNeeded(selection);
}
} // namespace mozilla