diff --git a/mozilla/content/html/content/src/nsHTMLAtoms.cpp b/mozilla/content/html/content/src/nsHTMLAtoms.cpp index 15a5ee9687b..664697ff836 100644 --- a/mozilla/content/html/content/src/nsHTMLAtoms.cpp +++ b/mozilla/content/html/content/src/nsHTMLAtoms.cpp @@ -101,6 +101,7 @@ nsIAtom* nsHTMLAtoms::h6; nsIAtom* nsHTMLAtoms::headers; nsIAtom* nsHTMLAtoms::height; nsIAtom* nsHTMLAtoms::hidden; +nsIAtom* nsHTMLAtoms::horizontalFramesetBorderPseudo; nsIAtom* nsHTMLAtoms::hover; nsIAtom* nsHTMLAtoms::hr; nsIAtom* nsHTMLAtoms::href; @@ -217,6 +218,7 @@ nsIAtom* nsHTMLAtoms::value; nsIAtom* nsHTMLAtoms::valuetype; nsIAtom* nsHTMLAtoms::variable; nsIAtom* nsHTMLAtoms::version; +nsIAtom* nsHTMLAtoms::verticalFramesetBorderPseudo; nsIAtom* nsHTMLAtoms::visibility; nsIAtom* nsHTMLAtoms::visited; nsIAtom* nsHTMLAtoms::vlink; @@ -314,6 +316,7 @@ void nsHTMLAtoms::AddrefAtoms() headers = NS_NewAtom("HEADERS"); height = NS_NewAtom("HEIGHT"); hidden = NS_NewAtom("HIDDEN"); + horizontalFramesetBorderPseudo = NS_NewAtom("HFRAMESETBORDER"); hover = NS_NewAtom("HOVER"); hr = NS_NewAtom("HR"); href = NS_NewAtom("HREF"); @@ -429,6 +432,7 @@ void nsHTMLAtoms::AddrefAtoms() valuetype = NS_NewAtom("VALUETYPE"); variable = NS_NewAtom("VARIABLE"); version = NS_NewAtom("VERSION"); + verticalFramesetBorderPseudo = NS_NewAtom("VFRAMESETBORDER"); visibility = NS_NewAtom("VISIBILITY"); visited = NS_NewAtom("VISITED"); vlink = NS_NewAtom("VLINK"); @@ -521,6 +525,7 @@ void nsHTMLAtoms::ReleaseAtoms() NS_RELEASE(headers); NS_RELEASE(height); NS_RELEASE(hidden); + NS_RELEASE(horizontalFramesetBorderPseudo); NS_RELEASE(hover); NS_RELEASE(hr); NS_RELEASE(href); @@ -632,6 +637,7 @@ void nsHTMLAtoms::ReleaseAtoms() NS_RELEASE(valuetype); NS_RELEASE(variable); NS_RELEASE(version); + NS_RELEASE(verticalFramesetBorderPseudo); NS_RELEASE(visibility); NS_RELEASE(visited); NS_RELEASE(vlink); diff --git a/mozilla/content/html/content/src/nsHTMLAtoms.h b/mozilla/content/html/content/src/nsHTMLAtoms.h index c65e06d5233..fe866cddc06 100644 --- a/mozilla/content/html/content/src/nsHTMLAtoms.h +++ b/mozilla/content/html/content/src/nsHTMLAtoms.h @@ -127,6 +127,7 @@ public: static nsIAtom* headers; static nsIAtom* height; static nsIAtom* hidden; + static nsIAtom* horizontalFramesetBorderPseudo; static nsIAtom* hover; static nsIAtom* hr; static nsIAtom* href; @@ -254,6 +255,7 @@ public: static nsIAtom* valuetype; static nsIAtom* variable; static nsIAtom* version; + static nsIAtom* verticalFramesetBorderPseudo; static nsIAtom* visibility; static nsIAtom* visited; static nsIAtom* vlink; diff --git a/mozilla/content/html/style/src/nsCSSLayout.cpp b/mozilla/content/html/style/src/nsCSSLayout.cpp index 91001ee39a3..9083aa529c8 100644 --- a/mozilla/content/html/style/src/nsCSSLayout.cpp +++ b/mozilla/content/html/style/src/nsCSSLayout.cpp @@ -122,6 +122,7 @@ nsCSSLayout::RelativePositionChildren(nsIPresContext* aCX, } } +#if XXX // XXX if this can handle proportional widths then do so // XXX check against other possible values and update static PRBool @@ -182,30 +183,129 @@ GetStyleDimension(nsIPresContext* aPresContext, } return rv; } +#endif + // XXX if display == row || rowspan ignore width + // XXX if display == col || colspan ignore height PRIntn nsCSSLayout::GetStyleSize(nsIPresContext* aPresContext, const nsHTMLReflowState& aReflowState, nsSize& aStyleSize) { - // XXX if display == row || rowspan ignore width - // XXX if display == col || colspan ignore height - PRIntn rv = NS_SIZE_HAS_NONE; + const nsStylePosition* pos; - nsresult result = aReflowState.frame->GetStyleData(eStyleStruct_Position, - (const nsStyleStruct*&)pos); + nsresult result = + aReflowState.frame->GetStyleData(eStyleStruct_Position, + (const nsStyleStruct*&)pos); if (NS_OK == result) { - if (GetStyleDimension(aPresContext, aReflowState, pos, pos->mWidth, - aStyleSize.width)) { -NS_ASSERTION(aStyleSize.width < 100000, "bad % result"); + nscoord containingBlockWidth, containingBlockHeight; + nscoord width = -1, height = -1; + PRIntn widthUnit = pos->mWidth.GetUnit(); + PRIntn heightUnit = pos->mHeight.GetUnit(); + + // When a percentage is specified we need to find the containing + // block to use as the basis for the percentage computation. + if ((eStyleUnit_Percent == widthUnit) || + (eStyleUnit_Percent == heightUnit)) { + // Find the containing block for this frame + nsIFrame* containingBlock = nsnull; + // XXX this cast is just plain wrong + const nsHTMLReflowState* rs = (const nsHTMLReflowState*) + aReflowState.parentReflowState; + while (nsnull != rs) { + if (nsnull != rs->frame) { + PRBool isContainingBlock; + if (NS_OK == rs->frame->IsPercentageBase(isContainingBlock)) { + if (isContainingBlock) { + containingBlock = rs->frame; + break; + } + } + } + // XXX this cast is just plain wrong + rs = (const nsHTMLReflowState*) rs->parentReflowState; + } + + // If there is no containing block then pretend the width or + // height units are auto. + if (nsnull == containingBlock) { + if (eStyleUnit_Percent == widthUnit) { + widthUnit = eStyleUnit_Auto; + } + if (eStyleUnit_Percent == heightUnit) { + heightUnit = eStyleUnit_Auto; + } + } + else { + if (eStyleUnit_Percent == widthUnit) { + if (eHTMLFrameConstraint_Unconstrained == rs->widthConstraint) { + if (NS_UNCONSTRAINEDSIZE == rs->maxSize.width) { + // When we don't know the width (yet) of the containing + // block we use a dummy value, assuming that the frame + // depending on the percentage value will be reflowed a + // second time. + containingBlockWidth = 1; + } + else { + containingBlockWidth = rs->maxSize.width; + } + } + else { + containingBlockWidth = rs->minWidth; + } + } + if (eStyleUnit_Percent == heightUnit) { + if (eHTMLFrameConstraint_Unconstrained == rs->heightConstraint) { + if (NS_UNCONSTRAINEDSIZE == rs->maxSize.height) { + // CSS2 spec, 10.5: if the height of the containing block + // is not specified explicitly then the value is + // interpreted like auto. + heightUnit = eStyleUnit_Auto; + } + else { + containingBlockHeight = rs->maxSize.height; + } + } + else { + containingBlockHeight = rs->minHeight; + } + } + } + } + + switch (widthUnit) { + case eStyleUnit_Coord: + width = pos->mWidth.GetCoordValue(); + break; + case eStyleUnit_Percent: + width = nscoord(pos->mWidth.GetPercentValue() * containingBlockWidth); + break; + case eStyleUnit_Auto: + // XXX See section 10.3 of the css2 spec and then write this code! + break; + } + switch (heightUnit) { + case eStyleUnit_Coord: + height = pos->mHeight.GetCoordValue(); + break; + case eStyleUnit_Percent: + height = nscoord(pos->mHeight.GetPercentValue() * containingBlockHeight); + break; + case eStyleUnit_Auto: + // XXX See section 10.6 of the css2 spec and then write this code! + break; + } + + if (width > 0) { + aStyleSize.width = width; rv |= NS_SIZE_HAS_WIDTH; } - if (GetStyleDimension(aPresContext, aReflowState, pos, pos->mHeight, - aStyleSize.height)) { -NS_ASSERTION(aStyleSize.height < 100000, "bad % result"); + if (height > 0) { + aStyleSize.height = height; rv |= NS_SIZE_HAS_HEIGHT; } } + return rv; } diff --git a/mozilla/content/shared/public/nsHTMLAtoms.h b/mozilla/content/shared/public/nsHTMLAtoms.h index c65e06d5233..fe866cddc06 100644 --- a/mozilla/content/shared/public/nsHTMLAtoms.h +++ b/mozilla/content/shared/public/nsHTMLAtoms.h @@ -127,6 +127,7 @@ public: static nsIAtom* headers; static nsIAtom* height; static nsIAtom* hidden; + static nsIAtom* horizontalFramesetBorderPseudo; static nsIAtom* hover; static nsIAtom* hr; static nsIAtom* href; @@ -254,6 +255,7 @@ public: static nsIAtom* valuetype; static nsIAtom* variable; static nsIAtom* version; + static nsIAtom* verticalFramesetBorderPseudo; static nsIAtom* visibility; static nsIAtom* visited; static nsIAtom* vlink; diff --git a/mozilla/content/shared/src/nsHTMLAtoms.cpp b/mozilla/content/shared/src/nsHTMLAtoms.cpp index 15a5ee9687b..664697ff836 100644 --- a/mozilla/content/shared/src/nsHTMLAtoms.cpp +++ b/mozilla/content/shared/src/nsHTMLAtoms.cpp @@ -101,6 +101,7 @@ nsIAtom* nsHTMLAtoms::h6; nsIAtom* nsHTMLAtoms::headers; nsIAtom* nsHTMLAtoms::height; nsIAtom* nsHTMLAtoms::hidden; +nsIAtom* nsHTMLAtoms::horizontalFramesetBorderPseudo; nsIAtom* nsHTMLAtoms::hover; nsIAtom* nsHTMLAtoms::hr; nsIAtom* nsHTMLAtoms::href; @@ -217,6 +218,7 @@ nsIAtom* nsHTMLAtoms::value; nsIAtom* nsHTMLAtoms::valuetype; nsIAtom* nsHTMLAtoms::variable; nsIAtom* nsHTMLAtoms::version; +nsIAtom* nsHTMLAtoms::verticalFramesetBorderPseudo; nsIAtom* nsHTMLAtoms::visibility; nsIAtom* nsHTMLAtoms::visited; nsIAtom* nsHTMLAtoms::vlink; @@ -314,6 +316,7 @@ void nsHTMLAtoms::AddrefAtoms() headers = NS_NewAtom("HEADERS"); height = NS_NewAtom("HEIGHT"); hidden = NS_NewAtom("HIDDEN"); + horizontalFramesetBorderPseudo = NS_NewAtom("HFRAMESETBORDER"); hover = NS_NewAtom("HOVER"); hr = NS_NewAtom("HR"); href = NS_NewAtom("HREF"); @@ -429,6 +432,7 @@ void nsHTMLAtoms::AddrefAtoms() valuetype = NS_NewAtom("VALUETYPE"); variable = NS_NewAtom("VARIABLE"); version = NS_NewAtom("VERSION"); + verticalFramesetBorderPseudo = NS_NewAtom("VFRAMESETBORDER"); visibility = NS_NewAtom("VISIBILITY"); visited = NS_NewAtom("VISITED"); vlink = NS_NewAtom("VLINK"); @@ -521,6 +525,7 @@ void nsHTMLAtoms::ReleaseAtoms() NS_RELEASE(headers); NS_RELEASE(height); NS_RELEASE(hidden); + NS_RELEASE(horizontalFramesetBorderPseudo); NS_RELEASE(hover); NS_RELEASE(hr); NS_RELEASE(href); @@ -632,6 +637,7 @@ void nsHTMLAtoms::ReleaseAtoms() NS_RELEASE(valuetype); NS_RELEASE(variable); NS_RELEASE(version); + NS_RELEASE(verticalFramesetBorderPseudo); NS_RELEASE(visibility); NS_RELEASE(visited); NS_RELEASE(vlink); diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index e0cd1d4d618..ee79dda90a4 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -506,7 +506,8 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight) CreateRenderingContext(mRootFrame, rcx); - nsHTMLReflowState reflowState(mRootFrame, eReflowReason_Initial, maxSize, rcx); + nsHTMLReflowState reflowState(*mPresContext, mRootFrame, + eReflowReason_Initial, maxSize, rcx); if (NS_OK == mRootFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { htmlReflow->Reflow(*mPresContext, desiredSize, reflowState, status); @@ -557,7 +558,8 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight) CreateRenderingContext(mRootFrame, rcx); - nsHTMLReflowState reflowState(mRootFrame, eReflowReason_Resize, maxSize, rcx); + nsHTMLReflowState reflowState(*mPresContext, mRootFrame, + eReflowReason_Resize, maxSize, rcx); if (NS_OK == mRootFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { htmlReflow->Reflow(*mPresContext, desiredSize, reflowState, status); diff --git a/mozilla/layout/forms/nsFieldSetFrame.cpp b/mozilla/layout/forms/nsFieldSetFrame.cpp index d73b68b82c8..dba2e8ba2d8 100644 --- a/mozilla/layout/forms/nsFieldSetFrame.cpp +++ b/mozilla/layout/forms/nsFieldSetFrame.cpp @@ -284,7 +284,8 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext, // Try to reflow the legend into the available space. It might not fit nsSize legendSize(0,0); if (mLegendFrame) { - nsHTMLReflowState legendReflowState(mLegendFrame, aReflowState, availSize); + nsHTMLReflowState legendReflowState(aPresContext, mLegendFrame, + aReflowState, availSize); ReflowChild(mLegendFrame, aPresContext, aDesiredSize, legendReflowState, aStatus); legendSize.width = aDesiredSize.width; @@ -307,7 +308,8 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext, // Try to reflow the content frame into the available space. It might not fit nsSize contentSize(0,0); - nsHTMLReflowState contentReflowState(mContentFrame, aReflowState, availSize); + nsHTMLReflowState contentReflowState(aPresContext, mContentFrame, + aReflowState, availSize); nscoord contentTopOffset = (legendSize.height > border.top) ? legendSize.height + padding.top : border.top + padding.top; @@ -328,7 +330,8 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext, // need to reflow the legend a 2nd time if (needAnotherLegendReflow && mLegendFrame) { - nsHTMLReflowState legendReflowState(mLegendFrame, aReflowState, availSize); + nsHTMLReflowState legendReflowState(aPresContext, mLegendFrame, + aReflowState, availSize); ReflowChild(mLegendFrame, aPresContext, aDesiredSize, legendReflowState, aStatus); legendSize.width = aDesiredSize.width; diff --git a/mozilla/layout/forms/nsFileControlFrame.cpp b/mozilla/layout/forms/nsFileControlFrame.cpp index 1bc824ef8a6..9e73c4fcc62 100644 --- a/mozilla/layout/forms/nsFileControlFrame.cpp +++ b/mozilla/layout/forms/nsFileControlFrame.cpp @@ -225,7 +225,8 @@ NS_IMETHODIMP nsFileControlFrame::Reflow(nsIPresContext& aPresContext, childFrame = mFirstChild; nsPoint offset(0,0); while (nsnull != childFrame) { // reflow, place, size the children - nsHTMLReflowState reflowState(childFrame, aReflowState, maxSize); + nsHTMLReflowState reflowState(aPresContext, childFrame, aReflowState, + maxSize); nsIHTMLReflow* htmlReflow; if (NS_OK == childFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { diff --git a/mozilla/layout/forms/nsLegendFrame.cpp b/mozilla/layout/forms/nsLegendFrame.cpp index 71c3a75cdbf..bdc44428659 100644 --- a/mozilla/layout/forms/nsLegendFrame.cpp +++ b/mozilla/layout/forms/nsLegendFrame.cpp @@ -123,14 +123,15 @@ nsLegendFrame::Paint(nsIPresContext& aPresContext, NS_IMETHODIMP nsLegendFrame::Reflow(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - const nsHTMLReflowState& aReflowState, - nsReflowStatus& aStatus) + nsHTMLReflowMetrics& aDesiredSize, + const nsHTMLReflowState& aReflowState, + nsReflowStatus& aStatus) { nsSize availSize(aReflowState.maxSize); // reflow the child - nsHTMLReflowState reflowState(mFirstChild, aReflowState, availSize); + nsHTMLReflowState reflowState(aPresContext, mFirstChild, aReflowState, + availSize); ReflowChild(mFirstChild, aPresContext, aDesiredSize, reflowState, aStatus); // get border and padding diff --git a/mozilla/layout/generic/nsBlockFrame.cpp b/mozilla/layout/generic/nsBlockFrame.cpp index c25cee2af37..f75b702afc5 100644 --- a/mozilla/layout/generic/nsBlockFrame.cpp +++ b/mozilla/layout/generic/nsBlockFrame.cpp @@ -157,9 +157,6 @@ struct nsBlockReflowState : public nsFrameReflowState { PRUint8 mTextAlign; PRUint8 mPrevMarginFlags; - nsSize mStyleSize; - PRIntn mStyleSizeFlags; - nscoord mBottomEdge; // maximum Y PRBool mUnconstrainedWidth; @@ -1317,18 +1314,12 @@ nsBlockReflowState::nsBlockReflowState(nsIPresContext& aPresContext, nscoord lr = mBorderPadding.left + mBorderPadding.right; mY = mBorderPadding.top; - - // Get and apply the stylistic size. Note: do not limit the - // height until we are done reflowing. - PRIntn ss = nsCSSLayout::GetStyleSize(&aPresContext, aReflowState, - mStyleSize); - mStyleSizeFlags = ss; - if (0 != (ss & NS_SIZE_HAS_WIDTH)) { - // The CSS2 spec says that the width attribute defines the - // width of the "content area" which does not include the - // border padding. So we add those back in. - mBorderArea.width = mStyleSize.width + lr; - mContentArea.width = mStyleSize.width; + if (eHTMLFrameConstraint_Unconstrained != widthConstraint) { + // The CSS2 spec says that the width attribute defines the width + // of the "content area" which does not include the border + // padding. So we add those back in. + mBorderArea.width = minWidth + lr; + mContentArea.width = minWidth; } else { if (mUnconstrainedWidth) { @@ -1835,11 +1826,10 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, nsHTMLReflowMetrics& aMetrics) { // Compute final width - PRIntn ss = aState.mStyleSizeFlags; - if (NS_SIZE_HAS_WIDTH & ss) { + if (eHTMLFrameConstraint_Unconstrained != aState.widthConstraint) { // Use style defined width aMetrics.width = aState.mBorderPadding.left + - aState.mStyleSize.width + aState.mBorderPadding.right; + aState.minWidth + aState.mBorderPadding.right; } else { // There are two options here. We either shrink wrap around our @@ -1856,10 +1846,10 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, } // Compute final height - if (NS_SIZE_HAS_HEIGHT & ss) { + if (eHTMLFrameConstraint_Unconstrained != aState.heightConstraint) { // Use style defined height aMetrics.height = aState.mBorderPadding.top + - aState.mStyleSize.height + aState.mBorderPadding.bottom; + aState.minHeight + aState.mBorderPadding.bottom; } else { // Shrink wrap our height around our contents. @@ -1896,7 +1886,8 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, // Special check for zero sized content: If our content is zero // sized then we collapse into nothingness. - if ((NS_SIZE_HAS_BOTH != ss) && + if ((eHTMLFrameConstraint_Unconstrained == aState.widthConstraint) && + (eHTMLFrameConstraint_Unconstrained == aState.heightConstraint) && ((0 == aState.mKidXMost - aState.mBorderPadding.left) || (0 == aState.mY - aState.mBorderPadding.top))) { aMetrics.width = 0; @@ -3388,7 +3379,8 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState, nsSize availSize; availSize.width = NS_UNCONSTRAINEDSIZE; availSize.height = NS_UNCONSTRAINEDSIZE; - nsHTMLReflowState reflowState(mBullet, aState, availSize, &aState.mLineLayout); + nsHTMLReflowState reflowState(aState.mPresContext, mBullet, aState, + availSize, &aState.mLineLayout); nsHTMLReflowMetrics metrics(nsnull); nsIHTMLReflow* htmlReflow; if (NS_OK == mBullet->QueryInterface(kIHTMLReflowIID, (void**) &htmlReflow)) { @@ -3883,8 +3875,8 @@ nsBlockFrame::ReflowFloater(nsIPresContext& aPresContext, // it's maxSize will be 0,0 until we compute it (we need the reflowState // for nsLayout::GetStyleSize so we have to do this first) nsSize kidAvailSize(0, 0); - nsHTMLReflowState reflowState(aFloaterFrame, aState, kidAvailSize, - eReflowReason_Initial); + nsHTMLReflowState reflowState(aPresContext, aFloaterFrame, aState, + kidAvailSize, eReflowReason_Initial); // Compute the available space for the floater. Use the default // 'auto' width and height values diff --git a/mozilla/layout/generic/nsBlockReflowState.cpp b/mozilla/layout/generic/nsBlockReflowState.cpp index c25cee2af37..f75b702afc5 100644 --- a/mozilla/layout/generic/nsBlockReflowState.cpp +++ b/mozilla/layout/generic/nsBlockReflowState.cpp @@ -157,9 +157,6 @@ struct nsBlockReflowState : public nsFrameReflowState { PRUint8 mTextAlign; PRUint8 mPrevMarginFlags; - nsSize mStyleSize; - PRIntn mStyleSizeFlags; - nscoord mBottomEdge; // maximum Y PRBool mUnconstrainedWidth; @@ -1317,18 +1314,12 @@ nsBlockReflowState::nsBlockReflowState(nsIPresContext& aPresContext, nscoord lr = mBorderPadding.left + mBorderPadding.right; mY = mBorderPadding.top; - - // Get and apply the stylistic size. Note: do not limit the - // height until we are done reflowing. - PRIntn ss = nsCSSLayout::GetStyleSize(&aPresContext, aReflowState, - mStyleSize); - mStyleSizeFlags = ss; - if (0 != (ss & NS_SIZE_HAS_WIDTH)) { - // The CSS2 spec says that the width attribute defines the - // width of the "content area" which does not include the - // border padding. So we add those back in. - mBorderArea.width = mStyleSize.width + lr; - mContentArea.width = mStyleSize.width; + if (eHTMLFrameConstraint_Unconstrained != widthConstraint) { + // The CSS2 spec says that the width attribute defines the width + // of the "content area" which does not include the border + // padding. So we add those back in. + mBorderArea.width = minWidth + lr; + mContentArea.width = minWidth; } else { if (mUnconstrainedWidth) { @@ -1835,11 +1826,10 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, nsHTMLReflowMetrics& aMetrics) { // Compute final width - PRIntn ss = aState.mStyleSizeFlags; - if (NS_SIZE_HAS_WIDTH & ss) { + if (eHTMLFrameConstraint_Unconstrained != aState.widthConstraint) { // Use style defined width aMetrics.width = aState.mBorderPadding.left + - aState.mStyleSize.width + aState.mBorderPadding.right; + aState.minWidth + aState.mBorderPadding.right; } else { // There are two options here. We either shrink wrap around our @@ -1856,10 +1846,10 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, } // Compute final height - if (NS_SIZE_HAS_HEIGHT & ss) { + if (eHTMLFrameConstraint_Unconstrained != aState.heightConstraint) { // Use style defined height aMetrics.height = aState.mBorderPadding.top + - aState.mStyleSize.height + aState.mBorderPadding.bottom; + aState.minHeight + aState.mBorderPadding.bottom; } else { // Shrink wrap our height around our contents. @@ -1896,7 +1886,8 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, // Special check for zero sized content: If our content is zero // sized then we collapse into nothingness. - if ((NS_SIZE_HAS_BOTH != ss) && + if ((eHTMLFrameConstraint_Unconstrained == aState.widthConstraint) && + (eHTMLFrameConstraint_Unconstrained == aState.heightConstraint) && ((0 == aState.mKidXMost - aState.mBorderPadding.left) || (0 == aState.mY - aState.mBorderPadding.top))) { aMetrics.width = 0; @@ -3388,7 +3379,8 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState, nsSize availSize; availSize.width = NS_UNCONSTRAINEDSIZE; availSize.height = NS_UNCONSTRAINEDSIZE; - nsHTMLReflowState reflowState(mBullet, aState, availSize, &aState.mLineLayout); + nsHTMLReflowState reflowState(aState.mPresContext, mBullet, aState, + availSize, &aState.mLineLayout); nsHTMLReflowMetrics metrics(nsnull); nsIHTMLReflow* htmlReflow; if (NS_OK == mBullet->QueryInterface(kIHTMLReflowIID, (void**) &htmlReflow)) { @@ -3883,8 +3875,8 @@ nsBlockFrame::ReflowFloater(nsIPresContext& aPresContext, // it's maxSize will be 0,0 until we compute it (we need the reflowState // for nsLayout::GetStyleSize so we have to do this first) nsSize kidAvailSize(0, 0); - nsHTMLReflowState reflowState(aFloaterFrame, aState, kidAvailSize, - eReflowReason_Initial); + nsHTMLReflowState reflowState(aPresContext, aFloaterFrame, aState, + kidAvailSize, eReflowReason_Initial); // Compute the available space for the floater. Use the default // 'auto' width and height values diff --git a/mozilla/layout/generic/nsBlockReflowState.h b/mozilla/layout/generic/nsBlockReflowState.h index c25cee2af37..f75b702afc5 100644 --- a/mozilla/layout/generic/nsBlockReflowState.h +++ b/mozilla/layout/generic/nsBlockReflowState.h @@ -157,9 +157,6 @@ struct nsBlockReflowState : public nsFrameReflowState { PRUint8 mTextAlign; PRUint8 mPrevMarginFlags; - nsSize mStyleSize; - PRIntn mStyleSizeFlags; - nscoord mBottomEdge; // maximum Y PRBool mUnconstrainedWidth; @@ -1317,18 +1314,12 @@ nsBlockReflowState::nsBlockReflowState(nsIPresContext& aPresContext, nscoord lr = mBorderPadding.left + mBorderPadding.right; mY = mBorderPadding.top; - - // Get and apply the stylistic size. Note: do not limit the - // height until we are done reflowing. - PRIntn ss = nsCSSLayout::GetStyleSize(&aPresContext, aReflowState, - mStyleSize); - mStyleSizeFlags = ss; - if (0 != (ss & NS_SIZE_HAS_WIDTH)) { - // The CSS2 spec says that the width attribute defines the - // width of the "content area" which does not include the - // border padding. So we add those back in. - mBorderArea.width = mStyleSize.width + lr; - mContentArea.width = mStyleSize.width; + if (eHTMLFrameConstraint_Unconstrained != widthConstraint) { + // The CSS2 spec says that the width attribute defines the width + // of the "content area" which does not include the border + // padding. So we add those back in. + mBorderArea.width = minWidth + lr; + mContentArea.width = minWidth; } else { if (mUnconstrainedWidth) { @@ -1835,11 +1826,10 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, nsHTMLReflowMetrics& aMetrics) { // Compute final width - PRIntn ss = aState.mStyleSizeFlags; - if (NS_SIZE_HAS_WIDTH & ss) { + if (eHTMLFrameConstraint_Unconstrained != aState.widthConstraint) { // Use style defined width aMetrics.width = aState.mBorderPadding.left + - aState.mStyleSize.width + aState.mBorderPadding.right; + aState.minWidth + aState.mBorderPadding.right; } else { // There are two options here. We either shrink wrap around our @@ -1856,10 +1846,10 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, } // Compute final height - if (NS_SIZE_HAS_HEIGHT & ss) { + if (eHTMLFrameConstraint_Unconstrained != aState.heightConstraint) { // Use style defined height aMetrics.height = aState.mBorderPadding.top + - aState.mStyleSize.height + aState.mBorderPadding.bottom; + aState.minHeight + aState.mBorderPadding.bottom; } else { // Shrink wrap our height around our contents. @@ -1896,7 +1886,8 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, // Special check for zero sized content: If our content is zero // sized then we collapse into nothingness. - if ((NS_SIZE_HAS_BOTH != ss) && + if ((eHTMLFrameConstraint_Unconstrained == aState.widthConstraint) && + (eHTMLFrameConstraint_Unconstrained == aState.heightConstraint) && ((0 == aState.mKidXMost - aState.mBorderPadding.left) || (0 == aState.mY - aState.mBorderPadding.top))) { aMetrics.width = 0; @@ -3388,7 +3379,8 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState, nsSize availSize; availSize.width = NS_UNCONSTRAINEDSIZE; availSize.height = NS_UNCONSTRAINEDSIZE; - nsHTMLReflowState reflowState(mBullet, aState, availSize, &aState.mLineLayout); + nsHTMLReflowState reflowState(aState.mPresContext, mBullet, aState, + availSize, &aState.mLineLayout); nsHTMLReflowMetrics metrics(nsnull); nsIHTMLReflow* htmlReflow; if (NS_OK == mBullet->QueryInterface(kIHTMLReflowIID, (void**) &htmlReflow)) { @@ -3883,8 +3875,8 @@ nsBlockFrame::ReflowFloater(nsIPresContext& aPresContext, // it's maxSize will be 0,0 until we compute it (we need the reflowState // for nsLayout::GetStyleSize so we have to do this first) nsSize kidAvailSize(0, 0); - nsHTMLReflowState reflowState(aFloaterFrame, aState, kidAvailSize, - eReflowReason_Initial); + nsHTMLReflowState reflowState(aPresContext, aFloaterFrame, aState, + kidAvailSize, eReflowReason_Initial); // Compute the available space for the floater. Use the default // 'auto' width and height values diff --git a/mozilla/layout/generic/nsFrameFrame.cpp b/mozilla/layout/generic/nsFrameFrame.cpp index 9fa1c8b3f59..a3762d2c2c3 100644 --- a/mozilla/layout/generic/nsFrameFrame.cpp +++ b/mozilla/layout/generic/nsFrameFrame.cpp @@ -324,7 +324,8 @@ nsHTMLFrameOuterFrame::Reflow(nsIPresContext& aPresContext, // Reflow the child and get its desired size nsHTMLReflowMetrics kidMetrics(aDesiredSize.maxElementSize); - nsHTMLReflowState kidReflowState(mFirstChild, aReflowState, innerSize); + nsHTMLReflowState kidReflowState(aPresContext, mFirstChild, aReflowState, + innerSize); nsIHTMLReflow* htmlReflow; if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { diff --git a/mozilla/layout/generic/nsFrameSetFrame.cpp b/mozilla/layout/generic/nsFrameSetFrame.cpp index 630e38cba37..b1d8886e4d9 100644 --- a/mozilla/layout/generic/nsFrameSetFrame.cpp +++ b/mozilla/layout/generic/nsFrameSetFrame.cpp @@ -670,7 +670,7 @@ nsHTMLFramesetFrame::ReflowPlaceChild(nsIFrame* aChild, } } - nsHTMLReflowState reflowState(aChild, aReflowState, aSize); + nsHTMLReflowState reflowState(aPresContext, aChild, aReflowState, aSize); nsIHTMLReflow* htmlReflow; if (NS_OK == aChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { @@ -1033,6 +1033,10 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext& aPresContext, if (borderWidth > 0) { if (firstTime) { // create horizontal border borderFrame = new nsHTMLFramesetBorderFrame(mContent, this, borderWidth, PR_FALSE, PR_FALSE); + nsIStyleContext* pseudoStyleContext = + aPresContext.ResolvePseudoStyleContextFor(nsHTMLAtoms::horizontalFramesetBorderPseudo, this); + borderFrame->SetStyleContext(&aPresContext, pseudoStyleContext); + mChildCount++; lastChild->SetNextSibling(borderFrame); lastChild = borderFrame; @@ -1053,6 +1057,10 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext& aPresContext, if (0 == cellIndex.y) { // in 1st row if (firstTime) { // create vertical border borderFrame = new nsHTMLFramesetBorderFrame(mContent, this, borderWidth, PR_TRUE, PR_FALSE); + nsIStyleContext* pseudoStyleContext = + aPresContext.ResolvePseudoStyleContextFor(nsHTMLAtoms::verticalFramesetBorderPseudo, this); + borderFrame->SetStyleContext(&aPresContext, pseudoStyleContext); + mChildCount++; lastChild->SetNextSibling(borderFrame); lastChild = borderFrame; @@ -1400,7 +1408,8 @@ nsHTMLFramesetFrame::MouseDrag(nsIPresContext& aPresContext, nsGUIEvent* aEvent) shell = aPresContext.GetShell(); shell->CreateRenderingContext(this, acx); NS_RELEASE(shell); - nsHTMLReflowState state(this, eReflowReason_Initial, size, acx); + nsHTMLReflowState state(aPresContext, this, eReflowReason_Initial, + size, acx); state.reason = eReflowReason_Incremental; nsReflowStatus status; nsDidReflowStatus didStatus; diff --git a/mozilla/layout/generic/nsHTMLFrame.cpp b/mozilla/layout/generic/nsHTMLFrame.cpp index f40589bde2b..cd26792d729 100644 --- a/mozilla/layout/generic/nsHTMLFrame.cpp +++ b/mozilla/layout/generic/nsHTMLFrame.cpp @@ -147,8 +147,9 @@ RootFrame::Reflow(nsIPresContext& aPresContext, // wants if (nsnull != mFirstChild) { nsHTMLReflowMetrics desiredSize(nsnull); - nsHTMLReflowState kidReflowState(mFirstChild, aReflowState, aReflowState.maxSize); - nsIHTMLReflow* htmlReflow; + nsHTMLReflowState kidReflowState(aPresContext, mFirstChild, aReflowState, + aReflowState.maxSize); + nsIHTMLReflow* htmlReflow; if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { ReflowChild(mFirstChild, aPresContext, desiredSize, kidReflowState, aStatus); @@ -364,7 +365,8 @@ RootContentFrame::Reflow(nsIPresContext& aPresContext, NS_ASSERTION(next == mFirstChild, "unexpected next reflow command frame"); nsSize maxSize(availWidth, NS_UNCONSTRAINEDSIZE); - nsHTMLReflowState kidReflowState(next, aReflowState, maxSize); + nsHTMLReflowState kidReflowState(aPresContext, next, aReflowState, + maxSize); // Dispatch the reflow command to our child frame. Allow it to be as high // as it wants @@ -411,7 +413,8 @@ RootContentFrame::Reflow(nsIPresContext& aPresContext, // Tile the pages vertically for (nsIFrame* kidFrame = mFirstChild; nsnull != kidFrame; ) { // Reflow the page - nsHTMLReflowState kidReflowState(kidFrame, aReflowState, pageSize, + nsHTMLReflowState kidReflowState(aPresContext, kidFrame, + aReflowState, pageSize, reflowReason); nsReflowStatus status; @@ -466,7 +469,8 @@ RootContentFrame::Reflow(nsIPresContext& aPresContext, } else { nsSize maxSize(availWidth, NS_UNCONSTRAINEDSIZE); - nsHTMLReflowState kidReflowState(mFirstChild, aReflowState, maxSize, + nsHTMLReflowState kidReflowState(aPresContext, mFirstChild, + aReflowState, maxSize, reflowReason); // Get the child's desired size. Our child's desired height is our diff --git a/mozilla/layout/generic/nsHTMLReflowCommand.cpp b/mozilla/layout/generic/nsHTMLReflowCommand.cpp index 13e200f742d..834892f3e2f 100644 --- a/mozilla/layout/generic/nsHTMLReflowCommand.cpp +++ b/mozilla/layout/generic/nsHTMLReflowCommand.cpp @@ -156,7 +156,8 @@ NS_IMETHODIMP nsHTMLReflowCommand::Dispatch(nsIPresContext& aPresContext, if (nsnull != root) { mPath.RemoveElementAt(mPath.Count() - 1); - nsHTMLReflowState reflowState(root, *this, aMaxSize, &aRendContext); + nsHTMLReflowState reflowState(aPresContext, root, *this, aMaxSize, + &aRendContext); nsIHTMLReflow* htmlReflow; nsReflowStatus status; diff --git a/mozilla/layout/generic/nsInlineFrame.cpp b/mozilla/layout/generic/nsInlineFrame.cpp index a87e138b1b9..39824666e0b 100644 --- a/mozilla/layout/generic/nsInlineFrame.cpp +++ b/mozilla/layout/generic/nsInlineFrame.cpp @@ -214,7 +214,11 @@ NS_IMETHODIMP nsInlineFrame::Init(nsIPresContext& aPresContext, nsIFrame* aChildList) { NS_PRECONDITION(nsnull == mFirstChild, "already initialized"); - return AppendNewFrames(aPresContext, aChildList); + nsresult rv = AppendNewFrames(aPresContext, aChildList); + if (NS_OK != rv) { + return rv; + } + return rv; } NS_IMETHODIMP diff --git a/mozilla/layout/generic/nsPageFrame.cpp b/mozilla/layout/generic/nsPageFrame.cpp index 87230a8b332..6cd9fa1e06c 100644 --- a/mozilla/layout/generic/nsPageFrame.cpp +++ b/mozilla/layout/generic/nsPageFrame.cpp @@ -90,7 +90,8 @@ NS_METHOD nsPageFrame::Reflow(nsIPresContext& aPresContext, // Dispatch the reflow command to our content child. Allow it to be as high // as it wants nsSize maxSize(aReflowState.maxSize.width, NS_UNCONSTRAINEDSIZE); - nsHTMLReflowState kidReflowState(mFirstChild, aReflowState, maxSize); + nsHTMLReflowState kidReflowState(aPresContext, mFirstChild, aReflowState, + maxSize); ReflowChild(mFirstChild, aPresContext, aDesiredSize, kidReflowState, aStatus); @@ -126,7 +127,8 @@ NS_METHOD nsPageFrame::Reflow(nsIPresContext& aPresContext, // Resize our frame allowing it only to be as big as we are // XXX Pay attention to the page's border and padding... if (nsnull != mFirstChild) { - nsHTMLReflowState kidReflowState(mFirstChild, aReflowState, aReflowState.maxSize); + nsHTMLReflowState kidReflowState(aPresContext, mFirstChild, aReflowState, + aReflowState.maxSize); nsIHTMLReflow* htmlReflow; if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { diff --git a/mozilla/layout/html/base/src/nsBlockFrame.cpp b/mozilla/layout/html/base/src/nsBlockFrame.cpp index c25cee2af37..f75b702afc5 100644 --- a/mozilla/layout/html/base/src/nsBlockFrame.cpp +++ b/mozilla/layout/html/base/src/nsBlockFrame.cpp @@ -157,9 +157,6 @@ struct nsBlockReflowState : public nsFrameReflowState { PRUint8 mTextAlign; PRUint8 mPrevMarginFlags; - nsSize mStyleSize; - PRIntn mStyleSizeFlags; - nscoord mBottomEdge; // maximum Y PRBool mUnconstrainedWidth; @@ -1317,18 +1314,12 @@ nsBlockReflowState::nsBlockReflowState(nsIPresContext& aPresContext, nscoord lr = mBorderPadding.left + mBorderPadding.right; mY = mBorderPadding.top; - - // Get and apply the stylistic size. Note: do not limit the - // height until we are done reflowing. - PRIntn ss = nsCSSLayout::GetStyleSize(&aPresContext, aReflowState, - mStyleSize); - mStyleSizeFlags = ss; - if (0 != (ss & NS_SIZE_HAS_WIDTH)) { - // The CSS2 spec says that the width attribute defines the - // width of the "content area" which does not include the - // border padding. So we add those back in. - mBorderArea.width = mStyleSize.width + lr; - mContentArea.width = mStyleSize.width; + if (eHTMLFrameConstraint_Unconstrained != widthConstraint) { + // The CSS2 spec says that the width attribute defines the width + // of the "content area" which does not include the border + // padding. So we add those back in. + mBorderArea.width = minWidth + lr; + mContentArea.width = minWidth; } else { if (mUnconstrainedWidth) { @@ -1835,11 +1826,10 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, nsHTMLReflowMetrics& aMetrics) { // Compute final width - PRIntn ss = aState.mStyleSizeFlags; - if (NS_SIZE_HAS_WIDTH & ss) { + if (eHTMLFrameConstraint_Unconstrained != aState.widthConstraint) { // Use style defined width aMetrics.width = aState.mBorderPadding.left + - aState.mStyleSize.width + aState.mBorderPadding.right; + aState.minWidth + aState.mBorderPadding.right; } else { // There are two options here. We either shrink wrap around our @@ -1856,10 +1846,10 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, } // Compute final height - if (NS_SIZE_HAS_HEIGHT & ss) { + if (eHTMLFrameConstraint_Unconstrained != aState.heightConstraint) { // Use style defined height aMetrics.height = aState.mBorderPadding.top + - aState.mStyleSize.height + aState.mBorderPadding.bottom; + aState.minHeight + aState.mBorderPadding.bottom; } else { // Shrink wrap our height around our contents. @@ -1896,7 +1886,8 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, // Special check for zero sized content: If our content is zero // sized then we collapse into nothingness. - if ((NS_SIZE_HAS_BOTH != ss) && + if ((eHTMLFrameConstraint_Unconstrained == aState.widthConstraint) && + (eHTMLFrameConstraint_Unconstrained == aState.heightConstraint) && ((0 == aState.mKidXMost - aState.mBorderPadding.left) || (0 == aState.mY - aState.mBorderPadding.top))) { aMetrics.width = 0; @@ -3388,7 +3379,8 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState, nsSize availSize; availSize.width = NS_UNCONSTRAINEDSIZE; availSize.height = NS_UNCONSTRAINEDSIZE; - nsHTMLReflowState reflowState(mBullet, aState, availSize, &aState.mLineLayout); + nsHTMLReflowState reflowState(aState.mPresContext, mBullet, aState, + availSize, &aState.mLineLayout); nsHTMLReflowMetrics metrics(nsnull); nsIHTMLReflow* htmlReflow; if (NS_OK == mBullet->QueryInterface(kIHTMLReflowIID, (void**) &htmlReflow)) { @@ -3883,8 +3875,8 @@ nsBlockFrame::ReflowFloater(nsIPresContext& aPresContext, // it's maxSize will be 0,0 until we compute it (we need the reflowState // for nsLayout::GetStyleSize so we have to do this first) nsSize kidAvailSize(0, 0); - nsHTMLReflowState reflowState(aFloaterFrame, aState, kidAvailSize, - eReflowReason_Initial); + nsHTMLReflowState reflowState(aPresContext, aFloaterFrame, aState, + kidAvailSize, eReflowReason_Initial); // Compute the available space for the floater. Use the default // 'auto' width and height values diff --git a/mozilla/layout/html/base/src/nsBlockReflowState.cpp b/mozilla/layout/html/base/src/nsBlockReflowState.cpp index c25cee2af37..f75b702afc5 100644 --- a/mozilla/layout/html/base/src/nsBlockReflowState.cpp +++ b/mozilla/layout/html/base/src/nsBlockReflowState.cpp @@ -157,9 +157,6 @@ struct nsBlockReflowState : public nsFrameReflowState { PRUint8 mTextAlign; PRUint8 mPrevMarginFlags; - nsSize mStyleSize; - PRIntn mStyleSizeFlags; - nscoord mBottomEdge; // maximum Y PRBool mUnconstrainedWidth; @@ -1317,18 +1314,12 @@ nsBlockReflowState::nsBlockReflowState(nsIPresContext& aPresContext, nscoord lr = mBorderPadding.left + mBorderPadding.right; mY = mBorderPadding.top; - - // Get and apply the stylistic size. Note: do not limit the - // height until we are done reflowing. - PRIntn ss = nsCSSLayout::GetStyleSize(&aPresContext, aReflowState, - mStyleSize); - mStyleSizeFlags = ss; - if (0 != (ss & NS_SIZE_HAS_WIDTH)) { - // The CSS2 spec says that the width attribute defines the - // width of the "content area" which does not include the - // border padding. So we add those back in. - mBorderArea.width = mStyleSize.width + lr; - mContentArea.width = mStyleSize.width; + if (eHTMLFrameConstraint_Unconstrained != widthConstraint) { + // The CSS2 spec says that the width attribute defines the width + // of the "content area" which does not include the border + // padding. So we add those back in. + mBorderArea.width = minWidth + lr; + mContentArea.width = minWidth; } else { if (mUnconstrainedWidth) { @@ -1835,11 +1826,10 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, nsHTMLReflowMetrics& aMetrics) { // Compute final width - PRIntn ss = aState.mStyleSizeFlags; - if (NS_SIZE_HAS_WIDTH & ss) { + if (eHTMLFrameConstraint_Unconstrained != aState.widthConstraint) { // Use style defined width aMetrics.width = aState.mBorderPadding.left + - aState.mStyleSize.width + aState.mBorderPadding.right; + aState.minWidth + aState.mBorderPadding.right; } else { // There are two options here. We either shrink wrap around our @@ -1856,10 +1846,10 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, } // Compute final height - if (NS_SIZE_HAS_HEIGHT & ss) { + if (eHTMLFrameConstraint_Unconstrained != aState.heightConstraint) { // Use style defined height aMetrics.height = aState.mBorderPadding.top + - aState.mStyleSize.height + aState.mBorderPadding.bottom; + aState.minHeight + aState.mBorderPadding.bottom; } else { // Shrink wrap our height around our contents. @@ -1896,7 +1886,8 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, // Special check for zero sized content: If our content is zero // sized then we collapse into nothingness. - if ((NS_SIZE_HAS_BOTH != ss) && + if ((eHTMLFrameConstraint_Unconstrained == aState.widthConstraint) && + (eHTMLFrameConstraint_Unconstrained == aState.heightConstraint) && ((0 == aState.mKidXMost - aState.mBorderPadding.left) || (0 == aState.mY - aState.mBorderPadding.top))) { aMetrics.width = 0; @@ -3388,7 +3379,8 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState, nsSize availSize; availSize.width = NS_UNCONSTRAINEDSIZE; availSize.height = NS_UNCONSTRAINEDSIZE; - nsHTMLReflowState reflowState(mBullet, aState, availSize, &aState.mLineLayout); + nsHTMLReflowState reflowState(aState.mPresContext, mBullet, aState, + availSize, &aState.mLineLayout); nsHTMLReflowMetrics metrics(nsnull); nsIHTMLReflow* htmlReflow; if (NS_OK == mBullet->QueryInterface(kIHTMLReflowIID, (void**) &htmlReflow)) { @@ -3883,8 +3875,8 @@ nsBlockFrame::ReflowFloater(nsIPresContext& aPresContext, // it's maxSize will be 0,0 until we compute it (we need the reflowState // for nsLayout::GetStyleSize so we have to do this first) nsSize kidAvailSize(0, 0); - nsHTMLReflowState reflowState(aFloaterFrame, aState, kidAvailSize, - eReflowReason_Initial); + nsHTMLReflowState reflowState(aPresContext, aFloaterFrame, aState, + kidAvailSize, eReflowReason_Initial); // Compute the available space for the floater. Use the default // 'auto' width and height values diff --git a/mozilla/layout/html/base/src/nsBlockReflowState.h b/mozilla/layout/html/base/src/nsBlockReflowState.h index c25cee2af37..f75b702afc5 100644 --- a/mozilla/layout/html/base/src/nsBlockReflowState.h +++ b/mozilla/layout/html/base/src/nsBlockReflowState.h @@ -157,9 +157,6 @@ struct nsBlockReflowState : public nsFrameReflowState { PRUint8 mTextAlign; PRUint8 mPrevMarginFlags; - nsSize mStyleSize; - PRIntn mStyleSizeFlags; - nscoord mBottomEdge; // maximum Y PRBool mUnconstrainedWidth; @@ -1317,18 +1314,12 @@ nsBlockReflowState::nsBlockReflowState(nsIPresContext& aPresContext, nscoord lr = mBorderPadding.left + mBorderPadding.right; mY = mBorderPadding.top; - - // Get and apply the stylistic size. Note: do not limit the - // height until we are done reflowing. - PRIntn ss = nsCSSLayout::GetStyleSize(&aPresContext, aReflowState, - mStyleSize); - mStyleSizeFlags = ss; - if (0 != (ss & NS_SIZE_HAS_WIDTH)) { - // The CSS2 spec says that the width attribute defines the - // width of the "content area" which does not include the - // border padding. So we add those back in. - mBorderArea.width = mStyleSize.width + lr; - mContentArea.width = mStyleSize.width; + if (eHTMLFrameConstraint_Unconstrained != widthConstraint) { + // The CSS2 spec says that the width attribute defines the width + // of the "content area" which does not include the border + // padding. So we add those back in. + mBorderArea.width = minWidth + lr; + mContentArea.width = minWidth; } else { if (mUnconstrainedWidth) { @@ -1835,11 +1826,10 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, nsHTMLReflowMetrics& aMetrics) { // Compute final width - PRIntn ss = aState.mStyleSizeFlags; - if (NS_SIZE_HAS_WIDTH & ss) { + if (eHTMLFrameConstraint_Unconstrained != aState.widthConstraint) { // Use style defined width aMetrics.width = aState.mBorderPadding.left + - aState.mStyleSize.width + aState.mBorderPadding.right; + aState.minWidth + aState.mBorderPadding.right; } else { // There are two options here. We either shrink wrap around our @@ -1856,10 +1846,10 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, } // Compute final height - if (NS_SIZE_HAS_HEIGHT & ss) { + if (eHTMLFrameConstraint_Unconstrained != aState.heightConstraint) { // Use style defined height aMetrics.height = aState.mBorderPadding.top + - aState.mStyleSize.height + aState.mBorderPadding.bottom; + aState.minHeight + aState.mBorderPadding.bottom; } else { // Shrink wrap our height around our contents. @@ -1896,7 +1886,8 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, // Special check for zero sized content: If our content is zero // sized then we collapse into nothingness. - if ((NS_SIZE_HAS_BOTH != ss) && + if ((eHTMLFrameConstraint_Unconstrained == aState.widthConstraint) && + (eHTMLFrameConstraint_Unconstrained == aState.heightConstraint) && ((0 == aState.mKidXMost - aState.mBorderPadding.left) || (0 == aState.mY - aState.mBorderPadding.top))) { aMetrics.width = 0; @@ -3388,7 +3379,8 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState, nsSize availSize; availSize.width = NS_UNCONSTRAINEDSIZE; availSize.height = NS_UNCONSTRAINEDSIZE; - nsHTMLReflowState reflowState(mBullet, aState, availSize, &aState.mLineLayout); + nsHTMLReflowState reflowState(aState.mPresContext, mBullet, aState, + availSize, &aState.mLineLayout); nsHTMLReflowMetrics metrics(nsnull); nsIHTMLReflow* htmlReflow; if (NS_OK == mBullet->QueryInterface(kIHTMLReflowIID, (void**) &htmlReflow)) { @@ -3883,8 +3875,8 @@ nsBlockFrame::ReflowFloater(nsIPresContext& aPresContext, // it's maxSize will be 0,0 until we compute it (we need the reflowState // for nsLayout::GetStyleSize so we have to do this first) nsSize kidAvailSize(0, 0); - nsHTMLReflowState reflowState(aFloaterFrame, aState, kidAvailSize, - eReflowReason_Initial); + nsHTMLReflowState reflowState(aPresContext, aFloaterFrame, aState, + kidAvailSize, eReflowReason_Initial); // Compute the available space for the floater. Use the default // 'auto' width and height values diff --git a/mozilla/layout/html/base/src/nsBodyFrame.cpp b/mozilla/layout/html/base/src/nsBodyFrame.cpp index 0749c6cc3c9..f0c7e1588df 100644 --- a/mozilla/layout/html/base/src/nsBodyFrame.cpp +++ b/mozilla/layout/html/base/src/nsBodyFrame.cpp @@ -185,7 +185,8 @@ nsBodyFrame::Reflow(nsIPresContext& aPresContext, // compute the available space and compute the origin... nsIHTMLReflow* reflow; if (NS_OK == nextFrame->QueryInterface(kIHTMLReflowIID, (void**)&reflow)) { - nsHTMLReflowState reflowState(nextFrame, aReflowState, aReflowState.maxSize); + nsHTMLReflowState reflowState(aPresContext, nextFrame, aReflowState, + aReflowState.maxSize); reflowState.spaceManager = mSpaceManager; reflow->WillReflow(aPresContext); nsresult rv = reflow->Reflow(aPresContext, aDesiredSize, reflowState, aStatus); @@ -249,7 +250,7 @@ nsBodyFrame::Reflow(nsIPresContext& aPresContext, mFirstChild->GetRect(kidOldRect); // Get the column's desired size - nsHTMLReflowState reflowState(mFirstChild, *rsp, kidMaxSize); + nsHTMLReflowState reflowState(aPresContext, mFirstChild, *rsp, kidMaxSize); reflowState.spaceManager = mSpaceManager; nsIHTMLReflow* htmlReflow; @@ -281,7 +282,7 @@ nsBodyFrame::Reflow(nsIPresContext& aPresContext, mFirstChild->SetRect(desiredRect); // Reflow any absolutely positioned frames that need reflowing - ReflowAbsoluteItems(&aPresContext, *rsp); + ReflowAbsoluteItems(aPresContext, *rsp); // Return our desired size ComputeDesiredSize(aPresContext, aReflowState, desiredRect, @@ -672,8 +673,9 @@ NS_METHOD nsBodyFrame::RemoveAbsoluteItem(nsAbsoluteFrame* aAnchorFrame) // Called at the end of the Reflow() member function so we can process // any abolutely positioned items that need to be reflowed -void nsBodyFrame::ReflowAbsoluteItems(nsIPresContext* aPresContext, - const nsHTMLReflowState& aReflowState) +void +nsBodyFrame::ReflowAbsoluteItems(nsIPresContext& aPresContext, + const nsHTMLReflowState& aReflowState) { for (PRInt32 i = 0; i < mAbsoluteItems.Count(); i++) { // Get the anchor frame and its absolutely positioned frame @@ -741,7 +743,7 @@ void nsBodyFrame::ReflowAbsoluteItems(nsIPresContext* aPresContext, nsIHTMLReflow* htmlReflow; if (NS_OK == absoluteFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { - htmlReflow->WillReflow(*aPresContext); + htmlReflow->WillReflow(aPresContext); absoluteFrame->MoveTo(rect.x, rect.y); if (reflowFrame) { @@ -755,10 +757,11 @@ void nsBodyFrame::ReflowAbsoluteItems(nsIPresContext* aPresContext, } nsHTMLReflowMetrics desiredSize(nsnull); - nsHTMLReflowState reflowState(absoluteFrame, aReflowState, availSize, + nsHTMLReflowState reflowState(aPresContext, absoluteFrame, + aReflowState, availSize, reflowReason); nsReflowStatus status; - htmlReflow->Reflow(*aPresContext, desiredSize, reflowState, status); + htmlReflow->Reflow(aPresContext, desiredSize, reflowState, status); // Figure out what size to actually use. If we let the child choose its // size, then use what the child requested. Otherwise, use the value diff --git a/mozilla/layout/html/base/src/nsBodyFrame.h b/mozilla/layout/html/base/src/nsBodyFrame.h index 46fe0d9bb8e..c38e783c9ae 100644 --- a/mozilla/layout/html/base/src/nsBodyFrame.h +++ b/mozilla/layout/html/base/src/nsBodyFrame.h @@ -93,7 +93,7 @@ protected: virtual PRIntn GetSkipSides() const; - void ReflowAbsoluteItems(nsIPresContext* aPresContext, + void ReflowAbsoluteItems(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState); nsIView* CreateAbsoluteView(const nsStylePosition* aPosition, diff --git a/mozilla/layout/html/base/src/nsFrameReflowState.cpp b/mozilla/layout/html/base/src/nsFrameReflowState.cpp index d7180477907..adb124ef966 100644 --- a/mozilla/layout/html/base/src/nsFrameReflowState.cpp +++ b/mozilla/layout/html/base/src/nsFrameReflowState.cpp @@ -22,6 +22,204 @@ #include "nsIFrame.h" #include "nsIHTMLReflow.h" #include "nsIContent.h" +#include "nsHTMLAtoms.h" + +// XXX there is no CLEAN way to detect the "replaced" attribute (yet) +void +nsHTMLReflowState::DetermineFrameType(nsIPresContext& aPresContext) +{ + nsIAtom* tag = nsnull; + nsIContent* content; + if ((NS_OK == frame->GetContent(content)) && (nsnull != content)) { + content->GetTag(tag); + NS_RELEASE(content); + } + + // Section 9.7 indicates that absolute position takes precedence + // over float which takes precedence over display. + const nsStyleDisplay* display; + frame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display); + const nsStylePosition* pos; + frame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&)pos); + if ((nsnull != pos) && (NS_STYLE_POSITION_ABSOLUTE == pos->mPosition)) { + // XXX replaced? + frameType = eCSSFrameType_Absolute; + } + else if (NS_STYLE_FLOAT_NONE != display->mFloats) { + // XXX replaced? + frameType = eCSSFrameType_Floating; + } + else { + switch (display->mDisplay) { + case NS_STYLE_DISPLAY_BLOCK: + case NS_STYLE_DISPLAY_LIST_ITEM: + case NS_STYLE_DISPLAY_TABLE: + case NS_STYLE_DISPLAY_TABLE_CELL: + case NS_STYLE_DISPLAY_TABLE_CAPTION: + frameType = eCSSFrameType_Block; + break; + + case NS_STYLE_DISPLAY_INLINE: + case NS_STYLE_DISPLAY_MARKER: + case NS_STYLE_DISPLAY_INLINE_TABLE: + if ((nsHTMLAtoms::img == tag) || + (nsHTMLAtoms::applet == tag) || + (nsHTMLAtoms::object == tag)) { + frameType = eCSSFrameType_InlineReplaced; + } + frameType = eCSSFrameType_Inline; + break; + + case NS_STYLE_DISPLAY_RUN_IN: + case NS_STYLE_DISPLAY_COMPACT: + // XXX need to look ahead at the frame's sibling + frameType = eCSSFrameType_Block; + break; + + case NS_STYLE_DISPLAY_TABLE_ROW_GROUP: + case NS_STYLE_DISPLAY_TABLE_COLUMN: + case NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP: + case NS_STYLE_DISPLAY_TABLE_HEADER_GROUP: + case NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP: + case NS_STYLE_DISPLAY_TABLE_ROW: + // XXX I don't know what to do about these yet...later + frameType = eCSSFrameType_Inline; + break; + + case NS_STYLE_DISPLAY_NONE: + default: + frameType = eCSSFrameType_Unknown; + break; + } + NS_IF_RELEASE(tag); + } +} + +void +nsHTMLReflowState::InitConstraints(nsIPresContext& aPresContext) +{ + // Assume that the values are unconstrained + widthConstraint = eHTMLFrameConstraint_Unconstrained; + heightConstraint = eHTMLFrameConstraint_Unconstrained; + + // Some frame types are not constrained by width/height style + // attributes. Return if the frame is one of those types. + switch (frameType) { + case eCSSFrameType_Unknown: + case eCSSFrameType_Inline: + return; + + default: + break; + } + + // Look for stylistic constraints on the width/height + const nsStylePosition* pos; + nsresult result = frame->GetStyleData(eStyleStruct_Position, + (const nsStyleStruct*&)pos); + if (NS_OK == result) { + nscoord containingBlockWidth, containingBlockHeight; + nscoord width = -1, height = -1; + PRIntn widthUnit = pos->mWidth.GetUnit(); + PRIntn heightUnit = pos->mHeight.GetUnit(); + + // When a percentage is specified we need to find the containing + // block to use as the basis for the percentage computation. + if ((eStyleUnit_Percent == widthUnit) || + (eStyleUnit_Percent == heightUnit)) { + // Find the containing block for this frame + nsIFrame* containingBlock = nsnull; + const nsReflowState* rs = parentReflowState; + while (nsnull != rs) { + if (nsnull != rs->frame) { + PRBool isContainingBlock; + if (NS_OK == rs->frame->IsPercentageBase(isContainingBlock)) { + if (isContainingBlock) { + containingBlock = rs->frame; + break; + } + } + } + rs = rs->parentReflowState; + } + + // If there is no containing block then pretend the width or + // height units are auto. + if (nsnull == containingBlock) { + if (eStyleUnit_Percent == widthUnit) { + widthUnit = eStyleUnit_Auto; + } + if (eStyleUnit_Percent == heightUnit) { + heightUnit = eStyleUnit_Auto; + } + } + else { + if (eStyleUnit_Percent == widthUnit) { + if (NS_UNCONSTRAINEDSIZE == rs->maxSize.width) { + // When we don't know the width (yet) of the containing + // block we use a dummy value, assuming that the frame + // depending on the percentage value will be reflowed a + // second time. + containingBlockWidth = 1; + } + else { + containingBlockWidth = rs->maxSize.width; + } + } + if (eStyleUnit_Percent == heightUnit) { + if (NS_UNCONSTRAINEDSIZE == rs->maxSize.height) { + // CSS2 spec, 10.5: if the height of the containing block + // is not specified explicitly then the value is + // interpreted like auto. + heightUnit = eStyleUnit_Auto; + } + else { + containingBlockHeight = rs->maxSize.height; + } + } + } + } + + switch (widthUnit) { + case eStyleUnit_Coord: + width = pos->mWidth.GetCoordValue(); + break; + case eStyleUnit_Percent: + width = nscoord(pos->mWidth.GetPercentValue() * containingBlockWidth); + break; + case eStyleUnit_Auto: + // XXX See section 10.3 of the css2 spec and then write this code! + break; + } + switch (heightUnit) { + case eStyleUnit_Coord: + height = pos->mHeight.GetCoordValue(); + break; + case eStyleUnit_Percent: + height = nscoord(pos->mHeight.GetPercentValue() * containingBlockHeight); + break; + case eStyleUnit_Auto: + // XXX See section 10.6 of the css2 spec and then write this code! + break; + } + + if (width > 0) { + minWidth = width; + maxWidth = width; + widthConstraint = eHTMLFrameConstraint_Constrained; + } + if (height > 0) { + minHeight = height; + maxHeight = height; + heightConstraint = eHTMLFrameConstraint_Constrained; + } + } + + // XXX this is probably a good place to calculate auto margins too + // (section 10.3/10.6 of the spec) +} + +//---------------------------------------------------------------------- nsFrameReflowState::nsFrameReflowState(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState, diff --git a/mozilla/layout/html/base/src/nsHTMLAtoms.cpp b/mozilla/layout/html/base/src/nsHTMLAtoms.cpp index 15a5ee9687b..664697ff836 100644 --- a/mozilla/layout/html/base/src/nsHTMLAtoms.cpp +++ b/mozilla/layout/html/base/src/nsHTMLAtoms.cpp @@ -101,6 +101,7 @@ nsIAtom* nsHTMLAtoms::h6; nsIAtom* nsHTMLAtoms::headers; nsIAtom* nsHTMLAtoms::height; nsIAtom* nsHTMLAtoms::hidden; +nsIAtom* nsHTMLAtoms::horizontalFramesetBorderPseudo; nsIAtom* nsHTMLAtoms::hover; nsIAtom* nsHTMLAtoms::hr; nsIAtom* nsHTMLAtoms::href; @@ -217,6 +218,7 @@ nsIAtom* nsHTMLAtoms::value; nsIAtom* nsHTMLAtoms::valuetype; nsIAtom* nsHTMLAtoms::variable; nsIAtom* nsHTMLAtoms::version; +nsIAtom* nsHTMLAtoms::verticalFramesetBorderPseudo; nsIAtom* nsHTMLAtoms::visibility; nsIAtom* nsHTMLAtoms::visited; nsIAtom* nsHTMLAtoms::vlink; @@ -314,6 +316,7 @@ void nsHTMLAtoms::AddrefAtoms() headers = NS_NewAtom("HEADERS"); height = NS_NewAtom("HEIGHT"); hidden = NS_NewAtom("HIDDEN"); + horizontalFramesetBorderPseudo = NS_NewAtom("HFRAMESETBORDER"); hover = NS_NewAtom("HOVER"); hr = NS_NewAtom("HR"); href = NS_NewAtom("HREF"); @@ -429,6 +432,7 @@ void nsHTMLAtoms::AddrefAtoms() valuetype = NS_NewAtom("VALUETYPE"); variable = NS_NewAtom("VARIABLE"); version = NS_NewAtom("VERSION"); + verticalFramesetBorderPseudo = NS_NewAtom("VFRAMESETBORDER"); visibility = NS_NewAtom("VISIBILITY"); visited = NS_NewAtom("VISITED"); vlink = NS_NewAtom("VLINK"); @@ -521,6 +525,7 @@ void nsHTMLAtoms::ReleaseAtoms() NS_RELEASE(headers); NS_RELEASE(height); NS_RELEASE(hidden); + NS_RELEASE(horizontalFramesetBorderPseudo); NS_RELEASE(hover); NS_RELEASE(hr); NS_RELEASE(href); @@ -632,6 +637,7 @@ void nsHTMLAtoms::ReleaseAtoms() NS_RELEASE(valuetype); NS_RELEASE(variable); NS_RELEASE(version); + NS_RELEASE(verticalFramesetBorderPseudo); NS_RELEASE(visibility); NS_RELEASE(visited); NS_RELEASE(vlink); diff --git a/mozilla/layout/html/base/src/nsHTMLAtoms.h b/mozilla/layout/html/base/src/nsHTMLAtoms.h index c65e06d5233..fe866cddc06 100644 --- a/mozilla/layout/html/base/src/nsHTMLAtoms.h +++ b/mozilla/layout/html/base/src/nsHTMLAtoms.h @@ -127,6 +127,7 @@ public: static nsIAtom* headers; static nsIAtom* height; static nsIAtom* hidden; + static nsIAtom* horizontalFramesetBorderPseudo; static nsIAtom* hover; static nsIAtom* hr; static nsIAtom* href; @@ -254,6 +255,7 @@ public: static nsIAtom* valuetype; static nsIAtom* variable; static nsIAtom* version; + static nsIAtom* verticalFramesetBorderPseudo; static nsIAtom* visibility; static nsIAtom* visited; static nsIAtom* vlink; diff --git a/mozilla/layout/html/base/src/nsHTMLFrame.cpp b/mozilla/layout/html/base/src/nsHTMLFrame.cpp index f40589bde2b..cd26792d729 100644 --- a/mozilla/layout/html/base/src/nsHTMLFrame.cpp +++ b/mozilla/layout/html/base/src/nsHTMLFrame.cpp @@ -147,8 +147,9 @@ RootFrame::Reflow(nsIPresContext& aPresContext, // wants if (nsnull != mFirstChild) { nsHTMLReflowMetrics desiredSize(nsnull); - nsHTMLReflowState kidReflowState(mFirstChild, aReflowState, aReflowState.maxSize); - nsIHTMLReflow* htmlReflow; + nsHTMLReflowState kidReflowState(aPresContext, mFirstChild, aReflowState, + aReflowState.maxSize); + nsIHTMLReflow* htmlReflow; if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { ReflowChild(mFirstChild, aPresContext, desiredSize, kidReflowState, aStatus); @@ -364,7 +365,8 @@ RootContentFrame::Reflow(nsIPresContext& aPresContext, NS_ASSERTION(next == mFirstChild, "unexpected next reflow command frame"); nsSize maxSize(availWidth, NS_UNCONSTRAINEDSIZE); - nsHTMLReflowState kidReflowState(next, aReflowState, maxSize); + nsHTMLReflowState kidReflowState(aPresContext, next, aReflowState, + maxSize); // Dispatch the reflow command to our child frame. Allow it to be as high // as it wants @@ -411,7 +413,8 @@ RootContentFrame::Reflow(nsIPresContext& aPresContext, // Tile the pages vertically for (nsIFrame* kidFrame = mFirstChild; nsnull != kidFrame; ) { // Reflow the page - nsHTMLReflowState kidReflowState(kidFrame, aReflowState, pageSize, + nsHTMLReflowState kidReflowState(aPresContext, kidFrame, + aReflowState, pageSize, reflowReason); nsReflowStatus status; @@ -466,7 +469,8 @@ RootContentFrame::Reflow(nsIPresContext& aPresContext, } else { nsSize maxSize(availWidth, NS_UNCONSTRAINEDSIZE); - nsHTMLReflowState kidReflowState(mFirstChild, aReflowState, maxSize, + nsHTMLReflowState kidReflowState(aPresContext, mFirstChild, + aReflowState, maxSize, reflowReason); // Get the child's desired size. Our child's desired height is our diff --git a/mozilla/layout/html/base/src/nsHTMLReflowCommand.cpp b/mozilla/layout/html/base/src/nsHTMLReflowCommand.cpp index 13e200f742d..834892f3e2f 100644 --- a/mozilla/layout/html/base/src/nsHTMLReflowCommand.cpp +++ b/mozilla/layout/html/base/src/nsHTMLReflowCommand.cpp @@ -156,7 +156,8 @@ NS_IMETHODIMP nsHTMLReflowCommand::Dispatch(nsIPresContext& aPresContext, if (nsnull != root) { mPath.RemoveElementAt(mPath.Count() - 1); - nsHTMLReflowState reflowState(root, *this, aMaxSize, &aRendContext); + nsHTMLReflowState reflowState(aPresContext, root, *this, aMaxSize, + &aRendContext); nsIHTMLReflow* htmlReflow; nsReflowStatus status; diff --git a/mozilla/layout/html/base/src/nsIHTMLReflow.h b/mozilla/layout/html/base/src/nsIHTMLReflow.h index 0fec8ff4625..a0ea48c0f55 100644 --- a/mozilla/layout/html/base/src/nsIHTMLReflow.h +++ b/mozilla/layout/html/base/src/nsIHTMLReflow.h @@ -60,62 +60,99 @@ struct nsHTMLReflowMetrics : nsReflowMetrics { //---------------------------------------------------------------------- /** - * The type of size constraint that applies to a particular dimension. - * For the fixed and fixed content cases the min size in the reflow state - * structure is ignored and you should use the max size value when reflowing - * the frame. + * The type of size constraint that applies to a particular + * dimension. For the fixed and fixed content cases the min/max + * width/height in the reflow state structure is ignored and you + * should use the max size value when reflowing the frame. * * @see nsHTMLReflowState */ -//XXX enum's are prefixed wrong -enum nsReflowConstraint { - eReflowSize_Unconstrained = 0, // choose whatever frame size you want - eReflowSize_Constrained = 1, // choose a frame size between the min and max sizes - eReflowSize_Fixed = 2, // frame size is fixed - eReflowSize_FixedContent = 3 // size of your content area is fixed +enum nsHTMLFrameConstraint { + // Choose whatever frame size you want (there is no stylistic limitation + // on the size of the frame) + eHTMLFrameConstraint_Unconstrained, + + // Choose a frame size between the min and max sizes + eHTMLFrameConstraint_Constrained, + + // Frame size is fixed. The nsReflowState::maxSize.width value + // determines the fixed width. + eHTMLFrameConstraint_Fixed, + + // Content size is fixed. The nsReflowState::maxSize.width value + // determines the fixed width. + eHTMLFrameConstraint_FixedContent }; //---------------------------------------------------------------------- /** - * Frame type. Included as part of the reflow state. + * CSS Frame type. Included as part of the reflow state. * * @see nsHTMLReflowState * * XXX This requires some more thought. Are these the correct set? * XXX Should we treat 'replaced' as a bit flag instead of doubling the * number of enumerators? - * XXX Should the name be nsCSSReflowFrameType? */ -enum nsReflowFrameType { - eReflowType_Inline = 0, // inline, non-replaced elements - eReflowType_InlineReplaced = 1, // inline, replaced elements (e.g., image) - eReflowType_Block = 2, // block-level, non-replaced elements in normal flow - eReflowType_BlockReplaced = 3, // block-level, replaced elements in normal flow - eReflowType_Floating = 4, // floating, non-replaced elements - eReflowType_FloatingReplaced = 5, // floating, replaced elements - eReflowType_Absolute = 6, // absolutely positioned, non-replaced elements - eReflowType_AbsoluteReplaced = 7 // absolutely positioned, replaced elements +enum nsCSSFrameType { + // unknown frame type + eCSSFrameType_Unknown, + + // inline, non-replaced elements + eCSSFrameType_Inline, + + // inline, replaced elements (e.g., image) + eCSSFrameType_InlineReplaced, + + // block-level, non-replaced elements in normal flow + eCSSFrameType_Block, + + // block-level, replaced elements in normal flow + eCSSFrameType_BlockReplaced, + + // floating, non-replaced elements + eCSSFrameType_Floating, + + // floating, replaced elements + eCSSFrameType_FloatingReplaced, + + // absolutely positioned, non-replaced elements + eCSSFrameType_Absolute, + + // absolutely positioned, replaced elements + eCSSFrameType_AbsoluteReplaced }; //---------------------------------------------------------------------- +/** + * HTML version of the reflow state. + * + * Note: the constructors are implemented inline later on in this file + */ struct nsHTMLReflowState : nsReflowState { - nsReflowFrameType frameType; - nsISpaceManager* spaceManager; - nsLineLayout* lineLayout; // only for inline reflow (set to NULL otherwise) + // The type of frame, from css's perspective. This value is + // initialized by the Init method below. + nsCSSFrameType frameType; - // XXX None of this is currently being used... -#if 0 - nsReflowConstraint widthConstraint; // constraint that applies to width dimension - nsReflowConstraint heightConstraint; // constraint that applies to height dimension - nsSize minSize; // the min available space in which to reflow. - // Only used for eReflowSize_Constrained -#endif + nsISpaceManager* spaceManager; + + // LineLayout object (only for inline reflow; set to NULL otherwise) + nsLineLayout* lineLayout; + + // Constraint that applies to width dimension + nsHTMLFrameConstraint widthConstraint; + nscoord minWidth, maxWidth; + + // Constraint that applies to height dimension + nsHTMLFrameConstraint heightConstraint; + nscoord minHeight, maxHeight; // Constructs an initial reflow state (no parent reflow state) for a // non-incremental reflow command. Sets reflowType to eReflowType_Block - nsHTMLReflowState(nsIFrame* aFrame, + nsHTMLReflowState(nsIPresContext& aPresContext, + nsIFrame* aFrame, nsReflowReason aReason, const nsSize& aMaxSize, nsIRenderingContext* aContext, @@ -123,7 +160,8 @@ struct nsHTMLReflowState : nsReflowState { // Constructs an initial reflow state (no parent reflow state) for an // incremental reflow command. Sets reflowType to eReflowType_Block - nsHTMLReflowState(nsIFrame* aFrame, + nsHTMLReflowState(nsIPresContext& aPresContext, + nsIFrame* aFrame, nsIReflowCommand& aReflowCommand, const nsSize& aMaxSize, nsIRenderingContext* aContext, @@ -133,16 +171,17 @@ struct nsHTMLReflowState : nsReflowState { // max size. Uses the reflow reason, space manager, reflow command, and // line layout from the parent's reflow state. Defaults to a reflow // frame type of eReflowType_Block - nsHTMLReflowState(nsIFrame* aFrame, + nsHTMLReflowState(nsIPresContext& aPresContext, + nsIFrame* aFrame, const nsHTMLReflowState& aParentReflowState, - const nsSize& aMaxSize, - nsReflowFrameType aFrameType = eReflowType_Block); + const nsSize& aMaxSize); // Construct a reflow state for the given inline frame, parent // reflow state, and max size. Uses the reflow reason, space // manager, and reflow command from the parent's reflow state. Sets // the reflow frame type to eReflowType_Inline - nsHTMLReflowState(nsIFrame* aFrame, + nsHTMLReflowState(nsIPresContext& aPresContext, + nsIFrame* aFrame, const nsHTMLReflowState& aParentReflowState, const nsSize& aMaxSize, nsLineLayout* aLineLayout); @@ -151,11 +190,25 @@ struct nsHTMLReflowState : nsReflowState { // reflow state. Uses the space manager from the parent's reflow state and // sets the reflow command to NULL. Sets lineLayout to NULL, and defaults to // a reflow frame type of eReflowType_Block - nsHTMLReflowState(nsIFrame* aFrame, + nsHTMLReflowState(nsIPresContext& aPresContext, + nsIFrame* aFrame, const nsHTMLReflowState& aParentReflowState, const nsSize& aMaxSize, - nsReflowReason aReflowReason, - nsReflowFrameType aFrameType = eReflowType_Block); + nsReflowReason aReflowReason); + +protected: + // This method initializes the widthConstraint, heightConstraint and + // minSize values appropriately. It also initializes the frameType + // value as well. This method is automatically called by the various + // constructors. + void Init(nsIPresContext& aPresContext) { + DetermineFrameType(aPresContext); + InitConstraints(aPresContext); + } + + void DetermineFrameType(nsIPresContext& aPresContext); + + void InitConstraints(nsIPresContext& aPresContext); }; //---------------------------------------------------------------------- @@ -224,31 +277,33 @@ public: // Constructs an initial reflow state (no parent reflow state) for a // non-incremental reflow command. Sets reflowType to eReflowType_Block inline -nsHTMLReflowState::nsHTMLReflowState(nsIFrame* aFrame, +nsHTMLReflowState::nsHTMLReflowState(nsIPresContext& aPresContext, + nsIFrame* aFrame, nsReflowReason aReason, const nsSize& aMaxSize, nsIRenderingContext* aContext, nsISpaceManager* aSpaceManager) : nsReflowState(aFrame, aReason, aMaxSize, aContext) { - frameType = eReflowType_Block; spaceManager = aSpaceManager; lineLayout = nsnull; + Init(aPresContext); } // Constructs an initial reflow state (no parent reflow state) for an // incremental reflow command. Sets reflowType to eReflowType_Block inline -nsHTMLReflowState::nsHTMLReflowState(nsIFrame* aFrame, +nsHTMLReflowState::nsHTMLReflowState(nsIPresContext& aPresContext, + nsIFrame* aFrame, nsIReflowCommand& aReflowCommand, const nsSize& aMaxSize, nsIRenderingContext* aContext, nsISpaceManager* aSpaceManager) : nsReflowState(aFrame, aReflowCommand, aMaxSize, aContext) { - frameType = eReflowType_Block; spaceManager = aSpaceManager; lineLayout = nsnull; + Init(aPresContext); } // Construct a reflow state for the given frame, parent reflow state, and @@ -256,30 +311,31 @@ nsHTMLReflowState::nsHTMLReflowState(nsIFrame* aFrame, // line layout from the parent's reflow state. Defaults to a reflow // frame type of eReflowType_Block inline -nsHTMLReflowState::nsHTMLReflowState(nsIFrame* aFrame, - const nsHTMLReflowState& aParentReflowState, - const nsSize& aMaxSize, - nsReflowFrameType aFrameType) - : nsReflowState(aFrame, aParentReflowState, aMaxSize) +nsHTMLReflowState::nsHTMLReflowState(nsIPresContext& aPresContext, + nsIFrame* aFrame, + const nsHTMLReflowState& aParentState, + const nsSize& aMaxSize) + : nsReflowState(aFrame, aParentState, aMaxSize) { - frameType = aFrameType; - spaceManager = aParentReflowState.spaceManager; - lineLayout = aParentReflowState.lineLayout; + spaceManager = aParentState.spaceManager; + lineLayout = aParentState.lineLayout; + Init(aPresContext); } // Construct a reflow state for the given inline frame, parent reflow state, // and max size. Uses the reflow reason, space manager, and reflow command from // the parent's reflow state. Sets the reflow frame type to eReflowType_Inline inline -nsHTMLReflowState::nsHTMLReflowState(nsIFrame* aFrame, - const nsHTMLReflowState& aParentReflowState, +nsHTMLReflowState::nsHTMLReflowState(nsIPresContext& aPresContext, + nsIFrame* aFrame, + const nsHTMLReflowState& aParentState, const nsSize& aMaxSize, nsLineLayout* aLineLayout) - : nsReflowState(aFrame, aParentReflowState, aMaxSize) + : nsReflowState(aFrame, aParentState, aMaxSize) { - frameType = eReflowType_Inline; - spaceManager = aParentReflowState.spaceManager; + spaceManager = aParentState.spaceManager; lineLayout = aLineLayout; + Init(aPresContext); } // Constructs a reflow state that overrides the reflow reason of the parent @@ -287,18 +343,16 @@ nsHTMLReflowState::nsHTMLReflowState(nsIFrame* aFrame, // sets the reflow command to NULL. Sets lineLayout to NULL, and defaults to // a reflow frame type of eReflowType_Block inline -nsHTMLReflowState::nsHTMLReflowState(nsIFrame* aFrame, - const nsHTMLReflowState& aParentReflowState, +nsHTMLReflowState::nsHTMLReflowState(nsIPresContext& aPresContext, + nsIFrame* aFrame, + const nsHTMLReflowState& aParentState, const nsSize& aMaxSize, - nsReflowReason aReflowReason, - nsReflowFrameType aFrameType) - : nsReflowState(aFrame, aParentReflowState, aMaxSize, aReflowReason) + nsReflowReason aReflowReason) + : nsReflowState(aFrame, aParentState, aMaxSize, aReflowReason) { - frameType = aFrameType; - spaceManager = aParentReflowState.spaceManager; + spaceManager = aParentState.spaceManager; lineLayout = nsnull; + Init(aPresContext); } #endif /* nsIHTMLReflow_h___ */ - - diff --git a/mozilla/layout/html/base/src/nsInlineFrame.cpp b/mozilla/layout/html/base/src/nsInlineFrame.cpp index a87e138b1b9..39824666e0b 100644 --- a/mozilla/layout/html/base/src/nsInlineFrame.cpp +++ b/mozilla/layout/html/base/src/nsInlineFrame.cpp @@ -214,7 +214,11 @@ NS_IMETHODIMP nsInlineFrame::Init(nsIPresContext& aPresContext, nsIFrame* aChildList) { NS_PRECONDITION(nsnull == mFirstChild, "already initialized"); - return AppendNewFrames(aPresContext, aChildList); + nsresult rv = AppendNewFrames(aPresContext, aChildList); + if (NS_OK != rv) { + return rv; + } + return rv; } NS_IMETHODIMP diff --git a/mozilla/layout/html/base/src/nsInlineReflow.cpp b/mozilla/layout/html/base/src/nsInlineReflow.cpp index 4b5b89c4a6c..c63b1a5d71f 100644 --- a/mozilla/layout/html/base/src/nsInlineReflow.cpp +++ b/mozilla/layout/html/base/src/nsInlineReflow.cpp @@ -403,10 +403,11 @@ nsInlineReflow::ReflowFrame(nsHTMLReflowMetrics& aMetrics, } // Setup reflow state for reflowing the frame - nsHTMLReflowState reflowState(mFrame, mOuterReflowState, mFrameAvailSize); + nsHTMLReflowState reflowState(mPresContext, mFrame, mOuterReflowState, + mFrameAvailSize); if (!mTreatFrameAsBlock) { mIsInlineAware = PR_TRUE; - reflowState.frameType = eReflowType_Inline; +//XX reflowState.frameType = eReflowType_Inline; reflowState.lineLayout = &mLineLayout; } reflowState.reason = reason; diff --git a/mozilla/layout/html/base/src/nsPageFrame.cpp b/mozilla/layout/html/base/src/nsPageFrame.cpp index 87230a8b332..6cd9fa1e06c 100644 --- a/mozilla/layout/html/base/src/nsPageFrame.cpp +++ b/mozilla/layout/html/base/src/nsPageFrame.cpp @@ -90,7 +90,8 @@ NS_METHOD nsPageFrame::Reflow(nsIPresContext& aPresContext, // Dispatch the reflow command to our content child. Allow it to be as high // as it wants nsSize maxSize(aReflowState.maxSize.width, NS_UNCONSTRAINEDSIZE); - nsHTMLReflowState kidReflowState(mFirstChild, aReflowState, maxSize); + nsHTMLReflowState kidReflowState(aPresContext, mFirstChild, aReflowState, + maxSize); ReflowChild(mFirstChild, aPresContext, aDesiredSize, kidReflowState, aStatus); @@ -126,7 +127,8 @@ NS_METHOD nsPageFrame::Reflow(nsIPresContext& aPresContext, // Resize our frame allowing it only to be as big as we are // XXX Pay attention to the page's border and padding... if (nsnull != mFirstChild) { - nsHTMLReflowState kidReflowState(mFirstChild, aReflowState, aReflowState.maxSize); + nsHTMLReflowState kidReflowState(aPresContext, mFirstChild, aReflowState, + aReflowState.maxSize); nsIHTMLReflow* htmlReflow; if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index e0cd1d4d618..ee79dda90a4 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -506,7 +506,8 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight) CreateRenderingContext(mRootFrame, rcx); - nsHTMLReflowState reflowState(mRootFrame, eReflowReason_Initial, maxSize, rcx); + nsHTMLReflowState reflowState(*mPresContext, mRootFrame, + eReflowReason_Initial, maxSize, rcx); if (NS_OK == mRootFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { htmlReflow->Reflow(*mPresContext, desiredSize, reflowState, status); @@ -557,7 +558,8 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight) CreateRenderingContext(mRootFrame, rcx); - nsHTMLReflowState reflowState(mRootFrame, eReflowReason_Resize, maxSize, rcx); + nsHTMLReflowState reflowState(*mPresContext, mRootFrame, + eReflowReason_Resize, maxSize, rcx); if (NS_OK == mRootFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { htmlReflow->Reflow(*mPresContext, desiredSize, reflowState, status); diff --git a/mozilla/layout/html/base/src/nsScrollFrame.cpp b/mozilla/layout/html/base/src/nsScrollFrame.cpp index 9f508fde9e9..633d2a87f47 100644 --- a/mozilla/layout/html/base/src/nsScrollFrame.cpp +++ b/mozilla/layout/html/base/src/nsScrollFrame.cpp @@ -121,7 +121,7 @@ nsScrollBodyFrame::Reflow(nsIPresContext& aPresContext, NS_ASSERTION(next == mFirstChild, "unexpected next reflow command frame"); nsSize maxSize(aReflowState.maxSize.width, NS_UNCONSTRAINEDSIZE); - nsHTMLReflowState kidReflowState(next, aReflowState, maxSize); + nsHTMLReflowState kidReflowState(aPresContext, next, aReflowState, maxSize); nsIHTMLReflow* htmlReflow; if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { @@ -159,7 +159,7 @@ nsScrollBodyFrame::Reflow(nsIPresContext& aPresContext, // Tile the pages vertically for (nsIFrame* kidFrame = mFirstChild; nsnull != kidFrame; ) { // Reflow the page - nsHTMLReflowState kidReflowState(kidFrame, aReflowState, pageSize); + nsHTMLReflowState kidReflowState(aPresContext, kidFrame, aReflowState, pageSize); nsReflowStatus status; // Place and size the page. If the page is narrower than our @@ -223,7 +223,7 @@ nsScrollBodyFrame::Reflow(nsIPresContext& aPresContext, // Allow the frame to be as wide as our max width, and as high // as it wants to be. nsSize maxSize(aReflowState.maxSize.width, NS_UNCONSTRAINEDSIZE); - nsHTMLReflowState kidReflowState(mFirstChild, aReflowState, maxSize); + nsHTMLReflowState kidReflowState(aPresContext, mFirstChild, aReflowState, maxSize); nsIHTMLReflow* htmlReflow; if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { @@ -386,7 +386,8 @@ nsScrollInnerFrame::Reflow(nsIPresContext& aPresContext, // Reflow the child nsHTMLReflowMetrics kidMetrics(aDesiredSize.maxElementSize); - nsHTMLReflowState kidReflowState(mFirstChild, aReflowState, maxSize); + + nsHTMLReflowState kidReflowState(aPresContext, mFirstChild, aReflowState, maxSize); nsIHTMLReflow* htmlReflow; if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { @@ -497,7 +498,7 @@ nsScrollOuterFrame::Reflow(nsIPresContext& aPresContext, } // Reflow the child and get its desired size - nsHTMLReflowState kidReflowState(mFirstChild, aReflowState, maxSize); + nsHTMLReflowState kidReflowState(aPresContext, mFirstChild, aReflowState, maxSize); nsIHTMLReflow* htmlReflow; if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { diff --git a/mozilla/layout/html/document/src/nsFrameFrame.cpp b/mozilla/layout/html/document/src/nsFrameFrame.cpp index 9fa1c8b3f59..a3762d2c2c3 100644 --- a/mozilla/layout/html/document/src/nsFrameFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameFrame.cpp @@ -324,7 +324,8 @@ nsHTMLFrameOuterFrame::Reflow(nsIPresContext& aPresContext, // Reflow the child and get its desired size nsHTMLReflowMetrics kidMetrics(aDesiredSize.maxElementSize); - nsHTMLReflowState kidReflowState(mFirstChild, aReflowState, innerSize); + nsHTMLReflowState kidReflowState(aPresContext, mFirstChild, aReflowState, + innerSize); nsIHTMLReflow* htmlReflow; if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { diff --git a/mozilla/layout/html/document/src/nsFrameSetFrame.cpp b/mozilla/layout/html/document/src/nsFrameSetFrame.cpp index 630e38cba37..b1d8886e4d9 100644 --- a/mozilla/layout/html/document/src/nsFrameSetFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameSetFrame.cpp @@ -670,7 +670,7 @@ nsHTMLFramesetFrame::ReflowPlaceChild(nsIFrame* aChild, } } - nsHTMLReflowState reflowState(aChild, aReflowState, aSize); + nsHTMLReflowState reflowState(aPresContext, aChild, aReflowState, aSize); nsIHTMLReflow* htmlReflow; if (NS_OK == aChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { @@ -1033,6 +1033,10 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext& aPresContext, if (borderWidth > 0) { if (firstTime) { // create horizontal border borderFrame = new nsHTMLFramesetBorderFrame(mContent, this, borderWidth, PR_FALSE, PR_FALSE); + nsIStyleContext* pseudoStyleContext = + aPresContext.ResolvePseudoStyleContextFor(nsHTMLAtoms::horizontalFramesetBorderPseudo, this); + borderFrame->SetStyleContext(&aPresContext, pseudoStyleContext); + mChildCount++; lastChild->SetNextSibling(borderFrame); lastChild = borderFrame; @@ -1053,6 +1057,10 @@ nsHTMLFramesetFrame::Reflow(nsIPresContext& aPresContext, if (0 == cellIndex.y) { // in 1st row if (firstTime) { // create vertical border borderFrame = new nsHTMLFramesetBorderFrame(mContent, this, borderWidth, PR_TRUE, PR_FALSE); + nsIStyleContext* pseudoStyleContext = + aPresContext.ResolvePseudoStyleContextFor(nsHTMLAtoms::verticalFramesetBorderPseudo, this); + borderFrame->SetStyleContext(&aPresContext, pseudoStyleContext); + mChildCount++; lastChild->SetNextSibling(borderFrame); lastChild = borderFrame; @@ -1400,7 +1408,8 @@ nsHTMLFramesetFrame::MouseDrag(nsIPresContext& aPresContext, nsGUIEvent* aEvent) shell = aPresContext.GetShell(); shell->CreateRenderingContext(this, acx); NS_RELEASE(shell); - nsHTMLReflowState state(this, eReflowReason_Initial, size, acx); + nsHTMLReflowState state(aPresContext, this, eReflowReason_Initial, + size, acx); state.reason = eReflowReason_Incremental; nsReflowStatus status; nsDidReflowStatus didStatus; diff --git a/mozilla/layout/html/forms/src/nsFieldSetFrame.cpp b/mozilla/layout/html/forms/src/nsFieldSetFrame.cpp index d73b68b82c8..dba2e8ba2d8 100644 --- a/mozilla/layout/html/forms/src/nsFieldSetFrame.cpp +++ b/mozilla/layout/html/forms/src/nsFieldSetFrame.cpp @@ -284,7 +284,8 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext, // Try to reflow the legend into the available space. It might not fit nsSize legendSize(0,0); if (mLegendFrame) { - nsHTMLReflowState legendReflowState(mLegendFrame, aReflowState, availSize); + nsHTMLReflowState legendReflowState(aPresContext, mLegendFrame, + aReflowState, availSize); ReflowChild(mLegendFrame, aPresContext, aDesiredSize, legendReflowState, aStatus); legendSize.width = aDesiredSize.width; @@ -307,7 +308,8 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext, // Try to reflow the content frame into the available space. It might not fit nsSize contentSize(0,0); - nsHTMLReflowState contentReflowState(mContentFrame, aReflowState, availSize); + nsHTMLReflowState contentReflowState(aPresContext, mContentFrame, + aReflowState, availSize); nscoord contentTopOffset = (legendSize.height > border.top) ? legendSize.height + padding.top : border.top + padding.top; @@ -328,7 +330,8 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext, // need to reflow the legend a 2nd time if (needAnotherLegendReflow && mLegendFrame) { - nsHTMLReflowState legendReflowState(mLegendFrame, aReflowState, availSize); + nsHTMLReflowState legendReflowState(aPresContext, mLegendFrame, + aReflowState, availSize); ReflowChild(mLegendFrame, aPresContext, aDesiredSize, legendReflowState, aStatus); legendSize.width = aDesiredSize.width; diff --git a/mozilla/layout/html/forms/src/nsFileControlFrame.cpp b/mozilla/layout/html/forms/src/nsFileControlFrame.cpp index 1bc824ef8a6..9e73c4fcc62 100644 --- a/mozilla/layout/html/forms/src/nsFileControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsFileControlFrame.cpp @@ -225,7 +225,8 @@ NS_IMETHODIMP nsFileControlFrame::Reflow(nsIPresContext& aPresContext, childFrame = mFirstChild; nsPoint offset(0,0); while (nsnull != childFrame) { // reflow, place, size the children - nsHTMLReflowState reflowState(childFrame, aReflowState, maxSize); + nsHTMLReflowState reflowState(aPresContext, childFrame, aReflowState, + maxSize); nsIHTMLReflow* htmlReflow; if (NS_OK == childFrame->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { diff --git a/mozilla/layout/html/forms/src/nsLegendFrame.cpp b/mozilla/layout/html/forms/src/nsLegendFrame.cpp index 71c3a75cdbf..bdc44428659 100644 --- a/mozilla/layout/html/forms/src/nsLegendFrame.cpp +++ b/mozilla/layout/html/forms/src/nsLegendFrame.cpp @@ -123,14 +123,15 @@ nsLegendFrame::Paint(nsIPresContext& aPresContext, NS_IMETHODIMP nsLegendFrame::Reflow(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - const nsHTMLReflowState& aReflowState, - nsReflowStatus& aStatus) + nsHTMLReflowMetrics& aDesiredSize, + const nsHTMLReflowState& aReflowState, + nsReflowStatus& aStatus) { nsSize availSize(aReflowState.maxSize); // reflow the child - nsHTMLReflowState reflowState(mFirstChild, aReflowState, availSize); + nsHTMLReflowState reflowState(aPresContext, mFirstChild, aReflowState, + availSize); ReflowChild(mFirstChild, aPresContext, aDesiredSize, reflowState, aStatus); // get border and padding diff --git a/mozilla/layout/html/style/src/nsCSSLayout.cpp b/mozilla/layout/html/style/src/nsCSSLayout.cpp index 91001ee39a3..9083aa529c8 100644 --- a/mozilla/layout/html/style/src/nsCSSLayout.cpp +++ b/mozilla/layout/html/style/src/nsCSSLayout.cpp @@ -122,6 +122,7 @@ nsCSSLayout::RelativePositionChildren(nsIPresContext* aCX, } } +#if XXX // XXX if this can handle proportional widths then do so // XXX check against other possible values and update static PRBool @@ -182,30 +183,129 @@ GetStyleDimension(nsIPresContext* aPresContext, } return rv; } +#endif + // XXX if display == row || rowspan ignore width + // XXX if display == col || colspan ignore height PRIntn nsCSSLayout::GetStyleSize(nsIPresContext* aPresContext, const nsHTMLReflowState& aReflowState, nsSize& aStyleSize) { - // XXX if display == row || rowspan ignore width - // XXX if display == col || colspan ignore height - PRIntn rv = NS_SIZE_HAS_NONE; + const nsStylePosition* pos; - nsresult result = aReflowState.frame->GetStyleData(eStyleStruct_Position, - (const nsStyleStruct*&)pos); + nsresult result = + aReflowState.frame->GetStyleData(eStyleStruct_Position, + (const nsStyleStruct*&)pos); if (NS_OK == result) { - if (GetStyleDimension(aPresContext, aReflowState, pos, pos->mWidth, - aStyleSize.width)) { -NS_ASSERTION(aStyleSize.width < 100000, "bad % result"); + nscoord containingBlockWidth, containingBlockHeight; + nscoord width = -1, height = -1; + PRIntn widthUnit = pos->mWidth.GetUnit(); + PRIntn heightUnit = pos->mHeight.GetUnit(); + + // When a percentage is specified we need to find the containing + // block to use as the basis for the percentage computation. + if ((eStyleUnit_Percent == widthUnit) || + (eStyleUnit_Percent == heightUnit)) { + // Find the containing block for this frame + nsIFrame* containingBlock = nsnull; + // XXX this cast is just plain wrong + const nsHTMLReflowState* rs = (const nsHTMLReflowState*) + aReflowState.parentReflowState; + while (nsnull != rs) { + if (nsnull != rs->frame) { + PRBool isContainingBlock; + if (NS_OK == rs->frame->IsPercentageBase(isContainingBlock)) { + if (isContainingBlock) { + containingBlock = rs->frame; + break; + } + } + } + // XXX this cast is just plain wrong + rs = (const nsHTMLReflowState*) rs->parentReflowState; + } + + // If there is no containing block then pretend the width or + // height units are auto. + if (nsnull == containingBlock) { + if (eStyleUnit_Percent == widthUnit) { + widthUnit = eStyleUnit_Auto; + } + if (eStyleUnit_Percent == heightUnit) { + heightUnit = eStyleUnit_Auto; + } + } + else { + if (eStyleUnit_Percent == widthUnit) { + if (eHTMLFrameConstraint_Unconstrained == rs->widthConstraint) { + if (NS_UNCONSTRAINEDSIZE == rs->maxSize.width) { + // When we don't know the width (yet) of the containing + // block we use a dummy value, assuming that the frame + // depending on the percentage value will be reflowed a + // second time. + containingBlockWidth = 1; + } + else { + containingBlockWidth = rs->maxSize.width; + } + } + else { + containingBlockWidth = rs->minWidth; + } + } + if (eStyleUnit_Percent == heightUnit) { + if (eHTMLFrameConstraint_Unconstrained == rs->heightConstraint) { + if (NS_UNCONSTRAINEDSIZE == rs->maxSize.height) { + // CSS2 spec, 10.5: if the height of the containing block + // is not specified explicitly then the value is + // interpreted like auto. + heightUnit = eStyleUnit_Auto; + } + else { + containingBlockHeight = rs->maxSize.height; + } + } + else { + containingBlockHeight = rs->minHeight; + } + } + } + } + + switch (widthUnit) { + case eStyleUnit_Coord: + width = pos->mWidth.GetCoordValue(); + break; + case eStyleUnit_Percent: + width = nscoord(pos->mWidth.GetPercentValue() * containingBlockWidth); + break; + case eStyleUnit_Auto: + // XXX See section 10.3 of the css2 spec and then write this code! + break; + } + switch (heightUnit) { + case eStyleUnit_Coord: + height = pos->mHeight.GetCoordValue(); + break; + case eStyleUnit_Percent: + height = nscoord(pos->mHeight.GetPercentValue() * containingBlockHeight); + break; + case eStyleUnit_Auto: + // XXX See section 10.6 of the css2 spec and then write this code! + break; + } + + if (width > 0) { + aStyleSize.width = width; rv |= NS_SIZE_HAS_WIDTH; } - if (GetStyleDimension(aPresContext, aReflowState, pos, pos->mHeight, - aStyleSize.height)) { -NS_ASSERTION(aStyleSize.height < 100000, "bad % result"); + if (height > 0) { + aStyleSize.height = height; rv |= NS_SIZE_HAS_HEIGHT; } } + return rv; } diff --git a/mozilla/layout/html/table/src/nsTableCellFrame.cpp b/mozilla/layout/html/table/src/nsTableCellFrame.cpp index 81b59c5222c..ba985ae9eab 100644 --- a/mozilla/layout/html/table/src/nsTableCellFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableCellFrame.cpp @@ -295,7 +295,8 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext& aPresContext, nsHTMLReflowMetrics kidSize(pMaxElementSize); kidSize.width=kidSize.height=kidSize.ascent=kidSize.descent=0; SetPriorAvailWidth(aReflowState.maxSize.width); - nsHTMLReflowState kidReflowState(mFirstChild, aReflowState, availSize); + nsHTMLReflowState kidReflowState(aPresContext, mFirstChild, aReflowState, + availSize); ReflowChild(mFirstChild, aPresContext, kidSize, kidReflowState, aStatus); #ifdef NS_DEBUG diff --git a/mozilla/layout/html/table/src/nsTableColGroupFrame.cpp b/mozilla/layout/html/table/src/nsTableColGroupFrame.cpp index 3d0fddc0537..c7a676ddc00 100644 --- a/mozilla/layout/html/table/src/nsTableColGroupFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableColGroupFrame.cpp @@ -207,7 +207,8 @@ NS_METHOD nsTableColGroupFrame::Reflow(nsIPresContext& aPresContext, // Give the child frame a chance to reflow, even though we know it'll have 0 size nsHTMLReflowMetrics kidSize(nsnull); // XXX Use a valid reason... - nsHTMLReflowState kidReflowState(kidFrame, aReflowState, nsSize(0,0), eReflowReason_Initial); + nsHTMLReflowState kidReflowState(aPresContext, kidFrame, aReflowState, + nsSize(0,0), eReflowReason_Initial); nsReflowStatus status; ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, status); diff --git a/mozilla/layout/html/table/src/nsTableFrame.cpp b/mozilla/layout/html/table/src/nsTableFrame.cpp index 216b51fd323..dcf88de6ec8 100644 --- a/mozilla/layout/html/table/src/nsTableFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableFrame.cpp @@ -1623,7 +1623,8 @@ NS_METHOD nsTableFrame::ResizeReflowPass1(nsIPresContext& aPresContext, continue; } nsSize maxKidElementSize(0,0); - nsHTMLReflowState kidReflowState(kidFrame, aReflowState, availSize); + nsHTMLReflowState kidReflowState(aPresContext, kidFrame, aReflowState, + availSize); PRInt32 yCoord = y; if (NS_UNCONSTRAINEDSIZE!=yCoord) @@ -2027,7 +2028,9 @@ NS_METHOD nsTableFrame::IR_TargetIsChild(nsIPresContext& aPresContext, // Pass along the reflow command nsHTMLReflowMetrics desiredSize(nsnull); // XXX Correctly compute the available space... - nsHTMLReflowState kidReflowState(aNextFrame, aReflowState.reflowState, aReflowState.reflowState.maxSize); + nsHTMLReflowState kidReflowState(aPresContext, aNextFrame, + aReflowState.reflowState, + aReflowState.reflowState.maxSize); ReflowChild(aNextFrame, aPresContext, desiredSize, kidReflowState, aStatus); @@ -2232,7 +2235,8 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext& aPresContext, } // Reflow the child into the available space - nsHTMLReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize, + nsHTMLReflowState kidReflowState(aPresContext, kidFrame, + aState.reflowState, kidAvailSize, reason); nscoord x = aState.leftInset + kidMargin.left; @@ -2371,7 +2375,8 @@ PRBool nsTableFrame::PullUpChildren(nsIPresContext& aPresContext, result = PR_FALSE; break; } - nsHTMLReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize, + nsHTMLReflowState kidReflowState(aPresContext, kidFrame, + aState.reflowState, aState.availSize, eReflowReason_Resize); ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, status); diff --git a/mozilla/layout/html/table/src/nsTableOuterFrame.cpp b/mozilla/layout/html/table/src/nsTableOuterFrame.cpp index 243db58d4a2..a153ff10088 100644 --- a/mozilla/layout/html/table/src/nsTableOuterFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableOuterFrame.cpp @@ -329,7 +329,8 @@ nsresult nsTableOuterFrame::IR_TargetIsCaptionFrame(nsIPresContext& aPres if (PR_TRUE==gsDebugIR) printf("TOF IR: passing down incremental reflow command to caption.\n"); nsSize captionMES(0,0); nsHTMLReflowMetrics captionSize(&captionMES); - nsHTMLReflowState captionReflowState(mCaptionFrame, aReflowState.reflowState, + nsHTMLReflowState captionReflowState(aPresContext, mCaptionFrame, + aReflowState.reflowState, nsSize(mRect.width, aReflowState.reflowState.maxSize.height)); rv = ReflowChild(mCaptionFrame, aPresContext, captionSize, captionReflowState, aStatus); @@ -368,7 +369,8 @@ nsresult nsTableOuterFrame::IR_TargetIsCaptionFrame(nsIPresContext& aPres tableWidth = mMinCaptionWidth; } nsHTMLReflowMetrics innerSize(aDesiredSize.maxElementSize); - nsHTMLReflowState innerReflowState(mInnerTableFrame, aReflowState.reflowState, + nsHTMLReflowState innerReflowState(aPresContext, mInnerTableFrame, + aReflowState.reflowState, nsSize(tableWidth, aReflowState.reflowState.maxSize.height), eReflowReason_Resize); rv = ReflowChild(mInnerTableFrame, aPresContext, innerSize, innerReflowState, aStatus); @@ -510,7 +512,8 @@ nsresult nsTableOuterFrame::IR_InnerTableReflow(nsIPresContext& aPresCont nsHTMLReflowMetrics innerSize(aDesiredSize.maxElementSize); nscoord tableMaxWidth = PR_MAX(aReflowState.reflowState.maxSize.width, mMinCaptionWidth); if (PR_TRUE==gsDebugIR) printf("TOF IR: mincaptionWidth=%d, tableMaxWidth=%d.\n", mMinCaptionWidth, tableMaxWidth); - nsHTMLReflowState innerReflowState(mInnerTableFrame, aReflowState.reflowState, + nsHTMLReflowState innerReflowState(aPresContext, mInnerTableFrame, + aReflowState.reflowState, nsSize(tableMaxWidth, aReflowState.reflowState.maxSize.height)); rv = ReflowChild(mInnerTableFrame, aPresContext, innerSize, innerReflowState, aStatus); if (PR_TRUE==gsDebugIR) printf("TOF IR: inner table reflow returned %d with width=%d height=%d\n", @@ -528,7 +531,8 @@ nsresult nsTableOuterFrame::IR_InnerTableReflow(nsIPresContext& aPresCont PRBool captionWasReflowed=PR_FALSE; if (priorInnerTableRect.width!=innerSize.width) { // the table width changed, so reflow the caption - nsHTMLReflowState captionReflowState(mCaptionFrame, aReflowState.reflowState, + nsHTMLReflowState captionReflowState(aPresContext, mCaptionFrame, + aReflowState.reflowState, nsSize(innerSize.width, aReflowState.reflowState.maxSize.height), eReflowReason_Resize); @@ -648,7 +652,8 @@ nsresult nsTableOuterFrame::IR_CaptionInserted(nsIPresContext& aPresConte if (PR_TRUE==gsDebugIR) printf("TOF IR: initial-reflowing caption\n"); nsSize maxElementSize; nsHTMLReflowMetrics captionSize(&maxElementSize); - nsHTMLReflowState captionReflowState(mCaptionFrame, aReflowState.reflowState, + nsHTMLReflowState captionReflowState(aPresContext, mCaptionFrame, + aReflowState.reflowState, nsSize(mRect.width, aReflowState.reflowState.maxSize.height), eReflowReason_Initial); nsIHTMLReflow* htmlReflow; @@ -677,7 +682,8 @@ nsresult nsTableOuterFrame::IR_CaptionInserted(nsIPresContext& aPresConte if ((oldCaptionMES != mMinCaptionWidth) && (mMinCaptionWidth > mRect.width)) { if (PR_TRUE==gsDebugIR) printf("TOF IR: resize-reflowing inner table\n"); - nsHTMLReflowState innerReflowState(mInnerTableFrame, aReflowState.reflowState, + nsHTMLReflowState innerReflowState(aPresContext, mInnerTableFrame, + aReflowState.reflowState, nsSize(mMinCaptionWidth, aReflowState.reflowState.maxSize.height), eReflowReason_Resize); rv = ReflowChild(mInnerTableFrame, aPresContext, innerSize, innerReflowState, aStatus); @@ -730,7 +736,8 @@ nsresult nsTableOuterFrame::IR_CaptionRemoved(nsIPresContext& aPresContex if (oldMinCaptionWidth > mRect.width) { // the old caption width had an effect on the inner table width, so reflow the inner table if (PR_TRUE==gsDebugIR) printf("TOF IR: reflowing inner table\n"); - nsHTMLReflowState innerReflowState(mInnerTableFrame, aReflowState.reflowState, + nsHTMLReflowState innerReflowState(aPresContext, mInnerTableFrame, + aReflowState.reflowState, nsSize(aReflowState.reflowState.maxSize.width, aReflowState.reflowState.maxSize.height)); // ReflowChild sets MES @@ -932,7 +939,8 @@ NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext& aPresContext, if (nsnull != mCaptionFrame) { nsSize maxElementSize; nsHTMLReflowMetrics captionSize(&maxElementSize); - nsHTMLReflowState captionReflowState(mCaptionFrame, aReflowState, + nsHTMLReflowState captionReflowState(aPresContext, mCaptionFrame, + aReflowState, nsSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE), eReflowReason_Initial); nsIHTMLReflow* htmlReflow; @@ -960,7 +968,8 @@ NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext& aPresContext, } // First reflow the inner table - nsHTMLReflowState innerReflowState(mInnerTableFrame, aReflowState, + nsHTMLReflowState innerReflowState(aPresContext, mInnerTableFrame, + aReflowState, nsSize(tableWidth, aReflowState.maxSize.height)); nsHTMLReflowMetrics innerSize(aDesiredSize.maxElementSize); @@ -995,7 +1004,8 @@ NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext& aPresContext, } // Reflow the caption. Let it be as high as it wants - nsHTMLReflowState captionReflowState(mCaptionFrame, state.reflowState, + nsHTMLReflowState captionReflowState(aPresContext, mCaptionFrame, + state.reflowState, nsSize(innerSize.width, NS_UNCONSTRAINEDSIZE), eReflowReason_Resize); nsHTMLReflowMetrics captionSize(nsnull); diff --git a/mozilla/layout/html/table/src/nsTableRowFrame.cpp b/mozilla/layout/html/table/src/nsTableRowFrame.cpp index 8ab99aac347..22742db37c0 100644 --- a/mozilla/layout/html/table/src/nsTableRowFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableRowFrame.cpp @@ -477,7 +477,8 @@ nsresult nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext, nsSize kidAvailSize(availWidth, NS_UNCONSTRAINEDSIZE); // Reflow the child - nsHTMLReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize, + nsHTMLReflowState kidReflowState(aPresContext, kidFrame, + aState.reflowState, kidAvailSize, eReflowReason_Resize); if (gsDebug) printf ("%p RR: avail=%d\n", this, availWidth); nsReflowStatus status; @@ -645,7 +646,8 @@ nsTableRowFrame::InitialReflow(nsIPresContext& aPresContext, kidAvailSize.SizeTo(table->GetColumnWidth(colIndex), NS_UNCONSTRAINEDSIZE); } - nsHTMLReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize, + nsHTMLReflowState kidReflowState(aPresContext, kidFrame, + aState.reflowState, kidAvailSize, eReflowReason_Initial); if (gsDebug) printf ("%p InitR: avail=%d\n", this, kidAvailSize.width); @@ -841,7 +843,8 @@ nsresult nsTableRowFrame::IncrementalReflow(nsIPresContext& aPresContext, // Pass along the reflow command nsSize kidMaxElementSize; nsHTMLReflowMetrics desiredSize(&kidMaxElementSize); - nsHTMLReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize); + nsHTMLReflowState kidReflowState(aPresContext, kidFrame, aState.reflowState, + kidAvailSize); // XXX Unfortunately we need to reflow the child several times. // The first time is for the incremental reflow command. We can't pass in diff --git a/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp b/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp index 831d088b226..b485bfec9c6 100644 --- a/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp @@ -300,7 +300,8 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon } // Reflow the child into the available space - nsHTMLReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize); + nsHTMLReflowState kidReflowState(*aPresContext, kidFrame, + aState.reflowState, kidAvailSize); if (gsDebug) printf("%p RG reflowing child %d (frame=%p) with avail width = %d\n", this, debugCounter, kidFrame, kidAvailSize.width); @@ -447,7 +448,8 @@ PRBool nsTableRowGroupFrame::PullUpChildren(nsIPresContext* aPresContext, result = PR_FALSE; break; } - nsHTMLReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize, + nsHTMLReflowState kidReflowState(*aPresContext, kidFrame, + aState.reflowState, aState.availSize, eReflowReason_Resize); ReflowChild(kidFrame, *aPresContext, kidSize, kidReflowState, status); @@ -770,7 +772,8 @@ nsTableRowGroupFrame::Reflow(nsIPresContext& aPresContext, // Pass along the reflow command // XXX Correctly compute the available space... - nsHTMLReflowState kidReflowState(kidFrame, aReflowState, aReflowState.maxSize); + nsHTMLReflowState kidReflowState(aPresContext, kidFrame, + aReflowState, aReflowState.maxSize); nsHTMLReflowMetrics desiredSize(nsnull); ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, aStatus); diff --git a/mozilla/layout/tables/nsTableCellFrame.cpp b/mozilla/layout/tables/nsTableCellFrame.cpp index 81b59c5222c..ba985ae9eab 100644 --- a/mozilla/layout/tables/nsTableCellFrame.cpp +++ b/mozilla/layout/tables/nsTableCellFrame.cpp @@ -295,7 +295,8 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext& aPresContext, nsHTMLReflowMetrics kidSize(pMaxElementSize); kidSize.width=kidSize.height=kidSize.ascent=kidSize.descent=0; SetPriorAvailWidth(aReflowState.maxSize.width); - nsHTMLReflowState kidReflowState(mFirstChild, aReflowState, availSize); + nsHTMLReflowState kidReflowState(aPresContext, mFirstChild, aReflowState, + availSize); ReflowChild(mFirstChild, aPresContext, kidSize, kidReflowState, aStatus); #ifdef NS_DEBUG diff --git a/mozilla/layout/tables/nsTableColGroupFrame.cpp b/mozilla/layout/tables/nsTableColGroupFrame.cpp index 3d0fddc0537..c7a676ddc00 100644 --- a/mozilla/layout/tables/nsTableColGroupFrame.cpp +++ b/mozilla/layout/tables/nsTableColGroupFrame.cpp @@ -207,7 +207,8 @@ NS_METHOD nsTableColGroupFrame::Reflow(nsIPresContext& aPresContext, // Give the child frame a chance to reflow, even though we know it'll have 0 size nsHTMLReflowMetrics kidSize(nsnull); // XXX Use a valid reason... - nsHTMLReflowState kidReflowState(kidFrame, aReflowState, nsSize(0,0), eReflowReason_Initial); + nsHTMLReflowState kidReflowState(aPresContext, kidFrame, aReflowState, + nsSize(0,0), eReflowReason_Initial); nsReflowStatus status; ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, status); diff --git a/mozilla/layout/tables/nsTableFrame.cpp b/mozilla/layout/tables/nsTableFrame.cpp index 216b51fd323..dcf88de6ec8 100644 --- a/mozilla/layout/tables/nsTableFrame.cpp +++ b/mozilla/layout/tables/nsTableFrame.cpp @@ -1623,7 +1623,8 @@ NS_METHOD nsTableFrame::ResizeReflowPass1(nsIPresContext& aPresContext, continue; } nsSize maxKidElementSize(0,0); - nsHTMLReflowState kidReflowState(kidFrame, aReflowState, availSize); + nsHTMLReflowState kidReflowState(aPresContext, kidFrame, aReflowState, + availSize); PRInt32 yCoord = y; if (NS_UNCONSTRAINEDSIZE!=yCoord) @@ -2027,7 +2028,9 @@ NS_METHOD nsTableFrame::IR_TargetIsChild(nsIPresContext& aPresContext, // Pass along the reflow command nsHTMLReflowMetrics desiredSize(nsnull); // XXX Correctly compute the available space... - nsHTMLReflowState kidReflowState(aNextFrame, aReflowState.reflowState, aReflowState.reflowState.maxSize); + nsHTMLReflowState kidReflowState(aPresContext, aNextFrame, + aReflowState.reflowState, + aReflowState.reflowState.maxSize); ReflowChild(aNextFrame, aPresContext, desiredSize, kidReflowState, aStatus); @@ -2232,7 +2235,8 @@ PRBool nsTableFrame::ReflowMappedChildren( nsIPresContext& aPresContext, } // Reflow the child into the available space - nsHTMLReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize, + nsHTMLReflowState kidReflowState(aPresContext, kidFrame, + aState.reflowState, kidAvailSize, reason); nscoord x = aState.leftInset + kidMargin.left; @@ -2371,7 +2375,8 @@ PRBool nsTableFrame::PullUpChildren(nsIPresContext& aPresContext, result = PR_FALSE; break; } - nsHTMLReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize, + nsHTMLReflowState kidReflowState(aPresContext, kidFrame, + aState.reflowState, aState.availSize, eReflowReason_Resize); ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, status); diff --git a/mozilla/layout/tables/nsTableOuterFrame.cpp b/mozilla/layout/tables/nsTableOuterFrame.cpp index 243db58d4a2..a153ff10088 100644 --- a/mozilla/layout/tables/nsTableOuterFrame.cpp +++ b/mozilla/layout/tables/nsTableOuterFrame.cpp @@ -329,7 +329,8 @@ nsresult nsTableOuterFrame::IR_TargetIsCaptionFrame(nsIPresContext& aPres if (PR_TRUE==gsDebugIR) printf("TOF IR: passing down incremental reflow command to caption.\n"); nsSize captionMES(0,0); nsHTMLReflowMetrics captionSize(&captionMES); - nsHTMLReflowState captionReflowState(mCaptionFrame, aReflowState.reflowState, + nsHTMLReflowState captionReflowState(aPresContext, mCaptionFrame, + aReflowState.reflowState, nsSize(mRect.width, aReflowState.reflowState.maxSize.height)); rv = ReflowChild(mCaptionFrame, aPresContext, captionSize, captionReflowState, aStatus); @@ -368,7 +369,8 @@ nsresult nsTableOuterFrame::IR_TargetIsCaptionFrame(nsIPresContext& aPres tableWidth = mMinCaptionWidth; } nsHTMLReflowMetrics innerSize(aDesiredSize.maxElementSize); - nsHTMLReflowState innerReflowState(mInnerTableFrame, aReflowState.reflowState, + nsHTMLReflowState innerReflowState(aPresContext, mInnerTableFrame, + aReflowState.reflowState, nsSize(tableWidth, aReflowState.reflowState.maxSize.height), eReflowReason_Resize); rv = ReflowChild(mInnerTableFrame, aPresContext, innerSize, innerReflowState, aStatus); @@ -510,7 +512,8 @@ nsresult nsTableOuterFrame::IR_InnerTableReflow(nsIPresContext& aPresCont nsHTMLReflowMetrics innerSize(aDesiredSize.maxElementSize); nscoord tableMaxWidth = PR_MAX(aReflowState.reflowState.maxSize.width, mMinCaptionWidth); if (PR_TRUE==gsDebugIR) printf("TOF IR: mincaptionWidth=%d, tableMaxWidth=%d.\n", mMinCaptionWidth, tableMaxWidth); - nsHTMLReflowState innerReflowState(mInnerTableFrame, aReflowState.reflowState, + nsHTMLReflowState innerReflowState(aPresContext, mInnerTableFrame, + aReflowState.reflowState, nsSize(tableMaxWidth, aReflowState.reflowState.maxSize.height)); rv = ReflowChild(mInnerTableFrame, aPresContext, innerSize, innerReflowState, aStatus); if (PR_TRUE==gsDebugIR) printf("TOF IR: inner table reflow returned %d with width=%d height=%d\n", @@ -528,7 +531,8 @@ nsresult nsTableOuterFrame::IR_InnerTableReflow(nsIPresContext& aPresCont PRBool captionWasReflowed=PR_FALSE; if (priorInnerTableRect.width!=innerSize.width) { // the table width changed, so reflow the caption - nsHTMLReflowState captionReflowState(mCaptionFrame, aReflowState.reflowState, + nsHTMLReflowState captionReflowState(aPresContext, mCaptionFrame, + aReflowState.reflowState, nsSize(innerSize.width, aReflowState.reflowState.maxSize.height), eReflowReason_Resize); @@ -648,7 +652,8 @@ nsresult nsTableOuterFrame::IR_CaptionInserted(nsIPresContext& aPresConte if (PR_TRUE==gsDebugIR) printf("TOF IR: initial-reflowing caption\n"); nsSize maxElementSize; nsHTMLReflowMetrics captionSize(&maxElementSize); - nsHTMLReflowState captionReflowState(mCaptionFrame, aReflowState.reflowState, + nsHTMLReflowState captionReflowState(aPresContext, mCaptionFrame, + aReflowState.reflowState, nsSize(mRect.width, aReflowState.reflowState.maxSize.height), eReflowReason_Initial); nsIHTMLReflow* htmlReflow; @@ -677,7 +682,8 @@ nsresult nsTableOuterFrame::IR_CaptionInserted(nsIPresContext& aPresConte if ((oldCaptionMES != mMinCaptionWidth) && (mMinCaptionWidth > mRect.width)) { if (PR_TRUE==gsDebugIR) printf("TOF IR: resize-reflowing inner table\n"); - nsHTMLReflowState innerReflowState(mInnerTableFrame, aReflowState.reflowState, + nsHTMLReflowState innerReflowState(aPresContext, mInnerTableFrame, + aReflowState.reflowState, nsSize(mMinCaptionWidth, aReflowState.reflowState.maxSize.height), eReflowReason_Resize); rv = ReflowChild(mInnerTableFrame, aPresContext, innerSize, innerReflowState, aStatus); @@ -730,7 +736,8 @@ nsresult nsTableOuterFrame::IR_CaptionRemoved(nsIPresContext& aPresContex if (oldMinCaptionWidth > mRect.width) { // the old caption width had an effect on the inner table width, so reflow the inner table if (PR_TRUE==gsDebugIR) printf("TOF IR: reflowing inner table\n"); - nsHTMLReflowState innerReflowState(mInnerTableFrame, aReflowState.reflowState, + nsHTMLReflowState innerReflowState(aPresContext, mInnerTableFrame, + aReflowState.reflowState, nsSize(aReflowState.reflowState.maxSize.width, aReflowState.reflowState.maxSize.height)); // ReflowChild sets MES @@ -932,7 +939,8 @@ NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext& aPresContext, if (nsnull != mCaptionFrame) { nsSize maxElementSize; nsHTMLReflowMetrics captionSize(&maxElementSize); - nsHTMLReflowState captionReflowState(mCaptionFrame, aReflowState, + nsHTMLReflowState captionReflowState(aPresContext, mCaptionFrame, + aReflowState, nsSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE), eReflowReason_Initial); nsIHTMLReflow* htmlReflow; @@ -960,7 +968,8 @@ NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext& aPresContext, } // First reflow the inner table - nsHTMLReflowState innerReflowState(mInnerTableFrame, aReflowState, + nsHTMLReflowState innerReflowState(aPresContext, mInnerTableFrame, + aReflowState, nsSize(tableWidth, aReflowState.maxSize.height)); nsHTMLReflowMetrics innerSize(aDesiredSize.maxElementSize); @@ -995,7 +1004,8 @@ NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext& aPresContext, } // Reflow the caption. Let it be as high as it wants - nsHTMLReflowState captionReflowState(mCaptionFrame, state.reflowState, + nsHTMLReflowState captionReflowState(aPresContext, mCaptionFrame, + state.reflowState, nsSize(innerSize.width, NS_UNCONSTRAINEDSIZE), eReflowReason_Resize); nsHTMLReflowMetrics captionSize(nsnull); diff --git a/mozilla/layout/tables/nsTableRowFrame.cpp b/mozilla/layout/tables/nsTableRowFrame.cpp index 8ab99aac347..22742db37c0 100644 --- a/mozilla/layout/tables/nsTableRowFrame.cpp +++ b/mozilla/layout/tables/nsTableRowFrame.cpp @@ -477,7 +477,8 @@ nsresult nsTableRowFrame::ResizeReflow(nsIPresContext& aPresContext, nsSize kidAvailSize(availWidth, NS_UNCONSTRAINEDSIZE); // Reflow the child - nsHTMLReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize, + nsHTMLReflowState kidReflowState(aPresContext, kidFrame, + aState.reflowState, kidAvailSize, eReflowReason_Resize); if (gsDebug) printf ("%p RR: avail=%d\n", this, availWidth); nsReflowStatus status; @@ -645,7 +646,8 @@ nsTableRowFrame::InitialReflow(nsIPresContext& aPresContext, kidAvailSize.SizeTo(table->GetColumnWidth(colIndex), NS_UNCONSTRAINEDSIZE); } - nsHTMLReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize, + nsHTMLReflowState kidReflowState(aPresContext, kidFrame, + aState.reflowState, kidAvailSize, eReflowReason_Initial); if (gsDebug) printf ("%p InitR: avail=%d\n", this, kidAvailSize.width); @@ -841,7 +843,8 @@ nsresult nsTableRowFrame::IncrementalReflow(nsIPresContext& aPresContext, // Pass along the reflow command nsSize kidMaxElementSize; nsHTMLReflowMetrics desiredSize(&kidMaxElementSize); - nsHTMLReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize); + nsHTMLReflowState kidReflowState(aPresContext, kidFrame, aState.reflowState, + kidAvailSize); // XXX Unfortunately we need to reflow the child several times. // The first time is for the incremental reflow command. We can't pass in diff --git a/mozilla/layout/tables/nsTableRowGroupFrame.cpp b/mozilla/layout/tables/nsTableRowGroupFrame.cpp index 831d088b226..b485bfec9c6 100644 --- a/mozilla/layout/tables/nsTableRowGroupFrame.cpp +++ b/mozilla/layout/tables/nsTableRowGroupFrame.cpp @@ -300,7 +300,8 @@ PRBool nsTableRowGroupFrame::ReflowMappedChildren( nsIPresContext* aPresCon } // Reflow the child into the available space - nsHTMLReflowState kidReflowState(kidFrame, aState.reflowState, kidAvailSize); + nsHTMLReflowState kidReflowState(*aPresContext, kidFrame, + aState.reflowState, kidAvailSize); if (gsDebug) printf("%p RG reflowing child %d (frame=%p) with avail width = %d\n", this, debugCounter, kidFrame, kidAvailSize.width); @@ -447,7 +448,8 @@ PRBool nsTableRowGroupFrame::PullUpChildren(nsIPresContext* aPresContext, result = PR_FALSE; break; } - nsHTMLReflowState kidReflowState(kidFrame, aState.reflowState, aState.availSize, + nsHTMLReflowState kidReflowState(*aPresContext, kidFrame, + aState.reflowState, aState.availSize, eReflowReason_Resize); ReflowChild(kidFrame, *aPresContext, kidSize, kidReflowState, status); @@ -770,7 +772,8 @@ nsTableRowGroupFrame::Reflow(nsIPresContext& aPresContext, // Pass along the reflow command // XXX Correctly compute the available space... - nsHTMLReflowState kidReflowState(kidFrame, aReflowState, aReflowState.maxSize); + nsHTMLReflowState kidReflowState(aPresContext, kidFrame, + aReflowState, aReflowState.maxSize); nsHTMLReflowMetrics desiredSize(nsnull); ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, aStatus);