From 7c693e494e1cbc0eb1849d2e23e2f626ff42e6cc Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Thu, 4 Oct 2007 05:16:35 +0000 Subject: [PATCH] Make sure to notify on the root if a flush happens before we've done so. Bug 397856, r=peterv, sr=sicking git-svn-id: svn://10.0.0.236/trunk@237254 18797224-902f-48f8-a5cc-f745e15eee43 --- .../html/document/src/nsHTMLContentSink.cpp | 56 ++++++++++++------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index 90e0a08cbcf..d5c9d8e4046 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -314,6 +314,8 @@ protected: void NotifyInsert(nsIContent* aContent, nsIContent* aChildContent, PRInt32 aIndexInContainer); + void NotifyRootInsertion(); + PRBool IsMonolithicContainer(nsHTMLTag aTag); #ifdef NS_DEBUG @@ -2343,24 +2345,7 @@ HTMLContentSink::OpenContainer(const nsIParserNode& aNode) // already-present attributes on the root. AddAttributes(aNode, mRoot, PR_TRUE, mNotifiedRootInsertion); if (!mNotifiedRootInsertion) { - NS_ASSERTION(!mLayoutStarted, - "How did we start layout without notifying on root?"); - // Now make sure to notify that we have now inserted our root. If - // there has been no initial reflow yet it'll be a no-op, but if - // there has been one we need this to get its frames constructed. - // Note that if mNotifiedRootInsertion is true we don't notify here, - // since that just means there are multiple tags in the - // document; in those cases we just want to put all the attrs on one - // tag. - mNotifiedRootInsertion = PR_TRUE; - PRInt32 index = mDocument->IndexOf(mRoot); - NS_ASSERTION(index != -1, "mRoot not child of document?"); - NotifyInsert(nsnull, mRoot, index); - - // Now update the notification information in all our - // contexts, since we just inserted the root and notified on - // our whole tree - UpdateChildCounts(); + NotifyRootInsertion(); } } break; @@ -3061,6 +3046,30 @@ HTMLContentSink::NotifyInsert(nsIContent* aContent, mInNotification--; } +void +HTMLContentSink::NotifyRootInsertion() +{ + NS_PRECONDITION(!mNotifiedRootInsertion, "Double-notifying on root?"); + NS_ASSERTION(!mLayoutStarted, + "How did we start layout without notifying on root?"); + // Now make sure to notify that we have now inserted our root. If + // there has been no initial reflow yet it'll be a no-op, but if + // there has been one we need this to get its frames constructed. + // Note that if mNotifiedRootInsertion is true we don't notify here, + // since that just means there are multiple tags in the + // document; in those cases we just want to put all the attrs on one + // tag. + mNotifiedRootInsertion = PR_TRUE; + PRInt32 index = mDocument->IndexOf(mRoot); + NS_ASSERTION(index != -1, "mRoot not child of document?"); + NotifyInsert(nsnull, mRoot, index); + + // Now update the notification information in all our + // contexts, since we just inserted the root and notified on + // our whole tree + UpdateChildCounts(); +} + PRBool HTMLContentSink::IsMonolithicContainer(nsHTMLTag aTag) { @@ -3198,11 +3207,11 @@ HTMLContentSink::FlushPendingNotifications(mozFlushType aType) { // Only flush tags if we're not doing the notification ourselves // (since we aren't reentrant) - if (mCurrentContext && !mInNotification) { + if (!mInNotification) { if (aType >= Flush_ContentAndNotify) { - mCurrentContext->FlushTags(); + FlushTags(); } - else { + else if (mCurrentContext) { mCurrentContext->FlushText(); } if (aType >= Flush_Layout) { @@ -3216,6 +3225,11 @@ HTMLContentSink::FlushPendingNotifications(mozFlushType aType) nsresult HTMLContentSink::FlushTags() { + if (!mNotifiedRootInsertion) { + NotifyRootInsertion(); + return NS_OK; + } + return mCurrentContext ? mCurrentContext->FlushTags() : NS_OK; }