Index: third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.h |
diff --git a/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.h b/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.h |
index 9e56d2c0c7136ba910f39fb2babe458030ecda38..e1f2a5f6a246ddc69af242a03f058341d0602292 100644 |
--- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.h |
+++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.h |
@@ -8,6 +8,7 @@ |
#include "core/css/CSSCustomIdentValue.h" |
#include "core/css/CSSIdentifierValue.h" |
#include "core/css/CSSPrimitiveValue.h" |
+#include "core/css/CSSValueList.h" |
#include "core/css/parser/CSSParserMode.h" |
#include "core/css/parser/CSSParserTokenRange.h" |
#include "platform/Length.h" // For ValueRange |
@@ -121,6 +122,24 @@ CSSIdentifierValue* ConsumeIdent(CSSParserTokenRange& range) { |
return CSSIdentifierValue::Create(range.ConsumeIncludingWhitespace().Id()); |
} |
+// ConsumeCommaSeparatedList takes a callback function to call on each item in |
+// the list, followed by the arguments to pass to this callback. |
+// The first argument to the callback must be the CSSParserTokenRange |
+template <typename Func, typename... Args> |
+CSSValueList* ConsumeCommaSeparatedList(Func callback, |
+ CSSParserTokenRange& range, |
+ Args... args) { |
+ CSSValueList* list = CSSValueList::CreateCommaSeparated(); |
+ do { |
+ CSSValue* value = callback(range, args...); |
+ if (!value) |
+ return nullptr; |
+ list->Append(*value); |
+ } while (ConsumeCommaIncludingWhitespace(range)); |
+ DCHECK(list->length()); |
+ return list; |
+} |
+ |
} // namespace CSSPropertyParserHelpers |
} // namespace blink |