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

This commit is contained in:
Mats Palmgren 2014-05-06 09:45:13 +00:00
parent 0948d077e1
commit 3716fd29bb
12 changed files with 44 additions and 55 deletions

View File

@ -994,7 +994,7 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue,
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.

View File

@ -508,6 +508,7 @@ 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)

View File

@ -6952,7 +6952,8 @@ CSSParserImpl::ParseGridAutoFlow()
}
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)) {
@ -6961,16 +6962,16 @@ CSSParserImpl::ParseGridAutoFlow()
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)) {
bitField & NS_STYLE_GRID_AUTO_FLOW_STACK)) {
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;
// '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);
@ -7825,37 +7826,17 @@ CSSParserImpl::ParseGrid()
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();
@ -7866,7 +7847,7 @@ CSSParserImpl::ParseGrid()
// 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);

View File

@ -1238,9 +1238,9 @@ const KTableValue nsCSSProps::kFontWeightKTable[] = {
};
const KTableValue nsCSSProps::kGridAutoFlowKTable[] = {
eCSSKeyword_none, NS_STYLE_GRID_AUTO_FLOW_NONE,
eCSSKeyword_column, NS_STYLE_GRID_AUTO_FLOW_COLUMN,
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_dense, NS_STYLE_GRID_AUTO_FLOW_DENSE,
eCSSKeyword_UNKNOWN,-1
};

View File

@ -1032,7 +1032,7 @@ nsCSSValue::AppendToString(nsCSSProperty aProperty, nsAString& aResult,
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;

View File

@ -2398,7 +2398,7 @@ 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;

View File

@ -7505,7 +7505,7 @@ nsRuleNode::ComputePositionData(void* aStartStruct,
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,

View File

@ -544,9 +544,9 @@ static inline mozilla::css::Side operator++(mozilla::css::Side& side, int) {
#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}

View File

@ -1243,7 +1243,7 @@ nsStylePosition::nsStylePosition(void)
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;

View File

@ -4802,22 +4802,26 @@ if (SpecialPowers.getBoolPref("layout.css.grid.enabled")) {
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",
]
@ -5046,12 +5050,9 @@ if (SpecialPowers.getBoolPref("layout.css.grid.enabled")) {
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",
@ -5067,6 +5068,7 @@ if (SpecialPowers.getBoolPref("layout.css.grid.enabled")) {
].concat(
gCSSProperties["grid-template"].invalid_values,
gCSSProperties["grid-auto-flow"].invalid_values
.filter((v) => v != 'none')
)
};

View File

@ -16,7 +16,7 @@ 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)",
@ -179,8 +179,13 @@ grid_test_cases = grid_template_test_cases.concat([
gridAutoFlow: "row",
},
{
specified: "none 40px",
gridAutoFlow: "none",
specified: "stack 40px",
gridAutoFlow: "stack row",
gridAutoColumns: "40px",
},
{
specified: "stack column 40px",
gridAutoFlow: "stack column",
gridAutoColumns: "40px",
},
{

View File

@ -16,7 +16,7 @@ var initial_values = {
gridTemplateAreas: "none",
gridTemplateColumns: "none",
gridTemplateRows: "none",
gridAutoFlow: "none",
gridAutoFlow: "row",
gridAutoColumns: "auto",
gridAutoRows: "auto",
};
@ -88,7 +88,7 @@ grid_test_cases = grid_template_test_cases.concat([
},
{
gridAutoColumns: "40px",
shorthand: "none 40px / auto",
shorthand: "row 40px / auto",
},
{
gridAutoFlow: "column dense",