diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index 6d4df1f90388..d8f613d88fe7 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -336,7 +336,6 @@ nsComboboxControlFrame::nsComboboxControlFrame() mCachedUncComboSize.height = kSizeNotSet; mItemDisplayWidth = 0; - mGoodToGo = PR_FALSE; mInRedisplayText = PR_FALSE; mRedisplayTextEventPosted = PR_FALSE; @@ -415,23 +414,6 @@ nsComboboxControlFrame::Init(nsPresContext* aPresContext, nsIFrame* aPrevInFlow) { mEventQueueService = do_GetService(kEventQueueServiceCID); - - //------------------------------- - // Start - Temporary fix for Bug 36558 - //------------------------------- - mGoodToGo = PR_FALSE; - nsIDocument* document = aContent->GetDocument(); - if (document) { -#ifdef MOZ_XUL - nsCOMPtr xulDoc(do_QueryInterface(document)); - mGoodToGo = xulDoc?PR_FALSE:PR_TRUE; -#else - mGoodToGo = PR_TRUE; -#endif - } - //------------------------------- - // Done - Temporary fix for Bug 36558 - //------------------------------- return nsAreaFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); } @@ -1189,12 +1171,6 @@ nsComboboxControlFrame::Reflow(nsPresContext* aPresContext, return NS_OK; } - if (eReflowReason_Initial == aReflowState.reason) { - if (NS_FAILED(CreateDisplayFrame(aPresContext))) { - return NS_ERROR_FAILURE; - } - } - // Go get all of the important frame nsresult rv = NS_OK; // Don't try to do any special sizing and positioning unless all of the frames @@ -1986,52 +1962,6 @@ nsComboboxControlFrame::GetContentInsertionFrame() { return mInRedisplayText ? mDisplayFrame : mDropdownFrame->GetContentInsertionFrame(); } -NS_IMETHODIMP -nsComboboxControlFrame::CreateDisplayFrame(nsPresContext* aPresContext) -{ - if (mGoodToGo) { - return NS_OK; - } - - nsIPresShell *shell = aPresContext->PresShell(); - nsStyleSet *styleSet = shell->StyleSet(); - - mDisplayFrame = NS_NewBlockFrame(shell, NS_BLOCK_SPACE_MGR); - if (NS_UNLIKELY(!mDisplayFrame)) { - return NS_ERROR_OUT_OF_MEMORY; - } - - // create the style context for the anonymous frame - nsRefPtr styleContext; - styleContext = styleSet->ResolvePseudoStyleFor(mContent, - nsCSSAnonBoxes::mozDisplayComboboxControlFrame, - mStyleContext); - if (!styleContext) { return NS_ERROR_NULL_POINTER; } - - // create a text frame and put it inside the block frame - mTextFrame = NS_NewTextFrame(shell); - if (NS_UNLIKELY(!mTextFrame)) { - return NS_ERROR_OUT_OF_MEMORY; - } - - nsRefPtr textStyleContext; - textStyleContext = styleSet->ResolveStyleForNonElement(styleContext); - if (!textStyleContext) { return NS_ERROR_NULL_POINTER; } - nsCOMPtr content(do_QueryInterface(mDisplayContent)); - mTextFrame->Init(aPresContext, content, mDisplayFrame, textStyleContext, nsnull); - mTextFrame->SetInitialChildList(aPresContext, nsnull, nsnull); - - aPresContext->FrameManager()->SetPrimaryFrameFor(content, mTextFrame); - - nsresult rv = mDisplayFrame->Init(aPresContext, mContent, this, styleContext, nsnull); - if (NS_FAILED(rv)) { return rv; } - - mDisplayFrame->SetInitialChildList(aPresContext, nsnull, mTextFrame); - - return NS_OK; -} - - NS_IMETHODIMP nsComboboxControlFrame::CreateAnonymousContent(nsPresContext* aPresContext, nsISupportsArray& aChildList) @@ -2112,61 +2042,67 @@ nsComboboxControlFrame::CreateFrameFor(nsPresContext* aPresContext, NS_PRECONDITION(nsnull != aPresContext, "null ptr"); *aFrame = nsnull; - NS_ASSERTION(mDisplayContent != nsnull, "mDisplayContent can't be null!"); + NS_ASSERTION(mDisplayContent, "mDisplayContent can't be null!"); - if (!mGoodToGo) { + if (!SameCOMIdentity(mDisplayContent, aContent)) { + // We only handle the frames for mDisplayContent here return NS_ERROR_FAILURE; } + + // Get PresShell + nsIPresShell *shell = aPresContext->PresShell(); + nsStyleSet *styleSet = shell->StyleSet(); - nsCOMPtr content(do_QueryInterface(mDisplayContent)); - if (aContent == content.get()) { - // Get PresShell - nsIPresShell *shell = aPresContext->PresShell(); - nsStyleSet *styleSet = shell->StyleSet(); - - // Start by by creating a containing frame - mDisplayFrame = NS_NewBlockFrame(shell, NS_BLOCK_SPACE_MGR); - if (NS_UNLIKELY(!mDisplayFrame)) { - return NS_ERROR_OUT_OF_MEMORY; - } - - // create the style context for the anonymous block frame - nsRefPtr styleContext; - styleContext = styleSet->ResolvePseudoStyleFor(mContent, - nsCSSAnonBoxes::mozDisplayComboboxControlFrame, - mStyleContext); - if (!styleContext) { return NS_ERROR_NULL_POINTER; } - - // Create a text frame and put it inside the block frame - mTextFrame = NS_NewTextFrame(shell); - if (NS_UNLIKELY(!mTextFrame)) { - return NS_ERROR_OUT_OF_MEMORY; - } - - nsRefPtr textStyleContext; - textStyleContext = styleSet->ResolveStyleForNonElement(styleContext); - if (!textStyleContext) { return NS_ERROR_NULL_POINTER; } - - // initialize the text frame - mTextFrame->Init(aPresContext, content, mDisplayFrame, textStyleContext, nsnull); - mTextFrame->SetInitialChildList(aPresContext, nsnull, nsnull); - - /*nsCOMPtr frameManager; - rv = shell->GetFrameManager(getter_AddRefs(frameManager)); - if (NS_FAILED(rv)) { return rv; } - if (!frameManager) { return NS_ERROR_NULL_POINTER; } - frameManager->SetPrimaryFrameFor(content, mTextFrame); - */ - - nsresult rv = mDisplayFrame->Init(aPresContext, mContent, this, styleContext, nsnull); - if (NS_FAILED(rv)) { return rv; } - - mDisplayFrame->SetInitialChildList(aPresContext, nsnull, mTextFrame); - *aFrame = mDisplayFrame; - return NS_OK; + // create the style contexts for the anonymous block frame and text frame + nsRefPtr styleContext; + styleContext = styleSet-> + ResolvePseudoStyleFor(mContent, + nsCSSAnonBoxes::mozDisplayComboboxControlFrame, + mStyleContext); + if (NS_UNLIKELY(!styleContext)) { + return NS_ERROR_NULL_POINTER; } - return NS_ERROR_FAILURE; + nsRefPtr textStyleContext; + textStyleContext = styleSet->ResolveStyleForNonElement(styleContext); + if (NS_UNLIKELY(!textStyleContext)) { + return NS_ERROR_NULL_POINTER; + } + + // Start by by creating our anonymous block frame + mDisplayFrame = NS_NewBlockFrame(shell, NS_BLOCK_SPACE_MGR); + if (NS_UNLIKELY(!mDisplayFrame)) { + return NS_ERROR_OUT_OF_MEMORY; + } + + nsresult rv = mDisplayFrame->Init(aPresContext, mContent, this, styleContext, + nsnull); + if (NS_FAILED(rv)) { + mDisplayFrame->Destroy(aPresContext); + mDisplayFrame = nsnull; + return rv; + } + + // Create a text frame and put it inside the block frame + mTextFrame = NS_NewTextFrame(shell); + if (NS_UNLIKELY(!mTextFrame)) { + return NS_ERROR_OUT_OF_MEMORY; + } + + // initialize the text frame + rv = mTextFrame->Init(aPresContext, aContent, mDisplayFrame, + textStyleContext, nsnull); + if (NS_FAILED(rv)) { + mDisplayFrame->Destroy(aPresContext); + mDisplayFrame = nsnull; + mTextFrame->Destroy(aPresContext); + mTextFrame = nsnull; + return rv; + } + + mDisplayFrame->SetInitialChildList(aPresContext, nsnull, mTextFrame); + *aFrame = mDisplayFrame; + return NS_OK; } @@ -2216,14 +2152,6 @@ nsComboboxControlFrame::Destroy(nsPresContext* aPresContext) } mPopupFrames.DestroyFrames(aPresContext); - if (!mGoodToGo) { - if (mDisplayFrame) { - fc->RemoveMappingsForFrameSubtree(mDisplayFrame, nsnull); - mDisplayFrame->Destroy(aPresContext); - mDisplayFrame = nsnull; - } - } - return nsAreaFrame::Destroy(aPresContext); } diff --git a/layout/forms/nsComboboxControlFrame.h b/layout/forms/nsComboboxControlFrame.h index 9de8b45263ec..c12b1a273f9d 100644 --- a/layout/forms/nsComboboxControlFrame.h +++ b/layout/forms/nsComboboxControlFrame.h @@ -211,8 +211,6 @@ public: protected: - NS_IMETHOD CreateDisplayFrame(nsPresContext* aPresContext); - #ifdef DO_NEW_REFLOW NS_IMETHOD ReflowItems(nsPresContext* aPresContext, const nsHTMLReflowState& aReflowState, @@ -281,7 +279,6 @@ protected: //nscoord mItemDisplayHeight; PRPackedBool mDroppedDown; // Current state of the dropdown list, PR_TRUE is dropped down - PRPackedBool mGoodToGo; PRPackedBool mInRedisplayText; PRPackedBool mRedisplayTextEventPosted;