Bug 841847: Ensure that we reflow a flex container's children, if any of them received a "measuring" reflow. r=dbaron a=lsblakk
authorDaniel Holbert <dholbert@cs.stanford.edu>
Fri, 22 Feb 2013 22:32:30 -0800
changeset 132237 f1a067a808194f474ff413b5e092f0a6dcf4d2af
parent 132236 f16d6c390b5ddc0647d0735a32b6e1096ea44dd4
child 132238 66736a53ee171fd5db219a17dabb664885ca589a
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron, lsblakk
bugs841847
milestone21.0a2
Bug 841847: Ensure that we reflow a flex container's children, if any of them received a "measuring" reflow. r=dbaron a=lsblakk
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