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

Side by Side Diff: Source/core/css/resolver/AnimatedStyleBuilder.cpp

Issue 22799020: Web Animations CSS: Support Animation of StyleImage and LengthBox (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix baselines for new test. Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/css/resolver/AnimatedStyleBuilder.h" 32 #include "core/css/resolver/AnimatedStyleBuilder.h"
33 33
34 #include "core/animation/AnimatableImage.h"
35 #include "core/animation/AnimatableLengthBox.h"
34 #include "core/animation/AnimatableNumber.h" 36 #include "core/animation/AnimatableNumber.h"
35 #include "core/animation/AnimatableTransform.h" 37 #include "core/animation/AnimatableTransform.h"
36 #include "core/animation/AnimatableUnknown.h" 38 #include "core/animation/AnimatableUnknown.h"
37 #include "core/animation/AnimatableValue.h" 39 #include "core/animation/AnimatableValue.h"
40 #include "core/animation/css/CSSAnimations.h"
41 #include "core/css/CSSPrimitiveValueMappings.h"
38 #include "core/css/resolver/StyleBuilder.h" 42 #include "core/css/resolver/StyleBuilder.h"
39 #include "core/css/resolver/StyleResolverState.h" 43 #include "core/css/resolver/StyleResolverState.h"
40 #include "core/rendering/style/RenderStyle.h" 44 #include "core/rendering/style/RenderStyle.h"
41 #include "wtf/MathExtras.h" 45 #include "wtf/MathExtras.h"
42 46
43 namespace WebCore { 47 namespace WebCore {
44 48
45 namespace { 49 namespace {
46 50
47 Length animatableValueToLength(const AnimatableValue* value, const StyleResolver State& state) 51 Length animatableValueToLength(const AnimatableValue* value, const StyleResolver State& state)
48 { 52 {
49 const RenderStyle* style = state.style(); 53 const RenderStyle* style = state.style();
50 return toAnimatableNumber(value)->toLength(style, state.rootElementStyle(), style->effectiveZoom()); 54 if (value->isNumber())
55 return toAnimatableNumber(value)->toLength(style, state.rootElementStyle (), style->effectiveZoom());
56 RefPtr<CSSValue> cssValue = toAnimatableUnknown(value)->toCSSValue();
57 CSSPrimitiveValue* cssPrimitiveValue = toCSSPrimitiveValue(cssValue.get());
58 if (cssPrimitiveValue->isLength())
Timothy Loh 2013/08/27 05:48:17 Looks wrong -- isLength returns false for keywords
59 return cssPrimitiveValue->convertToLength<AnyConversion>(style, state.ro otElementStyle(), style->effectiveZoom());
60 return Length(Undefined);
51 } 61 }
52 62
53 unsigned animatableValueToUnsigned(const AnimatableValue* value) 63 unsigned animatableValueToUnsigned(const AnimatableValue* value)
54 { 64 {
55 return clampTo<unsigned>(round(toAnimatableNumber(value)->toDouble())); 65 return clampTo<unsigned>(round(toAnimatableNumber(value)->toDouble()));
56 } 66 }
57 67
68 LengthBox animatableValueToLengthBox(const AnimatableValue* value, const StyleRe solverState& state)
69 {
70 const AnimatableLengthBox* animatableLengthBox = toAnimatableLengthBox(value );
71 return LengthBox(
72 animatableValueToLength(animatableLengthBox->top(), state),
73 animatableValueToLength(animatableLengthBox->right(), state),
74 animatableValueToLength(animatableLengthBox->bottom(), state),
75 animatableValueToLength(animatableLengthBox->left(), state));
76 }
77
58 } // namespace 78 } // namespace
59 79
60 // FIXME: This should handle all animatable properties
61 // (see CSSAnimatableValueFactory for list of remaining)
62
63 // FIXME: Generate this function. 80 // FIXME: Generate this function.
64 void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, StyleResolverSt ate& state, const AnimatableValue* value) 81 void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, StyleResolverSt ate& state, const AnimatableValue* value)
65 { 82 {
66 if (value->isUnknown()) { 83 if (value->isUnknown()) {
67 StyleBuilder::applyProperty(property, state, toAnimatableUnknown(value)- >toCSSValue().get()); 84 StyleBuilder::applyProperty(property, state, toAnimatableUnknown(value)- >toCSSValue().get());
68 return; 85 return;
69 } 86 }
70 RenderStyle* style = state.style(); 87 RenderStyle* style = state.style();
71 switch (property) { 88 switch (property) {
72 case CSSPropertyBorderBottomWidth: 89 case CSSPropertyBorderBottomWidth:
73 style->setBorderBottomWidth(animatableValueToUnsigned(value)); 90 style->setBorderBottomWidth(animatableValueToUnsigned(value));
74 return; 91 return;
92 case CSSPropertyBorderImageOutset:
93 style->setBorderImageOutset(animatableValueToLengthBox(value, state));
94 return;
95 case CSSPropertyBorderImageSlice:
96 style->setBorderImageSlices(animatableValueToLengthBox(value, state));
97 return;
98 case CSSPropertyBorderImageSource:
99 style->setBorderImageSource(toAnimatableImage(value)->toStyleImage());
100 return;
101 case CSSPropertyBorderImageWidth:
102 style->setBorderImageWidth(animatableValueToLengthBox(value, state));
103 return;
75 case CSSPropertyBorderLeftWidth: 104 case CSSPropertyBorderLeftWidth:
76 style->setBorderLeftWidth(animatableValueToUnsigned(value)); 105 style->setBorderLeftWidth(animatableValueToUnsigned(value));
77 return; 106 return;
78 case CSSPropertyBorderRightWidth: 107 case CSSPropertyBorderRightWidth:
79 style->setBorderRightWidth(animatableValueToUnsigned(value)); 108 style->setBorderRightWidth(animatableValueToUnsigned(value));
80 return; 109 return;
81 case CSSPropertyBorderTopWidth: 110 case CSSPropertyBorderTopWidth:
82 style->setBorderTopWidth(animatableValueToUnsigned(value)); 111 style->setBorderTopWidth(animatableValueToUnsigned(value));
83 return; 112 return;
84 case CSSPropertyBottom: 113 case CSSPropertyBottom:
85 style->setBottom(animatableValueToLength(value, state)); 114 style->setBottom(animatableValueToLength(value, state));
86 return; 115 return;
116 case CSSPropertyClip:
117 style->setClip(animatableValueToLengthBox(value, state));
118 return;
87 case CSSPropertyHeight: 119 case CSSPropertyHeight:
88 style->setHeight(animatableValueToLength(value, state)); 120 style->setHeight(animatableValueToLength(value, state));
89 return; 121 return;
122 case CSSPropertyListStyleImage:
123 style->setListStyleImage(toAnimatableImage(value)->toStyleImage());
124 return;
90 case CSSPropertyLeft: 125 case CSSPropertyLeft:
91 style->setLeft(animatableValueToLength(value, state)); 126 style->setLeft(animatableValueToLength(value, state));
92 return; 127 return;
93 case CSSPropertyMarginBottom: 128 case CSSPropertyMarginBottom:
94 style->setMarginBottom(animatableValueToLength(value, state)); 129 style->setMarginBottom(animatableValueToLength(value, state));
95 return; 130 return;
96 case CSSPropertyMarginLeft: 131 case CSSPropertyMarginLeft:
97 style->setMarginLeft(animatableValueToLength(value, state)); 132 style->setMarginLeft(animatableValueToLength(value, state));
98 return; 133 return;
99 case CSSPropertyMarginRight: 134 case CSSPropertyMarginRight:
(...skipping 28 matching lines...) Expand all
128 return; 163 return;
129 case CSSPropertyPaddingTop: 164 case CSSPropertyPaddingTop:
130 style->setPaddingTop(animatableValueToLength(value, state)); 165 style->setPaddingTop(animatableValueToLength(value, state));
131 return; 166 return;
132 case CSSPropertyRight: 167 case CSSPropertyRight:
133 style->setRight(animatableValueToLength(value, state)); 168 style->setRight(animatableValueToLength(value, state));
134 return; 169 return;
135 case CSSPropertyTop: 170 case CSSPropertyTop:
136 style->setTop(animatableValueToLength(value, state)); 171 style->setTop(animatableValueToLength(value, state));
137 return; 172 return;
173 case CSSPropertyWebkitMaskBoxImageSource:
174 style->setMaskBoxImageSource(toAnimatableImage(value)->toStyleImage());
175 return;
176 case CSSPropertyWebkitMaskImage:
177 style->setMaskImage(toAnimatableImage(value)->toStyleImage());
178 return;
138 case CSSPropertyWebkitPerspectiveOriginX: 179 case CSSPropertyWebkitPerspectiveOriginX:
139 style->setPerspectiveOriginX(animatableValueToLength(value, state)); 180 style->setPerspectiveOriginX(animatableValueToLength(value, state));
140 return; 181 return;
141 case CSSPropertyWebkitPerspectiveOriginY: 182 case CSSPropertyWebkitPerspectiveOriginY:
142 style->setPerspectiveOriginY(animatableValueToLength(value, state)); 183 style->setPerspectiveOriginY(animatableValueToLength(value, state));
143 return; 184 return;
144 case CSSPropertyWebkitTransform: 185 case CSSPropertyWebkitTransform:
145 style->setTransform(toAnimatableTransform(value)->transformOperations()) ; 186 style->setTransform(toAnimatableTransform(value)->transformOperations()) ;
146 return; 187 return;
147 case CSSPropertyWebkitTransformOriginX: 188 case CSSPropertyWebkitTransformOriginX:
148 style->setTransformOriginX(animatableValueToLength(value, state)); 189 style->setTransformOriginX(animatableValueToLength(value, state));
149 return; 190 return;
150 case CSSPropertyWebkitTransformOriginY: 191 case CSSPropertyWebkitTransformOriginY:
151 style->setTransformOriginY(animatableValueToLength(value, state)); 192 style->setTransformOriginY(animatableValueToLength(value, state));
152 return; 193 return;
153 case CSSPropertyWidth: 194 case CSSPropertyWidth:
154 style->setWidth(animatableValueToLength(value, state)); 195 style->setWidth(animatableValueToLength(value, state));
155 return; 196 return;
156 default: 197 default:
157 RELEASE_ASSERT_WITH_MESSAGE(false, "Unable to apply AnimatableValue to R enderStyle, not yet implemented!"); 198 RELEASE_ASSERT_WITH_MESSAGE(!CSSAnimations::isAnimatableProperty(propert y), "Unable to apply AnimatableValue to RenderStyle, not yet implemented: %s", g etPropertyNameString(property).utf8().data());
158 return; 199 ASSERT_NOT_REACHED();
159 } 200 }
160 } 201 }
161 202
162 } // namespace WebCore 203 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698