Make sure to notify document observers even about content that gets added to

the document before StartLayout().  Block those notifications from getting
passed on to the frame constructor before StartLayout(), though.  Bug 220930,
r=peterv, sr=jst
This commit is contained in:
bzbarsky%mit.edu 2003-10-11 00:27:45 +00:00
parent 009763dfa8
commit 90bce6cd8e
4 changed files with 47 additions and 23 deletions

View File

@ -2851,25 +2851,7 @@ HTMLContentSink::OpenBody(const nsIParserNode& aNode)
MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::OpenBody()\n"));
MOZ_TIMER_STOP(mWatch);
// Check to see if InitialReflow() has been called on any of our
// presShells. If so, the InitialReflow() call inside StartLayout()
// will be supressed, so we can't rely on it to construct the body
// frame for us, so we'll have to manually call NotifyInsert() or
// NotifyAppend() to make sure a body frame gets constructed. (Bug 153815)
PRBool didInitialReflow = PR_FALSE;
PRUint32 i, ns = mDocument->GetNumberOfShells();
for (i = 0; i < ns; i++) {
nsIPresShell *shell = mDocument->GetShellAt(i);
shell->GetDidInitialReflow(&didInitialReflow);
if (didInitialReflow) {
break;
}
}
if (didInitialReflow && mCurrentContext->mStackPos > 1) {
if (mCurrentContext->mStackPos > 1) {
PRInt32 parentIndex = mCurrentContext->mStackPos - 2;
nsIHTMLContent *parent = mCurrentContext->mStack[parentIndex].mContent;
PRInt32 numFlushed = mCurrentContext->mStack[parentIndex].mNumFlushed;
@ -2883,10 +2865,6 @@ HTMLContentSink::OpenBody(const nsIParserNode& aNode)
if (insertionPoint != -1) {
NotifyInsert(parent, mBody, insertionPoint - 1);
} else {
// XXX: Would it be better to use |parent->ChildCount() - 1| so
// that we don't cause notifications for the <head> element and
// it's children?
NotifyAppend(parent, numFlushed);
}
}

View File

@ -267,6 +267,19 @@ nsXMLContentSink::DidBuildModel()
loader->RemoveObserver(this);
}
// Notify document observers that all the content has been stuck
// into the document.
// XXX do we need to notify for things like PIs? Or just the
// documentElement?
NS_ASSERTION(mDocument->IndexOf(mDocElement) != -1,
"mDocElement not in doc?");
mDocument->BeginUpdate(UPDATE_CONTENT_MODEL);
mDocument->ContentInserted(nsnull, mDocElement,
// XXXbz is this last arg relevant if
// the container is null?
mDocument->IndexOf(mDocElement));
mDocument->EndUpdate(UPDATE_CONTENT_MODEL);
StartLayout();
#if 0 /* Disable until this works for XML */
@ -347,6 +360,23 @@ nsXMLContentSink::OnTransformDone(nsresult aResult,
loader->RemoveObserver(this);
}
// Notify document observers that all the content has been stuck
// into the document.
// XXX do we need to notify for things like PIs? Or just the
// documentElement?
nsCOMPtr<nsIContent> rootContent;
mDocument->GetRootContent(getter_AddRefs(rootContent));
if (rootContent) {
NS_ASSERTION(mDocument->IndexOf(rootContent) != -1,
"rootContent not in doc?");
mDocument->BeginUpdate(UPDATE_CONTENT_MODEL);
mDocument->ContentInserted(nsnull, mDocElement,
// XXXbz is this last arg relevant if
// the container is null?
mDocument->IndexOf(rootContent));
mDocument->EndUpdate(UPDATE_CONTENT_MODEL);
}
// Start the layout process
StartLayout();

View File

@ -5335,6 +5335,10 @@ PresShell::ContentAppended(nsIDocument *aDocument,
nsIContent* aContainer,
PRInt32 aNewIndexInContainer)
{
if (!mDidInitialReflow) {
return NS_OK;
}
WillCauseReflow();
MOZ_TIMER_DEBUGLOG(("Start: Frame Creation: PresShell::ContentAppended(), this=%p\n", this));
MOZ_TIMER_START(mFrameCreationWatch);
@ -5356,6 +5360,10 @@ PresShell::ContentInserted(nsIDocument* aDocument,
nsIContent* aChild,
PRInt32 aIndexInContainer)
{
if (!mDidInitialReflow) {
return NS_OK;
}
WillCauseReflow();
nsresult rv = mStyleSet->ContentInserted(mPresContext, aContainer, aChild, aIndexInContainer);
VERIFY_STYLE_TREE;

View File

@ -5335,6 +5335,10 @@ PresShell::ContentAppended(nsIDocument *aDocument,
nsIContent* aContainer,
PRInt32 aNewIndexInContainer)
{
if (!mDidInitialReflow) {
return NS_OK;
}
WillCauseReflow();
MOZ_TIMER_DEBUGLOG(("Start: Frame Creation: PresShell::ContentAppended(), this=%p\n", this));
MOZ_TIMER_START(mFrameCreationWatch);
@ -5356,6 +5360,10 @@ PresShell::ContentInserted(nsIDocument* aDocument,
nsIContent* aChild,
PRInt32 aIndexInContainer)
{
if (!mDidInitialReflow) {
return NS_OK;
}
WillCauseReflow();
nsresult rv = mStyleSet->ContentInserted(mPresContext, aContainer, aChild, aIndexInContainer);
VERIFY_STYLE_TREE;