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

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: SVG Paint 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/CSSSVGDocumentValue.h"
12 #include "core/css/CSSShadowValue.h"
13 #include "core/css/CSSValueList.h"
14 #include "core/css/Pair.h"
15 #include "core/css/Rect.h"
16 #include "core/css/resolver/StyleResolver.h"
17 #include "core/css/resolver/StyleResolverState.h"
18
19 namespace WebCore {
20
21 void DeferredLegacyStyleInterpolation::apply(StyleResolverState& state) const
22 {
23 RefPtrWillBeRawPtr<LegacyStyleInterpolation> innerInterpolation = LegacyStyl eInterpolation::create(
24 StyleResolver::createAnimatableValueSnapshot(*state.element(), m_id, *m_ startCSSValue, *state.style()),
25 StyleResolver::createAnimatableValueSnapshot(*state.element(), m_id, *m_ endCSSValue, *state.style()),
26 m_id);
27 innerInterpolation->interpolate(m_cachedIteration, m_cachedFraction);
28 innerInterpolation->apply(state);
29 }
30
31 bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const C SSValue& value)
32 {
33 switch (value.cssValueType()) {
34 case CSSValue::CSS_INHERIT:
35 return true;
36 case CSSValue::CSS_PRIMITIVE_VALUE:
37 return interpolationRequiresStyleResolve(toCSSPrimitiveValue(value));
38 case CSSValue::CSS_VALUE_LIST:
39 return interpolationRequiresStyleResolve(toCSSValueList(value));
40 case CSSValue::CSS_CUSTOM:
41 if (value.isImageValue())
42 return interpolationRequiresStyleResolve(toCSSImageValue(value));
43 if (value.isShadowValue())
44 return interpolationRequiresStyleResolve(toCSSShadowValue(value));
45 if (value.isSVGDocumentValue())
46 return interpolationRequiresStyleResolve(toCSSSVGDocumentValue(value ));
47 if (value.isSVGPaint())
48 return false;
49 // FIXME: consider other custom types.
50 return true;
51 case CSSValue::CSS_INITIAL:
52 // FIXME: should not require resolving styles for initial.
53 return true;
54 default:
55 ASSERT_NOT_REACHED();
56 return true;
57 }
58 }
59
60 bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const C SSPrimitiveValue& primitiveValue)
61 {
62 // FIXME: consider other types.
63 if (primitiveValue.isNumber() || primitiveValue.isPercentage() || primitiveV alue.isAngle() || primitiveValue.isRGBColor() || primitiveValue.isURI())
64 return false;
65
66 if (primitiveValue.isLength())
67 return primitiveValue.isFontRelativeLength() || primitiveValue.isViewpor tPercentageLength();
68
69 if (primitiveValue.isCalculated()) {
70 CSSLengthArray lengthArray(CSSPrimitiveValue::LengthUnitTypeCount);
71 primitiveValue.accumulateLengthArray(lengthArray);
72 return lengthArray[CSSPrimitiveValue::UnitTypeFontSize] != 0
73 || lengthArray[CSSPrimitiveValue::UnitTypeFontXSize] != 0
74 || lengthArray[CSSPrimitiveValue::UnitTypeRootFontSize] != 0
75 || lengthArray[CSSPrimitiveValue::UnitTypeZeroCharacterWidth] != 0
76 || lengthArray[CSSPrimitiveValue::UnitTypeViewportWidth] != 0
77 || lengthArray[CSSPrimitiveValue::UnitTypeViewportHeight] != 0
78 || lengthArray[CSSPrimitiveValue::UnitTypeViewportMin] != 0
79 || lengthArray[CSSPrimitiveValue::UnitTypeViewportMax] != 0;
80 }
81
82 if (Pair* pair = primitiveValue.getPairValue()) {
83 return interpolationRequiresStyleResolve(*pair->first())
84 || interpolationRequiresStyleResolve(*pair->second());
85 }
86
87 if (Rect* rect = primitiveValue.getRectValue()) {
88 return interpolationRequiresStyleResolve(*rect->top())
89 || interpolationRequiresStyleResolve(*rect->right())
90 || interpolationRequiresStyleResolve(*rect->bottom())
91 || interpolationRequiresStyleResolve(*rect->left());
92 }
93
94 if (Quad* quad = primitiveValue.getQuadValue()) {
95 return interpolationRequiresStyleResolve(*quad->top())
96 || interpolationRequiresStyleResolve(*quad->right())
97 || interpolationRequiresStyleResolve(*quad->bottom())
98 || interpolationRequiresStyleResolve(*quad->left());
99 }
100
101 if (primitiveValue.isShape())
102 return interpolationRequiresStyleResolve(*primitiveValue.getShapeValue() );
103
104 CSSValueID id = primitiveValue.getValueID();
105 bool isColor = ((id >= CSSValueAqua && id <= CSSValueTransparent)
106 || (id >= CSSValueAliceblue && id <= CSSValueYellowgreen)
107 || id == CSSValueGrey);
108 return (id != CSSValueNone) && !isColor;
109 }
110
111 bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const C SSImageValue& imageValue)
112 {
113 return false;
114 }
115
116 bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const C SSShadowValue& shadowValue)
117 {
118 return (shadowValue.x && interpolationRequiresStyleResolve(*shadowValue.x))
119 || (shadowValue.y && interpolationRequiresStyleResolve(*shadowValue.y))
120 || (shadowValue.blur && interpolationRequiresStyleResolve(*shadowValue.b lur))
121 || (shadowValue.spread && interpolationRequiresStyleResolve(*shadowValue .spread))
122 || (shadowValue.style && interpolationRequiresStyleResolve(*shadowValue. style))
123 || (shadowValue.color && interpolationRequiresStyleResolve(*shadowValue. color));
124 }
125
126 bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const C SSSVGDocumentValue& documentValue)
127 {
128 return true;
129 }
130
131 bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const C SSValueList& valueList)
132 {
133 size_t length = valueList.length();
134 for (size_t index = 0; index < length; ++index) {
135 if (interpolationRequiresStyleResolve(*valueList.item(index)))
136 return true;
137 }
138 return false;
139 }
140
141 bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const C SSBasicShape& shape)
142 {
143 // FIXME: Should determine the specific shape, and inspect the members.
144 return false;
145 }
146
147 void DeferredLegacyStyleInterpolation::trace(Visitor* visitor)
148 {
149 StyleInterpolation::trace(visitor);
150 visitor->trace(m_startCSSValue);
151 visitor->trace(m_endCSSValue);
152 }
153
154 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698