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

Side by Side Diff: third_party/WebKit/Source/core/css/properties/CSSPropertyCounterUtils.cpp

Issue 2772263004: Added CSSPropertyCounterUtils which holds shared counter parsing logic. (Closed)
Patch Set: addressed reviewer comment Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/css/properties/CSSPropertyCounterUtils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "core/css/properties/CSSPropertyCounterUtils.h"
6
7 #include "core/css/CSSValueList.h"
8 #include "core/css/CSSValuePair.h"
9 #include "core/css/parser/CSSParserTokenRange.h"
10 #include "core/css/parser/CSSPropertyParserHelpers.h"
11
12 namespace blink {
13
14 CSSValue* CSSPropertyCounterUtils::consumeCounter(CSSParserTokenRange& range,
15 int defaultValue) {
16 if (range.peek().id() == CSSValueNone)
17 return CSSPropertyParserHelpers::consumeIdent(range);
18
19 CSSValueList* list = CSSValueList::createSpaceSeparated();
20 do {
21 CSSCustomIdentValue* counterName =
22 CSSPropertyParserHelpers::consumeCustomIdent(range);
23 if (!counterName)
24 return nullptr;
25 int value = defaultValue;
26 if (CSSPrimitiveValue* counterValue =
27 CSSPropertyParserHelpers::consumeInteger(range))
28 value = clampTo<int>(counterValue->getDoubleValue());
29 list->append(*CSSValuePair::create(
30 counterName,
31 CSSPrimitiveValue::create(value, CSSPrimitiveValue::UnitType::Integer),
32 CSSValuePair::DropIdenticalValues));
33 } while (!range.atEnd());
34 return list;
35 }
36
37 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/properties/CSSPropertyCounterUtils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698