OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/DeferredLegacyStyleInterpolation.h" | 5 #include "core/animation/DeferredLegacyStyleInterpolation.h" |
6 | 6 |
7 #include "core/animation/ElementAnimations.h" | |
8 #include "core/animation/css/CSSAnimatableValueFactory.h" | |
9 #include "core/css/CSSBasicShapeValues.h" | 7 #include "core/css/CSSBasicShapeValues.h" |
10 #include "core/css/CSSImageValue.h" | 8 #include "core/css/CSSImageValue.h" |
11 #include "core/css/CSSPrimitiveValue.h" | 9 #include "core/css/CSSPrimitiveValue.h" |
12 #include "core/css/CSSQuadValue.h" | 10 #include "core/css/CSSQuadValue.h" |
13 #include "core/css/CSSSVGDocumentValue.h" | 11 #include "core/css/CSSSVGDocumentValue.h" |
14 #include "core/css/CSSShadowValue.h" | 12 #include "core/css/CSSShadowValue.h" |
15 #include "core/css/CSSValueList.h" | 13 #include "core/css/CSSValueList.h" |
16 #include "core/css/CSSValuePair.h" | 14 #include "core/css/CSSValuePair.h" |
17 #include "core/css/resolver/StyleResolver.h" | |
18 #include "core/css/resolver/StyleResolverState.h" | |
19 | 15 |
20 namespace blink { | 16 namespace blink { |
21 | 17 |
22 void DeferredLegacyStyleInterpolation::apply(StyleResolverState& state) const | |
23 { | |
24 if (m_outdated || !state.element()->elementAnimations() || !state.element()-
>elementAnimations()->isAnimationStyleChange()) { | |
25 RefPtr<AnimatableValue> startAnimatableValue; | |
26 RefPtr<AnimatableValue> endAnimatableValue; | |
27 | |
28 // Snapshot underlying values for neutral keyframes first because non-ne
utral keyframes will mutate the StyleResolverState. | |
29 if (!m_endCSSValue) { | |
30 endAnimatableValue = StyleResolver::createAnimatableValueSnapshot(st
ate, m_id, m_endCSSValue.get()); | |
31 startAnimatableValue = StyleResolver::createAnimatableValueSnapshot(
state, m_id, m_startCSSValue.get()); | |
32 } else { | |
33 startAnimatableValue = StyleResolver::createAnimatableValueSnapshot(
state, m_id, m_startCSSValue.get()); | |
34 endAnimatableValue = StyleResolver::createAnimatableValueSnapshot(st
ate, m_id, m_endCSSValue.get()); | |
35 } | |
36 | |
37 m_innerInterpolation = LegacyStyleInterpolation::create(startAnimatableV
alue, endAnimatableValue, m_id); | |
38 m_outdated = false; | |
39 } | |
40 | |
41 m_innerInterpolation->interpolate(m_cachedIteration, m_cachedFraction); | |
42 m_innerInterpolation->apply(state); | |
43 } | |
44 | |
45 bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const C
SSValue& value) | 18 bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const C
SSValue& value) |
46 { | 19 { |
47 // FIXME: should not require resolving styles for inherit/initial/unset. | 20 // FIXME: should not require resolving styles for inherit/initial/unset. |
48 if (value.isCSSWideKeyword()) | 21 if (value.isCSSWideKeyword()) |
49 return true; | 22 return true; |
50 if (value.isBasicShapeCircleValue()) | 23 if (value.isBasicShapeCircleValue()) |
51 return interpolationRequiresStyleResolve(toCSSBasicShapeCircleValue(valu
e)); | 24 return interpolationRequiresStyleResolve(toCSSBasicShapeCircleValue(valu
e)); |
52 if (value.isBasicShapeEllipseValue()) | 25 if (value.isBasicShapeEllipseValue()) |
53 return interpolationRequiresStyleResolve(toCSSBasicShapeEllipseValue(val
ue)); | 26 return interpolationRequiresStyleResolve(toCSSBasicShapeEllipseValue(val
ue)); |
54 if (value.isBasicShapePolygonValue()) | 27 if (value.isBasicShapePolygonValue()) |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 141 |
169 bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const C
SSQuadValue& quad) | 142 bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const C
SSQuadValue& quad) |
170 { | 143 { |
171 return interpolationRequiresStyleResolve(*quad.top()) | 144 return interpolationRequiresStyleResolve(*quad.top()) |
172 || interpolationRequiresStyleResolve(*quad.right()) | 145 || interpolationRequiresStyleResolve(*quad.right()) |
173 || interpolationRequiresStyleResolve(*quad.bottom()) | 146 || interpolationRequiresStyleResolve(*quad.bottom()) |
174 || interpolationRequiresStyleResolve(*quad.left()); | 147 || interpolationRequiresStyleResolve(*quad.left()); |
175 } | 148 } |
176 | 149 |
177 } // namespace blink | 150 } // namespace blink |
OLD | NEW |