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

MozReview-Commit-ID: DXzdtPQ01lo

--HG--
extra : rebase_source : 1fa36a1195aa7a6b5d891f83659af155b5bb16c0
This commit is contained in:
Masayuki Nakano 2018-05-11 19:32:00 +09:00
Родитель 531991202f
Коммит 8cb4cfda65
2 изменённых файлов: 26 добавлений и 5 удалений

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

@ -10232,11 +10232,21 @@ HTMLEditRules::WillRemoveAbsolutePosition(bool* aCancel,
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
AutoSelectionRestorer selectionRestorer(&SelectionRef(), &HTMLEditorRef()); {
AutoSelectionRestorer selectionRestorer(&SelectionRef(), &HTMLEditorRef());
nsresult rv = HTMLEditorRef().SetPositionToAbsoluteOrStatic(*element, false); nsresult rv = HTMLEditorRef().SetPositionToAbsoluteOrStatic(*element, false);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(!CanHandleEditAction())) {
return rv; return NS_ERROR_EDITOR_DESTROYED;
}
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
}
// Restoring Selection might cause destroying the HTML editor.
if (NS_WARN_IF(!CanHandleEditAction())) {
return NS_ERROR_EDITOR_DESTROYED;
} }
return NS_OK; return NS_OK;
} }

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

@ -259,7 +259,18 @@ protected:
nsresult WillAlign(const nsAString& aAlignType, nsresult WillAlign(const nsAString& aAlignType,
bool* aCancel, bool* aHandled); bool* aCancel, bool* aHandled);
nsresult WillAbsolutePosition(bool* aCancel, bool* aHandled); nsresult WillAbsolutePosition(bool* aCancel, bool* aHandled);
nsresult WillRemoveAbsolutePosition(bool* aCancel, bool* aHandled);
/**
* Called before changing absolute positioned element to static positioned.
* This method actually changes the position property of nearest absolute
* positioned element. Therefore, this might cause destroying the HTML
* editor.
*
* @param aCancel Returns true if the operation is canceled.
* @param aHandled Returns true if the edit action is handled.
*/
MOZ_MUST_USE nsresult
WillRemoveAbsolutePosition(bool* aCancel, bool* aHandled);
/** /**
* Called before changing z-index. * Called before changing z-index.