Bug 725376 - Don't do column balancing deeper than 5 nested levels to avoid hang. r=roc
This commit is contained in:
@@ -364,6 +364,22 @@ nsColumnSetFrame::ChooseColumnStrategy(const nsHTMLReflowState& aReflowState)
|
|||||||
nscoord colGap = GetColumnGap(this, colStyle);
|
nscoord colGap = GetColumnGap(this, colStyle);
|
||||||
PRInt32 numColumns = colStyle->mColumnCount;
|
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;
|
nscoord colWidth;
|
||||||
if (colStyle->mColumnWidth.GetUnit() == eStyleUnit_Coord) {
|
if (colStyle->mColumnWidth.GetUnit() == eStyleUnit_Coord) {
|
||||||
colWidth = colStyle->mColumnWidth.GetCoordValue();
|
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 column-fill is set to 'balance', then we want to balance the columns.
|
||||||
if (colStyle->mColumnFill == NS_STYLE_COLUMN_FILL_BALANCE) {
|
if (isBalancing) {
|
||||||
// Balancing!
|
// Balancing!
|
||||||
|
|
||||||
if (numColumns <= 0) {
|
if (numColumns <= 0) {
|
||||||
@@ -657,6 +673,7 @@ nsColumnSetFrame::ReflowChildren(nsHTMLReflowMetrics& aDesiredSize,
|
|||||||
aReflowState.ComputedHeight());
|
aReflowState.ComputedHeight());
|
||||||
kidReflowState.mFlags.mIsTopOfPage = true;
|
kidReflowState.mFlags.mIsTopOfPage = true;
|
||||||
kidReflowState.mFlags.mTableIsSplittable = false;
|
kidReflowState.mFlags.mTableIsSplittable = false;
|
||||||
|
kidReflowState.mFlags.mIsColumnBalancing = aConfig.mBalanceColCount < PR_INT32_MAX;
|
||||||
|
|
||||||
#ifdef DEBUG_roc
|
#ifdef DEBUG_roc
|
||||||
printf("*** Reflowing child #%d %p: availHeight=%d\n",
|
printf("*** Reflowing child #%d %p: availHeight=%d\n",
|
||||||
|
|||||||
@@ -367,7 +367,7 @@ public:
|
|||||||
// and never insider a column frame
|
// and never insider a column frame
|
||||||
PRUint16 mHeightDependsOnAncestorCell:1; // Does frame height depend on
|
PRUint16 mHeightDependsOnAncestorCell:1; // Does frame height depend on
|
||||||
// an ancestor table-cell?
|
// an ancestor table-cell?
|
||||||
|
PRUint16 mIsColumnBalancing:1; // nsColumnSetFrame is balancing columns
|
||||||
} mFlags;
|
} mFlags;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user