diff --git a/mozilla/content/html/content/public/nsIHTMLContent.h b/mozilla/content/html/content/public/nsIHTMLContent.h index aa8f0a8a2a1..51af9faef63 100644 --- a/mozilla/content/html/content/public/nsIHTMLContent.h +++ b/mozilla/content/html/content/public/nsIHTMLContent.h @@ -81,8 +81,10 @@ public: * Used by the html content's delegate to create a frame * for the content. */ - virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame) = 0; + virtual nsresult CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) = 0; }; #endif /* nsIHTMLContent_h___ */ diff --git a/mozilla/layout/base/src/nsContainerFrame.cpp b/mozilla/layout/base/src/nsContainerFrame.cpp index 4224c89099d..ccaab3b829a 100644 --- a/mozilla/layout/base/src/nsContainerFrame.cpp +++ b/mozilla/layout/base/src/nsContainerFrame.cpp @@ -59,9 +59,11 @@ nsContainerFrame::~nsContainerFrame() } } -void nsContainerFrame::PrepareContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsContainerFrame* aContFrame) +void +nsContainerFrame::PrepareContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsContainerFrame* aContFrame) { // Append the continuing frame to the flow aContFrame->AppendToFlow(this); @@ -74,25 +76,24 @@ void nsContainerFrame::PrepareContinuingFrame(nsIPresContext* aPresContext, aContFrame->mLastContentOffset = nextOffset; aContFrame->mLastContentIsComplete = PR_TRUE; - // Resolve style for the continuing frame and set its style context. - // XXX presumptive - nsIStyleContext* styleContext = - aPresContext->ResolveStyleContextFor(mContent, aParent); - aContFrame->SetStyleContext(aPresContext, styleContext); - NS_RELEASE(styleContext); + aContFrame->SetStyleContext(aPresContext, aStyleContext); } -NS_METHOD nsContainerFrame::CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame) +NS_METHOD +nsContainerFrame::CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame) { nsIContentDelegate* contentDelegate = mContent->GetDelegate(aPresContext); - - aContinuingFrame = contentDelegate->CreateFrame(aPresContext, mContent, aParent); + nsresult rv = contentDelegate->CreateFrame(aPresContext, mContent, aParent, + aStyleContext, aContinuingFrame); NS_RELEASE(contentDelegate); - - PrepareContinuingFrame(aPresContext, aParent, (nsContainerFrame*)aContinuingFrame); - return NS_OK; + if (NS_OK == rv) { + PrepareContinuingFrame(aPresContext, aParent, aStyleContext, + (nsContainerFrame*)aContinuingFrame); + } + return rv; } diff --git a/mozilla/layout/base/src/nsContainerFrame.h b/mozilla/layout/base/src/nsContainerFrame.h index 92dacc00258..93410fa6444 100644 --- a/mozilla/layout/base/src/nsContainerFrame.h +++ b/mozilla/layout/base/src/nsContainerFrame.h @@ -111,9 +111,10 @@ public: * set the content offsets, mLastContentOffset, and append the continuing * frame to the flow. */ - NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame); + NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame); // Painting NS_IMETHOD Paint(nsIPresContext& aPresContext, @@ -195,12 +196,14 @@ protected: virtual ~nsContainerFrame(); /** - * Prepare a continuation frame of this frame for reflow. Appends it to the - * flow, sets its content offsets, mLastContentIsComplete, and style context. - * Subclasses should invoke this method after construction of a continuing frame. + * Prepare a continuation frame of this frame for reflow. Appends + * it to the flow, sets its content offsets, mLastContentIsComplete, + * and style context. Subclasses should invoke this method after + * construction of a continuing frame. */ void PrepareContinuingFrame(nsIPresContext* aPresContext, nsIFrame* aParent, + nsIStyleContext* aStyleContext, nsContainerFrame* aContFrame); diff --git a/mozilla/layout/base/src/nsFrame.cpp b/mozilla/layout/base/src/nsFrame.cpp index 31c958a5bce..28a2c122284 100644 --- a/mozilla/layout/base/src/nsFrame.cpp +++ b/mozilla/layout/base/src/nsFrame.cpp @@ -177,9 +177,13 @@ NS_METHOD nsFrame::GetContent(nsIContent*& aContent) const NS_METHOD nsFrame::GetContentIndex(PRInt32& aIndexInParent) const { nsIContent* parent = mContent->GetParent(); - - aIndexInParent = parent->IndexOf(mContent); - NS_RELEASE(parent); + if (nsnull != parent) { + aIndexInParent = parent->IndexOf(mContent); + NS_RELEASE(parent); + } + else { + aIndexInParent = 0; + } return NS_OK; } @@ -733,13 +737,14 @@ NS_METHOD nsFrame::IsSplittable(SplittableType& aIsSplittable) const return NS_OK; } -NS_METHOD nsFrame::CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame) +NS_METHOD nsFrame::CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame) { NS_ERROR("not splittable"); aContinuingFrame = nsnull; - return NS_OK; + return NS_OK;/* XXX return an invalid value? */ } NS_METHOD nsFrame::GetPrevInFlow(nsIFrame*& aPrevInFlow) const @@ -1259,4 +1264,4 @@ void nsFrame::NewContentIsAfter(nsIPresContext& aPresContext, #endif } -#endif \ No newline at end of file +#endif diff --git a/mozilla/layout/base/src/nsFrame.h b/mozilla/layout/base/src/nsFrame.h index a5d5f7b0e0a..7087562d0a8 100644 --- a/mozilla/layout/base/src/nsFrame.h +++ b/mozilla/layout/base/src/nsFrame.h @@ -128,9 +128,10 @@ public: // Flow member functions NS_IMETHOD IsSplittable(SplittableType& aIsSplittable) const; - NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame); + NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame); NS_IMETHOD GetPrevInFlow(nsIFrame*& aPrevInFlow) const; NS_IMETHOD SetPrevInFlow(nsIFrame*); diff --git a/mozilla/layout/base/src/nsPresShell.cpp b/mozilla/layout/base/src/nsPresShell.cpp index 570cc3a0d17..9e4e3afab65 100644 --- a/mozilla/layout/base/src/nsPresShell.cpp +++ b/mozilla/layout/base/src/nsPresShell.cpp @@ -340,14 +340,13 @@ void PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight) if (nsnull != root) { nsIContentDelegate* cd = root->GetDelegate(mPresContext); if (nsnull != cd) { - mRootFrame = cd->CreateFrame(mPresContext, root, nsnull); + nsIStyleContext* rootSC = + mPresContext->ResolveStyleContextFor(root, nsnull); + nsresult rv = cd->CreateFrame(mPresContext, root, nsnull, + rootSC, mRootFrame); + NS_RELEASE(rootSC); NS_RELEASE(cd); - // set root frame's style context - nsIStyleContext* rootContext = mPresContext->ResolveStyleContextFor(root, nsnull); - mRootFrame->SetStyleContext(mPresContext,rootContext); - NS_RELEASE(rootContext); - // Bind root frame to root view (and root window) nsIView* rootView = mViewManager->GetRootView(); mRootFrame->SetView(rootView); diff --git a/mozilla/layout/base/src/nsSplittableFrame.cpp b/mozilla/layout/base/src/nsSplittableFrame.cpp index df4b5a4851f..7287010fd25 100644 --- a/mozilla/layout/base/src/nsSplittableFrame.cpp +++ b/mozilla/layout/base/src/nsSplittableFrame.cpp @@ -48,14 +48,20 @@ NS_METHOD nsSplittableFrame::IsSplittable(SplittableType& aIsSplittable) const * the receiver's geometric parent * @return the continuing frame or null if unsuccessful */ -NS_METHOD nsSplittableFrame::CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame) +NS_METHOD +nsSplittableFrame::CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame) { nsIContentDelegate* contentDelegate = mContent->GetDelegate(aPresContext); - aContinuingFrame = contentDelegate->CreateFrame(aPresContext, mContent, aParent); + nsresult rv = contentDelegate->CreateFrame(aPresContext, mContent, aParent, + aStyleContext, aContinuingFrame); NS_RELEASE(contentDelegate); + if (NS_OK != rv) { + return rv; + } // Append the continuing frame to the flow aContinuingFrame->AppendToFlow(this); @@ -66,7 +72,7 @@ NS_METHOD nsSplittableFrame::CreateContinuingFrame(nsIPresContext* aPresContext, aContinuingFrame->SetStyleContext(aPresContext,styleContext); NS_RELEASE(styleContext); - return NS_OK; + return rv; } NS_METHOD nsSplittableFrame::GetPrevInFlow(nsIFrame*& aPrevInFlow) const diff --git a/mozilla/layout/base/src/nsSplittableFrame.h b/mozilla/layout/base/src/nsSplittableFrame.h index c8d4d11c08d..78b504a72c5 100644 --- a/mozilla/layout/base/src/nsSplittableFrame.h +++ b/mozilla/layout/base/src/nsSplittableFrame.h @@ -27,9 +27,10 @@ public: // CreateContinuingFrame() does the default behavior of using the // content delegate to create a new frame NS_IMETHOD IsSplittable(SplittableType& aIsSplittable) const; - NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame); + NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame); // Flow member functions. NS_IMETHOD GetPrevInFlow(nsIFrame*& aPrevInFlow) const; diff --git a/mozilla/layout/generic/nsBlockFrame.h b/mozilla/layout/generic/nsBlockFrame.h index b09af228e91..861ac78d069 100644 --- a/mozilla/layout/generic/nsBlockFrame.h +++ b/mozilla/layout/generic/nsBlockFrame.h @@ -172,9 +172,10 @@ public: NS_IMETHOD GetReflowMetrics(nsIPresContext* aPresContext, nsReflowMetrics& aMetrics); NS_IMETHOD IsSplittable(SplittableType& aIsSplittable) const; - NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame); + NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame); NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; NS_IMETHOD ListTag(FILE* out) const; NS_IMETHOD VerifyTree() const; diff --git a/mozilla/layout/generic/nsHTMLContainerFrame.cpp b/mozilla/layout/generic/nsHTMLContainerFrame.cpp index eff15d3c419..c171c79dced 100644 --- a/mozilla/layout/generic/nsHTMLContainerFrame.cpp +++ b/mozilla/layout/generic/nsHTMLContainerFrame.cpp @@ -243,35 +243,45 @@ static void AdjustIndexInParents(nsIFrame* aContainerFrame, } } -nsIFrame* nsHTMLContainerFrame::CreateFrameFor(nsIPresContext* aPresContext, - nsIContent* aContent) +nsresult +nsHTMLContainerFrame::CreateFrameFor(nsIPresContext* aPresContext, + nsIContent* aContent, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) { - // Get the style content for the frame - nsIStyleContextPtr styleContext = aPresContext->ResolveStyleContextFor(aContent, this); - nsStylePosition* position = (nsStylePosition*)styleContext->GetData(kStylePositionSID); - nsStyleDisplay* display = (nsStyleDisplay*)styleContext->GetData(kStyleDisplaySID); - nsIFrame* result; + // Get the style data for the frame + nsStylePosition* position = (nsStylePosition*) + aStyleContext->GetData(kStylePositionSID); + nsStyleDisplay* display = (nsStyleDisplay*) + aStyleContext->GetData(kStyleDisplaySID); + nsIFrame* frame = nsnull; // See whether it wants any special handling + nsresult rv; if (NS_STYLE_POSITION_ABSOLUTE == position->mPosition) { - AbsoluteFrame::NewFrame(&result, aContent, this); + rv = AbsoluteFrame::NewFrame(&frame, aContent, this); + if (NS_OK == rv) { + frame->SetStyleContext(aPresContext, aStyleContext); + } } else if (display->mFloats != NS_STYLE_FLOAT_NONE) { - PlaceholderFrame::NewFrame(&result, aContent, this); + rv = PlaceholderFrame::NewFrame(&frame, aContent, this); + if (NS_OK == rv) { + frame->SetStyleContext(aPresContext, aStyleContext); + } } else if (NS_STYLE_DISPLAY_NONE == display->mDisplay) { - nsFrame::NewFrame(&result, aContent, this); + rv = nsFrame::NewFrame(&frame, aContent, this); + if (NS_OK == rv) { + frame->SetStyleContext(aPresContext, aStyleContext); + } } else { - nsIContentDelegate* delegate; - // Ask the content delegate to create the frame - // XXX The delegate will also resolve the style context... - delegate = aContent->GetDelegate(aPresContext); - result = delegate->CreateFrame(aPresContext, aContent, this); + nsIContentDelegate* delegate = aContent->GetDelegate(aPresContext); + rv = delegate->CreateFrame(aPresContext, aContent, this, + aStyleContext, frame); NS_RELEASE(delegate); } - - // Set the frame's style context - result->SetStyleContext(aPresContext, styleContext); - return result; + aResult = frame; + return rv; } NS_METHOD nsHTMLContainerFrame::ContentInserted(nsIPresShell* aShell, @@ -324,13 +334,18 @@ NS_METHOD nsHTMLContainerFrame::ContentInserted(nsIPresShell* aShell, // next-in-flow(s). It could be a pseudo-frame, but then it better also be // a nsHTMLContainerFrame... nsHTMLContainerFrame* parent = this; - if (nsnull != prevSibling) { prevSibling->GetGeometricParent((nsIFrame*&)parent); } // Create the new frame - nsIFrame* newFrame = parent->CreateFrameFor(aPresContext, aChild); + nsIStyleContext* kidSC; + kidSC = aPresContext->ResolveStyleContextFor(aChild, parent); + nsIFrame* newFrame; + nsresult rv = parent->CreateFrameFor(aPresContext, aChild, kidSC, newFrame); + if (NS_OK != rv) { + return rv; + } // Insert the frame if (nsnull == prevSibling) { diff --git a/mozilla/layout/generic/nsHTMLContainerFrame.h b/mozilla/layout/generic/nsHTMLContainerFrame.h index f3a4fe248cc..812f6bf0d0b 100644 --- a/mozilla/layout/generic/nsHTMLContainerFrame.h +++ b/mozilla/layout/generic/nsHTMLContainerFrame.h @@ -61,8 +61,10 @@ protected: const nsString& aURLSpec, const nsString& aTargetSpec); - nsIFrame* CreateFrameFor(nsIPresContext* aPresContext, - nsIContent* aContent); + nsresult CreateFrameFor(nsIPresContext* aPresContext, + nsIContent* aContent, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); }; #endif /* nsHTMLContainerFrame_h___ */ diff --git a/mozilla/layout/generic/nsInlineFrame.cpp b/mozilla/layout/generic/nsInlineFrame.cpp index 6b6688e2549..c1407f15c1f 100644 --- a/mozilla/layout/generic/nsInlineFrame.cpp +++ b/mozilla/layout/generic/nsInlineFrame.cpp @@ -256,7 +256,11 @@ PRBool nsInlineFrame::ReflowMappedChildren(nsIPresContext* aPresContext, // frame. This hooks the child into the flow nsIFrame* continuingFrame; - kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame); + nsIStyleContext* kidSC; + kidFrame->GetStyleContext(aPresContext, kidSC); + kidFrame->CreateContinuingFrame(aPresContext, this, kidSC, + continuingFrame); + NS_RELEASE(kidSC); NS_ASSERTION(nsnull != continuingFrame, "frame creation failed"); // Add the continuing frame to the sibling list @@ -440,7 +444,11 @@ PRBool nsInlineFrame::PullUpChildren(nsIPresContext* aPresContext, // prepares it for reflow. nsIFrame* continuingFrame; - kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame); + nsIStyleContext* kidSC; + kidFrame->GetStyleContext(aPresContext, kidSC); + kidFrame->CreateContinuingFrame(aPresContext, this, kidSC, + continuingFrame); + NS_RELEASE(kidSC); NS_ASSERTION(nsnull != continuingFrame, "frame creation failed"); // Add the continuing frame to our sibling list and then push @@ -568,12 +576,17 @@ nsInlineFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext, kidStyleContext->GetData(kStylePositionSID); // Check whether it wants to floated or absolutely positioned + nsresult rv; if (NS_STYLE_POSITION_ABSOLUTE == kidPosition->mPosition) { - AbsoluteFrame::NewFrame(&kidFrame, kid, this); - kidFrame->SetStyleContext(aPresContext,kidStyleContext); + rv = AbsoluteFrame::NewFrame(&kidFrame, kid, this); + if (NS_OK == rv) { + kidFrame->SetStyleContext(aPresContext, kidStyleContext); + } } else if (kidDisplay->mFloats != NS_STYLE_FLOAT_NONE) { - PlaceholderFrame::NewFrame(&kidFrame, kid, this); - kidFrame->SetStyleContext(aPresContext,kidStyleContext); + rv = PlaceholderFrame::NewFrame(&kidFrame, kid, this); + if (NS_OK == rv) { + kidFrame->SetStyleContext(aPresContext, kidStyleContext); + } } else if (nsnull == kidPrevInFlow) { nsIContentDelegate* kidDel; switch (kidDisplay->mDisplay) { @@ -590,18 +603,22 @@ nsInlineFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext, case NS_STYLE_DISPLAY_INLINE: kidDel = kid->GetDelegate(aPresContext); - kidFrame = kidDel->CreateFrame(aPresContext, kid, this); + rv = kidDel->CreateFrame(aPresContext, kid, this, + kidStyleContext, kidFrame); NS_RELEASE(kidDel); break; default: NS_ASSERTION(nsnull == kidPrevInFlow, "bad prev in flow"); - nsFrame::NewFrame(&kidFrame, kid, this); + rv = nsFrame::NewFrame(&kidFrame, kid, this); + if (NS_OK == rv) { + kidFrame->SetStyleContext(aPresContext, kidStyleContext); + } break; } - kidFrame->SetStyleContext(aPresContext,kidStyleContext); } else { - kidPrevInFlow->CreateContinuingFrame(aPresContext, this, kidFrame); + rv = kidPrevInFlow->CreateContinuingFrame(aPresContext, this, + kidStyleContext, kidFrame); } NS_RELEASE(kid); NS_RELEASE(kidStyleContext); diff --git a/mozilla/layout/generic/nsLineLayout.cpp b/mozilla/layout/generic/nsLineLayout.cpp index 368b6a8d53e..65d5361cd0f 100644 --- a/mozilla/layout/generic/nsLineLayout.cpp +++ b/mozilla/layout/generic/nsLineLayout.cpp @@ -537,7 +537,11 @@ nsLineLayout::SplitLine(PRInt32 aChildReflowStatus, PRInt32 aRemainingKids) // into our lines child list. nsIFrame* nextFrame; mPrevKidFrame->GetNextSibling(nextFrame); - mPrevKidFrame->CreateContinuingFrame(mPresContext, mBlock, nextInFlow); + nsIStyleContext* kidSC; + mPrevKidFrame->GetStyleContext(mPresContext, kidSC); + mPrevKidFrame->CreateContinuingFrame(mPresContext, mBlock, kidSC, + nextInFlow); + NS_RELEASE(kidSC); if (nsnull == nextInFlow) { return NS_ERROR_OUT_OF_MEMORY; } @@ -828,74 +832,61 @@ done: nsresult nsLineLayout::CreateFrameFor(nsIContent* aKid) { - nsresult rv = NS_OK; - - // XXX what if kidSC ends up null? nsIStyleContextPtr kidSC = - mPresContext->ResolveStyleContextFor(aKid, mBlock); + mPresContext->ResolveStyleContextFor(aKid, mBlock); // XXX bad API + if (nsnull == kidSC) { + return NS_ERROR_OUT_OF_MEMORY; + } nsStylePosition* kidPosition = (nsStylePosition*) kidSC->GetData(kStylePositionSID); nsStyleDisplay* kidDisplay = (nsStyleDisplay*) kidSC->GetData(kStyleDisplaySID); // Check whether it wants to floated or absolutely positioned - // XXX don't lose error status from frame ctor's! PRBool isBlock = PR_FALSE; nsIFrame* kidFrame; + nsresult rv; if (NS_STYLE_POSITION_ABSOLUTE == kidPosition->mPosition) { - AbsoluteFrame::NewFrame(&kidFrame, aKid, mBlock); - kidFrame->SetStyleContext(mPresContext, kidSC); + rv = AbsoluteFrame::NewFrame(&kidFrame, aKid, mBlock); + if (NS_OK == rv) { + kidFrame->SetStyleContext(mPresContext, kidSC); + } } else if (kidDisplay->mFloats != NS_STYLE_FLOAT_NONE) { - PlaceholderFrame::NewFrame(&kidFrame, aKid, mBlock); - kidFrame->SetStyleContext(mPresContext, kidSC); + rv = PlaceholderFrame::NewFrame(&kidFrame, aKid, mBlock); + if (NS_OK == rv) { + kidFrame->SetStyleContext(mPresContext, kidSC); + } } else if (nsnull == mKidPrevInFlow) { // Create initial frame for the child - - // XXX refactor to just let delegate create frame (unless style is - // none) and then after that if it's a block frame and the child - // count is non-zero we return the break-before value. - nsIContentDelegate* kidDel; switch (kidDisplay->mDisplay) { + case NS_STYLE_DISPLAY_NONE: + rv = nsFrame::NewFrame(&kidFrame, aKid, mBlock); + if (NS_OK == rv) { + kidFrame->SetStyleContext(mPresContext, kidSC); + } + break; + case NS_STYLE_DISPLAY_BLOCK: case NS_STYLE_DISPLAY_LIST_ITEM: -#if 0 - // XXX Do we still need this? Now that the body code is changed it - // causes a problem... - if (mBlockIsPseudo) { - // Don't create the frame! It doesn't belong in us. - - // XXX the unfortunate thing here is that we waste the style - // lookup! - - return NS_LINE_LAYOUT_PSEUDO_BREAK_BEFORE_BLOCK; - } -#endif - kidDel = aKid->GetDelegate(mPresContext); - kidFrame = kidDel->CreateFrame(mPresContext, aKid, mBlock); - NS_RELEASE(kidDel); isBlock = PR_TRUE; - break; - - case NS_STYLE_DISPLAY_INLINE: - // XXX pass in kidSC to speed things up *alot*! - // XXX fix CreateFrame API to return an nsresult! + // FALL THROUGH + default: kidDel = aKid->GetDelegate(mPresContext); - kidFrame = kidDel->CreateFrame(mPresContext, aKid, mBlock); + rv = kidDel->CreateFrame(mPresContext, aKid, mBlock, kidSC, kidFrame); NS_RELEASE(kidDel); break; - - default:/* XXX bzzt! */ - nsFrame::NewFrame(&kidFrame, aKid, mBlock); - break; } - kidFrame->SetStyleContext(mPresContext, kidSC); } else { // Since kid has a prev-in-flow, use that to create the next // frame. - mKidPrevInFlow->CreateContinuingFrame(mPresContext, mBlock, kidFrame); + rv = mKidPrevInFlow->CreateContinuingFrame(mPresContext, mBlock, kidSC, + kidFrame); NS_ASSERTION(0 == mLine->mChildCount, "bad continuation"); } + if (NS_OK != rv) { + return rv; + } mKidFrame = kidFrame; mNewFrames++; diff --git a/mozilla/layout/generic/nsPageFrame.cpp b/mozilla/layout/generic/nsPageFrame.cpp index e9f420ab4cf..a15fda7e470 100644 --- a/mozilla/layout/generic/nsPageFrame.cpp +++ b/mozilla/layout/generic/nsPageFrame.cpp @@ -38,16 +38,14 @@ void PageFrame::CreateFirstChild(nsIPresContext* aPresContext) // Create a frame nsIContentDelegate* cd = child->GetDelegate(aPresContext); if (nsnull != cd) { - mFirstChild = cd->CreateFrame(aPresContext, child, this); - if (nsnull != mFirstChild) { + nsIStyleContext* kidStyleContext = + aPresContext->ResolveStyleContextFor(child, this); + nsresult rv = cd->CreateFrame(aPresContext, child, this, + kidStyleContext, mFirstChild); + NS_RELEASE(kidStyleContext); + if (NS_OK == mFirstChild) { mChildCount = 1; mLastContentOffset = mFirstContentOffset; - - // Resolve style and set the style context - nsIStyleContext* kidStyleContext = - aPresContext->ResolveStyleContextFor(child, this); - mFirstChild->SetStyleContext(aPresContext,kidStyleContext); - NS_RELEASE(kidStyleContext); } NS_RELEASE(cd); } @@ -80,7 +78,12 @@ NS_METHOD PageFrame::ResizeReflow(nsIPresContext* aPresContext, prevPage->LastChild(prevLastChild); // Create a continuing child of the previous page's last child - prevLastChild->CreateContinuingFrame(aPresContext, this, mFirstChild); + nsIStyleContext* kidSC; + prevLastChild->GetStyleContext(aPresContext, kidSC); + nsresult rv = prevLastChild->CreateContinuingFrame(aPresContext, this, + kidSC, mFirstChild); + NS_RELEASE(kidSC); + mChildCount = 1; mLastContentOffset = mFirstContentOffset; } @@ -154,12 +157,17 @@ NS_METHOD PageFrame::IncrementalReflow(nsIPresContext* aPresContext, return NS_OK; } -NS_METHOD PageFrame::CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame) +NS_METHOD +PageFrame::CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame) { PageFrame* cf = new PageFrame(mContent, aParent); - PrepareContinuingFrame(aPresContext, aParent, cf); + if (nsnull == cf) { + return NS_ERROR_OUT_OF_MEMORY; + } + PrepareContinuingFrame(aPresContext, aParent, aStyleContext, cf); aContinuingFrame = cf; return NS_OK; } diff --git a/mozilla/layout/generic/nsPageFrame.h b/mozilla/layout/generic/nsPageFrame.h index 629816d3631..28972f714fa 100644 --- a/mozilla/layout/generic/nsPageFrame.h +++ b/mozilla/layout/generic/nsPageFrame.h @@ -37,9 +37,10 @@ public: nsReflowCommand& aReflowCommand, ReflowStatus& aStatus); - NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame); + NS_IMETHOD CreateContinuingFrame(nsIPresContext* aCX, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame); NS_IMETHOD Paint(nsIPresContext& aPresContext, nsIRenderingContext& aRenderingContext, diff --git a/mozilla/layout/generic/nsPlaceholderFrame.cpp b/mozilla/layout/generic/nsPlaceholderFrame.cpp index fbc71ef6076..80cad9608bb 100644 --- a/mozilla/layout/generic/nsPlaceholderFrame.cpp +++ b/mozilla/layout/generic/nsPlaceholderFrame.cpp @@ -69,12 +69,13 @@ NS_METHOD PlaceholderFrame::ResizeReflow(nsIPresContext* aPresContext, if (nsnull == mAnchoredItem) { // Create the anchored item nsIContentDelegate* delegate = mContent->GetDelegate(aPresContext); - - mAnchoredItem = delegate->CreateFrame(aPresContext, mContent, mGeometricParent); + nsresult rv = delegate->CreateFrame(aPresContext, mContent, + mGeometricParent, mStyleContext, + mAnchoredItem); NS_RELEASE(delegate); - - // Set the style context for the frame - mAnchoredItem->SetStyleContext(aPresContext,mStyleContext); + if (NS_OK != rv) { + return rv; + } // Resize reflow the anchored item into the available space // XXX Check for complete? diff --git a/mozilla/layout/html/base/src/nsAbsoluteFrame.cpp b/mozilla/layout/html/base/src/nsAbsoluteFrame.cpp index fcd06811503..ccc547babc8 100644 --- a/mozilla/layout/html/base/src/nsAbsoluteFrame.cpp +++ b/mozilla/layout/html/base/src/nsAbsoluteFrame.cpp @@ -245,11 +245,12 @@ NS_METHOD AbsoluteFrame::ResizeReflow(nsIPresContext* aPresContext, // also create a view nsIContentDelegate* delegate = mContent->GetDelegate(aPresContext); - mFrame= delegate->CreateFrame(aPresContext, mContent, this); + nsresult rv = delegate->CreateFrame(aPresContext, mContent, this, + mStyleContext, mFrame); NS_RELEASE(delegate); - - // Set the style context for the frame - mFrame->SetStyleContext(aPresContext,mStyleContext); + if (NS_OK != rv) { + return rv; + } } // Get the containing block, and its associated view diff --git a/mozilla/layout/html/base/src/nsBRPart.cpp b/mozilla/layout/html/base/src/nsBRPart.cpp index 3d6e0d9a29f..3918ac40e4d 100644 --- a/mozilla/layout/html/base/src/nsBRPart.cpp +++ b/mozilla/layout/html/base/src/nsBRPart.cpp @@ -134,8 +134,11 @@ public: virtual void UnsetAttribute(nsIAtom* aAttribute); - virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame); + + virtual nsresult CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); PRInt32 GetClear() { return mClear; @@ -163,11 +166,19 @@ BRPart::~BRPart() { } -nsIFrame* BRPart::CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame) +nsresult +BRPart::CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) { - nsIFrame* rv = new BRFrame(this, aParentFrame); - return rv; + nsIFrame* frame = new BRFrame(this, aParentFrame); + if (nsnull == frame) { + return NS_ERROR_OUT_OF_MEMORY; + } + frame->SetStyleContext(aPresContext, aStyleContext); + aResult = frame; + return NS_OK; } //---------------------------------------------------------------------- diff --git a/mozilla/layout/html/base/src/nsBlockFrame.h b/mozilla/layout/html/base/src/nsBlockFrame.h index b09af228e91..861ac78d069 100644 --- a/mozilla/layout/html/base/src/nsBlockFrame.h +++ b/mozilla/layout/html/base/src/nsBlockFrame.h @@ -172,9 +172,10 @@ public: NS_IMETHOD GetReflowMetrics(nsIPresContext* aPresContext, nsReflowMetrics& aMetrics); NS_IMETHOD IsSplittable(SplittableType& aIsSplittable) const; - NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame); + NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame); NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; NS_IMETHOD ListTag(FILE* out) const; NS_IMETHOD VerifyTree() const; diff --git a/mozilla/layout/html/base/src/nsBodyFrame.cpp b/mozilla/layout/html/base/src/nsBodyFrame.cpp index 51ec9b1547f..0434bcaf2e4 100644 --- a/mozilla/layout/html/base/src/nsBodyFrame.cpp +++ b/mozilla/layout/html/base/src/nsBodyFrame.cpp @@ -96,7 +96,7 @@ void nsBodyFrame::CreateColumnFrame(nsIPresContext* aPresContext) NS_ASSERTION(prevBody->ChildIsPseudoFrame(prevColumn), "bad previous column"); // Create a continuing column - prevColumn->CreateContinuingFrame(aPresContext, this, mFirstChild); + prevColumn->CreateContinuingFrame(aPresContext, this, nsnull, mFirstChild); mChildCount = 1; } } @@ -364,12 +364,17 @@ void nsBodyFrame::RemoveAnchoredItem(nsIFrame* aAnchoredItem) mChildCount--; } -NS_METHOD nsBodyFrame::CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame) +NS_METHOD +nsBodyFrame::CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame) { nsBodyFrame* cf = new nsBodyFrame(mContent, aParent); - PrepareContinuingFrame(aPresContext, aParent, cf); + if (nsnull == cf) { + return NS_ERROR_OUT_OF_MEMORY; + } + PrepareContinuingFrame(aPresContext, aParent, aStyleContext, cf); aContinuingFrame = cf; return NS_OK; } diff --git a/mozilla/layout/html/base/src/nsBodyFrame.h b/mozilla/layout/html/base/src/nsBodyFrame.h index adebebc1743..1c5eee8c5f8 100644 --- a/mozilla/layout/html/base/src/nsBodyFrame.h +++ b/mozilla/layout/html/base/src/nsBodyFrame.h @@ -55,9 +55,10 @@ public: nsIContent* aChild, PRInt32 aIndexInParent); - NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame); + NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame); virtual void AddAnchoredItem(nsIFrame* aAnchoredItem, AnchoringPosition aPosition, diff --git a/mozilla/layout/html/base/src/nsBodyPart.cpp b/mozilla/layout/html/base/src/nsBodyPart.cpp index ffd011e9ee5..a6d4cacfb0c 100644 --- a/mozilla/layout/html/base/src/nsBodyPart.cpp +++ b/mozilla/layout/html/base/src/nsBodyPart.cpp @@ -27,8 +27,11 @@ public: NS_IMETHOD_(nsrefcnt) AddRef(); NS_IMETHOD_(nsrefcnt) Release(); - virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame); + + virtual nsresult CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); protected: virtual ~BodyPart(); @@ -57,12 +60,20 @@ nsrefcnt BodyPart::Release(void) return mRefCnt; } -nsIFrame* BodyPart::CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame) +nsresult +BodyPart::CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) { - nsIFrame* rv; - nsresult status = nsBodyFrame::NewFrame(&rv, this, aParentFrame); - return rv; + nsIFrame* frame = nsnull; + nsresult rv = nsBodyFrame::NewFrame(&frame, this, aParentFrame); + if (NS_OK != rv) { + return rv; + } + frame->SetStyleContext(aPresContext, aStyleContext); + aResult = frame; + return NS_OK; } nsresult diff --git a/mozilla/layout/html/base/src/nsHRPart.cpp b/mozilla/layout/html/base/src/nsHRPart.cpp index 5f00a230e25..638342d4a11 100644 --- a/mozilla/layout/html/base/src/nsHRPart.cpp +++ b/mozilla/layout/html/base/src/nsHRPart.cpp @@ -47,8 +47,11 @@ public: virtual nsrefcnt AddRef(void); virtual nsrefcnt Release(void); #endif - virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame); + + virtual nsresult CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); virtual nsContentAttr GetAttribute(nsIAtom* aAttribute, @@ -417,11 +420,19 @@ nsContentAttr HRulePart::AttributeToString(nsIAtom* aAttribute, //---------------------------------------------------------------------- -nsIFrame* HRulePart::CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame) +nsresult +HRulePart::CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) { - nsIFrame* rv = new HRuleFrame(this, aParentFrame); - return rv; + nsIFrame* frame = new HRuleFrame(this, aParentFrame); + if (nsnull == frame) { + return NS_ERROR_OUT_OF_MEMORY; + } + frame->SetStyleContext(aPresContext, aStyleContext); + aResult = frame; + return NS_OK; } nsresult diff --git a/mozilla/layout/html/base/src/nsHTMLContainer.cpp b/mozilla/layout/html/base/src/nsHTMLContainer.cpp index abd1f3c68fd..52d653d99d6 100644 --- a/mozilla/layout/html/base/src/nsHTMLContainer.cpp +++ b/mozilla/layout/html/base/src/nsHTMLContainer.cpp @@ -182,39 +182,38 @@ void nsHTMLContainer::Compact() //XXX I'll turn this on in a bit... mChildren.Compact(); } -nsIFrame* nsHTMLContainer::CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame) +nsresult +nsHTMLContainer::CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) { - // Resolve style for the piece of content - // XXX The caller has also resolved the style context, which means we're - // resolving it more than once. That's inefficient, and we need to fix it... - nsIStyleContext* styleContext = - aPresContext->ResolveStyleContextFor(this, aParentFrame); nsStyleDisplay* styleDisplay = - (nsStyleDisplay*)styleContext->GetData(kStyleDisplaySID); + (nsStyleDisplay*) aStyleContext->GetData(kStyleDisplaySID); // Use style to choose what kind of frame to create - nsIFrame* rv; - nsresult fr; + nsIFrame* frame = nsnull; + nsresult rv; switch (styleDisplay->mDisplay) { case NS_STYLE_DISPLAY_BLOCK: - fr = nsBlockFrame::NewFrame(&rv, this, aParentFrame); + rv = nsBlockFrame::NewFrame(&frame, this, aParentFrame); break; case NS_STYLE_DISPLAY_INLINE: - fr = nsInlineFrame::NewFrame(&rv, this, aParentFrame); + rv = nsInlineFrame::NewFrame(&frame, this, aParentFrame); break; case NS_STYLE_DISPLAY_LIST_ITEM: - fr = nsListItemFrame::NewFrame(&rv, this, aParentFrame); + rv = nsListItemFrame::NewFrame(&frame, this, aParentFrame); break; default: // Create an empty frame for holding content that is not being // reflowed. - fr = nsFrame::NewFrame(&rv, this, aParentFrame); + rv = nsFrame::NewFrame(&frame, this, aParentFrame); break; } - - rv->SetStyleContext(aPresContext,styleContext); - NS_RELEASE(styleContext); + if (NS_OK == rv) { + frame->SetStyleContext(aPresContext, aStyleContext); + } + aResult = frame; return rv; } diff --git a/mozilla/layout/html/base/src/nsHTMLContainer.h b/mozilla/layout/html/base/src/nsHTMLContainer.h index b63ccfdce28..7d5e2323fce 100644 --- a/mozilla/layout/html/base/src/nsHTMLContainer.h +++ b/mozilla/layout/html/base/src/nsHTMLContainer.h @@ -38,8 +38,10 @@ public: virtual void Compact(); - virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame); + virtual nsresult CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); virtual void MapAttributesInto(nsIStyleContext* aContext, diff --git a/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp b/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp index eff15d3c419..c171c79dced 100644 --- a/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp +++ b/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp @@ -243,35 +243,45 @@ static void AdjustIndexInParents(nsIFrame* aContainerFrame, } } -nsIFrame* nsHTMLContainerFrame::CreateFrameFor(nsIPresContext* aPresContext, - nsIContent* aContent) +nsresult +nsHTMLContainerFrame::CreateFrameFor(nsIPresContext* aPresContext, + nsIContent* aContent, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) { - // Get the style content for the frame - nsIStyleContextPtr styleContext = aPresContext->ResolveStyleContextFor(aContent, this); - nsStylePosition* position = (nsStylePosition*)styleContext->GetData(kStylePositionSID); - nsStyleDisplay* display = (nsStyleDisplay*)styleContext->GetData(kStyleDisplaySID); - nsIFrame* result; + // Get the style data for the frame + nsStylePosition* position = (nsStylePosition*) + aStyleContext->GetData(kStylePositionSID); + nsStyleDisplay* display = (nsStyleDisplay*) + aStyleContext->GetData(kStyleDisplaySID); + nsIFrame* frame = nsnull; // See whether it wants any special handling + nsresult rv; if (NS_STYLE_POSITION_ABSOLUTE == position->mPosition) { - AbsoluteFrame::NewFrame(&result, aContent, this); + rv = AbsoluteFrame::NewFrame(&frame, aContent, this); + if (NS_OK == rv) { + frame->SetStyleContext(aPresContext, aStyleContext); + } } else if (display->mFloats != NS_STYLE_FLOAT_NONE) { - PlaceholderFrame::NewFrame(&result, aContent, this); + rv = PlaceholderFrame::NewFrame(&frame, aContent, this); + if (NS_OK == rv) { + frame->SetStyleContext(aPresContext, aStyleContext); + } } else if (NS_STYLE_DISPLAY_NONE == display->mDisplay) { - nsFrame::NewFrame(&result, aContent, this); + rv = nsFrame::NewFrame(&frame, aContent, this); + if (NS_OK == rv) { + frame->SetStyleContext(aPresContext, aStyleContext); + } } else { - nsIContentDelegate* delegate; - // Ask the content delegate to create the frame - // XXX The delegate will also resolve the style context... - delegate = aContent->GetDelegate(aPresContext); - result = delegate->CreateFrame(aPresContext, aContent, this); + nsIContentDelegate* delegate = aContent->GetDelegate(aPresContext); + rv = delegate->CreateFrame(aPresContext, aContent, this, + aStyleContext, frame); NS_RELEASE(delegate); } - - // Set the frame's style context - result->SetStyleContext(aPresContext, styleContext); - return result; + aResult = frame; + return rv; } NS_METHOD nsHTMLContainerFrame::ContentInserted(nsIPresShell* aShell, @@ -324,13 +334,18 @@ NS_METHOD nsHTMLContainerFrame::ContentInserted(nsIPresShell* aShell, // next-in-flow(s). It could be a pseudo-frame, but then it better also be // a nsHTMLContainerFrame... nsHTMLContainerFrame* parent = this; - if (nsnull != prevSibling) { prevSibling->GetGeometricParent((nsIFrame*&)parent); } // Create the new frame - nsIFrame* newFrame = parent->CreateFrameFor(aPresContext, aChild); + nsIStyleContext* kidSC; + kidSC = aPresContext->ResolveStyleContextFor(aChild, parent); + nsIFrame* newFrame; + nsresult rv = parent->CreateFrameFor(aPresContext, aChild, kidSC, newFrame); + if (NS_OK != rv) { + return rv; + } // Insert the frame if (nsnull == prevSibling) { diff --git a/mozilla/layout/html/base/src/nsHTMLContainerFrame.h b/mozilla/layout/html/base/src/nsHTMLContainerFrame.h index f3a4fe248cc..812f6bf0d0b 100644 --- a/mozilla/layout/html/base/src/nsHTMLContainerFrame.h +++ b/mozilla/layout/html/base/src/nsHTMLContainerFrame.h @@ -61,8 +61,10 @@ protected: const nsString& aURLSpec, const nsString& aTargetSpec); - nsIFrame* CreateFrameFor(nsIPresContext* aPresContext, - nsIContent* aContent); + nsresult CreateFrameFor(nsIPresContext* aPresContext, + nsIContent* aContent, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); }; #endif /* nsHTMLContainerFrame_h___ */ diff --git a/mozilla/layout/html/base/src/nsHTMLContent.cpp b/mozilla/layout/html/base/src/nsHTMLContent.cpp index 7c62dc0af8a..0236fbd1524 100644 --- a/mozilla/layout/html/base/src/nsHTMLContent.cpp +++ b/mozilla/layout/html/base/src/nsHTMLContent.cpp @@ -44,9 +44,11 @@ class ContentDelegate : public nsIContentDelegate { public: ContentDelegate(); NS_DECL_ISUPPORTS - virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIFrame* aParentFrame); + NS_IMETHOD CreateFrame(nsIPresContext* aPresContext, + nsIContent* aContent, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); protected: ~ContentDelegate(); }; @@ -62,27 +64,34 @@ ContentDelegate::~ContentDelegate() { } -nsIFrame* ContentDelegate::CreateFrame(nsIPresContext* aPresContext, - nsIContent* aContent, - nsIFrame* aParentFrame) +NS_METHOD +ContentDelegate::CreateFrame(nsIPresContext* aPresContext, + nsIContent* aContent, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) { NS_PRECONDITION(nsnull != aContent, "null ptr"); // Make sure the content is html content nsIHTMLContent* hc; - nsIFrame* rv; - nsresult status = aContent->QueryInterface(kIHTMLContentIID, (void**) &hc); - if (NS_OK != status) { + nsIFrame* frame = nsnull; + nsresult rv = aContent->QueryInterface(kIHTMLContentIID, (void**) &hc); + if (NS_OK != rv) { // This means that *somehow* somebody which is not an html // content object got ahold of this delegate and tried to // create a frame with it. Give them back an nsFrame. - status = nsFrame::NewFrame(&rv, aContent, aParentFrame); - return rv; + rv = nsFrame::NewFrame(&frame, aContent, aParentFrame); + if (NS_OK == rv) { + frame->SetStyleContext(aPresContext, aStyleContext); + } } - - // Ask the content object to create the frame - rv = hc->CreateFrame(aPresContext, aParentFrame); - NS_RELEASE(hc); + else { + // Ask the content object to create the frame + rv = hc->CreateFrame(aPresContext, aParentFrame, aStyleContext, frame); + NS_RELEASE(hc); + } + aResult = frame; return rv; } diff --git a/mozilla/layout/html/base/src/nsHTMLImage.cpp b/mozilla/layout/html/base/src/nsHTMLImage.cpp index e2c0e139dbf..daacd828349 100644 --- a/mozilla/layout/html/base/src/nsHTMLImage.cpp +++ b/mozilla/layout/html/base/src/nsHTMLImage.cpp @@ -76,8 +76,10 @@ class ImagePart : public nsHTMLTagContent { public: ImagePart(nsIAtom* aTag); - virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame); + virtual nsresult CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); virtual nsContentAttr GetAttribute(nsIAtom* aAttribute, @@ -565,11 +567,19 @@ void ImagePart::MapAttributesInto(nsIStyleContext* aContext, } } -nsIFrame* ImagePart::CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame) +nsresult +ImagePart::CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) { - ImageFrame* rv = new ImageFrame(this, aParentFrame); - return rv; + ImageFrame* frame = new ImageFrame(this, aParentFrame); + if (nsnull == frame) { + return NS_ERROR_OUT_OF_MEMORY; + } + aResult = frame; + frame->SetStyleContext(aPresContext, aStyleContext); + return NS_OK; } nsresult diff --git a/mozilla/layout/html/base/src/nsIHTMLContent.h b/mozilla/layout/html/base/src/nsIHTMLContent.h index aa8f0a8a2a1..51af9faef63 100644 --- a/mozilla/layout/html/base/src/nsIHTMLContent.h +++ b/mozilla/layout/html/base/src/nsIHTMLContent.h @@ -81,8 +81,10 @@ public: * Used by the html content's delegate to create a frame * for the content. */ - virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame) = 0; + virtual nsresult CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) = 0; }; #endif /* nsIHTMLContent_h___ */ diff --git a/mozilla/layout/html/base/src/nsInlineFrame.cpp b/mozilla/layout/html/base/src/nsInlineFrame.cpp index 6b6688e2549..c1407f15c1f 100644 --- a/mozilla/layout/html/base/src/nsInlineFrame.cpp +++ b/mozilla/layout/html/base/src/nsInlineFrame.cpp @@ -256,7 +256,11 @@ PRBool nsInlineFrame::ReflowMappedChildren(nsIPresContext* aPresContext, // frame. This hooks the child into the flow nsIFrame* continuingFrame; - kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame); + nsIStyleContext* kidSC; + kidFrame->GetStyleContext(aPresContext, kidSC); + kidFrame->CreateContinuingFrame(aPresContext, this, kidSC, + continuingFrame); + NS_RELEASE(kidSC); NS_ASSERTION(nsnull != continuingFrame, "frame creation failed"); // Add the continuing frame to the sibling list @@ -440,7 +444,11 @@ PRBool nsInlineFrame::PullUpChildren(nsIPresContext* aPresContext, // prepares it for reflow. nsIFrame* continuingFrame; - kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame); + nsIStyleContext* kidSC; + kidFrame->GetStyleContext(aPresContext, kidSC); + kidFrame->CreateContinuingFrame(aPresContext, this, kidSC, + continuingFrame); + NS_RELEASE(kidSC); NS_ASSERTION(nsnull != continuingFrame, "frame creation failed"); // Add the continuing frame to our sibling list and then push @@ -568,12 +576,17 @@ nsInlineFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext, kidStyleContext->GetData(kStylePositionSID); // Check whether it wants to floated or absolutely positioned + nsresult rv; if (NS_STYLE_POSITION_ABSOLUTE == kidPosition->mPosition) { - AbsoluteFrame::NewFrame(&kidFrame, kid, this); - kidFrame->SetStyleContext(aPresContext,kidStyleContext); + rv = AbsoluteFrame::NewFrame(&kidFrame, kid, this); + if (NS_OK == rv) { + kidFrame->SetStyleContext(aPresContext, kidStyleContext); + } } else if (kidDisplay->mFloats != NS_STYLE_FLOAT_NONE) { - PlaceholderFrame::NewFrame(&kidFrame, kid, this); - kidFrame->SetStyleContext(aPresContext,kidStyleContext); + rv = PlaceholderFrame::NewFrame(&kidFrame, kid, this); + if (NS_OK == rv) { + kidFrame->SetStyleContext(aPresContext, kidStyleContext); + } } else if (nsnull == kidPrevInFlow) { nsIContentDelegate* kidDel; switch (kidDisplay->mDisplay) { @@ -590,18 +603,22 @@ nsInlineFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext, case NS_STYLE_DISPLAY_INLINE: kidDel = kid->GetDelegate(aPresContext); - kidFrame = kidDel->CreateFrame(aPresContext, kid, this); + rv = kidDel->CreateFrame(aPresContext, kid, this, + kidStyleContext, kidFrame); NS_RELEASE(kidDel); break; default: NS_ASSERTION(nsnull == kidPrevInFlow, "bad prev in flow"); - nsFrame::NewFrame(&kidFrame, kid, this); + rv = nsFrame::NewFrame(&kidFrame, kid, this); + if (NS_OK == rv) { + kidFrame->SetStyleContext(aPresContext, kidStyleContext); + } break; } - kidFrame->SetStyleContext(aPresContext,kidStyleContext); } else { - kidPrevInFlow->CreateContinuingFrame(aPresContext, this, kidFrame); + rv = kidPrevInFlow->CreateContinuingFrame(aPresContext, this, + kidStyleContext, kidFrame); } NS_RELEASE(kid); NS_RELEASE(kidStyleContext); diff --git a/mozilla/layout/html/base/src/nsLineLayout.cpp b/mozilla/layout/html/base/src/nsLineLayout.cpp index 368b6a8d53e..65d5361cd0f 100644 --- a/mozilla/layout/html/base/src/nsLineLayout.cpp +++ b/mozilla/layout/html/base/src/nsLineLayout.cpp @@ -537,7 +537,11 @@ nsLineLayout::SplitLine(PRInt32 aChildReflowStatus, PRInt32 aRemainingKids) // into our lines child list. nsIFrame* nextFrame; mPrevKidFrame->GetNextSibling(nextFrame); - mPrevKidFrame->CreateContinuingFrame(mPresContext, mBlock, nextInFlow); + nsIStyleContext* kidSC; + mPrevKidFrame->GetStyleContext(mPresContext, kidSC); + mPrevKidFrame->CreateContinuingFrame(mPresContext, mBlock, kidSC, + nextInFlow); + NS_RELEASE(kidSC); if (nsnull == nextInFlow) { return NS_ERROR_OUT_OF_MEMORY; } @@ -828,74 +832,61 @@ done: nsresult nsLineLayout::CreateFrameFor(nsIContent* aKid) { - nsresult rv = NS_OK; - - // XXX what if kidSC ends up null? nsIStyleContextPtr kidSC = - mPresContext->ResolveStyleContextFor(aKid, mBlock); + mPresContext->ResolveStyleContextFor(aKid, mBlock); // XXX bad API + if (nsnull == kidSC) { + return NS_ERROR_OUT_OF_MEMORY; + } nsStylePosition* kidPosition = (nsStylePosition*) kidSC->GetData(kStylePositionSID); nsStyleDisplay* kidDisplay = (nsStyleDisplay*) kidSC->GetData(kStyleDisplaySID); // Check whether it wants to floated or absolutely positioned - // XXX don't lose error status from frame ctor's! PRBool isBlock = PR_FALSE; nsIFrame* kidFrame; + nsresult rv; if (NS_STYLE_POSITION_ABSOLUTE == kidPosition->mPosition) { - AbsoluteFrame::NewFrame(&kidFrame, aKid, mBlock); - kidFrame->SetStyleContext(mPresContext, kidSC); + rv = AbsoluteFrame::NewFrame(&kidFrame, aKid, mBlock); + if (NS_OK == rv) { + kidFrame->SetStyleContext(mPresContext, kidSC); + } } else if (kidDisplay->mFloats != NS_STYLE_FLOAT_NONE) { - PlaceholderFrame::NewFrame(&kidFrame, aKid, mBlock); - kidFrame->SetStyleContext(mPresContext, kidSC); + rv = PlaceholderFrame::NewFrame(&kidFrame, aKid, mBlock); + if (NS_OK == rv) { + kidFrame->SetStyleContext(mPresContext, kidSC); + } } else if (nsnull == mKidPrevInFlow) { // Create initial frame for the child - - // XXX refactor to just let delegate create frame (unless style is - // none) and then after that if it's a block frame and the child - // count is non-zero we return the break-before value. - nsIContentDelegate* kidDel; switch (kidDisplay->mDisplay) { + case NS_STYLE_DISPLAY_NONE: + rv = nsFrame::NewFrame(&kidFrame, aKid, mBlock); + if (NS_OK == rv) { + kidFrame->SetStyleContext(mPresContext, kidSC); + } + break; + case NS_STYLE_DISPLAY_BLOCK: case NS_STYLE_DISPLAY_LIST_ITEM: -#if 0 - // XXX Do we still need this? Now that the body code is changed it - // causes a problem... - if (mBlockIsPseudo) { - // Don't create the frame! It doesn't belong in us. - - // XXX the unfortunate thing here is that we waste the style - // lookup! - - return NS_LINE_LAYOUT_PSEUDO_BREAK_BEFORE_BLOCK; - } -#endif - kidDel = aKid->GetDelegate(mPresContext); - kidFrame = kidDel->CreateFrame(mPresContext, aKid, mBlock); - NS_RELEASE(kidDel); isBlock = PR_TRUE; - break; - - case NS_STYLE_DISPLAY_INLINE: - // XXX pass in kidSC to speed things up *alot*! - // XXX fix CreateFrame API to return an nsresult! + // FALL THROUGH + default: kidDel = aKid->GetDelegate(mPresContext); - kidFrame = kidDel->CreateFrame(mPresContext, aKid, mBlock); + rv = kidDel->CreateFrame(mPresContext, aKid, mBlock, kidSC, kidFrame); NS_RELEASE(kidDel); break; - - default:/* XXX bzzt! */ - nsFrame::NewFrame(&kidFrame, aKid, mBlock); - break; } - kidFrame->SetStyleContext(mPresContext, kidSC); } else { // Since kid has a prev-in-flow, use that to create the next // frame. - mKidPrevInFlow->CreateContinuingFrame(mPresContext, mBlock, kidFrame); + rv = mKidPrevInFlow->CreateContinuingFrame(mPresContext, mBlock, kidSC, + kidFrame); NS_ASSERTION(0 == mLine->mChildCount, "bad continuation"); } + if (NS_OK != rv) { + return rv; + } mKidFrame = kidFrame; mNewFrames++; diff --git a/mozilla/layout/html/base/src/nsListItemFrame.cpp b/mozilla/layout/html/base/src/nsListItemFrame.cpp index 2b30ce501b3..5d984e0503d 100644 --- a/mozilla/layout/html/base/src/nsListItemFrame.cpp +++ b/mozilla/layout/html/base/src/nsListItemFrame.cpp @@ -647,12 +647,17 @@ NS_METHOD nsListItemFrame::IncrementalReflow(nsIPresContext* aCX, } #endif -NS_METHOD nsListItemFrame::CreateContinuingFrame(nsIPresContext* aCX, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame) +NS_METHOD +nsListItemFrame::CreateContinuingFrame(nsIPresContext* aCX, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame) { nsListItemFrame* cf = new nsListItemFrame(mContent, aParent); - PrepareContinuingFrame(aCX, aParent, cf); + if (nsnull == cf) { + return NS_ERROR_OUT_OF_MEMORY; + } + PrepareContinuingFrame(aCX, aParent, aStyleContext, cf); aContinuingFrame = cf; return NS_OK; } diff --git a/mozilla/layout/html/base/src/nsListItemFrame.h b/mozilla/layout/html/base/src/nsListItemFrame.h index 526994f0f13..b1dcbf6fa03 100644 --- a/mozilla/layout/html/base/src/nsListItemFrame.h +++ b/mozilla/layout/html/base/src/nsListItemFrame.h @@ -34,9 +34,10 @@ public: nsRect& aDesiredRect, nsSize* aMaxElementSize, ReflowStatus& aStatus); - NS_IMETHOD CreateContinuingFrame(nsIPresContext* aCX, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame); + NS_IMETHOD CreateContinuingFrame(nsIPresContext* aCX, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame); /** * Return the reflow state for the list container that contains this diff --git a/mozilla/layout/html/base/src/nsPageFrame.cpp b/mozilla/layout/html/base/src/nsPageFrame.cpp index e9f420ab4cf..a15fda7e470 100644 --- a/mozilla/layout/html/base/src/nsPageFrame.cpp +++ b/mozilla/layout/html/base/src/nsPageFrame.cpp @@ -38,16 +38,14 @@ void PageFrame::CreateFirstChild(nsIPresContext* aPresContext) // Create a frame nsIContentDelegate* cd = child->GetDelegate(aPresContext); if (nsnull != cd) { - mFirstChild = cd->CreateFrame(aPresContext, child, this); - if (nsnull != mFirstChild) { + nsIStyleContext* kidStyleContext = + aPresContext->ResolveStyleContextFor(child, this); + nsresult rv = cd->CreateFrame(aPresContext, child, this, + kidStyleContext, mFirstChild); + NS_RELEASE(kidStyleContext); + if (NS_OK == mFirstChild) { mChildCount = 1; mLastContentOffset = mFirstContentOffset; - - // Resolve style and set the style context - nsIStyleContext* kidStyleContext = - aPresContext->ResolveStyleContextFor(child, this); - mFirstChild->SetStyleContext(aPresContext,kidStyleContext); - NS_RELEASE(kidStyleContext); } NS_RELEASE(cd); } @@ -80,7 +78,12 @@ NS_METHOD PageFrame::ResizeReflow(nsIPresContext* aPresContext, prevPage->LastChild(prevLastChild); // Create a continuing child of the previous page's last child - prevLastChild->CreateContinuingFrame(aPresContext, this, mFirstChild); + nsIStyleContext* kidSC; + prevLastChild->GetStyleContext(aPresContext, kidSC); + nsresult rv = prevLastChild->CreateContinuingFrame(aPresContext, this, + kidSC, mFirstChild); + NS_RELEASE(kidSC); + mChildCount = 1; mLastContentOffset = mFirstContentOffset; } @@ -154,12 +157,17 @@ NS_METHOD PageFrame::IncrementalReflow(nsIPresContext* aPresContext, return NS_OK; } -NS_METHOD PageFrame::CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame) +NS_METHOD +PageFrame::CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame) { PageFrame* cf = new PageFrame(mContent, aParent); - PrepareContinuingFrame(aPresContext, aParent, cf); + if (nsnull == cf) { + return NS_ERROR_OUT_OF_MEMORY; + } + PrepareContinuingFrame(aPresContext, aParent, aStyleContext, cf); aContinuingFrame = cf; return NS_OK; } diff --git a/mozilla/layout/html/base/src/nsPageFrame.h b/mozilla/layout/html/base/src/nsPageFrame.h index 629816d3631..28972f714fa 100644 --- a/mozilla/layout/html/base/src/nsPageFrame.h +++ b/mozilla/layout/html/base/src/nsPageFrame.h @@ -37,9 +37,10 @@ public: nsReflowCommand& aReflowCommand, ReflowStatus& aStatus); - NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame); + NS_IMETHOD CreateContinuingFrame(nsIPresContext* aCX, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame); NS_IMETHOD Paint(nsIPresContext& aPresContext, nsIRenderingContext& aRenderingContext, diff --git a/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp b/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp index fbc71ef6076..80cad9608bb 100644 --- a/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp +++ b/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp @@ -69,12 +69,13 @@ NS_METHOD PlaceholderFrame::ResizeReflow(nsIPresContext* aPresContext, if (nsnull == mAnchoredItem) { // Create the anchored item nsIContentDelegate* delegate = mContent->GetDelegate(aPresContext); - - mAnchoredItem = delegate->CreateFrame(aPresContext, mContent, mGeometricParent); + nsresult rv = delegate->CreateFrame(aPresContext, mContent, + mGeometricParent, mStyleContext, + mAnchoredItem); NS_RELEASE(delegate); - - // Set the style context for the frame - mAnchoredItem->SetStyleContext(aPresContext,mStyleContext); + if (NS_OK != rv) { + return rv; + } // Resize reflow the anchored item into the available space // XXX Check for complete? diff --git a/mozilla/layout/html/base/src/nsRootPart.cpp b/mozilla/layout/html/base/src/nsRootPart.cpp index 879ffac032f..6788d4d7cbb 100644 --- a/mozilla/layout/html/base/src/nsRootPart.cpp +++ b/mozilla/layout/html/base/src/nsRootPart.cpp @@ -267,16 +267,14 @@ void RootContentFrame::CreateFirstChild(nsIPresContext* aPresContext) // Create a frame nsIContentDelegate* cd = child->GetDelegate(aPresContext); if (nsnull != cd) { - mFirstChild = cd->CreateFrame(aPresContext, child, this); - if (nsnull != mFirstChild) { + nsIStyleContext* kidStyleContext = + aPresContext->ResolveStyleContextFor(child, this); + nsresult rv = cd->CreateFrame(aPresContext, child, this, + kidStyleContext, mFirstChild); + NS_RELEASE(kidStyleContext); + if (NS_OK == rv) { mChildCount = 1; mLastContentOffset = mFirstContentOffset; - - // Resolve style and set the style context - nsIStyleContext* kidStyleContext = - aPresContext->ResolveStyleContextFor(child, this); - mFirstChild->SetStyleContext(aPresContext,kidStyleContext); - NS_RELEASE(kidStyleContext); } NS_RELEASE(cd); } @@ -340,9 +338,12 @@ NS_METHOD RootContentFrame::ResizeReflow(nsIPresContext* aPresContext, } else if (nsnull == kidNextInFlow) { // The page isn't complete and it doesn't have a next-in-flow so // create a continuing page + nsIStyleContext* kidSC; + kidFrame->GetStyleContext(aPresContext, kidSC); nsIFrame* continuingPage; - - kidFrame->CreateContinuingFrame(aPresContext, this, continuingPage); + nsresult rv = kidFrame->CreateContinuingFrame(aPresContext, this, + kidSC, continuingPage); + NS_RELEASE(kidSC); // Add it to our child list #ifdef NS_DEBUG @@ -448,8 +449,11 @@ public: NS_IMETHOD_(nsrefcnt) AddRef(); NS_IMETHOD_(nsrefcnt) Release(); - virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame); + + virtual nsresult CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); protected: virtual ~RootPart(); @@ -480,11 +484,19 @@ nsrefcnt RootPart::Release(void) return mRefCnt; } -nsIFrame* RootPart::CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame) +nsresult +RootPart::CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) { - nsIFrame* rv = new RootFrame(this); - return rv; + RootFrame* frame = new RootFrame(this); + if (nsnull == frame) { + return NS_ERROR_OUT_OF_MEMORY; + } + frame->SetStyleContext(aPresContext, aStyleContext); + aResult = frame; + return NS_OK; } nsresult diff --git a/mozilla/layout/html/base/src/nsSpacerPart.cpp b/mozilla/layout/html/base/src/nsSpacerPart.cpp index c5a614417cc..83a8f1214ec 100644 --- a/mozilla/layout/html/base/src/nsSpacerPart.cpp +++ b/mozilla/layout/html/base/src/nsSpacerPart.cpp @@ -50,8 +50,10 @@ class SpacerPart : public nsHTMLTagContent { public: SpacerPart(nsIAtom* aTag); - virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame); + virtual nsresult CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); @@ -200,10 +202,19 @@ SpacerPart::~SpacerPart() { } -nsIFrame* SpacerPart::CreateFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame) +nsresult +SpacerPart::CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) { - nsIFrame* rv = new SpacerFrame(this, aParentFrame); - return rv; + nsIFrame* frame = new SpacerFrame(this, aParentFrame); + if (nsnull == frame) { + return NS_ERROR_OUT_OF_MEMORY; + } + frame->SetStyleContext(aPresContext, aStyleContext); + aResult = frame; + return NS_OK; } void SpacerPart::SetAttribute(nsIAtom* aAttribute, const nsString& aValue) diff --git a/mozilla/layout/html/base/src/nsTextContent.cpp b/mozilla/layout/html/base/src/nsTextContent.cpp index d312140bec9..140dc5995a8 100644 --- a/mozilla/layout/html/base/src/nsTextContent.cpp +++ b/mozilla/layout/html/base/src/nsTextContent.cpp @@ -219,7 +219,10 @@ public: virtual void ToHTMLString(nsString& aBuf) const; - virtual nsIFrame* CreateFrame(nsIPresContext* aCX, nsIFrame* aParentFrame); + virtual nsresult CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); // nsIScriptObjectOwner interface virtual nsresult GetScriptObject(JSContext *aContext, void** aScriptObject); @@ -1309,10 +1312,19 @@ void Text::GetText(nsString& aBuf, PRInt32 aOffset, PRInt32 aCount) } #endif -nsIFrame* Text::CreateFrame(nsIPresContext* aCX, nsIFrame* aParentFrame) +nsresult +Text::CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) { - nsIFrame* rv = new TextFrame(this, aParentFrame); - return rv; + nsIFrame* frame = new TextFrame(this, aParentFrame); + if (nsnull == frame) { + return NS_ERROR_OUT_OF_MEMORY; + } + frame->SetStyleContext(aPresContext, aStyleContext); + aResult = frame; + return NS_OK; } nsresult Text::GetScriptObject(JSContext *aContext, void** aScriptObject) diff --git a/mozilla/layout/html/base/src/nsWBRPart.cpp b/mozilla/layout/html/base/src/nsWBRPart.cpp index 1d1f7620485..0e19e67894f 100644 --- a/mozilla/layout/html/base/src/nsWBRPart.cpp +++ b/mozilla/layout/html/base/src/nsWBRPart.cpp @@ -24,8 +24,10 @@ class WBRPart : public nsHTMLTagContent { public: WBRPart(nsIAtom* aTag); - virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame); + virtual nsresult CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); protected: virtual ~WBRPart(); @@ -40,14 +42,20 @@ WBRPart::~WBRPart() { } -nsIFrame* WBRPart::CreateFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame) +nsresult +WBRPart::CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) { - nsIFrame* frame; + nsIFrame* frame = nsnull; nsresult rv = nsFrame::NewFrame(&frame, this, aParentFrame); - if (NS_OK == rv) { - return frame; + if (NS_OK != rv) { + return rv; } - return nsnull; + frame->SetStyleContext(aPresContext, aStyleContext); + aResult = frame; + return NS_OK; } nsresult diff --git a/mozilla/layout/html/forms/src/nsInput.cpp b/mozilla/layout/html/forms/src/nsInput.cpp index 9510f8510d1..3b2453e4c29 100644 --- a/mozilla/layout/html/forms/src/nsInput.cpp +++ b/mozilla/layout/html/forms/src/nsInput.cpp @@ -162,15 +162,6 @@ nsrefcnt nsInput::Release() return mRefCnt; } - -nsIFrame* -nsInput::CreateFrame(nsIPresContext *aPresContext, - nsIFrame *aParentFrame) -{ - NS_ASSERTION(0, "frames must be created by subclasses of Input"); - return nsnull; -} - PRBool nsInput::IsHidden() { diff --git a/mozilla/layout/html/forms/src/nsInput.h b/mozilla/layout/html/forms/src/nsInput.h index 17aa8487987..31151382f86 100644 --- a/mozilla/layout/html/forms/src/nsInput.h +++ b/mozilla/layout/html/forms/src/nsInput.h @@ -46,8 +46,10 @@ public: /** * @see nsIContentDelegate CreateFrame */ - virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame); + virtual nsresult CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) = 0; virtual void MapAttributesInto(nsIStyleContext* aContext, nsIPresContext* aPresContext); diff --git a/mozilla/layout/html/forms/src/nsInputButton.cpp b/mozilla/layout/html/forms/src/nsInputButton.cpp index 95f8c2bac84..ed3657d420e 100644 --- a/mozilla/layout/html/forms/src/nsInputButton.cpp +++ b/mozilla/layout/html/forms/src/nsInputButton.cpp @@ -63,8 +63,10 @@ public: nsInputButton (nsIAtom* aTag, nsIFormManager* aManager, nsButtonType aType); - virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame); + virtual nsresult CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); virtual void GetDefaultLabel(nsString& aLabel); @@ -206,19 +208,28 @@ nsInputButton::GetDefaultLabel(nsString& aString) } } -nsIFrame* +nsresult nsInputButton::CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame) + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) { + nsIFrame* frame = nsnull; if (kButton_Hidden == mType) { - nsIFrame* frame; - nsFrame::NewFrame(&frame, this, aParentFrame); - return frame; + nsresult rv = nsFrame::NewFrame(&frame, this, aParentFrame); + if (NS_OK != rv) { + return rv; + } } else { - return new nsInputButtonFrame(this, aParentFrame); + frame = new nsInputButtonFrame(this, aParentFrame); + if (nsnull == frame) { + return NS_ERROR_OUT_OF_MEMORY; + } } - + frame->SetStyleContext(aPresContext, aStyleContext); + aResult = frame; + return NS_OK; } PRInt32 diff --git a/mozilla/layout/html/forms/src/nsInputCheckbox.cpp b/mozilla/layout/html/forms/src/nsInputCheckbox.cpp index 8fbd6228ec0..9ca28b13bba 100644 --- a/mozilla/layout/html/forms/src/nsInputCheckbox.cpp +++ b/mozilla/layout/html/forms/src/nsInputCheckbox.cpp @@ -195,11 +195,19 @@ nsInputCheckbox::Reset() } } -nsIFrame* -nsInputCheckbox::CreateFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame) +nsresult +nsInputCheckbox::CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) { - nsIFrame* rv = new nsInputCheckboxFrame(this, aParentFrame); - return rv; + nsIFrame* frame = new nsInputCheckboxFrame(this, aParentFrame); + if (nsnull == frame) { + return NS_ERROR_OUT_OF_MEMORY; + } + frame->SetStyleContext(aPresContext, aStyleContext); + aResult = frame; + return NS_OK; } void nsInputCheckbox::GetType(nsString& aResult) const diff --git a/mozilla/layout/html/forms/src/nsInputCheckbox.h b/mozilla/layout/html/forms/src/nsInputCheckbox.h index eb46276b42d..f7d4d2e03a9 100644 --- a/mozilla/layout/html/forms/src/nsInputCheckbox.h +++ b/mozilla/layout/html/forms/src/nsInputCheckbox.h @@ -28,8 +28,10 @@ public: typedef nsInput nsInputCheckboxSuper; nsInputCheckbox (nsIAtom* aTag, nsIFormManager* aManager); - virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame); + virtual nsresult CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); diff --git a/mozilla/layout/html/forms/src/nsInputFile.cpp b/mozilla/layout/html/forms/src/nsInputFile.cpp index 75d13d5dfd3..6b48533ad01 100644 --- a/mozilla/layout/html/forms/src/nsInputFile.cpp +++ b/mozilla/layout/html/forms/src/nsInputFile.cpp @@ -68,12 +68,19 @@ nsInputFile::~nsInputFile() } } -nsIFrame* +nsresult nsInputFile::CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame) + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) { - nsIFrame* rv = new nsInputFileFrame(this, aParentFrame); - return rv; + nsIFrame* frame = new nsInputFileFrame(this, aParentFrame); + if (nsnull == frame) { + return NS_ERROR_OUT_OF_MEMORY; + } + frame->SetStyleContext(aPresContext, aStyleContext); + aResult = frame; + return NS_OK; } void nsInputFile::GetType(nsString& aResult) const diff --git a/mozilla/layout/html/forms/src/nsInputFile.h b/mozilla/layout/html/forms/src/nsInputFile.h index 5d7b67ec128..e41a5fb8382 100644 --- a/mozilla/layout/html/forms/src/nsInputFile.h +++ b/mozilla/layout/html/forms/src/nsInputFile.h @@ -30,8 +30,10 @@ public: typedef nsInput nsInputFileSuper; nsInputFile (nsIAtom* aTag, nsIFormManager* aManager); - virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame); + virtual nsresult CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); protected: virtual ~nsInputFile(); diff --git a/mozilla/layout/html/forms/src/nsInputRadio.cpp b/mozilla/layout/html/forms/src/nsInputRadio.cpp index 9704ea98c17..2033d62b819 100644 --- a/mozilla/layout/html/forms/src/nsInputRadio.cpp +++ b/mozilla/layout/html/forms/src/nsInputRadio.cpp @@ -185,13 +185,19 @@ nsInputRadio::SetChecked(PRBool aValue, PRBool aSetInitialValue) ((nsIRadioButton *)mWidget)->SetState(aValue); } - -nsIFrame* +nsresult nsInputRadio::CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame) + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) { - nsIFrame* rv = new nsInputRadioFrame(this, aParentFrame); - return rv; + nsIFrame* frame = new nsInputRadioFrame(this, aParentFrame); + if (nsnull == frame) { + return NS_ERROR_OUT_OF_MEMORY; + } + frame->SetStyleContext(aPresContext, aStyleContext); + aResult = frame; + return NS_OK; } void nsInputRadio::GetType(nsString& aResult) const diff --git a/mozilla/layout/html/forms/src/nsInputRadio.h b/mozilla/layout/html/forms/src/nsInputRadio.h index 5d4ed90562c..d74d6186ac7 100644 --- a/mozilla/layout/html/forms/src/nsInputRadio.h +++ b/mozilla/layout/html/forms/src/nsInputRadio.h @@ -32,8 +32,10 @@ public: typedef nsInput nsInputRadioSuper; nsInputRadio (nsIAtom* aTag, nsIFormManager* aManager); - virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame); + virtual nsresult CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); diff --git a/mozilla/layout/html/forms/src/nsInputText.cpp b/mozilla/layout/html/forms/src/nsInputText.cpp index 2ec06730ae4..c221c2a0487 100644 --- a/mozilla/layout/html/forms/src/nsInputText.cpp +++ b/mozilla/layout/html/forms/src/nsInputText.cpp @@ -202,11 +202,19 @@ nsInputText::GetTextType() const return mType; } -nsIFrame* +nsresult nsInputText::CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame) + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) { - return new nsInputTextFrame(this, aParentFrame); + nsIFrame* frame = new nsInputTextFrame(this, aParentFrame); + if (nsnull == frame) { + return NS_ERROR_OUT_OF_MEMORY; + } + frame->SetStyleContext(aPresContext, aStyleContext); + aResult = frame; + return NS_OK; } PRInt32 diff --git a/mozilla/layout/html/forms/src/nsInputText.h b/mozilla/layout/html/forms/src/nsInputText.h index c9ed078c022..6b1aac889f7 100644 --- a/mozilla/layout/html/forms/src/nsInputText.h +++ b/mozilla/layout/html/forms/src/nsInputText.h @@ -38,8 +38,10 @@ public: typedef nsInput nsInputTextSuper; nsInputText (nsIAtom* aTag, nsIFormManager* aManager, nsInputTextType aType); - virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame); + virtual nsresult CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); diff --git a/mozilla/layout/html/forms/src/nsSelect.cpp b/mozilla/layout/html/forms/src/nsSelect.cpp index aac6b7ffa8a..53cfc54239d 100644 --- a/mozilla/layout/html/forms/src/nsSelect.cpp +++ b/mozilla/layout/html/forms/src/nsSelect.cpp @@ -74,8 +74,10 @@ public: typedef nsInput super; nsSelect (nsIAtom* aTag, nsIFormManager* aFormMan); - virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame); + virtual nsresult CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); @@ -108,8 +110,10 @@ public: nsOption (nsIAtom* aTag); - virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame); + virtual nsresult CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); @@ -299,12 +303,19 @@ void nsSelect::GetType(nsString& aResult) const aResult = "select"; } -nsIFrame* +nsresult nsSelect::CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame) + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) { - nsIFrame* rv = new nsSelectFrame(this, aParentFrame); - return rv; + nsIFrame* frame = new nsSelectFrame(this, aParentFrame); + if (nsnull == frame) { + return NS_ERROR_OUT_OF_MEMORY; + } + frame->SetStyleContext(aPresContext, aStyleContext); + aResult = frame; + return NS_OK; } void nsSelect::SetAttribute(nsIAtom* aAttribute, @@ -460,13 +471,20 @@ void nsOption::GetType(nsString& aResult) const aResult = "select"; } -nsIFrame* +nsresult nsOption::CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame) + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) { nsIFrame* frame; - nsFrame::NewFrame(&frame, this, aParentFrame); - return frame; + nsresult rv = nsFrame::NewFrame(&frame, this, aParentFrame); + if (NS_OK != rv) { + return rv; + } + frame->SetStyleContext(aPresContext, aStyleContext); + aResult = frame; + return NS_OK; } void nsOption::SetAttribute(nsIAtom* aAttribute, diff --git a/mozilla/layout/html/table/src/nsTableCaption.cpp b/mozilla/layout/html/table/src/nsTableCaption.cpp index 1d7d4a5ef11..8c1a5fad931 100644 --- a/mozilla/layout/html/table/src/nsTableCaption.cpp +++ b/mozilla/layout/html/table/src/nsTableCaption.cpp @@ -76,13 +76,21 @@ int nsTableCaption::GetType() return nsITableContent::kTableCaptionType; } -nsIFrame* nsTableCaption::CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame) +nsresult +nsTableCaption::CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) { NS_PRECONDITION(nsnull!=aPresContext, "bad arg"); - nsIFrame* rv; - nsresult status = nsTableCaptionFrame::NewFrame(&rv, this, aParentFrame); - NS_ASSERTION(nsnull!=rv, "bad arg"); + + nsIFrame* frame; + nsresult rv = nsTableCaptionFrame::NewFrame(&frame, this, aParentFrame); + if (NS_OK != rv) { + return rv; + } + frame->SetStyleContext(aPresContext, aStyleContext); + aResult = frame; return rv; } diff --git a/mozilla/layout/html/table/src/nsTableCaption.h b/mozilla/layout/html/table/src/nsTableCaption.h index e8d6881b3fb..5ae717190b9 100644 --- a/mozilla/layout/html/table/src/nsTableCaption.h +++ b/mozilla/layout/html/table/src/nsTableCaption.h @@ -59,8 +59,10 @@ public: virtual int GetType(); /** @see nsIHTMLContent::CreateFrame */ - virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame); - + virtual nsresult CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); }; #endif diff --git a/mozilla/layout/html/table/src/nsTableCaptionFrame.cpp b/mozilla/layout/html/table/src/nsTableCaptionFrame.cpp index 180c98a0ad1..e58fb551a91 100644 --- a/mozilla/layout/html/table/src/nsTableCaptionFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableCaptionFrame.cpp @@ -90,7 +90,11 @@ void nsTableCaptionFrame::CreatePsuedoFrame(nsIPresContext* aPresContext) NS_ASSERTION(prevFrame->ChildIsPseudoFrame(prevPseudoFrame), "bad previous pseudo-frame"); // Create a continuing column - prevPseudoFrame->CreateContinuingFrame(aPresContext, this, mFirstChild); + nsIStyleContext* kidSC; + prevPseudoFrame->GetStyleContext(aPresContext, kidSC); + prevPseudoFrame->CreateContinuingFrame(aPresContext, this, kidSC, + mFirstChild); + NS_RELEASE(kidSC); mChildCount = 1; } } @@ -324,13 +328,18 @@ NS_METHOD nsTableCaptionFrame::IncrementalReflow(nsIPresContext* aPresContext, return NS_OK; } -NS_METHOD nsTableCaptionFrame::CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame) +NS_METHOD +nsTableCaptionFrame::CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame) { if (PR_TRUE==gsDebug) printf("nsTableCaptionFrame::CreateContinuingFrame called\n"); nsTableCaptionFrame* cf = new nsTableCaptionFrame(mContent, aParent); - PrepareContinuingFrame(aPresContext, aParent, cf); + if (nsnull == cf) { + return NS_ERROR_OUT_OF_MEMORY; + } + PrepareContinuingFrame(aPresContext, aParent, aStyleContext, cf); aContinuingFrame = cf; return NS_OK; } diff --git a/mozilla/layout/html/table/src/nsTableCaptionFrame.h b/mozilla/layout/html/table/src/nsTableCaptionFrame.h index 7b2c8c294c4..3c326c39c79 100644 --- a/mozilla/layout/html/table/src/nsTableCaptionFrame.h +++ b/mozilla/layout/html/table/src/nsTableCaptionFrame.h @@ -54,9 +54,10 @@ public: /** * @see nsContainerFrame */ - NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame); + NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame); virtual void VerticallyAlignChild(nsIPresContext* aPresContext); diff --git a/mozilla/layout/html/table/src/nsTableCell.cpp b/mozilla/layout/html/table/src/nsTableCell.cpp index d0701cc8fe5..cb9d81d362d 100644 --- a/mozilla/layout/html/table/src/nsTableCell.cpp +++ b/mozilla/layout/html/table/src/nsTableCell.cpp @@ -143,13 +143,21 @@ void nsTableCell::SetColIndex (int aColIndex) mColIndex = aColIndex; } -nsIFrame* nsTableCell::CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame) +nsresult +nsTableCell::CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) { NS_PRECONDITION(nsnull!=aPresContext, "bad arg"); - nsIFrame* rv; - nsresult status = nsTableCellFrame::NewFrame(&rv, this, aParentFrame); - NS_ASSERTION(nsnull!=rv, "bad arg"); + + nsIFrame* frame; + nsresult rv = nsTableCellFrame::NewFrame(&frame, this, aParentFrame); + if (NS_OK != rv) { + return rv; + } + frame->SetStyleContext(aPresContext, aStyleContext); + aResult = frame; return rv; } diff --git a/mozilla/layout/html/table/src/nsTableCell.h b/mozilla/layout/html/table/src/nsTableCell.h index 2ba412a5d5e..e3601d2daa6 100644 --- a/mozilla/layout/html/table/src/nsTableCell.h +++ b/mozilla/layout/html/table/src/nsTableCell.h @@ -86,8 +86,10 @@ public: virtual int GetType(); /** @see nsIHTMLContent::CreateFrame */ - virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame); + virtual nsresult CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); virtual void SetAttribute(nsIAtom* aAttribute, const nsString& aValue); diff --git a/mozilla/layout/html/table/src/nsTableCellFrame.cpp b/mozilla/layout/html/table/src/nsTableCellFrame.cpp index c05c1a1a9ac..1597e13e1ba 100644 --- a/mozilla/layout/html/table/src/nsTableCellFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableCellFrame.cpp @@ -194,7 +194,10 @@ void nsTableCellFrame::CreatePsuedoFrame(nsIPresContext* aPresContext) NS_ASSERTION(prevFrame->ChildIsPseudoFrame(prevPseudoFrame), "bad previous pseudo-frame"); // Create a continuing column - prevPseudoFrame->CreateContinuingFrame(aPresContext, this, mFirstChild); + nsIStyleContext* kidSC; + prevPseudoFrame->GetStyleContext(aPresContext, kidSC); + prevPseudoFrame->CreateContinuingFrame(aPresContext, this, kidSC, mFirstChild); + NS_RELEASE(kidSC); mChildCount = 1; } } @@ -334,12 +337,17 @@ NS_METHOD nsTableCellFrame::IncrementalReflow(nsIPresContext* aPresContext, return NS_OK; } -NS_METHOD nsTableCellFrame::CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame) +NS_METHOD +nsTableCellFrame::CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame) { nsTableCellFrame* cf = new nsTableCellFrame(mContent, aParent); - PrepareContinuingFrame(aPresContext, aParent, cf); + if (nsnull == cf) { + return NS_ERROR_OUT_OF_MEMORY; + } + PrepareContinuingFrame(aPresContext, aParent, aStyleContext, cf); aContinuingFrame = cf; return NS_OK; } diff --git a/mozilla/layout/html/table/src/nsTableCellFrame.h b/mozilla/layout/html/table/src/nsTableCellFrame.h index 7679dc2f272..fdcf1f63525 100644 --- a/mozilla/layout/html/table/src/nsTableCellFrame.h +++ b/mozilla/layout/html/table/src/nsTableCellFrame.h @@ -54,9 +54,10 @@ public: /** * @see nsContainerFrame */ - NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame); + NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame); void VerticallyAlignChild(nsIPresContext* aPresContext); diff --git a/mozilla/layout/html/table/src/nsTableCol.cpp b/mozilla/layout/html/table/src/nsTableCol.cpp index fc8a48d8388..f689ac39b4c 100644 --- a/mozilla/layout/html/table/src/nsTableCol.cpp +++ b/mozilla/layout/html/table/src/nsTableCol.cpp @@ -319,11 +319,21 @@ nsString * nsTableCol::GetAllInternalAttributeNames () return nsnull; } -nsIFrame* nsTableCol::CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame) +nsresult +nsTableCol::CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) { - nsIFrame* rv; - nsresult status = nsTableColFrame::NewFrame(&rv, this, aParentFrame); + NS_PRECONDITION(nsnull!=aPresContext, "bad arg"); + + nsIFrame* frame; + nsresult rv = nsTableColFrame::NewFrame(&frame, this, aParentFrame); + if (NS_OK != rv) { + return rv; + } + frame->SetStyleContext(aPresContext, aStyleContext); + aResult = frame; return rv; } diff --git a/mozilla/layout/html/table/src/nsTableCol.h b/mozilla/layout/html/table/src/nsTableCol.h index cb74175f306..4a7ba2ff69d 100644 --- a/mozilla/layout/html/table/src/nsTableCol.h +++ b/mozilla/layout/html/table/src/nsTableCol.h @@ -76,8 +76,10 @@ public: virtual int GetType(); /** @see nsIHTMLContent::CreateFrame */ - virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame); + virtual nsresult CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); /** return the number of columns this content object represents. always >= 1*/ virtual int GetRepeat (); diff --git a/mozilla/layout/html/table/src/nsTableColGroup.cpp b/mozilla/layout/html/table/src/nsTableColGroup.cpp index c9511ece403..a99b54c1852 100644 --- a/mozilla/layout/html/table/src/nsTableColGroup.cpp +++ b/mozilla/layout/html/table/src/nsTableColGroup.cpp @@ -331,12 +331,21 @@ PRBool nsTableColGroup::IsCol(nsIContent * aContent) const return result; } -nsIFrame* nsTableColGroup::CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame) +nsresult +nsTableColGroup::CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) { - nsIFrame* rv; - nsresult status = nsTableColGroupFrame::NewFrame(&rv, this, aParentFrame); - NS_ASSERTION(nsnull!=rv, "can't allocate a new frame"); + NS_PRECONDITION(nsnull!=aPresContext, "bad arg"); + + nsIFrame* frame; + nsresult rv = nsTableColGroupFrame::NewFrame(&frame, this, aParentFrame); + if (NS_OK != rv) { + return rv; + } + frame->SetStyleContext(aPresContext, aStyleContext); + aResult = frame; return rv; } diff --git a/mozilla/layout/html/table/src/nsTableColGroup.h b/mozilla/layout/html/table/src/nsTableColGroup.h index 8befe33b59c..61d20ebaaf1 100644 --- a/mozilla/layout/html/table/src/nsTableColGroup.h +++ b/mozilla/layout/html/table/src/nsTableColGroup.h @@ -77,8 +77,10 @@ public: NS_IMETHOD_(nsrefcnt) Release(); /** @see nsIHTMLContent::CreateFrame */ - virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame); + virtual nsresult CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); /** returns nsITableContent::kTableColGroupType */ virtual int GetType(); diff --git a/mozilla/layout/html/table/src/nsTableFrame.cpp b/mozilla/layout/html/table/src/nsTableFrame.cpp index ed652616bd9..a90adf1d1b0 100644 --- a/mozilla/layout/html/table/src/nsTableFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableFrame.cpp @@ -637,9 +637,9 @@ nsIFrame::ReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresCont { nsIContentDelegate* kidDel; kidDel = kid->GetDelegate(aPresContext); - kidFrame = kidDel->CreateFrame(aPresContext, kid, this); + nsresult rv = kidDel->CreateFrame(aPresContext, kid, + this, kidStyleContext, kidFrame); NS_RELEASE(kidDel); - kidFrame->SetStyleContext(aPresContext,kidStyleContext); } nsSize maxKidElementSize; @@ -1058,7 +1058,10 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext* aPresContext, // frame. This hooks the child into the flow nsIFrame* continuingFrame; - kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame); + nsIStyleContext* kidSC; + kidFrame->GetStyleContext(aPresContext, kidSC); + kidFrame->CreateContinuingFrame(aPresContext, this, kidSC, continuingFrame); + NS_RELEASE(kidSC); NS_ASSERTION(nsnull != continuingFrame, "frame creation failed"); // Add the continuing frame to the sibling list @@ -1286,7 +1289,10 @@ PRBool nsTableFrame::PullUpChildren(nsIPresContext* aPresContext, // prepares it for reflow. nsIFrame* continuingFrame; - kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame); + nsIStyleContext* kidSC; + kidFrame->GetStyleContext(aPresContext, kidSC); + kidFrame->CreateContinuingFrame(aPresContext, this, kidSC, continuingFrame); + NS_RELEASE(kidSC); NS_ASSERTION(nsnull != continuingFrame, "frame creation failed"); // Add the continuing frame to our sibling list and then push @@ -1412,11 +1418,12 @@ nsTableFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext, if (nsnull == kidPrevInFlow) { nsIContentDelegate* kidDel = nsnull; kidDel = kid->GetDelegate(aPresContext); - kidFrame = kidDel->CreateFrame(aPresContext, kid, this); + nsresult rv = kidDel->CreateFrame(aPresContext, kid, this, + kidStyleContext, kidFrame); NS_RELEASE(kidDel); - kidFrame->SetStyleContext(aPresContext, kidStyleContext); } else { - kidPrevInFlow->CreateContinuingFrame(aPresContext, this, kidFrame); + kidPrevInFlow->CreateContinuingFrame(aPresContext, this, kidStyleContext, + kidFrame); } // Try to reflow the child into the available space. It might not @@ -2039,12 +2046,17 @@ PRBool nsTableFrame::IsFirstPassValid() const return firstInFlow->mFirstPassValid; } -NS_METHOD nsTableFrame::CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame) +NS_METHOD +nsTableFrame::CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame) { nsTableFrame* cf = new nsTableFrame(mContent, aParent); - PrepareContinuingFrame(aPresContext, aParent, cf); + if (nsnull == cf) { + return NS_ERROR_OUT_OF_MEMORY; + } + PrepareContinuingFrame(aPresContext, aParent, aStyleContext, cf); if (PR_TRUE==gsDebug) printf("nsTableFrame::CCF parent = %p, this=%p, cf=%p\n", aParent, this, cf); // set my width, because all frames in a table flow are the same width // code in nsTableOuterFrame depends on this being set @@ -2074,9 +2086,10 @@ NS_METHOD nsTableFrame::CreateContinuingFrame(nsIPresContext* aPresContext, aPresContext->ResolveStyleContextFor(content, cf); // kidStyleContext: REFCNT++ nsIContentDelegate* kidDel = nsnull; kidDel = content->GetDelegate(aPresContext); // kidDel: REFCNT++ - nsIFrame * duplicateFrame = kidDel->CreateFrame(aPresContext, content, cf); + nsIFrame* duplicateFrame; + nsresult rv = kidDel->CreateFrame(aPresContext, content, cf, + kidStyleContext, duplicateFrame); NS_RELEASE(kidDel); // kidDel: REFCNT-- - duplicateFrame->SetStyleContext(aPresContext,kidStyleContext); NS_RELEASE(kidStyleContext); // kidStyleContenxt: REFCNT-- if (nsnull==lastSib) diff --git a/mozilla/layout/html/table/src/nsTableFrame.h b/mozilla/layout/html/table/src/nsTableFrame.h index 62ce24bb1a9..88599c72f4f 100644 --- a/mozilla/layout/html/table/src/nsTableFrame.h +++ b/mozilla/layout/html/table/src/nsTableFrame.h @@ -95,9 +95,10 @@ public: ReflowStatus& aStatus); /** @see nsContainerFrame::CreateContinuingFrame */ - NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame); + NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame); /** resize myself and my children according to the arcane rules of cell height magic. * By default, the height of a cell is the max (height of cells in its row) diff --git a/mozilla/layout/html/table/src/nsTableOuterFrame.cpp b/mozilla/layout/html/table/src/nsTableOuterFrame.cpp index 3105384a307..84de6ac9b82 100644 --- a/mozilla/layout/html/table/src/nsTableOuterFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableOuterFrame.cpp @@ -529,8 +529,11 @@ PRBool nsTableOuterFrame::ReflowMappedChildren( nsIPresContext* aPresContex // The child doesn't have a next-in-flow so create a continuing // frame. This hooks the child into the flow nsIFrame* continuingFrame; - - kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame); + nsIStyleContext* kidSC; + kidFrame->GetStyleContext(aPresContext, kidSC); + kidFrame->CreateContinuingFrame(aPresContext, this, kidSC, + continuingFrame); + NS_RELEASE(kidSC); NS_ASSERTION(nsnull != continuingFrame, "frame creation failed"); // Add the continuing frame to the sibling list @@ -764,8 +767,10 @@ PRBool nsTableOuterFrame::PullUpChildren( nsIPresContext* aPresContext, // continuing frame. The creation appends it to the flow and // prepares it for reflow. nsIFrame* continuingFrame; - - kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame); + nsIStyleContext* kidSC; + kidFrame->GetStyleContext(aPresContext, kidSC); + kidFrame->CreateContinuingFrame(aPresContext, this, kidSC, + continuingFrame); NS_ASSERTION(nsnull != continuingFrame, "frame creation failed"); // Add the continuing frame to our sibling list and then push @@ -1202,12 +1207,17 @@ nsTableOuterFrame::IncrementalReflow(nsIPresContext* aPresContext, return NS_OK; } -NS_METHOD nsTableOuterFrame::CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame) +NS_METHOD +nsTableOuterFrame::CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame) { nsTableOuterFrame* cf = new nsTableOuterFrame(mContent, aParent); - PrepareContinuingFrame(aPresContext, aParent, cf); + if (nsnull == cf) { + return NS_ERROR_OUT_OF_MEMORY; + } + PrepareContinuingFrame(aPresContext, aParent, aStyleContext, cf); cf->SetFirstPassValid(PR_TRUE); if (PR_TRUE==gsDebug) printf("nsTableOuterFrame::CCF parent = %p, this=%p, cf=%p\n", aParent, this, cf); @@ -1215,9 +1225,11 @@ NS_METHOD nsTableOuterFrame::CreateContinuingFrame(nsIPresContext* aPresContext, return NS_OK; } -void nsTableOuterFrame::PrepareContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsTableOuterFrame* aContFrame) +void +nsTableOuterFrame::PrepareContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsTableOuterFrame* aContFrame) { // Append the continuing frame to the flow aContFrame->AppendToFlow(this); @@ -1238,12 +1250,7 @@ void nsTableOuterFrame::PrepareContinuingFrame(nsIPresContext* aPresContext, aContFrame->SetFirstContentOffset(nextOffset); aContFrame->SetLastContentOffset(nextOffset); aContFrame->SetLastContentIsComplete(PR_TRUE); - - // Resolve style for the continuing frame and set its style context. - // XXX presumptive - nsIStyleContextPtr styleContext = - aPresContext->ResolveStyleContextFor(mContent, aParent); - aContFrame->SetStyleContext(aPresContext,styleContext); + aContFrame->SetStyleContext(aPresContext, aStyleContext); } NS_METHOD nsTableOuterFrame::VerifyTree() const @@ -1373,8 +1380,10 @@ void nsTableOuterFrame::CreateInnerTableFrame(nsIPresContext* aPresContext) if (nsnull==mInnerTableFrame) { nsIFrame* continuingFrame; - - prevInnerTable->CreateContinuingFrame(aPresContext, this, continuingFrame); + nsIStyleContext* kidSC; + prevInnerTable->GetStyleContext(aPresContext, kidSC); + prevInnerTable->CreateContinuingFrame(aPresContext, this, kidSC, + continuingFrame); mInnerTableFrame = (nsTableFrame*)continuingFrame; mChildCount++; } diff --git a/mozilla/layout/html/table/src/nsTableOuterFrame.h b/mozilla/layout/html/table/src/nsTableOuterFrame.h index 08d0c7ea89b..7cd0cea66a2 100644 --- a/mozilla/layout/html/table/src/nsTableOuterFrame.h +++ b/mozilla/layout/html/table/src/nsTableOuterFrame.h @@ -97,9 +97,10 @@ public: ReflowStatus& aStatus); /** @see nsContainerFrame */ - NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame); + NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame); /** destructor */ virtual ~nsTableOuterFrame(); @@ -206,9 +207,10 @@ protected: /** overridden here to handle special caption-table relationship * @see nsContainerFrame::PrepareContinuingFrame */ - virtual void PrepareContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsTableOuterFrame* aContFrame); + void PrepareContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsTableOuterFrame* aContFrame); /** * Remove and delete aChild's next-in-flow(s). Updates the sibling and flow diff --git a/mozilla/layout/html/table/src/nsTablePart.cpp b/mozilla/layout/html/table/src/nsTablePart.cpp index 37942362695..44f95789520 100644 --- a/mozilla/layout/html/table/src/nsTablePart.cpp +++ b/mozilla/layout/html/table/src/nsTablePart.cpp @@ -998,10 +998,21 @@ PRInt32 nsTablePart::GetEffectiveRowSpan (PRInt32 aRowIndex, nsTableCell *aCell) /** * Create a frame object that will layout this table. */ -nsIFrame* nsTablePart::CreateFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame) +nsresult +nsTablePart::CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) { - nsIFrame* rv; - nsresult status = nsTableOuterFrame::NewFrame(&rv, this, aParentFrame); + NS_PRECONDITION(nsnull!=aPresContext, "bad arg"); + + nsIFrame* frame; + nsresult rv = nsTableOuterFrame::NewFrame(&frame, this, aParentFrame); + if (NS_OK != rv) { + return rv; + } + frame->SetStyleContext(aPresContext, aStyleContext); + aResult = frame; return rv; } diff --git a/mozilla/layout/html/table/src/nsTablePart.h b/mozilla/layout/html/table/src/nsTablePart.h index 14d379e2835..76faaeb6cf9 100644 --- a/mozilla/layout/html/table/src/nsTablePart.h +++ b/mozilla/layout/html/table/src/nsTablePart.h @@ -144,8 +144,10 @@ public: virtual PRBool AppendChild(nsIContent* aKid); virtual PRBool RemoveChildAt(PRInt32 aIndex); - virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame); + virtual nsresult CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); /** called when the input stream knows that the input has been completely consumed. * this is a hook for future optimizations. diff --git a/mozilla/layout/html/table/src/nsTableRow.cpp b/mozilla/layout/html/table/src/nsTableRow.cpp index 0d079052225..e9576c53486 100644 --- a/mozilla/layout/html/table/src/nsTableRow.cpp +++ b/mozilla/layout/html/table/src/nsTableRow.cpp @@ -239,12 +239,21 @@ PRBool nsTableRow::RemoveChildAt (int aIndex) return result; } -// nsTableRowFrame checks args -nsIFrame* nsTableRow::CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame) +nsresult +nsTableRow::CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) { - nsIFrame* rv; - nsresult status = nsTableRowFrame::NewFrame(&rv, this, aParentFrame); + NS_PRECONDITION(nsnull!=aPresContext, "bad arg"); + + nsIFrame* frame; + nsresult rv = nsTableRowFrame::NewFrame(&frame, this, aParentFrame); + if (NS_OK != rv) { + return rv; + } + frame->SetStyleContext(aPresContext, aStyleContext); + aResult = frame; return rv; } diff --git a/mozilla/layout/html/table/src/nsTableRow.h b/mozilla/layout/html/table/src/nsTableRow.h index c23fb602a99..4b070ac1029 100644 --- a/mozilla/layout/html/table/src/nsTableRow.h +++ b/mozilla/layout/html/table/src/nsTableRow.h @@ -70,8 +70,10 @@ public: virtual int GetType(); /** @see nsIHTMLContent::CreateFrame */ - virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame); + virtual nsresult CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); /** return the row group that contains me (my parent) */ virtual nsTableRowGroup *GetRowGroup (); diff --git a/mozilla/layout/html/table/src/nsTableRowFrame.cpp b/mozilla/layout/html/table/src/nsTableRowFrame.cpp index 23198d8279d..54e473ea82e 100644 --- a/mozilla/layout/html/table/src/nsTableRowFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableRowFrame.cpp @@ -391,8 +391,11 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext, // No the child isn't complete, and it doesn't have a next in flow so // create a continuing frame. This hooks the child into the flow. nsIFrame* continuingFrame; - - kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame); + nsIStyleContext* kidSC; + kidFrame->GetStyleContext(aPresContext, kidSC); + kidFrame->CreateContinuingFrame(aPresContext, this, kidSC, + continuingFrame); + NS_RELEASE(kidSC); // Insert the frame. We'll reflow it next pass through the loop nsIFrame* nextSib; @@ -654,8 +657,11 @@ PRBool nsTableRowFrame::PullUpChildren(nsIPresContext* aPresContext, // continuing frame. The creation appends it to the flow and // prepares it for reflow. nsIFrame* continuingFrame; - - kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame); + nsIStyleContext* kidSC; + kidFrame->GetStyleContext(aPresContext, kidSC); + kidFrame->CreateContinuingFrame(aPresContext, this, kidSC, + continuingFrame); + NS_RELEASE(kidSC); NS_ASSERTION(nsnull != continuingFrame, "frame creation failed"); // Add the continuing frame to our sibling list and then push @@ -808,11 +814,12 @@ nsTableRowFrame::ReflowUnmappedChildren( nsIPresContext* aPresContext, if (nsnull == kidPrevInFlow) { nsIContentDelegate* kidDel = nsnull; kidDel = cell->GetDelegate(aPresContext); - kidFrame = kidDel->CreateFrame(aPresContext, cell, this); + nsresult rv = kidDel->CreateFrame(aPresContext, cell, + this, kidStyleContext, kidFrame); NS_RELEASE(kidDel); - kidFrame->SetStyleContext(aPresContext,kidStyleContext); } else { - kidPrevInFlow->CreateContinuingFrame(aPresContext, this, kidFrame); + kidPrevInFlow->CreateContinuingFrame(aPresContext, this, + kidStyleContext, kidFrame); } NS_RELEASE(kidStyleContext); @@ -1030,13 +1037,18 @@ nsTableRowFrame::IncrementalReflow(nsIPresContext* aPresContext, return NS_OK; } -NS_METHOD nsTableRowFrame::CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame) +NS_METHOD +nsTableRowFrame::CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame) { if (gsDebug1==PR_TRUE) printf("nsTableRowFrame::CreateContinuingFrame\n"); nsTableRowFrame* cf = new nsTableRowFrame(mContent, aParent); - PrepareContinuingFrame(aPresContext, aParent, cf); + if (nsnull == cf) { + return NS_ERROR_OUT_OF_MEMORY; + } + PrepareContinuingFrame(aPresContext, aParent, aStyleContext, cf); aContinuingFrame = cf; return NS_OK; } diff --git a/mozilla/layout/html/table/src/nsTableRowFrame.h b/mozilla/layout/html/table/src/nsTableRowFrame.h index 77578e71066..e84cfb28d2f 100644 --- a/mozilla/layout/html/table/src/nsTableRowFrame.h +++ b/mozilla/layout/html/table/src/nsTableRowFrame.h @@ -91,9 +91,10 @@ public: ReflowStatus& aStatus); /** @see nsContainerFrame::CreateContinuingFrame */ - NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame); + NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame); /** set mTallestCell to 0 in anticipation of recalculating it */ void ResetMaxChildHeight(); diff --git a/mozilla/layout/html/table/src/nsTableRowGroup.cpp b/mozilla/layout/html/table/src/nsTableRowGroup.cpp index 7e473dc9729..30ae7935e53 100644 --- a/mozilla/layout/html/table/src/nsTableRowGroup.cpp +++ b/mozilla/layout/html/table/src/nsTableRowGroup.cpp @@ -94,12 +94,21 @@ nsrefcnt nsTableRowGroup::Release(void) return mRefCnt; } -// nsTableRowGroupFrame checks arguments -nsIFrame* nsTableRowGroup::CreateFrame( nsIPresContext* aPresContext, - nsIFrame* aParentFrame) +nsresult +nsTableRowGroup::CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult) { - nsIFrame* rv; - nsresult status = nsTableRowGroupFrame::NewFrame(&rv, this, aParentFrame); + NS_PRECONDITION(nsnull!=aPresContext, "bad arg"); + + nsIFrame* frame; + nsresult rv = nsTableRowGroupFrame::NewFrame(&frame, this, aParentFrame); + if (NS_OK != rv) { + return rv; + } + frame->SetStyleContext(aPresContext, aStyleContext); + aResult = frame; return rv; } diff --git a/mozilla/layout/html/table/src/nsTableRowGroup.h b/mozilla/layout/html/table/src/nsTableRowGroup.h index 5c408a9f693..58f90b4ec30 100644 --- a/mozilla/layout/html/table/src/nsTableRowGroup.h +++ b/mozilla/layout/html/table/src/nsTableRowGroup.h @@ -63,8 +63,10 @@ public: NS_IMETHOD_(nsrefcnt) Release(); /** @see nsIHTMLContent::CreateFrame */ - virtual nsIFrame* CreateFrame(nsIPresContext* aPresContext, - nsIFrame* aParentFrame); + virtual nsresult CreateFrame(nsIPresContext* aPresContext, + nsIFrame* aParentFrame, + nsIStyleContext* aStyleContext, + nsIFrame*& aResult); /** return the number of contained rows */ virtual int GetRowCount () diff --git a/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp b/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp index a92ca395f69..bc77cceed71 100644 --- a/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp @@ -359,8 +359,11 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon // No the child isn't complete, and it doesn't have a next in flow so // create a continuing frame. This hooks the child into the flow. nsIFrame* continuingFrame; - - kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame); + nsIStyleContext* kidSC; + kidFrame->GetStyleContext(aPresContext, kidSC); + kidFrame->CreateContinuingFrame(aPresContext, this, kidSC, + continuingFrame); + NS_RELEASE(kidSC); // Insert the frame. We'll reflow it next pass through the loop nsIFrame* nextSib; @@ -587,8 +590,11 @@ PRBool nsTableRowGroupFrame::PullUpChildren(nsIPresContext* aPresContext, // continuing frame. The creation appends it to the flow and // prepares it for reflow. nsIFrame* continuingFrame; - - kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame); + nsIStyleContext* kidSC; + kidFrame->GetStyleContext(aPresContext, kidSC); + kidFrame->CreateContinuingFrame(aPresContext, this, kidSC, + continuingFrame); + NS_RELEASE(kidSC); NS_ASSERTION(nsnull != continuingFrame, "frame creation failed"); // Add the continuing frame to our sibling list and then push @@ -739,11 +745,12 @@ nsTableRowGroupFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext, if (nsnull == kidPrevInFlow) { nsIContentDelegate* kidDel = nsnull; kidDel = kid->GetDelegate(aPresContext); - kidFrame = kidDel->CreateFrame(aPresContext, kid, this); + nsresult rv = kidDel->CreateFrame(aPresContext, kid, this, kidSC, + kidFrame); NS_RELEASE(kidDel); - kidFrame->SetStyleContext(aPresContext,kidSC); } else { - kidPrevInFlow->CreateContinuingFrame(aPresContext, this, kidFrame); + kidPrevInFlow->CreateContinuingFrame(aPresContext, this, kidSC, + kidFrame); } // Try to reflow the child into the available space. It might not @@ -922,12 +929,17 @@ nsTableRowGroupFrame::IncrementalReflow(nsIPresContext* aPresContext, return NS_OK; } -NS_METHOD nsTableRowGroupFrame::CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame) +NS_METHOD +nsTableRowGroupFrame::CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame) { nsTableRowGroupFrame* cf = new nsTableRowGroupFrame(mContent, aParent); - PrepareContinuingFrame(aPresContext, aParent, cf); + if (nsnull == cf) { + return NS_ERROR_OUT_OF_MEMORY; + } + PrepareContinuingFrame(aPresContext, aParent, aStyleContext, cf); if (PR_TRUE==gsDebug1) printf("nsTableRowGroupFrame::CCF parent = %p, this=%p, cf=%p\n", aParent, this, cf); aContinuingFrame = cf; return NS_OK; diff --git a/mozilla/layout/html/table/src/nsTableRowGroupFrame.h b/mozilla/layout/html/table/src/nsTableRowGroupFrame.h index f215d4ad285..23edb9aca3c 100644 --- a/mozilla/layout/html/table/src/nsTableRowGroupFrame.h +++ b/mozilla/layout/html/table/src/nsTableRowGroupFrame.h @@ -85,9 +85,10 @@ public: ReflowStatus& aStatus); /** @see nsContainerFrame::CreateContinuingFrame */ - NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame); + NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame); /** returns the type of the mapped row group content in aType. * caller MUST call release on the returned object if it is not null. diff --git a/mozilla/layout/tables/nsTableCellFrame.cpp b/mozilla/layout/tables/nsTableCellFrame.cpp index c05c1a1a9ac..1597e13e1ba 100644 --- a/mozilla/layout/tables/nsTableCellFrame.cpp +++ b/mozilla/layout/tables/nsTableCellFrame.cpp @@ -194,7 +194,10 @@ void nsTableCellFrame::CreatePsuedoFrame(nsIPresContext* aPresContext) NS_ASSERTION(prevFrame->ChildIsPseudoFrame(prevPseudoFrame), "bad previous pseudo-frame"); // Create a continuing column - prevPseudoFrame->CreateContinuingFrame(aPresContext, this, mFirstChild); + nsIStyleContext* kidSC; + prevPseudoFrame->GetStyleContext(aPresContext, kidSC); + prevPseudoFrame->CreateContinuingFrame(aPresContext, this, kidSC, mFirstChild); + NS_RELEASE(kidSC); mChildCount = 1; } } @@ -334,12 +337,17 @@ NS_METHOD nsTableCellFrame::IncrementalReflow(nsIPresContext* aPresContext, return NS_OK; } -NS_METHOD nsTableCellFrame::CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame) +NS_METHOD +nsTableCellFrame::CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame) { nsTableCellFrame* cf = new nsTableCellFrame(mContent, aParent); - PrepareContinuingFrame(aPresContext, aParent, cf); + if (nsnull == cf) { + return NS_ERROR_OUT_OF_MEMORY; + } + PrepareContinuingFrame(aPresContext, aParent, aStyleContext, cf); aContinuingFrame = cf; return NS_OK; } diff --git a/mozilla/layout/tables/nsTableCellFrame.h b/mozilla/layout/tables/nsTableCellFrame.h index 7679dc2f272..fdcf1f63525 100644 --- a/mozilla/layout/tables/nsTableCellFrame.h +++ b/mozilla/layout/tables/nsTableCellFrame.h @@ -54,9 +54,10 @@ public: /** * @see nsContainerFrame */ - NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame); + NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame); void VerticallyAlignChild(nsIPresContext* aPresContext); diff --git a/mozilla/layout/tables/nsTableFrame.cpp b/mozilla/layout/tables/nsTableFrame.cpp index ed652616bd9..a90adf1d1b0 100644 --- a/mozilla/layout/tables/nsTableFrame.cpp +++ b/mozilla/layout/tables/nsTableFrame.cpp @@ -637,9 +637,9 @@ nsIFrame::ReflowStatus nsTableFrame::ResizeReflowPass1(nsIPresContext* aPresCont { nsIContentDelegate* kidDel; kidDel = kid->GetDelegate(aPresContext); - kidFrame = kidDel->CreateFrame(aPresContext, kid, this); + nsresult rv = kidDel->CreateFrame(aPresContext, kid, + this, kidStyleContext, kidFrame); NS_RELEASE(kidDel); - kidFrame->SetStyleContext(aPresContext,kidStyleContext); } nsSize maxKidElementSize; @@ -1058,7 +1058,10 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext* aPresContext, // frame. This hooks the child into the flow nsIFrame* continuingFrame; - kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame); + nsIStyleContext* kidSC; + kidFrame->GetStyleContext(aPresContext, kidSC); + kidFrame->CreateContinuingFrame(aPresContext, this, kidSC, continuingFrame); + NS_RELEASE(kidSC); NS_ASSERTION(nsnull != continuingFrame, "frame creation failed"); // Add the continuing frame to the sibling list @@ -1286,7 +1289,10 @@ PRBool nsTableFrame::PullUpChildren(nsIPresContext* aPresContext, // prepares it for reflow. nsIFrame* continuingFrame; - kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame); + nsIStyleContext* kidSC; + kidFrame->GetStyleContext(aPresContext, kidSC); + kidFrame->CreateContinuingFrame(aPresContext, this, kidSC, continuingFrame); + NS_RELEASE(kidSC); NS_ASSERTION(nsnull != continuingFrame, "frame creation failed"); // Add the continuing frame to our sibling list and then push @@ -1412,11 +1418,12 @@ nsTableFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext, if (nsnull == kidPrevInFlow) { nsIContentDelegate* kidDel = nsnull; kidDel = kid->GetDelegate(aPresContext); - kidFrame = kidDel->CreateFrame(aPresContext, kid, this); + nsresult rv = kidDel->CreateFrame(aPresContext, kid, this, + kidStyleContext, kidFrame); NS_RELEASE(kidDel); - kidFrame->SetStyleContext(aPresContext, kidStyleContext); } else { - kidPrevInFlow->CreateContinuingFrame(aPresContext, this, kidFrame); + kidPrevInFlow->CreateContinuingFrame(aPresContext, this, kidStyleContext, + kidFrame); } // Try to reflow the child into the available space. It might not @@ -2039,12 +2046,17 @@ PRBool nsTableFrame::IsFirstPassValid() const return firstInFlow->mFirstPassValid; } -NS_METHOD nsTableFrame::CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame) +NS_METHOD +nsTableFrame::CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame) { nsTableFrame* cf = new nsTableFrame(mContent, aParent); - PrepareContinuingFrame(aPresContext, aParent, cf); + if (nsnull == cf) { + return NS_ERROR_OUT_OF_MEMORY; + } + PrepareContinuingFrame(aPresContext, aParent, aStyleContext, cf); if (PR_TRUE==gsDebug) printf("nsTableFrame::CCF parent = %p, this=%p, cf=%p\n", aParent, this, cf); // set my width, because all frames in a table flow are the same width // code in nsTableOuterFrame depends on this being set @@ -2074,9 +2086,10 @@ NS_METHOD nsTableFrame::CreateContinuingFrame(nsIPresContext* aPresContext, aPresContext->ResolveStyleContextFor(content, cf); // kidStyleContext: REFCNT++ nsIContentDelegate* kidDel = nsnull; kidDel = content->GetDelegate(aPresContext); // kidDel: REFCNT++ - nsIFrame * duplicateFrame = kidDel->CreateFrame(aPresContext, content, cf); + nsIFrame* duplicateFrame; + nsresult rv = kidDel->CreateFrame(aPresContext, content, cf, + kidStyleContext, duplicateFrame); NS_RELEASE(kidDel); // kidDel: REFCNT-- - duplicateFrame->SetStyleContext(aPresContext,kidStyleContext); NS_RELEASE(kidStyleContext); // kidStyleContenxt: REFCNT-- if (nsnull==lastSib) diff --git a/mozilla/layout/tables/nsTableFrame.h b/mozilla/layout/tables/nsTableFrame.h index 62ce24bb1a9..88599c72f4f 100644 --- a/mozilla/layout/tables/nsTableFrame.h +++ b/mozilla/layout/tables/nsTableFrame.h @@ -95,9 +95,10 @@ public: ReflowStatus& aStatus); /** @see nsContainerFrame::CreateContinuingFrame */ - NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame); + NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame); /** resize myself and my children according to the arcane rules of cell height magic. * By default, the height of a cell is the max (height of cells in its row) diff --git a/mozilla/layout/tables/nsTableOuterFrame.cpp b/mozilla/layout/tables/nsTableOuterFrame.cpp index 3105384a307..84de6ac9b82 100644 --- a/mozilla/layout/tables/nsTableOuterFrame.cpp +++ b/mozilla/layout/tables/nsTableOuterFrame.cpp @@ -529,8 +529,11 @@ PRBool nsTableOuterFrame::ReflowMappedChildren( nsIPresContext* aPresContex // The child doesn't have a next-in-flow so create a continuing // frame. This hooks the child into the flow nsIFrame* continuingFrame; - - kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame); + nsIStyleContext* kidSC; + kidFrame->GetStyleContext(aPresContext, kidSC); + kidFrame->CreateContinuingFrame(aPresContext, this, kidSC, + continuingFrame); + NS_RELEASE(kidSC); NS_ASSERTION(nsnull != continuingFrame, "frame creation failed"); // Add the continuing frame to the sibling list @@ -764,8 +767,10 @@ PRBool nsTableOuterFrame::PullUpChildren( nsIPresContext* aPresContext, // continuing frame. The creation appends it to the flow and // prepares it for reflow. nsIFrame* continuingFrame; - - kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame); + nsIStyleContext* kidSC; + kidFrame->GetStyleContext(aPresContext, kidSC); + kidFrame->CreateContinuingFrame(aPresContext, this, kidSC, + continuingFrame); NS_ASSERTION(nsnull != continuingFrame, "frame creation failed"); // Add the continuing frame to our sibling list and then push @@ -1202,12 +1207,17 @@ nsTableOuterFrame::IncrementalReflow(nsIPresContext* aPresContext, return NS_OK; } -NS_METHOD nsTableOuterFrame::CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame) +NS_METHOD +nsTableOuterFrame::CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame) { nsTableOuterFrame* cf = new nsTableOuterFrame(mContent, aParent); - PrepareContinuingFrame(aPresContext, aParent, cf); + if (nsnull == cf) { + return NS_ERROR_OUT_OF_MEMORY; + } + PrepareContinuingFrame(aPresContext, aParent, aStyleContext, cf); cf->SetFirstPassValid(PR_TRUE); if (PR_TRUE==gsDebug) printf("nsTableOuterFrame::CCF parent = %p, this=%p, cf=%p\n", aParent, this, cf); @@ -1215,9 +1225,11 @@ NS_METHOD nsTableOuterFrame::CreateContinuingFrame(nsIPresContext* aPresContext, return NS_OK; } -void nsTableOuterFrame::PrepareContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsTableOuterFrame* aContFrame) +void +nsTableOuterFrame::PrepareContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsTableOuterFrame* aContFrame) { // Append the continuing frame to the flow aContFrame->AppendToFlow(this); @@ -1238,12 +1250,7 @@ void nsTableOuterFrame::PrepareContinuingFrame(nsIPresContext* aPresContext, aContFrame->SetFirstContentOffset(nextOffset); aContFrame->SetLastContentOffset(nextOffset); aContFrame->SetLastContentIsComplete(PR_TRUE); - - // Resolve style for the continuing frame and set its style context. - // XXX presumptive - nsIStyleContextPtr styleContext = - aPresContext->ResolveStyleContextFor(mContent, aParent); - aContFrame->SetStyleContext(aPresContext,styleContext); + aContFrame->SetStyleContext(aPresContext, aStyleContext); } NS_METHOD nsTableOuterFrame::VerifyTree() const @@ -1373,8 +1380,10 @@ void nsTableOuterFrame::CreateInnerTableFrame(nsIPresContext* aPresContext) if (nsnull==mInnerTableFrame) { nsIFrame* continuingFrame; - - prevInnerTable->CreateContinuingFrame(aPresContext, this, continuingFrame); + nsIStyleContext* kidSC; + prevInnerTable->GetStyleContext(aPresContext, kidSC); + prevInnerTable->CreateContinuingFrame(aPresContext, this, kidSC, + continuingFrame); mInnerTableFrame = (nsTableFrame*)continuingFrame; mChildCount++; } diff --git a/mozilla/layout/tables/nsTableOuterFrame.h b/mozilla/layout/tables/nsTableOuterFrame.h index 08d0c7ea89b..7cd0cea66a2 100644 --- a/mozilla/layout/tables/nsTableOuterFrame.h +++ b/mozilla/layout/tables/nsTableOuterFrame.h @@ -97,9 +97,10 @@ public: ReflowStatus& aStatus); /** @see nsContainerFrame */ - NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame); + NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame); /** destructor */ virtual ~nsTableOuterFrame(); @@ -206,9 +207,10 @@ protected: /** overridden here to handle special caption-table relationship * @see nsContainerFrame::PrepareContinuingFrame */ - virtual void PrepareContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsTableOuterFrame* aContFrame); + void PrepareContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsTableOuterFrame* aContFrame); /** * Remove and delete aChild's next-in-flow(s). Updates the sibling and flow diff --git a/mozilla/layout/tables/nsTableRowFrame.cpp b/mozilla/layout/tables/nsTableRowFrame.cpp index 23198d8279d..54e473ea82e 100644 --- a/mozilla/layout/tables/nsTableRowFrame.cpp +++ b/mozilla/layout/tables/nsTableRowFrame.cpp @@ -391,8 +391,11 @@ PRBool nsTableRowFrame::ReflowMappedChildren(nsIPresContext* aPresContext, // No the child isn't complete, and it doesn't have a next in flow so // create a continuing frame. This hooks the child into the flow. nsIFrame* continuingFrame; - - kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame); + nsIStyleContext* kidSC; + kidFrame->GetStyleContext(aPresContext, kidSC); + kidFrame->CreateContinuingFrame(aPresContext, this, kidSC, + continuingFrame); + NS_RELEASE(kidSC); // Insert the frame. We'll reflow it next pass through the loop nsIFrame* nextSib; @@ -654,8 +657,11 @@ PRBool nsTableRowFrame::PullUpChildren(nsIPresContext* aPresContext, // continuing frame. The creation appends it to the flow and // prepares it for reflow. nsIFrame* continuingFrame; - - kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame); + nsIStyleContext* kidSC; + kidFrame->GetStyleContext(aPresContext, kidSC); + kidFrame->CreateContinuingFrame(aPresContext, this, kidSC, + continuingFrame); + NS_RELEASE(kidSC); NS_ASSERTION(nsnull != continuingFrame, "frame creation failed"); // Add the continuing frame to our sibling list and then push @@ -808,11 +814,12 @@ nsTableRowFrame::ReflowUnmappedChildren( nsIPresContext* aPresContext, if (nsnull == kidPrevInFlow) { nsIContentDelegate* kidDel = nsnull; kidDel = cell->GetDelegate(aPresContext); - kidFrame = kidDel->CreateFrame(aPresContext, cell, this); + nsresult rv = kidDel->CreateFrame(aPresContext, cell, + this, kidStyleContext, kidFrame); NS_RELEASE(kidDel); - kidFrame->SetStyleContext(aPresContext,kidStyleContext); } else { - kidPrevInFlow->CreateContinuingFrame(aPresContext, this, kidFrame); + kidPrevInFlow->CreateContinuingFrame(aPresContext, this, + kidStyleContext, kidFrame); } NS_RELEASE(kidStyleContext); @@ -1030,13 +1037,18 @@ nsTableRowFrame::IncrementalReflow(nsIPresContext* aPresContext, return NS_OK; } -NS_METHOD nsTableRowFrame::CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame) +NS_METHOD +nsTableRowFrame::CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame) { if (gsDebug1==PR_TRUE) printf("nsTableRowFrame::CreateContinuingFrame\n"); nsTableRowFrame* cf = new nsTableRowFrame(mContent, aParent); - PrepareContinuingFrame(aPresContext, aParent, cf); + if (nsnull == cf) { + return NS_ERROR_OUT_OF_MEMORY; + } + PrepareContinuingFrame(aPresContext, aParent, aStyleContext, cf); aContinuingFrame = cf; return NS_OK; } diff --git a/mozilla/layout/tables/nsTableRowFrame.h b/mozilla/layout/tables/nsTableRowFrame.h index 77578e71066..e84cfb28d2f 100644 --- a/mozilla/layout/tables/nsTableRowFrame.h +++ b/mozilla/layout/tables/nsTableRowFrame.h @@ -91,9 +91,10 @@ public: ReflowStatus& aStatus); /** @see nsContainerFrame::CreateContinuingFrame */ - NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame); + NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame); /** set mTallestCell to 0 in anticipation of recalculating it */ void ResetMaxChildHeight(); diff --git a/mozilla/layout/tables/nsTableRowGroupFrame.cpp b/mozilla/layout/tables/nsTableRowGroupFrame.cpp index a92ca395f69..bc77cceed71 100644 --- a/mozilla/layout/tables/nsTableRowGroupFrame.cpp +++ b/mozilla/layout/tables/nsTableRowGroupFrame.cpp @@ -359,8 +359,11 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon // No the child isn't complete, and it doesn't have a next in flow so // create a continuing frame. This hooks the child into the flow. nsIFrame* continuingFrame; - - kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame); + nsIStyleContext* kidSC; + kidFrame->GetStyleContext(aPresContext, kidSC); + kidFrame->CreateContinuingFrame(aPresContext, this, kidSC, + continuingFrame); + NS_RELEASE(kidSC); // Insert the frame. We'll reflow it next pass through the loop nsIFrame* nextSib; @@ -587,8 +590,11 @@ PRBool nsTableRowGroupFrame::PullUpChildren(nsIPresContext* aPresContext, // continuing frame. The creation appends it to the flow and // prepares it for reflow. nsIFrame* continuingFrame; - - kidFrame->CreateContinuingFrame(aPresContext, this, continuingFrame); + nsIStyleContext* kidSC; + kidFrame->GetStyleContext(aPresContext, kidSC); + kidFrame->CreateContinuingFrame(aPresContext, this, kidSC, + continuingFrame); + NS_RELEASE(kidSC); NS_ASSERTION(nsnull != continuingFrame, "frame creation failed"); // Add the continuing frame to our sibling list and then push @@ -739,11 +745,12 @@ nsTableRowGroupFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext, if (nsnull == kidPrevInFlow) { nsIContentDelegate* kidDel = nsnull; kidDel = kid->GetDelegate(aPresContext); - kidFrame = kidDel->CreateFrame(aPresContext, kid, this); + nsresult rv = kidDel->CreateFrame(aPresContext, kid, this, kidSC, + kidFrame); NS_RELEASE(kidDel); - kidFrame->SetStyleContext(aPresContext,kidSC); } else { - kidPrevInFlow->CreateContinuingFrame(aPresContext, this, kidFrame); + kidPrevInFlow->CreateContinuingFrame(aPresContext, this, kidSC, + kidFrame); } // Try to reflow the child into the available space. It might not @@ -922,12 +929,17 @@ nsTableRowGroupFrame::IncrementalReflow(nsIPresContext* aPresContext, return NS_OK; } -NS_METHOD nsTableRowGroupFrame::CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame) +NS_METHOD +nsTableRowGroupFrame::CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame) { nsTableRowGroupFrame* cf = new nsTableRowGroupFrame(mContent, aParent); - PrepareContinuingFrame(aPresContext, aParent, cf); + if (nsnull == cf) { + return NS_ERROR_OUT_OF_MEMORY; + } + PrepareContinuingFrame(aPresContext, aParent, aStyleContext, cf); if (PR_TRUE==gsDebug1) printf("nsTableRowGroupFrame::CCF parent = %p, this=%p, cf=%p\n", aParent, this, cf); aContinuingFrame = cf; return NS_OK; diff --git a/mozilla/layout/tables/nsTableRowGroupFrame.h b/mozilla/layout/tables/nsTableRowGroupFrame.h index f215d4ad285..23edb9aca3c 100644 --- a/mozilla/layout/tables/nsTableRowGroupFrame.h +++ b/mozilla/layout/tables/nsTableRowGroupFrame.h @@ -85,9 +85,10 @@ public: ReflowStatus& aStatus); /** @see nsContainerFrame::CreateContinuingFrame */ - NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, - nsIFrame* aParent, - nsIFrame*& aContinuingFrame); + NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, + nsIFrame* aParent, + nsIStyleContext* aStyleContext, + nsIFrame*& aContinuingFrame); /** returns the type of the mapped row group content in aType. * caller MUST call release on the returned object if it is not null.