| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/resolver/CSSVariableResolver.h" | 5 #include "core/css/resolver/CSSVariableResolver.h" |
| 6 | 6 |
| 7 #include "core/CSSPropertyNames.h" | 7 #include "core/CSSPropertyNames.h" |
| 8 #include "core/CSSValueKeywords.h" | 8 #include "core/CSSValueKeywords.h" |
| 9 #include "core/StyleBuilderFunctions.h" | 9 #include "core/StyleBuilderFunctions.h" |
| 10 #include "core/StylePropertyShorthand.h" | 10 #include "core/StylePropertyShorthand.h" |
| 11 #include "core/css/CSSValuePool.h" | 11 #include "core/css/CSSValuePool.h" |
| 12 #include "core/css/CSSVariableData.h" | 12 #include "core/css/CSSVariableData.h" |
| 13 #include "core/css/CSSVariableReferenceValue.h" | 13 #include "core/css/CSSVariableReferenceValue.h" |
| 14 #include "core/css/parser/CSSParserToken.h" | 14 #include "core/css/parser/CSSParserToken.h" |
| 15 #include "core/css/parser/CSSParserTokenRange.h" | 15 #include "core/css/parser/CSSParserTokenRange.h" |
| 16 #include "core/css/parser/CSSParserValues.h" | 16 #include "core/css/parser/CSSParserValues.h" |
| 17 #include "core/css/parser/CSSPropertyParser.h" | 17 #include "core/css/parser/CSSPropertyParser.h" |
| 18 #include "core/css/parser/CSSVariableParser.h" | |
| 19 #include "core/css/resolver/StyleBuilder.h" | 18 #include "core/css/resolver/StyleBuilder.h" |
| 20 #include "core/css/resolver/StyleResolverState.h" | 19 #include "core/css/resolver/StyleResolverState.h" |
| 21 #include "core/style/StyleVariableData.h" | 20 #include "core/style/StyleVariableData.h" |
| 22 #include "wtf/Vector.h" | 21 #include "wtf/Vector.h" |
| 23 | 22 |
| 24 namespace blink { | 23 namespace blink { |
| 25 | 24 |
| 26 bool CSSVariableResolver::resolveFallback(CSSParserTokenRange range, Vector<CSSP
arserToken>& result) | 25 bool CSSVariableResolver::resolveFallback(CSSParserTokenRange range, Vector<CSSP
arserToken>& result) |
| 27 { | 26 { |
| 28 if (range.atEnd()) | 27 if (range.atEnd()) |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 result.appendVector(variableData->tokens()); | 84 result.appendVector(variableData->tokens()); |
| 86 Vector<CSSParserToken> trash; | 85 Vector<CSSParserToken> trash; |
| 87 resolveFallback(range, trash); | 86 resolveFallback(range, trash); |
| 88 return true; | 87 return true; |
| 89 } | 88 } |
| 90 | 89 |
| 91 void CSSVariableResolver::resolveApplyAtRule(CSSParserTokenRange& range, | 90 void CSSVariableResolver::resolveApplyAtRule(CSSParserTokenRange& range, |
| 92 Vector<CSSParserToken>& result) | 91 Vector<CSSParserToken>& result) |
| 93 { | 92 { |
| 94 ASSERT(range.peek().type() == AtKeywordToken && range.peek().valueEqualsIgno
ringASCIICase("apply")); | 93 ASSERT(range.peek().type() == AtKeywordToken && range.peek().valueEqualsIgno
ringASCIICase("apply")); |
| 95 CSSParserTokenRange originalRange = range; | |
| 96 | |
| 97 range.consumeIncludingWhitespace(); | 94 range.consumeIncludingWhitespace(); |
| 98 const CSSParserToken& variableName = range.consumeIncludingWhitespace(); | 95 const CSSParserToken& variableName = range.consumeIncludingWhitespace(); |
| 99 if (!CSSVariableParser::isValidVariableName(variableName) | 96 // TODO(timloh): Should we actually be consuming this? |
| 100 || !(range.atEnd() || range.peek().type() == SemicolonToken || range.pee
k().type() == RightBraceToken)) { | |
| 101 range = originalRange; | |
| 102 result.append(range.consume()); | |
| 103 return; | |
| 104 } | |
| 105 if (range.peek().type() == SemicolonToken) | 97 if (range.peek().type() == SemicolonToken) |
| 106 range.consume(); | 98 range.consume(); |
| 107 | 99 |
| 108 CSSVariableData* variableData = valueForCustomProperty(variableName.value())
; | 100 CSSVariableData* variableData = valueForCustomProperty(variableName.value())
; |
| 109 if (!variableData) | 101 if (!variableData) |
| 110 return; // Invalid custom property | 102 return; // Invalid custom property |
| 111 | 103 |
| 112 CSSParserTokenRange rule = variableData->tokenRange(); | 104 CSSParserTokenRange rule = variableData->tokenRange(); |
| 113 rule.consumeWhitespace(); | 105 rule.consumeWhitespace(); |
| 114 if (rule.peek().type() != LeftBraceToken) | 106 if (rule.peek().type() != LeftBraceToken) |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 variable.value = resolver.resolveCustomProperty(variable.key, *varia
ble.value); | 185 variable.value = resolver.resolveCustomProperty(variable.key, *varia
ble.value); |
| 194 } | 186 } |
| 195 } | 187 } |
| 196 | 188 |
| 197 CSSVariableResolver::CSSVariableResolver(StyleVariableData* styleVariableData) | 189 CSSVariableResolver::CSSVariableResolver(StyleVariableData* styleVariableData) |
| 198 : m_styleVariableData(styleVariableData) | 190 : m_styleVariableData(styleVariableData) |
| 199 { | 191 { |
| 200 } | 192 } |
| 201 | 193 |
| 202 } // namespace blink | 194 } // namespace blink |
| OLD | NEW |