Update To 11.40.268.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/animatable/AnimatableClipPathOperation.h"
35 #include "core/animation/animatable/AnimatableColor.h"
36 #include "core/animation/animatable/AnimatableDouble.h"
37 #include "core/animation/animatable/AnimatableFilterOperations.h"
38 #include "core/animation/animatable/AnimatableImage.h"
39 #include "core/animation/animatable/AnimatableLength.h"
40 #include "core/animation/animatable/AnimatableLengthBox.h"
41 #include "core/animation/animatable/AnimatableLengthBoxAndBool.h"
42 #include "core/animation/animatable/AnimatableLengthPoint.h"
43 #include "core/animation/animatable/AnimatableLengthPoint3D.h"
44 #include "core/animation/animatable/AnimatableLengthSize.h"
45 #include "core/animation/animatable/AnimatableRepeatable.h"
46 #include "core/animation/animatable/AnimatableSVGLength.h"
47 #include "core/animation/animatable/AnimatableSVGPaint.h"
48 #include "core/animation/animatable/AnimatableShadow.h"
49 #include "core/animation/animatable/AnimatableShapeValue.h"
50 #include "core/animation/animatable/AnimatableStrokeDasharrayList.h"
51 #include "core/animation/animatable/AnimatableTransform.h"
52 #include "core/animation/animatable/AnimatableUnknown.h"
53 #include "core/animation/animatable/AnimatableValue.h"
54 #include "core/animation/animatable/AnimatableVisibility.h"
55 #include "core/css/CSSPrimitiveValueMappings.h"
56 #include "core/css/CSSPropertyMetadata.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 blink {
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 TransformOrigin animatableValueToTransformOrigin(const AnimatableValue* value, const StyleResolverState& state, ValueRange range = ValueRangeAll)
122 {
123     const AnimatableLengthPoint3D* animatableLengthPoint3D = toAnimatableLengthPoint3D(value);
124     return TransformOrigin(
125         animatableValueToLength(animatableLengthPoint3D->x(), state),
126         animatableValueToLength(animatableLengthPoint3D->y(), state),
127         clampTo<float>(toAnimatableDouble(animatableLengthPoint3D->z())->toDouble())
128     );
129 }
130
131 LengthSize animatableValueToLengthSize(const AnimatableValue* value, const StyleResolverState& state, ValueRange range)
132 {
133     const AnimatableLengthSize* animatableLengthSize = toAnimatableLengthSize(value);
134     return LengthSize(
135         animatableValueToLength(animatableLengthSize->width(), state, range),
136         animatableValueToLength(animatableLengthSize->height(), state, range));
137 }
138
139 void setFillSize(FillLayer* fillLayer, const AnimatableValue* value, const StyleResolverState& state)
140 {
141     if (value->isLengthSize())
142         fillLayer->setSize(FillSize(SizeLength, animatableValueToLengthSize(value, state, ValueRangeNonNegative)));
143     else
144         state.styleMap().mapFillSize(fillLayer, toAnimatableUnknown(value)->toCSSValue().get());
145 }
146
147 PassRefPtr<SVGLength> animatableValueToNonNegativeSVGLength(const AnimatableValue* value)
148 {
149     RefPtr<SVGLength> length = toAnimatableSVGLength(value)->toSVGLength();
150     if (length->valueInSpecifiedUnits() < 0)
151         length->setValueInSpecifiedUnits(0);
152     return length.release();
153 }
154
155 template <CSSPropertyID property>
156 void setOnFillLayers(FillLayer& fillLayers, const AnimatableValue* value, StyleResolverState& state)
157 {
158     const WillBeHeapVector<RefPtrWillBeMember<AnimatableValue> >& values = toAnimatableRepeatable(value)->values();
159     ASSERT(!values.isEmpty());
160     FillLayer* fillLayer = &fillLayers;
161     FillLayer* prev = 0;
162     for (size_t i = 0; i < values.size(); ++i) {
163         if (!fillLayer)
164             fillLayer = prev->ensureNext();
165         const AnimatableValue* layerValue = values[i].get();
166         switch (property) {
167         case CSSPropertyBackgroundImage:
168         case CSSPropertyWebkitMaskImage:
169             if (layerValue->isImage()) {
170                 fillLayer->setImage(state.styleImage(property, toAnimatableImage(layerValue)->toCSSValue()));
171             } else {
172                 ASSERT(toAnimatableUnknown(layerValue)->toCSSValueID() == CSSValueNone);
173                 fillLayer->setImage(nullptr);
174             }
175             break;
176         case CSSPropertyBackgroundPositionX:
177         case CSSPropertyWebkitMaskPositionX:
178             fillLayer->setXPosition(animatableValueToLength(layerValue, state));
179             break;
180         case CSSPropertyBackgroundPositionY:
181         case CSSPropertyWebkitMaskPositionY:
182             fillLayer->setYPosition(animatableValueToLength(layerValue, state));
183             break;
184         case CSSPropertyBackgroundSize:
185         case CSSPropertyWebkitBackgroundSize:
186         case CSSPropertyWebkitMaskSize:
187             setFillSize(fillLayer, layerValue, state);
188             break;
189         default:
190             ASSERT_NOT_REACHED();
191         }
192         prev = fillLayer;
193         fillLayer = fillLayer->next();
194     }
195     while (fillLayer) {
196         switch (property) {
197         case CSSPropertyBackgroundImage:
198         case CSSPropertyWebkitMaskImage:
199             fillLayer->clearImage();
200             break;
201         case CSSPropertyBackgroundPositionX:
202         case CSSPropertyWebkitMaskPositionX:
203             fillLayer->clearXPosition();
204             break;
205         case CSSPropertyBackgroundPositionY:
206         case CSSPropertyWebkitMaskPositionY:
207             fillLayer->clearYPosition();
208             break;
209         case CSSPropertyBackgroundSize:
210         case CSSPropertyWebkitBackgroundSize:
211         case CSSPropertyWebkitMaskSize:
212             fillLayer->clearSize();
213             break;
214         default:
215             ASSERT_NOT_REACHED();
216         }
217         fillLayer = fillLayer->next();
218     }
219 }
220
221 FontStretch animatableValueToFontStretch(const AnimatableValue* value)
222 {
223     ASSERT(FontStretchUltraCondensed == 1 && FontStretchUltraExpanded == 9);
224     unsigned index = round(toAnimatableDouble(value)->toDouble()) - 1;
225     static const FontStretch stretchValues[] = {
226         FontStretchUltraCondensed,
227         FontStretchExtraCondensed,
228         FontStretchCondensed,
229         FontStretchSemiCondensed,
230         FontStretchNormal,
231         FontStretchSemiExpanded,
232         FontStretchExpanded,
233         FontStretchExtraExpanded,
234         FontStretchUltraExpanded
235     };
236
237     index = clampTo<unsigned>(index, 0, WTF_ARRAY_LENGTH(stretchValues) - 1);
238     return stretchValues[index];
239 }
240
241 FontWeight animatableValueToFontWeight(const AnimatableValue* value)
242 {
243     int index = round(toAnimatableDouble(value)->toDouble() / 100) - 1;
244
245     static const FontWeight weights[] = {
246         FontWeight100,
247         FontWeight200,
248         FontWeight300,
249         FontWeight400,
250         FontWeight500,
251         FontWeight600,
252         FontWeight700,
253         FontWeight800,
254         FontWeight900
255     };
256
257     index = clampTo<int>(index, 0, WTF_ARRAY_LENGTH(weights) - 1);
258
259     return weights[index];
260 }
261
262 } // namespace
263
264 // FIXME: Generate this function.
265 void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, StyleResolverState& state, const AnimatableValue* value)
266 {
267     ASSERT(CSSPropertyMetadata::isAnimatableProperty(property));
268     if (value->isUnknown()) {
269         StyleBuilder::applyProperty(property, state, toAnimatableUnknown(value)->toCSSValue().get());
270         return;
271     }
272     RenderStyle* style = state.style();
273     switch (property) {
274     case CSSPropertyBackgroundColor:
275         style->setBackgroundColor(toAnimatableColor(value)->color());
276         style->setVisitedLinkBackgroundColor(toAnimatableColor(value)->visitedLinkColor());
277         return;
278     case CSSPropertyBackgroundImage:
279         setOnFillLayers<CSSPropertyBackgroundImage>(style->accessBackgroundLayers(), value, state);
280         return;
281     case CSSPropertyBackgroundPositionX:
282         setOnFillLayers<CSSPropertyBackgroundPositionX>(style->accessBackgroundLayers(), value, state);
283         return;
284     case CSSPropertyBackgroundPositionY:
285         setOnFillLayers<CSSPropertyBackgroundPositionY>(style->accessBackgroundLayers(), value, state);
286         return;
287     case CSSPropertyBackgroundSize:
288         setOnFillLayers<CSSPropertyBackgroundSize>(style->accessBackgroundLayers(), value, state);
289         return;
290     case CSSPropertyBaselineShift:
291         style->setBaselineShiftValue(toAnimatableSVGLength(value)->toSVGLength());
292         return;
293     case CSSPropertyBorderBottomColor:
294         style->setBorderBottomColor(toAnimatableColor(value)->color());
295         style->setVisitedLinkBorderBottomColor(toAnimatableColor(value)->visitedLinkColor());
296         return;
297     case CSSPropertyBorderBottomLeftRadius:
298         style->setBorderBottomLeftRadius(animatableValueToLengthSize(value, state, ValueRangeNonNegative));
299         return;
300     case CSSPropertyBorderBottomRightRadius:
301         style->setBorderBottomRightRadius(animatableValueToLengthSize(value, state, ValueRangeNonNegative));
302         return;
303     case CSSPropertyBorderBottomWidth:
304         style->setBorderBottomWidth(animatableValueRoundClampTo<unsigned>(value));
305         return;
306     case CSSPropertyBorderImageOutset:
307         style->setBorderImageOutset(animatableValueToBorderImageLengthBox(value, state));
308         return;
309     case CSSPropertyBorderImageSlice:
310         style->setBorderImageSlices(animatableValueToLengthBox(value, state, ValueRangeNonNegative));
311         return;
312     case CSSPropertyBorderImageSource:
313         style->setBorderImageSource(state.styleImage(property, toAnimatableImage(value)->toCSSValue()));
314         return;
315     case CSSPropertyBorderImageWidth:
316         style->setBorderImageWidth(animatableValueToBorderImageLengthBox(value, state));
317         return;
318     case CSSPropertyBorderLeftColor:
319         style->setBorderLeftColor(toAnimatableColor(value)->color());
320         style->setVisitedLinkBorderLeftColor(toAnimatableColor(value)->visitedLinkColor());
321         return;
322     case CSSPropertyBorderLeftWidth:
323         style->setBorderLeftWidth(animatableValueRoundClampTo<unsigned>(value));
324         return;
325     case CSSPropertyBorderRightColor:
326         style->setBorderRightColor(toAnimatableColor(value)->color());
327         style->setVisitedLinkBorderRightColor(toAnimatableColor(value)->visitedLinkColor());
328         return;
329     case CSSPropertyBorderRightWidth:
330         style->setBorderRightWidth(animatableValueRoundClampTo<unsigned>(value));
331         return;
332     case CSSPropertyBorderTopColor:
333         style->setBorderTopColor(toAnimatableColor(value)->color());
334         style->setVisitedLinkBorderTopColor(toAnimatableColor(value)->visitedLinkColor());
335         return;
336     case CSSPropertyBorderTopLeftRadius:
337         style->setBorderTopLeftRadius(animatableValueToLengthSize(value, state, ValueRangeNonNegative));
338         return;
339     case CSSPropertyBorderTopRightRadius:
340         style->setBorderTopRightRadius(animatableValueToLengthSize(value, state, ValueRangeNonNegative));
341         return;
342     case CSSPropertyBorderTopWidth:
343         style->setBorderTopWidth(animatableValueRoundClampTo<unsigned>(value));
344         return;
345     case CSSPropertyBottom:
346         style->setBottom(animatableValueToLength(value, state));
347         return;
348     case CSSPropertyBoxShadow:
349     case CSSPropertyWebkitBoxShadow:
350         style->setBoxShadow(toAnimatableShadow(value)->shadowList());
351         return;
352     case CSSPropertyClip:
353         style->setClip(animatableValueToLengthBox(value, state));
354         return;
355     case CSSPropertyColor:
356         style->setColor(toAnimatableColor(value)->color());
357         style->setVisitedLinkColor(toAnimatableColor(value)->visitedLinkColor());
358         return;
359     case CSSPropertyFillOpacity:
360         style->setFillOpacity(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0, 1));
361         return;
362     case CSSPropertyFill:
363         {
364             const AnimatableSVGPaint* svgPaint = toAnimatableSVGPaint(value);
365             style->accessSVGStyle().setFillPaint(svgPaint->paintType(), svgPaint->color(), svgPaint->uri(), true, false);
366             style->accessSVGStyle().setFillPaint(svgPaint->visitedLinkPaintType(), svgPaint->visitedLinkColor(), svgPaint->visitedLinkURI(), false, true);
367         }
368         return;
369     case CSSPropertyFlexGrow:
370         style->setFlexGrow(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0));
371         return;
372     case CSSPropertyFlexShrink:
373         style->setFlexShrink(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0));
374         return;
375     case CSSPropertyFlexBasis:
376         style->setFlexBasis(animatableValueToLength(value, state, ValueRangeNonNegative));
377         return;
378     case CSSPropertyFloodColor:
379         style->setFloodColor(toAnimatableColor(value)->color());
380         return;
381     case CSSPropertyFloodOpacity:
382         style->setFloodOpacity(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0, 1));
383         return;
384     case CSSPropertyFontSize:
385         style->setFontSize(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0));
386         return;
387     case CSSPropertyFontStretch:
388         style->setFontStretch(animatableValueToFontStretch(value));
389         return;
390     case CSSPropertyFontWeight:
391         style->setFontWeight(animatableValueToFontWeight(value));
392         return;
393     case CSSPropertyHeight:
394         style->setHeight(animatableValueToLength(value, state, ValueRangeNonNegative));
395         return;
396     case CSSPropertyLeft:
397         style->setLeft(animatableValueToLength(value, state));
398         return;
399     case CSSPropertyLightingColor:
400         style->setLightingColor(toAnimatableColor(value)->color());
401         return;
402     case CSSPropertyLineHeight:
403         if (value->isLength())
404             style->setLineHeight(animatableValueToLength(value, state, ValueRangeNonNegative));
405         else
406             style->setLineHeight(Length(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0), Percent));
407         return;
408     case CSSPropertyListStyleImage:
409         style->setListStyleImage(state.styleImage(property, toAnimatableImage(value)->toCSSValue()));
410         return;
411     case CSSPropertyLetterSpacing:
412         style->setLetterSpacing(clampTo<float>(toAnimatableDouble(value)->toDouble()));
413         return;
414     case CSSPropertyMarginBottom:
415         style->setMarginBottom(animatableValueToLength(value, state));
416         return;
417     case CSSPropertyMarginLeft:
418         style->setMarginLeft(animatableValueToLength(value, state));
419         return;
420     case CSSPropertyMarginRight:
421         style->setMarginRight(animatableValueToLength(value, state));
422         return;
423     case CSSPropertyMarginTop:
424         style->setMarginTop(animatableValueToLength(value, state));
425         return;
426     case CSSPropertyMaxHeight:
427         style->setMaxHeight(animatableValueToLength(value, state, ValueRangeNonNegative));
428         return;
429     case CSSPropertyMaxWidth:
430         style->setMaxWidth(animatableValueToLength(value, state, ValueRangeNonNegative));
431         return;
432     case CSSPropertyMinHeight:
433         style->setMinHeight(animatableValueToLength(value, state, ValueRangeNonNegative));
434         return;
435     case CSSPropertyMinWidth:
436         style->setMinWidth(animatableValueToLength(value, state, ValueRangeNonNegative));
437         return;
438     case CSSPropertyObjectPosition:
439         style->setObjectPosition(animatableValueToLengthPoint(value, state));
440         return;
441     case CSSPropertyOpacity:
442         // Avoiding a value of 1 forces a layer to be created.
443         style->setOpacity(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0, nextafterf(1, 0)));
444         return;
445     case CSSPropertyOrphans:
446         style->setOrphans(animatableValueRoundClampTo<unsigned short>(value, 1));
447         return;
448     case CSSPropertyOutlineColor:
449         style->setOutlineColor(toAnimatableColor(value)->color());
450         style->setVisitedLinkOutlineColor(toAnimatableColor(value)->visitedLinkColor());
451         return;
452     case CSSPropertyOutlineOffset:
453         style->setOutlineOffset(animatableValueRoundClampTo<int>(value));
454         return;
455     case CSSPropertyOutlineWidth:
456         style->setOutlineWidth(animatableValueRoundClampTo<unsigned short>(value));
457         return;
458     case CSSPropertyPaddingBottom:
459         style->setPaddingBottom(animatableValueToLength(value, state, ValueRangeNonNegative));
460         return;
461     case CSSPropertyPaddingLeft:
462         style->setPaddingLeft(animatableValueToLength(value, state, ValueRangeNonNegative));
463         return;
464     case CSSPropertyPaddingRight:
465         style->setPaddingRight(animatableValueToLength(value, state, ValueRangeNonNegative));
466         return;
467     case CSSPropertyPaddingTop:
468         style->setPaddingTop(animatableValueToLength(value, state, ValueRangeNonNegative));
469         return;
470     case CSSPropertyRight:
471         style->setRight(animatableValueToLength(value, state));
472         return;
473     case CSSPropertyStrokeWidth:
474         style->setStrokeWidth(animatableValueToNonNegativeSVGLength(value));
475         return;
476     case CSSPropertyStopColor:
477         style->setStopColor(toAnimatableColor(value)->color());
478         return;
479     case CSSPropertyStopOpacity:
480         style->setStopOpacity(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0, 1));
481         return;
482     case CSSPropertyStrokeDasharray:
483         style->setStrokeDashArray(toAnimatableStrokeDasharrayList(value)->toSVGLengthList());
484         return;
485     case CSSPropertyStrokeDashoffset:
486         style->setStrokeDashOffset(toAnimatableSVGLength(value)->toSVGLength());
487         return;
488     case CSSPropertyStrokeMiterlimit:
489         style->setStrokeMiterLimit(clampTo<float>(toAnimatableDouble(value)->toDouble(), 1));
490         return;
491     case CSSPropertyStrokeOpacity:
492         style->setStrokeOpacity(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0, 1));
493         return;
494     case CSSPropertyStroke:
495         {
496             const AnimatableSVGPaint* svgPaint = toAnimatableSVGPaint(value);
497             style->accessSVGStyle().setStrokePaint(svgPaint->paintType(), svgPaint->color(), svgPaint->uri(), true, false);
498             style->accessSVGStyle().setStrokePaint(svgPaint->visitedLinkPaintType(), svgPaint->visitedLinkColor(), svgPaint->visitedLinkURI(), false, true);
499         }
500         return;
501     case CSSPropertyTextDecorationColor:
502         style->setTextDecorationColor(toAnimatableColor(value)->color());
503         style->setVisitedLinkTextDecorationColor(toAnimatableColor(value)->visitedLinkColor());
504         return;
505     case CSSPropertyTextIndent:
506         style->setTextIndent(animatableValueToLength(value, state));
507         return;
508     case CSSPropertyTextShadow:
509         style->setTextShadow(toAnimatableShadow(value)->shadowList());
510         return;
511     case CSSPropertyTop:
512         style->setTop(animatableValueToLength(value, state));
513         return;
514     case CSSPropertyWebkitBackgroundSize:
515         setOnFillLayers<CSSPropertyWebkitBackgroundSize>(style->accessBackgroundLayers(), value, state);
516         return;
517     case CSSPropertyWebkitBorderHorizontalSpacing:
518         style->setHorizontalBorderSpacing(animatableValueRoundClampTo<unsigned short>(value));
519         return;
520     case CSSPropertyWebkitBorderVerticalSpacing:
521         style->setVerticalBorderSpacing(animatableValueRoundClampTo<unsigned short>(value));
522         return;
523     case CSSPropertyWebkitClipPath:
524         style->setClipPath(toAnimatableClipPathOperation(value)->clipPathOperation());
525         return;
526     case CSSPropertyWebkitColumnCount:
527         style->setColumnCount(animatableValueRoundClampTo<unsigned short>(value, 1));
528         return;
529     case CSSPropertyWebkitColumnGap:
530         style->setColumnGap(clampTo(toAnimatableDouble(value)->toDouble(), 0));
531         return;
532     case CSSPropertyWebkitColumnRuleColor:
533         style->setColumnRuleColor(toAnimatableColor(value)->color());
534         style->setVisitedLinkColumnRuleColor(toAnimatableColor(value)->visitedLinkColor());
535         return;
536     case CSSPropertyWebkitColumnWidth:
537         style->setColumnWidth(clampTo(toAnimatableDouble(value)->toDouble(), std::numeric_limits<float>::epsilon()));
538         return;
539     case CSSPropertyWebkitColumnRuleWidth:
540         style->setColumnRuleWidth(animatableValueRoundClampTo<unsigned short>(value));
541         return;
542     case CSSPropertyWebkitFilter:
543         style->setFilter(toAnimatableFilterOperations(value)->operations());
544         return;
545     case CSSPropertyWebkitMaskBoxImageOutset:
546         style->setMaskBoxImageOutset(animatableValueToBorderImageLengthBox(value, state));
547         return;
548     case CSSPropertyWebkitMaskBoxImageSlice:
549         style->setMaskBoxImageSlices(animatableValueToLengthBox(toAnimatableLengthBoxAndBool(value)->box(), state, ValueRangeNonNegative));
550         style->setMaskBoxImageSlicesFill(toAnimatableLengthBoxAndBool(value)->flag());
551         return;
552     case CSSPropertyWebkitMaskBoxImageSource:
553         style->setMaskBoxImageSource(state.styleImage(property, toAnimatableImage(value)->toCSSValue()));
554         return;
555     case CSSPropertyWebkitMaskBoxImageWidth:
556         style->setMaskBoxImageWidth(animatableValueToBorderImageLengthBox(value, state));
557         return;
558     case CSSPropertyWebkitMaskImage:
559         setOnFillLayers<CSSPropertyWebkitMaskImage>(style->accessMaskLayers(), value, state);
560         return;
561     case CSSPropertyWebkitMaskPositionX:
562         setOnFillLayers<CSSPropertyWebkitMaskPositionX>(style->accessMaskLayers(), value, state);
563         return;
564     case CSSPropertyWebkitMaskPositionY:
565         setOnFillLayers<CSSPropertyWebkitMaskPositionY>(style->accessMaskLayers(), value, state);
566         return;
567     case CSSPropertyWebkitMaskSize:
568         setOnFillLayers<CSSPropertyWebkitMaskSize>(style->accessMaskLayers(), value, state);
569         return;
570     case CSSPropertyPerspective:
571         style->setPerspective(clampTo<float>(toAnimatableDouble(value)->toDouble()));
572         return;
573     case CSSPropertyPerspectiveOrigin:
574         style->setPerspectiveOrigin(animatableValueToLengthPoint(value, state));
575         return;
576     case CSSPropertyShapeOutside:
577         style->setShapeOutside(toAnimatableShapeValue(value)->shapeValue());
578         return;
579     case CSSPropertyShapeMargin:
580         style->setShapeMargin(animatableValueToLength(value, state, ValueRangeNonNegative));
581         return;
582     case CSSPropertyShapeImageThreshold:
583         style->setShapeImageThreshold(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0, 1));
584         return;
585     case CSSPropertyWebkitTextStrokeColor:
586         style->setTextStrokeColor(toAnimatableColor(value)->color());
587         style->setVisitedLinkTextStrokeColor(toAnimatableColor(value)->visitedLinkColor());
588         return;
589     case CSSPropertyTransform: {
590         const TransformOperations& operations = toAnimatableTransform(value)->transformOperations();
591         // FIXME: This normalization (handling of 'none') should be performed at input in AnimatableValueFactory.
592         style->setTransform(operations.size() ? operations : TransformOperations(true));
593         return;
594     }
595     case CSSPropertyTransformOrigin:
596         style->setTransformOrigin(animatableValueToTransformOrigin(value, state));
597         return;
598     case CSSPropertyWidows:
599         style->setWidows(animatableValueRoundClampTo<unsigned short>(value, 1));
600         return;
601     case CSSPropertyWidth:
602         style->setWidth(animatableValueToLength(value, state, ValueRangeNonNegative));
603         return;
604     case CSSPropertyWordSpacing:
605         style->setWordSpacing(clampTo<float>(toAnimatableDouble(value)->toDouble()));
606         return;
607     case CSSPropertyVerticalAlign:
608         style->setVerticalAlignLength(animatableValueToLength(value, state));
609         return;
610     case CSSPropertyVisibility:
611         style->setVisibility(toAnimatableVisibility(value)->visibility());
612         return;
613     case CSSPropertyZIndex:
614         style->setZIndex(animatableValueRoundClampTo<int>(value));
615         return;
616     case CSSPropertyZoom:
617         style->setZoom(clampTo<float>(toAnimatableDouble(value)->toDouble(), std::numeric_limits<float>::denorm_min()));
618         return;
619     default:
620         ASSERT_NOT_REACHED();
621     }
622 }
623
624 } // namespace blink