Commit 837eef49 authored by timloh@chromium.org's avatar timloh@chromium.org

Move rolling back badly parsed property to CSSPropertyParser::parseValue

When CSSPropertyParser::parseValue fails, we sometimes have already
yielded property/value pairs (e.g. when parsing shorthands). In this
case we roll back any yielded values. This patch moves the logic for this
to CSSPropertyParser since this is a better fit for it and makes the
parseValue interface more sensible.

BUG=404023

Review URL: https://codereview.chromium.org/645033004

git-svn-id: svn://svn.chromium.org/blink/trunk@183879 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 3fd185d7
......@@ -411,9 +411,7 @@ internal_decls:
internal_value:
INTERNAL_VALUE_SYM maybe_space expr TOKEN_EOF {
parser->m_valueList = parser->sinkFloatingValueList($3);
int oldParsedProperties = parser->m_parsedProperties.size();
if (!parser->parseValue(parser->m_id, parser->m_important))
parser->rollbackLastProperties(parser->m_parsedProperties.size() - oldParsedProperties);
parser->parseValue(parser->m_id, parser->m_important);
parser->m_valueList = nullptr;
}
;
......@@ -1519,12 +1517,10 @@ declaration:
bool isPropertyParsed = false;
if ($1 != CSSPropertyInvalid) {
parser->m_valueList = parser->sinkFloatingValueList($5);
int oldParsedProperties = parser->m_parsedProperties.size();
$$ = parser->parseValue($1, $6);
if (!$$) {
parser->rollbackLastProperties(parser->m_parsedProperties.size() - oldParsedProperties);
if (!$$)
parser->reportError($4, InvalidPropertyValueCSSError);
} else
else
isPropertyParsed = true;
parser->m_valueList = nullptr;
}
......
......@@ -120,6 +120,8 @@ bool CSSPropertyParser::parseValue(CSSPropertyID property, bool important,
CSSParserValueList* valueList, const CSSParserContext& context, bool inViewport,
WillBeHeapVector<CSSProperty, 256>& parsedProperties, CSSRuleSourceData::Type ruleType)
{
int parsedPropertiesSize = parsedProperties.size();
CSSPropertyParser parser(valueList, context, inViewport, parsedProperties, ruleType);
bool parseSuccess = parser.parseValue(property, important);
......@@ -127,6 +129,9 @@ bool CSSPropertyParser::parseValue(CSSPropertyID property, bool important,
if (parseSuccess && context.useCounter())
context.useCounter()->count(context, property);
if (!parseSuccess)
parser.rollbackLastProperties(parsedProperties.size() - parsedPropertiesSize);
return parseSuccess;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment