Bug 1460509 - part 7: Make TextEditRules::DidDeleteSelection() return NS_ERROR_EDITOR_DESTROYED if it causes destroying the editor r=m_kato

And also this patch removes unnecessary arguments from the method.

MozReview-Commit-ID: UKscK4vFVX

--HG--
extra : rebase_source : 7f6b9405824a3f175f165a2d7d75a293108278f3
This commit is contained in:
Masayuki Nakano 2018-05-11 16:48:29 +09:00
parent d6057a85d0
commit b2219367ca
3 changed files with 12 additions and 6 deletions

View File

@ -3707,7 +3707,7 @@ HTMLEditRules::DidDeleteSelection(nsIEditor::EDirection aDir,
}
// call through to base class
return TextEditRules::DidDeleteSelection(aDir, aResult);
return TextEditRules::DidDeleteSelection();
}
nsresult

View File

@ -377,7 +377,7 @@ TextEditRules::DidDoAction(Selection* aSelection,
switch (aInfo->action) {
case EditAction::deleteSelection:
return DidDeleteSelection(aInfo->collapsedAction, aResult);
return DidDeleteSelection();
case EditAction::undo:
return DidUndo(aResult);
case EditAction::redo:
@ -1081,8 +1081,7 @@ TextEditRules::WillDeleteSelection(nsIEditor::EDirection aCollapsedAction,
}
nsresult
TextEditRules::DidDeleteSelection(nsIEditor::EDirection aCollapsedAction,
nsresult aResult)
TextEditRules::DidDeleteSelection()
{
MOZ_ASSERT(IsEditorDataAvailable());
@ -1098,6 +1097,9 @@ TextEditRules::DidDeleteSelection(nsIEditor::EDirection aCollapsedAction,
nsresult rv =
TextEditorRef().DeleteNodeWithTransaction(
*selectionStartPoint.GetContainer());
if (NS_WARN_IF(!CanHandleEditAction())) {
return NS_ERROR_EDITOR_DESTROYED;
}
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}

View File

@ -149,8 +149,12 @@ protected:
nsresult WillDeleteSelection(nsIEditor::EDirection aCollapsedAction,
bool* aCancel,
bool* aHandled);
nsresult DidDeleteSelection(nsIEditor::EDirection aCollapsedAction,
nsresult aResult);
/**
* Called after deleted selected content.
* This method may remove empty text node and makes guarantee that caret
* is never at left of <br> element.
*/
MOZ_MUST_USE nsresult DidDeleteSelection();
nsresult WillSetTextProperty(bool* aCancel, bool* aHandled);