Commit b58fb795 authored by bugsnash's avatar bugsnash Committed by Commit bot

Refactored out need to pass property to IsValidAnimationPropertyList.

Part of project Ribbon

This refactor is one step in the process of refactoring out property
specific logic inside switch cases in
CSSPropertyParser::ParseSingleValue. This is required to implement the
parseSingleValue methods in the property APIs without passing property
ID to the API.

Given that the IsValidAnimationPropertyList function only ever returned
false if the property passed was CSSPropertyTransitionProperty, this
check was moved to the calling methods.

The next step in this process will be to refactor out the need to pass
property to the ConsumeAnimationPropertyList function. At this stage the
call to IsValidAnimationPropertyList will be moved to the
CSSPropertyTransitionProperty case only and the check for this property
will be removed.

The check for this property in
CSSPropertyParser::ConsumeAnimationShorthand will be refactored out at a
later stage in project Ribbon.

BUG=668012

Review-Url: https://codereview.chromium.org/2835893002
Cr-Commit-Position: refs/heads/master@{#467277}
parent 40c92451
......@@ -490,9 +490,8 @@ static CSSValue* ConsumeAnimationValue(CSSPropertyID property,
}
}
static bool IsValidAnimationPropertyList(CSSPropertyID property,
const CSSValueList& value_list) {
if (property != CSSPropertyTransitionProperty || value_list.length() < 2)
static bool IsValidAnimationPropertyList(const CSSValueList& value_list) {
if (value_list.length() < 2)
return true;
for (auto& value : value_list) {
if (value->IsIdentifierValue() &&
......@@ -515,7 +514,8 @@ static CSSValueList* ConsumeAnimationPropertyList(
return nullptr;
list->Append(*value);
} while (ConsumeCommaIncludingWhitespace(range));
if (!IsValidAnimationPropertyList(property, *list))
if (property == CSSPropertyTransitionProperty &&
!IsValidAnimationPropertyList(*list))
return nullptr;
DCHECK(list->length());
return list;
......@@ -561,7 +561,11 @@ bool CSSPropertyParser::ConsumeAnimationShorthand(
} while (ConsumeCommaIncludingWhitespace(range_));
for (size_t i = 0; i < longhand_count; ++i) {
if (!IsValidAnimationPropertyList(shorthand.properties()[i], *longhands[i]))
// TODO(bugsnash): Refactor out the need to check for
// CSSPropertyTransitionProperty here when this is method implemented in the
// property APIs
if (shorthand.properties()[i] == CSSPropertyTransitionProperty &&
!IsValidAnimationPropertyList(*longhands[i]))
return false;
}
......
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