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

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

Issue 25082007: Web Animations CSS: Split AnimatableNumber into AnimatableDouble and AnimatableLength (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased onto virtual enum change Created 7 years, 2 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 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/css/resolver/AnimatedStyleBuilder.h" 32 #include "core/css/resolver/AnimatedStyleBuilder.h"
33 33
34 #include "core/animation/AnimatableColor.h" 34 #include "core/animation/AnimatableColor.h"
35 #include "core/animation/AnimatableDouble.h"
35 #include "core/animation/AnimatableImage.h" 36 #include "core/animation/AnimatableImage.h"
37 #include "core/animation/AnimatableLength.h"
36 #include "core/animation/AnimatableLengthBox.h" 38 #include "core/animation/AnimatableLengthBox.h"
37 #include "core/animation/AnimatableLengthSize.h" 39 #include "core/animation/AnimatableLengthSize.h"
38 #include "core/animation/AnimatableNumber.h"
39 #include "core/animation/AnimatableTransform.h" 40 #include "core/animation/AnimatableTransform.h"
40 #include "core/animation/AnimatableUnknown.h" 41 #include "core/animation/AnimatableUnknown.h"
41 #include "core/animation/AnimatableValue.h" 42 #include "core/animation/AnimatableValue.h"
42 #include "core/animation/AnimatableVisibility.h" 43 #include "core/animation/AnimatableVisibility.h"
43 #include "core/animation/css/CSSAnimations.h" 44 #include "core/animation/css/CSSAnimations.h"
44 #include "core/css/CSSPrimitiveValueMappings.h" 45 #include "core/css/CSSPrimitiveValueMappings.h"
45 #include "core/css/resolver/StyleBuilder.h" 46 #include "core/css/resolver/StyleBuilder.h"
46 #include "core/css/resolver/StyleResolverState.h" 47 #include "core/css/resolver/StyleResolverState.h"
47 #include "core/rendering/style/RenderStyle.h" 48 #include "core/rendering/style/RenderStyle.h"
48 #include "wtf/MathExtras.h" 49 #include "wtf/MathExtras.h"
49 #include "wtf/TypeTraits.h" 50 #include "wtf/TypeTraits.h"
50 51
51 namespace WebCore { 52 namespace WebCore {
52 53
53 namespace { 54 namespace {
54 55
55 Length animatableValueToLength(const AnimatableValue* value, const StyleResolver State& state, NumberRange range = AllValues) 56 Length animatableValueToLength(const AnimatableValue* value, const StyleResolver State& state, NumberRange range = AllValues)
56 { 57 {
57 const RenderStyle* style = state.style(); 58 const RenderStyle* style = state.style();
58 if (value->isNumber()) 59 if (value->isLength())
59 return toAnimatableNumber(value)->toLength(style, state.rootElementStyle (), style->effectiveZoom(), range); 60 return toAnimatableLength(value)->toLength(style, state.rootElementStyle (), style->effectiveZoom(), range);
60 RefPtr<CSSValue> cssValue = toAnimatableUnknown(value)->toCSSValue(); 61 RefPtr<CSSValue> cssValue = toAnimatableUnknown(value)->toCSSValue();
61 CSSPrimitiveValue* cssPrimitiveValue = toCSSPrimitiveValue(cssValue.get()); 62 CSSPrimitiveValue* cssPrimitiveValue = toCSSPrimitiveValue(cssValue.get());
62 return cssPrimitiveValue->convertToLength<AnyConversion>(style, state.rootEl ementStyle(), style->effectiveZoom()); 63 return cssPrimitiveValue->convertToLength<AnyConversion>(style, state.rootEl ementStyle(), style->effectiveZoom());
63 } 64 }
64 65
65 template<typename T> T animatableValueRoundClampTo(const AnimatableValue* value) 66 template<typename T> T animatableValueRoundClampTo(const AnimatableValue* value)
66 { 67 {
67 COMPILE_ASSERT(WTF::IsInteger<T>::value, ShouldUseIntegralTypeTWhenRoundingV alues); 68 COMPILE_ASSERT(WTF::IsInteger<T>::value, ShouldUseIntegralTypeTWhenRoundingV alues);
68 return clampTo<T>(round(toAnimatableNumber(value)->toDouble())); 69 return clampTo<T>(round(toAnimatableDouble(value)->toDouble()));
69 } 70 }
70 71
71 LengthBox animatableValueToLengthBox(const AnimatableValue* value, const StyleRe solverState& state) 72 LengthBox animatableValueToLengthBox(const AnimatableValue* value, const StyleRe solverState& state)
72 { 73 {
73 const AnimatableLengthBox* animatableLengthBox = toAnimatableLengthBox(value ); 74 const AnimatableLengthBox* animatableLengthBox = toAnimatableLengthBox(value );
74 return LengthBox( 75 return LengthBox(
75 animatableValueToLength(animatableLengthBox->top(), state), 76 animatableValueToLength(animatableLengthBox->top(), state),
76 animatableValueToLength(animatableLengthBox->right(), state), 77 animatableValueToLength(animatableLengthBox->right(), state),
77 animatableValueToLength(animatableLengthBox->bottom(), state), 78 animatableValueToLength(animatableLengthBox->bottom(), state),
78 animatableValueToLength(animatableLengthBox->left(), state)); 79 animatableValueToLength(animatableLengthBox->left(), state));
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 case CSSPropertyMaxWidth: 191 case CSSPropertyMaxWidth:
191 style->setMaxWidth(animatableValueToLength(value, state)); 192 style->setMaxWidth(animatableValueToLength(value, state));
192 return; 193 return;
193 case CSSPropertyMinHeight: 194 case CSSPropertyMinHeight:
194 style->setMinHeight(animatableValueToLength(value, state)); 195 style->setMinHeight(animatableValueToLength(value, state));
195 return; 196 return;
196 case CSSPropertyMinWidth: 197 case CSSPropertyMinWidth:
197 style->setMinWidth(animatableValueToLength(value, state)); 198 style->setMinWidth(animatableValueToLength(value, state));
198 return; 199 return;
199 case CSSPropertyOpacity: 200 case CSSPropertyOpacity:
200 style->setOpacity(toAnimatableNumber(value)->toDouble()); 201 style->setOpacity(toAnimatableDouble(value)->toDouble());
201 return; 202 return;
202 case CSSPropertyOutlineColor: 203 case CSSPropertyOutlineColor:
203 style->setOutlineColor(toAnimatableColor(value)->color()); 204 style->setOutlineColor(toAnimatableColor(value)->color());
204 style->setVisitedLinkOutlineColor(toAnimatableColor(value)->visitedLinkC olor()); 205 style->setVisitedLinkOutlineColor(toAnimatableColor(value)->visitedLinkC olor());
205 return; 206 return;
206 case CSSPropertyOutlineOffset: 207 case CSSPropertyOutlineOffset:
207 style->setOutlineOffset(animatableValueRoundClampTo<int>(value)); 208 style->setOutlineOffset(animatableValueRoundClampTo<int>(value));
208 return; 209 return;
209 case CSSPropertyOutlineWidth: 210 case CSSPropertyOutlineWidth:
210 style->setOutlineWidth(animatableValueRoundClampTo<unsigned short>(value )); 211 style->setOutlineWidth(animatableValueRoundClampTo<unsigned short>(value ));
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 case CSSPropertyWebkitTransform: 275 case CSSPropertyWebkitTransform:
275 style->setTransform(toAnimatableTransform(value)->transformOperations()) ; 276 style->setTransform(toAnimatableTransform(value)->transformOperations()) ;
276 return; 277 return;
277 case CSSPropertyWebkitTransformOriginX: 278 case CSSPropertyWebkitTransformOriginX:
278 style->setTransformOriginX(animatableValueToLength(value, state)); 279 style->setTransformOriginX(animatableValueToLength(value, state));
279 return; 280 return;
280 case CSSPropertyWebkitTransformOriginY: 281 case CSSPropertyWebkitTransformOriginY:
281 style->setTransformOriginY(animatableValueToLength(value, state)); 282 style->setTransformOriginY(animatableValueToLength(value, state));
282 return; 283 return;
283 case CSSPropertyWebkitTransformOriginZ: 284 case CSSPropertyWebkitTransformOriginZ:
284 style->setTransformOriginZ(toAnimatableNumber(value)->toDouble()); 285 style->setTransformOriginZ(toAnimatableDouble(value)->toDouble());
285 return; 286 return;
286 case CSSPropertyWidth: 287 case CSSPropertyWidth:
287 style->setWidth(animatableValueToLength(value, state)); 288 style->setWidth(animatableValueToLength(value, state));
288 return; 289 return;
289 case CSSPropertyWordSpacing: 290 case CSSPropertyWordSpacing:
290 style->setWordSpacing(clampTo<float>(toAnimatableNumber(value)->toDouble ())); 291 style->setWordSpacing(clampTo<float>(toAnimatableDouble(value)->toDouble ()));
291 return; 292 return;
292 case CSSPropertyVisibility: 293 case CSSPropertyVisibility:
293 style->setVisibility(toAnimatableVisibility(value)->visibility()); 294 style->setVisibility(toAnimatableVisibility(value)->visibility());
294 return; 295 return;
295 case CSSPropertyZIndex: 296 case CSSPropertyZIndex:
296 style->setZIndex(animatableValueRoundClampTo<int>(value)); 297 style->setZIndex(animatableValueRoundClampTo<int>(value));
297 return; 298 return;
298 default: 299 default:
299 RELEASE_ASSERT_WITH_MESSAGE(!CSSAnimations::isAnimatableProperty(propert y), "Web Animations not yet implemented: Unable to apply AnimatableValue to Rend erStyle: %s", getPropertyNameString(property).utf8().data()); 300 RELEASE_ASSERT_WITH_MESSAGE(!CSSAnimations::isAnimatableProperty(propert y), "Web Animations not yet implemented: Unable to apply AnimatableValue to Rend erStyle: %s", getPropertyNameString(property).utf8().data());
300 ASSERT_NOT_REACHED(); 301 ASSERT_NOT_REACHED();
301 } 302 }
302 } 303 }
303 304
304 } // namespace WebCore 305 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698