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

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: applyAndSnapshotAnimatableValue 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/CSSPrimitiveValue.h"
10 #include "core/css/CSSShadowValue.h"
11 #include "core/css/CSSValueList.h"
12 #include "core/css/Pair.h"
13 #include "core/css/Rect.h"
14 #include "core/css/resolver/StyleResolver.h"
15 #include "core/css/resolver/StyleResolverState.h"
16
17 namespace WebCore {
18
19 void DeferredLegacyStyleInterpolation::apply(StyleResolverState& state) const
20 {
21 RefPtrWillBeRawPtr<LegacyStyleInterpolation> innerInterpolation = LegacyStyl eInterpolation::create(
22 StyleResolver::applyAndSnapshotAnimatableValue(*state.element(), m_id, * m_startCSSValue, state.style()),
shans 2014/05/26 03:31:01 Have two different functions. I think a function t
Eric Willigers 2014/05/26 06:32:47 Agreed, done.
23 StyleResolver::applyAndSnapshotAnimatableValue(*state.element(), m_id, * m_endCSSValue, state.style()),
24 m_id);
25 innerInterpolation->interpolate(m_cachedIteration, m_cachedFraction);
26 innerInterpolation->apply(state);
27 }
28
29 bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const C SSValue& value)
30 {
31 switch (value.cssValueType()) {
32 case CSSValue::CSS_INHERIT:
33 return true;
34 case CSSValue::CSS_PRIMITIVE_VALUE:
35 return interpolationRequiresStyleResolve(toCSSPrimitiveValue(value));
36 case CSSValue::CSS_VALUE_LIST:
37 return interpolationRequiresStyleResolve(toCSSValueList(value));
38 case CSSValue::CSS_CUSTOM:
39 if (value.isShadowValue())
40 return interpolationRequiresStyleResolve(toCSSShadowValue(value));
41 return false;
dstockwell 2014/05/26 01:16:04 Shouldn't the default be true?
Eric Willigers 2014/05/26 06:32:47 Done. Note this leads to a couple of extra failure
42 case CSSValue::CSS_INITIAL:
43 return false;
dstockwell 2014/05/26 01:16:04 Doesn't this depend on what the initial value is?
Eric Willigers 2014/05/26 06:32:47 Done.
44 default:
45 ASSERT_NOT_REACHED();
46 return false;
dstockwell 2014/05/26 01:16:04 Shouldn't the default be true?
Eric Willigers 2014/05/26 06:32:47 Done.
47 }
48 }
49
50 bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const C SSPrimitiveValue& primitiveValue)
51 {
52 if (primitiveValue.isCalculated()) {
53 CSSLengthArray lengthArray;
54 CSSPrimitiveValue::zeroLengthArray(lengthArray);
55 primitiveValue.accumulateLengthArray(lengthArray);
56 return lengthArray[CSSPrimitiveValue::UnitTypeFontSize] != 0
57 || lengthArray[CSSPrimitiveValue::UnitTypeFontXSize] != 0
58 || lengthArray[CSSPrimitiveValue::UnitTypeRootFontSize] != 0
59 || lengthArray[CSSPrimitiveValue::UnitTypeZeroCharacterWidth] != 0
60 || lengthArray[CSSPrimitiveValue::UnitTypeViewportWidth] != 0
61 || lengthArray[CSSPrimitiveValue::UnitTypeViewportHeight] != 0
62 || lengthArray[CSSPrimitiveValue::UnitTypeViewportMin] != 0
63 || lengthArray[CSSPrimitiveValue::UnitTypeViewportMax] != 0;
64 }
65
66 if (primitiveValue.isLength())
67 return primitiveValue.isFontRelativeLength() || primitiveValue.isViewpor tPercentageLength();
68
69 if (Pair* pair = primitiveValue.getPairValue()) {
70 return interpolationRequiresStyleResolve(*pair->first())
71 || interpolationRequiresStyleResolve(*pair->second());
72 }
73
74 if (Rect* rect = primitiveValue.getRectValue()) {
75 return interpolationRequiresStyleResolve(*rect->top())
76 || interpolationRequiresStyleResolve(*rect->right())
77 || interpolationRequiresStyleResolve(*rect->bottom())
78 || interpolationRequiresStyleResolve(*rect->left());
79 }
80
81 if (Quad* quad = primitiveValue.getQuadValue()) {
82 return interpolationRequiresStyleResolve(*quad->top())
83 || interpolationRequiresStyleResolve(*quad->right())
84 || interpolationRequiresStyleResolve(*quad->bottom())
85 || interpolationRequiresStyleResolve(*quad->left());
86 }
87
88 switch (primitiveValue.getValueID()) {
89 case CSSValueBolder:
90 case CSSValueCurrentcolor:
91 case CSSValueHigher:
92 case CSSValueLarger:
93 case CSSValueLighter:
94 case CSSValueLower:
95 case CSSValueSmaller:
96 return true;
97 default:
98 return false;
dstockwell 2014/05/26 01:16:04 Expand these cases and make the default true?
Eric Willigers 2014/05/26 06:32:47 I have made the color constants false and default
99 }
100 }
101
102 bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const C SSShadowValue& shadowValue)
103 {
104 return (shadowValue.x && interpolationRequiresStyleResolve(*shadowValue.x))
105 || (shadowValue.y && interpolationRequiresStyleResolve(*shadowValue.y))
106 || (shadowValue.blur && interpolationRequiresStyleResolve(*shadowValue.b lur))
107 || (shadowValue.spread && interpolationRequiresStyleResolve(*shadowValue .spread))
108 || (shadowValue.style && interpolationRequiresStyleResolve(*shadowValue. style))
109 || (shadowValue.color && interpolationRequiresStyleResolve(*shadowValue. color));
110 }
111
112 bool DeferredLegacyStyleInterpolation::interpolationRequiresStyleResolve(const C SSValueList& valueList)
113 {
114 size_t length = valueList.length();
115 for (size_t index = 0; index < length; ++index) {
116 if (interpolationRequiresStyleResolve(*valueList.item(index)))
117 return true;
118 }
119 return false;
120 }
121
122 void DeferredLegacyStyleInterpolation::trace(Visitor* visitor)
123 {
124 StyleInterpolation::trace(visitor);
125 visitor->trace(m_startCSSValue);
126 visitor->trace(m_endCSSValue);
127 }
128
129 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698