Commit 4463a612 authored by Mats Palmgren's avatar Mats Palmgren
Browse files

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

parent e1e299bc
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -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",
+1 −1
Original line number Diff line number Diff line
@@ -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: