diff --git a/layout/forms/nsFieldSetFrame.cpp b/layout/forms/nsFieldSetFrame.cpp index 14310fcaa085..b182ae35406b 100644 --- a/layout/forms/nsFieldSetFrame.cpp +++ b/layout/forms/nsFieldSetFrame.cpp @@ -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. diff --git a/layout/generic/nsFirstLetterFrame.cpp b/layout/generic/nsFirstLetterFrame.cpp index 9d14d6e15dda..6e2efc66e9ef 100644 --- a/layout/generic/nsFirstLetterFrame.cpp +++ b/layout/generic/nsFirstLetterFrame.cpp @@ -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 diff --git a/layout/generic/nsFirstLetterFrame.h b/layout/generic/nsFirstLetterFrame.h index d698759c2e9d..454a15fbb500 100644 --- a/layout/generic/nsFirstLetterFrame.h +++ b/layout/generic/nsFirstLetterFrame.h @@ -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, diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index eb235ff2ed00..aa56c6bcf1e9 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -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(); diff --git a/layout/generic/nsFrame.h b/layout/generic/nsFrame.h index fbb922bc29b5..922cc91eca87 100644 --- a/layout/generic/nsFrame.h +++ b/layout/generic/nsFrame.h @@ -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. diff --git a/layout/generic/nsHTMLCanvasFrame.cpp b/layout/generic/nsHTMLCanvasFrame.cpp index 45074f7127d9..b3ccd18749cb 100644 --- a/layout/generic/nsHTMLCanvasFrame.cpp +++ b/layout/generic/nsHTMLCanvasFrame.cpp @@ -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(); diff --git a/layout/generic/nsHTMLCanvasFrame.h b/layout/generic/nsHTMLCanvasFrame.h index 26b1e0388708..410e18e3aee0 100644 --- a/layout/generic/nsHTMLCanvasFrame.h +++ b/layout/generic/nsHTMLCanvasFrame.h @@ -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, diff --git a/layout/generic/nsHTMLReflowState.cpp b/layout/generic/nsHTMLReflowState.cpp index 8c86a5e81184..b74ea401b8cc 100644 --- a/layout/generic/nsHTMLReflowState.cpp +++ b/layout/generic/nsHTMLReflowState.cpp @@ -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; diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index fb90cc765589..d9873900c4e5 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -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 diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index fa1d3ac064f0..304f99d41ed9 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -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); diff --git a/layout/generic/nsImageFrame.h b/layout/generic/nsImageFrame.h index 27ecd5f66c7f..84c6351a64fb 100644 --- a/layout/generic/nsImageFrame.h +++ b/layout/generic/nsImageFrame.h @@ -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(); diff --git a/layout/generic/nsInlineFrame.cpp b/layout/generic/nsInlineFrame.cpp index eddff255c25b..0a4695b7d7c8 100644 --- a/layout/generic/nsInlineFrame.cpp +++ b/layout/generic/nsInlineFrame.cpp @@ -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); diff --git a/layout/generic/nsInlineFrame.h b/layout/generic/nsInlineFrame.h index 94faa93074ba..2bb25c9e1ead 100644 --- a/layout/generic/nsInlineFrame.h +++ b/layout/generic/nsInlineFrame.h @@ -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, diff --git a/layout/generic/nsPageContentFrame.cpp b/layout/generic/nsPageContentFrame.cpp index bed3e694a923..45afa0a1d10a 100644 --- a/layout/generic/nsPageContentFrame.cpp +++ b/layout/generic/nsPageContentFrame.cpp @@ -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) diff --git a/layout/generic/nsPageContentFrame.h b/layout/generic/nsPageContentFrame.h index dd891f7d8e23..bf6e56c6e522 100644 --- a/layout/generic/nsPageContentFrame.h +++ b/layout/generic/nsPageContentFrame.h @@ -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 diff --git a/layout/generic/nsSubDocumentFrame.cpp b/layout/generic/nsSubDocumentFrame.cpp index 656433fe2548..a23defda1f81 100644 --- a/layout/generic/nsSubDocumentFrame.cpp +++ b/layout/generic/nsSubDocumentFrame.cpp @@ -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 diff --git a/layout/generic/nsSubDocumentFrame.h b/layout/generic/nsSubDocumentFrame.h index 2d5a23d68556..8f4101a389a9 100644 --- a/layout/generic/nsSubDocumentFrame.h +++ b/layout/generic/nsSubDocumentFrame.h @@ -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, diff --git a/layout/generic/nsTextFrame.h b/layout/generic/nsTextFrame.h index 70bb27d41e90..21660dc9f7c5 100644 --- a/layout/generic/nsTextFrame.h +++ b/layout/generic/nsTextFrame.h @@ -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, diff --git a/layout/generic/nsTextFrameThebes.cpp b/layout/generic/nsTextFrameThebes.cpp index 1d59bb17f39e..0ae56aa7e925 100644 --- a/layout/generic/nsTextFrameThebes.cpp +++ b/layout/generic/nsTextFrameThebes.cpp @@ -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); diff --git a/layout/generic/nsVideoFrame.cpp b/layout/generic/nsVideoFrame.cpp index 828711b1a3e8..17106d1db8f2 100644 --- a/layout/generic/nsVideoFrame.cpp +++ b/layout/generic/nsVideoFrame.cpp @@ -450,7 +450,7 @@ nsSize nsVideoFrame::ComputeSize(nsRenderingContext *aRenderingContext, nsSize aMargin, nsSize aBorder, nsSize aPadding, - bool aShrinkWrap) + PRUint32 aFlags) { nsSize size = GetVideoIntrinsicSize(aRenderingContext); diff --git a/layout/generic/nsVideoFrame.h b/layout/generic/nsVideoFrame.h index 08bbbaf66496..7a2f6f731bc9 100644 --- a/layout/generic/nsVideoFrame.h +++ b/layout/generic/nsVideoFrame.h @@ -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); diff --git a/layout/svg/base/src/nsSVGOuterSVGFrame.cpp b/layout/svg/base/src/nsSVGOuterSVGFrame.cpp index 070230743251..59b0ea7156e3 100644 --- a/layout/svg/base/src/nsSVGOuterSVGFrame.cpp +++ b/layout/svg/base/src/nsSVGOuterSVGFrame.cpp @@ -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(mContent); diff --git a/layout/svg/base/src/nsSVGOuterSVGFrame.h b/layout/svg/base/src/nsSVGOuterSVGFrame.h index 2283705820e7..04dcc1458f7e 100644 --- a/layout/svg/base/src/nsSVGOuterSVGFrame.h +++ b/layout/svg/base/src/nsSVGOuterSVGFrame.h @@ -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, diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index 66436822ce04..90c37ce9a51b 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -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. diff --git a/layout/tables/nsTableFrame.h b/layout/tables/nsTableFrame.h index e52d8f868e35..39f1f6fa7551 100644 --- a/layout/tables/nsTableFrame.h +++ b/layout/tables/nsTableFrame.h @@ -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,