OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/css/properties/CSSPropertyAPITextIndent.h" | 5 #include "core/css/properties/CSSPropertyAPITextIndent.h" |
6 | 6 |
7 #include "core/css/CSSValueList.h" | 7 #include "core/css/CSSValueList.h" |
8 #include "core/css/parser/CSSParserContext.h" | 8 #include "core/css/parser/CSSParserContext.h" |
9 #include "core/css/parser/CSSPropertyParserHelpers.h" | 9 #include "core/css/parser/CSSPropertyParserHelpers.h" |
10 #include "platform/RuntimeEnabledFeatures.h" | 10 #include "platform/RuntimeEnabledFeatures.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 const CSSValue* CSSPropertyAPITextIndent::parseSingleValue( | 14 const CSSValue* CSSPropertyAPITextIndent::parseSingleValue( |
15 CSSParserTokenRange& range, | 15 CSSParserTokenRange& range, |
16 const CSSParserContext* context) { | 16 const CSSParserContext& context) { |
17 // [ <length> | <percentage> ] && hanging? && each-line? | 17 // [ <length> | <percentage> ] && hanging? && each-line? |
18 // Keywords only allowed when css3Text is enabled. | 18 // Keywords only allowed when css3Text is enabled. |
19 CSSValueList* list = CSSValueList::createSpaceSeparated(); | 19 CSSValueList* list = CSSValueList::createSpaceSeparated(); |
20 | 20 |
21 bool hasLengthOrPercentage = false; | 21 bool hasLengthOrPercentage = false; |
22 bool hasEachLine = false; | 22 bool hasEachLine = false; |
23 bool hasHanging = false; | 23 bool hasHanging = false; |
24 | 24 |
25 do { | 25 do { |
26 if (!hasLengthOrPercentage) { | 26 if (!hasLengthOrPercentage) { |
27 if (CSSValue* textIndent = | 27 if (CSSValue* textIndent = |
28 CSSPropertyParserHelpers::consumeLengthOrPercent( | 28 CSSPropertyParserHelpers::consumeLengthOrPercent( |
29 range, context->mode(), ValueRangeAll, | 29 range, context.mode(), ValueRangeAll, |
30 CSSPropertyParserHelpers::UnitlessQuirk::Allow)) { | 30 CSSPropertyParserHelpers::UnitlessQuirk::Allow)) { |
31 list->append(*textIndent); | 31 list->append(*textIndent); |
32 hasLengthOrPercentage = true; | 32 hasLengthOrPercentage = true; |
33 continue; | 33 continue; |
34 } | 34 } |
35 } | 35 } |
36 | 36 |
37 if (RuntimeEnabledFeatures::css3TextEnabled()) { | 37 if (RuntimeEnabledFeatures::css3TextEnabled()) { |
38 CSSValueID id = range.peek().id(); | 38 CSSValueID id = range.peek().id(); |
39 if (!hasEachLine && id == CSSValueEachLine) { | 39 if (!hasEachLine && id == CSSValueEachLine) { |
(...skipping 10 matching lines...) Expand all Loading... |
50 return nullptr; | 50 return nullptr; |
51 } while (!range.atEnd()); | 51 } while (!range.atEnd()); |
52 | 52 |
53 if (!hasLengthOrPercentage) | 53 if (!hasLengthOrPercentage) |
54 return nullptr; | 54 return nullptr; |
55 | 55 |
56 return list; | 56 return list; |
57 } | 57 } |
58 | 58 |
59 } // namespace blink | 59 } // namespace blink |
OLD | NEW |