2 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
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
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.
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.
32 #include "core/css/resolver/AnimatedStyleBuilder.h"
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"
67 Length animatableValueToLength(const AnimatableValue* value, const StyleResolverState& state, ValueRange range = ValueRangeAll)
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());
76 BorderImageLength animatableValueToBorderImageLength(const AnimatableValue* value, const StyleResolverState& state)
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()));
87 template<typename T> T animatableValueRoundClampTo(const AnimatableValue* value, T min = defaultMinimumForClamp<T>(), T max = defaultMaximumForClamp<T>())
89 COMPILE_ASSERT(WTF::IsInteger<T>::value, ShouldUseIntegralTypeTWhenRoundingValues);
90 return clampTo<T>(round(toAnimatableDouble(value)->toDouble()), min, max);
93 LengthBox animatableValueToLengthBox(const AnimatableValue* value, const StyleResolverState& state, ValueRange range = ValueRangeAll)
95 const AnimatableLengthBox* animatableLengthBox = toAnimatableLengthBox(value);
97 animatableValueToLength(animatableLengthBox->top(), state, range),
98 animatableValueToLength(animatableLengthBox->right(), state, range),
99 animatableValueToLength(animatableLengthBox->bottom(), state, range),
100 animatableValueToLength(animatableLengthBox->left(), state, range));
103 BorderImageLengthBox animatableValueToBorderImageLengthBox(const AnimatableValue* value, const StyleResolverState& state)
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));
113 LengthPoint animatableValueToLengthPoint(const AnimatableValue* value, const StyleResolverState& state, ValueRange range = ValueRangeAll)
115 const AnimatableLengthPoint* animatableLengthPoint = toAnimatableLengthPoint(value);
117 animatableValueToLength(animatableLengthPoint->x(), state, range),
118 animatableValueToLength(animatableLengthPoint->y(), state, range));
121 LengthSize animatableValueToLengthSize(const AnimatableValue* value, const StyleResolverState& state, ValueRange range)
123 const AnimatableLengthSize* animatableLengthSize = toAnimatableLengthSize(value);
125 animatableValueToLength(animatableLengthSize->width(), state, range),
126 animatableValueToLength(animatableLengthSize->height(), state, range));
129 template <CSSPropertyID property>
130 void setFillSize(FillLayer* fillLayer, const AnimatableValue* value, const StyleResolverState& state)
132 if (value->isLengthSize())
133 fillLayer->setSize(FillSize(SizeLength, animatableValueToLengthSize(value, state, ValueRangeNonNegative)));
135 state.styleMap().mapFillSize(property, fillLayer, toAnimatableUnknown(value)->toCSSValue().get());
138 PassRefPtr<SVGLength> animatableValueToNonNegativeSVGLength(const AnimatableValue* value)
140 RefPtr<SVGLength> length = toAnimatableSVGLength(value)->toSVGLength();
141 if (length->valueInSpecifiedUnits() < 0)
142 length->setValueInSpecifiedUnits(0);
143 return length.release();
146 template <CSSPropertyID property>
147 void setOnFillLayers(FillLayer* fillLayer, const AnimatableValue* value, StyleResolverState& state)
149 const WillBeHeapVector<RefPtrWillBeMember<AnimatableValue> >& values = toAnimatableRepeatable(value)->values();
150 ASSERT(!values.isEmpty());
152 for (size_t i = 0; i < values.size(); ++i) {
155 case CSSPropertyBackgroundImage:
156 case CSSPropertyBackgroundPositionX:
157 case CSSPropertyBackgroundPositionY:
158 case CSSPropertyBackgroundSize:
159 case CSSPropertyWebkitBackgroundSize:
160 fillLayer = new FillLayer(BackgroundFillLayer);
162 case CSSPropertyWebkitMaskImage:
163 case CSSPropertyWebkitMaskPositionX:
164 case CSSPropertyWebkitMaskPositionY:
165 case CSSPropertyWebkitMaskSize:
166 fillLayer = new FillLayer(MaskFillLayer);
169 ASSERT_NOT_REACHED();
171 prev->setNext(fillLayer);
173 const AnimatableValue* layerValue = values[i].get();
175 case CSSPropertyBackgroundImage:
176 case CSSPropertyWebkitMaskImage:
177 if (layerValue->isImage()) {
178 fillLayer->setImage(state.styleImage(property, toAnimatableImage(layerValue)->toCSSValue()));
180 ASSERT(toAnimatableUnknown(layerValue)->toCSSValueID() == CSSValueNone);
181 fillLayer->setImage(nullptr);
184 case CSSPropertyBackgroundPositionX:
185 case CSSPropertyWebkitMaskPositionX:
186 fillLayer->setXPosition(animatableValueToLength(layerValue, state));
188 case CSSPropertyBackgroundPositionY:
189 case CSSPropertyWebkitMaskPositionY:
190 fillLayer->setYPosition(animatableValueToLength(layerValue, state));
192 case CSSPropertyBackgroundSize:
193 case CSSPropertyWebkitBackgroundSize:
194 case CSSPropertyWebkitMaskSize:
195 setFillSize<property>(fillLayer, layerValue, state);
198 ASSERT_NOT_REACHED();
201 fillLayer = fillLayer->next();
205 case CSSPropertyBackgroundImage:
206 case CSSPropertyWebkitMaskImage:
207 fillLayer->clearImage();
209 case CSSPropertyBackgroundPositionX:
210 case CSSPropertyWebkitMaskPositionX:
211 fillLayer->clearXPosition();
213 case CSSPropertyBackgroundPositionY:
214 case CSSPropertyWebkitMaskPositionY:
215 fillLayer->clearYPosition();
217 case CSSPropertyBackgroundSize:
218 case CSSPropertyWebkitBackgroundSize:
219 case CSSPropertyWebkitMaskSize:
220 fillLayer->clearSize();
223 ASSERT_NOT_REACHED();
225 fillLayer = fillLayer->next();
229 FontWeight animatableValueToFontWeight(const AnimatableValue* value)
231 int index = round(toAnimatableDouble(value)->toDouble() / 100) - 1;
233 static const FontWeight weights[] = {
245 index = clampTo<int>(index, 0, WTF_ARRAY_LENGTH(weights) - 1);
247 return weights[index];
252 // FIXME: Generate this function.
253 void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, StyleResolverState& state, const AnimatableValue* value)
255 ASSERT(CSSAnimations::isAnimatableProperty(property));
256 if (value->isUnknown()) {
257 StyleBuilder::applyProperty(property, state, toAnimatableUnknown(value)->toCSSValue().get());
260 RenderStyle* style = state.style();
262 case CSSPropertyBackgroundColor:
263 style->setBackgroundColor(toAnimatableColor(value)->color());
264 style->setVisitedLinkBackgroundColor(toAnimatableColor(value)->visitedLinkColor());
266 case CSSPropertyBackgroundImage:
267 setOnFillLayers<CSSPropertyBackgroundImage>(style->accessBackgroundLayers(), value, state);
269 case CSSPropertyBackgroundPositionX:
270 setOnFillLayers<CSSPropertyBackgroundPositionX>(style->accessBackgroundLayers(), value, state);
272 case CSSPropertyBackgroundPositionY:
273 setOnFillLayers<CSSPropertyBackgroundPositionY>(style->accessBackgroundLayers(), value, state);
275 case CSSPropertyBackgroundSize:
276 setOnFillLayers<CSSPropertyBackgroundSize>(style->accessBackgroundLayers(), value, state);
278 case CSSPropertyBaselineShift:
279 style->setBaselineShiftValue(toAnimatableSVGLength(value)->toSVGLength());
281 case CSSPropertyBorderBottomColor:
282 style->setBorderBottomColor(toAnimatableColor(value)->color());
283 style->setVisitedLinkBorderBottomColor(toAnimatableColor(value)->visitedLinkColor());
285 case CSSPropertyBorderBottomLeftRadius:
286 style->setBorderBottomLeftRadius(animatableValueToLengthSize(value, state, ValueRangeNonNegative));
288 case CSSPropertyBorderBottomRightRadius:
289 style->setBorderBottomRightRadius(animatableValueToLengthSize(value, state, ValueRangeNonNegative));
291 case CSSPropertyBorderBottomWidth:
292 style->setBorderBottomWidth(animatableValueRoundClampTo<unsigned>(value));
294 case CSSPropertyBorderImageOutset:
295 style->setBorderImageOutset(animatableValueToBorderImageLengthBox(value, state));
297 case CSSPropertyBorderImageSlice:
298 style->setBorderImageSlices(animatableValueToLengthBox(value, state, ValueRangeNonNegative));
300 case CSSPropertyBorderImageSource:
301 style->setBorderImageSource(state.styleImage(property, toAnimatableImage(value)->toCSSValue()));
303 case CSSPropertyBorderImageWidth:
304 style->setBorderImageWidth(animatableValueToBorderImageLengthBox(value, state));
306 case CSSPropertyBorderLeftColor:
307 style->setBorderLeftColor(toAnimatableColor(value)->color());
308 style->setVisitedLinkBorderLeftColor(toAnimatableColor(value)->visitedLinkColor());
310 case CSSPropertyBorderLeftWidth:
311 style->setBorderLeftWidth(animatableValueRoundClampTo<unsigned>(value));
313 case CSSPropertyBorderRightColor:
314 style->setBorderRightColor(toAnimatableColor(value)->color());
315 style->setVisitedLinkBorderRightColor(toAnimatableColor(value)->visitedLinkColor());
317 case CSSPropertyBorderRightWidth:
318 style->setBorderRightWidth(animatableValueRoundClampTo<unsigned>(value));
320 case CSSPropertyBorderTopColor:
321 style->setBorderTopColor(toAnimatableColor(value)->color());
322 style->setVisitedLinkBorderTopColor(toAnimatableColor(value)->visitedLinkColor());
324 case CSSPropertyBorderTopLeftRadius:
325 style->setBorderTopLeftRadius(animatableValueToLengthSize(value, state, ValueRangeNonNegative));
327 case CSSPropertyBorderTopRightRadius:
328 style->setBorderTopRightRadius(animatableValueToLengthSize(value, state, ValueRangeNonNegative));
330 case CSSPropertyBorderTopWidth:
331 style->setBorderTopWidth(animatableValueRoundClampTo<unsigned>(value));
333 case CSSPropertyBottom:
334 style->setBottom(animatableValueToLength(value, state));
336 case CSSPropertyBoxShadow:
337 case CSSPropertyWebkitBoxShadow:
338 style->setBoxShadow(toAnimatableShadow(value)->shadowList());
340 case CSSPropertyClip:
341 style->setClip(animatableValueToLengthBox(value, state));
342 style->setHasClip(true);
344 case CSSPropertyColor:
345 style->setColor(toAnimatableColor(value)->color());
346 style->setVisitedLinkColor(toAnimatableColor(value)->visitedLinkColor());
348 case CSSPropertyFillOpacity:
349 style->setFillOpacity(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0, 1));
351 case CSSPropertyFill:
353 const AnimatableSVGPaint* svgPaint = toAnimatableSVGPaint(value);
354 style->accessSVGStyle()->setFillPaint(svgPaint->paintType(), svgPaint->color(), svgPaint->uri());
357 case CSSPropertyFlexGrow:
358 style->setFlexGrow(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0));
360 case CSSPropertyFlexShrink:
361 style->setFlexShrink(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0));
363 case CSSPropertyFlexBasis:
364 style->setFlexBasis(animatableValueToLength(value, state, ValueRangeNonNegative));
366 case CSSPropertyFloodColor:
367 style->setFloodColor(toAnimatableColor(value)->color());
369 case CSSPropertyFloodOpacity:
370 style->setFloodOpacity(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0, 1));
372 case CSSPropertyFontSize:
373 style->setFontSize(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0));
375 case CSSPropertyFontWeight:
376 style->setFontWeight(animatableValueToFontWeight(value));
378 case CSSPropertyHeight:
379 style->setHeight(animatableValueToLength(value, state, ValueRangeNonNegative));
381 case CSSPropertyLeft:
382 style->setLeft(animatableValueToLength(value, state));
384 case CSSPropertyLightingColor:
385 style->setLightingColor(toAnimatableColor(value)->color());
387 case CSSPropertyLineHeight:
388 if (value->isLength())
389 style->setLineHeight(animatableValueToLength(value, state, ValueRangeNonNegative));
391 style->setLineHeight(Length(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0), Percent));
393 case CSSPropertyListStyleImage:
394 style->setListStyleImage(state.styleImage(property, toAnimatableImage(value)->toCSSValue()));
396 case CSSPropertyLetterSpacing:
397 style->setLetterSpacing(clampTo<float>(toAnimatableDouble(value)->toDouble()));
399 case CSSPropertyMarginBottom:
400 style->setMarginBottom(animatableValueToLength(value, state));
402 case CSSPropertyMarginLeft:
403 style->setMarginLeft(animatableValueToLength(value, state));
405 case CSSPropertyMarginRight:
406 style->setMarginRight(animatableValueToLength(value, state));
408 case CSSPropertyMarginTop:
409 style->setMarginTop(animatableValueToLength(value, state));
411 case CSSPropertyMaxHeight:
412 style->setMaxHeight(animatableValueToLength(value, state, ValueRangeNonNegative));
414 case CSSPropertyMaxWidth:
415 style->setMaxWidth(animatableValueToLength(value, state, ValueRangeNonNegative));
417 case CSSPropertyMinHeight:
418 style->setMinHeight(animatableValueToLength(value, state, ValueRangeNonNegative));
420 case CSSPropertyMinWidth:
421 style->setMinWidth(animatableValueToLength(value, state, ValueRangeNonNegative));
423 case CSSPropertyObjectPosition:
424 style->setObjectPosition(animatableValueToLengthPoint(value, state));
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)));
430 case CSSPropertyOrphans:
431 style->setOrphans(animatableValueRoundClampTo<unsigned short>(value, 1));
433 case CSSPropertyOutlineColor:
434 style->setOutlineColor(toAnimatableColor(value)->color());
435 style->setVisitedLinkOutlineColor(toAnimatableColor(value)->visitedLinkColor());
437 case CSSPropertyOutlineOffset:
438 style->setOutlineOffset(animatableValueRoundClampTo<int>(value));
440 case CSSPropertyOutlineWidth:
441 style->setOutlineWidth(animatableValueRoundClampTo<unsigned short>(value));
443 case CSSPropertyPaddingBottom:
444 style->setPaddingBottom(animatableValueToLength(value, state, ValueRangeNonNegative));
446 case CSSPropertyPaddingLeft:
447 style->setPaddingLeft(animatableValueToLength(value, state, ValueRangeNonNegative));
449 case CSSPropertyPaddingRight:
450 style->setPaddingRight(animatableValueToLength(value, state, ValueRangeNonNegative));
452 case CSSPropertyPaddingTop:
453 style->setPaddingTop(animatableValueToLength(value, state, ValueRangeNonNegative));
455 case CSSPropertyRight:
456 style->setRight(animatableValueToLength(value, state));
458 case CSSPropertyStrokeWidth:
459 style->setStrokeWidth(animatableValueToNonNegativeSVGLength(value));
461 case CSSPropertyStopColor:
462 style->setStopColor(toAnimatableColor(value)->color());
464 case CSSPropertyStopOpacity:
465 style->setStopOpacity(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0, 1));
467 case CSSPropertyStrokeDasharray:
468 style->setStrokeDashArray(toAnimatableStrokeDasharrayList(value)->toSVGLengthList());
470 case CSSPropertyStrokeDashoffset:
471 style->setStrokeDashOffset(toAnimatableSVGLength(value)->toSVGLength());
473 case CSSPropertyStrokeMiterlimit:
474 style->setStrokeMiterLimit(clampTo<float>(toAnimatableDouble(value)->toDouble(), 1));
476 case CSSPropertyStrokeOpacity:
477 style->setStrokeOpacity(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0, 1));
479 case CSSPropertyStroke:
481 const AnimatableSVGPaint* svgPaint = toAnimatableSVGPaint(value);
482 style->accessSVGStyle()->setStrokePaint(svgPaint->paintType(), svgPaint->color(), svgPaint->uri());
485 case CSSPropertyTextDecorationColor:
486 style->setTextDecorationColor(toAnimatableColor(value)->color());
487 style->setVisitedLinkTextDecorationColor(toAnimatableColor(value)->visitedLinkColor());
489 case CSSPropertyTextIndent:
490 style->setTextIndent(animatableValueToLength(value, state));
492 case CSSPropertyTextShadow:
493 style->setTextShadow(toAnimatableShadow(value)->shadowList());
496 style->setTop(animatableValueToLength(value, state));
498 case CSSPropertyWebkitBackgroundSize:
499 setOnFillLayers<CSSPropertyWebkitBackgroundSize>(style->accessBackgroundLayers(), value, state);
501 case CSSPropertyWebkitBorderHorizontalSpacing:
502 style->setHorizontalBorderSpacing(animatableValueRoundClampTo<unsigned short>(value));
504 case CSSPropertyWebkitBorderVerticalSpacing:
505 style->setVerticalBorderSpacing(animatableValueRoundClampTo<unsigned short>(value));
507 case CSSPropertyWebkitClipPath:
508 style->setClipPath(toAnimatableClipPathOperation(value)->clipPathOperation());
510 case CSSPropertyWebkitColumnCount:
511 style->setColumnCount(animatableValueRoundClampTo<unsigned short>(value, 1));
513 case CSSPropertyWebkitColumnGap:
514 style->setColumnGap(clampTo(toAnimatableDouble(value)->toDouble(), 0));
516 case CSSPropertyWebkitColumnRuleColor:
517 style->setColumnRuleColor(toAnimatableColor(value)->color());
518 style->setVisitedLinkColumnRuleColor(toAnimatableColor(value)->visitedLinkColor());
520 case CSSPropertyWebkitColumnWidth:
521 style->setColumnWidth(clampTo(toAnimatableDouble(value)->toDouble(), std::numeric_limits<float>::epsilon()));
523 case CSSPropertyWebkitColumnRuleWidth:
524 style->setColumnRuleWidth(animatableValueRoundClampTo<unsigned short>(value));
526 case CSSPropertyWebkitFilter:
527 style->setFilter(toAnimatableFilterOperations(value)->operations());
529 case CSSPropertyWebkitMaskBoxImageOutset:
530 style->setMaskBoxImageOutset(animatableValueToBorderImageLengthBox(value, state));
532 case CSSPropertyWebkitMaskBoxImageSlice:
533 style->setMaskBoxImageSlices(animatableValueToLengthBox(toAnimatableLengthBoxAndBool(value)->box(), state, ValueRangeNonNegative));
534 style->setMaskBoxImageSlicesFill(toAnimatableLengthBoxAndBool(value)->flag());
536 case CSSPropertyWebkitMaskBoxImageSource:
537 style->setMaskBoxImageSource(state.styleImage(property, toAnimatableImage(value)->toCSSValue()));
539 case CSSPropertyWebkitMaskBoxImageWidth:
540 style->setMaskBoxImageWidth(animatableValueToBorderImageLengthBox(value, state));
542 case CSSPropertyWebkitMaskImage:
543 setOnFillLayers<CSSPropertyWebkitMaskImage>(style->accessMaskLayers(), value, state);
545 case CSSPropertyWebkitMaskPositionX:
546 setOnFillLayers<CSSPropertyWebkitMaskPositionX>(style->accessMaskLayers(), value, state);
548 case CSSPropertyWebkitMaskPositionY:
549 setOnFillLayers<CSSPropertyWebkitMaskPositionY>(style->accessMaskLayers(), value, state);
551 case CSSPropertyWebkitMaskSize:
552 setOnFillLayers<CSSPropertyWebkitMaskSize>(style->accessMaskLayers(), value, state);
554 case CSSPropertyPerspective:
555 style->setPerspective(clampTo<float>(toAnimatableDouble(value)->toDouble()));
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));
564 case CSSPropertyWebkitPerspectiveOriginX:
565 ASSERT(!RuntimeEnabledFeatures::cssTransformsUnprefixedEnabled());
566 style->setPerspectiveOriginX(animatableValueToLength(value, state));
568 case CSSPropertyWebkitPerspectiveOriginY:
569 ASSERT(!RuntimeEnabledFeatures::cssTransformsUnprefixedEnabled());
570 style->setPerspectiveOriginY(animatableValueToLength(value, state));
572 case CSSPropertyShapeOutside:
573 style->setShapeOutside(toAnimatableShapeValue(value)->shapeValue());
575 case CSSPropertyShapeMargin:
576 style->setShapeMargin(animatableValueToLength(value, state, ValueRangeNonNegative));
578 case CSSPropertyShapeImageThreshold:
579 style->setShapeImageThreshold(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0, 1));
581 case CSSPropertyWebkitTextStrokeColor:
582 style->setTextStrokeColor(toAnimatableColor(value)->color());
583 style->setVisitedLinkTextStrokeColor(toAnimatableColor(value)->visitedLinkColor());
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));
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()));
599 case CSSPropertyWebkitTransformOriginX:
600 ASSERT(!RuntimeEnabledFeatures::cssTransformsUnprefixedEnabled());
601 style->setTransformOriginX(animatableValueToLength(value, state));
603 case CSSPropertyWebkitTransformOriginY:
604 ASSERT(!RuntimeEnabledFeatures::cssTransformsUnprefixedEnabled());
605 style->setTransformOriginY(animatableValueToLength(value, state));
607 case CSSPropertyWebkitTransformOriginZ:
608 ASSERT(!RuntimeEnabledFeatures::cssTransformsUnprefixedEnabled());
609 style->setTransformOriginZ(toAnimatableDouble(value)->toDouble());
611 case CSSPropertyWidows:
612 style->setWidows(animatableValueRoundClampTo<unsigned short>(value, 1));
614 case CSSPropertyWidth:
615 style->setWidth(animatableValueToLength(value, state, ValueRangeNonNegative));
617 case CSSPropertyWordSpacing:
618 style->setWordSpacing(clampTo<float>(toAnimatableDouble(value)->toDouble()));
620 case CSSPropertyVisibility:
621 style->setVisibility(toAnimatableVisibility(value)->visibility());
623 case CSSPropertyZIndex:
624 style->setZIndex(animatableValueRoundClampTo<int>(value));
626 case CSSPropertyZoom:
627 style->setZoom(clampTo<float>(toAnimatableDouble(value)->toDouble(), std::numeric_limits<float>::denorm_min()));
630 ASSERT_NOT_REACHED();
634 } // namespace WebCore