Bug 956046: Allow adjacent anonymous flex items if we've reordered items with the "order" property. r=dbaron
authorDaniel Holbert <dholbert@cs.stanford.edu>
Wed, 08 Jan 2014 14:37:13 -0800
changeset 178659 8342bfb3ef5296de6a11e37299aefa4447a4e70b
parent 178658 7a992353f9c7cc9006c12e4560cf15e02567d140
child 178660 cad9ce8315a498999ed05ccc635e050b7dd8821b
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs956046
milestone29.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 956046: Allow adjacent anonymous flex items if we've reordered items with the "order" property. r=dbaron
layout/generic/nsFlexContainerFrame.cpp
layout/reftests/w3c-css/submitted/flexbox/flexbox-anonymous-items-1-ref.html
layout/reftests/w3c-css/submitted/flexbox/flexbox-anonymous-items-1.html
layout/reftests/w3c-css/submitted/flexbox/reftest.list
--- a/layout/generic/nsFlexContainerFrame.cpp
+++ b/layout/generic/nsFlexContainerFrame.cpp
@@ -1354,18 +1354,19 @@ nsFlexContainerFrame::SanityCheckAnonymo
   bool prevChildWasAnonFlexItem = false;
   for (nsIFrame* child = mFrames.FirstChild(); child;
        child = child->GetNextSibling()) {
     MOZ_ASSERT(!FrameWantsToBeInAnonymousFlexItem(child),
                "frame wants to be inside an anonymous flex item, "
                "but it isn't");
     if (child->StyleContext()->GetPseudo() ==
         nsCSSAnonBoxes::anonymousFlexItem) {
-      MOZ_ASSERT(!prevChildWasAnonFlexItem,
-                 "two anon flex items in a row (shouldn't happen)");
+      MOZ_ASSERT(!prevChildWasAnonFlexItem || mChildrenHaveBeenReordered,
+                 "two anon flex items in a row (shouldn't happen, unless our "
+                 "children have been reordered with the 'order' property)");
 
       nsIFrame* firstWrappedChild = child->GetFirstPrincipalChild();
       MOZ_ASSERT(firstWrappedChild,
                  "anonymous flex item is empty (shouldn't happen)");
       prevChildWasAnonFlexItem = true;
     } else {
       prevChildWasAnonFlexItem = false;
     }
new file mode 100644
--- /dev/null
+++ b/layout/reftests/w3c-css/submitted/flexbox/flexbox-anonymous-items-1-ref.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<html>
+<head>
+  <title>CSS Reftest Reference</title>
+  <link rel="author" title="Daniel Holbert" href="mailto:dholbert@mozilla.com">
+  <meta charset="utf-8">
+</head>
+<body>
+  a ab bx x
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/w3c-css/submitted/flexbox/flexbox-anonymous-items-1.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<html>
+<head>
+  <title>CSS Test: Testing that we gracefully handle cases where two anonymous flex items become adjacent due to "order" reordering</title>
+  <link rel="author" title="Daniel Holbert" href="mailto:dholbert@mozilla.com">
+  <link rel="help" href="http://www.w3.org/TR/css3-flexbox/#flex-items">
+  <link rel="match" href="flexbox-anonymous-items-1-ref.html">
+  <meta charset="utf-8">
+  <style>
+    .flexContainer {
+      display: flex;
+    }
+  </style>
+</head>
+<body>
+  <div class="flexContainer">
+    a a
+    <div style="order: 1">x x</div>
+    b b
+  </div>
+</body>
+</html>
--- a/layout/reftests/w3c-css/submitted/flexbox/reftest.list
+++ b/layout/reftests/w3c-css/submitted/flexbox/reftest.list
@@ -1,8 +1,11 @@
+# Tests for handling anonymous flex items
+== flexbox-anonymous-items-1.html flexbox-anonymous-items-1-ref.html
+
 # Tests for alignment of flex lines (align-content property)
 == flexbox-align-content-horiz-1a.xhtml flexbox-align-content-horiz-1-ref.xhtml
 == flexbox-align-content-horiz-1b.xhtml flexbox-align-content-horiz-1-ref.xhtml
 == flexbox-align-content-vert-1a.xhtml  flexbox-align-content-vert-1-ref.xhtml
 == flexbox-align-content-vert-1b.xhtml  flexbox-align-content-vert-1-ref.xhtml
 
 # Tests for cross-axis alignment (align-self / align-items properties)
 == flexbox-align-self-baseline-horiz-1.xhtml flexbox-align-self-baseline-horiz-1-ref.xhtml