Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(390)

Side by Side Diff: Source/core/animation/interpolation/DeferredLegacyStyleInterpolation.cpp

Issue 292173009: Web Animations - responsive interpolation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@0519_MySeparation
Patch Set: ConciseColorTest Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "core/animation/interpolation/DeferredLegacyStyleInterpolation.h"
7
8 #include "core/animation/interpolation/LegacyStyleInterpolation.h"
9 #include "core/css/CSSImageValue.h"
10 #include "core/css/CSSPrimitiveValue.h"
11 #include "core/css/CSSShadowValue.h"
12 #include "core/css/CSSValueList.h"
13 #include "core/css/Pair.h"
14 #include "core/css/Rect.h"
15 #include "core/css/resolver/StyleResolver.h"
16 #include "core/css/resolver/StyleResolverState.h"
17
18 namespace WebCore {
19
20 void DeferredLegacyStyleInterpolation::apply(StyleResolverState& state) const
21 {
22 RefPtrWillBeRawPtr<LegacyStyleInterpolation> innerInterpolation = LegacyStyl eInterpolation::create(
23 StyleResolver::createAnimatableValueSnapshot(*state.element(), m_id, *m_ startCSSValue, *state.style()),
24 StyleResolver::createAnimatableValueSnapshot(*state.element(), m_id, *m_ endCSSValue, *state.style()),
25 m_id);
26 innerInterpolation->interpolate(m_cachedIteration, m_cachedFraction);
27 innerInterpolation->apply(state);
28 }
29
30 bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const C SSValue& value)
31 {
32 switch (value.cssValueType()) {
33 case CSSValue::CSS_INHERIT:
34 return true;
35 case CSSValue::CSS_PRIMITIVE_VALUE:
36 return interpolationRequiresStyleResolve(toCSSPrimitiveValue(value));
37 case CSSValue::CSS_VALUE_LIST:
38 return interpolationRequiresStyleResolve(toCSSValueList(value));
39 case CSSValue::CSS_CUSTOM:
40 if (value.isImageValue())
41 return interpolationRequiresStyleResolve(toCSSImageValue(value));
42 if (value.isShadowValue())
43 return interpolationRequiresStyleResolve(toCSSShadowValue(value));
44 return true;
45 case CSSValue::CSS_INITIAL:
46 // FIXME: should not require resolving styles for initial.
47 return true;
48 default:
49 ASSERT_NOT_REACHED();
50 return true;
51 }
52 }
53
54 bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const C SSPrimitiveValue& primitiveValue)
55 {
56 if (primitiveValue.isCalculated()) {
57 CSSLengthArray lengthArray(CSSPrimitiveValue::LengthUnitTypeCount);
58 primitiveValue.accumulateLengthArray(lengthArray);
59 return lengthArray[CSSPrimitiveValue::UnitTypeFontSize] != 0
60 || lengthArray[CSSPrimitiveValue::UnitTypeFontXSize] != 0
61 || lengthArray[CSSPrimitiveValue::UnitTypeRootFontSize] != 0
62 || lengthArray[CSSPrimitiveValue::UnitTypeZeroCharacterWidth] != 0
63 || lengthArray[CSSPrimitiveValue::UnitTypeViewportWidth] != 0
64 || lengthArray[CSSPrimitiveValue::UnitTypeViewportHeight] != 0
65 || lengthArray[CSSPrimitiveValue::UnitTypeViewportMin] != 0
66 || lengthArray[CSSPrimitiveValue::UnitTypeViewportMax] != 0;
67 }
68
69 if (primitiveValue.isLength())
70 return primitiveValue.isFontRelativeLength() || primitiveValue.isViewpor tPercentageLength();
71
72 if (Pair* pair = primitiveValue.getPairValue()) {
73 return interpolationRequiresStyleResolve(*pair->first())
74 || interpolationRequiresStyleResolve(*pair->second());
75 }
76
77 if (Rect* rect = primitiveValue.getRectValue()) {
78 return interpolationRequiresStyleResolve(*rect->top())
79 || interpolationRequiresStyleResolve(*rect->right())
80 || interpolationRequiresStyleResolve(*rect->bottom())
81 || interpolationRequiresStyleResolve(*rect->left());
82 }
83
84 if (Quad* quad = primitiveValue.getQuadValue()) {
85 return interpolationRequiresStyleResolve(*quad->top())
86 || interpolationRequiresStyleResolve(*quad->right())
87 || interpolationRequiresStyleResolve(*quad->bottom())
88 || interpolationRequiresStyleResolve(*quad->left());
89 }
90
91 CSSValueID id = primitiveValue.getValueID();
92 bool isColor = ((id >= CSSValueAqua && id <= CSSValueTransparent)
93 || (id >= CSSValueAliceblue && id <= CSSValueYellowgreen)
94 || id == CSSValueGrey);
95 return !isColor;
96 }
97
98 bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const C SSImageValue& imageValue)
99 {
100 return false;
101 }
102
103 bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const C SSShadowValue& shadowValue)
104 {
105 return (shadowValue.x && interpolationRequiresStyleResolve(*shadowValue.x))
106 || (shadowValue.y && interpolationRequiresStyleResolve(*shadowValue.y))
107 || (shadowValue.blur && interpolationRequiresStyleResolve(*shadowValue.b lur))
108 || (shadowValue.spread && interpolationRequiresStyleResolve(*shadowValue .spread))
109 || (shadowValue.style && interpolationRequiresStyleResolve(*shadowValue. style))
110 || (shadowValue.color && interpolationRequiresStyleResolve(*shadowValue. color));
111 }
112
113 bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const C SSValueList& valueList)
114 {
115 size_t length = valueList.length();
116 for (size_t index = 0; index < length; ++index) {
117 if (interpolationRequiresStyleResolve(*valueList.item(index)))
118 return true;
119 }
120 return false;
121 }
122
123 void DeferredLegacyStyleInterpolation::trace(Visitor* visitor)
124 {
125 StyleInterpolation::trace(visitor);
126 visitor->trace(m_startCSSValue);
127 visitor->trace(m_endCSSValue);
128 }
129
130 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698