Bug 774835: Refactor nsHTMLReflowState::ApplyMinMaxConstraints to separate behavior of width and height. [r=roc]

--HG--
extra : rebase_source : c6a25e9c19c65d86013ddf8afc15026ca02321c4
This commit is contained in:
Elika Etemad 2012-07-18 10:26:05 -04:00
Родитель 8e9d48f8a2
Коммит 5186834e80
6 изменённых файлов: 26 добавлений и 32 удалений

Просмотреть файл

@ -427,7 +427,7 @@ nsListControlFrame::Reflow(nsPresContext* aPresContext,
// When not doing an initial reflow, and when the height is auto, start off
// with our computed height set to what we'd expect our height to be.
nscoord computedHeight = CalcIntrinsicHeight(oldHeightOfARow, length);
state.ApplyMinMaxConstraints(nsnull, &computedHeight);
computedHeight = state.ApplyMinMaxHeight(computedHeight);
state.SetComputedHeight(computedHeight);
}
@ -485,7 +485,7 @@ nsListControlFrame::Reflow(nsPresContext* aPresContext,
// Now compute the height we want to have
nscoord computedHeight = CalcIntrinsicHeight(HeightOfARow(), length);
state.ApplyMinMaxConstraints(nsnull, &computedHeight);
computedHeight = state.ApplyMinMaxHeight(computedHeight);
state.SetComputedHeight(computedHeight);
nsHTMLScrollFrame::WillReflow(aPresContext);

Просмотреть файл

@ -1429,11 +1429,9 @@ nsBlockFrame::ComputeFinalSize(const nsHTMLReflowState& aReflowState,
aMetrics.mCarriedOutBottomMargin.Zero();
}
else if (NS_FRAME_IS_COMPLETE(aState.mReflowStatus)) {
nscoord autoHeight = bottomEdgeOfChildren;
autoHeight -= borderPadding.top;
nscoord oldAutoHeight = autoHeight;
aReflowState.ApplyMinMaxConstraints(nsnull, &autoHeight);
if (autoHeight != oldAutoHeight) {
nscoord contentHeight = bottomEdgeOfChildren - borderPadding.top;
nscoord autoHeight = aReflowState.ApplyMinMaxHeight(contentHeight);
if (autoHeight != contentHeight) {
// Our min-height or max-height made our height change. Don't carry out
// our kids' bottom margins.
aMetrics.mCarriedOutBottomMargin.Zero();

Просмотреть файл

@ -298,7 +298,8 @@ static nsSize ComputeInsideBorderSize(ScrollReflowState* aState,
aState->mReflowState.mComputedPadding.TopBottom();
}
aState->mReflowState.ApplyMinMaxConstraints(&contentWidth, &contentHeight);
contentWidth = aState->mReflowState.ApplyMinMaxWidth(contentWidth);
contentHeight = aState->mReflowState.ApplyMinMaxHeight(contentHeight);
return nsSize(contentWidth + aState->mReflowState.mComputedPadding.LeftRight(),
contentHeight + aState->mReflowState.mComputedPadding.TopBottom());
}

Просмотреть файл

@ -2426,25 +2426,6 @@ nsCSSOffsetState::ComputePadding(nscoord aContainingBlockWidth, nsIAtom* aFrameT
return isWidthDependent;
}
void
nsHTMLReflowState::ApplyMinMaxConstraints(nscoord* aFrameWidth,
nscoord* aFrameHeight) const
{
if (aFrameWidth) {
if (NS_UNCONSTRAINEDSIZE != mComputedMaxWidth) {
*aFrameWidth = NS_MIN(*aFrameWidth, mComputedMaxWidth);
}
*aFrameWidth = NS_MAX(*aFrameWidth, mComputedMinWidth);
}
if (aFrameHeight) {
if (NS_UNCONSTRAINEDSIZE != mComputedMaxHeight) {
*aFrameHeight = NS_MIN(*aFrameHeight, mComputedMaxHeight);
}
*aFrameHeight = NS_MAX(*aFrameHeight, mComputedMinHeight);
}
}
void
nsHTMLReflowState::ComputeMinMaxValues(nscoord aContainingBlockWidth,
nscoord aContainingBlockHeight,

Просмотреть файл

@ -413,11 +413,25 @@ public:
nscoord& aContainingBlockHeight);
/**
* Apply the mComputed(Min/Max)(Width/Height) values to the content
* size computed so far. If a passed-in pointer is null, we skip
* adjusting that dimension.
* Apply the mComputed(Min/Max)Width constraints to the content
* size computed so far.
*/
void ApplyMinMaxConstraints(nscoord* aContentWidth, nscoord* aContentHeight) const;
nscoord ApplyMinMaxWidth(nscoord aWidth) const {
if (NS_UNCONSTRAINEDSIZE != mComputedMaxWidth) {
aWidth = NS_MIN(aWidth, mComputedMaxWidth);
}
return NS_MAX(aWidth, mComputedMinWidth);
}
/**
* Apply the mComputed(Min/Max)Height constraints to the content
* size computed so far.
*/
nscoord ApplyMinMaxHeight(nscoord aHeight) const {
if (NS_UNCONSTRAINEDSIZE != mComputedMaxHeight) {
aHeight = NS_MIN(aHeight, mComputedMaxHeight);
}
return NS_MAX(aHeight, mComputedMinHeight);
}
bool ShouldReflowAllKids() const {
// Note that we could make a stronger optimization for mVResize if

Просмотреть файл

@ -688,7 +688,7 @@ nsBoxFrame::Reflow(nsPresContext* aPresContext,
computedSize.height -= outsideBoxSizing;
// Note: might be negative now, but that's OK because min-width is
// never negative.
aReflowState.ApplyMinMaxConstraints(nsnull, &computedSize.height);
computedSize.height = aReflowState.ApplyMinMaxHeight(computedSize.height);
computedSize.height += outsideBoxSizing;
} else {
computedSize.height += m.top + m.bottom;