From 661f32547b2cd13c8bc63d2bf79b52e9430adc5b Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Sat, 13 Jan 2007 03:32:31 +0000 Subject: [PATCH] ConstructDocElementFrame can return null if the XBL hasn't loaded yet. Handle that XBL loading later by changing how XBL triggers the frame construction and making it possible to recreate the doc element hierarchy even if there is no doc element frame. Bug 366207, r=sicking, sr=roc --- content/xbl/src/nsXBLService.cpp | 10 +------- layout/base/nsCSSFrameConstructor.cpp | 37 ++++++++++++++------------- 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/content/xbl/src/nsXBLService.cpp b/content/xbl/src/nsXBLService.cpp index ef28818ea60..1a86aa17c02 100644 --- a/content/xbl/src/nsXBLService.cpp +++ b/content/xbl/src/nsXBLService.cpp @@ -174,13 +174,6 @@ public: if (!ready) return; - // XXX Deal with layered bindings. For example, mBoundElement may be anonymous content. - // Now do a ContentInserted notification to cause the frames to get installed finally, - nsIContent* parent = mBoundElement->GetParent(); - PRInt32 index = 0; - if (parent) - index = parent->IndexOf(mBoundElement); - // If |mBoundElement| is (in addition to having binding |mBinding|) // also a descendant of another element with binding |mBinding|, // then we might have just constructed it due to the @@ -199,8 +192,7 @@ public: shell->FrameManager()->GetUndisplayedContent(mBoundElement); if (!sc) { - nsCOMPtr obs(do_QueryInterface(shell)); - obs->ContentInserted(doc, parent, mBoundElement, index); + shell->RecreateFramesFor(mBoundElement); } } } diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 3a8bee990f2..030f5bfe53b 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -7638,26 +7638,27 @@ nsCSSFrameConstructor::ReconstructDocElementHierarchyInternal() // XXXbz So why can't we reuse ContentRemoved? - nsIFrame* docParentFrame = docElementFrame->GetParent(); + NS_ASSERTION(docElementFrame->GetParent() == mDocElementContainingBlock, + "Unexpected doc element parent frame"); - NS_ASSERTION(docParentFrame, "should have a parent frame"); - if (docParentFrame) { - // Remove the old document element hieararchy - rv = state.mFrameManager->RemoveFrame(docParentFrame, nsnull, - docElementFrame); - if (NS_SUCCEEDED(rv)) { - // Create the new document element hierarchy - nsIFrame* newChild; - rv = ConstructDocElementFrame(state, rootContent, - docParentFrame, &newChild); - - if (NS_SUCCEEDED(rv)) { - rv = state.mFrameManager->InsertFrames(docParentFrame, nsnull, - nsnull, newChild); - - } - } + // Remove the old document element hieararchy + rv = state.mFrameManager->RemoveFrame(mDocElementContainingBlock, + nsnull, docElementFrame); + if (NS_FAILED(rv)) { + return rv; } + + } + + // Create the new document element hierarchy + nsIFrame* newChild; + rv = ConstructDocElementFrame(state, rootContent, + mDocElementContainingBlock, &newChild); + + // newChild could be null even if |rv| is success, thanks to XBL. + if (NS_SUCCEEDED(rv) && newChild) { + rv = state.mFrameManager->InsertFrames(mDocElementContainingBlock, + nsnull, nsnull, newChild); } } }