OLD | NEW |
(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 |
OLD | NEW |