Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Unified Diff: third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp

Issue 1449213002: Parse flex/flex-flow shorthands in CSSPropertyParser with CSSParserTokens (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Patch for landing Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp
diff --git a/third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp b/third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp
index 4a95d794a8b78b20219116ee325402b4fbec1183..f524d8b8c694f7299213f76f673518d94f713dec 100644
--- a/third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp
+++ b/third_party/WebKit/Source/core/css/parser/LegacyCSSPropertyParser.cpp
@@ -749,27 +749,6 @@ bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
case CSSPropertyWebkitBoxOrdinalGroup:
validPrimitive = validUnit(value, FInteger | FNonNeg) && value->fValue;
break;
- case CSSPropertyFlex: {
- ShorthandScope scope(this, propId);
- if (id == CSSValueNone) {
- addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(0, CSSPrimitiveValue::UnitType::Number), important);
- addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(0, CSSPrimitiveValue::UnitType::Number), important);
- addProperty(CSSPropertyFlexBasis, cssValuePool().createIdentifierValue(CSSValueAuto), important);
- return true;
- }
- return parseFlex(m_valueList, important);
- }
- case CSSPropertyFlexBasis:
- // FIXME: Support intrinsic dimensions too.
- if (id == CSSValueAuto)
- validPrimitive = true;
- else
- validPrimitive = validUnit(value, FLength | FPercent | FNonNeg);
- break;
- case CSSPropertyFlexGrow:
- case CSSPropertyFlexShrink:
- validPrimitive = validUnit(value, FNumber | FNonNeg);
- break;
case CSSPropertyOrder:
validPrimitive = validUnit(value, FInteger);
break;
@@ -1000,8 +979,6 @@ bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
case CSSPropertyPadding:
// <padding-width>{1,4} | inherit
return parse4Values(propId, paddingShorthand().properties(), important);
- case CSSPropertyFlexFlow:
- return parseShorthand(propId, flexFlowShorthand(), important);
case CSSPropertyListStyle:
return parseShorthand(propId, listStyleShorthand(), important);
case CSSPropertyWebkitColumnRule:
@@ -1177,6 +1154,11 @@ bool CSSPropertyParser::parseValue(CSSPropertyID unresolvedProperty, bool import
case CSSPropertyMarkerStart:
case CSSPropertyMarkerMid:
case CSSPropertyMarkerEnd:
+ case CSSPropertyFlex:
+ case CSSPropertyFlexBasis:
+ case CSSPropertyFlexGrow:
+ case CSSPropertyFlexShrink:
+ case CSSPropertyFlexFlow:
validPrimitive = false;
break;
@@ -3860,55 +3842,6 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseReflect()
return CSSReflectValue::create(direction.release(), offset.release(), mask.release());
}
-static bool isFlexBasisMiddleArg(double flexGrow, double flexShrink, double unsetValue, int argSize)
-{
- return flexGrow != unsetValue && flexShrink == unsetValue && argSize == 3;
-}
-
-bool CSSPropertyParser::parseFlex(CSSParserValueList* args, bool important)
-{
- if (!args || !args->size() || args->size() > 3)
- return false;
- static const double unsetValue = -1;
- double flexGrow = unsetValue;
- double flexShrink = unsetValue;
- RefPtrWillBeRawPtr<CSSPrimitiveValue> flexBasis = nullptr;
-
- while (CSSParserValue* arg = args->current()) {
- if (validUnit(arg, FNumber | FNonNeg)) {
- if (flexGrow == unsetValue)
- flexGrow = arg->fValue;
- else if (flexShrink == unsetValue)
- flexShrink = arg->fValue;
- else if (!arg->fValue) {
- // flex only allows a basis of 0 (sans units) if flex-grow and flex-shrink values have already been set.
- flexBasis = cssValuePool().createValue(0, CSSPrimitiveValue::UnitType::Pixels);
- } else {
- // We only allow 3 numbers without units if the last value is 0. E.g., flex:1 1 1 is invalid.
- return false;
- }
- } else if (!flexBasis && (arg->id == CSSValueAuto || validUnit(arg, FLength | FPercent | FNonNeg)) && !isFlexBasisMiddleArg(flexGrow, flexShrink, unsetValue, args->size()))
- flexBasis = parseValidPrimitive(arg->id, arg);
- else {
- // Not a valid arg for flex.
- return false;
- }
- args->next();
- }
-
- if (flexGrow == unsetValue)
- flexGrow = 1;
- if (flexShrink == unsetValue)
- flexShrink = 1;
- if (!flexBasis)
- flexBasis = cssValuePool().createValue(0, CSSPrimitiveValue::UnitType::Percentage);
-
- addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(clampTo<float>(flexGrow), CSSPrimitiveValue::UnitType::Number), important);
- addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(clampTo<float>(flexShrink), CSSPrimitiveValue::UnitType::Number), important);
- addProperty(CSSPropertyFlexBasis, flexBasis, important);
- return true;
-}
-
PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parsePosition(CSSParserValueList* valueList)
{
RefPtrWillBeRawPtr<CSSValue> xValue = nullptr;
« no previous file with comments | « third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698