mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-07 08:18:41 +09:00
Edit transactions should store their editor instance with strong reference
Edit transactions should store their editor instance with a strong reference, and they should be released when the editor is destroyed.
This commit is contained in:
parent
2f312335f3
commit
fbab5890eb
23 changed files with 150 additions and 53 deletions
|
|
@ -50,6 +50,7 @@ CreateElementTransaction::~CreateElementTransaction()
|
|||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(CreateElementTransaction,
|
||||
EditTransactionBase,
|
||||
mEditorBase,
|
||||
mParent,
|
||||
mNewNode,
|
||||
mRefNode)
|
||||
|
|
@ -63,7 +64,9 @@ NS_INTERFACE_MAP_END_INHERITING(EditTransactionBase)
|
|||
NS_IMETHODIMP
|
||||
CreateElementTransaction::DoTransaction()
|
||||
{
|
||||
MOZ_ASSERT(mEditorBase && mTag && mParent);
|
||||
if (NS_WARN_IF(!mEditorBase) || NS_WARN_IF(!mTag) || NS_WARN_IF(!mParent)) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
mNewNode = mEditorBase->CreateHTMLContent(mTag);
|
||||
NS_ENSURE_STATE(mNewNode);
|
||||
|
|
@ -106,7 +109,9 @@ CreateElementTransaction::DoTransaction()
|
|||
NS_IMETHODIMP
|
||||
CreateElementTransaction::UndoTransaction()
|
||||
{
|
||||
MOZ_ASSERT(mEditorBase && mParent);
|
||||
if (NS_WARN_IF(!mEditorBase) || NS_WARN_IF(!mParent)) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
ErrorResult rv;
|
||||
mParent->RemoveChild(*mNewNode, rv);
|
||||
|
|
@ -117,7 +122,9 @@ CreateElementTransaction::UndoTransaction()
|
|||
NS_IMETHODIMP
|
||||
CreateElementTransaction::RedoTransaction()
|
||||
{
|
||||
MOZ_ASSERT(mEditorBase && mParent);
|
||||
if (NS_WARN_IF(!mEditorBase) || NS_WARN_IF(!mParent)) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
// First, reset mNewNode so it has no attributes or content
|
||||
// XXX We never actually did this, we only cleared mNewNode's contents if it
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue