diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index bbbe52cf0be..6a806bbfea9 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -2370,19 +2370,24 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresShell* aPresShell, view->GetViewFlags(&viewFlags); view->SetViewFlags(viewFlags | NS_VIEW_PUBLIC_FLAG_DONT_BITBLT); } - + // Set the initial child lists contentFrame->SetInitialChildList(aPresContext, nsnull, - childItems.childList); - if (aState.mAbsoluteItems.childList) { - contentFrame->SetInitialChildList(aPresContext, - nsLayoutAtoms::absoluteList, - aState.mAbsoluteItems.childList); - } - if (aState.mFloatedItems.childList) { - contentFrame->SetInitialChildList(aPresContext, - nsLayoutAtoms::floaterList, - aState.mFloatedItems.childList); + childItems.childList); + + // only support absolute positioning if we are a block. + // if we are a box don't do it. + if (isBlockFrame) { + if (aState.mAbsoluteItems.childList) { + contentFrame->SetInitialChildList(aPresContext, + nsLayoutAtoms::absoluteList, + aState.mAbsoluteItems.childList); + } + if (aState.mFloatedItems.childList) { + contentFrame->SetInitialChildList(aPresContext, + nsLayoutAtoms::floaterList, + aState.mFloatedItems.childList); + } } } @@ -3357,15 +3362,21 @@ nsCSSFrameConstructor::ConstructFieldSetFrame(nsIPresShell* aPresShell, // cache our display type const nsStyleDisplay* styleDisplay; newFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) styleDisplay); - + + /* PRUint32 childFlags = (NS_STYLE_DISPLAY_BLOCK != styleDisplay->mDisplay) ? NS_BLOCK_SHRINK_WRAP : 0; // inherit the FieldSet state PRUint32 parentState; newFrame->GetFrameState( &parentState ); childFlags |= parentState; + childFlags |= NS_BLOCK_SHRINK_WRAP; +*/ nsIFrame * areaFrame; - NS_NewAreaFrame(shell, &areaFrame, childFlags); +// NS_NewAreaFrame(shell, &areaFrame, childFlags); + + + NS_NewBlockFrame(shell, &areaFrame); // Resolve style and initialize the frame nsIStyleContext* styleContext; @@ -4370,10 +4381,14 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, newFrame->SetFrameState(state | NS_FRAME_REPLACED_ELEMENT); } + // xul does not support absolute positioning + nsIFrame* geometricParent = aParentFrame; + + /* nsIFrame* geometricParent = isAbsolutelyPositioned ? aState.mAbsoluteItems.containingBlock : aParentFrame; - + */ // if the new frame was already initialized to initialize it again. if (!frameHasBeenInitialized) { diff --git a/mozilla/layout/forms/nsFieldSetFrame.cpp b/mozilla/layout/forms/nsFieldSetFrame.cpp index d3b7ccb09bc..eac7473c8c9 100644 --- a/mozilla/layout/forms/nsFieldSetFrame.cpp +++ b/mozilla/layout/forms/nsFieldSetFrame.cpp @@ -336,7 +336,9 @@ nsFieldSetFrame::Reflow(nsIPresContext* aPresContext, legendReflowState.mComputedHeight = NS_INTRINSICSIZE; legendReflowState.reason = reason; - ReflowChild(mLegendFrame, aPresContext, aDesiredSize, legendReflowState, + nsHTMLReflowMetrics legendDesiredSize(0,0); + + ReflowChild(mLegendFrame, aPresContext, legendDesiredSize, legendReflowState, 0, 0, NS_FRAME_NO_MOVE_FRAME, aStatus); // get the legend's margin @@ -347,8 +349,8 @@ nsFieldSetFrame::Reflow(nsIPresContext* aPresContext, legendSpacing->GetMargin(legendMargin); // figure out the legend's rectangle - mLegendRect.width = aDesiredSize.width + legendMargin.left + legendMargin.right; - mLegendRect.height = aDesiredSize.height + legendMargin.top + legendMargin.bottom; + mLegendRect.width = legendDesiredSize.width + legendMargin.left + legendMargin.right; + mLegendRect.height = legendDesiredSize.height + legendMargin.top + legendMargin.bottom; mLegendRect.x = borderPadding.left; mLegendRect.y = 0; @@ -382,7 +384,7 @@ nsFieldSetFrame::Reflow(nsIPresContext* aPresContext, availSize.width = mLegendRect.width; } - FinishReflowChild(mLegendFrame, aPresContext, aDesiredSize, 0, 0, NS_FRAME_NO_MOVE_FRAME); + FinishReflowChild(mLegendFrame, aPresContext, legendDesiredSize, 0, 0, NS_FRAME_NO_MOVE_FRAME); } } @@ -405,11 +407,15 @@ nsFieldSetFrame::Reflow(nsIPresContext* aPresContext, kidReflowState.reason = reason; + nsHTMLReflowMetrics kidDesiredSize(0,0); + + // Reflow the frame - ReflowChild(mContentFrame, aPresContext, aDesiredSize, kidReflowState, + ReflowChild(mContentFrame, aPresContext, kidDesiredSize, kidReflowState, kidReflowState.mComputedMargin.left, kidReflowState.mComputedMargin.top, 0, aStatus); + /* printf("*** %p computedHgt: %d ", this, aReflowState.mComputedHeight); printf("Reason: "); switch (aReflowState.reason) { @@ -418,27 +424,30 @@ nsFieldSetFrame::Reflow(nsIPresContext* aPresContext, case eReflowReason_Resize: printf("Resize"); break; case eReflowReason_StyleChange:printf("eReflowReason_StyleChange");break; } + */ // set the rect. make sure we add the margin back in. - contentRect.SetRect(borderPadding.left,borderPadding.top + mLegendSpace,aDesiredSize.width ,aDesiredSize.height); + contentRect.SetRect(borderPadding.left,borderPadding.top + mLegendSpace,kidDesiredSize.width ,kidDesiredSize.height); if (aReflowState.mComputedHeight != NS_INTRINSICSIZE && - borderPadding.top + mLegendSpace+aDesiredSize.height > aReflowState.mComputedHeight) { - aDesiredSize.height = aReflowState.mComputedHeight-(borderPadding.top + mLegendSpace); - printf(" areaHgt: %d", aDesiredSize.height); + borderPadding.top + mLegendSpace+kidDesiredSize.height > aReflowState.mComputedHeight) { + kidDesiredSize.height = aReflowState.mComputedHeight-(borderPadding.top + mLegendSpace); + printf(" areaHgt: %d", kidDesiredSize.height); } - FinishReflowChild(mContentFrame, aPresContext, aDesiredSize, contentRect.x, contentRect.y, 0); + FinishReflowChild(mContentFrame, aPresContext, kidDesiredSize, contentRect.x, contentRect.y, 0); nsFrameState kidState; mContentFrame->GetFrameState(&kidState); // printf("width: %d, height: %d\n", desiredSize.mCombinedArea.width, desiredSize.mCombinedArea.height); + /* if (kidState & NS_FRAME_OUTSIDE_CHILDREN) { mState |= NS_FRAME_OUTSIDE_CHILDREN; aDesiredSize.mOverflowArea.width += borderPadding.left + borderPadding.right; aDesiredSize.mOverflowArea.height += borderPadding.top + borderPadding.bottom + mLegendSpace; } + */ NS_FRAME_TRACE_REFLOW_OUT("FieldSet::Reflow", aStatus); @@ -496,7 +505,7 @@ nsFieldSetFrame::Reflow(nsIPresContext* aPresContext, if (aReflowState.mComputedHeight == NS_INTRINSICSIZE) { aDesiredSize.height = mLegendSpace + borderPadding.top + - aDesiredSize.height + + contentRect.height + borderPadding.bottom; } else { nscoord min = borderPadding.top + borderPadding.bottom + mLegendRect.height; @@ -507,7 +516,7 @@ nsFieldSetFrame::Reflow(nsIPresContext* aPresContext, if (aReflowState.mComputedWidth == NS_INTRINSICSIZE) { aDesiredSize.width = borderPadding.left + - aDesiredSize.width + + contentRect.width + borderPadding.right; } else { nscoord min = borderPadding.left + borderPadding.right + mLegendRect.width; diff --git a/mozilla/layout/forms/nsFormControlHelper.cpp b/mozilla/layout/forms/nsFormControlHelper.cpp index dc24f6195e7..7bc27e8a0f1 100644 --- a/mozilla/layout/forms/nsFormControlHelper.cpp +++ b/mozilla/layout/forms/nsFormControlHelper.cpp @@ -84,6 +84,7 @@ nsFormControlHelper::~nsFormControlHelper() void nsFormControlHelper::ForceDrawFrame(nsIPresContext* aPresContext, nsIFrame * aFrame) { + if (aFrame == nsnull) { return; } @@ -98,10 +99,11 @@ void nsFormControlHelper::ForceDrawFrame(nsIPresContext* aPresContext, nsIFrame nsIViewManager * viewMgr; view->GetViewManager(viewMgr); if (viewMgr != nsnull) { - viewMgr->UpdateView(view, rect, 0); + viewMgr->UpdateView(view, rect, NS_VMREFRESH_NO_SYNC); NS_RELEASE(viewMgr); } } + } PRBool nsFormControlHelper::GetBool(const nsString& aValue) diff --git a/mozilla/layout/generic/nsGfxScrollFrame.cpp b/mozilla/layout/generic/nsGfxScrollFrame.cpp index ed1f1b29a8b..fadefaf3ac6 100644 --- a/mozilla/layout/generic/nsGfxScrollFrame.cpp +++ b/mozilla/layout/generic/nsGfxScrollFrame.cpp @@ -235,6 +235,7 @@ public: PRBool mHasHorizontalScrollbar; PRBool mFirstPass; PRBool mIsRoot; + PRBool mNeverReflowed; }; NS_IMPL_ISUPPORTS2(nsGfxScrollFrameInner, nsIDocumentObserver, nsIScrollPositionListener) @@ -261,6 +262,7 @@ nsGfxScrollFrame::nsGfxScrollFrame(nsIDocument* aDocument) mInner->mDocument = aDocument; mPresContext = nsnull; mInner->mIsRoot = PR_FALSE; + mInner->mNeverReflowed = PR_TRUE; } nsGfxScrollFrame::~nsGfxScrollFrame() @@ -491,10 +493,11 @@ nsGfxScrollFrame::Reflow(nsIPresContext* aPresContext, // Handle Incremental Reflow nsIFrame* incrementalChild = nsnull; - if ( aReflowState.reason == eReflowReason_Initial) { + if (mInner->mNeverReflowed) { // on the initial reflow see if we are the root box. // the root box. mInner->mIsRoot = PR_TRUE; + mInner->mNeverReflowed = PR_FALSE; // see if we are the root box nsIFrame* parent = mParent; @@ -507,7 +510,9 @@ nsGfxScrollFrame::Reflow(nsIPresContext* aPresContext, parent->GetParent(&parent); } - } else if ( aReflowState.reason == eReflowReason_Incremental ) { + } + + if ( aReflowState.reason == eReflowReason_Incremental ) { nsIReflowCommand::ReflowType reflowType; aReflowState.reflowCommand->GetType(reflowType); diff --git a/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp b/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp index ed1f1b29a8b..fadefaf3ac6 100644 --- a/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp +++ b/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp @@ -235,6 +235,7 @@ public: PRBool mHasHorizontalScrollbar; PRBool mFirstPass; PRBool mIsRoot; + PRBool mNeverReflowed; }; NS_IMPL_ISUPPORTS2(nsGfxScrollFrameInner, nsIDocumentObserver, nsIScrollPositionListener) @@ -261,6 +262,7 @@ nsGfxScrollFrame::nsGfxScrollFrame(nsIDocument* aDocument) mInner->mDocument = aDocument; mPresContext = nsnull; mInner->mIsRoot = PR_FALSE; + mInner->mNeverReflowed = PR_TRUE; } nsGfxScrollFrame::~nsGfxScrollFrame() @@ -491,10 +493,11 @@ nsGfxScrollFrame::Reflow(nsIPresContext* aPresContext, // Handle Incremental Reflow nsIFrame* incrementalChild = nsnull; - if ( aReflowState.reason == eReflowReason_Initial) { + if (mInner->mNeverReflowed) { // on the initial reflow see if we are the root box. // the root box. mInner->mIsRoot = PR_TRUE; + mInner->mNeverReflowed = PR_FALSE; // see if we are the root box nsIFrame* parent = mParent; @@ -507,7 +510,9 @@ nsGfxScrollFrame::Reflow(nsIPresContext* aPresContext, parent->GetParent(&parent); } - } else if ( aReflowState.reason == eReflowReason_Incremental ) { + } + + if ( aReflowState.reason == eReflowReason_Incremental ) { nsIReflowCommand::ReflowType reflowType; aReflowState.reflowCommand->GetType(reflowType); diff --git a/mozilla/layout/html/forms/src/nsFieldSetFrame.cpp b/mozilla/layout/html/forms/src/nsFieldSetFrame.cpp index d3b7ccb09bc..eac7473c8c9 100644 --- a/mozilla/layout/html/forms/src/nsFieldSetFrame.cpp +++ b/mozilla/layout/html/forms/src/nsFieldSetFrame.cpp @@ -336,7 +336,9 @@ nsFieldSetFrame::Reflow(nsIPresContext* aPresContext, legendReflowState.mComputedHeight = NS_INTRINSICSIZE; legendReflowState.reason = reason; - ReflowChild(mLegendFrame, aPresContext, aDesiredSize, legendReflowState, + nsHTMLReflowMetrics legendDesiredSize(0,0); + + ReflowChild(mLegendFrame, aPresContext, legendDesiredSize, legendReflowState, 0, 0, NS_FRAME_NO_MOVE_FRAME, aStatus); // get the legend's margin @@ -347,8 +349,8 @@ nsFieldSetFrame::Reflow(nsIPresContext* aPresContext, legendSpacing->GetMargin(legendMargin); // figure out the legend's rectangle - mLegendRect.width = aDesiredSize.width + legendMargin.left + legendMargin.right; - mLegendRect.height = aDesiredSize.height + legendMargin.top + legendMargin.bottom; + mLegendRect.width = legendDesiredSize.width + legendMargin.left + legendMargin.right; + mLegendRect.height = legendDesiredSize.height + legendMargin.top + legendMargin.bottom; mLegendRect.x = borderPadding.left; mLegendRect.y = 0; @@ -382,7 +384,7 @@ nsFieldSetFrame::Reflow(nsIPresContext* aPresContext, availSize.width = mLegendRect.width; } - FinishReflowChild(mLegendFrame, aPresContext, aDesiredSize, 0, 0, NS_FRAME_NO_MOVE_FRAME); + FinishReflowChild(mLegendFrame, aPresContext, legendDesiredSize, 0, 0, NS_FRAME_NO_MOVE_FRAME); } } @@ -405,11 +407,15 @@ nsFieldSetFrame::Reflow(nsIPresContext* aPresContext, kidReflowState.reason = reason; + nsHTMLReflowMetrics kidDesiredSize(0,0); + + // Reflow the frame - ReflowChild(mContentFrame, aPresContext, aDesiredSize, kidReflowState, + ReflowChild(mContentFrame, aPresContext, kidDesiredSize, kidReflowState, kidReflowState.mComputedMargin.left, kidReflowState.mComputedMargin.top, 0, aStatus); + /* printf("*** %p computedHgt: %d ", this, aReflowState.mComputedHeight); printf("Reason: "); switch (aReflowState.reason) { @@ -418,27 +424,30 @@ nsFieldSetFrame::Reflow(nsIPresContext* aPresContext, case eReflowReason_Resize: printf("Resize"); break; case eReflowReason_StyleChange:printf("eReflowReason_StyleChange");break; } + */ // set the rect. make sure we add the margin back in. - contentRect.SetRect(borderPadding.left,borderPadding.top + mLegendSpace,aDesiredSize.width ,aDesiredSize.height); + contentRect.SetRect(borderPadding.left,borderPadding.top + mLegendSpace,kidDesiredSize.width ,kidDesiredSize.height); if (aReflowState.mComputedHeight != NS_INTRINSICSIZE && - borderPadding.top + mLegendSpace+aDesiredSize.height > aReflowState.mComputedHeight) { - aDesiredSize.height = aReflowState.mComputedHeight-(borderPadding.top + mLegendSpace); - printf(" areaHgt: %d", aDesiredSize.height); + borderPadding.top + mLegendSpace+kidDesiredSize.height > aReflowState.mComputedHeight) { + kidDesiredSize.height = aReflowState.mComputedHeight-(borderPadding.top + mLegendSpace); + printf(" areaHgt: %d", kidDesiredSize.height); } - FinishReflowChild(mContentFrame, aPresContext, aDesiredSize, contentRect.x, contentRect.y, 0); + FinishReflowChild(mContentFrame, aPresContext, kidDesiredSize, contentRect.x, contentRect.y, 0); nsFrameState kidState; mContentFrame->GetFrameState(&kidState); // printf("width: %d, height: %d\n", desiredSize.mCombinedArea.width, desiredSize.mCombinedArea.height); + /* if (kidState & NS_FRAME_OUTSIDE_CHILDREN) { mState |= NS_FRAME_OUTSIDE_CHILDREN; aDesiredSize.mOverflowArea.width += borderPadding.left + borderPadding.right; aDesiredSize.mOverflowArea.height += borderPadding.top + borderPadding.bottom + mLegendSpace; } + */ NS_FRAME_TRACE_REFLOW_OUT("FieldSet::Reflow", aStatus); @@ -496,7 +505,7 @@ nsFieldSetFrame::Reflow(nsIPresContext* aPresContext, if (aReflowState.mComputedHeight == NS_INTRINSICSIZE) { aDesiredSize.height = mLegendSpace + borderPadding.top + - aDesiredSize.height + + contentRect.height + borderPadding.bottom; } else { nscoord min = borderPadding.top + borderPadding.bottom + mLegendRect.height; @@ -507,7 +516,7 @@ nsFieldSetFrame::Reflow(nsIPresContext* aPresContext, if (aReflowState.mComputedWidth == NS_INTRINSICSIZE) { aDesiredSize.width = borderPadding.left + - aDesiredSize.width + + contentRect.width + borderPadding.right; } else { nscoord min = borderPadding.left + borderPadding.right + mLegendRect.width; diff --git a/mozilla/layout/html/forms/src/nsFormControlHelper.cpp b/mozilla/layout/html/forms/src/nsFormControlHelper.cpp index dc24f6195e7..7bc27e8a0f1 100644 --- a/mozilla/layout/html/forms/src/nsFormControlHelper.cpp +++ b/mozilla/layout/html/forms/src/nsFormControlHelper.cpp @@ -84,6 +84,7 @@ nsFormControlHelper::~nsFormControlHelper() void nsFormControlHelper::ForceDrawFrame(nsIPresContext* aPresContext, nsIFrame * aFrame) { + if (aFrame == nsnull) { return; } @@ -98,10 +99,11 @@ void nsFormControlHelper::ForceDrawFrame(nsIPresContext* aPresContext, nsIFrame nsIViewManager * viewMgr; view->GetViewManager(viewMgr); if (viewMgr != nsnull) { - viewMgr->UpdateView(view, rect, 0); + viewMgr->UpdateView(view, rect, NS_VMREFRESH_NO_SYNC); NS_RELEASE(viewMgr); } } + } PRBool nsFormControlHelper::GetBool(const nsString& aValue) diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp index bbbe52cf0be..6a806bbfea9 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -2370,19 +2370,24 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresShell* aPresShell, view->GetViewFlags(&viewFlags); view->SetViewFlags(viewFlags | NS_VIEW_PUBLIC_FLAG_DONT_BITBLT); } - + // Set the initial child lists contentFrame->SetInitialChildList(aPresContext, nsnull, - childItems.childList); - if (aState.mAbsoluteItems.childList) { - contentFrame->SetInitialChildList(aPresContext, - nsLayoutAtoms::absoluteList, - aState.mAbsoluteItems.childList); - } - if (aState.mFloatedItems.childList) { - contentFrame->SetInitialChildList(aPresContext, - nsLayoutAtoms::floaterList, - aState.mFloatedItems.childList); + childItems.childList); + + // only support absolute positioning if we are a block. + // if we are a box don't do it. + if (isBlockFrame) { + if (aState.mAbsoluteItems.childList) { + contentFrame->SetInitialChildList(aPresContext, + nsLayoutAtoms::absoluteList, + aState.mAbsoluteItems.childList); + } + if (aState.mFloatedItems.childList) { + contentFrame->SetInitialChildList(aPresContext, + nsLayoutAtoms::floaterList, + aState.mFloatedItems.childList); + } } } @@ -3357,15 +3362,21 @@ nsCSSFrameConstructor::ConstructFieldSetFrame(nsIPresShell* aPresShell, // cache our display type const nsStyleDisplay* styleDisplay; newFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) styleDisplay); - + + /* PRUint32 childFlags = (NS_STYLE_DISPLAY_BLOCK != styleDisplay->mDisplay) ? NS_BLOCK_SHRINK_WRAP : 0; // inherit the FieldSet state PRUint32 parentState; newFrame->GetFrameState( &parentState ); childFlags |= parentState; + childFlags |= NS_BLOCK_SHRINK_WRAP; +*/ nsIFrame * areaFrame; - NS_NewAreaFrame(shell, &areaFrame, childFlags); +// NS_NewAreaFrame(shell, &areaFrame, childFlags); + + + NS_NewBlockFrame(shell, &areaFrame); // Resolve style and initialize the frame nsIStyleContext* styleContext; @@ -4370,10 +4381,14 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, newFrame->SetFrameState(state | NS_FRAME_REPLACED_ELEMENT); } + // xul does not support absolute positioning + nsIFrame* geometricParent = aParentFrame; + + /* nsIFrame* geometricParent = isAbsolutelyPositioned ? aState.mAbsoluteItems.containingBlock : aParentFrame; - + */ // if the new frame was already initialized to initialize it again. if (!frameHasBeenInitialized) { diff --git a/mozilla/layout/xul/base/src/nsBoxFrame.cpp b/mozilla/layout/xul/base/src/nsBoxFrame.cpp index a86c4a852b0..9f8f71ee276 100644 --- a/mozilla/layout/xul/base/src/nsBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsBoxFrame.cpp @@ -236,6 +236,7 @@ public: // make these flags! PRBool mHorizontal; PRBool mIsRoot; + PRBool mNeverReflowed; Valignment mValign; Halignment mHalign; @@ -277,6 +278,7 @@ nsBoxFrame::nsBoxFrame() // if not otherwise specified boxes by default are horizontal. mInner->mHorizontal = PR_TRUE; mInner->mIsRoot = PR_FALSE; + mInner->mNeverReflowed = PR_TRUE; mInner->mValign = nsBoxFrameInner::vAlign_Default; mInner->mHalign = nsBoxFrameInner::hAlign_Default; @@ -631,7 +633,10 @@ nsBoxFrame::GetChildBoxInfo(nsIPresContext* aPresContext, const nsHTMLReflowStat nsString reason("To get pref size"); nsHTMLReflowState state(aReflowState); - state.reason = eReflowReason_Initial; + state.availableWidth = NS_INTRINSICSIZE; + state.availableHeight = NS_INTRINSICSIZE; + state.reason = eReflowReason_Resize; + nsIFrame* incrementalChild = nsnull; mInner->FlowChildAt(aFrame, aPresContext, desiredSize, state, status, aSize, 0, 0, PR_FALSE, incrementalChild, redraw, reason); @@ -759,10 +764,11 @@ nsBoxFrame::Reflow(nsIPresContext* aPresContext, //--------------------------------------------------------- nsIFrame* incrementalChild = nsnull; - if ( aReflowState.reason == eReflowReason_Initial) { + if (mInner->mNeverReflowed) { // on the initial reflow see if we are the root box. // the root box. mInner->mIsRoot = PR_TRUE; + mInner->mNeverReflowed = PR_FALSE; // see if we are the root box nsIFrame* parent = mParent; @@ -775,9 +781,10 @@ nsBoxFrame::Reflow(nsIPresContext* aPresContext, parent->GetParent(&parent); } if (mInner->mIsRoot) - printf("--------INITIAL REFLOW--------\n"); - - } else if ( aReflowState.reason == eReflowReason_Incremental ) { + printf("-------- BOX IS ROOT --------\n"); + } + + if ( aReflowState.reason == eReflowReason_Incremental ) { nsIReflowCommand::ReflowType reflowType; aReflowState.reflowCommand->GetType(reflowType); @@ -1567,6 +1574,13 @@ nsBoxFrameInner::FlowChildAt(nsIFrame* childFrame, PRBool needsReflow = PR_FALSE; nsReflowReason reason = aReflowState.reason; + if (aInfo.neverReflowed) { + NS_ASSERTION(reason != eReflowReason_Incremental,"Error should not be incremental!!"); + reason = eReflowReason_Initial; + } else if (reason == eReflowReason_Initial) { + reason = eReflowReason_Resize; + } + switch(reason) { // if the child we are reflowing is the child we popped off the incremental @@ -1622,31 +1636,38 @@ nsBoxFrameInner::FlowChildAt(nsIFrame* childFrame, // if we don't need a reflow then // lets see if we are already that size. Yes? then don't even reflow. We are done. - if (!needsReflow && aInfo.calculatedSize.width != NS_INTRINSICSIZE && aInfo.calculatedSize.height != NS_INTRINSICSIZE) { + if (!needsReflow) { - // if the new calculated size has a 0 width or a 0 height - if ((currentRect.width == 0 || currentRect.height == 0) && (aInfo.calculatedSize.width == 0 || aInfo.calculatedSize.height == 0)) { - needsReflow = PR_FALSE; - desiredSize.width = aInfo.calculatedSize.width - (margin.left + margin.right); - desiredSize.height = aInfo.calculatedSize.height - (margin.top + margin.bottom); - childFrame->SizeTo(aPresContext, desiredSize.width, desiredSize.height); - } else { - desiredSize.width = currentRect.width; - desiredSize.height = currentRect.height; + if (aInfo.calculatedSize.width != NS_INTRINSICSIZE && aInfo.calculatedSize.height != NS_INTRINSICSIZE) { + + // if the new calculated size has a 0 width or a 0 height + if ((currentRect.width == 0 || currentRect.height == 0) && (aInfo.calculatedSize.width == 0 || aInfo.calculatedSize.height == 0)) { + needsReflow = PR_FALSE; + desiredSize.width = aInfo.calculatedSize.width - (margin.left + margin.right); + desiredSize.height = aInfo.calculatedSize.height - (margin.top + margin.bottom); + childFrame->SizeTo(aPresContext, desiredSize.width, desiredSize.height); + } else { + desiredSize.width = currentRect.width; + desiredSize.height = currentRect.height; - // remove the margin. The rect of our child does not include it but our calculated size does. - nscoord calcWidth = aInfo.calculatedSize.width - (margin.left + margin.right); - nscoord calcHeight = aInfo.calculatedSize.height - (margin.top + margin.bottom); + // remove the margin. The rect of our child does not include it but our calculated size does. + nscoord calcWidth = aInfo.calculatedSize.width - (margin.left + margin.right); + nscoord calcHeight = aInfo.calculatedSize.height - (margin.top + margin.bottom); - // don't reflow if we are already the right size - if (currentRect.width == calcWidth && currentRect.height == calcHeight) - needsReflow = PR_FALSE; - else - needsReflow = PR_TRUE; + // don't reflow if we are already the right size + if (currentRect.width == calcWidth && currentRect.height == calcHeight) + needsReflow = PR_FALSE; + else + needsReflow = PR_TRUE; + } + } else { + // if the width or height are intrinsic alway reflow because + // we don't know what it should be. + needsReflow = PR_TRUE; } - } - + } + // ok now reflow the child into the springs calculated space if (needsReflow) { @@ -1763,6 +1784,7 @@ nsBoxFrameInner::FlowChildAt(nsIFrame* childFrame, } childFrame->Reflow(aPresContext, desiredSize, reflowState, aStatus); + aInfo.neverReflowed = PR_FALSE; NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status"); @@ -2364,6 +2386,9 @@ nsBoxFrame::AttributeChanged(nsIPresContext* aPresContext, NS_IMETHODIMP nsBoxFrame::GetBoxInfo(nsIPresContext* aPresContext, const nsHTMLReflowState& aReflowState, nsBoxInfo& aSize) { + nsMargin debugInset(0,0,0,0); + mInner->GetDebugInset(debugInset); + nsresult rv; aSize.Clear(); @@ -2392,6 +2417,14 @@ nsBoxFrame::GetBoxInfo(nsIPresContext* aPresContext, const nsHTMLReflowState& aR // get the size of the child. This is the min, max, preferred, and spring constant // it does not include its border. rv = GetChildBoxInfo(aPresContext, aReflowState, info->frame, *info); + + // make sure we can see the debug info + if (info->prefSize.width < debugInset.left) + info->prefSize.width = debugInset.left; + + if (info->prefSize.height < debugInset.top) + info->prefSize.height = debugInset.top; + NS_ASSERTION(rv == NS_OK,"failed to child box info"); if (NS_FAILED(rv)) return rv; @@ -2441,8 +2474,6 @@ nsBoxFrame::GetBoxInfo(nsIPresContext* aPresContext, const nsHTMLReflowState& aR nsMargin inset(0,0,0,0); GetInset(inset); - nsMargin debugInset(0,0,0,0); - mInner->GetDebugInset(debugInset); inset += debugInset; nsSize in(inset.left+inset.right,inset.top+inset.bottom); @@ -2801,6 +2832,7 @@ nsCalculatedBoxInfoImpl::nsCalculatedBoxInfoImpl(nsIFrame* aFrame) prefWidthIntrinsic = PR_TRUE; prefHeightIntrinsic = PR_TRUE; needsRecalc = PR_TRUE; + neverReflowed = PR_TRUE; } nsCalculatedBoxInfoImpl::~nsCalculatedBoxInfoImpl() diff --git a/mozilla/layout/xul/base/src/nsBoxFrame.h b/mozilla/layout/xul/base/src/nsBoxFrame.h index 04ee2e84752..55527265254 100644 --- a/mozilla/layout/xul/base/src/nsBoxFrame.h +++ b/mozilla/layout/xul/base/src/nsBoxFrame.h @@ -51,6 +51,7 @@ public: nsIFrame* frame; PRBool prefWidthIntrinsic; PRBool prefHeightIntrinsic; + PRBool neverReflowed; }; class nsInfoList