Bug 389462 - columns don't reflow on resize r=roc
authorfantasai <fantasai.cvs@inkedblade.net>
Mon, 06 Jul 2009 18:23:24 -0700
changeset 30044 a13eed3a20e7fa58718c290580a66f219b56a3cf
parent 30043 f46e6aee13358520ea32ab998a74a304c870e630
child 30045 cbca9757bf6e99297b9d0ad7c8509170c5b8daa4
push id7887
push userfantasai.cvs@inkedblade.net
push dateTue, 07 Jul 2009 01:24:43 +0000
treeherdermozilla-central@a13eed3a20e7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs389462
milestone1.9.2a1pre
Bug 389462 - columns don't reflow on resize r=roc
layout/generic/nsBlockFrame.cpp
layout/generic/nsColumnSetFrame.cpp
layout/reftests/pagination/reftest.list
layout/reftests/pagination/resize-reflow-000.html
layout/reftests/pagination/resize-reflow-000.ref.html
layout/reftests/pagination/resize-reflow-001.html
layout/reftests/pagination/resize-reflow-001.inner.html
layout/reftests/pagination/resize-reflow-001.ref.html
--- a/layout/generic/nsBlockFrame.cpp
+++ b/layout/generic/nsBlockFrame.cpp
@@ -1772,17 +1772,27 @@ nsBlockFrame::ReflowDirtyLines(nsBlockRe
     printf(" computedWidth=%d\n", aState.mReflowState.ComputedWidth());
   }
   AutoNoisyIndenter indent(gNoisyReflow);
 #endif
 
   PRBool selfDirty = (GetStateBits() & NS_FRAME_IS_DIRTY) ||
                      (aState.mReflowState.mFlags.mVResize &&
                       (GetStateBits() & NS_FRAME_CONTAINS_RELATIVE_HEIGHT));
-  
+
+  // Reflow our last line if our availableHeight has increased
+  // so that we (and our last child) pull up content as necessary
+  if (aState.mReflowState.availableHeight != NS_UNCONSTRAINEDSIZE
+      && GetNextInFlow() && aState.mReflowState.availableHeight > mRect.height) {
+    line_iterator lastLine = end_lines();
+    if (lastLine != begin_lines()) {
+      --lastLine;
+      lastLine->MarkDirty();
+    }
+  }
     // the amount by which we will slide the current line if it is not
     // dirty
   nscoord deltaY = 0;
 
     // whether we did NOT reflow the previous line and thus we need to
     // recompute the carried out margin before the line if we want to
     // reflow it or if its previous margin is dirty
   PRBool needToRecoverState = PR_FALSE;
