| 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 const CSSVariableReferenceValue& value, | 222 const CSSVariableReferenceValue& value, |
| 223 bool disallow_animation_tainted) { | 223 bool disallow_animation_tainted) { |
| 224 CSSVariableResolver resolver(state); | 224 CSSVariableResolver resolver(state); |
| 225 Vector<CSSParserToken> tokens; | 225 Vector<CSSParserToken> tokens; |
| 226 bool is_animation_tainted = false; | 226 bool is_animation_tainted = false; |
| 227 if (!resolver.ResolveTokenRange(value.VariableDataValue()->Tokens(), | 227 if (!resolver.ResolveTokenRange(value.VariableDataValue()->Tokens(), |
| 228 disallow_animation_tainted, tokens, | 228 disallow_animation_tainted, tokens, |
| 229 is_animation_tainted)) | 229 is_animation_tainted)) |
| 230 return CSSUnsetValue::Create(); | 230 return CSSUnsetValue::Create(); |
| 231 const CSSValue* result = | 231 const CSSValue* result = |
| 232 CSSPropertyParser::ParseSingleValue(id, tokens, StrictCSSParserContext()); | 232 CSSPropertyParser::ParseSingleValue(id, tokens, value.ParserContext()); |
| 233 if (!result) | 233 if (!result) |
| 234 return CSSUnsetValue::Create(); | 234 return CSSUnsetValue::Create(); |
| 235 return result; | 235 return result; |
| 236 } | 236 } |
| 237 | 237 |
| 238 const CSSValue* CSSVariableResolver::ResolvePendingSubstitutions( | 238 const CSSValue* CSSVariableResolver::ResolvePendingSubstitutions( |
| 239 const StyleResolverState& state, | 239 const StyleResolverState& state, |
| 240 CSSPropertyID id, | 240 CSSPropertyID id, |
| 241 const CSSPendingSubstitutionValue& pending_value, | 241 const CSSPendingSubstitutionValue& pending_value, |
| 242 bool disallow_animation_tainted) { | 242 bool disallow_animation_tainted) { |
| 243 // Longhands from shorthand references follow this path. | 243 // Longhands from shorthand references follow this path. |
| 244 HeapHashMap<CSSPropertyID, Member<const CSSValue>>& property_cache = | 244 HeapHashMap<CSSPropertyID, Member<const CSSValue>>& property_cache = |
| 245 state.ParsedPropertiesForPendingSubstitutionCache(pending_value); | 245 state.ParsedPropertiesForPendingSubstitutionCache(pending_value); |
| 246 | 246 |
| 247 const CSSValue* value = property_cache.at(id); | 247 const CSSValue* value = property_cache.at(id); |
| 248 if (!value) { | 248 if (!value) { |
| 249 // TODO(timloh): We shouldn't retry this for all longhands if the shorthand | 249 // TODO(timloh): We shouldn't retry this for all longhands if the shorthand |
| 250 // ends up invalid. | 250 // ends up invalid. |
| 251 CSSVariableReferenceValue* shorthand_value = pending_value.ShorthandValue(); | 251 CSSVariableReferenceValue* shorthand_value = pending_value.ShorthandValue(); |
| 252 CSSPropertyID shorthand_property_id = pending_value.ShorthandPropertyId(); | 252 CSSPropertyID shorthand_property_id = pending_value.ShorthandPropertyId(); |
| 253 | 253 |
| 254 CSSVariableResolver resolver(state); | 254 CSSVariableResolver resolver(state); |
| 255 | 255 |
| 256 Vector<CSSParserToken> tokens; | 256 Vector<CSSParserToken> tokens; |
| 257 bool is_animation_tainted = false; | 257 bool is_animation_tainted = false; |
| 258 if (resolver.ResolveTokenRange( | 258 if (resolver.ResolveTokenRange( |
| 259 shorthand_value->VariableDataValue()->Tokens(), | 259 shorthand_value->VariableDataValue()->Tokens(), |
| 260 disallow_animation_tainted, tokens, is_animation_tainted)) { | 260 disallow_animation_tainted, tokens, is_animation_tainted)) { |
| 261 CSSParserContext* context = CSSParserContext::Create(kHTMLStandardMode); | |
| 262 | 261 |
| 263 HeapVector<CSSProperty, 256> parsed_properties; | 262 HeapVector<CSSProperty, 256> parsed_properties; |
| 264 | 263 |
| 265 if (CSSPropertyParser::ParseValue( | 264 if (CSSPropertyParser::ParseValue( |
| 266 shorthand_property_id, false, CSSParserTokenRange(tokens), | 265 shorthand_property_id, false, CSSParserTokenRange(tokens), |
| 267 context, parsed_properties, StyleRule::RuleType::kStyle)) { | 266 shorthand_value->ParserContext(), parsed_properties, |
| 267 StyleRule::RuleType::kStyle)) { |
| 268 unsigned parsed_properties_count = parsed_properties.size(); | 268 unsigned parsed_properties_count = parsed_properties.size(); |
| 269 for (unsigned i = 0; i < parsed_properties_count; ++i) { | 269 for (unsigned i = 0; i < parsed_properties_count; ++i) { |
| 270 property_cache.Set(parsed_properties[i].Id(), | 270 property_cache.Set(parsed_properties[i].Id(), |
| 271 parsed_properties[i].Value()); | 271 parsed_properties[i].Value()); |
| 272 } | 272 } |
| 273 } | 273 } |
| 274 } | 274 } |
| 275 value = property_cache.at(id); | 275 value = property_cache.at(id); |
| 276 } | 276 } |
| 277 | 277 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 } | 334 } |
| 335 } | 335 } |
| 336 } | 336 } |
| 337 | 337 |
| 338 CSSVariableResolver::CSSVariableResolver(const StyleResolverState& state) | 338 CSSVariableResolver::CSSVariableResolver(const StyleResolverState& state) |
| 339 : inherited_variables_(state.Style()->InheritedVariables()), | 339 : inherited_variables_(state.Style()->InheritedVariables()), |
| 340 non_inherited_variables_(state.Style()->NonInheritedVariables()), | 340 non_inherited_variables_(state.Style()->NonInheritedVariables()), |
| 341 registry_(state.GetDocument().GetPropertyRegistry()) {} | 341 registry_(state.GetDocument().GetPropertyRegistry()) {} |
| 342 | 342 |
| 343 } // namespace blink | 343 } // namespace blink |
| OLD | NEW |