mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 14:55:47 +00:00
Bug 1079157 - part 1 - Purely mechanical renaming of local variables and members in nsColumnSetFrame. r=smontagu
This commit is contained in:
parent
d928f41d37
commit
4673c6322c
@ -31,7 +31,7 @@ NS_NewColumnSetFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, nsFrame
|
||||
NS_IMPL_FRAMEARENA_HELPERS(nsColumnSetFrame)
|
||||
|
||||
nsColumnSetFrame::nsColumnSetFrame(nsStyleContext* aContext)
|
||||
: nsContainerFrame(aContext), mLastBalanceHeight(NS_INTRINSICSIZE),
|
||||
: nsContainerFrame(aContext), mLastBalanceBSize(NS_INTRINSICSIZE),
|
||||
mLastFrameStatus(NS_FRAME_COMPLETE)
|
||||
{
|
||||
}
|
||||
@ -123,7 +123,7 @@ nsColumnSetFrame::PaintColumnRule(nsRenderingContext* aCtx,
|
||||
}
|
||||
|
||||
static nscoord
|
||||
GetAvailableContentWidth(const nsHTMLReflowState& aReflowState)
|
||||
GetAvailableContentISize(const nsHTMLReflowState& aReflowState)
|
||||
{
|
||||
if (aReflowState.AvailableWidth() == NS_INTRINSICSIZE) {
|
||||
return NS_INTRINSICSIZE;
|
||||
@ -135,7 +135,7 @@ GetAvailableContentWidth(const nsHTMLReflowState& aReflowState)
|
||||
}
|
||||
|
||||
nscoord
|
||||
nsColumnSetFrame::GetAvailableContentHeight(const nsHTMLReflowState& aReflowState)
|
||||
nsColumnSetFrame::GetAvailableContentBSize(const nsHTMLReflowState& aReflowState)
|
||||
{
|
||||
if (aReflowState.AvailableHeight() == NS_INTRINSICSIZE) {
|
||||
return NS_INTRINSICSIZE;
|
||||
@ -166,17 +166,17 @@ GetColumnGap(nsColumnSetFrame* aFrame,
|
||||
nsColumnSetFrame::ReflowConfig
|
||||
nsColumnSetFrame::ChooseColumnStrategy(const nsHTMLReflowState& aReflowState,
|
||||
bool aForceAuto = false,
|
||||
nscoord aFeasibleHeight = NS_INTRINSICSIZE,
|
||||
nscoord aInfeasibleHeight = 0)
|
||||
nscoord aFeasibleBSize = NS_INTRINSICSIZE,
|
||||
nscoord aInfeasibleBSize = 0)
|
||||
|
||||
{
|
||||
nscoord knownFeasibleHeight = aFeasibleHeight;
|
||||
nscoord knownInfeasibleHeight = aInfeasibleHeight;
|
||||
nscoord knownFeasibleBSize = aFeasibleBSize;
|
||||
nscoord knownInfeasibleBSize = aInfeasibleBSize;
|
||||
|
||||
const nsStyleColumn* colStyle = StyleColumn();
|
||||
nscoord availContentWidth = GetAvailableContentWidth(aReflowState);
|
||||
nscoord availContentISize = GetAvailableContentISize(aReflowState);
|
||||
if (aReflowState.ComputedWidth() != NS_INTRINSICSIZE) {
|
||||
availContentWidth = aReflowState.ComputedWidth();
|
||||
availContentISize = aReflowState.ComputedWidth();
|
||||
}
|
||||
|
||||
nscoord consumedBSize = GetConsumedBSize();
|
||||
@ -186,12 +186,12 @@ nsColumnSetFrame::ChooseColumnStrategy(const nsHTMLReflowState& aReflowState,
|
||||
// if we have an unconstrained available height.
|
||||
nscoord computedBSize = GetEffectiveComputedBSize(aReflowState,
|
||||
consumedBSize);
|
||||
nscoord colHeight = GetAvailableContentHeight(aReflowState);
|
||||
nscoord colBSize = GetAvailableContentBSize(aReflowState);
|
||||
|
||||
if (aReflowState.ComputedHeight() != NS_INTRINSICSIZE) {
|
||||
colHeight = aReflowState.ComputedHeight();
|
||||
colBSize = aReflowState.ComputedHeight();
|
||||
} else if (aReflowState.ComputedMaxHeight() != NS_INTRINSICSIZE) {
|
||||
colHeight = std::min(colHeight, aReflowState.ComputedMaxHeight());
|
||||
colBSize = std::min(colBSize, aReflowState.ComputedMaxHeight());
|
||||
}
|
||||
|
||||
nscoord colGap = GetColumnGap(this, colStyle);
|
||||
@ -214,46 +214,46 @@ nsColumnSetFrame::ChooseColumnStrategy(const nsHTMLReflowState& aReflowState,
|
||||
}
|
||||
}
|
||||
|
||||
nscoord colWidth;
|
||||
nscoord colISize;
|
||||
if (colStyle->mColumnWidth.GetUnit() == eStyleUnit_Coord) {
|
||||
colWidth = colStyle->mColumnWidth.GetCoordValue();
|
||||
NS_ASSERTION(colWidth >= 0, "negative column width");
|
||||
colISize = colStyle->mColumnWidth.GetCoordValue();
|
||||
NS_ASSERTION(colISize >= 0, "negative column width");
|
||||
// Reduce column count if necessary to make columns fit in the
|
||||
// available width. Compute max number of columns that fit in
|
||||
// availContentWidth, satisfying colGap*(maxColumns - 1) +
|
||||
// colWidth*maxColumns <= availContentWidth
|
||||
if (availContentWidth != NS_INTRINSICSIZE && colGap + colWidth > 0
|
||||
// availContentISize, satisfying colGap*(maxColumns - 1) +
|
||||
// colISize*maxColumns <= availContentISize
|
||||
if (availContentISize != NS_INTRINSICSIZE && colGap + colISize > 0
|
||||
&& numColumns > 0) {
|
||||
// This expression uses truncated rounding, which is what we
|
||||
// want
|
||||
int32_t maxColumns =
|
||||
std::min(nscoord(nsStyleColumn::kMaxColumnCount),
|
||||
(availContentWidth + colGap)/(colGap + colWidth));
|
||||
(availContentISize + colGap)/(colGap + colISize));
|
||||
numColumns = std::max(1, std::min(numColumns, maxColumns));
|
||||
}
|
||||
} else if (numColumns > 0 && availContentWidth != NS_INTRINSICSIZE) {
|
||||
nscoord widthMinusGaps = availContentWidth - colGap*(numColumns - 1);
|
||||
colWidth = widthMinusGaps/numColumns;
|
||||
} else if (numColumns > 0 && availContentISize != NS_INTRINSICSIZE) {
|
||||
nscoord iSizeMinusGaps = availContentISize - colGap*(numColumns - 1);
|
||||
colISize = iSizeMinusGaps/numColumns;
|
||||
} else {
|
||||
colWidth = NS_INTRINSICSIZE;
|
||||
colISize = NS_INTRINSICSIZE;
|
||||
}
|
||||
// Take care of the situation where there's only one column but it's
|
||||
// still too wide
|
||||
colWidth = std::max(1, std::min(colWidth, availContentWidth));
|
||||
colISize = std::max(1, std::min(colISize, availContentISize));
|
||||
|
||||
nscoord expectedWidthLeftOver = 0;
|
||||
nscoord expectedISizeLeftOver = 0;
|
||||
|
||||
if (colWidth != NS_INTRINSICSIZE && availContentWidth != NS_INTRINSICSIZE) {
|
||||
if (colISize != NS_INTRINSICSIZE && availContentISize != NS_INTRINSICSIZE) {
|
||||
// distribute leftover space
|
||||
|
||||
// First, determine how many columns will be showing if the column
|
||||
// count is auto
|
||||
if (numColumns <= 0) {
|
||||
// choose so that colGap*(nominalColumnCount - 1) +
|
||||
// colWidth*nominalColumnCount is nearly availContentWidth
|
||||
// colISize*nominalColumnCount is nearly availContentISize
|
||||
// make sure to round down
|
||||
if (colGap + colWidth > 0) {
|
||||
numColumns = (availContentWidth + colGap)/(colGap + colWidth);
|
||||
if (colGap + colISize > 0) {
|
||||
numColumns = (availContentISize + colGap)/(colGap + colISize);
|
||||
// The number of columns should never exceed kMaxColumnCount.
|
||||
numColumns = std::min(nscoord(nsStyleColumn::kMaxColumnCount),
|
||||
numColumns);
|
||||
@ -265,10 +265,10 @@ nsColumnSetFrame::ChooseColumnStrategy(const nsHTMLReflowState& aReflowState,
|
||||
|
||||
// Compute extra space and divide it among the columns
|
||||
nscoord extraSpace =
|
||||
std::max(0, availContentWidth - (colWidth*numColumns + colGap*(numColumns - 1)));
|
||||
std::max(0, availContentISize - (colISize*numColumns + colGap*(numColumns - 1)));
|
||||
nscoord extraToColumns = extraSpace/numColumns;
|
||||
colWidth += extraToColumns;
|
||||
expectedWidthLeftOver = extraSpace - (extraToColumns*numColumns);
|
||||
colISize += extraToColumns;
|
||||
expectedISizeLeftOver = extraSpace - (extraToColumns*numColumns);
|
||||
}
|
||||
|
||||
if (isBalancing) {
|
||||
@ -277,7 +277,7 @@ nsColumnSetFrame::ChooseColumnStrategy(const nsHTMLReflowState& aReflowState,
|
||||
// and balancing is required. Let's just use one column then.
|
||||
numColumns = 1;
|
||||
}
|
||||
colHeight = std::min(mLastBalanceHeight, colHeight);
|
||||
colBSize = std::min(mLastBalanceBSize, colBSize);
|
||||
} else {
|
||||
// This is the case when the column-fill property is set to 'auto'.
|
||||
// No balancing, so don't limit the column count
|
||||
@ -291,16 +291,16 @@ nsColumnSetFrame::ChooseColumnStrategy(const nsHTMLReflowState& aReflowState,
|
||||
// to have a minimum of 1 css px. Once a resolution is made
|
||||
// on what minimum to have for a page height, we may need to
|
||||
// change this value to match the appropriate spec(s).
|
||||
colHeight = std::max(colHeight, nsPresContext::CSSPixelsToAppUnits(1));
|
||||
colBSize = std::max(colBSize, nsPresContext::CSSPixelsToAppUnits(1));
|
||||
}
|
||||
|
||||
#ifdef DEBUG_roc
|
||||
printf("*** nsColumnSetFrame::ChooseColumnStrategy: numColumns=%d, colWidth=%d, expectedWidthLeftOver=%d, colHeight=%d, colGap=%d\n",
|
||||
numColumns, colWidth, expectedWidthLeftOver, colHeight, colGap);
|
||||
printf("*** nsColumnSetFrame::ChooseColumnStrategy: numColumns=%d, colISize=%d, expectedISizeLeftOver=%d, colBSize=%d, colGap=%d\n",
|
||||
numColumns, colISize, expectedISizeLeftOver, colBSize, colGap);
|
||||
#endif
|
||||
ReflowConfig config = { numColumns, colWidth, expectedWidthLeftOver, colGap,
|
||||
colHeight, isBalancing, knownFeasibleHeight,
|
||||
knownInfeasibleHeight, computedBSize, consumedBSize };
|
||||
ReflowConfig config = { numColumns, colISize, expectedISizeLeftOver, colGap,
|
||||
colBSize, isBalancing, knownFeasibleBSize,
|
||||
knownInfeasibleBSize, computedBSize, consumedBSize };
|
||||
return config;
|
||||
}
|
||||
|
||||
@ -310,14 +310,14 @@ nsColumnSetFrame::ReflowColumns(nsHTMLReflowMetrics& aDesiredSize,
|
||||
nsReflowStatus& aReflowStatus,
|
||||
ReflowConfig& aConfig,
|
||||
bool aLastColumnUnbounded,
|
||||
nsCollapsingMargin* aCarriedOutBottomMargin,
|
||||
nsCollapsingMargin* aCarriedOutBEndMargin,
|
||||
ColumnBalanceData& aColData)
|
||||
{
|
||||
bool feasible = ReflowChildren(aDesiredSize, aReflowState,
|
||||
aReflowStatus, aConfig, aLastColumnUnbounded,
|
||||
aCarriedOutBottomMargin, aColData);
|
||||
aCarriedOutBEndMargin, aColData);
|
||||
|
||||
if (aColData.mHasExcessHeight) {
|
||||
if (aColData.mHasExcessBSize) {
|
||||
aConfig = ChooseColumnStrategy(aReflowState, true);
|
||||
|
||||
// We need to reflow our children again one last time, otherwise we might
|
||||
@ -325,7 +325,7 @@ nsColumnSetFrame::ReflowColumns(nsHTMLReflowMetrics& aDesiredSize,
|
||||
// bailed out of balancing.
|
||||
feasible = ReflowChildren(aDesiredSize, aReflowState, aReflowStatus,
|
||||
aConfig, aLastColumnUnbounded,
|
||||
aCarriedOutBottomMargin, aColData);
|
||||
aCarriedOutBEndMargin, aColData);
|
||||
}
|
||||
|
||||
return feasible;
|
||||
@ -348,23 +348,23 @@ nsColumnSetFrame::GetMinISize(nsRenderingContext *aRenderingContext) {
|
||||
width = mFrames.FirstChild()->GetMinISize(aRenderingContext);
|
||||
}
|
||||
const nsStyleColumn* colStyle = StyleColumn();
|
||||
nscoord colWidth;
|
||||
nscoord colISize;
|
||||
if (colStyle->mColumnWidth.GetUnit() == eStyleUnit_Coord) {
|
||||
colWidth = colStyle->mColumnWidth.GetCoordValue();
|
||||
colISize = colStyle->mColumnWidth.GetCoordValue();
|
||||
// As available width reduces to zero, we reduce our number of columns
|
||||
// to one, and don't enforce the column width, so just return the min
|
||||
// of the child's min-width with any specified column width.
|
||||
width = std::min(width, colWidth);
|
||||
width = std::min(width, colISize);
|
||||
} else {
|
||||
NS_ASSERTION(colStyle->mColumnCount > 0,
|
||||
"column-count and column-width can't both be auto");
|
||||
// As available width reduces to zero, we still have mColumnCount columns,
|
||||
// so multiply the child's min-width by the number of columns.
|
||||
colWidth = width;
|
||||
colISize = width;
|
||||
width *= colStyle->mColumnCount;
|
||||
// The multiplication above can make 'width' negative (integer overflow),
|
||||
// so use std::max to protect against that.
|
||||
width = std::max(width, colWidth);
|
||||
width = std::max(width, colISize);
|
||||
}
|
||||
// XXX count forced column breaks here? Maybe we should return the child's
|
||||
// min-width times the minimum number of columns.
|
||||
@ -382,13 +382,13 @@ nsColumnSetFrame::GetPrefISize(nsRenderingContext *aRenderingContext) {
|
||||
const nsStyleColumn* colStyle = StyleColumn();
|
||||
nscoord colGap = GetColumnGap(this, colStyle);
|
||||
|
||||
nscoord colWidth;
|
||||
nscoord colISize;
|
||||
if (colStyle->mColumnWidth.GetUnit() == eStyleUnit_Coord) {
|
||||
colWidth = colStyle->mColumnWidth.GetCoordValue();
|
||||
colISize = colStyle->mColumnWidth.GetCoordValue();
|
||||
} else if (mFrames.FirstChild()) {
|
||||
colWidth = mFrames.FirstChild()->GetPrefISize(aRenderingContext);
|
||||
colISize = mFrames.FirstChild()->GetPrefISize(aRenderingContext);
|
||||
} else {
|
||||
colWidth = 0;
|
||||
colISize = 0;
|
||||
}
|
||||
|
||||
int32_t numColumns = colStyle->mColumnCount;
|
||||
@ -397,10 +397,10 @@ nsColumnSetFrame::GetPrefISize(nsRenderingContext *aRenderingContext) {
|
||||
numColumns = 1;
|
||||
}
|
||||
|
||||
nscoord width = colWidth*numColumns + colGap*(numColumns - 1);
|
||||
nscoord width = colISize*numColumns + colGap*(numColumns - 1);
|
||||
// The multiplication above can make 'width' negative (integer overflow),
|
||||
// so use std::max to protect against that.
|
||||
result = std::max(width, colWidth);
|
||||
result = std::max(width, colISize);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -410,27 +410,27 @@ nsColumnSetFrame::ReflowChildren(nsHTMLReflowMetrics& aDesiredSize,
|
||||
nsReflowStatus& aStatus,
|
||||
const ReflowConfig& aConfig,
|
||||
bool aUnboundedLastColumn,
|
||||
nsCollapsingMargin* aBottomMarginCarriedOut,
|
||||
nsCollapsingMargin* aCarriedOutBEndMargin,
|
||||
ColumnBalanceData& aColData)
|
||||
{
|
||||
aColData.Reset();
|
||||
bool allFit = true;
|
||||
bool RTL = StyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL;
|
||||
bool shrinkingHeightOnly = !NS_SUBTREE_DIRTY(this) &&
|
||||
mLastBalanceHeight > aConfig.mColMaxHeight;
|
||||
bool shrinkingBSizeOnly = !NS_SUBTREE_DIRTY(this) &&
|
||||
mLastBalanceBSize > aConfig.mColMaxBSize;
|
||||
|
||||
#ifdef DEBUG_roc
|
||||
printf("*** Doing column reflow pass: mLastBalanceHeight=%d, mColMaxHeight=%d, RTL=%d\n, mBalanceColCount=%d, mColWidth=%d, mColGap=%d\n",
|
||||
mLastBalanceHeight, aConfig.mColMaxHeight, RTL, aConfig.mBalanceColCount,
|
||||
aConfig.mColWidth, aConfig.mColGap);
|
||||
printf("*** Doing column reflow pass: mLastBalanceBSize=%d, mColMaxBSize=%d, RTL=%d\n, mBalanceColCount=%d, mColISize=%d, mColGap=%d\n",
|
||||
mLastBalanceBSize, aConfig.mColMaxBSize, RTL, aConfig.mBalanceColCount,
|
||||
aConfig.mColISize, aConfig.mColGap);
|
||||
#endif
|
||||
|
||||
DrainOverflowColumns();
|
||||
|
||||
const bool colHeightChanged = mLastBalanceHeight != aConfig.mColMaxHeight;
|
||||
const bool colBSizeChanged = mLastBalanceBSize != aConfig.mColMaxBSize;
|
||||
|
||||
if (colHeightChanged) {
|
||||
mLastBalanceHeight = aConfig.mColMaxHeight;
|
||||
if (colBSizeChanged) {
|
||||
mLastBalanceBSize = aConfig.mColMaxBSize;
|
||||
// XXX Seems like this could fire if incremental reflow pushed the column set
|
||||
// down so we reflow incrementally with a different available height.
|
||||
// We need a way to do an incremental reflow and be sure availableHeight
|
||||
@ -454,12 +454,12 @@ nsColumnSetFrame::ReflowChildren(nsHTMLReflowMetrics& aDesiredSize,
|
||||
// slop. Otherwise we'll waste time moving the columns by some tiny
|
||||
// amount unnecessarily.
|
||||
if (RTL) {
|
||||
nscoord availWidth = aReflowState.AvailableWidth();
|
||||
nscoord availISize = aReflowState.AvailableWidth();
|
||||
if (aReflowState.ComputedWidth() != NS_INTRINSICSIZE) {
|
||||
availWidth = aReflowState.ComputedWidth();
|
||||
availISize = aReflowState.ComputedWidth();
|
||||
}
|
||||
if (availWidth != NS_INTRINSICSIZE) {
|
||||
childOrigin.x += availWidth - aConfig.mColWidth;
|
||||
if (availISize != NS_INTRINSICSIZE) {
|
||||
childOrigin.x += availISize - aConfig.mColISize;
|
||||
#ifdef DEBUG_roc
|
||||
printf("*** childOrigin.x = %d\n", childOrigin.x);
|
||||
#endif
|
||||
@ -493,12 +493,12 @@ nsColumnSetFrame::ReflowChildren(nsHTMLReflowMetrics& aDesiredSize,
|
||||
// boundary, but if so, too bad, this optimization is defeated.)
|
||||
// We want scrollable overflow here since this is a calculation that
|
||||
// affects layout.
|
||||
bool skipResizeHeightShrink = shrinkingHeightOnly
|
||||
&& child->GetScrollableOverflowRect().YMost() <= aConfig.mColMaxHeight;
|
||||
bool skipResizeBSizeShrink = shrinkingBSizeOnly
|
||||
&& child->GetScrollableOverflowRect().YMost() <= aConfig.mColMaxBSize;
|
||||
|
||||
nscoord childContentBEnd = 0;
|
||||
WritingMode wm = child->GetWritingMode();
|
||||
if (!reflowNext && (skipIncremental || skipResizeHeightShrink)) {
|
||||
if (!reflowNext && (skipIncremental || skipResizeBSizeShrink)) {
|
||||
// This child does not need to be reflowed, but we may need to move it
|
||||
MoveChildTo(this, child, childOrigin);
|
||||
|
||||
@ -514,13 +514,13 @@ nsColumnSetFrame::ReflowChildren(nsHTMLReflowMetrics& aDesiredSize,
|
||||
childContentBEnd = nsLayoutUtils::CalculateContentBEnd(wm, child);
|
||||
#ifdef DEBUG_roc
|
||||
printf("*** Skipping child #%d %p (incremental %d, resize height shrink %d): status = %d\n",
|
||||
columnCount, (void*)child, skipIncremental, skipResizeHeightShrink, aStatus);
|
||||
columnCount, (void*)child, skipIncremental, skipResizeBSizeShrink, aStatus);
|
||||
#endif
|
||||
} else {
|
||||
nsSize physicalSize(aConfig.mColWidth, aConfig.mColMaxHeight);
|
||||
nsSize physicalSize(aConfig.mColISize, aConfig.mColMaxBSize);
|
||||
|
||||
if (aUnboundedLastColumn && columnCount == aConfig.mBalanceColCount - 1) {
|
||||
physicalSize.height = GetAvailableContentHeight(aReflowState);
|
||||
physicalSize.height = GetAvailableContentBSize(aReflowState);
|
||||
}
|
||||
LogicalSize availSize(wm, physicalSize);
|
||||
LogicalSize computedSize = aReflowState.ComputedSize(wm);
|
||||
@ -537,7 +537,7 @@ nsColumnSetFrame::ReflowChildren(nsHTMLReflowMetrics& aDesiredSize,
|
||||
|
||||
// We need to reflow any float placeholders, even if our column height
|
||||
// hasn't changed.
|
||||
kidReflowState.mFlags.mMustReflowPlaceholders = !colHeightChanged;
|
||||
kidReflowState.mFlags.mMustReflowPlaceholders = !colBSizeChanged;
|
||||
|
||||
#ifdef DEBUG_roc
|
||||
printf("*** Reflowing child #%d %p: availHeight=%d\n",
|
||||
@ -577,18 +577,18 @@ nsColumnSetFrame::ReflowChildren(nsHTMLReflowMetrics& aDesiredSize,
|
||||
|
||||
NS_FRAME_TRACE_REFLOW_OUT("Column::Reflow", aStatus);
|
||||
|
||||
*aBottomMarginCarriedOut = kidDesiredSize.mCarriedOutBEndMargin;
|
||||
*aCarriedOutBEndMargin = kidDesiredSize.mCarriedOutBEndMargin;
|
||||
|
||||
FinishReflowChild(child, PresContext(), kidDesiredSize,
|
||||
&kidReflowState, childOrigin.x, childOrigin.y, 0);
|
||||
|
||||
childContentBEnd = nsLayoutUtils::CalculateContentBEnd(wm, child);
|
||||
if (childContentBEnd > aConfig.mColMaxHeight) {
|
||||
if (childContentBEnd > aConfig.mColMaxBSize) {
|
||||
allFit = false;
|
||||
}
|
||||
if (childContentBEnd > availSize.BSize(wm)) {
|
||||
aColData.mMaxOverflowingHeight = std::max(childContentBEnd,
|
||||
aColData.mMaxOverflowingHeight);
|
||||
aColData.mMaxOverflowingBSize = std::max(childContentBEnd,
|
||||
aColData.mMaxOverflowingBSize);
|
||||
}
|
||||
}
|
||||
|
||||
@ -596,8 +596,8 @@ nsColumnSetFrame::ReflowChildren(nsHTMLReflowMetrics& aDesiredSize,
|
||||
|
||||
ConsiderChildOverflow(overflowRects, child);
|
||||
contentBEnd = std::max(contentBEnd, childContentBEnd);
|
||||
aColData.mLastHeight = childContentBEnd;
|
||||
aColData.mSumHeight += childContentBEnd;
|
||||
aColData.mLastBSize = childContentBEnd;
|
||||
aColData.mSumBSize += childContentBEnd;
|
||||
|
||||
// Build a continuation column if necessary
|
||||
nsIFrame* kidNextInFlow = child->GetNextInFlow();
|
||||
@ -641,7 +641,7 @@ nsColumnSetFrame::ReflowChildren(nsHTMLReflowMetrics& aDesiredSize,
|
||||
// We overflowed vertically, but have not exceeded the number of
|
||||
// columns. We're going to go into overflow columns now, so balancing
|
||||
// no longer applies.
|
||||
aColData.mHasExcessHeight = true;
|
||||
aColData.mHasExcessBSize = true;
|
||||
}
|
||||
|
||||
if (columnCount >= aConfig.mBalanceColCount) {
|
||||
@ -674,9 +674,9 @@ nsColumnSetFrame::ReflowChildren(nsHTMLReflowMetrics& aDesiredSize,
|
||||
|
||||
if (child) {
|
||||
if (!RTL) {
|
||||
childOrigin.x += aConfig.mColWidth + aConfig.mColGap;
|
||||
childOrigin.x += aConfig.mColISize + aConfig.mColGap;
|
||||
} else {
|
||||
childOrigin.x -= aConfig.mColWidth + aConfig.mColGap;
|
||||
childOrigin.x -= aConfig.mColISize + aConfig.mColGap;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_roc
|
||||
@ -700,7 +700,7 @@ nsColumnSetFrame::ReflowChildren(nsHTMLReflowMetrics& aDesiredSize,
|
||||
}
|
||||
}
|
||||
|
||||
aColData.mMaxHeight = contentBEnd;
|
||||
aColData.mMaxBSize = contentBEnd;
|
||||
contentRect.height = std::max(contentRect.height, contentBEnd);
|
||||
mLastFrameStatus = aStatus;
|
||||
|
||||
@ -712,12 +712,12 @@ nsColumnSetFrame::ReflowChildren(nsHTMLReflowMetrics& aDesiredSize,
|
||||
|
||||
// Apply computed and min/max values
|
||||
// (aConfig members need to be converted from Width/Height to ISize/BSize)
|
||||
if (aConfig.mComputedHeight != NS_INTRINSICSIZE) {
|
||||
if (aConfig.mComputedBSize != NS_INTRINSICSIZE) {
|
||||
if (aReflowState.AvailableHeight() != NS_INTRINSICSIZE) {
|
||||
contentSize.BSize(wm) = std::min(contentSize.BSize(wm),
|
||||
aConfig.mComputedHeight);
|
||||
aConfig.mComputedBSize);
|
||||
} else {
|
||||
contentSize.BSize(wm) = aConfig.mComputedHeight;
|
||||
contentSize.BSize(wm) = aConfig.mComputedBSize;
|
||||
}
|
||||
} else {
|
||||
// We add the "consumed" height back in so that we're applying
|
||||
@ -727,7 +727,7 @@ nsColumnSetFrame::ReflowChildren(nsHTMLReflowMetrics& aDesiredSize,
|
||||
// has prev-in-flows, trigger a larger height than actually required.
|
||||
contentSize.BSize(wm) =
|
||||
aReflowState.ApplyMinMaxHeight(contentSize.BSize(wm),
|
||||
aConfig.mConsumedHeight);
|
||||
aConfig.mConsumedBSize);
|
||||
}
|
||||
if (aReflowState.ComputedISize() != NS_INTRINSICSIZE) {
|
||||
contentSize.ISize(wm) = aReflowState.ComputedISize();
|
||||
@ -778,7 +778,7 @@ nsColumnSetFrame::DrainOverflowColumns()
|
||||
}
|
||||
|
||||
void
|
||||
nsColumnSetFrame::FindBestBalanceHeight(const nsHTMLReflowState& aReflowState,
|
||||
nsColumnSetFrame::FindBestBalanceBSize(const nsHTMLReflowState& aReflowState,
|
||||
nsPresContext* aPresContext,
|
||||
ReflowConfig& aConfig,
|
||||
ColumnBalanceData& aColData,
|
||||
@ -794,11 +794,11 @@ nsColumnSetFrame::FindBestBalanceHeight(const nsHTMLReflowState& aReflowState,
|
||||
bp.ApplySkipSides(GetSkipSides());
|
||||
bp.bottom = aReflowState.ComputedPhysicalBorderPadding().bottom;
|
||||
|
||||
nscoord availableContentHeight =
|
||||
GetAvailableContentHeight(aReflowState);
|
||||
nscoord availableContentBSize =
|
||||
GetAvailableContentBSize(aReflowState);
|
||||
|
||||
// Termination of the algorithm below is guaranteed because
|
||||
// aConfig.knownFeasibleHeight - aConfig.knownInfeasibleHeight decreases in every
|
||||
// aConfig.knownFeasibleBSize - aConfig.knownInfeasibleBSize decreases in every
|
||||
// iteration.
|
||||
|
||||
// We set this flag when we detect that we may contain a frame
|
||||
@ -807,93 +807,93 @@ nsColumnSetFrame::FindBestBalanceHeight(const nsHTMLReflowState& aReflowState,
|
||||
bool maybeContinuousBreakingDetected = false;
|
||||
|
||||
while (!aPresContext->HasPendingInterrupt()) {
|
||||
nscoord lastKnownFeasibleHeight = aConfig.mKnownFeasibleHeight;
|
||||
nscoord lastKnownFeasibleBSize = aConfig.mKnownFeasibleBSize;
|
||||
|
||||
// Record what we learned from the last reflow
|
||||
if (feasible) {
|
||||
// maxHeight is feasible. Also, mLastBalanceHeight is feasible.
|
||||
aConfig.mKnownFeasibleHeight = std::min(aConfig.mKnownFeasibleHeight,
|
||||
aColData.mMaxHeight);
|
||||
aConfig.mKnownFeasibleHeight = std::min(aConfig.mKnownFeasibleHeight,
|
||||
mLastBalanceHeight);
|
||||
// maxHeight is feasible. Also, mLastBalanceBSize is feasible.
|
||||
aConfig.mKnownFeasibleBSize = std::min(aConfig.mKnownFeasibleBSize,
|
||||
aColData.mMaxBSize);
|
||||
aConfig.mKnownFeasibleBSize = std::min(aConfig.mKnownFeasibleBSize,
|
||||
mLastBalanceBSize);
|
||||
|
||||
// Furthermore, no height less than the height of the last
|
||||
// column can ever be feasible. (We might be able to reduce the
|
||||
// height of a non-last column by moving content to a later column,
|
||||
// but we can't do that with the last column.)
|
||||
if (mFrames.GetLength() == aConfig.mBalanceColCount) {
|
||||
aConfig.mKnownInfeasibleHeight = std::max(aConfig.mKnownInfeasibleHeight,
|
||||
aColData.mLastHeight - 1);
|
||||
aConfig.mKnownInfeasibleBSize = std::max(aConfig.mKnownInfeasibleBSize,
|
||||
aColData.mLastBSize - 1);
|
||||
}
|
||||
} else {
|
||||
aConfig.mKnownInfeasibleHeight = std::max(aConfig.mKnownInfeasibleHeight,
|
||||
mLastBalanceHeight);
|
||||
aConfig.mKnownInfeasibleBSize = std::max(aConfig.mKnownInfeasibleBSize,
|
||||
mLastBalanceBSize);
|
||||
// If a column didn't fit in its available height, then its current
|
||||
// height must be the minimum height for unbreakable content in
|
||||
// the column, and therefore no smaller height can be feasible.
|
||||
aConfig.mKnownInfeasibleHeight = std::max(aConfig.mKnownInfeasibleHeight,
|
||||
aColData.mMaxOverflowingHeight - 1);
|
||||
aConfig.mKnownInfeasibleBSize = std::max(aConfig.mKnownInfeasibleBSize,
|
||||
aColData.mMaxOverflowingBSize - 1);
|
||||
|
||||
if (aUnboundedLastColumn) {
|
||||
// The last column is unbounded, so all content got reflowed, so the
|
||||
// mColMaxHeight is feasible.
|
||||
aConfig.mKnownFeasibleHeight = std::min(aConfig.mKnownFeasibleHeight,
|
||||
aColData.mMaxHeight);
|
||||
// mColMaxBSize is feasible.
|
||||
aConfig.mKnownFeasibleBSize = std::min(aConfig.mKnownFeasibleBSize,
|
||||
aColData.mMaxBSize);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_roc
|
||||
printf("*** nsColumnSetFrame::Reflow balancing knownInfeasible=%d knownFeasible=%d\n",
|
||||
aConfig.mKnownInfeasibleHeight, aConfig.mKnownFeasibleHeight);
|
||||
aConfig.mKnownInfeasibleBSize, aConfig.mKnownFeasibleBSize);
|
||||
#endif
|
||||
|
||||
|
||||
if (aConfig.mKnownInfeasibleHeight >= aConfig.mKnownFeasibleHeight - 1) {
|
||||
// aConfig.mKnownFeasibleHeight is where we want to be
|
||||
if (aConfig.mKnownInfeasibleBSize >= aConfig.mKnownFeasibleBSize - 1) {
|
||||
// aConfig.mKnownFeasibleBSize is where we want to be
|
||||
break;
|
||||
}
|
||||
|
||||
if (aConfig.mKnownInfeasibleHeight >= availableContentHeight) {
|
||||
if (aConfig.mKnownInfeasibleBSize >= availableContentBSize) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (lastKnownFeasibleHeight - aConfig.mKnownFeasibleHeight == 1) {
|
||||
if (lastKnownFeasibleBSize - aConfig.mKnownFeasibleBSize == 1) {
|
||||
// We decreased the feasible height by one twip only. This could
|
||||
// indicate that there is a continuously breakable child frame
|
||||
// that we are crawling through.
|
||||
maybeContinuousBreakingDetected = true;
|
||||
}
|
||||
|
||||
nscoord nextGuess = (aConfig.mKnownFeasibleHeight + aConfig.mKnownInfeasibleHeight)/2;
|
||||
nscoord nextGuess = (aConfig.mKnownFeasibleBSize + aConfig.mKnownInfeasibleBSize)/2;
|
||||
// The constant of 600 twips is arbitrary. It's about two line-heights.
|
||||
if (aConfig.mKnownFeasibleHeight - nextGuess < 600 &&
|
||||
if (aConfig.mKnownFeasibleBSize - nextGuess < 600 &&
|
||||
!maybeContinuousBreakingDetected) {
|
||||
// We're close to our target, so just try shrinking just the
|
||||
// minimum amount that will cause one of our columns to break
|
||||
// differently.
|
||||
nextGuess = aConfig.mKnownFeasibleHeight - 1;
|
||||
nextGuess = aConfig.mKnownFeasibleBSize - 1;
|
||||
} else if (aUnboundedLastColumn) {
|
||||
// Make a guess by dividing that into N columns. Add some slop
|
||||
// to try to make it on the feasible side. The constant of
|
||||
// 600 twips is arbitrary. It's about two line-heights.
|
||||
nextGuess = aColData.mSumHeight/aConfig.mBalanceColCount + 600;
|
||||
nextGuess = aColData.mSumBSize/aConfig.mBalanceColCount + 600;
|
||||
// Sanitize it
|
||||
nextGuess = clamped(nextGuess, aConfig.mKnownInfeasibleHeight + 1,
|
||||
aConfig.mKnownFeasibleHeight - 1);
|
||||
} else if (aConfig.mKnownFeasibleHeight == NS_INTRINSICSIZE) {
|
||||
nextGuess = clamped(nextGuess, aConfig.mKnownInfeasibleBSize + 1,
|
||||
aConfig.mKnownFeasibleBSize - 1);
|
||||
} else if (aConfig.mKnownFeasibleBSize == NS_INTRINSICSIZE) {
|
||||
// This can happen when we had a next-in-flow so we didn't
|
||||
// want to do an unbounded height measuring step. Let's just increase
|
||||
// from the infeasible height by some reasonable amount.
|
||||
nextGuess = aConfig.mKnownInfeasibleHeight*2 + 600;
|
||||
nextGuess = aConfig.mKnownInfeasibleBSize*2 + 600;
|
||||
}
|
||||
// Don't bother guessing more than our height constraint.
|
||||
nextGuess = std::min(availableContentHeight, nextGuess);
|
||||
nextGuess = std::min(availableContentBSize, nextGuess);
|
||||
|
||||
#ifdef DEBUG_roc
|
||||
printf("*** nsColumnSetFrame::Reflow balancing choosing next guess=%d\n", nextGuess);
|
||||
#endif
|
||||
|
||||
aConfig.mColMaxHeight = nextGuess;
|
||||
aConfig.mColMaxBSize = nextGuess;
|
||||
|
||||
aUnboundedLastColumn = false;
|
||||
AddStateBits(NS_FRAME_IS_DIRTY);
|
||||
@ -912,13 +912,13 @@ nsColumnSetFrame::FindBestBalanceHeight(const nsHTMLReflowState& aReflowState,
|
||||
// We may need to reflow one more time at the feasible height to
|
||||
// get a valid layout.
|
||||
bool skip = false;
|
||||
if (aConfig.mKnownInfeasibleHeight >= availableContentHeight) {
|
||||
aConfig.mColMaxHeight = availableContentHeight;
|
||||
if (mLastBalanceHeight == availableContentHeight) {
|
||||
if (aConfig.mKnownInfeasibleBSize >= availableContentBSize) {
|
||||
aConfig.mColMaxBSize = availableContentBSize;
|
||||
if (mLastBalanceBSize == availableContentBSize) {
|
||||
skip = true;
|
||||
}
|
||||
} else {
|
||||
aConfig.mColMaxHeight = aConfig.mKnownFeasibleHeight;
|
||||
aConfig.mColMaxBSize = aConfig.mKnownFeasibleBSize;
|
||||
}
|
||||
if (!skip) {
|
||||
// If our height is unconstrained, make sure that the last column is
|
||||
@ -927,7 +927,7 @@ nsColumnSetFrame::FindBestBalanceHeight(const nsHTMLReflowState& aReflowState,
|
||||
// that.
|
||||
AddStateBits(NS_FRAME_IS_DIRTY);
|
||||
feasible = ReflowColumns(aDesiredSize, aReflowState, aStatus, aConfig,
|
||||
availableContentHeight == NS_UNCONSTRAINEDSIZE,
|
||||
availableContentBSize == NS_UNCONSTRAINEDSIZE,
|
||||
&aOutMargin, aColData);
|
||||
}
|
||||
}
|
||||
@ -992,7 +992,7 @@ nsColumnSetFrame::Reflow(nsPresContext* aPresContext,
|
||||
bool unboundedLastColumn = config.mIsBalancing && !nextInFlow;
|
||||
nsCollapsingMargin carriedOutBottomMargin;
|
||||
ColumnBalanceData colData;
|
||||
colData.mHasExcessHeight = false;
|
||||
colData.mHasExcessBSize = false;
|
||||
|
||||
bool feasible = ReflowColumns(aDesiredSize, aReflowState, aStatus, config,
|
||||
unboundedLastColumn, &carriedOutBottomMargin,
|
||||
@ -1002,7 +1002,7 @@ nsColumnSetFrame::Reflow(nsPresContext* aPresContext,
|
||||
// reflown all of our children, and there is no need for a binary search to
|
||||
// determine proper column height.
|
||||
if (config.mIsBalancing && !aPresContext->HasPendingInterrupt()) {
|
||||
FindBestBalanceHeight(aReflowState, aPresContext, config, colData,
|
||||
FindBestBalanceBSize(aReflowState, aPresContext, config, colData,
|
||||
aDesiredSize, carriedOutBottomMargin,
|
||||
unboundedLastColumn, feasible, aStatus);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
* Retrieve the available height for content of this frame. The available content
|
||||
* height is the available height for the frame, minus borders and padding.
|
||||
*/
|
||||
virtual nscoord GetAvailableContentHeight(const nsHTMLReflowState& aReflowState);
|
||||
virtual nscoord GetAvailableContentBSize(const nsHTMLReflowState& aReflowState);
|
||||
|
||||
virtual nsContainerFrame* GetContentInsertionFrame() MOZ_OVERRIDE {
|
||||
nsIFrame* frame = GetFirstPrincipalChild();
|
||||
@ -92,7 +92,7 @@ public:
|
||||
#endif
|
||||
|
||||
protected:
|
||||
nscoord mLastBalanceHeight;
|
||||
nscoord mLastBalanceBSize;
|
||||
nsReflowStatus mLastFrameStatus;
|
||||
|
||||
/**
|
||||
@ -104,11 +104,11 @@ protected:
|
||||
int32_t mBalanceColCount;
|
||||
|
||||
// The width of each individual column.
|
||||
nscoord mColWidth;
|
||||
nscoord mColISize;
|
||||
|
||||
// The amount of width that is expected to be left over after all the
|
||||
// columns and column gaps are laid out.
|
||||
nscoord mExpectedWidthLeftOver;
|
||||
nscoord mExpectedISizeLeftOver;
|
||||
|
||||
// The width of each column gap.
|
||||
nscoord mColGap;
|
||||
@ -116,7 +116,7 @@ protected:
|
||||
// The maximum height of any individual column during a reflow iteration.
|
||||
// This parameter is set during each iteration of the binary search for
|
||||
// the best column height.
|
||||
nscoord mColMaxHeight;
|
||||
nscoord mColMaxBSize;
|
||||
|
||||
// A boolean controlling whether or not we are balancing. This should be
|
||||
// equivalent to mBalanceColCount == INT32_MAX.
|
||||
@ -124,19 +124,19 @@ protected:
|
||||
|
||||
// The last known column height that was 'feasible'. A column height is
|
||||
// feasible if all child content fits within the specified height.
|
||||
nscoord mKnownFeasibleHeight;
|
||||
nscoord mKnownFeasibleBSize;
|
||||
|
||||
// The last known height that was 'infeasible'. A column height is
|
||||
// infeasible if not all child content fits within the specified height.
|
||||
nscoord mKnownInfeasibleHeight;
|
||||
nscoord mKnownInfeasibleBSize;
|
||||
|
||||
// Height of the column set frame
|
||||
nscoord mComputedHeight;
|
||||
nscoord mComputedBSize;
|
||||
|
||||
// The height "consumed" by previous-in-flows.
|
||||
// The computed height should be equal to the height of the element (i.e.
|
||||
// the computed height itself) plus the consumed height.
|
||||
nscoord mConsumedHeight;
|
||||
nscoord mConsumedBSize;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -144,22 +144,22 @@ protected:
|
||||
*/
|
||||
struct ColumnBalanceData {
|
||||
// The maximum "content height" of any column
|
||||
nscoord mMaxHeight;
|
||||
nscoord mMaxBSize;
|
||||
// The sum of the "content heights" for all columns
|
||||
nscoord mSumHeight;
|
||||
nscoord mSumBSize;
|
||||
// The "content height" of the last column
|
||||
nscoord mLastHeight;
|
||||
nscoord mLastBSize;
|
||||
// The maximum "content height" of all columns that overflowed
|
||||
// their available height
|
||||
nscoord mMaxOverflowingHeight;
|
||||
nscoord mMaxOverflowingBSize;
|
||||
// This flag determines whether the last reflow of children exceeded the
|
||||
// computed height of the column set frame. If so, we set the height to
|
||||
// this maximum allowable height, and continue reflow without balancing.
|
||||
bool mHasExcessHeight;
|
||||
bool mHasExcessBSize;
|
||||
|
||||
void Reset() {
|
||||
mMaxHeight = mSumHeight = mLastHeight = mMaxOverflowingHeight = 0;
|
||||
mHasExcessHeight = false;
|
||||
mMaxBSize = mSumBSize = mLastBSize = mMaxOverflowingBSize = 0;
|
||||
mHasExcessBSize = false;
|
||||
}
|
||||
};
|
||||
|
||||
@ -168,7 +168,7 @@ protected:
|
||||
nsReflowStatus& aReflowStatus,
|
||||
ReflowConfig& aConfig,
|
||||
bool aLastColumnUnbounded,
|
||||
nsCollapsingMargin* aCarriedOutBottomMargin,
|
||||
nsCollapsingMargin* aCarriedOutBEndMargin,
|
||||
ColumnBalanceData& aColData);
|
||||
|
||||
/**
|
||||
@ -179,8 +179,8 @@ protected:
|
||||
* the state machine that controls column balancing.
|
||||
*/
|
||||
ReflowConfig ChooseColumnStrategy(const nsHTMLReflowState& aReflowState,
|
||||
bool aForceAuto, nscoord aFeasibleHeight,
|
||||
nscoord aInfeasibleHeight);
|
||||
bool aForceAuto, nscoord aFeasibleBSize,
|
||||
nscoord aInfeasibleBSize);
|
||||
|
||||
/**
|
||||
* Perform the binary search for the best balance height for this column set.
|
||||
@ -206,7 +206,7 @@ protected:
|
||||
* @param aStatus A final reflow status of the column set frame, passed in as
|
||||
* an output parameter.
|
||||
*/
|
||||
void FindBestBalanceHeight(const nsHTMLReflowState& aReflowState,
|
||||
void FindBestBalanceBSize(const nsHTMLReflowState& aReflowState,
|
||||
nsPresContext* aPresContext,
|
||||
ReflowConfig& aConfig,
|
||||
ColumnBalanceData& aColData,
|
||||
@ -217,14 +217,14 @@ protected:
|
||||
nsReflowStatus& aStatus);
|
||||
/**
|
||||
* Reflow column children. Returns true iff the content that was reflowed
|
||||
* fit into the mColMaxHeight.
|
||||
* fit into the mColMaxBSize.
|
||||
*/
|
||||
bool ReflowChildren(nsHTMLReflowMetrics& aDesiredSize,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsReflowStatus& aStatus,
|
||||
const ReflowConfig& aConfig,
|
||||
bool aLastColumnUnbounded,
|
||||
nsCollapsingMargin* aCarriedOutBottomMargin,
|
||||
nsCollapsingMargin* aCarriedOutBEndMargin,
|
||||
ColumnBalanceData& aColData);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user