Bug 994592 - Make 'row' the initial value for 'grid-auto-flow' and remove 'none' as a valid value. And add the 'stack' variants. r=simon.sapin
authorMats Palmgren <matspal@gmail.com>
Tue, 06 May 2014 09:45:13 +0000
changeset 181734 a07ce7d79a6c363a7e03ba743581e47c8298807a
parent 181733 6efbbdf09c63f23ff8ab99a14185c7dbf3650446
child 181735 7f715a1d5b28f716a7087a03816b206cc31bd350
push id26731
push userryanvm@gmail.com
push dateTue, 06 May 2014 20:24:50 +0000
treeherdermozilla-central@df540d726c01 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssimon.sapin
bugs994592
milestone32.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 994592 - Make 'row' the initial value for 'grid-auto-flow' and remove 'none' as a valid value. And add the 'stack' variants. r=simon.sapin
layout/style/Declaration.cpp
layout/style/nsCSSKeywordList.h
layout/style/nsCSSParser.cpp
layout/style/nsCSSProps.cpp
layout/style/nsCSSValue.cpp
layout/style/nsComputedDOMStyle.cpp
layout/style/nsRuleNode.cpp
layout/style/nsStyleConsts.h
layout/style/nsStyleStruct.cpp
layout/style/test/property_database.js
layout/style/test/test_grid_container_shorthands.html
layout/style/test/test_grid_shorthand_serialization.html
--- a/layout/style/Declaration.cpp
+++ b/layout/style/Declaration.cpp
@@ -989,17 +989,17 @@ Declaration::GetValue(nsCSSProperty aPro
         aValue.Append(char16_t(' '));
         AppendValueToString(eCSSProperty_grid_auto_columns,
                             aValue, aSerialization);
         aValue.AppendLiteral(" / ");
         AppendValueToString(eCSSProperty_grid_auto_rows,
                             aValue, aSerialization);
         break;
       } else if (!(autoFlowValue.GetUnit() == eCSSUnit_Enumerated &&
-                   autoFlowValue.GetIntValue() == NS_STYLE_GRID_AUTO_FLOW_NONE &&
+                   autoFlowValue.GetIntValue() == NS_STYLE_GRID_AUTO_FLOW_ROW &&
                    autoColumnsValue.GetUnit() == eCSSUnit_Auto &&
                    autoRowsValue.GetUnit() == eCSSUnit_Auto)) {
         // Not serializable, bail.
         return;
       }
       // Fall through to eCSSProperty_grid_template
     }
     case eCSSProperty_grid_template: {
--- a/layout/style/nsCSSKeywordList.h
+++ b/layout/style/nsCSSKeywordList.h
@@ -503,16 +503,17 @@ CSS_KEY(small-caption, small_caption)
 CSS_KEY(smaller, smaller)
 CSS_KEY(soft, soft)
 CSS_KEY(soft-light, soft_light)
 CSS_KEY(solid, solid)
 CSS_KEY(space-around, space_around)
 CSS_KEY(space-between, space_between)
 CSS_KEY(span, span)
 CSS_KEY(square, square)
+CSS_KEY(stack, stack)
 CSS_KEY(stacked-fractions, stacked_fractions)
 CSS_KEY(start, start)
 CSS_KEY(static, static)
 CSS_KEY(status-bar, status_bar)
 CSS_KEY(step-end, step_end)
 CSS_KEY(step-start, step_start)
 CSS_KEY(sticky, sticky)
 CSS_KEY(stretch, stretch)
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -6947,35 +6947,36 @@ CSSParserImpl::ParseGridAutoFlow()
 {
   nsCSSValue value;
   if (ParseVariant(value, VARIANT_INHERIT, nullptr)) {
     AppendValue(eCSSProperty_grid_auto_flow, value);
     return true;
   }
 
   static const int32_t mask[] = {
-    NS_STYLE_GRID_AUTO_FLOW_COLUMN | NS_STYLE_GRID_AUTO_FLOW_ROW,
+    NS_STYLE_GRID_AUTO_FLOW_ROW | NS_STYLE_GRID_AUTO_FLOW_COLUMN,
+    NS_STYLE_GRID_AUTO_FLOW_DENSE | NS_STYLE_GRID_AUTO_FLOW_STACK,
     MASK_END_VALUE
   };
   if (!ParseBitmaskValues(value, nsCSSProps::kGridAutoFlowKTable, mask)) {
     return false;
   }
   int32_t bitField = value.GetIntValue();
 
   // Requires one of these
-  if (!(bitField & NS_STYLE_GRID_AUTO_FLOW_NONE ||
+  if (!(bitField & NS_STYLE_GRID_AUTO_FLOW_ROW ||
         bitField & NS_STYLE_GRID_AUTO_FLOW_COLUMN ||
-        bitField & NS_STYLE_GRID_AUTO_FLOW_ROW)) {
-    return false;
-  }
-
-  // 'none' is only valid if it occurs alone:
-  if (bitField & NS_STYLE_GRID_AUTO_FLOW_NONE &&
-      bitField != NS_STYLE_GRID_AUTO_FLOW_NONE) {
-    return false;
+        bitField & NS_STYLE_GRID_AUTO_FLOW_STACK)) {
+    return false;
+  }
+
+  // 'stack' without 'row' or 'column' defaults to 'stack row'
+  if (bitField == NS_STYLE_GRID_AUTO_FLOW_STACK) {
+    value.SetIntValue(bitField | NS_STYLE_GRID_AUTO_FLOW_ROW,
+                      eCSSUnit_Enumerated);
   }
 
   AppendValue(eCSSProperty_grid_auto_flow, value);
   return true;
 }
 
 CSSParseResult
 CSSParserImpl::ParseGridLineNames(nsCSSValue& aValue)
@@ -7820,58 +7821,38 @@ CSSParserImpl::ParseGrid()
     for (const nsCSSProperty* subprops =
            nsCSSProps::SubpropertyEntryFor(eCSSProperty_grid);
          *subprops != eCSSProperty_UNKNOWN; ++subprops) {
       AppendValue(*subprops, value);
     }
     return true;
   }
 
-  // 'none' at the beginning could be a <'grid-auto-flow'>
-  // (which also covers 'none' by itself)
-  // or a <'grid-template-columns'> (as part of <'grid-template'>)
-  if (ParseVariant(value, VARIANT_NONE, nullptr)) {
-    if (ExpectSymbol('/', true)) {
-      AppendValue(eCSSProperty_grid_template_columns, value);
-
-      // Set grid-auto-* subproperties to their initial values.
-      value.SetIntValue(NS_STYLE_GRID_AUTO_FLOW_NONE, eCSSUnit_Enumerated);
-      AppendValue(eCSSProperty_grid_auto_flow, value);
-      value.SetAutoValue();
-      AppendValue(eCSSProperty_grid_auto_columns, value);
-      AppendValue(eCSSProperty_grid_auto_rows, value);
-
-      return ParseGridTemplateAfterSlash(/* aColumnsIsTrackList = */ false);
-    }
-    value.SetIntValue(NS_STYLE_GRID_AUTO_FLOW_NONE, eCSSUnit_Enumerated);
-    AppendValue(eCSSProperty_grid_auto_flow, value);
-    return ParseGridShorthandAutoProps();
-  }
-
   // An empty value is always invalid.
   if (!GetToken(true)) {
     return false;
   }
 
-  // If the value starts with a 'dense', 'column' or 'row' keyword,
-  // it can only start with a <'grid-auto-flow'>
+  // The values starts with a <'grid-auto-flow'> if and only if
+  // it starts with a 'stack', 'dense', 'column' or 'row' keyword.
   if (mToken.mType == eCSSToken_Ident) {
     nsCSSKeyword keyword = nsCSSKeywords::LookupKeyword(mToken.mIdent);
-    if (keyword == eCSSKeyword_dense ||
+    if (keyword == eCSSKeyword_stack ||
+        keyword == eCSSKeyword_dense ||
         keyword == eCSSKeyword_column ||
         keyword == eCSSKeyword_row) {
       UngetToken();
       return ParseGridAutoFlow() && ParseGridShorthandAutoProps();
     }
   }
   UngetToken();
 
   // Set other subproperties to their initial values
   // and parse <'grid-template'>.
-  value.SetIntValue(NS_STYLE_GRID_AUTO_FLOW_NONE, eCSSUnit_Enumerated);
+  value.SetIntValue(NS_STYLE_GRID_AUTO_FLOW_ROW, eCSSUnit_Enumerated);
   AppendValue(eCSSProperty_grid_auto_flow, value);
   value.SetAutoValue();
   AppendValue(eCSSProperty_grid_auto_columns, value);
   AppendValue(eCSSProperty_grid_auto_rows, value);
   return ParseGridTemplate();
 }
 
 // Parse [ <'grid-auto-columns'> [ / <'grid-auto-rows'> ]? ]?
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -1233,19 +1233,19 @@ const KTableValue nsCSSProps::kFontWeigh
   eCSSKeyword_normal, NS_STYLE_FONT_WEIGHT_NORMAL,
   eCSSKeyword_bold, NS_STYLE_FONT_WEIGHT_BOLD,
   eCSSKeyword_bolder, NS_STYLE_FONT_WEIGHT_BOLDER,
   eCSSKeyword_lighter, NS_STYLE_FONT_WEIGHT_LIGHTER,
   eCSSKeyword_UNKNOWN,-1
 };
 
 const KTableValue nsCSSProps::kGridAutoFlowKTable[] = {
-  eCSSKeyword_none, NS_STYLE_GRID_AUTO_FLOW_NONE,
+  eCSSKeyword_stack, NS_STYLE_GRID_AUTO_FLOW_STACK,
+  eCSSKeyword_row, NS_STYLE_GRID_AUTO_FLOW_ROW,
   eCSSKeyword_column, NS_STYLE_GRID_AUTO_FLOW_COLUMN,
-  eCSSKeyword_row, NS_STYLE_GRID_AUTO_FLOW_ROW,
   eCSSKeyword_dense, NS_STYLE_GRID_AUTO_FLOW_DENSE,
   eCSSKeyword_UNKNOWN,-1
 };
 
 const KTableValue nsCSSProps::kGridTrackBreadthKTable[] = {
   eCSSKeyword_min_content, NS_STYLE_GRID_TRACK_BREADTH_MIN_CONTENT,
   eCSSKeyword_max_content, NS_STYLE_GRID_TRACK_BREADTH_MAX_CONTENT,
   eCSSKeyword_UNKNOWN,-1
--- a/layout/style/nsCSSValue.cpp
+++ b/layout/style/nsCSSValue.cpp
@@ -1027,17 +1027,17 @@ nsCSSValue::AppendToString(nsCSSProperty
       nsStyleUtil::AppendBitmaskCSSValue(aProperty, intValue,
                                          NS_FONT_VARIANT_NUMERIC_LINING,
                                          NS_FONT_VARIANT_NUMERIC_ORDINAL,
                                          aResult);
       break;
 
     case eCSSProperty_grid_auto_flow:
       nsStyleUtil::AppendBitmaskCSSValue(aProperty, intValue,
-                                         NS_STYLE_GRID_AUTO_FLOW_NONE,
+                                         NS_STYLE_GRID_AUTO_FLOW_STACK,
                                          NS_STYLE_GRID_AUTO_FLOW_DENSE,
                                          aResult);
       break;
 
     case eCSSProperty_grid_auto_position:
     case eCSSProperty_grid_column_start:
     case eCSSProperty_grid_column_end:
     case eCSSProperty_grid_row_start:
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -2393,17 +2393,17 @@ nsComputedDOMStyle::GetGridTemplateColum
 }
 
 CSSValue*
 nsComputedDOMStyle::DoGetGridAutoFlow()
 {
   nsAutoString str;
   nsStyleUtil::AppendBitmaskCSSValue(eCSSProperty_grid_auto_flow,
                                      StylePosition()->mGridAutoFlow,
-                                     NS_STYLE_GRID_AUTO_FLOW_NONE,
+                                     NS_STYLE_GRID_AUTO_FLOW_STACK,
                                      NS_STYLE_GRID_AUTO_FLOW_DENSE,
                                      str);
   nsROCSSPrimitiveValue* val = new nsROCSSPrimitiveValue;
   val->SetString(str);
   return val;
 }
 
 CSSValue*
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -7500,17 +7500,17 @@ nsRuleNode::ComputePositionData(void* aS
     case eCSSUnit_Null:
       break;
     case eCSSUnit_Inherit:
       canStoreInRuleTree = false;
       pos->mGridAutoFlow = parentPos->mGridAutoFlow;
       break;
     case eCSSUnit_Initial:
     case eCSSUnit_Unset:
-      pos->mGridAutoFlow = NS_STYLE_GRID_AUTO_FLOW_NONE;
+      pos->mGridAutoFlow = NS_STYLE_GRID_AUTO_FLOW_ROW;
       break;
     default:
       NS_ASSERTION(gridAutoFlow.GetUnit() == eCSSUnit_Enumerated,
                    "Unexpected unit");
       pos->mGridAutoFlow = gridAutoFlow.GetIntValue();
   }
 
   // grid-auto-columns
--- a/layout/style/nsStyleConsts.h
+++ b/layout/style/nsStyleConsts.h
@@ -539,19 +539,19 @@ static inline mozilla::css::Side operato
 #define NS_STYLE_FONT_INFO                      11
 #define NS_STYLE_FONT_DIALOG                    12
 #define NS_STYLE_FONT_BUTTON                    13
 #define NS_STYLE_FONT_PULL_DOWN_MENU            14
 #define NS_STYLE_FONT_LIST                      15
 #define NS_STYLE_FONT_FIELD                     16
 
 // grid-auto-flow keywords
-#define NS_STYLE_GRID_AUTO_FLOW_NONE            (1 << 0)
-#define NS_STYLE_GRID_AUTO_FLOW_COLUMN          (1 << 1)
-#define NS_STYLE_GRID_AUTO_FLOW_ROW             (1 << 2)
+#define NS_STYLE_GRID_AUTO_FLOW_STACK           (1 << 0)
+#define NS_STYLE_GRID_AUTO_FLOW_ROW             (1 << 1)
+#define NS_STYLE_GRID_AUTO_FLOW_COLUMN          (1 << 2)
 #define NS_STYLE_GRID_AUTO_FLOW_DENSE           (1 << 3)
 
 // 'subgrid' keyword in grid-template-{columns,rows}
 #define NS_STYLE_GRID_TEMPLATE_SUBGRID          0
 
 // CSS Grid <track-breadth> keywords
 // Should not overlap with NS_STYLE_GRID_TEMPLATE_SUBGRID
 #define NS_STYLE_GRID_TRACK_BREADTH_MAX_CONTENT 1
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -1238,17 +1238,17 @@ nsStylePosition::nsStylePosition(void)
                                   eStyleUnit_Enumerated);
   mGridAutoColumnsMax.SetIntValue(NS_STYLE_GRID_TRACK_BREADTH_MAX_CONTENT,
                                   eStyleUnit_Enumerated);
   mGridAutoRowsMin.SetIntValue(NS_STYLE_GRID_TRACK_BREADTH_MIN_CONTENT,
                                eStyleUnit_Enumerated);
   mGridAutoRowsMax.SetIntValue(NS_STYLE_GRID_TRACK_BREADTH_MAX_CONTENT,
                                eStyleUnit_Enumerated);
 