--- a/layout/generic/nsColumnSetFrame.cpp
+++ b/layout/generic/nsColumnSetFrame.cpp
@@ -586,17 +586,17 @@ nsColumnSetFrame::ReflowChildren(nsHTMLR
     // might be pullable back to this column. We can't skip if it's the last child
     // because we need to obtain the bottom margin. We can't skip
     // if this is the last column and we're supposed to assign unbounded
     // height to it, because that could change the available height from
     // the last time we reflowed it and we should try to pull all the
     // content from its next sibling. (Note that it might be the last
     // column, but not be the last child because the desired number of columns
     // has changed.)
-    PRBool skipIncremental = !(GetStateBits() & NS_FRAME_IS_DIRTY)
+    PRBool skipIncremental = !aReflowState.ShouldReflowAllKids()
       && !NS_SUBTREE_DIRTY(child)
       && child->GetNextSibling()
       && !(aUnboundedLastColumn && columnCount == aConfig.mBalanceColCount - 1)
       && !NS_SUBTREE_DIRTY(child->GetNextSibling());
     // If we need to pull up content from the prev-in-flow then this is not just
     // a height shrink. The prev in flow will have set the dirty bit.
     // Check the overflow rect YMost instead of just the child's content height. The child
     // may have overflowing content that cares about the available height boundary.
@@ -902,16 +902,26 @@ nsColumnSetFrame::Reflow(nsPresContext* 
                          nsReflowStatus&          aStatus)
 {
   DO_GLOBAL_REFLOW_COUNT("nsColumnSetFrame");
   DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
 
   // Initialize OUT parameter
   aStatus = NS_FRAME_COMPLETE;
 
+  // Our children depend on our height if we have a fixed height.
+  if (aReflowState.ComputedHeight() != NS_AUTOHEIGHT) {
+    NS_ASSERTION(aReflowState.ComputedHeight() != NS_INTRINSICSIZE,
+                 "Unexpected mComputedHeight");
+    AddStateBits(NS_FRAME_CONTAINS_RELATIVE_HEIGHT);
+  }
+  else {
+    RemoveStateBits(NS_FRAME_CONTAINS_RELATIVE_HEIGHT);
+  }
+
   //------------ Handle Incremental Reflow -----------------
 
   ReflowConfig config = ChooseColumnStrategy(aReflowState);
   PRBool isBalancing = config.mBalanceColCount < PR_INT32_MAX;
   
   // If balancing, then we allow the last column to grow to unbounded
   // height during the first reflow. This gives us a way to estimate
   // what the average column height should be, because we can measure
--- a/layout/reftests/pagination/reftest.list
+++ b/layout/reftests/pagination/reftest.list
@@ -18,8 +18,10 @@ fails == border-breaking-004-cols.xhtml 
 == content-inserted-005.xhtml content-inserted-002.ref.xhtml
 == content-inserted-006.xhtml content-inserted-002.ref.xhtml
 == content-inserted-007.xhtml content-inserted-002.ref.xhtml
 == content-inserted-008.xhtml content-inserted-001.ref.xhtml
 == content-inserted-009.xhtml content-inserted-002.ref.xhtml
 == abspos-breaking-000.xhtml abspos-breaking-000.ref.xhtml
 == abspos-breaking-001.xhtml abspos-breaking-000.ref.xhtml
 == abspos-breaking-002.xhtml abspos-breaking-000.ref.xhtml
+== resize-reflow-000.html resize-reflow-000.ref.html
+== resize-reflow-001.html resize-reflow-001.ref.html
new file mode 100644
--- /dev/null
+++ b/layout/reftests/pagination/resize-reflow-000.html
@@ -0,0 +1,28 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Resize Reflow Test</title>
+</head>
+<body>
+
+<div style="-moz-column-width: 12em;
+            border: silver solid;
+            width: 30em" id="outer">
+x <div style="border: dotted;
+              background: aqua;
+              color: gray;">
+        blah<br>
+        blah<br>
+        blah<br>
+        blah
+  </div>
+</div>
+
+<script>
+document.body.offsetWidth;
+n = document.getElementById("outer").firstChild;
+n.data = ' ';
+</script>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/pagination/resize-reflow-000.ref.html
@@ -0,0 +1,22 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Resize Reflow Test</title>
+</head>
+<body>
+
+<div style="-moz-column-width: 12em;
+            border: silver solid;
+            width: 30em" id="outer">
+  <div style="border: dotted;
+              background: aqua;
+              color: gray;">
+        blah<br>
+        blah<br>
+        blah<br>
+        blah
+  </div>
+</div>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/pagination/resize-reflow-001.html
@@ -0,0 +1,19 @@
+<!DOCTYPE HTML>
+<html class="reftest-wait">
+<title>Resize Reflow Harness</title>
+  <style>
+    html,body { height: 100%; }
+  </style>
+<body onload="
+var iframe = document.getElementById('outer')
+iframe.style.width = '50em';
+iframe.contentDocument.body.offsetWidth;
+iframe.style.width = '28em';
+document.documentElement.className = '';
+">
+
+<iframe id="outer" src="resize-reflow-001.inner.html" height="90%" frameborder=0></iframe>
+
+<script>
+
+</script>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/pagination/resize-reflow-001.inner.html
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Resize Reflow Test</title>
+  <style>
+    html, body { margin: 0; padding: 0; }
+    html { overflow: hidden }
+  </style>
+</head>
+<body>
+
+<div style="-moz-column-width: 12em;
+            border: silver solid;
+            height: 3em;">
+  <div style="border: dotted;
+              background: aqua;
+              color: gray;">
+        blah<br>
+        blah<br>
+        blah<br>
+        blah
+  </div>
+</div>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/pagination/resize-reflow-001.ref.html
@@ -0,0 +1,22 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Resize Reflow Test</title>
+</head>
+<body style="width: 28em">
+
+<div style="-moz-column-width: 12em;
+            border: silver solid;
+            height: 3em;">
+  <div style="border: dotted;
+              background: aqua;
+              color: gray;">
+        blah<br>
+        blah<br>
+        blah<br>
+        blah
+  </div>
+</div>
+
+</body>
+</html>