Bug 841847: Ensure that we reflow a flex container's children, if any of them received a "measuring" reflow. r=dbaron
authorDaniel Holbert <dholbert@cs.stanford.edu>
Fri, 22 Feb 2013 22:32:30 -0800
changeset 122729 d339d3b173d42b7a23301977c02a2c529890b7cc
parent 122728 5f688e2b37dccad4022bede8f5fdd199a8c2db1e
child 122730 7a332016b950d426a3c3242581d1b50690936ae0
push id24356
push usergszorc@mozilla.com
push dateSun, 24 Feb 2013 01:00:12 +0000
treeherdermozilla-central@195e706140d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs841847
milestone22.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 841847: Ensure that we reflow a flex container's children, if any of them received a "measuring" reflow. r=dbaron
layout/generic/nsFlexContainerFrame.cpp
layout/reftests/flexbox/flexbox-dyn-changeFrameWidth-2-iframe.html
layout/reftests/flexbox/flexbox-dyn-changeFrameWidth-2-ref.xhtml
layout/reftests/flexbox/flexbox-dyn-changeFrameWidth-2.xhtml
layout/reftests/flexbox/flexbox-dyn-changeFrameWidth-3-iframe.html
layout/reftests/flexbox/flexbox-dyn-changeFrameWidth-3-ref.xhtml
layout/reftests/flexbox/flexbox-dyn-changeFrameWidth-3.xhtml
layout/reftests/flexbox/reftest.list
--- a/layout/generic/nsFlexContainerFrame.cpp
+++ b/layout/generic/nsFlexContainerFrame.cpp
@@ -2123,16 +2123,29 @@ nsFlexContainerFrame::Reflow(nsPresConte
 
   // Our frame's main-size is the content-box size plus border and padding.
   nscoord frameMainSize = flexContainerMainSize +
     axisTracker.GetMarginSizeInMainAxis(aReflowState.mComputedBorderPadding);
 
   nscoord frameCrossSize;
 
   if (!shouldReflowChildren) {
+    // So far, it looks like none of our flex items need a reflow.
+    // HOWEVER: if we already gave any of them a measuring reflow, then we
+    // should consider it dirty -- it'll need a "real" reflow to undo the
+    // effects of our measuring reflow.
+    for (uint32_t i = 0; i < items.Length(); ++i) {
+      if (items[i].HadMeasuringReflow()) {
+        shouldReflowChildren = true;
+        break;
+      }
+    }
+  }
+
+  if (!shouldReflowChildren) {
     // Children don't need reflow --> assume our content-box size is the same
     // since our last reflow.
     frameCrossSize = mCachedContentBoxCrossSize +
       axisTracker.GetMarginSizeInCrossAxis(aReflowState.mComputedBorderPadding);
   } else {
     MainAxisPositionTracker mainAxisPosnTracker(this, axisTracker,
                                                 aReflowState, items);
 
copy from layout/reftests/flexbox/flexbox-dyn-changeFrameWidth-1-iframe.html
copy to layout/reftests/flexbox/flexbox-dyn-changeFrameWidth-2-iframe.html
--- a/layout/reftests/flexbox/flexbox-dyn-changeFrameWidth-1-iframe.html
+++ b/layout/reftests/flexbox/flexbox-dyn-changeFrameWidth-2-iframe.html
@@ -1,24 +1,27 @@
 <html>
   <head>
     <style>
       body {
         margin: 0;
       }
-      .outerContainer {
+      #container {
         display: flex;
-        height: 100px;
+        flex-direction: column;
+        border: 10px solid lime;
+        width: 80px;
+        height: 80px;
         background-color: red;
       }
-      .innerContainer {
-        display: flex;
-        flex: 1;
+      #item {
         background-color: lime;
+        width: 80px;
+        height: 80px;
       }
     </style>
   </head>
   <body>
-    <div class="outerContainer">
-      <div class="innerContainer"></div>
+    <div id="container">
+      <div id="item"></div>
     </div>
   </body>
 </html>
copy from layout/reftests/flexbox/flexbox-dyn-changeFrameWidth-1-ref.xhtml
copy to layout/reftests/flexbox/flexbox-dyn-changeFrameWidth-2-ref.xhtml
copy from layout/reftests/flexbox/flexbox-dyn-changeFrameWidth-1.xhtml
copy to layout/reftests/flexbox/flexbox-dyn-changeFrameWidth-2.xhtml
--- a/layout/reftests/flexbox/flexbox-dyn-changeFrameWidth-1.xhtml
+++ b/layout/reftests/flexbox/flexbox-dyn-changeFrameWidth-2.xhtml
@@ -1,16 +1,17 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
      Any copyright is dedicated to the Public Domain.
      http://creativecommons.org/publicdomain/zero/1.0/
 -->
 <!--
-    This test checks that we reflow nested flex containers sufficiently when
-    the window (or the iframe we're inside of) is horizontally resized.
+    This test checks that we don't end up with the effects of an intermediate
+    "measuring" reflow left over, when we resize a window that contains a
+    vertical flex container with a fixed-height flex item.
 
     This test should end up rendering as a lime square, 100px by 100px.
 -->
 <html xmlns="http://www.w3.org/1999/xhtml"
       class="reftest-wait">
   <head>
     <style>
       #frame {
@@ -23,11 +24,11 @@
       function tweak() {
         document.getElementById("frame").style.width = "100px";
         document.documentElement.removeAttribute("class");
       }
       window.addEventListener("MozReftestInvalidate", tweak, false);
     </script>
   </head>
   <body>
-    <iframe id="frame" src="flexbox-dyn-changeFrameWidth-1-iframe.html"></iframe>
+    <iframe id="frame" src="flexbox-dyn-changeFrameWidth-2-iframe.html"></iframe>
   </body>
 </html>
copy from layout/reftests/flexbox/flexbox-dyn-changeFrameWidth-1-iframe.html
copy to layout/reftests/flexbox/flexbox-dyn-changeFrameWidth-3-iframe.html
--- a/layout/reftests/flexbox/flexbox-dyn-changeFrameWidth-1-iframe.html
+++ b/layout/reftests/flexbox/flexbox-dyn-changeFrameWidth-3-iframe.html
@@ -1,24 +1,29 @@
 <html>
   <head>
     <style>
       body {
         margin: 0;
       }
-      .outerContainer {
+      #container {
         display: flex;
-        height: 100px;
+        flex-direction: column;
+        border: 10px solid lime;
+        width: 80px;
+        height: 80px;
         background-color: red;
       }
-      .innerContainer {
-        display: flex;
-        flex: 1;
+      #item {
         background-color: lime;
+        min-height: 0;
+        width: 80px;
+        height: auto;
+        line-height: 80px;
       }
     </style>
   </head>
   <body>
-    <div class="outerContainer">
-      <div class="innerContainer"></div>
+    <div id="container">
+      <div id="item">&nbsp;</div>
     </div>
   </body>
 </html>
copy from layout/reftests/flexbox/flexbox-dyn-changeFrameWidth-1-ref.xhtml
copy to layout/reftests/flexbox/flexbox-dyn-changeFrameWidth-3-ref.xhtml
copy from layout/reftests/flexbox/flexbox-dyn-changeFrameWidth-1.xhtml
copy to layout/reftests/flexbox/flexbox-dyn-changeFrameWidth-3.xhtml
--- a/layout/reftests/flexbox/flexbox-dyn-changeFrameWidth-1.xhtml
+++ b/layout/reftests/flexbox/flexbox-dyn-changeFrameWidth-3.xhtml
@@ -1,16 +1,17 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
      Any copyright is dedicated to the Public Domain.
      http://creativecommons.org/publicdomain/zero/1.0/
 -->
 <!--
-    This test checks that we reflow nested flex containers sufficiently when
-    the window (or the iframe we're inside of) is horizontally resized.
+    This test checks that we don't end up with the effects of an intermediate
+    "measuring" reflow left over, when we resize a window that contains a
+    vertical flex container with an auto-height flex item.
 
     This test should end up rendering as a lime square, 100px by 100px.
 -->
 <html xmlns="http://www.w3.org/1999/xhtml"
       class="reftest-wait">
   <head>
     <style>
       #frame {
@@ -23,11 +24,11 @@
       function tweak() {
         document.getElementById("frame").style.width = "100px";
         document.documentElement.removeAttribute("class");
       }
       window.addEventListener("MozReftestInvalidate", tweak, false);
     </script>
   </head>
   <body>
-    <iframe id="frame" src="flexbox-dyn-changeFrameWidth-1-iframe.html"></iframe>
+    <iframe id="frame" src="flexbox-dyn-changeFrameWidth-3-iframe.html"></iframe>
   </body>
 </html>
--- a/layout/reftests/flexbox/reftest.list
+++ b/layout/reftests/flexbox/reftest.list
@@ -66,16 +66,18 @@ fails == flexbox-basic-img-vert-2.xhtml 
 == flexbox-basic-textarea-vert-2.xhtml  flexbox-basic-textarea-vert-2-ref.xhtml
 == flexbox-basic-video-horiz-1.xhtml    flexbox-basic-video-horiz-1-ref.xhtml
 == flexbox-basic-video-horiz-2.xhtml    flexbox-basic-video-horiz-2-ref.xhtml
 == flexbox-basic-video-vert-1.xhtml     flexbox-basic-video-vert-1-ref.xhtml
 fails == flexbox-basic-video-vert-2.xhtml flexbox-basic-video-vert-2-ref.xhtml # bug 794660
 
 # Tests for dynamic modifications of content inside/around a flex container
 == flexbox-dyn-changeFrameWidth-1.xhtml flexbox-dyn-changeFrameWidth-1-ref.xhtml
+== flexbox-dyn-changeFrameWidth-2.xhtml flexbox-dyn-changeFrameWidth-2-ref.xhtml
+== flexbox-dyn-changeFrameWidth-3.xhtml flexbox-dyn-changeFrameWidth-3-ref.xhtml
 == flexbox-dyn-changePadding-1a.xhtml flexbox-dyn-changePadding-1-ref.xhtml
 == flexbox-dyn-changePadding-1b.xhtml flexbox-dyn-changePadding-1-ref.xhtml
 
 # Tests for dynamic insertions of content into a flex container
 # (with existing [div | span | text] inside the flexbox, and new content
 # inserted adjacent to that existing content.)
 == flexbox-dyn-insertAroundDiv-1.xhtml flexbox-dyn-insertAroundDiv-1-ref.xhtml
 == flexbox-dyn-insertAroundDiv-2.xhtml flexbox-dyn-insertAroundDiv-2-ref.xhtml