зеркало из https://github.com/mozilla/gecko-dev.git
Clear the weak back pointers in nsTextEditRules and nsHTMLEditRules when they are no longer valid, to prepare for editor cycle collection. (Bug 423233) r+sr=peterv
This commit is contained in:
Родитель
d6f3ecb3aa
Коммит
2dc4c3c055
|
@ -38,10 +38,10 @@
|
|||
#ifndef nsEditRules_h__
|
||||
#define nsEditRules_h__
|
||||
|
||||
// 783223c9-153a-4e01-8422-39a3afe469da
|
||||
#define NS_IEDITRULES_IID \
|
||||
{ /* a6cf911d-15b3-11d2-932e-00805f8add32 */ \
|
||||
0xa6cf911d, 0x15b3, 0x11d2, \
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
|
||||
{ 0x783223c9, 0x153a, 0x4e01, \
|
||||
{ 0x84, 0x22, 0x39, 0xa3, 0xaf, 0xe4, 0x69, 0xda } }
|
||||
|
||||
class nsPlaintextEditor;
|
||||
class nsISelection;
|
||||
|
@ -73,6 +73,7 @@ public:
|
|||
//NOTE: Use NS_DECL_ISUPPORTS_INHERITED in any class inherited from nsIEditRules
|
||||
|
||||
NS_IMETHOD Init(nsPlaintextEditor *aEditor, PRUint32 aFlags)=0;
|
||||
NS_IMETHOD DetachEditor()=0;
|
||||
NS_IMETHOD BeforeEdit(PRInt32 action, nsIEditor::EDirection aDirection)=0;
|
||||
NS_IMETHOD AfterEdit(PRInt32 action, nsIEditor::EDirection aDirection)=0;
|
||||
NS_IMETHOD WillDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, PRBool *aCancel, PRBool *aHandled)=0;
|
||||
|
|
|
@ -225,11 +225,12 @@ mDocChangeRange(nsnull)
|
|||
nsHTMLEditRules::~nsHTMLEditRules()
|
||||
{
|
||||
// remove ourselves as a listener to edit actions
|
||||
// In the normal case, we have already been removed by
|
||||
// ~nsHTMLEditor, in which case we will get an error here
|
||||
// In some cases, we have already been removed by
|
||||
// ~nsHTMLEditor, in which case we will get a null pointer here
|
||||
// which we ignore. But this allows us to add the ability to
|
||||
// switch rule sets on the fly if we want.
|
||||
mHTMLEditor->RemoveEditActionListener(this);
|
||||
if (mHTMLEditor)
|
||||
mHTMLEditor->RemoveEditActionListener(this);
|
||||
}
|
||||
|
||||
/********************************************************
|
||||
|
@ -302,6 +303,12 @@ nsHTMLEditRules::Init(nsPlaintextEditor *aEditor, PRUint32 aFlags)
|
|||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditRules::DetachEditor()
|
||||
{
|
||||
mHTMLEditor = nsnull;
|
||||
return nsTextEditRules::DetachEditor();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditRules::BeforeEdit(PRInt32 action, nsIEditor::EDirection aDirection)
|
||||
|
|
|
@ -87,6 +87,7 @@ public:
|
|||
|
||||
// nsIEditRules methods
|
||||
NS_IMETHOD Init(nsPlaintextEditor *aEditor, PRUint32 aFlags);
|
||||
NS_IMETHOD DetachEditor();
|
||||
NS_IMETHOD BeforeEdit(PRInt32 action, nsIEditor::EDirection aDirection);
|
||||
NS_IMETHOD AfterEdit(PRInt32 action, nsIEditor::EDirection aDirection);
|
||||
NS_IMETHOD WillDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, PRBool *aCancel, PRBool *aHandled);
|
||||
|
|
|
@ -115,6 +115,9 @@ nsPlaintextEditor::~nsPlaintextEditor()
|
|||
// Remove event listeners. Note that if we had an HTML editor,
|
||||
// it installed its own instead of these
|
||||
RemoveEventListeners();
|
||||
|
||||
if (mRules)
|
||||
mRules->DetachEditor();
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsPlaintextEditor, nsEditor)
|
||||
|
|
|
@ -182,6 +182,13 @@ nsTextEditRules::Init(nsPlaintextEditor *aEditor, PRUint32 aFlags)
|
|||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextEditRules::DetachEditor()
|
||||
{
|
||||
mEditor = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextEditRules::GetFlags(PRUint32 *aFlags)
|
||||
{
|
||||
|
|
|
@ -66,6 +66,7 @@ public:
|
|||
|
||||
// nsIEditRules methods
|
||||
NS_IMETHOD Init(nsPlaintextEditor *aEditor, PRUint32 aFlags);
|
||||
NS_IMETHOD DetachEditor();
|
||||
NS_IMETHOD BeforeEdit(PRInt32 action, nsIEditor::EDirection aDirection);
|
||||
NS_IMETHOD AfterEdit(PRInt32 action, nsIEditor::EDirection aDirection);
|
||||
NS_IMETHOD WillDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, PRBool *aCancel, PRBool *aHandled);
|
||||
|
|
Загрузка…
Ссылка в новой задаче