| 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" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 | 82 |
| 83 result.appendVector(variableData->tokens()); | 83 result.appendVector(variableData->tokens()); |
| 84 Vector<CSSParserToken> trash; | 84 Vector<CSSParserToken> trash; |
| 85 resolveFallback(range, trash); | 85 resolveFallback(range, trash); |
| 86 return true; | 86 return true; |
| 87 } | 87 } |
| 88 | 88 |
| 89 void CSSVariableResolver::resolveApplyAtRule(CSSParserTokenRange& range, | 89 void CSSVariableResolver::resolveApplyAtRule(CSSParserTokenRange& range, |
| 90 Vector<CSSParserToken>& result) | 90 Vector<CSSParserToken>& result) |
| 91 { | 91 { |
| 92 ASSERT(range.peek().type() == AtKeywordToken && range.peek().valueEqualsIgno
ringASCIICase("apply")); | 92 DCHECK(range.peek().type() == AtKeywordToken && equalIgnoringASCIICase(range
.peek().value(), "apply")); |
| 93 range.consumeIncludingWhitespace(); | 93 range.consumeIncludingWhitespace(); |
| 94 const CSSParserToken& variableName = range.consumeIncludingWhitespace(); | 94 const CSSParserToken& variableName = range.consumeIncludingWhitespace(); |
| 95 // TODO(timloh): Should we actually be consuming this? | 95 // TODO(timloh): Should we actually be consuming this? |
| 96 if (range.peek().type() == SemicolonToken) | 96 if (range.peek().type() == SemicolonToken) |
| 97 range.consume(); | 97 range.consume(); |
| 98 | 98 |
| 99 CSSVariableData* variableData = valueForCustomProperty(variableName.value().
toAtomicString()); | 99 CSSVariableData* variableData = valueForCustomProperty(variableName.value().
toAtomicString()); |
| 100 if (!variableData) | 100 if (!variableData) |
| 101 return; // Invalid custom property | 101 return; // Invalid custom property |
| 102 | 102 |
| 103 CSSParserTokenRange rule = variableData->tokenRange(); | 103 CSSParserTokenRange rule = variableData->tokenRange(); |
| 104 rule.consumeWhitespace(); | 104 rule.consumeWhitespace(); |
| 105 if (rule.peek().type() != LeftBraceToken) | 105 if (rule.peek().type() != LeftBraceToken) |
| 106 return; | 106 return; |
| 107 CSSParserTokenRange ruleContents = rule.consumeBlock(); | 107 CSSParserTokenRange ruleContents = rule.consumeBlock(); |
| 108 rule.consumeWhitespace(); | 108 rule.consumeWhitespace(); |
| 109 if (!rule.atEnd()) | 109 if (!rule.atEnd()) |
| 110 return; | 110 return; |
| 111 | 111 |
| 112 result.appendRange(ruleContents.begin(), ruleContents.end()); | 112 result.appendRange(ruleContents.begin(), ruleContents.end()); |
| 113 } | 113 } |
| 114 | 114 |
| 115 bool CSSVariableResolver::resolveTokenRange(CSSParserTokenRange range, | 115 bool CSSVariableResolver::resolveTokenRange(CSSParserTokenRange range, |
| 116 Vector<CSSParserToken>& result) | 116 Vector<CSSParserToken>& result) |
| 117 { | 117 { |
| 118 bool success = true; | 118 bool success = true; |
| 119 while (!range.atEnd()) { | 119 while (!range.atEnd()) { |
| 120 if (range.peek().functionId() == CSSValueVar) { | 120 if (range.peek().functionId() == CSSValueVar) { |
| 121 success &= resolveVariableReference(range.consumeBlock(), result); | 121 success &= resolveVariableReference(range.consumeBlock(), result); |
| 122 } else if (range.peek().type() == AtKeywordToken && range.peek().valueEq
ualsIgnoringASCIICase("apply") | 122 } else if (range.peek().type() == AtKeywordToken && equalIgnoringASCIICa
se(range.peek().value(), "apply") |
| 123 && RuntimeEnabledFeatures::cssApplyAtRulesEnabled()) { | 123 && RuntimeEnabledFeatures::cssApplyAtRulesEnabled()) { |
| 124 resolveApplyAtRule(range, result); | 124 resolveApplyAtRule(range, result); |
| 125 } else { | 125 } else { |
| 126 result.append(range.consume()); | 126 result.append(range.consume()); |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 return success; | 129 return success; |
| 130 } | 130 } |
| 131 | 131 |
| 132 CSSValue* CSSVariableResolver::resolveVariableReferences(StyleVariableData* styl
eVariableData, CSSPropertyID id, const CSSVariableReferenceValue& value) | 132 CSSValue* CSSVariableResolver::resolveVariableReferences(StyleVariableData* styl
eVariableData, CSSPropertyID id, const CSSVariableReferenceValue& value) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 variable.value = resolver.resolveCustomProperty(variable.key, *varia
ble.value); | 184 variable.value = resolver.resolveCustomProperty(variable.key, *varia
ble.value); |
| 185 } | 185 } |
| 186 } | 186 } |
| 187 | 187 |
| 188 CSSVariableResolver::CSSVariableResolver(StyleVariableData* styleVariableData) | 188 CSSVariableResolver::CSSVariableResolver(StyleVariableData* styleVariableData) |
| 189 : m_styleVariableData(styleVariableData) | 189 : m_styleVariableData(styleVariableData) |
| 190 { | 190 { |
| 191 } | 191 } |
| 192 | 192 |
| 193 } // namespace blink | 193 } // namespace blink |
| OLD | NEW |