Try to avoid crashing in a timer callback in the HTML5 tree builder

This commit is contained in:
Henri Sivonen 2009-03-17 11:38:08 +02:00
parent 564b78820e
commit 9936094021
2 changed files with 14 additions and 0 deletions

View File

@ -68,6 +68,9 @@ nsHtml5TreeBuilder::nsHtml5TreeBuilder(nsHtml5Parser* aParser)
formPointer(nsnull),
headPointer(nsnull),
mNeedsFlush(PR_FALSE),
#ifdef DEBUG
mActive(PR_FALSE),
#endif
mFlushTimer(do_CreateInstance("@mozilla.org/timer;1")),
mParser(aParser)
{
@ -77,7 +80,9 @@ nsHtml5TreeBuilder::nsHtml5TreeBuilder(nsHtml5Parser* aParser)
nsHtml5TreeBuilder::~nsHtml5TreeBuilder()
{
MOZ_COUNT_DTOR(nsHtml5TreeBuilder);
NS_ASSERTION(!mActive, "nsHtml5TreeBuilder deleted without ever calling end() on it!");
mOpQueue.Clear();
mFlushTimer->Cancel(); // XXX why is this even necessary? it is, though.
}
nsIContent*
@ -252,6 +257,9 @@ nsHtml5TreeBuilder::start(PRBool fragment)
mParser->GetDocument()->BeginLoad(); // XXX fragment?
}
mNeedsFlush = PR_FALSE;
#ifdef DEBUG
mActive = PR_TRUE;
#endif
}
void
@ -259,6 +267,9 @@ nsHtml5TreeBuilder::end()
{
mFlushTimer->Cancel();
Flush();
#ifdef DEBUG
mActive = PR_FALSE;
#endif
#ifdef DEBUG_hsivonen
printf("MAX INSERTION BATCH LEN: %d\n", sInsertionBatchMaxLength);
printf("MAX NOTIFICATION BATCH LEN: %d\n", sAppendBatchMaxSize);

View File

@ -47,6 +47,9 @@
nsCOMPtr<nsITimer> mFlushTimer;
nsHtml5Parser* mParser; // weak ref
PRBool mHasProcessedBase;
#ifdef DEBUG
PRBool mActive;
#endif
nsTArray<nsHtml5TreeOperation> mOpQueue;
nsTArray<nsIContentPtr> mElementsSeenInThisAppendBatch;
nsTArray<nsHtml5PendingNotification> mPendingNotifications;