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

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

Issue 2939883003: Added CSSPropertyTransitionPropertyUtils which holds shared parsing logic. (Closed)
Patch Set: fixed build error 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 4ef06b9285d0fcb71ecc3513d7109ba47548365d..e754820a89a52ffc4b58acb54925221593b81a3f 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"
@@ -50,6 +49,7 @@
#include "core/css/properties/CSSPropertyMarginUtils.h"
#include "core/css/properties/CSSPropertyOffsetPathUtils.h"
#include "core/css/properties/CSSPropertyPositionUtils.h"
+#include "core/css/properties/CSSPropertyTransitionPropertyUtils.h"
#include "core/css/properties/CSSPropertyWebkitBorderWidthUtils.h"
#include "core/frame/UseCounter.h"
#include "core/layout/LayoutTheme.h"
@@ -59,6 +59,8 @@ namespace blink {
using namespace CSSPropertyParserHelpers;
+class CSSCustomIdentValue;
+
CSSPropertyParser::CSSPropertyParser(
const CSSParserTokenRange& range,
const CSSParserContext* context,
@@ -317,23 +319,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;
@@ -451,7 +436,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);
@@ -461,17 +447,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,
@@ -516,7 +491,7 @@ bool CSSPropertyParser::ConsumeAnimationShorthand(
// CSSPropertyTransitionProperty here when this is method implemented in the
// property APIs
if (shorthand.properties()[i] == CSSPropertyTransitionProperty &&
- !IsValidAnimationPropertyList(*longhands[i]))
+ !CSSPropertyTransitionPropertyUtils::IsValidPropertyList(*longhands[i]))
return false;
}
@@ -1548,9 +1523,11 @@ 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::IsValidPropertyList(*list))
return nullptr;
return list;
}

Powered by Google App Engine
This is Rietveld 408576698