зеркало из https://github.com/mozilla/gecko-dev.git
Bug 939905: Add support for CSS "flex-flow" shorthand property. r=heycam
This commit is contained in:
Родитель
f21dfba90a
Коммит
a84ea6e027
|
@ -850,6 +850,18 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue) const
|
||||||
AppendValueToString(subprops[2], aValue);
|
AppendValueToString(subprops[2], aValue);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case eCSSProperty_flex_flow: {
|
||||||
|
// flex-direction, flex-wrap, separated by single space
|
||||||
|
const nsCSSProperty* subprops =
|
||||||
|
nsCSSProps::SubpropertyEntryFor(aProperty);
|
||||||
|
NS_ABORT_IF_FALSE(subprops[2] == eCSSProperty_UNKNOWN,
|
||||||
|
"must have exactly two subproperties");
|
||||||
|
|
||||||
|
AppendValueToString(subprops[0], aValue);
|
||||||
|
aValue.Append(PRUnichar(' '));
|
||||||
|
AppendValueToString(subprops[1], aValue);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case eCSSProperty__moz_transform: {
|
case eCSSProperty__moz_transform: {
|
||||||
// shorthands that are just aliases with different parsing rules
|
// shorthands that are just aliases with different parsing rules
|
||||||
const nsCSSProperty* subprops =
|
const nsCSSProperty* subprops =
|
||||||
|
|
|
@ -472,8 +472,10 @@ protected:
|
||||||
bool ParseCalcTerm(nsCSSValue& aValue, int32_t& aVariantMask);
|
bool ParseCalcTerm(nsCSSValue& aValue, int32_t& aVariantMask);
|
||||||
bool RequireWhitespace();
|
bool RequireWhitespace();
|
||||||
|
|
||||||
// For "flex" shorthand property, defined in CSS3 Flexbox
|
// For "flex" shorthand property, defined in CSS Flexbox spec
|
||||||
bool ParseFlex();
|
bool ParseFlex();
|
||||||
|
// For "flex-flow" shorthand property, defined in CSS Flexbox spec
|
||||||
|
bool ParseFlexFlow();
|
||||||
|
|
||||||
// for 'clip' and '-moz-image-region'
|
// for 'clip' and '-moz-image-region'
|
||||||
bool ParseRect(nsCSSProperty aPropID);
|
bool ParseRect(nsCSSProperty aPropID);
|
||||||
|
@ -5736,6 +5738,39 @@ CSSParserImpl::ParseFlex()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// flex-flow: <flex-direction> || <flex-wrap>
|
||||||
|
bool
|
||||||
|
CSSParserImpl::ParseFlexFlow()
|
||||||
|
{
|
||||||
|
static const nsCSSProperty kFlexFlowSubprops[] = {
|
||||||
|
eCSSProperty_flex_direction,
|
||||||
|
eCSSProperty_flex_wrap
|
||||||
|
};
|
||||||
|
const size_t numProps = NS_ARRAY_LENGTH(kFlexFlowSubprops);
|
||||||
|
nsCSSValue values[numProps];
|
||||||
|
|
||||||
|
int32_t found = ParseChoice(values, kFlexFlowSubprops, numProps);
|
||||||
|
|
||||||
|
// Bail if we didn't successfully parse anything, or if there's trailing junk.
|
||||||
|
if (found < 1 || !ExpectEndProperty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If either property didn't get an explicit value, use its initial value.
|
||||||
|
if ((found & 1) == 0) {
|
||||||
|
values[0].SetIntValue(NS_STYLE_FLEX_DIRECTION_ROW, eCSSUnit_Enumerated);
|
||||||
|
}
|
||||||
|
if ((found & 2) == 0) {
|
||||||
|
values[1].SetIntValue(NS_STYLE_FLEX_WRAP_NOWRAP, eCSSUnit_Enumerated);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store these values and declare success!
|
||||||
|
for (size_t i = 0; i < numProps; i++) {
|
||||||
|
AppendValue(kFlexFlowSubprops[i], values[i]);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// <color-stop> : <color> [ <percentage> | <length> ]?
|
// <color-stop> : <color> [ <percentage> | <length> ]?
|
||||||
bool
|
bool
|
||||||
CSSParserImpl::ParseColorStop(nsCSSValueGradient* aGradient)
|
CSSParserImpl::ParseColorStop(nsCSSValueGradient* aGradient)
|
||||||
|
@ -6581,6 +6616,8 @@ CSSParserImpl::ParsePropertyByFunction(nsCSSProperty aPropID)
|
||||||
return ParseFilter();
|
return ParseFilter();
|
||||||
case eCSSProperty_flex:
|
case eCSSProperty_flex:
|
||||||
return ParseFlex();
|
return ParseFlex();
|
||||||
|
case eCSSProperty_flex_flow:
|
||||||
|
return ParseFlexFlow();
|
||||||
case eCSSProperty_font:
|
case eCSSProperty_font:
|
||||||
return ParseFont();
|
return ParseFont();
|
||||||
case eCSSProperty_image_region:
|
case eCSSProperty_image_region:
|
||||||
|
|
|
@ -1659,6 +1659,12 @@ CSS_PROP_POSITION(
|
||||||
kFlexDirectionKTable,
|
kFlexDirectionKTable,
|
||||||
offsetof(nsStylePosition, mFlexDirection),
|
offsetof(nsStylePosition, mFlexDirection),
|
||||||
eStyleAnimType_EnumU8)
|
eStyleAnimType_EnumU8)
|
||||||
|
CSS_PROP_SHORTHAND(
|
||||||
|
flex-flow,
|
||||||
|
flex_flow,
|
||||||
|
FlexFlow,
|
||||||
|
CSS_PROPERTY_PARSE_FUNCTION,
|
||||||
|
"")
|
||||||
CSS_PROP_POSITION(
|
CSS_PROP_POSITION(
|
||||||
flex-grow,
|
flex-grow,
|
||||||
flex_grow,
|
flex_grow,
|
||||||
|
|
|
@ -2421,6 +2421,12 @@ static const nsCSSProperty gFlexSubpropTable[] = {
|
||||||
eCSSProperty_UNKNOWN
|
eCSSProperty_UNKNOWN
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const nsCSSProperty gFlexFlowSubpropTable[] = {
|
||||||
|
eCSSProperty_flex_direction,
|
||||||
|
eCSSProperty_flex_wrap,
|
||||||
|
eCSSProperty_UNKNOWN
|
||||||
|
};
|
||||||
|
|
||||||
static const nsCSSProperty gOverflowSubpropTable[] = {
|
static const nsCSSProperty gOverflowSubpropTable[] = {
|
||||||
eCSSProperty_overflow_x,
|
eCSSProperty_overflow_x,
|
||||||
eCSSProperty_overflow_y,
|
eCSSProperty_overflow_y,
|
||||||
|
|
|
@ -3842,6 +3842,46 @@ var gCSSProperties = {
|
||||||
other_values: [ "row-reverse", "column", "column-reverse" ],
|
other_values: [ "row-reverse", "column", "column-reverse" ],
|
||||||
invalid_values: [ "10px", "30%", "justify", "column wrap" ]
|
invalid_values: [ "10px", "30%", "justify", "column wrap" ]
|
||||||
},
|
},
|
||||||
|
"flex-flow": {
|
||||||
|
domProp: "flexFlow",
|
||||||
|
inherited: false,
|
||||||
|
type: CSS_TYPE_TRUE_SHORTHAND,
|
||||||
|
subproperties: [
|
||||||
|
"flex-direction",
|
||||||
|
"flex-wrap"
|
||||||
|
],
|
||||||
|
initial_values: [ "row nowrap", "nowrap row", "row", "nowrap" ],
|
||||||
|
other_values: [
|
||||||
|
// only specifying one property:
|
||||||
|
"column",
|
||||||
|
"wrap",
|
||||||
|
"wrap-reverse",
|
||||||
|
// specifying both properties, 'flex-direction' first:
|
||||||
|
"row wrap",
|
||||||
|
"row wrap-reverse",
|
||||||
|
"column wrap",
|
||||||
|
"column wrap-reverse",
|
||||||
|
// specifying both properties, 'flex-wrap' first:
|
||||||
|
"wrap row",
|
||||||
|
"wrap column",
|
||||||
|
"wrap-reverse row",
|
||||||
|
"wrap-reverse column",
|
||||||
|
],
|
||||||
|
invalid_values: [
|
||||||
|
// specifying flex-direction twice (invalid):
|
||||||
|
"row column",
|
||||||
|
"row column nowrap",
|
||||||
|
"row nowrap column",
|
||||||
|
"nowrap row column",
|
||||||
|
// specifying flex-wrap twice (invalid):
|
||||||
|
"nowrap wrap-reverse",
|
||||||
|
"nowrap wrap-reverse row",
|
||||||
|
"nowrap row wrap-reverse",
|
||||||
|
"row nowrap wrap-reverse",
|
||||||
|
// Invalid data-type / invalid keyword type:
|
||||||
|
"1px", "5%", "justify", "none"
|
||||||
|
]
|
||||||
|
},
|
||||||
"flex-grow": {
|
"flex-grow": {
|
||||||
domProp: "flexGrow",
|
domProp: "flexGrow",
|
||||||
inherited: false,
|
inherited: false,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче