From 8f4243ecdb73bbf3ab093a2ce2df2083dcdaf0dd Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Wed, 23 Aug 2006 04:02:21 +0000 Subject: [PATCH] Handle XUL popups gracefully in non-XUL documents. Bug 306940, r+sr=roc, a=dveditz for 1.8.0.7, a=schrep for 1.8.1 git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@208154 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/nsCSSFrameConstructor.cpp | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index 3d1741b3ed4..0aec9892b10 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -6324,7 +6324,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsFrameConstructorState& aState, if (rootFrame) rootFrame = rootFrame->GetFirstChild(nsnull); nsCOMPtr rootBox(do_QueryInterface(rootFrame)); - NS_ASSERTION(rootBox, "unexpected null pointer"); + PRBool added = PR_FALSE; if (rootBox) { nsIFrame* popupSetFrame; rootBox->GetPopupSetFrame(&popupSetFrame); @@ -6332,13 +6332,25 @@ nsCSSFrameConstructor::ConstructXULFrame(nsFrameConstructorState& aState, if (popupSetFrame) { nsCOMPtr popupSet(do_QueryInterface(popupSetFrame)); NS_ASSERTION(popupSet, "unexpected null pointer"); - if (popupSet) + if (popupSet) { + added = PR_TRUE; popupSet->AddPopupFrame(newFrame); + } } } - // Add the placeholder frame to the flow - aFrameItems.AddChild(placeholderFrame); + if (added) { + // Add the placeholder frame to the flow + aFrameItems.AddChild(placeholderFrame); + } else { + // Didn't add the popup set frame... Need to clean up and + // just not construct a frame here. + aState.mFrameManager->UnregisterPlaceholderFrame(NS_STATIC_CAST(nsPlaceholderFrame*, placeholderFrame)); + newFrame->Destroy(aState.mPresContext); + placeholderFrame->Destroy(aState.mPresContext); + *aHaltProcessing = PR_TRUE; + return NS_OK; + } } else { #endif // Add the new frame to our list of frame items. Note that we