Bug 732610 - Make nsIFrame::ComputeSize take a bitfield 'aFlags' instead of a bool 'aShrinkWrap'. r=dbaron

This commit is contained in:
Daniel Holbert 2012-03-16 11:01:05 -07:00
parent 7f9923f96d
commit 7dcfb057c4
25 changed files with 58 additions and 41 deletions

View File

@ -85,7 +85,7 @@ public:
virtual nsSize ComputeSize(nsRenderingContext *aRenderingContext,
nsSize aCBSize, nscoord aAvailableWidth,
nsSize aMargin, nsSize aBorder, nsSize aPadding,
bool aShrinkWrap);
PRUint32 aFlags) MOZ_OVERRIDE;
virtual nscoord GetBaseline() const;
virtual void DestroyFrom(nsIFrame* aDestructRoot);
@ -399,11 +399,11 @@ nsFieldSetFrame::GetPrefWidth(nsRenderingContext* aRenderingContext)
nsFieldSetFrame::ComputeSize(nsRenderingContext *aRenderingContext,
nsSize aCBSize, nscoord aAvailableWidth,
nsSize aMargin, nsSize aBorder, nsSize aPadding,
bool aShrinkWrap)
PRUint32 aFlags)
{
nsSize result =
nsContainerFrame::ComputeSize(aRenderingContext, aCBSize, aAvailableWidth,
aMargin, aBorder, aPadding, aShrinkWrap);
aMargin, aBorder, aPadding, aFlags);
// Fieldsets never shrink below their min width.

View File

@ -180,7 +180,7 @@ nsFirstLetterFrame::GetPrefWidth(nsRenderingContext *aRenderingContext)
nsFirstLetterFrame::ComputeSize(nsRenderingContext *aRenderingContext,
nsSize aCBSize, nscoord aAvailableWidth,
nsSize aMargin, nsSize aBorder, nsSize aPadding,
bool aShrinkWrap)
PRUint32 aFlags)
{
if (GetPrevInFlow()) {
// We're wrapping the text *after* the first letter, so behave like an
@ -188,7 +188,7 @@ nsFirstLetterFrame::ComputeSize(nsRenderingContext *aRenderingContext,
return nsSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
}
return nsContainerFrame::ComputeSize(aRenderingContext,
aCBSize, aAvailableWidth, aMargin, aBorder, aPadding, aShrinkWrap);
aCBSize, aAvailableWidth, aMargin, aBorder, aPadding, aFlags);
}
NS_IMETHODIMP

View File

@ -83,7 +83,7 @@ public:
virtual nsSize ComputeSize(nsRenderingContext *aRenderingContext,
nsSize aCBSize, nscoord aAvailableWidth,
nsSize aMargin, nsSize aBorder, nsSize aPadding,
bool aShrinkWrap);
PRUint32 aFlags) MOZ_OVERRIDE;
NS_IMETHOD Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,

View File

@ -3741,10 +3741,11 @@ nsFrame::GetIntrinsicRatio()
nsFrame::ComputeSize(nsRenderingContext *aRenderingContext,
nsSize aCBSize, nscoord aAvailableWidth,
nsSize aMargin, nsSize aBorder, nsSize aPadding,
bool aShrinkWrap)
PRUint32 aFlags)
{
nsSize result = ComputeAutoSize(aRenderingContext, aCBSize, aAvailableWidth,
aMargin, aBorder, aPadding, aShrinkWrap);
aMargin, aBorder, aPadding,
aFlags & eShrinkWrap);
nsSize boxSizingAdjust(0,0);
const nsStylePosition *stylePos = GetStylePosition();

View File

@ -294,7 +294,7 @@ public:
virtual nsSize ComputeSize(nsRenderingContext *aRenderingContext,
nsSize aCBSize, nscoord aAvailableWidth,
nsSize aMargin, nsSize aBorder, nsSize aPadding,
bool aShrinkWrap);
PRUint32 aFlags) MOZ_OVERRIDE;
// Compute tight bounds assuming this frame honours its border, background
// and outline, its children's tight bounds, and nothing else.

View File

