Bug 1305244 part 2 - [css-grid] Represent single-value <flex> track sizes as minmax(auto, <flex>) internally. r=dholbert
authorMats Palmgren <mats@mozilla.com>
Sat, 29 Oct 2016 01:30:10 +0200
changeset 320089 1f4500ce11a744b7a6ae93b85020a4000213a40f
parent 320088 b727c67b91a3268e893f4f63057f6cb7fae1b4ba
child 320090 ac4628bf99126783da833e1641d673c92ee4b1a7
push id20749
push userryanvm@gmail.com
push dateSat, 29 Oct 2016 13:21:21 +0000
treeherderfx-team@1b170b39ed6b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1305244
milestone52.0a1
Bug 1305244 part 2 - [css-grid] Represent single-value <flex> track sizes as minmax(auto, <flex>) internally. r=dholbert
layout/style/nsCSSParser.cpp
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -8808,18 +8808,28 @@ CSSParserImpl::ParseGridTrackSize(nsCSSV
   const bool requireFixedSize =
     !!(aFlags & GridTrackSizeFlags::eFixedTrackSize);
   // Attempt to parse a single <track-breadth>.
   CSSParseResult result = ParseGridTrackBreadth(aValue);
   if (requireFixedSize && result == CSSParseResult::Ok &&
       !aValue.IsLengthPercentCalcUnit()) {
     result = CSSParseResult::Error;
   }
-  if (result == CSSParseResult::Ok ||
-      result == CSSParseResult::Error) {
+  if (result == CSSParseResult::Error) {
+    return result;
+  }
+  if (result == CSSParseResult::Ok) {
+    if (aValue.GetUnit() == eCSSUnit_FlexFraction) {
+      // Single value <flex> is represented internally as minmax(auto, <flex>).
+      nsCSSValue minmax;
+      nsCSSValue::Array* func = minmax.InitFunction(eCSSKeyword_minmax, 2);
+      func->Item(1).SetAutoValue();
+      func->Item(2) = aValue;
+      aValue = minmax;
+    }
     return result;
   }
 
   // Attempt to parse a minmax() or fit-content() function.
   if (!GetToken(true)) {
     return CSSParseResult::NotFound;
   }
   if (eCSSToken_Function != mToken.mType) {
@@ -8845,17 +8855,17 @@ CSSParserImpl::ParseGridTrackSize(nsCSSV
       ExpectSymbol(',', true) &&
       ParseGridTrackBreadth(func->Item(2)) == CSSParseResult::Ok &&
       ExpectSymbol(')', true)) {
     if (requireFixedSize &&
         !func->Item(1).IsLengthPercentCalcUnit() &&
         !func->Item(2).IsLengthPercentCalcUnit()) {
       return CSSParseResult::Error;
     }
-    // Reject 'fr' min-sizing.
+    // Reject <flex> min-sizing.
     if (func->Item(1).GetUnit() == eCSSUnit_FlexFraction) {
       return CSSParseResult::Error;
     }
     return CSSParseResult::Ok;
   }
   SkipUntil(')');
   return CSSParseResult::Error;
 }