Bug 752187 - Part 8: Implement unprefixed linear-gradient parsing. r=dbaron

This commit is contained in:
Masatoshi Kimura 2012-07-07 10:27:08 -04:00
Родитель b27adf13d6
Коммит 6eab3cff50
1 изменённых файлов: 53 добавлений и 51 удалений

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

@ -4999,34 +4999,12 @@ CSSParserImpl::ParseLinearGradient(nsCSSValue& aValue, bool aIsRepeating,
nsRefPtr<nsCSSValueGradient> cssGradient
= new nsCSSValueGradient(false, aIsRepeating);
// <gradient-line>
if (!GetToken(true)) {
return false;
}
bool toCorner = false;
if (mToken.mType == eCSSToken_Ident &&
mToken.mIdent.LowerCaseEqualsLiteral("to")) {
toCorner = true;
if (!GetToken(true)) {
return false;
}
}
nsCSSTokenType ty = mToken.mType;
nsString id = mToken.mIdent;
cssGradient->mIsLegacySyntax = !toCorner;
UngetToken();
// <legacy-gradient-line>
bool haveGradientLine = IsLegacyGradientLine(ty, id);
if (haveGradientLine) {
if (toCorner) {
// "to" syntax only allows box position keywords
if (ty != eCSSToken_Ident) {
SkipUntil(')');
return false;
}
// "to" syntax doesn't allow explicit "center"
if (!ParseBoxPositionValues(cssGradient->mBgPos, false, false)) {
@ -5034,6 +5012,7 @@ CSSParserImpl::ParseLinearGradient(nsCSSValue& aValue, bool aIsRepeating,
return false;
}
// [ to [left | right] || [top | bottom] ] ,
const nsCSSValue& xValue = cssGradient->mBgPos.mXValue;
const nsCSSValue& yValue = cssGradient->mBgPos.mYValue;
if (xValue.GetUnit() != eCSSUnit_Enumerated ||
@ -5052,7 +5031,31 @@ CSSParserImpl::ParseLinearGradient(nsCSSValue& aValue, bool aIsRepeating,
SkipUntil(')');
return false;
}
} else {
return ParseGradientColorStops(cssGradient, aValue);
}
if (!aIsLegacy) {
UngetToken();
// <angle> ,
if (ParseVariant(cssGradient->mAngle, VARIANT_ANGLE, nsnull) &&
!ExpectSymbol(',', true)) {
SkipUntil(')');
return false;
}
return ParseGradientColorStops(cssGradient, aValue);
}
nsCSSTokenType ty = mToken.mType;
nsString id = mToken.mIdent;
UngetToken();
// <legacy-gradient-line>
bool haveGradientLine = IsLegacyGradientLine(ty, id);
if (haveGradientLine) {
cssGradient->mIsLegacySyntax = true;
bool haveAngle =
ParseVariant(cssGradient->mAngle, VARIANT_ANGLE, nsnull);
@ -5075,7 +5078,6 @@ CSSParserImpl::ParseLinearGradient(nsCSSValue& aValue, bool aIsRepeating,
}
}
}
}
return ParseGradientColorStops(cssGradient, aValue);
}