Bug 1460509 - part 83: Make HTMLEditRules::InsertBRIfNeeded() return NS_ERROR_EDITOR_DESTROYED if it causes destroying the editor r=m_kato

MozReview-Commit-ID: Kuga8LvWfaM

--HG--
extra : rebase_source : 8e3e855268a5bddf069a8cfbb869eb64074188fb
This commit is contained in:
Masayuki Nakano 2018-05-18 12:41:53 +09:00
Родитель ec1146f4c4
Коммит ddb1f08834
2 изменённых файлов: 9 добавлений и 8 удалений

Просмотреть файл

@ -3345,13 +3345,6 @@ HTMLEditRules::DeleteNodeIfCollapsedText(nsINode& aNode)
return NS_OK;
}
/**
* InsertBRIfNeeded() determines if a br is needed for current selection to not
* be spastic. If so, it inserts one. Callers responsibility to only call
* with collapsed selection.
*
* @param aSelection The collapsed selection.
*/
nsresult
HTMLEditRules::InsertBRIfNeeded()
{
@ -3381,6 +3374,9 @@ HTMLEditRules::InsertBRIfNeeded()
HTMLEditorRef().InsertBrElementWithTransaction(SelectionRef(),
atStartOfSelection,
nsIEditor::ePrevious);
if (NS_WARN_IF(!CanHandleEditAction())) {
return NS_ERROR_EDITOR_DESTROYED;
}
if (NS_WARN_IF(!brElement)) {
return NS_ERROR_FAILURE;
}

Просмотреть файл

@ -259,7 +259,12 @@ protected:
*/
MOZ_MUST_USE nsresult DidDeleteSelection();
nsresult InsertBRIfNeeded();
/**
* InsertBRIfNeeded() determines if a br is needed for current selection to
* not be spastic. If so, it inserts one. Callers responsibility to only
* call with collapsed selection.
*/
MOZ_MUST_USE nsresult InsertBRIfNeeded();
/**
* CanContainParagraph() returns true if aElement can have a <p> element as