@ -195,7 +195,7 @@ nsHTMLCanvasFrame::GetIntrinsicRatio()
nsHTMLCanvasFrame::ComputeSize(nsRenderingContext *aRenderingContext,
nsSize aCBSize, nscoord aAvailableWidth,
nsSize aMargin, nsSize aBorder, nsSize aPadding,
bool aShrinkWrap)
PRUint32 aFlags)
{
nsIntSize size = GetCanvasSize();

View File

@ -84,7 +84,7 @@ public:
virtual nsSize ComputeSize(nsRenderingContext *aRenderingContext,
nsSize aCBSize, nscoord aAvailableWidth,
nsSize aMargin, nsSize aBorder, nsSize aPadding,
bool aShrinkWrap);
PRUint32 aFlags) MOZ_OVERRIDE;
NS_IMETHOD Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,

View File

@ -1238,7 +1238,11 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsPresContext* aPresContext,
bool widthIsAuto = eStyleUnit_Auto == mStylePosition->mWidth.GetUnit();
bool heightIsAuto = eStyleUnit_Auto == mStylePosition->mHeight.GetUnit();
bool shrinkWrap = leftIsAuto || rightIsAuto;
PRUint32 computeSizeFlags = 0;
if (leftIsAuto || rightIsAuto) {
computeSizeFlags |= nsIFrame::eShrinkWrap;
}
{
AutoMaybeNullInflationContainer an(frame);
@ -1257,7 +1261,7 @@ nsHTMLReflowState::InitAbsoluteConstraints(nsPresContext* aPresContext,
mComputedPadding.TopBottom()),
nsSize(mComputedPadding.LeftRight(),
mComputedPadding.TopBottom()),
shrinkWrap);
computeSizeFlags);
mComputedWidth = size.width;
mComputedHeight = size.height;
}
@ -1868,7 +1872,12 @@ nsHTMLReflowState::InitConstraints(nsPresContext* aPresContext,
NS_CSS_FRAME_TYPE_BLOCK == NS_FRAME_GET_TYPE(mFrameType);
// make sure legend frames with display:block and width:auto still
// shrink-wrap
bool shrinkWrap = !isBlock || aFrameType == nsGkAtoms::legendFrame;
PRUint32 computeSizeFlags = 0;
if (!isBlock || aFrameType == nsGkAtoms::legendFrame) {
computeSizeFlags |= nsIFrame::eShrinkWrap;
}
nsSize size =
frame->ComputeSize(rendContext,
nsSize(aContainingBlockWidth,
@ -1882,7 +1891,7 @@ nsHTMLReflowState::InitConstraints(nsPresContext* aPresContext,
mComputedPadding.TopBottom()),
nsSize(mComputedPadding.LeftRight(),
mComputedPadding.TopBottom()),
shrinkWrap);
computeSizeFlags);
mComputedWidth = size.width;
mComputedHeight = size.height;

View File

@ -1651,6 +1651,16 @@ public:
*/
virtual nsSize GetIntrinsicRatio() = 0;
/**
* Bit-flags to pass to ComputeSize in |aFlags| parameter.
*/
enum {
/* Set if the frame is in a context where non-replaced blocks should
* shrink-wrap (e.g., it's floating, absolutely positioned, or
* inline-block). */
eShrinkWrap = 1 << 0
};
/**
* Compute the size that a frame will occupy. Called while
* constructing the nsHTMLReflowState to be used to Reflow the frame,
@ -1682,18 +1692,15 @@ public:
* positioning.
* @param aBorder The sum of the vertical / horizontal border widths
* of the frame.
* @param aPadding The sum of the vertical / horizontal margins of
* the frame, including actual values resulting from
* percentages.
* @param aShrinkWrap Whether the frame is in a context where
* non-replaced blocks should shrink-wrap (e.g.,
* it's floating, absolutely positioned, or
* inline-block).
* @param aPadding The sum of the vertical / horizontal margins of
* the frame, including actual values resulting from
* percentages.
* @param aFlags Flags to further customize behavior (definitions above).
*/
virtual nsSize ComputeSize(nsRenderingContext *aRenderingContext,
nsSize aCBSize, nscoord aAvailableWidth,
nsSize aMargin, nsSize aBorder, nsSize aPadding,
bool aShrinkWrap) = 0;
PRUint32 aFlags) = 0;
/**
* Compute a tight bounding rectangle for the frame. This is a rectangle

View File

@ -765,7 +765,7 @@ nsImageFrame::EnsureIntrinsicSizeAndRatio(nsPresContext* aPresContext)
nsImageFrame::ComputeSize(nsRenderingContext *aRenderingContext,
nsSize aCBSize, nscoord aAvailableWidth,
nsSize aMargin, nsSize aBorder, nsSize aPadding,
bool aShrinkWrap)
PRUint32 aFlags)
{
nsPresContext *presContext = PresContext();
EnsureIntrinsicSizeAndRatio(presContext);

View File

@ -215,7 +215,7 @@ protected:
virtual nsSize ComputeSize(nsRenderingContext *aRenderingContext,
nsSize aCBSize, nscoord aAvailableWidth,
nsSize aMargin, nsSize aBorder, nsSize aPadding,
bool aShrinkWrap);
PRUint32 aFlags) MOZ_OVERRIDE;
bool IsServerImageMap();

View File

@ -233,7 +233,7 @@ nsInlineFrame::AddInlinePrefWidth(nsRenderingContext *aRenderingContext,
nsInlineFrame::ComputeSize(nsRenderingContext *aRenderingContext,
nsSize aCBSize, nscoord aAvailableWidth,
nsSize aMargin, nsSize aBorder, nsSize aPadding,
bool aShrinkWrap)
PRUint32 aFlags)
{
// Inlines and text don't compute size before reflow.
return nsSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);

View File

@ -112,7 +112,7 @@ public:
virtual nsSize ComputeSize(nsRenderingContext *aRenderingContext,
nsSize aCBSize, nscoord aAvailableWidth,
nsSize aMargin, nsSize aBorder, nsSize aPadding,
bool aShrinkWrap);
PRUint32 aFlags) MOZ_OVERRIDE;
virtual nsRect ComputeTightBounds(gfxContext* aContext) const;
NS_IMETHOD Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,

View File

@ -60,7 +60,7 @@ NS_IMPL_FRAMEARENA_HELPERS(nsPageContentFrame)
nsPageContentFrame::ComputeSize(nsRenderingContext *aRenderingContext,
nsSize aCBSize, nscoord aAvailableWidth,
nsSize aMargin, nsSize aBorder, nsSize aPadding,
bool aShrinkWrap)
PRUint32 aFlags)
{
NS_ASSERTION(mPD, "Pages are supposed to have page data");
nscoord height = (!mPD || mPD->mReflowSize.height == NS_UNCONSTRAINEDSIZE)

View File

@ -71,7 +71,7 @@ public:
virtual nsSize ComputeSize(nsRenderingContext *aRenderingContext,
nsSize aCBSize, nscoord aAvailableWidth,
nsSize aMargin, nsSize aBorder, nsSize aPadding,
bool aShrinkWrap);
PRUint32 aFlags) MOZ_OVERRIDE;
/**
* Get the "type" of the frame

View File

@ -546,7 +546,7 @@ nsSubDocumentFrame::ComputeAutoSize(nsRenderingContext *aRenderingContext,
nsSubDocumentFrame::ComputeSize(nsRenderingContext *aRenderingContext,
nsSize aCBSize, nscoord aAvailableWidth,
nsSize aMargin, nsSize aBorder, nsSize aPadding,
bool aShrinkWrap)
PRUint32 aFlags)
{
nsIFrame* subDocRoot = ObtainIntrinsicSizeFrame();
if (subDocRoot) {
@ -557,7 +557,7 @@ nsSubDocumentFrame::ComputeSize(nsRenderingContext *aRenderingContext,
aCBSize, aMargin, aBorder, aPadding);
}
return nsLeafFrame::ComputeSize(aRenderingContext, aCBSize, aAvailableWidth,
aMargin, aBorder, aPadding, aShrinkWrap);
aMargin, aBorder, aPadding, aFlags);
}
NS_IMETHODIMP

View File

@ -89,7 +89,7 @@ public:
virtual nsSize ComputeSize(nsRenderingContext *aRenderingContext,
nsSize aCBSize, nscoord aAvailableWidth,
nsSize aMargin, nsSize aBorder, nsSize aPadding,
bool aShrinkWrap);
PRUint32 aFlags) MOZ_OVERRIDE;
NS_IMETHOD Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,

View File

@ -241,7 +241,7 @@ public:
virtual nsSize ComputeSize(nsRenderingContext *aRenderingContext,
nsSize aCBSize, nscoord aAvailableWidth,
nsSize aMargin, nsSize aBorder, nsSize aPadding,
bool aShrinkWrap);
PRUint32 aFlags) MOZ_OVERRIDE;
virtual nsRect ComputeTightBounds(gfxContext* aContext) const;
NS_IMETHOD Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aMetrics,

View File

@ -6868,7 +6868,7 @@ nsTextFrame::AddInlinePrefWidth(nsRenderingContext *aRenderingContext,
nsTextFrame::ComputeSize(nsRenderingContext *aRenderingContext,
nsSize aCBSize, nscoord aAvailableWidth,
nsSize aMargin, nsSize aBorder, nsSize aPadding,
bool aShrinkWrap)
PRUint32 aFlags)
{
// Inlines and text don't compute size before reflow.
return nsSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);

View File

@ -450,7 +450,7 @@ nsSize nsVideoFrame::ComputeSize(nsRenderingContext *aRenderingContext,
nsSize aMargin,
nsSize aBorder,
nsSize aPadding,
bool aShrinkWrap)
PRUint32 aFlags)
{
nsSize size = GetVideoIntrinsicSize(aRenderingContext);

View File

@ -81,7 +81,7 @@ public:
virtual nsSize ComputeSize(nsRenderingContext *aRenderingContext,
nsSize aCBSize, nscoord aAvailableWidth,
nsSize aMargin, nsSize aBorder, nsSize aPadding,
bool aShrinkWrap);
PRUint32 aFlags) MOZ_OVERRIDE;
virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext);
virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext);
virtual void DestroyFrom(nsIFrame* aDestructRoot);

View File

@ -309,7 +309,7 @@ nsSVGOuterSVGFrame::GetIntrinsicRatio()
nsSVGOuterSVGFrame::ComputeSize(nsRenderingContext *aRenderingContext,
nsSize aCBSize, nscoord aAvailableWidth,
nsSize aMargin, nsSize aBorder, nsSize aPadding,
bool aShrinkWrap)
PRUint32 aFlags)
{
nsSVGSVGElement* content = static_cast<nsSVGSVGElement*>(mContent);

View File

@ -81,7 +81,7 @@ public:
virtual nsSize ComputeSize(nsRenderingContext *aRenderingContext,
nsSize aCBSize, nscoord aAvailableWidth,
nsSize aMargin, nsSize aBorder, nsSize aPadding,
bool aShrinkWrap);
PRUint32 aFlags) MOZ_OVERRIDE;
NS_IMETHOD Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,

View File

@ -1509,11 +1509,11 @@ nsTableFrame::IntrinsicWidthOffsets(nsRenderingContext* aRenderingContext)
nsTableFrame::ComputeSize(nsRenderingContext *aRenderingContext,
nsSize aCBSize, nscoord aAvailableWidth,
nsSize aMargin, nsSize aBorder, nsSize aPadding,
bool aShrinkWrap)
PRUint32 aFlags)
{
nsSize result =
nsContainerFrame::ComputeSize(aRenderingContext, aCBSize, aAvailableWidth,
aMargin, aBorder, aPadding, aShrinkWrap);
aMargin, aBorder, aPadding, aFlags);
// If we're a container for font size inflation, then shrink
// wrapping inside of us should not apply font size inflation.

View File

@ -309,7 +309,7 @@ public:
virtual nsSize ComputeSize(nsRenderingContext *aRenderingContext,
nsSize aCBSize, nscoord aAvailableWidth,
nsSize aMargin, nsSize aBorder, nsSize aPadding,
bool aShrinkWrap);
PRUint32 aFlags) MOZ_OVERRIDE;
virtual nsSize ComputeAutoSize(nsRenderingContext *aRenderingContext,
nsSize aCBSize, nscoord aAvailableWidth,
nsSize aMargin, nsSize aBorder,