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

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(
15 CSSParserTokenRange& range,
16 CounterDefaultValue defaultValue) {
17 if (range.peek().id() == CSSValueNone)
18 return CSSPropertyParserHelpers::consumeIdent(range);
19
20 CSSValueList* list = CSSValueList::createSpaceSeparated();
21 do {
22 CSSCustomIdentValue* counterName =
23 CSSPropertyParserHelpers::consumeCustomIdent(range);
24 if (!counterName)
25 return nullptr;
26 int value = static_cast<int>(defaultValue);
suzyh_UTC10 (ex-contributor) 2017/03/28 02:26:08 This int-iness enum-iness arrangement is a bit wei
27 if (CSSPrimitiveValue* counterValue =
28 CSSPropertyParserHelpers::consumeInteger(range))
29 value = clampTo<int>(counterValue->getDoubleValue());
suzyh_UTC10 (ex-contributor) 2017/03/28 02:26:08 Would it make sense to use getIntValue() instead t
Bugs Nash 2017/03/28 02:32:50 I think we're experiencing creep here? This is a r
30 list->append(*CSSValuePair::create(
31 counterName,
32 CSSPrimitiveValue::create(value, CSSPrimitiveValue::UnitType::Integer),
33 CSSValuePair::DropIdenticalValues));
34 } while (!range.atEnd());
35 return list;
36 }
37
38 } // 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