Bug 1151201 - [css-grid] Update parsing of 'auto' in track-sizing functions to latest version of the spec. r=simon.sapin

This commit is contained in:
Mats Palmgren 2015-04-30 18:42:50 +00:00
Родитель f247a57b0a
Коммит 167c7e473b
6 изменённых файлов: 30 добавлений и 37 удалений

Просмотреть файл

@ -1030,6 +1030,7 @@ InitializeTrackSize(nscoord aPercentageBasis,
// http://dev.w3.org/csswg/css-grid/#algo-init
nscoord& base = aTrackSize->mBase;
switch (aMinCoord.GetUnit()) {
case eStyleUnit_Auto:
case eStyleUnit_Enumerated:
case eStyleUnit_FlexFraction:
base = 0;
@ -1039,6 +1040,7 @@ InitializeTrackSize(nscoord aPercentageBasis,
}
nscoord& limit = aTrackSize->mLimit;
switch (aMaxCoord.GetUnit()) {
case eStyleUnit_Auto:
case eStyleUnit_Enumerated:
limit = NS_UNCONSTRAINEDSIZE;
break;

Просмотреть файл

@ -8055,17 +8055,17 @@ CSSParserImpl::ParseOptionalLineNameListAfterSubgrid(nsCSSValue& aValue)
}
}
// Parse a <track-breadth>
// Parse a <track-breadth>.
bool
CSSParserImpl::ParseGridTrackBreadth(nsCSSValue& aValue)
{
if (ParseNonNegativeVariant(aValue,
VARIANT_LPCALC | VARIANT_KEYWORD,
VARIANT_AUTO | VARIANT_LPCALC | VARIANT_KEYWORD,
nsCSSProps::kGridTrackBreadthKTable)) {
return true;
}
// Attempt to parse <flex> (a dimension with the "fr" unit)
// Attempt to parse <flex> (a dimension with the "fr" unit).
if (!GetToken(true)) {
return false;
}
@ -8079,17 +8079,16 @@ CSSParserImpl::ParseGridTrackBreadth(nsCSSValue& aValue)
return true;
}
// Parse a <track-size>
// Parse a <track-size>.
CSSParseResult
CSSParserImpl::ParseGridTrackSize(nsCSSValue& aValue)
{
// Attempt to parse 'auto' or a single <track-breadth>
if (ParseGridTrackBreadth(aValue) ||
ParseVariant(aValue, VARIANT_AUTO, nullptr)) {
// Attempt to parse a single <track-breadth>.
if (ParseGridTrackBreadth(aValue)) {
return CSSParseResult::Ok;
}
// Attempt to parse a minmax() function
// Attempt to parse a minmax() function.
if (!GetToken(true)) {
return CSSParseResult::NotFound;
}

Просмотреть файл

@ -7327,6 +7327,8 @@ SetGridTrackBreadth(const nsCSSValue& aValue,
nsCSSUnit unit = aValue.GetUnit();
if (unit == eCSSUnit_FlexFraction) {
aResult.SetFlexFractionValue(aValue.GetFloatValue());
} else if (unit == eCSSUnit_Auto) {
aResult.SetAutoValue();
} else {
MOZ_ASSERT(unit != eCSSUnit_Inherit && unit != eCSSUnit_Unset,
"Unexpected value that would use dummyParentCoord");
@ -7354,12 +7356,6 @@ SetGridTrackSize(const nsCSSValue& aValue,
aStyleContext, aPresContext, aCanStoreInRuleTree);
SetGridTrackBreadth(func->Item(2), aResultMax,
aStyleContext, aPresContext, aCanStoreInRuleTree);
} else if (aValue.GetUnit() == eCSSUnit_Auto) {
// 'auto' computes to 'minmax(min-content, max-content)'
aResultMin.SetIntValue(NS_STYLE_GRID_TRACK_BREADTH_MIN_CONTENT,
eStyleUnit_Enumerated);
aResultMax.SetIntValue(NS_STYLE_GRID_TRACK_BREADTH_MAX_CONTENT,
eStyleUnit_Enumerated);
} else {
// A single <track-breadth>,
// specifies identical min and max sizing functions.
@ -7393,12 +7389,10 @@ SetGridAutoColumnsRows(const nsCSSValue& aValue,
case eCSSUnit_Initial:
case eCSSUnit_Unset:
// The initial value is 'auto',
// which computes to 'minmax(min-content, max-content)'.
// which computes to 'minmax(auto, auto)'.
// (Explicitly-specified 'auto' values are handled in SetGridTrackSize.)
aResultMin.SetIntValue(NS_STYLE_GRID_TRACK_BREADTH_MIN_CONTENT,
eStyleUnit_Enumerated);
aResultMax.SetIntValue(NS_STYLE_GRID_TRACK_BREADTH_MAX_CONTENT,
eStyleUnit_Enumerated);
aResultMin.SetAutoValue();
aResultMax.SetAutoValue();
break;
default:

Просмотреть файл

@ -1413,15 +1413,11 @@ nsStylePosition::nsStylePosition(void)
mFlexBasis.SetAutoValue();
// The initial value of grid-auto-columns and grid-auto-rows is 'auto',
// which computes to 'minmax(min-content, max-content)'.
mGridAutoColumnsMin.SetIntValue(NS_STYLE_GRID_TRACK_BREADTH_MIN_CONTENT,
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);
// which computes to 'minmax(auto, auto)'.
mGridAutoColumnsMin.SetAutoValue();
mGridAutoColumnsMax.SetAutoValue();
mGridAutoRowsMin.SetAutoValue();
mGridAutoRowsMax.SetAutoValue();
mGridAutoFlow = NS_STYLE_GRID_AUTO_FLOW_ROW;
mBoxSizing = NS_STYLE_BOX_SIZING_CONTENT;

Просмотреть файл

@ -5751,6 +5751,8 @@ if (SpecialPowers.getBoolPref("layout.css.grid.enabled")) {
"max-content",
"calc(20px + 10%)",
"minmax(20px, max-content)",
"minmax(min-content, auto)",
"minmax(auto, max-content)",
"m\\69nmax(20px, 4Fr)",
"MinMax(min-content, calc(20px + 10%))",
],
@ -5767,7 +5769,6 @@ if (SpecialPowers.getBoolPref("layout.css.grid.enabled")) {
"mİnmax(20px, 100px)",
"minmax(20px, 100px, 200px)",
"maxmin(100px, 20px)",
"minmax(min-content, auto)",
"minmax(min-content, minmax(30px, max-content))",
]
};
@ -5792,6 +5793,8 @@ if (SpecialPowers.getBoolPref("layout.css.grid.enabled")) {
"(normal) 40px () auto ( ) 12%",
"(foo) 40px min-content ( bar ) calc(20px + 10%) max-content",
"40px min-content calc(20px + 10%) max-content",
"minmax(min-content, auto)",
"minmax(auto, max-content)",
"m\\69nmax(20px, 4Fr)",
"40px MinMax(min-content, calc(20px + 10%)) max-content",
"40px 2em",
@ -5838,7 +5841,6 @@ if (SpecialPowers.getBoolPref("layout.css.grid.enabled")) {
"mİnmax(20px, 100px)",
"minmax(20px, 100px, 200px)",
"maxmin(100px, 20px)",
"minmax(min-content, auto)",
"minmax(min-content, minmax(30px, max-content))",
"repeat(0, 20px)",
"repeat(-3, 20px)",

Просмотреть файл

@ -18,8 +18,8 @@ var initial_values = {
gridTemplateRows: "none",
gridAutoFlow: "row",
// Computed value for 'auto'
gridAutoColumns: "minmax(min-content, max-content)",
gridAutoRows: "minmax(min-content, max-content)",
gridAutoColumns: "auto",
gridAutoRows: "auto",
};
// For various specified values of the grid-template shorthand,
@ -106,24 +106,24 @@ var grid_template_test_cases = [
{
specified: "'fizz'",
gridTemplateAreas: "\"fizz\"",
gridTemplateRows: "minmax(min-content, max-content)",
gridTemplateRows: "auto",
},
{
specified: "(bar) 'fizz'",
gridTemplateAreas: "\"fizz\"",
gridTemplateRows: "(bar) minmax(min-content, max-content)",
gridTemplateRows: "(bar) auto",
},
{
specified: "(foo) 40px / 'fizz'",
gridTemplateAreas: "\"fizz\"",
gridTemplateColumns: "(foo) 40px",
gridTemplateRows: "minmax(min-content, max-content)",
gridTemplateRows: "auto",
},
{
specified: "(foo) 40px / (bar) 'fizz'",
gridTemplateAreas: "\"fizz\"",
gridTemplateColumns: "(foo) 40px",
gridTemplateRows: "(bar) minmax(min-content, max-content)",
gridTemplateRows: "(bar) auto",
},
{
specified: "(foo) 40px / 'fizz' 100px",
@ -195,7 +195,7 @@ grid_test_cases = grid_template_test_cases.concat([
{
specified: "column dense auto",
gridAutoFlow: "column dense",
gridAutoColumns: "minmax(min-content, max-content)",
gridAutoColumns: "auto",
},
{
specified: "dense row minmax(min-content, 2fr)",