Bug 725376 - Don't do column balancing deeper than 5 nested levels to avoid hang. r=roc

This commit is contained in:
Mats Palmgren 2012-02-12 22:21:51 +01:00
parent d28a42b8c2
commit 2fd1364623
2 changed files with 19 additions and 2 deletions

View File

@ -364,6 +364,22 @@ nsColumnSetFrame::ChooseColumnStrategy(const nsHTMLReflowState& aReflowState)
nscoord colGap = GetColumnGap(this, colStyle);
PRInt32 numColumns = colStyle->mColumnCount;
bool isBalancing = colStyle->mColumnFill == NS_STYLE_COLUMN_FILL_BALANCE;
if (isBalancing) {
const PRUint32 MAX_NESTED_COLUMN_BALANCING = 5;
PRUint32 cnt = 1;
for (const nsHTMLReflowState* rs = aReflowState.parentReflowState;
rs && cnt < MAX_NESTED_COLUMN_BALANCING;
rs = rs->parentReflowState) {
if (rs->mFlags.mIsColumnBalancing) {
++cnt;
}
}
if (cnt == MAX_NESTED_COLUMN_BALANCING) {
numColumns = 1;
}
}
nscoord colWidth;
if (colStyle->mColumnWidth.GetUnit() == eStyleUnit_Coord) {
colWidth = colStyle->mColumnWidth.GetCoordValue();
@ -417,7 +433,7 @@ nsColumnSetFrame::ChooseColumnStrategy(const nsHTMLReflowState& aReflowState)
}
// If column-fill is set to 'balance', then we want to balance the columns.
if (colStyle->mColumnFill == NS_STYLE_COLUMN_FILL_BALANCE) {
if (isBalancing) {
// Balancing!
if (numColumns <= 0) {
@ -657,6 +673,7 @@ nsColumnSetFrame::ReflowChildren(nsHTMLReflowMetrics& aDesiredSize,
aReflowState.ComputedHeight());
kidReflowState.mFlags.mIsTopOfPage = true;
kidReflowState.mFlags.mTableIsSplittable = false;
kidReflowState.mFlags.mIsColumnBalancing = aConfig.mBalanceColCount < PR_INT32_MAX;
#ifdef DEBUG_roc
printf("*** Reflowing child #%d %p: availHeight=%d\n",

View File

@ -367,7 +367,7 @@ public:
// and never insider a column frame
PRUint16 mHeightDependsOnAncestorCell:1; // Does frame height depend on
// an ancestor table-cell?
PRUint16 mIsColumnBalancing:1; // nsColumnSetFrame is balancing columns
} mFlags;
private: