Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / css / resolver / AnimatedStyleBuilder.cpp
1 /*
2  * Copyright (C) 2013 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *     * Neither the name of Google Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
29  */
30
31 #include "config.h"
32 #include "core/css/resolver/AnimatedStyleBuilder.h"
33
34 #include "core/animation/AnimatableClipPathOperation.h"
35 #include "core/animation/AnimatableColor.h"
36 #include "core/animation/AnimatableDouble.h"
37 #include "core/animation/AnimatableFilterOperations.h"
38 #include "core/animation/AnimatableImage.h"
39 #include "core/animation/AnimatableLength.h"
40 #include "core/animation/AnimatableLengthBox.h"
41 #include "core/animation/AnimatableLengthBoxAndBool.h"
42 #include "core/animation/AnimatableLengthPoint.h"
43 #include "core/animation/AnimatableLengthPoint3D.h"
44 #include "core/animation/AnimatableLengthSize.h"
45 #include "core/animation/AnimatableRepeatable.h"
46 #include "core/animation/AnimatableSVGLength.h"
47 #include "core/animation/AnimatableSVGPaint.h"
48 #include "core/animation/AnimatableShadow.h"
49 #include "core/animation/AnimatableShapeValue.h"
50 #include "core/animation/AnimatableStrokeDasharrayList.h"
51 #include "core/animation/AnimatableTransform.h"
52 #include "core/animation/AnimatableUnknown.h"
53 #include "core/animation/AnimatableValue.h"
54 #include "core/animation/AnimatableVisibility.h"
55 #include "core/animation/css/CSSAnimations.h"
56 #include "core/css/CSSPrimitiveValueMappings.h"
57 #include "core/css/resolver/StyleBuilder.h"
58 #include "core/css/resolver/StyleResolverState.h"
59 #include "core/rendering/style/RenderStyle.h"
60 #include "wtf/MathExtras.h"
61 #include "wtf/TypeTraits.h"
62
63 namespace WebCore {
64
65 namespace {
66
67 Length animatableValueToLength(const AnimatableValue* value, const StyleResolverState& state, ValueRange range = ValueRangeAll)
68 {
69     if (value->isLength())
70         return toAnimatableLength(value)->length(state.style()->effectiveZoom(), range);
71     RefPtrWillBeRawPtr<CSSValue> cssValue = toAnimatableUnknown(value)->toCSSValue();
72     CSSPrimitiveValue* cssPrimitiveValue = toCSSPrimitiveValue(cssValue.get());
73     return cssPrimitiveValue->convertToLength<AnyConversion>(state.cssToLengthConversionData());
74 }
75
76 BorderImageLength animatableValueToBorderImageLength(const AnimatableValue* value, const StyleResolverState& state)
77 {
78     if (value->isLength())
79         return BorderImageLength(toAnimatableLength(value)->length(state.style()->effectiveZoom(), ValueRangeNonNegative));
80     if (value->isDouble())
81         return BorderImageLength(clampTo<double>(toAnimatableDouble(value)->toDouble(), 0));
82     RefPtrWillBeRawPtr<CSSValue> cssValue = toAnimatableUnknown(value)->toCSSValue();
83     CSSPrimitiveValue* cssPrimitiveValue = toCSSPrimitiveValue(cssValue.get());
84     return BorderImageLength(cssPrimitiveValue->convertToLength<AnyConversion>(state.cssToLengthConversionData()));
85 }
86
87 template<typename T> T animatableValueRoundClampTo(const AnimatableValue* value, T min = defaultMinimumForClamp<T>(), T max = defaultMaximumForClamp<T>())
88 {
89     COMPILE_ASSERT(WTF::IsInteger<T>::value, ShouldUseIntegralTypeTWhenRoundingValues);
90     return clampTo<T>(round(toAnimatableDouble(value)->toDouble()), min, max);
91 }
92
93 LengthBox animatableValueToLengthBox(const AnimatableValue* value, const StyleResolverState& state, ValueRange range = ValueRangeAll)
94 {
95     const AnimatableLengthBox* animatableLengthBox = toAnimatableLengthBox(value);
96     return LengthBox(
97         animatableValueToLength(animatableLengthBox->top(), state, range),
98         animatableValueToLength(animatableLengthBox->right(), state, range),
99         animatableValueToLength(animatableLengthBox->bottom(), state, range),
100         animatableValueToLength(animatableLengthBox->left(), state, range));
101 }
102
103 BorderImageLengthBox animatableValueToBorderImageLengthBox(const AnimatableValue* value, const StyleResolverState& state)
104 {
105     const AnimatableLengthBox* animatableLengthBox = toAnimatableLengthBox(value);
106     return BorderImageLengthBox(
107         animatableValueToBorderImageLength(animatableLengthBox->top(), state),
108         animatableValueToBorderImageLength(animatableLengthBox->right(), state),
109         animatableValueToBorderImageLength(animatableLengthBox->bottom(), state),
110         animatableValueToBorderImageLength(animatableLengthBox->left(), state));
111 }
112
113 LengthPoint animatableValueToLengthPoint(const AnimatableValue* value, const StyleResolverState& state, ValueRange range = ValueRangeAll)
114 {
115     const AnimatableLengthPoint* animatableLengthPoint = toAnimatableLengthPoint(value);
116     return LengthPoint(
117         animatableValueToLength(animatableLengthPoint->x(), state, range),
118         animatableValueToLength(animatableLengthPoint->y(), state, range));
119 }
120
121 LengthSize animatableValueToLengthSize(const AnimatableValue* value, const StyleResolverState& state, ValueRange range)
122 {
123     const AnimatableLengthSize* animatableLengthSize = toAnimatableLengthSize(value);
124     return LengthSize(
125         animatableValueToLength(animatableLengthSize->width(), state, range),
126         animatableValueToLength(animatableLengthSize->height(), state, range));
127 }
128
129 template <CSSPropertyID property>
130 void setFillSize(FillLayer* fillLayer, const AnimatableValue* value, const StyleResolverState& state)
131 {
132     if (value->isLengthSize())
133         fillLayer->setSize(FillSize(SizeLength, animatableValueToLengthSize(value, state, ValueRangeNonNegative)));
134     else
135         state.styleMap().mapFillSize(property, fillLayer, toAnimatableUnknown(value)->toCSSValue().get());
136 }
137
138 PassRefPtr<SVGLength> animatableValueToNonNegativeSVGLength(const AnimatableValue* value)
139 {
140     RefPtr<SVGLength> length = toAnimatableSVGLength(value)->toSVGLength();
141     if (length->valueInSpecifiedUnits() < 0)
142         length->setValueInSpecifiedUnits(0);
143     return length.release();
144 }
145
146 template <CSSPropertyID property>
147 void setOnFillLayers(FillLayer* fillLayer, const AnimatableValue* value, StyleResolverState& state)
148 {
149     const WillBeHeapVector<RefPtrWillBeMember<AnimatableValue> >& values = toAnimatableRepeatable(value)->values();
150     ASSERT(!values.isEmpty());
151     FillLayer* prev = 0;
152     for (size_t i = 0; i < values.size(); ++i) {
153         if (!fillLayer) {
154             switch (property) {
155             case CSSPropertyBackgroundImage:
156             case CSSPropertyBackgroundPositionX:
157             case CSSPropertyBackgroundPositionY:
158             case CSSPropertyBackgroundSize:
159             case CSSPropertyWebkitBackgroundSize:
160                 fillLayer = new FillLayer(BackgroundFillLayer);
161                 break;
162             case CSSPropertyWebkitMaskImage:
163             case CSSPropertyWebkitMaskPositionX:
164             case CSSPropertyWebkitMaskPositionY:
165             case CSSPropertyWebkitMaskSize:
166                 fillLayer = new FillLayer(MaskFillLayer);
167                 break;
168             default:
169                 ASSERT_NOT_REACHED();
170             }
171             prev->setNext(fillLayer);
172         }
173         const AnimatableValue* layerValue = values[i].get();
174         switch (property) {
175         case CSSPropertyBackgroundImage:
176         case CSSPropertyWebkitMaskImage:
177             if (layerValue->isImage()) {
178                 fillLayer->setImage(state.styleImage(property, toAnimatableImage(layerValue)->toCSSValue()));
179             } else {
180                 ASSERT(toAnimatableUnknown(layerValue)->toCSSValueID() == CSSValueNone);
181                 fillLayer->setImage(nullptr);
182             }
183             break;
184         case CSSPropertyBackgroundPositionX:
185         case CSSPropertyWebkitMaskPositionX:
186             fillLayer->setXPosition(animatableValueToLength(layerValue, state));
187             break;
188         case CSSPropertyBackgroundPositionY:
189         case CSSPropertyWebkitMaskPositionY:
190             fillLayer->setYPosition(animatableValueToLength(layerValue, state));
191             break;
192         case CSSPropertyBackgroundSize:
193         case CSSPropertyWebkitBackgroundSize:
194         case CSSPropertyWebkitMaskSize:
195             setFillSize<property>(fillLayer, layerValue, state);
196             break;
197         default:
198             ASSERT_NOT_REACHED();
199         }
200         prev = fillLayer;
201         fillLayer = fillLayer->next();
202     }
203     while (fillLayer) {
204         switch (property) {
205         case CSSPropertyBackgroundImage:
206         case CSSPropertyWebkitMaskImage:
207             fillLayer->clearImage();
208             break;
209         case CSSPropertyBackgroundPositionX:
210         case CSSPropertyWebkitMaskPositionX:
211             fillLayer->clearXPosition();
212             break;
213         case CSSPropertyBackgroundPositionY:
214         case CSSPropertyWebkitMaskPositionY:
215             fillLayer->clearYPosition();
216             break;
217         case CSSPropertyBackgroundSize:
218         case CSSPropertyWebkitBackgroundSize:
219         case CSSPropertyWebkitMaskSize:
220             fillLayer->clearSize();
221             break;
222         default:
223             ASSERT_NOT_REACHED();
224         }
225         fillLayer = fillLayer->next();
226     }
227 }
228
229 FontWeight animatableValueToFontWeight(const AnimatableValue* value)
230 {
231     int index = round(toAnimatableDouble(value)->toDouble() / 100) - 1;
232
233     static const FontWeight weights[] = {
234         FontWeight100,
235         FontWeight200,
236         FontWeight300,
237         FontWeight400,
238         FontWeight500,
239         FontWeight600,
240         FontWeight700,
241         FontWeight800,
242         FontWeight900
243     };
244
245     index = clampTo<int>(index, 0, WTF_ARRAY_LENGTH(weights) - 1);
246
247     return weights[index];
248 }
249
250 } // namespace
251
252 // FIXME: Generate this function.
253 void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, StyleResolverState& state, const AnimatableValue* value)
254 {
255     ASSERT(CSSAnimations::isAnimatableProperty(property));
256     if (value->isUnknown()) {
257         StyleBuilder::applyProperty(property, state, toAnimatableUnknown(value)->toCSSValue().get());
258         return;
259     }
260     RenderStyle* style = state.style();
261     switch (property) {
262     case CSSPropertyBackgroundColor:
263         style->setBackgroundColor(toAnimatableColor(value)->color());
264         style->setVisitedLinkBackgroundColor(toAnimatableColor(value)->visitedLinkColor());
265         return;
266     case CSSPropertyBackgroundImage:
267         setOnFillLayers<CSSPropertyBackgroundImage>(style->accessBackgroundLayers(), value, state);
268         return;
269     case CSSPropertyBackgroundPositionX:
270         setOnFillLayers<CSSPropertyBackgroundPositionX>(style->accessBackgroundLayers(), value, state);
271         return;
272     case CSSPropertyBackgroundPositionY:
273         setOnFillLayers<CSSPropertyBackgroundPositionY>(style->accessBackgroundLayers(), value, state);
274         return;
275     case CSSPropertyBackgroundSize:
276         setOnFillLayers<CSSPropertyBackgroundSize>(style->accessBackgroundLayers(), value, state);
277         return;
278     case CSSPropertyBaselineShift:
279         style->setBaselineShiftValue(toAnimatableSVGLength(value)->toSVGLength());
280         return;
281     case CSSPropertyBorderBottomColor:
282         style->setBorderBottomColor(toAnimatableColor(value)->color());
283         style->setVisitedLinkBorderBottomColor(toAnimatableColor(value)->visitedLinkColor());
284         return;
285     case CSSPropertyBorderBottomLeftRadius:
286         style->setBorderBottomLeftRadius(animatableValueToLengthSize(value, state, ValueRangeNonNegative));
287         return;
288     case CSSPropertyBorderBottomRightRadius:
289         style->setBorderBottomRightRadius(animatableValueToLengthSize(value, state, ValueRangeNonNegative));
290         return;
291     case CSSPropertyBorderBottomWidth:
292         style->setBorderBottomWidth(animatableValueRoundClampTo<unsigned>(value));
293         return;
294     case CSSPropertyBorderImageOutset:
295         style->setBorderImageOutset(animatableValueToBorderImageLengthBox(value, state));
296         return;
297     case CSSPropertyBorderImageSlice:
298         style->setBorderImageSlices(animatableValueToLengthBox(value, state, ValueRangeNonNegative));
299         return;
300     case CSSPropertyBorderImageSource:
301         style->setBorderImageSource(state.styleImage(property, toAnimatableImage(value)->toCSSValue()));
302         return;
303     case CSSPropertyBorderImageWidth:
304         style->setBorderImageWidth(animatableValueToBorderImageLengthBox(value, state));
305         return;
306     case CSSPropertyBorderLeftColor:
307         style->setBorderLeftColor(toAnimatableColor(value)->color());
308         style->setVisitedLinkBorderLeftColor(toAnimatableColor(value)->visitedLinkColor());
309         return;
310     case CSSPropertyBorderLeftWidth:
311         style->setBorderLeftWidth(animatableValueRoundClampTo<unsigned>(value));
312         return;
313     case CSSPropertyBorderRightColor:
314         style->setBorderRightColor(toAnimatableColor(value)->color());
315         style->setVisitedLinkBorderRightColor(toAnimatableColor(value)->visitedLinkColor());
316         return;
317     case CSSPropertyBorderRightWidth:
318         style->setBorderRightWidth(animatableValueRoundClampTo<unsigned>(value));
319         return;
320     case CSSPropertyBorderTopColor:
321         style->setBorderTopColor(toAnimatableColor(value)->color());
322         style->setVisitedLinkBorderTopColor(toAnimatableColor(value)->visitedLinkColor());
323         return;
324     case CSSPropertyBorderTopLeftRadius:
325         style->setBorderTopLeftRadius(animatableValueToLengthSize(value, state, ValueRangeNonNegative));
326         return;
327     case CSSPropertyBorderTopRightRadius:
328         style->setBorderTopRightRadius(animatableValueToLengthSize(value, state, ValueRangeNonNegative));
329         return;
330     case CSSPropertyBorderTopWidth:
331         style->setBorderTopWidth(animatableValueRoundClampTo<unsigned>(value));
332         return;
333     case CSSPropertyBottom:
334         style->setBottom(animatableValueToLength(value, state));
335         return;
336     case CSSPropertyBoxShadow:
337     case CSSPropertyWebkitBoxShadow:
338         style->setBoxShadow(toAnimatableShadow(value)->shadowList());
339         return;
340     case CSSPropertyClip:
341         style->setClip(animatableValueToLengthBox(value, state));
342         style->setHasClip(true);
343         return;
344     case CSSPropertyColor:
345         style->setColor(toAnimatableColor(value)->color());
346         style->setVisitedLinkColor(toAnimatableColor(value)->visitedLinkColor());
347         return;
348     case CSSPropertyFillOpacity:
349         style->setFillOpacity(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0, 1));
350         return;
351     case CSSPropertyFill:
352         {
353             const AnimatableSVGPaint* svgPaint = toAnimatableSVGPaint(value);
354             style->accessSVGStyle()->setFillPaint(svgPaint->paintType(), svgPaint->color(), svgPaint->uri());
355         }
356         return;
357     case CSSPropertyFlexGrow:
358         style->setFlexGrow(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0));
359         return;
360     case CSSPropertyFlexShrink:
361         style->setFlexShrink(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0));
362         return;
363     case CSSPropertyFlexBasis:
364         style->setFlexBasis(animatableValueToLength(value, state, ValueRangeNonNegative));
365         return;
366     case CSSPropertyFloodColor:
367         style->setFloodColor(toAnimatableColor(value)->color());
368         return;
369     case CSSPropertyFloodOpacity:
370         style->setFloodOpacity(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0, 1));
371         return;
372     case CSSPropertyFontSize:
373         style->setFontSize(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0));
374         return;
375     case CSSPropertyFontWeight:
376         style->setFontWeight(animatableValueToFontWeight(value));
377         return;
378     case CSSPropertyHeight:
379         style->setHeight(animatableValueToLength(value, state, ValueRangeNonNegative));
380         return;
381     case CSSPropertyLeft:
382         style->setLeft(animatableValueToLength(value, state));
383         return;
384     case CSSPropertyLightingColor:
385         style->setLightingColor(toAnimatableColor(value)->color());
386         return;
387     case CSSPropertyLineHeight:
388         if (value->isLength())
389             style->setLineHeight(animatableValueToLength(value, state, ValueRangeNonNegative));
390         else
391             style->setLineHeight(Length(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0), Percent));
392         return;
393     case CSSPropertyListStyleImage:
394         style->setListStyleImage(state.styleImage(property, toAnimatableImage(value)->toCSSValue()));
395         return;
396     case CSSPropertyLetterSpacing:
397         style->setLetterSpacing(clampTo<float>(toAnimatableDouble(value)->toDouble()));
398         return;
399     case CSSPropertyMarginBottom:
400         style->setMarginBottom(animatableValueToLength(value, state));
401         return;
402     case CSSPropertyMarginLeft:
403         style->setMarginLeft(animatableValueToLength(value, state));
404         return;
405     case CSSPropertyMarginRight:
406         style->setMarginRight(animatableValueToLength(value, state));
407         return;
408     case CSSPropertyMarginTop:
409         style->setMarginTop(animatableValueToLength(value, state));
410         return;
411     case CSSPropertyMaxHeight:
412         style->setMaxHeight(animatableValueToLength(value, state, ValueRangeNonNegative));
413         return;
414     case CSSPropertyMaxWidth:
415         style->setMaxWidth(animatableValueToLength(value, state, ValueRangeNonNegative));
416         return;
417     case CSSPropertyMinHeight:
418         style->setMinHeight(animatableValueToLength(value, state, ValueRangeNonNegative));
419         return;
420     case CSSPropertyMinWidth:
421         style->setMinWidth(animatableValueToLength(value, state, ValueRangeNonNegative));
422         return;
423     case CSSPropertyObjectPosition:
424         style->setObjectPosition(animatableValueToLengthPoint(value, state));
425         return;
426     case CSSPropertyOpacity:
427         // Avoiding a value of 1 forces a layer to be created.
428         style->setOpacity(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0, nextafterf(1, 0)));
429         return;
430     case CSSPropertyOrphans:
431         style->setOrphans(animatableValueRoundClampTo<unsigned short>(value, 1));
432         return;
433     case CSSPropertyOutlineColor:
434         style->setOutlineColor(toAnimatableColor(value)->color());
435         style->setVisitedLinkOutlineColor(toAnimatableColor(value)->visitedLinkColor());
436         return;
437     case CSSPropertyOutlineOffset:
438         style->setOutlineOffset(animatableValueRoundClampTo<int>(value));
439         return;
440     case CSSPropertyOutlineWidth:
441         style->setOutlineWidth(animatableValueRoundClampTo<unsigned short>(value));
442         return;
443     case CSSPropertyPaddingBottom:
444         style->setPaddingBottom(animatableValueToLength(value, state, ValueRangeNonNegative));
445         return;
446     case CSSPropertyPaddingLeft:
447         style->setPaddingLeft(animatableValueToLength(value, state, ValueRangeNonNegative));
448         return;
449     case CSSPropertyPaddingRight:
450         style->setPaddingRight(animatableValueToLength(value, state, ValueRangeNonNegative));
451         return;
452     case CSSPropertyPaddingTop:
453         style->setPaddingTop(animatableValueToLength(value, state, ValueRangeNonNegative));
454         return;
455     case CSSPropertyRight:
456         style->setRight(animatableValueToLength(value, state));
457         return;
458     case CSSPropertyStrokeWidth:
459         style->setStrokeWidth(animatableValueToNonNegativeSVGLength(value));
460         return;
461     case CSSPropertyStopColor:
462         style->setStopColor(toAnimatableColor(value)->color());
463         return;
464     case CSSPropertyStopOpacity:
465         style->setStopOpacity(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0, 1));
466         return;
467     case CSSPropertyStrokeDasharray:
468         style->setStrokeDashArray(toAnimatableStrokeDasharrayList(value)->toSVGLengthList());
469         return;
470     case CSSPropertyStrokeDashoffset:
471         style->setStrokeDashOffset(toAnimatableSVGLength(value)->toSVGLength());
472         return;
473     case CSSPropertyStrokeMiterlimit:
474         style->setStrokeMiterLimit(clampTo<float>(toAnimatableDouble(value)->toDouble(), 1));
475         return;
476     case CSSPropertyStrokeOpacity:
477         style->setStrokeOpacity(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0, 1));
478         return;
479     case CSSPropertyStroke:
480         {
481             const AnimatableSVGPaint* svgPaint = toAnimatableSVGPaint(value);
482             style->accessSVGStyle()->setStrokePaint(svgPaint->paintType(), svgPaint->color(), svgPaint->uri());
483         }
484         return;
485     case CSSPropertyTextDecorationColor:
486         style->setTextDecorationColor(toAnimatableColor(value)->color());
487         style->setVisitedLinkTextDecorationColor(toAnimatableColor(value)->visitedLinkColor());
488         return;
489     case CSSPropertyTextIndent:
490         style->setTextIndent(animatableValueToLength(value, state));
491         return;
492     case CSSPropertyTextShadow:
493         style->setTextShadow(toAnimatableShadow(value)->shadowList());
494         return;
495     case CSSPropertyTop:
496         style->setTop(animatableValueToLength(value, state));
497         return;
498     case CSSPropertyWebkitBackgroundSize:
499         setOnFillLayers<CSSPropertyWebkitBackgroundSize>(style->accessBackgroundLayers(), value, state);
500         return;
501     case CSSPropertyWebkitBorderHorizontalSpacing:
502         style->setHorizontalBorderSpacing(animatableValueRoundClampTo<unsigned short>(value));
503         return;
504     case CSSPropertyWebkitBorderVerticalSpacing:
505         style->setVerticalBorderSpacing(animatableValueRoundClampTo<unsigned short>(value));
506         return;
507     case CSSPropertyWebkitClipPath:
508         style->setClipPath(toAnimatableClipPathOperation(value)->clipPathOperation());
509         return;
510     case CSSPropertyWebkitColumnCount:
511         style->setColumnCount(animatableValueRoundClampTo<unsigned short>(value, 1));
512         return;
513     case CSSPropertyWebkitColumnGap:
514         style->setColumnGap(clampTo(toAnimatableDouble(value)->toDouble(), 0));
515         return;
516     case CSSPropertyWebkitColumnRuleColor:
517         style->setColumnRuleColor(toAnimatableColor(value)->color());
518         style->setVisitedLinkColumnRuleColor(toAnimatableColor(value)->visitedLinkColor());
519         return;
520     case CSSPropertyWebkitColumnWidth:
521         style->setColumnWidth(clampTo(toAnimatableDouble(value)->toDouble(), std::numeric_limits<float>::epsilon()));
522         return;
523     case CSSPropertyWebkitColumnRuleWidth:
524         style->setColumnRuleWidth(animatableValueRoundClampTo<unsigned short>(value));
525         return;
526     case CSSPropertyWebkitFilter:
527         style->setFilter(toAnimatableFilterOperations(value)->operations());
528         return;
529     case CSSPropertyWebkitMaskBoxImageOutset:
530         style->setMaskBoxImageOutset(animatableValueToBorderImageLengthBox(value, state));
531         return;
532     case CSSPropertyWebkitMaskBoxImageSlice:
533         style->setMaskBoxImageSlices(animatableValueToLengthBox(toAnimatableLengthBoxAndBool(value)->box(), state, ValueRangeNonNegative));
534         style->setMaskBoxImageSlicesFill(toAnimatableLengthBoxAndBool(value)->flag());
535         return;
536     case CSSPropertyWebkitMaskBoxImageSource:
537         style->setMaskBoxImageSource(state.styleImage(property, toAnimatableImage(value)->toCSSValue()));
538         return;
539     case CSSPropertyWebkitMaskBoxImageWidth:
540         style->setMaskBoxImageWidth(animatableValueToBorderImageLengthBox(value, state));
541         return;
542     case CSSPropertyWebkitMaskImage:
543         setOnFillLayers<CSSPropertyWebkitMaskImage>(style->accessMaskLayers(), value, state);
544         return;
545     case CSSPropertyWebkitMaskPositionX:
546         setOnFillLayers<CSSPropertyWebkitMaskPositionX>(style->accessMaskLayers(), value, state);
547         return;
548     case CSSPropertyWebkitMaskPositionY:
549         setOnFillLayers<CSSPropertyWebkitMaskPositionY>(style->accessMaskLayers(), value, state);
550         return;
551     case CSSPropertyWebkitMaskSize:
552         setOnFillLayers<CSSPropertyWebkitMaskSize>(style->accessMaskLayers(), value, state);
553         return;
554     case CSSPropertyPerspective:
555         style->setPerspective(clampTo<float>(toAnimatableDouble(value)->toDouble()));
556         return;
557     case CSSPropertyPerspectiveOrigin: {
558         ASSERT(RuntimeEnabledFeatures::cssTransformsUnprefixedEnabled());
559         const AnimatableLengthPoint* animatableLengthPoint = toAnimatableLengthPoint(value);
560         style->setPerspectiveOriginX(animatableValueToLength(animatableLengthPoint->x(), state));
561         style->setPerspectiveOriginY(animatableValueToLength(animatableLengthPoint->y(), state));
562         return;
563     }
564     case CSSPropertyWebkitPerspectiveOriginX:
565         ASSERT(!RuntimeEnabledFeatures::cssTransformsUnprefixedEnabled());
566         style->setPerspectiveOriginX(animatableValueToLength(value, state));
567         return;
568     case CSSPropertyWebkitPerspectiveOriginY:
569         ASSERT(!RuntimeEnabledFeatures::cssTransformsUnprefixedEnabled());
570         style->setPerspectiveOriginY(animatableValueToLength(value, state));
571         return;
572     case CSSPropertyShapeOutside:
573         style->setShapeOutside(toAnimatableShapeValue(value)->shapeValue());
574         return;
575     case CSSPropertyShapeMargin:
576         style->setShapeMargin(animatableValueToLength(value, state, ValueRangeNonNegative));
577         return;
578     case CSSPropertyShapeImageThreshold:
579         style->setShapeImageThreshold(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0, 1));
580         return;
581     case CSSPropertyWebkitTextStrokeColor:
582         style->setTextStrokeColor(toAnimatableColor(value)->color());
583         style->setVisitedLinkTextStrokeColor(toAnimatableColor(value)->visitedLinkColor());
584         return;
585     case CSSPropertyTransform: {
586         const TransformOperations& operations = toAnimatableTransform(value)->transformOperations();
587         // FIXME: This normalization (handling of 'none') should be performed at input in AnimatableValueFactory.
588         style->setTransform(operations.size() ? operations : TransformOperations(true));
589         return;
590     }
591     case CSSPropertyTransformOrigin: {
592         ASSERT(RuntimeEnabledFeatures::cssTransformsUnprefixedEnabled());
593         const AnimatableLengthPoint3D* animatableLengthPoint3D = toAnimatableLengthPoint3D(value);
594         style->setTransformOriginX(animatableValueToLength(animatableLengthPoint3D->x(), state));
595         style->setTransformOriginY(animatableValueToLength(animatableLengthPoint3D->y(), state));
596         style->setTransformOriginZ(clampTo<float>(toAnimatableDouble(animatableLengthPoint3D->z())->toDouble()));
597         return;
598     }
599     case CSSPropertyWebkitTransformOriginX:
600         ASSERT(!RuntimeEnabledFeatures::cssTransformsUnprefixedEnabled());
601         style->setTransformOriginX(animatableValueToLength(value, state));
602         return;
603     case CSSPropertyWebkitTransformOriginY:
604         ASSERT(!RuntimeEnabledFeatures::cssTransformsUnprefixedEnabled());
605         style->setTransformOriginY(animatableValueToLength(value, state));
606         return;
607     case CSSPropertyWebkitTransformOriginZ:
608         ASSERT(!RuntimeEnabledFeatures::cssTransformsUnprefixedEnabled());
609         style->setTransformOriginZ(toAnimatableDouble(value)->toDouble());
610         return;
611     case CSSPropertyWidows:
612         style->setWidows(animatableValueRoundClampTo<unsigned short>(value, 1));
613         return;
614     case CSSPropertyWidth:
615         style->setWidth(animatableValueToLength(value, state, ValueRangeNonNegative));
616         return;
617     case CSSPropertyWordSpacing:
618         style->setWordSpacing(clampTo<float>(toAnimatableDouble(value)->toDouble()));
619         return;
620     case CSSPropertyVisibility:
621         style->setVisibility(toAnimatableVisibility(value)->visibility());
622         return;
623     case CSSPropertyZIndex:
624         style->setZIndex(animatableValueRoundClampTo<int>(value));
625         return;
626     case CSSPropertyZoom:
627         style->setZoom(clampTo<float>(toAnimatableDouble(value)->toDouble(), std::numeric_limits<float>::denorm_min()));
628         return;
629     default:
630         ASSERT_NOT_REACHED();
631     }
632 }
633
634 } // namespace WebCore