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/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"
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 void setFillSize(FillLayer* fillLayer, const AnimatableValue* value, const StyleResolverState& state)
131 if (value->isLengthSize())
132 fillLayer->setSize(FillSize(SizeLength, animatableValueToLengthSize(value, state, ValueRangeNonNegative)));
134 state.styleMap().mapFillSize(fillLayer, toAnimatableUnknown(value)->toCSSValue().get());
137 PassRefPtr<SVGLength> animatableValueToNonNegativeSVGLength(const AnimatableValue* value)
139 RefPtr<SVGLength> length = toAnimatableSVGLength(value)->toSVGLength();
140 if (length->valueInSpecifiedUnits() < 0)
141 length->setValueInSpecifiedUnits(0);
142 return length.release();
145 template <CSSPropertyID property>
146 void setOnFillLayers(FillLayer& fillLayers, const AnimatableValue* value, StyleResolverState& state)
148 const WillBeHeapVector<RefPtrWillBeMember<AnimatableValue> >& values = toAnimatableRepeatable(value)->values();
149 ASSERT(!values.isEmpty());
150 FillLayer* fillLayer = &fillLayers;
152 for (size_t i = 0; i < values.size(); ++i) {
154 fillLayer = prev->ensureNext();
155 const AnimatableValue* layerValue = values[i].get();
157 case CSSPropertyBackgroundImage:
158 case CSSPropertyWebkitMaskImage:
159 if (layerValue->isImage()) {
160 fillLayer->setImage(state.styleImage(property, toAnimatableImage(layerValue)->toCSSValue()));
162 ASSERT(toAnimatableUnknown(layerValue)->toCSSValueID() == CSSValueNone);
163 fillLayer->setImage(nullptr);
166 case CSSPropertyBackgroundPositionX:
167 case CSSPropertyWebkitMaskPositionX:
168 fillLayer->setXPosition(animatableValueToLength(layerValue, state));
170 case CSSPropertyBackgroundPositionY:
171 case CSSPropertyWebkitMaskPositionY:
172 fillLayer->setYPosition(animatableValueToLength(layerValue, state));
174 case CSSPropertyBackgroundSize:
175 case CSSPropertyWebkitBackgroundSize:
176 case CSSPropertyWebkitMaskSize:
177 setFillSize(fillLayer, layerValue, state);
180 ASSERT_NOT_REACHED();
183 fillLayer = fillLayer->next();
187 case CSSPropertyBackgroundImage:
188 case CSSPropertyWebkitMaskImage:
189 fillLayer->clearImage();
191 case CSSPropertyBackgroundPositionX:
192 case CSSPropertyWebkitMaskPositionX:
193 fillLayer->clearXPosition();
195 case CSSPropertyBackgroundPositionY:
196 case CSSPropertyWebkitMaskPositionY:
197 fillLayer->clearYPosition();
199 case CSSPropertyBackgroundSize:
200 case CSSPropertyWebkitBackgroundSize:
201 case CSSPropertyWebkitMaskSize:
202 fillLayer->clearSize();
205 ASSERT_NOT_REACHED();
207 fillLayer = fillLayer->next();
211 FontStretch animatableValueToFontStretch(const AnimatableValue* value)
213 ASSERT(FontStretchUltraCondensed == 1 && FontStretchUltraExpanded == 9);
214 unsigned index = round(toAnimatableDouble(value)->toDouble()) - 1;
215 static const FontStretch stretchValues[] = {
216 FontStretchUltraCondensed,
217 FontStretchExtraCondensed,
218 FontStretchCondensed,
219 FontStretchSemiCondensed,
221 FontStretchSemiExpanded,
223 FontStretchExtraExpanded,
224 FontStretchUltraExpanded
227 index = clampTo<unsigned>(index, 0, WTF_ARRAY_LENGTH(stretchValues) - 1);
228 return stretchValues[index];
231 FontWeight animatableValueToFontWeight(const AnimatableValue* value)
233 int index = round(toAnimatableDouble(value)->toDouble() / 100) - 1;
235 static const FontWeight weights[] = {
247 index = clampTo<int>(index, 0, WTF_ARRAY_LENGTH(weights) - 1);
249 return weights[index];
254 // FIXME: Generate this function.
255 void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, StyleResolverState& state, const AnimatableValue* value)
257 ASSERT(CSSPropertyMetadata::isAnimatableProperty(property));
258 if (value->isUnknown()) {
259 StyleBuilder::applyProperty(property, state, toAnimatableUnknown(value)->toCSSValue().get());
262 RenderStyle* style = state.style();
264 case CSSPropertyBackgroundColor:
265 style->setBackgroundColor(toAnimatableColor(value)->color());
266 style->setVisitedLinkBackgroundColor(toAnimatableColor(value)->visitedLinkColor());
268 case CSSPropertyBackgroundImage:
269 setOnFillLayers<CSSPropertyBackgroundImage>(style->accessBackgroundLayers(), value, state);
271 case CSSPropertyBackgroundPositionX:
272 setOnFillLayers<CSSPropertyBackgroundPositionX>(style->accessBackgroundLayers(), value, state);
274 case CSSPropertyBackgroundPositionY:
275 setOnFillLayers<CSSPropertyBackgroundPositionY>(style->accessBackgroundLayers(), value, state);
277 case CSSPropertyBackgroundSize:
278 setOnFillLayers<CSSPropertyBackgroundSize>(style->accessBackgroundLayers(), value, state);
280 case CSSPropertyBaselineShift:
281 style->setBaselineShiftValue(toAnimatableSVGLength(value)->toSVGLength());
283 case CSSPropertyBorderBottomColor:
284 style->setBorderBottomColor(toAnimatableColor(value)->color());
285 style->setVisitedLinkBorderBottomColor(toAnimatableColor(value)->visitedLinkColor());
287 case CSSPropertyBorderBottomLeftRadius:
288 style->setBorderBottomLeftRadius(animatableValueToLengthSize(value, state, ValueRangeNonNegative));
290 case CSSPropertyBorderBottomRightRadius:
291 style->setBorderBottomRightRadius(animatableValueToLengthSize(value, state, ValueRangeNonNegative));
293 case CSSPropertyBorderBottomWidth:
294 style->setBorderBottomWidth(animatableValueRoundClampTo<unsigned>(value));
296 case CSSPropertyBorderImageOutset:
297 style->setBorderImageOutset(animatableValueToBorderImageLengthBox(value, state));
299 case CSSPropertyBorderImageSlice:
300 style->setBorderImageSlices(animatableValueToLengthBox(value, state, ValueRangeNonNegative));
302 case CSSPropertyBorderImageSource:
303 style->setBorderImageSource(state.styleImage(property, toAnimatableImage(value)->toCSSValue()));
305 case CSSPropertyBorderImageWidth:
306 style->setBorderImageWidth(animatableValueToBorderImageLengthBox(value, state));
308 case CSSPropertyBorderLeftColor:
309 style->setBorderLeftColor(toAnimatableColor(value)->color());
310 style->setVisitedLinkBorderLeftColor(toAnimatableColor(value)->visitedLinkColor());
312 case CSSPropertyBorderLeftWidth:
313 style->setBorderLeftWidth(animatableValueRoundClampTo<unsigned>(value));
315 case CSSPropertyBorderRightColor:
316 style->setBorderRightColor(toAnimatableColor(value)->color());
317 style->setVisitedLinkBorderRightColor(toAnimatableColor(value)->visitedLinkColor());
319 case CSSPropertyBorderRightWidth:
320 style->setBorderRightWidth(animatableValueRoundClampTo<unsigned>(value));
322 case CSSPropertyBorderTopColor:
323 style->setBorderTopColor(toAnimatableColor(value)->color());
324 style->setVisitedLinkBorderTopColor(toAnimatableColor(value)->visitedLinkColor());
326 case CSSPropertyBorderTopLeftRadius:
327 style->setBorderTopLeftRadius(animatableValueToLengthSize(value, state, ValueRangeNonNegative));
329 case CSSPropertyBorderTopRightRadius:
330 style->setBorderTopRightRadius(animatableValueToLengthSize(value, state, ValueRangeNonNegative));
332 case CSSPropertyBorderTopWidth:
333 style->setBorderTopWidth(animatableValueRoundClampTo<unsigned>(value));
335 case CSSPropertyBottom:
336 style->setBottom(animatableValueToLength(value, state));
338 case CSSPropertyBoxShadow:
339 case CSSPropertyWebkitBoxShadow:
340 style->setBoxShadow(toAnimatableShadow(value)->shadowList());
342 case CSSPropertyClip:
343 style->setClip(animatableValueToLengthBox(value, state));
345 case CSSPropertyColor:
346 style->setColor(toAnimatableColor(value)->color());
347 style->setVisitedLinkColor(toAnimatableColor(value)->visitedLinkColor());
349 case CSSPropertyFillOpacity:
350 style->setFillOpacity(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0, 1));
352 case CSSPropertyFill:
354 const AnimatableSVGPaint* svgPaint = toAnimatableSVGPaint(value);
355 style->accessSVGStyle().setFillPaint(svgPaint->paintType(), svgPaint->color(), svgPaint->uri(), true, false);
356 style->accessSVGStyle().setFillPaint(svgPaint->visitedLinkPaintType(), svgPaint->visitedLinkColor(), svgPaint->visitedLinkURI(), false, true);
359 case CSSPropertyFlexGrow:
360 style->setFlexGrow(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0));
362 case CSSPropertyFlexShrink:
363 style->setFlexShrink(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0));
365 case CSSPropertyFlexBasis:
366 style->setFlexBasis(animatableValueToLength(value, state, ValueRangeNonNegative));
368 case CSSPropertyFloodColor:
369 style->setFloodColor(toAnimatableColor(value)->color());
371 case CSSPropertyFloodOpacity:
372 style->setFloodOpacity(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0, 1));
374 case CSSPropertyFontSize:
375 style->setFontSize(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0));
377 case CSSPropertyFontStretch:
378 style->setFontStretch(animatableValueToFontStretch(value));
380 case CSSPropertyFontWeight:
381 style->setFontWeight(animatableValueToFontWeight(value));
383 case CSSPropertyHeight:
384 style->setHeight(animatableValueToLength(value, state, ValueRangeNonNegative));
386 case CSSPropertyLeft:
387 style->setLeft(animatableValueToLength(value, state));
389 case CSSPropertyLightingColor:
390 style->setLightingColor(toAnimatableColor(value)->color());
392 case CSSPropertyLineHeight:
393 if (value->isLength())
394 style->setLineHeight(animatableValueToLength(value, state, ValueRangeNonNegative));
396 style->setLineHeight(Length(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0), Percent));
398 case CSSPropertyListStyleImage:
399 style->setListStyleImage(state.styleImage(property, toAnimatableImage(value)->toCSSValue()));
401 case CSSPropertyLetterSpacing:
402 style->setLetterSpacing(clampTo<float>(toAnimatableDouble(value)->toDouble()));
404 case CSSPropertyMarginBottom:
405 style->setMarginBottom(animatableValueToLength(value, state));
407 case CSSPropertyMarginLeft:
408 style->setMarginLeft(animatableValueToLength(value, state));
410 case CSSPropertyMarginRight:
411 style->setMarginRight(animatableValueToLength(value, state));
413 case CSSPropertyMarginTop:
414 style->setMarginTop(animatableValueToLength(value, state));
416 case CSSPropertyMaxHeight:
417 style->setMaxHeight(animatableValueToLength(value, state, ValueRangeNonNegative));
419 case CSSPropertyMaxWidth:
420 style->setMaxWidth(animatableValueToLength(value, state, ValueRangeNonNegative));
422 case CSSPropertyMinHeight:
423 style->setMinHeight(animatableValueToLength(value, state, ValueRangeNonNegative));
425 case CSSPropertyMinWidth:
426 style->setMinWidth(animatableValueToLength(value, state, ValueRangeNonNegative));
428 case CSSPropertyObjectPosition:
429 style->setObjectPosition(animatableValueToLengthPoint(value, state));
431 case CSSPropertyOpacity:
432 // Avoiding a value of 1 forces a layer to be created.
433 style->setOpacity(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0, nextafterf(1, 0)));
435 case CSSPropertyOrphans:
436 style->setOrphans(animatableValueRoundClampTo<unsigned short>(value, 1));
438 case CSSPropertyOutlineColor:
439 style->setOutlineColor(toAnimatableColor(value)->color());
440 style->setVisitedLinkOutlineColor(toAnimatableColor(value)->visitedLinkColor());
442 case CSSPropertyOutlineOffset:
443 style->setOutlineOffset(animatableValueRoundClampTo<int>(value));
445 case CSSPropertyOutlineWidth:
446 style->setOutlineWidth(animatableValueRoundClampTo<unsigned short>(value));
448 case CSSPropertyPaddingBottom:
449 style->setPaddingBottom(animatableValueToLength(value, state, ValueRangeNonNegative));
451 case CSSPropertyPaddingLeft:
452 style->setPaddingLeft(animatableValueToLength(value, state, ValueRangeNonNegative));
454 case CSSPropertyPaddingRight:
455 style->setPaddingRight(animatableValueToLength(value, state, ValueRangeNonNegative));
457 case CSSPropertyPaddingTop:
458 style->setPaddingTop(animatableValueToLength(value, state, ValueRangeNonNegative));
460 case CSSPropertyRight:
461 style->setRight(animatableValueToLength(value, state));
463 case CSSPropertyStrokeWidth:
464 style->setStrokeWidth(animatableValueToNonNegativeSVGLength(value));
466 case CSSPropertyStopColor:
467 style->setStopColor(toAnimatableColor(value)->color());
469 case CSSPropertyStopOpacity:
470 style->setStopOpacity(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0, 1));
472 case CSSPropertyStrokeDasharray:
473 style->setStrokeDashArray(toAnimatableStrokeDasharrayList(value)->toSVGLengthList());
475 case CSSPropertyStrokeDashoffset:
476 style->setStrokeDashOffset(toAnimatableSVGLength(value)->toSVGLength());
478 case CSSPropertyStrokeMiterlimit:
479 style->setStrokeMiterLimit(clampTo<float>(toAnimatableDouble(value)->toDouble(), 1));
481 case CSSPropertyStrokeOpacity:
482 style->setStrokeOpacity(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0, 1));
484 case CSSPropertyStroke:
486 const AnimatableSVGPaint* svgPaint = toAnimatableSVGPaint(value);
487 style->accessSVGStyle().setStrokePaint(svgPaint->paintType(), svgPaint->color(), svgPaint->uri(), true, false);
488 style->accessSVGStyle().setStrokePaint(svgPaint->visitedLinkPaintType(), svgPaint->visitedLinkColor(), svgPaint->visitedLinkURI(), false, true);
491 case CSSPropertyTextDecorationColor:
492 style->setTextDecorationColor(toAnimatableColor(value)->color());
493 style->setVisitedLinkTextDecorationColor(toAnimatableColor(value)->visitedLinkColor());
495 case CSSPropertyTextIndent:
496 style->setTextIndent(animatableValueToLength(value, state));
498 case CSSPropertyTextShadow:
499 style->setTextShadow(toAnimatableShadow(value)->shadowList());
502 style->setTop(animatableValueToLength(value, state));
504 case CSSPropertyWebkitBackgroundSize:
505 setOnFillLayers<CSSPropertyWebkitBackgroundSize>(style->accessBackgroundLayers(), value, state);
507 case CSSPropertyWebkitBorderHorizontalSpacing:
508 style->setHorizontalBorderSpacing(animatableValueRoundClampTo<unsigned short>(value));
510 case CSSPropertyWebkitBorderVerticalSpacing:
511 style->setVerticalBorderSpacing(animatableValueRoundClampTo<unsigned short>(value));
513 case CSSPropertyWebkitClipPath:
514 style->setClipPath(toAnimatableClipPathOperation(value)->clipPathOperation());
516 case CSSPropertyWebkitColumnCount:
517 style->setColumnCount(animatableValueRoundClampTo<unsigned short>(value, 1));
519 case CSSPropertyWebkitColumnGap:
520 style->setColumnGap(clampTo(toAnimatableDouble(value)->toDouble(), 0));
522 case CSSPropertyWebkitColumnRuleColor:
523 style->setColumnRuleColor(toAnimatableColor(value)->color());
524 style->setVisitedLinkColumnRuleColor(toAnimatableColor(value)->visitedLinkColor());
526 case CSSPropertyWebkitColumnWidth:
527 style->setColumnWidth(clampTo(toAnimatableDouble(value)->toDouble(), std::numeric_limits<float>::epsilon()));
529 case CSSPropertyWebkitColumnRuleWidth:
530 style->setColumnRuleWidth(animatableValueRoundClampTo<unsigned short>(value));
532 case CSSPropertyWebkitFilter:
533 style->setFilter(toAnimatableFilterOperations(value)->operations());
535 case CSSPropertyWebkitMaskBoxImageOutset:
536 style->setMaskBoxImageOutset(animatableValueToBorderImageLengthBox(value, state));
538 case CSSPropertyWebkitMaskBoxImageSlice:
539 style->setMaskBoxImageSlices(animatableValueToLengthBox(toAnimatableLengthBoxAndBool(value)->box(), state, ValueRangeNonNegative));
540 style->setMaskBoxImageSlicesFill(toAnimatableLengthBoxAndBool(value)->flag());
542 case CSSPropertyWebkitMaskBoxImageSource:
543 style->setMaskBoxImageSource(state.styleImage(property, toAnimatableImage(value)->toCSSValue()));
545 case CSSPropertyWebkitMaskBoxImageWidth:
546 style->setMaskBoxImageWidth(animatableValueToBorderImageLengthBox(value, state));
548 case CSSPropertyWebkitMaskImage:
549 setOnFillLayers<CSSPropertyWebkitMaskImage>(style->accessMaskLayers(), value, state);
551 case CSSPropertyWebkitMaskPositionX:
552 setOnFillLayers<CSSPropertyWebkitMaskPositionX>(style->accessMaskLayers(), value, state);
554 case CSSPropertyWebkitMaskPositionY:
555 setOnFillLayers<CSSPropertyWebkitMaskPositionY>(style->accessMaskLayers(), value, state);
557 case CSSPropertyWebkitMaskSize:
558 setOnFillLayers<CSSPropertyWebkitMaskSize>(style->accessMaskLayers(), value, state);
560 case CSSPropertyPerspective:
561 style->setPerspective(clampTo<float>(toAnimatableDouble(value)->toDouble()));
563 case CSSPropertyPerspectiveOrigin: {
564 const AnimatableLengthPoint* animatableLengthPoint = toAnimatableLengthPoint(value);
565 style->setPerspectiveOriginX(animatableValueToLength(animatableLengthPoint->x(), state));
566 style->setPerspectiveOriginY(animatableValueToLength(animatableLengthPoint->y(), state));
569 case CSSPropertyShapeOutside:
570 style->setShapeOutside(toAnimatableShapeValue(value)->shapeValue());
572 case CSSPropertyShapeMargin:
573 style->setShapeMargin(animatableValueToLength(value, state, ValueRangeNonNegative));
575 case CSSPropertyShapeImageThreshold:
576 style->setShapeImageThreshold(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0, 1));
578 case CSSPropertyWebkitTextStrokeColor:
579 style->setTextStrokeColor(toAnimatableColor(value)->color());
580 style->setVisitedLinkTextStrokeColor(toAnimatableColor(value)->visitedLinkColor());
582 case CSSPropertyTransform: {
583 const TransformOperations& operations = toAnimatableTransform(value)->transformOperations();
584 // FIXME: This normalization (handling of 'none') should be performed at input in AnimatableValueFactory.
585 style->setTransform(operations.size() ? operations : TransformOperations(true));
588 case CSSPropertyTransformOrigin: {
589 const AnimatableLengthPoint3D* animatableLengthPoint3D = toAnimatableLengthPoint3D(value);
590 style->setTransformOriginX(animatableValueToLength(animatableLengthPoint3D->x(), state));
591 style->setTransformOriginY(animatableValueToLength(animatableLengthPoint3D->y(), state));
592 style->setTransformOriginZ(clampTo<float>(toAnimatableDouble(animatableLengthPoint3D->z())->toDouble()));
595 case CSSPropertyWidows:
596 style->setWidows(animatableValueRoundClampTo<unsigned short>(value, 1));
598 case CSSPropertyWidth:
599 style->setWidth(animatableValueToLength(value, state, ValueRangeNonNegative));
601 case CSSPropertyWordSpacing:
602 style->setWordSpacing(clampTo<float>(toAnimatableDouble(value)->toDouble()));
604 case CSSPropertyVerticalAlign:
605 style->setVerticalAlignLength(animatableValueToLength(value, state));
607 case CSSPropertyVisibility:
608 style->setVisibility(toAnimatableVisibility(value)->visibility());
610 case CSSPropertyZIndex:
611 style->setZIndex(animatableValueRoundClampTo<int>(value));
613 case CSSPropertyZoom:
614 style->setZoom(clampTo<float>(toAnimatableDouble(value)->toDouble(), std::numeric_limits<float>::denorm_min()));
617 ASSERT_NOT_REACHED();