Bug 1460509 - part 5: Make TextEditRules::CreateTrailingBRIfNeeded() return NS_ERROR_EDITOR_DESTROYED if it causes destroying the editor r?m_kato
MozReview-Commit-ID: CNTgECam862
--- a/editor/libeditor/TextEditRules.cpp
+++ b/editor/libeditor/TextEditRules.cpp
@@ -1407,16 +1407,19 @@ TextEditRules::CreateTrailingBRIfNeeded(
// Morph it back to a mozBR
lastChild->AsElement()->UnsetAttr(kNameSpaceID_None,
kMOZEditorBogusNodeAttrAtom,
false);
lastChild->AsElement()->SetAttr(kNameSpaceID_None, nsGkAtoms::type,
NS_LITERAL_STRING("_moz"),
true);
+ if (NS_WARN_IF(!CanHandleEditAction())) {
+ return NS_ERROR_EDITOR_DESTROYED;
+ }
return NS_OK;
}
nsresult
TextEditRules::CreateBogusNodeIfNeeded()
{
MOZ_ASSERT(IsEditorDataAvailable());
--- a/editor/libeditor/TextEditRules.h
+++ b/editor/libeditor/TextEditRules.h
@@ -179,17 +179,17 @@ protected:
/**
* Check for and replace a redundant trailing break.
*/
nsresult RemoveRedundantTrailingBR();
/**
* Creates a trailing break in the text doc if there is not one already.
*/
- nsresult CreateTrailingBRIfNeeded();
+ MOZ_MUST_USE nsresult CreateTrailingBRIfNeeded();
/**
* Creates a bogus <br> node if the root element has no editable content.
*/
MOZ_MUST_USE nsresult CreateBogusNodeIfNeeded();
/**
* Returns a truncated insertion string if insertion would place us over