зеркало из https://github.com/mozilla/pjs.git
Fix for bug #75305: Doing Undo and Redo crashes browser
Added nsAutoUpdateViewBatch class, and use it in nsPlaintexteditor::Undo()/Redo(). editor/base/nsEditorUtils.h editor/base/nsPlaintextEditor.cpp r=jfrancis@netscape.com sr=sfraser@netscape.com
This commit is contained in:
Родитель
1395ecc9b1
Коммит
fa37dd981f
|
@ -144,6 +144,31 @@ class nsAutoTxnsConserveSelection
|
|||
PRBool mOldState;
|
||||
};
|
||||
|
||||
/***************************************************************************
|
||||
* stack based helper class for batching reflow and paint requests.
|
||||
*/
|
||||
class nsAutoUpdateViewBatch
|
||||
{
|
||||
public:
|
||||
|
||||
nsAutoUpdateViewBatch(nsEditor *ed) : mEd(ed)
|
||||
{
|
||||
NS_ASSERTION(mEd, "null mEd pointer!");
|
||||
|
||||
if (mEd)
|
||||
mEd->BeginUpdateViewBatch();
|
||||
}
|
||||
|
||||
~nsAutoUpdateViewBatch()
|
||||
{
|
||||
if (mEd)
|
||||
mEd->EndUpdateViewBatch();
|
||||
}
|
||||
|
||||
protected:
|
||||
nsEditor *mEd;
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
* some helper classes for iterating the dom tree
|
||||
*****************************************************************************/
|
||||
|
|
|
@ -1301,6 +1301,8 @@ nsPlaintextEditor::SetWrapWidth(PRInt32 aWrapColumn)
|
|||
NS_IMETHODIMP
|
||||
nsPlaintextEditor::Undo(PRUint32 aCount)
|
||||
{
|
||||
nsAutoUpdateViewBatch beginViewBatching(this);
|
||||
|
||||
ForceCompositionEnd();
|
||||
nsresult result = NS_OK;
|
||||
|
||||
|
@ -1327,6 +1329,7 @@ nsPlaintextEditor::Redo(PRUint32 aCount)
|
|||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
nsAutoUpdateViewBatch beginViewBatching(this);
|
||||
nsAutoRules beginRulesSniffing(this, kOpRedo, nsIEditor::eNone);
|
||||
|
||||
nsTextRulesInfo ruleInfo(nsTextEditRules::kRedo);
|
||||
|
|
|
@ -144,6 +144,31 @@ class nsAutoTxnsConserveSelection
|
|||
PRBool mOldState;
|
||||
};
|
||||
|
||||
/***************************************************************************
|
||||
* stack based helper class for batching reflow and paint requests.
|
||||
*/
|
||||
class nsAutoUpdateViewBatch
|
||||
{
|
||||
public:
|
||||
|
||||
nsAutoUpdateViewBatch(nsEditor *ed) : mEd(ed)
|
||||
{
|
||||
NS_ASSERTION(mEd, "null mEd pointer!");
|
||||
|
||||
if (mEd)
|
||||
mEd->BeginUpdateViewBatch();
|
||||
}
|
||||
|
||||
~nsAutoUpdateViewBatch()
|
||||
{
|
||||
if (mEd)
|
||||
mEd->EndUpdateViewBatch();
|
||||
}
|
||||
|
||||
protected:
|
||||
nsEditor *mEd;
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
* some helper classes for iterating the dom tree
|
||||
*****************************************************************************/
|
||||
|
|
|
@ -1301,6 +1301,8 @@ nsPlaintextEditor::SetWrapWidth(PRInt32 aWrapColumn)
|
|||
NS_IMETHODIMP
|
||||
nsPlaintextEditor::Undo(PRUint32 aCount)
|
||||
{
|
||||
nsAutoUpdateViewBatch beginViewBatching(this);
|
||||
|
||||
ForceCompositionEnd();
|
||||
nsresult result = NS_OK;
|
||||
|
||||
|
@ -1327,6 +1329,7 @@ nsPlaintextEditor::Redo(PRUint32 aCount)
|
|||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
nsAutoUpdateViewBatch beginViewBatching(this);
|
||||
nsAutoRules beginRulesSniffing(this, kOpRedo, nsIEditor::eNone);
|
||||
|
||||
nsTextRulesInfo ruleInfo(nsTextEditRules::kRedo);
|
||||
|
|
Загрузка…
Ссылка в новой задаче