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

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

Issue 2610853004: Implements CSSPropertyAPI for the text-indent property. (Closed)
Patch Set: rebase 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
5 #include "core/css/properties/CSSPropertyAPITextIndent.h"
6
7 #include "core/css/CSSValueList.h"
8 #include "core/css/parser/CSSParserContext.h"
9 #include "core/css/parser/CSSPropertyParserHelpers.h"
10 #include "platform/RuntimeEnabledFeatures.h"
11
12 namespace blink {
13
14 const CSSValue* CSSPropertyAPITextIndent::parseSingleValue(
15 CSSParserTokenRange& range,
16 const CSSParserContext* context) {
17 // [ <length> | <percentage> ] && hanging? && each-line?
18 // Keywords only allowed when css3Text is enabled.
19 CSSValueList* list = CSSValueList::createSpaceSeparated();
20
21 bool hasLengthOrPercentage = false;
22 bool hasEachLine = false;
23 bool hasHanging = false;
24
25 do {
26 if (!hasLengthOrPercentage) {
27 if (CSSValue* textIndent =
28 CSSPropertyParserHelpers::consumeLengthOrPercent(
29 range, context->mode(), ValueRangeAll,
30 CSSPropertyParserHelpers::UnitlessQuirk::Allow)) {
31 list->append(*textIndent);
32 hasLengthOrPercentage = true;
33 continue;
34 }
35 }
36
37 if (RuntimeEnabledFeatures::css3TextEnabled()) {
38 CSSValueID id = range.peek().id();
39 if (!hasEachLine && id == CSSValueEachLine) {
40 list->append(*CSSPropertyParserHelpers::consumeIdent(range));
41 hasEachLine = true;
42 continue;
43 }
44 if (!hasHanging && id == CSSValueHanging) {
45 list->append(*CSSPropertyParserHelpers::consumeIdent(range));
46 hasHanging = true;
47 continue;
48 }
49 }
50 return nullptr;
51 } while (!range.atEnd());
52
53 if (!hasLengthOrPercentage)
54 return nullptr;
55
56 return list;
57 }
58
59 } // namespace blink
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