mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-04 14:58:37 +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
|
|
@ -21,7 +21,7 @@ using namespace dom;
|
|||
JoinNodeTransaction::JoinNodeTransaction(EditorBase& aEditorBase,
|
||||
nsINode& aLeftNode,
|
||||
nsINode& aRightNode)
|
||||
: mEditorBase(aEditorBase)
|
||||
: mEditorBase(&aEditorBase)
|
||||
, mLeftNode(&aLeftNode)
|
||||
, mRightNode(&aRightNode)
|
||||
, mOffset(0)
|
||||
|
|
@ -29,6 +29,7 @@ JoinNodeTransaction::JoinNodeTransaction(EditorBase& aEditorBase,
|
|||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(JoinNodeTransaction, EditTransactionBase,
|
||||
mEditorBase,
|
||||
mLeftNode,
|
||||
mRightNode,
|
||||
mParent)
|
||||
|
|
@ -39,7 +40,8 @@ NS_INTERFACE_MAP_END_INHERITING(EditTransactionBase)
|
|||
nsresult
|
||||
JoinNodeTransaction::CheckValidity()
|
||||
{
|
||||
if (!mEditorBase.IsModifiableNode(mLeftNode->GetParentNode())) {
|
||||
if (NS_WARN_IF(!mEditorBase) ||
|
||||
!mEditorBase->IsModifiableNode(mLeftNode->GetParentNode())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_OK;
|
||||
|
|
@ -50,6 +52,12 @@ JoinNodeTransaction::CheckValidity()
|
|||
NS_IMETHODIMP
|
||||
JoinNodeTransaction::DoTransaction()
|
||||
{
|
||||
if (NS_WARN_IF(!mEditorBase) ||
|
||||
NS_WARN_IF(!mLeftNode) ||
|
||||
NS_WARN_IF(!mRightNode)) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
// Get the parent node
|
||||
nsCOMPtr<nsINode> leftParent = mLeftNode->GetParentNode();
|
||||
NS_ENSURE_TRUE(leftParent, NS_ERROR_NULL_POINTER);
|
||||
|
|
@ -65,7 +73,7 @@ JoinNodeTransaction::DoTransaction()
|
|||
mParent = leftParent;
|
||||
mOffset = mLeftNode->Length();
|
||||
|
||||
return mEditorBase.JoinNodesImpl(mRightNode, mLeftNode, mParent);
|
||||
return mEditorBase->JoinNodesImpl(mRightNode, mLeftNode, mParent);
|
||||
}
|
||||
|
||||
//XXX: What if instead of split, we just deleted the unneeded children of
|
||||
|
|
@ -73,7 +81,11 @@ JoinNodeTransaction::DoTransaction()
|
|||
NS_IMETHODIMP
|
||||
JoinNodeTransaction::UndoTransaction()
|
||||
{
|
||||
MOZ_ASSERT(mParent);
|
||||
if (NS_WARN_IF(!mParent) ||
|
||||
NS_WARN_IF(!mRightNode) ||
|
||||
NS_WARN_IF(!mLeftNode)) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
// First, massage the existing node so it is in its post-split state
|
||||
ErrorResult rv;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue