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

Side by Side Diff: Source/core/animation/css/CSSAnimatableValueFactory.cpp

Issue 22799020: Web Animations CSS: Support Animation of StyleImage and LengthBox (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased 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
« no previous file with comments | « Source/core/animation/AnimatableValue.h ('k') | Source/core/animation/css/CSSAnimations.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 14 matching lines...) Expand all
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/animation/css/CSSAnimatableValueFactory.h" 32 #include "core/animation/css/CSSAnimatableValueFactory.h"
33 33
34 #include "CSSValueKeywords.h" 34 #include "CSSValueKeywords.h"
35 #include "core/animation/AnimatableImage.h"
36 #include "core/animation/AnimatableLengthBox.h"
35 #include "core/animation/AnimatableNumber.h" 37 #include "core/animation/AnimatableNumber.h"
36 #include "core/animation/AnimatableTransform.h" 38 #include "core/animation/AnimatableTransform.h"
37 #include "core/animation/AnimatableUnknown.h" 39 #include "core/animation/AnimatableUnknown.h"
40 #include "core/animation/css/CSSAnimations.h"
41 #include "core/css/CSSPrimitiveValue.h"
38 #include "core/platform/Length.h" 42 #include "core/platform/Length.h"
43 #include "core/platform/LengthBox.h"
39 #include "core/rendering/style/RenderStyle.h" 44 #include "core/rendering/style/RenderStyle.h"
40 45
41 46
42 namespace WebCore { 47 namespace WebCore {
43 48
44 // FIXME: Handle remaining animatable properties (pulled from CSSPropertyAnimati on):
45 // CSSPropertyBackgroundColor
46 // CSSPropertyBackgroundImage
47 // CSSPropertyBackgroundPositionX
48 // CSSPropertyBackgroundPositionY
49 // CSSPropertyBackgroundSize
50 // CSSPropertyBaselineShift
51 // CSSPropertyBorderBottomColor
52 // CSSPropertyBorderBottomLeftRadius
53 // CSSPropertyBorderBottomRightRadius
54 // CSSPropertyBorderImageOutset
55 // CSSPropertyBorderImageSlice
56 // CSSPropertyBorderImageSource
57 // CSSPropertyBorderImageWidth
58 // CSSPropertyBorderLeftColor
59 // CSSPropertyBorderRightColor
60 // CSSPropertyBorderTopColor
61 // CSSPropertyBorderTopLeftRadius
62 // CSSPropertyBorderTopRightRadius
63 // CSSPropertyBoxShadow
64 // CSSPropertyClip
65 // CSSPropertyColor
66 // CSSPropertyFill
67 // CSSPropertyFillOpacity
68 // CSSPropertyFloodColor
69 // CSSPropertyFloodOpacity
70 // CSSPropertyFontSize
71 // CSSPropertyKerning
72 // CSSPropertyLetterSpacing
73 // CSSPropertyLightingColor
74 // CSSPropertyLineHeight
75 // CSSPropertyListStyleImage
76 // CSSPropertyOpacity
77 // CSSPropertyOrphans
78 // CSSPropertyOutlineColor
79 // CSSPropertyOutlineOffset
80 // CSSPropertyOutlineWidth
81 // CSSPropertyStopColor
82 // CSSPropertyStopOpacity
83 // CSSPropertyStroke
84 // CSSPropertyStrokeDashoffset
85 // CSSPropertyStrokeMiterlimit
86 // CSSPropertyStrokeOpacity
87 // CSSPropertyStrokeWidth
88 // CSSPropertyTextIndent
89 // CSSPropertyTextShadow
90 // CSSPropertyVisibility
91 // CSSPropertyWebkitBackgroundSize
92 // CSSPropertyWebkitBorderHorizontalSpacing
93 // CSSPropertyWebkitBorderVerticalSpacing
94 // CSSPropertyWebkitBoxShadow
95 // CSSPropertyWebkitClipPath
96 // CSSPropertyWebkitColumnCount
97 // CSSPropertyWebkitColumnGap
98 // CSSPropertyWebkitColumnRuleColor
99 // CSSPropertyWebkitColumnRuleWidth
100 // CSSPropertyWebkitColumnWidth
101 // CSSPropertyWebkitFilter
102 // CSSPropertyWebkitMaskBoxImage
103 // CSSPropertyWebkitMaskBoxImageSource
104 // CSSPropertyWebkitMaskImage
105 // CSSPropertyWebkitMaskPositionX
106 // CSSPropertyWebkitMaskPositionY
107 // CSSPropertyWebkitMaskSize
108 // CSSPropertyWebkitPerspective
109 // CSSPropertyWebkitShapeInside
110 // CSSPropertyWebkitTextFillColor
111 // CSSPropertyWebkitTextStrokeColor
112 // CSSPropertyWebkitTransformOriginZ
113 // CSSPropertyWidows
114 // CSSPropertyWordSpacing
115 // CSSPropertyZIndex
116 // CSSPropertyZoom
117
118 static PassRefPtr<AnimatableValue> createFromLength(const Length& length, const RenderStyle* style) 49 static PassRefPtr<AnimatableValue> createFromLength(const Length& length, const RenderStyle* style)
119 { 50 {
120 switch (length.type()) { 51 switch (length.type()) {
121 case Relative: 52 case Relative:
122 return AnimatableNumber::create(length.value(), AnimatableNumber::UnitTy peNumber); 53 return AnimatableNumber::create(length.value(), AnimatableNumber::UnitTy peNumber);
123 case Fixed: 54 case Fixed:
124 return AnimatableNumber::create(adjustFloatForAbsoluteZoom(length.value( ), style), AnimatableNumber::UnitTypeLength); 55 return AnimatableNumber::create(adjustFloatForAbsoluteZoom(length.value( ), style), AnimatableNumber::UnitTypeLength);
125 case Percent: 56 case Percent:
126 return AnimatableNumber::create(length.value(), AnimatableNumber::UnitTy pePercentage); 57 return AnimatableNumber::create(length.value(), AnimatableNumber::UnitTy pePercentage);
127 case ViewportPercentageWidth: 58 case ViewportPercentageWidth:
(...skipping 24 matching lines...) Expand all
152 } 83 }
153 ASSERT_NOT_REACHED(); 84 ASSERT_NOT_REACHED();
154 return 0; 85 return 0;
155 } 86 }
156 87
157 inline static PassRefPtr<AnimatableValue> createFromDouble(double value) 88 inline static PassRefPtr<AnimatableValue> createFromDouble(double value)
158 { 89 {
159 return AnimatableNumber::create(value, AnimatableNumber::UnitTypeNumber); 90 return AnimatableNumber::create(value, AnimatableNumber::UnitTypeNumber);
160 } 91 }
161 92
93 inline static PassRefPtr<AnimatableValue> createFromLengthBox(const LengthBox le ngthBox, const RenderStyle* style)
94 {
95 return AnimatableLengthBox::create(
96 createFromLength(lengthBox.left(), style),
97 createFromLength(lengthBox.right(), style),
98 createFromLength(lengthBox.top(), style),
99 createFromLength(lengthBox.bottom(), style));
100 }
101
162 // FIXME: Generate this function. 102 // FIXME: Generate this function.
163 PassRefPtr<AnimatableValue> CSSAnimatableValueFactory::create(CSSPropertyID prop erty, const RenderStyle* style) 103 PassRefPtr<AnimatableValue> CSSAnimatableValueFactory::create(CSSPropertyID prop erty, const RenderStyle* style)
164 { 104 {
165 switch (property) { 105 switch (property) {
166 case CSSPropertyBorderBottomWidth: 106 case CSSPropertyBorderBottomWidth:
167 return createFromDouble(style->borderBottomWidth()); 107 return createFromDouble(style->borderBottomWidth());
108 case CSSPropertyBorderImageOutset:
109 return createFromLengthBox(style->borderImageOutset(), style);
110 case CSSPropertyBorderImageSlice:
111 return createFromLengthBox(style->borderImageSlices(), style);
112 case CSSPropertyBorderImageSource:
113 return AnimatableImage::create(style->borderImageSource());
114 case CSSPropertyBorderImageWidth:
115 return createFromLengthBox(style->borderImageWidth(), style);
168 case CSSPropertyBorderLeftWidth: 116 case CSSPropertyBorderLeftWidth:
169 return createFromDouble(style->borderLeftWidth()); 117 return createFromDouble(style->borderLeftWidth());
170 case CSSPropertyBorderRightWidth: 118 case CSSPropertyBorderRightWidth:
171 return createFromDouble(style->borderRightWidth()); 119 return createFromDouble(style->borderRightWidth());
172 case CSSPropertyBorderTopWidth: 120 case CSSPropertyBorderTopWidth:
173 return createFromDouble(style->borderTopWidth()); 121 return createFromDouble(style->borderTopWidth());
174 case CSSPropertyBottom: 122 case CSSPropertyBottom:
175 return createFromLength(style->bottom(), style); 123 return createFromLength(style->bottom(), style);
124 case CSSPropertyClip:
125 return createFromLengthBox(style->clip(), style);
176 case CSSPropertyHeight: 126 case CSSPropertyHeight:
177 return createFromLength(style->height(), style); 127 return createFromLength(style->height(), style);
128 case CSSPropertyListStyleImage:
129 return AnimatableImage::create(style->listStyleImage());
178 case CSSPropertyLeft: 130 case CSSPropertyLeft:
179 return createFromLength(style->left(), style); 131 return createFromLength(style->left(), style);
180 case CSSPropertyMarginBottom: 132 case CSSPropertyMarginBottom:
181 return createFromLength(style->marginBottom(), style); 133 return createFromLength(style->marginBottom(), style);
182 case CSSPropertyMarginLeft: 134 case CSSPropertyMarginLeft:
183 return createFromLength(style->marginLeft(), style); 135 return createFromLength(style->marginLeft(), style);
184 case CSSPropertyMarginRight: 136 case CSSPropertyMarginRight:
185 return createFromLength(style->marginRight(), style); 137 return createFromLength(style->marginRight(), style);
186 case CSSPropertyMarginTop: 138 case CSSPropertyMarginTop:
187 return createFromLength(style->marginTop(), style); 139 return createFromLength(style->marginTop(), style);
(...skipping 12 matching lines...) Expand all
200 case CSSPropertyPaddingLeft: 152 case CSSPropertyPaddingLeft:
201 return createFromLength(style->paddingLeft(), style); 153 return createFromLength(style->paddingLeft(), style);
202 case CSSPropertyPaddingRight: 154 case CSSPropertyPaddingRight:
203 return createFromLength(style->paddingRight(), style); 155 return createFromLength(style->paddingRight(), style);
204 case CSSPropertyPaddingTop: 156 case CSSPropertyPaddingTop:
205 return createFromLength(style->paddingTop(), style); 157 return createFromLength(style->paddingTop(), style);
206 case CSSPropertyRight: 158 case CSSPropertyRight:
207 return createFromLength(style->right(), style); 159 return createFromLength(style->right(), style);
208 case CSSPropertyTop: 160 case CSSPropertyTop:
209 return createFromLength(style->top(), style); 161 return createFromLength(style->top(), style);
162 case CSSPropertyWebkitMaskBoxImageSource:
163 return AnimatableImage::create(style->maskBoxImageSource());
164 case CSSPropertyWebkitMaskImage:
165 return AnimatableImage::create(style->maskImage());
210 case CSSPropertyWebkitPerspectiveOriginX: 166 case CSSPropertyWebkitPerspectiveOriginX:
211 return createFromLength(style->perspectiveOriginX(), style); 167 return createFromLength(style->perspectiveOriginX(), style);
212 case CSSPropertyWebkitPerspectiveOriginY: 168 case CSSPropertyWebkitPerspectiveOriginY:
213 return createFromLength(style->perspectiveOriginY(), style); 169 return createFromLength(style->perspectiveOriginY(), style);
214 case CSSPropertyWebkitTransform: 170 case CSSPropertyWebkitTransform:
215 return AnimatableTransform::create(style->transform()); 171 return AnimatableTransform::create(style->transform());
216 case CSSPropertyWebkitTransformOriginX: 172 case CSSPropertyWebkitTransformOriginX:
217 return createFromLength(style->transformOriginX(), style); 173 return createFromLength(style->transformOriginX(), style);
218 case CSSPropertyWebkitTransformOriginY: 174 case CSSPropertyWebkitTransformOriginY:
219 return createFromLength(style->transformOriginY(), style); 175 return createFromLength(style->transformOriginY(), style);
220 case CSSPropertyWidth: 176 case CSSPropertyWidth:
221 return createFromLength(style->width(), style); 177 return createFromLength(style->width(), style);
222 default: 178 default:
223 RELEASE_ASSERT_WITH_MESSAGE(false, "Web Animations not yet implemented: Create AnimatableValue from render style"); 179 RELEASE_ASSERT_WITH_MESSAGE(!CSSAnimations::isAnimatableProperty(propert y), "Web Animations not yet implemented: Create AnimatableValue from render styl e: %s", getPropertyNameString(property).utf8().data());
180 ASSERT_NOT_REACHED();
224 return 0; 181 return 0;
225 } 182 }
226 } 183 }
227 184
228 } // namespace WebCore 185 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/animation/AnimatableValue.h ('k') | Source/core/animation/css/CSSAnimations.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698