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

Side by Side Diff: third_party/WebKit/Source/core/css/properties/CSSPropertyPositionUtils.h

Issue 2647503004: Added CSSPropertyPositionUtils which holds position parsing methods. (Closed)
Patch Set: Merged correctly Created 3 years, 11 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/parser/CSSPropertyParser.cpp ('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 #ifndef CSSPropertyPositionUtils_h
5 #define CSSPropertyPositionUtils_h
6
7 #include "core/CSSValueKeywords.h"
8 #include "core/css/parser/CSSParserMode.h"
9
10 #include "wtf/Allocator.h"
11
12 namespace blink {
13
14 class CSSParserTokenRange;
15 class CSSValue;
16
17 class CSSPropertyPositionUtils {
18 STATIC_ONLY(CSSPropertyPositionUtils);
19
20 template <CSSValueID start, CSSValueID end>
21 static CSSValue* consumePositionLonghand(CSSParserTokenRange& range,
22 CSSParserMode cssParserMode) {
23 if (range.peek().type() == IdentToken) {
24 CSSValueID id = range.peek().id();
25 int percent;
26 if (id == start)
27 percent = 0;
28 else if (id == CSSValueCenter)
29 percent = 50;
30 else if (id == end)
31 percent = 100;
32 else
33 return nullptr;
34 range.consumeIncludingWhitespace();
35 return CSSPrimitiveValue::create(percent,
36 CSSPrimitiveValue::UnitType::Percentage);
37 }
38 return CSSPropertyParserHelpers::consumeLengthOrPercent(
39 range, cssParserMode, ValueRangeAll);
40 }
41 };
42
43 } // namespace blink
44
45 #endif // CSSPropertyPositionUtils_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/parser/CSSPropertyParser.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698