Bug 221820 - Part 3: Debug-only assertion for reentrancy detection; r=bzbarsky
This commit is contained in:
@@ -951,6 +951,31 @@ NS_IMETHODIMP nsTextControlFrame::GetAccessible(nsIAccessible** aAccessible)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
class EditorInitializerEntryTracker {
|
||||
public:
|
||||
explicit EditorInitializerEntryTracker(nsTextControlFrame &frame)
|
||||
: mFrame(frame)
|
||||
, mFirstEntry(PR_FALSE)
|
||||
{
|
||||
if (!mFrame.mInEditorInitialization) {
|
||||
mFrame.mInEditorInitialization = PR_TRUE;
|
||||
mFirstEntry = PR_TRUE;
|
||||
}
|
||||
}
|
||||
~EditorInitializerEntryTracker()
|
||||
{
|
||||
if (mFirstEntry) {
|
||||
mFrame.mInEditorInitialization = PR_FALSE;
|
||||
}
|
||||
}
|
||||
PRBool EnteredMoreThanOnce() const { return !mFirstEntry; }
|
||||
private:
|
||||
nsTextControlFrame &mFrame;
|
||||
PRBool mFirstEntry;
|
||||
};
|
||||
#endif
|
||||
|
||||
nsTextControlFrame::nsTextControlFrame(nsIPresShell* aShell, nsStyleContext* aContext)
|
||||
: nsStackFrame(aShell, aContext)
|
||||
, mUseEditor(PR_FALSE)
|
||||
@@ -960,6 +985,9 @@ nsTextControlFrame::nsTextControlFrame(nsIPresShell* aShell, nsStyleContext* aCo
|
||||
, mFireChangeEventState(PR_FALSE)
|
||||
, mInSecureKeyboardInputMode(PR_FALSE)
|
||||
, mTextListener(nsnull)
|
||||
#ifdef DEBUG
|
||||
, mInEditorInitialization(PR_FALSE)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1507,6 +1535,14 @@ nsTextControlFrame::EnsureEditorInitialized()
|
||||
// editor.
|
||||
mUseEditor = PR_TRUE;
|
||||
|
||||
#ifdef DEBUG
|
||||
// Make sure we are not being called again until we're finished.
|
||||
// If reentrancy happens, just pretend that we don't have an editor.
|
||||
const EditorInitializerEntryTracker tracker(*this);
|
||||
NS_ASSERTION(!tracker.EnteredMoreThanOnce(),
|
||||
"EnsureEditorInitialized has been called while a previous call was in progress");
|
||||
#endif
|
||||
|
||||
// If we have a default value, insert it under the div we created
|
||||
// above, but be sure to use the editor so that '*' characters get
|
||||
// displayed for password fields, etc. SetValue() will call the
|
||||
|
||||
Reference in New Issue
Block a user