OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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/animation/CSSInterpolationType.h" | 5 #include "core/animation/CSSInterpolationType.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include "core/StylePropertyShorthand.h" | 8 #include "core/StylePropertyShorthand.h" |
| 9 #include "core/animation/CSSInterpolationEnvironment.h" |
9 #include "core/animation/StringKeyframe.h" | 10 #include "core/animation/StringKeyframe.h" |
10 #include "core/css/CSSCustomPropertyDeclaration.h" | 11 #include "core/css/CSSCustomPropertyDeclaration.h" |
11 #include "core/css/CSSValue.h" | 12 #include "core/css/CSSValue.h" |
12 #include "core/css/CSSVariableReferenceValue.h" | 13 #include "core/css/CSSVariableReferenceValue.h" |
13 #include "core/css/ComputedStyleCSSValueMapping.h" | 14 #include "core/css/ComputedStyleCSSValueMapping.h" |
14 #include "core/css/PropertyRegistration.h" | 15 #include "core/css/PropertyRegistration.h" |
15 #include "core/css/parser/CSSTokenizer.h" | 16 #include "core/css/parser/CSSTokenizer.h" |
16 #include "core/css/resolver/CSSVariableResolver.h" | 17 #include "core/css/resolver/CSSVariableResolver.h" |
17 #include "core/css/resolver/StyleBuilder.h" | 18 #include "core/css/resolver/StyleBuilder.h" |
18 #include "core/css/resolver/StyleResolverState.h" | 19 #include "core/css/resolver/StyleResolverState.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 } | 122 } |
122 return result; | 123 return result; |
123 } | 124 } |
124 | 125 |
125 InterpolationValue CSSInterpolationType::MaybeConvertSingleInternal( | 126 InterpolationValue CSSInterpolationType::MaybeConvertSingleInternal( |
126 const PropertySpecificKeyframe& keyframe, | 127 const PropertySpecificKeyframe& keyframe, |
127 const InterpolationEnvironment& environment, | 128 const InterpolationEnvironment& environment, |
128 const InterpolationValue& underlying, | 129 const InterpolationValue& underlying, |
129 ConversionCheckers& conversion_checkers) const { | 130 ConversionCheckers& conversion_checkers) const { |
130 const CSSValue* value = ToCSSPropertySpecificKeyframe(keyframe).Value(); | 131 const CSSValue* value = ToCSSPropertySpecificKeyframe(keyframe).Value(); |
131 const StyleResolverState& state = environment.GetState(); | 132 const StyleResolverState& state = |
| 133 ToCSSInterpolationEnvironment(environment).GetState(); |
132 | 134 |
133 if (!value) | 135 if (!value) |
134 return MaybeConvertNeutral(underlying, conversion_checkers); | 136 return MaybeConvertNeutral(underlying, conversion_checkers); |
135 | 137 |
136 if (GetProperty().IsCSSCustomProperty()) { | 138 if (GetProperty().IsCSSCustomProperty()) { |
137 return MaybeConvertCustomPropertyDeclaration( | 139 return MaybeConvertCustomPropertyDeclaration( |
138 ToCSSCustomPropertyDeclaration(*value), state, conversion_checkers); | 140 ToCSSCustomPropertyDeclaration(*value), state, conversion_checkers); |
139 } | 141 } |
140 | 142 |
141 if (value->IsVariableReferenceValue() || | 143 if (value->IsVariableReferenceValue() || |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 if (parsed_value) { | 238 if (parsed_value) { |
237 return MaybeConvertValue(*parsed_value, &state, conversion_checkers); | 239 return MaybeConvertValue(*parsed_value, &state, conversion_checkers); |
238 } | 240 } |
239 } | 241 } |
240 | 242 |
241 return nullptr; | 243 return nullptr; |
242 } | 244 } |
243 | 245 |
244 InterpolationValue CSSInterpolationType::MaybeConvertUnderlyingValue( | 246 InterpolationValue CSSInterpolationType::MaybeConvertUnderlyingValue( |
245 const InterpolationEnvironment& environment) const { | 247 const InterpolationEnvironment& environment) const { |
246 const ComputedStyle& style = environment.Style(); | 248 const ComputedStyle& style = |
| 249 ToCSSInterpolationEnvironment(environment).Style(); |
247 if (!GetProperty().IsCSSCustomProperty()) { | 250 if (!GetProperty().IsCSSCustomProperty()) { |
248 return MaybeConvertStandardPropertyUnderlyingValue(style); | 251 return MaybeConvertStandardPropertyUnderlyingValue(style); |
249 } | 252 } |
250 | 253 |
251 const PropertyHandle property = GetProperty(); | 254 const PropertyHandle property = GetProperty(); |
252 const AtomicString& name = property.CustomPropertyName(); | 255 const AtomicString& name = property.CustomPropertyName(); |
253 if (!registration_) { | 256 if (!registration_) { |
254 return nullptr; | 257 return nullptr; |
255 } | 258 } |
256 const CSSValue* underlying_value = | 259 const CSSValue* underlying_value = |
257 style.GetRegisteredVariable(name, registration_->Inherits()); | 260 style.GetRegisteredVariable(name, registration_->Inherits()); |
258 if (!underlying_value) { | 261 if (!underlying_value) { |
259 underlying_value = registration_->Initial(); | 262 underlying_value = registration_->Initial(); |
260 } | 263 } |
261 if (!underlying_value) { | 264 if (!underlying_value) { |
262 return nullptr; | 265 return nullptr; |
263 } | 266 } |
264 // TODO(alancutter): Remove the need for passing in conversion checkers. | 267 // TODO(alancutter): Remove the need for passing in conversion checkers. |
265 ConversionCheckers dummy_conversion_checkers; | 268 ConversionCheckers dummy_conversion_checkers; |
266 return MaybeConvertValue(*underlying_value, nullptr, | 269 return MaybeConvertValue(*underlying_value, nullptr, |
267 dummy_conversion_checkers); | 270 dummy_conversion_checkers); |
268 } | 271 } |
269 | 272 |
270 void CSSInterpolationType::Apply( | 273 void CSSInterpolationType::Apply( |
271 const InterpolableValue& interpolable_value, | 274 const InterpolableValue& interpolable_value, |
272 const NonInterpolableValue* non_interpolable_value, | 275 const NonInterpolableValue* non_interpolable_value, |
273 InterpolationEnvironment& environment) const { | 276 InterpolationEnvironment& environment) const { |
274 StyleResolverState& state = environment.GetState(); | 277 StyleResolverState& state = |
| 278 ToCSSInterpolationEnvironment(environment).GetState(); |
275 | 279 |
276 if (GetProperty().IsCSSCustomProperty()) { | 280 if (GetProperty().IsCSSCustomProperty()) { |
277 ApplyCustomPropertyValue(interpolable_value, non_interpolable_value, state); | 281 ApplyCustomPropertyValue(interpolable_value, non_interpolable_value, state); |
278 return; | 282 return; |
279 } | 283 } |
280 ApplyStandardPropertyValue(interpolable_value, non_interpolable_value, state); | 284 ApplyStandardPropertyValue(interpolable_value, non_interpolable_value, state); |
281 } | 285 } |
282 | 286 |
283 void CSSInterpolationType::ApplyCustomPropertyValue( | 287 void CSSInterpolationType::ApplyCustomPropertyValue( |
284 const InterpolableValue& interpolable_value, | 288 const InterpolableValue& interpolable_value, |
(...skipping 22 matching lines...) Expand all Loading... |
307 if (registration_->Inherits()) { | 311 if (registration_->Inherits()) { |
308 style.SetResolvedInheritedVariable(property_name, std::move(variable_data), | 312 style.SetResolvedInheritedVariable(property_name, std::move(variable_data), |
309 css_value); | 313 css_value); |
310 } else { | 314 } else { |
311 style.SetResolvedNonInheritedVariable(property_name, | 315 style.SetResolvedNonInheritedVariable(property_name, |
312 std::move(variable_data), css_value); | 316 std::move(variable_data), css_value); |
313 } | 317 } |
314 } | 318 } |
315 | 319 |
316 } // namespace blink | 320 } // namespace blink |
OLD | NEW |