Remove the mGoodToGo goop. Its main effect seems to be to cause crashes when

HTML <select>s are used in XUL.  Bug 319796, r+sr=roc
This commit is contained in:
bzbarsky%mit.edu 2005-12-11 20:45:58 +00:00
Родитель d3d8f2c12f
Коммит f9bea49aa1
2 изменённых файлов: 55 добавлений и 130 удалений

Просмотреть файл

@ -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<nsIXULDocument> 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<nsStyleContext> 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<nsStyleContext> textStyleContext;
textStyleContext = styleSet->ResolveStyleForNonElement(styleContext);
if (!textStyleContext) { return NS_ERROR_NULL_POINTER; }
nsCOMPtr<nsIContent> 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<nsIContent> 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<nsStyleContext> 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<nsStyleContext> 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<nsIFrameManager> 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<nsStyleContext> styleContext;
styleContext = styleSet->
ResolvePseudoStyleFor(mContent,
nsCSSAnonBoxes::mozDisplayComboboxControlFrame,
mStyleContext);
if (NS_UNLIKELY(!styleContext)) {
return NS_ERROR_NULL_POINTER;
}
return NS_ERROR_FAILURE;
nsRefPtr<nsStyleContext> 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);
}

Просмотреть файл

@ -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;