| 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 e1f2a5f6a246ddc69af242a03f058341d0602292..7e070a72d51db27d7d718e4691431ece5fe381d6 100644
|
| --- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.h
|
| +++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.h
|
| @@ -126,18 +126,35 @@ CSSIdentifierValue* ConsumeIdent(CSSParserTokenRange& range) {
|
| // 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();
|
| +CSSValue* ConsumeCommaSeparatedList(bool optimise,
|
| + Func callback,
|
| + CSSParserTokenRange& range,
|
| + Args... args) {
|
| + CSSValue* result = nullptr;
|
| + if (!optimise)
|
| + result = CSSValueList::CreateCommaSeparated();
|
| do {
|
| CSSValue* value = callback(range, args...);
|
| if (!value)
|
| return nullptr;
|
| - list->Append(*value);
|
| +
|
| + if (optimise) {
|
| + if (!result) {
|
| + // To conserve memory we don't wrap a single value in a list.
|
| + result = value;
|
| + continue;
|
| + }
|
| + if (!result->IsBaseValueList()) {
|
| + CSSValue* first_value = result;
|
| + result = CSSValueList::CreateCommaSeparated();
|
| + ToCSSValueList(result)->Append(*first_value);
|
| + }
|
| + }
|
| + ToCSSValueList(result)->Append(*value);
|
| } while (ConsumeCommaIncludingWhitespace(range));
|
| - DCHECK(list->length());
|
| - return list;
|
| +
|
| + DCHECK(!result->IsBaseValueList() || ToCSSValueList(result)->length());
|
| + return result;
|
| }
|
|
|
| } // namespace CSSPropertyParserHelpers
|
|
|