-  mGridAutoFlow = NS_STYLE_GRID_AUTO_FLOW_NONE;
+  mGridAutoFlow = NS_STYLE_GRID_AUTO_FLOW_ROW;
   mBoxSizing = NS_STYLE_BOX_SIZING_CONTENT;
   mAlignContent = NS_STYLE_ALIGN_CONTENT_STRETCH;
   mAlignItems = NS_STYLE_ALIGN_ITEMS_INITIAL_VALUE;
   mAlignSelf = NS_STYLE_ALIGN_SELF_AUTO;
   mFlexDirection = NS_STYLE_FLEX_DIRECTION_ROW;
   mFlexWrap = NS_STYLE_FLEX_WRAP_NOWRAP;
   mJustifyContent = NS_STYLE_JUSTIFY_CONTENT_FLEX_START;
   mOrder = NS_STYLE_ORDER_INITIAL;
--- a/layout/style/test/property_database.js
+++ b/layout/style/test/property_database.js
@@ -4797,32 +4797,36 @@ if (SpecialPowers.getBoolPref("layout.cs
 }
 
 if (SpecialPowers.getBoolPref("layout.css.grid.enabled")) {
   gCSSProperties["display"].other_values.push("grid", "inline-grid");
   gCSSProperties["grid-auto-flow"] = {
     domProp: "gridAutoFlow",
     inherited: false,
     type: CSS_TYPE_LONGHAND,
-    initial_values: [ "none" ],
+    initial_values: [ "row" ],
     other_values: [
       "column",
-      "row",
       "column dense",
       "row dense",
       "dense column",
       "dense row",
+      "stack column",
+      "stack row",
+      "stack",
     ],
     invalid_values: [
       "",
       "auto",
+      "none",
       "10px",
       "dense",
-      "none row",
-      "none dense",
+      "stack dense",
+      "stack stack",
+      "stack row stack",
       "column row",
       "dense row dense",
     ]
   };
 
   gCSSProperties["grid-auto-columns"] = {
     domProp: "gridAutoColumns",
     inherited: false,
@@ -5041,37 +5045,35 @@ if (SpecialPowers.getBoolPref("layout.cs
       "grid-template-rows",
       "grid-auto-flow",
       "grid-auto-columns",
       "grid-auto-rows",
     ],
     initial_values: [
       "none",
       "none / none",
-      "none auto",
-      "none auto / auto",
     ],
     other_values: [
-      "row",
-      "none 40px",
+      "stack 40px",
       "column dense auto",
       "dense row minmax(min-content, 2fr)",
       "row 40px / 100px",
     ].concat(
       gCSSProperties["grid-template"].other_values,
       gCSSProperties["grid-auto-flow"].other_values
     ),
     invalid_values: [
       "row column 40px",
       "row -20px",
       "row 200ms",
       "row 40px 100px",
     ].concat(
       gCSSProperties["grid-template"].invalid_values,
       gCSSProperties["grid-auto-flow"].invalid_values
+        .filter((v) => v != 'none')
     )
   };
 
   var gridLineOtherValues = [
     "foo",
     "2",
     "2 foo",
     "foo 2",
--- a/layout/style/test/test_grid_container_shorthands.html
+++ b/layout/style/test/test_grid_container_shorthands.html
@@ -11,17 +11,17 @@
 <body>
 
 <script>
 
 var initial_values = {
     gridTemplateAreas: "none",
     gridTemplateColumns: "none",
     gridTemplateRows: "none",
-    gridAutoFlow: "none",
+    gridAutoFlow: "row",
     // Computed value for 'auto'
     gridAutoColumns: "minmax(min-content, max-content)",
     gridAutoRows: "minmax(min-content, max-content)",
 };
 
 // For various specified values of the grid-template shorthand,
 // test the computed values of the corresponding longhands.
 var grid_template_test_cases = [
@@ -174,18 +174,23 @@ var grid_template_test_cases = [
 ];
 
 grid_test_cases = grid_template_test_cases.concat([
     {
         specified: "row",
         gridAutoFlow: "row",
     },
     {
-        specified: "none 40px",
-        gridAutoFlow: "none",
+        specified: "stack 40px",
+        gridAutoFlow: "stack row",
+        gridAutoColumns: "40px",
+    },
+    {
+        specified: "stack column 40px",
+        gridAutoFlow: "stack column",
         gridAutoColumns: "40px",
     },
     {
         specified: "column dense auto",
         gridAutoFlow: "column dense",
         gridAutoColumns: "minmax(min-content, max-content)",
     },
     {
--- a/layout/style/test/test_grid_shorthand_serialization.html
+++ b/layout/style/test/test_grid_shorthand_serialization.html
@@ -11,17 +11,17 @@
 <body>
 
 <script>
 
 var initial_values = {
     gridTemplateAreas: "none",
     gridTemplateColumns: "none",
     gridTemplateRows: "none",
-    gridAutoFlow: "none",
+    gridAutoFlow: "row",
     gridAutoColumns: "auto",
     gridAutoRows: "auto",
 };
 
 // For various specified values of the grid-template subproperties,
 // test the serialization of the shorthand.
 var grid_template_test_cases = [
     {
@@ -83,17 +83,17 @@ var grid_template_test_cases = [
 
 grid_test_cases = grid_template_test_cases.concat([
     {
         gridAutoFlow: "row",
         shorthand: "row auto / auto",
     },
     {
         gridAutoColumns: "40px",
-        shorthand: "none 40px / auto",
+        shorthand: "row 40px / auto",
     },
     {
         gridAutoFlow: "column dense",
         gridAutoColumns: "minmax(min-content, max-content)",
         shorthand: "column dense minmax(min-content, max-content) / auto",
     },
     {
         gridAutoFlow: "row dense",