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

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

Issue 2939883003: Added CSSPropertyTransitionPropertyUtils which holds shared parsing logic. (Closed)
Patch Set: Added ConsumeTransitinProperty method Created 3 years, 6 months 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
Index: third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
diff --git a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
index eda9dfb196a270dbd326f49a2db7fcae9c3d8984..54f7b5d75b4f0c5147581c274f0f7315a3193b0c 100644
--- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
+++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp
@@ -9,7 +9,6 @@
#include "core/css/CSSBasicShapeValues.h"
#include "core/css/CSSContentDistributionValue.h"
#include "core/css/CSSCursorImageValue.h"
-#include "core/css/CSSCustomIdentValue.h"
#include "core/css/CSSFontFaceSrcValue.h"
#include "core/css/CSSFontFamilyValue.h"
#include "core/css/CSSFunctionValue.h"
@@ -49,6 +48,7 @@
#include "core/css/properties/CSSPropertyOffsetPathUtils.h"
#include "core/css/properties/CSSPropertyPositionUtils.h"
#include "core/css/properties/CSSPropertyShapeUtils.h"
+#include "core/css/properties/CSSPropertyTransitionPropertyUtils.h"
#include "core/css/properties/CSSPropertyWebkitBorderWidthUtils.h"
#include "core/frame/UseCounter.h"
#include "core/layout/LayoutTheme.h"
@@ -58,6 +58,8 @@ namespace blink {
using namespace CSSPropertyParserHelpers;
+class CSSCustomIdentValue;
+
CSSPropertyParser::CSSPropertyParser(
const CSSParserTokenRange& range,
const CSSParserContext* context,
@@ -316,23 +318,6 @@ static CSSValue* ConsumeAnimationIterationCount(CSSParserTokenRange& range) {
return ConsumeNumber(range, kValueRangeNonNegative);
}
-static CSSValue* ConsumeTransitionProperty(CSSParserTokenRange& range) {
- const CSSParserToken& token = range.Peek();
- if (token.GetType() != kIdentToken)
- return nullptr;
- if (token.Id() == CSSValueNone)
- return ConsumeIdent(range);
-
- CSSPropertyID unresolved_property = token.ParseAsUnresolvedCSSPropertyID();
- if (unresolved_property != CSSPropertyInvalid &&
- unresolved_property != CSSPropertyVariable) {
- DCHECK(CSSPropertyMetadata::IsEnabledProperty(unresolved_property));
- range.ConsumeIncludingWhitespace();
- return CSSCustomIdentValue::Create(unresolved_property);
- }
- return ConsumeCustomIdent(range);
-}
-
static CSSValue* ConsumeSteps(CSSParserTokenRange& range) {
DCHECK_EQ(range.Peek().FunctionId(), CSSValueSteps);
CSSParserTokenRange range_copy = range;
@@ -450,7 +435,8 @@ static CSSValue* ConsumeAnimationValue(CSSPropertyID property,
case CSSPropertyAnimationPlayState:
return ConsumeIdent<CSSValueRunning, CSSValuePaused>(range);
case CSSPropertyTransitionProperty:
- return ConsumeTransitionProperty(range);
+ return CSSPropertyTransitionPropertyUtils::ConsumeTransitionProperty(
+ range);
case CSSPropertyAnimationTimingFunction:
case CSSPropertyTransitionTimingFunction:
return ConsumeAnimationTimingFunction(range);
@@ -460,17 +446,6 @@ static CSSValue* ConsumeAnimationValue(CSSPropertyID property,
}
}
-static bool IsValidAnimationPropertyList(const CSSValueList& value_list) {
- if (value_list.length() < 2)
- return true;
- for (auto& value : value_list) {
- if (value->IsIdentifierValue() &&
- ToCSSIdentifierValue(*value).GetValueID() == CSSValueNone)
- return false;
- }
- return true;
-}
-
bool CSSPropertyParser::ConsumeAnimationShorthand(
const StylePropertyShorthand& shorthand,
bool use_legacy_parsing,
@@ -515,7 +490,8 @@ bool CSSPropertyParser::ConsumeAnimationShorthand(
// CSSPropertyTransitionProperty here when this is method implemented in the
// property APIs
if (shorthand.properties()[i] == CSSPropertyTransitionProperty &&
- !IsValidAnimationPropertyList(*longhands[i]))
+ !CSSPropertyTransitionPropertyUtils::IsValidAnimationPropertyList(
+ *longhands[i]))
return false;
}
@@ -1515,9 +1491,12 @@ const CSSValue* CSSPropertyParser::ParseSingleValue(
return ConsumeCommaSeparatedList(
ConsumeIdent<CSSValueRunning, CSSValuePaused>, range_);
case CSSPropertyTransitionProperty: {
- CSSValueList* list =
- ConsumeCommaSeparatedList(ConsumeTransitionProperty, range_);
- if (!list || !IsValidAnimationPropertyList(*list))
+ CSSValueList* list = ConsumeCommaSeparatedList(
+ CSSPropertyTransitionPropertyUtils::ConsumeTransitionProperty,
+ range_);
+ if (!list ||
+ !CSSPropertyTransitionPropertyUtils::IsValidAnimationPropertyList(
+ *list))
return nullptr;
return list;
}

Powered by Google App Engine
This is Rietveld 408576698