OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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/CSSPropertyAPIWillChange.h" |
| 6 |
| 7 #include "core/css/CSSValueList.h" |
| 8 #include "core/css/parser/CSSParserTokenRange.h" |
| 9 #include "core/css/parser/CSSPropertyParser.h" |
| 10 #include "core/css/parser/CSSPropertyParserHelpers.h" |
| 11 |
| 12 namespace blink { |
| 13 |
| 14 const CSSValue* CSSPropertyAPIWillChange::parseSingleValue( |
| 15 CSSParserTokenRange& range, |
| 16 const CSSParserContext& context) { |
| 17 if (range.peek().id() == CSSValueAuto) |
| 18 return CSSPropertyParserHelpers::consumeIdent(range); |
| 19 |
| 20 CSSValueList* values = CSSValueList::createCommaSeparated(); |
| 21 // Every comma-separated list of identifiers is a valid will-change value, |
| 22 // unless the list includes an explicitly disallowed identifier. |
| 23 while (true) { |
| 24 if (range.peek().type() != IdentToken) |
| 25 return nullptr; |
| 26 CSSPropertyID unresolvedProperty = |
| 27 unresolvedCSSPropertyID(range.peek().value()); |
| 28 if (unresolvedProperty != CSSPropertyInvalid && |
| 29 unresolvedProperty != CSSPropertyVariable) { |
| 30 DCHECK(CSSPropertyMetadata::isEnabledProperty(unresolvedProperty)); |
| 31 // Now "all" is used by both CSSValue and CSSPropertyValue. |
| 32 // Need to return nullptr when currentValue is CSSPropertyAll. |
| 33 if (unresolvedProperty == CSSPropertyWillChange || |
| 34 unresolvedProperty == CSSPropertyAll) |
| 35 return nullptr; |
| 36 values->append(*CSSCustomIdentValue::create(unresolvedProperty)); |
| 37 range.consumeIncludingWhitespace(); |
| 38 } else { |
| 39 switch (range.peek().id()) { |
| 40 case CSSValueNone: |
| 41 case CSSValueAll: |
| 42 case CSSValueAuto: |
| 43 case CSSValueDefault: |
| 44 case CSSValueInitial: |
| 45 case CSSValueInherit: |
| 46 return nullptr; |
| 47 case CSSValueContents: |
| 48 case CSSValueScrollPosition: |
| 49 values->append(*CSSPropertyParserHelpers::consumeIdent(range)); |
| 50 break; |
| 51 default: |
| 52 range.consumeIncludingWhitespace(); |
| 53 break; |
| 54 } |
| 55 } |
| 56 |
| 57 if (range.atEnd()) |
| 58 break; |
| 59 if (!CSSPropertyParserHelpers::consumeCommaIncludingWhitespace(range)) |
| 60 return nullptr; |
| 61 } |
| 62 |
| 63 return values; |
| 64 } |
| 65 |
| 66 } // namespace blink |
OLD | NEW |