OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 Length animatableValueToLength(const AnimatableValue* value, const StyleResolver
State& state, NumberRange range = AllValues) | 66 Length animatableValueToLength(const AnimatableValue* value, const StyleResolver
State& state, NumberRange range = AllValues) |
67 { | 67 { |
68 const RenderStyle* style = state.style(); | 68 const RenderStyle* style = state.style(); |
69 if (value->isLength()) | 69 if (value->isLength()) |
70 return toAnimatableLength(value)->toLength(style, state.rootElementStyle
(), style->effectiveZoom(), range); | 70 return toAnimatableLength(value)->toLength(style, state.rootElementStyle
(), style->effectiveZoom(), range); |
71 RefPtr<CSSValue> cssValue = toAnimatableUnknown(value)->toCSSValue(); | 71 RefPtr<CSSValue> cssValue = toAnimatableUnknown(value)->toCSSValue(); |
72 CSSPrimitiveValue* cssPrimitiveValue = toCSSPrimitiveValue(cssValue.get()); | 72 CSSPrimitiveValue* cssPrimitiveValue = toCSSPrimitiveValue(cssValue.get()); |
73 return cssPrimitiveValue->convertToLength<AnyConversion>(style, state.rootEl
ementStyle(), style->effectiveZoom()); | 73 return cssPrimitiveValue->convertToLength<AnyConversion>(style, state.rootEl
ementStyle(), style->effectiveZoom()); |
74 } | 74 } |
75 | 75 |
76 BorderImageLength animatableValueToBorderImageLength(const AnimatableValue* valu
e, const StyleResolverState& state, NumberRange range = AllValues) | 76 BorderImageLength animatableValueToBorderImageLength(const AnimatableValue* valu
e, const StyleResolverState& state) |
77 { | 77 { |
78 const RenderStyle* style = state.style(); | 78 const RenderStyle* style = state.style(); |
79 if (value->isLength()) | 79 if (value->isLength()) |
80 return BorderImageLength(toAnimatableLength(value)->toLength(style, stat
e.rootElementStyle(), style->effectiveZoom(), range)); | 80 return BorderImageLength(toAnimatableLength(value)->toLength(style, stat
e.rootElementStyle(), style->effectiveZoom(), NonNegativeValues)); |
81 if (value->isDouble()) | 81 if (value->isDouble()) |
82 return BorderImageLength(toAnimatableDouble(value)->toDouble()); | 82 return BorderImageLength(clampTo<double>(toAnimatableDouble(value)->toDo
uble(), 0)); |
83 RefPtr<CSSValue> cssValue = toAnimatableUnknown(value)->toCSSValue(); | 83 RefPtr<CSSValue> cssValue = toAnimatableUnknown(value)->toCSSValue(); |
84 CSSPrimitiveValue* cssPrimitiveValue = toCSSPrimitiveValue(cssValue.get()); | 84 CSSPrimitiveValue* cssPrimitiveValue = toCSSPrimitiveValue(cssValue.get()); |
85 return BorderImageLength(cssPrimitiveValue->convertToLength<AnyConversion>(s
tyle, state.rootElementStyle(), style->effectiveZoom())); | 85 return BorderImageLength(cssPrimitiveValue->convertToLength<AnyConversion>(s
tyle, state.rootElementStyle(), style->effectiveZoom())); |
86 } | 86 } |
87 | 87 |
88 template<typename T> T animatableValueRoundClampTo(const AnimatableValue* value,
T min = defaultMinimumForClamp<T>(), T max = defaultMaximumForClamp<T>()) | 88 template<typename T> T animatableValueRoundClampTo(const AnimatableValue* value,
T min = defaultMinimumForClamp<T>(), T max = defaultMaximumForClamp<T>()) |
89 { | 89 { |
90 COMPILE_ASSERT(WTF::IsInteger<T>::value, ShouldUseIntegralTypeTWhenRoundingV
alues); | 90 COMPILE_ASSERT(WTF::IsInteger<T>::value, ShouldUseIntegralTypeTWhenRoundingV
alues); |
91 return clampTo<T>(round(toAnimatableDouble(value)->toDouble()), min, max); | 91 return clampTo<T>(round(toAnimatableDouble(value)->toDouble()), min, max); |
92 } | 92 } |
93 | 93 |
94 LengthBox animatableValueToLengthBox(const AnimatableValue* value, const StyleRe
solverState& state, NumberRange range = AllValues) | 94 LengthBox animatableValueToLengthBox(const AnimatableValue* value, const StyleRe
solverState& state, NumberRange range = AllValues) |
95 { | 95 { |
96 const AnimatableLengthBox* animatableLengthBox = toAnimatableLengthBox(value
); | 96 const AnimatableLengthBox* animatableLengthBox = toAnimatableLengthBox(value
); |
97 return LengthBox( | 97 return LengthBox( |
98 animatableValueToLength(animatableLengthBox->top(), state, range), | 98 animatableValueToLength(animatableLengthBox->top(), state, range), |
99 animatableValueToLength(animatableLengthBox->right(), state, range), | 99 animatableValueToLength(animatableLengthBox->right(), state, range), |
100 animatableValueToLength(animatableLengthBox->bottom(), state, range), | 100 animatableValueToLength(animatableLengthBox->bottom(), state, range), |
101 animatableValueToLength(animatableLengthBox->left(), state, range)); | 101 animatableValueToLength(animatableLengthBox->left(), state, range)); |
102 } | 102 } |
103 | 103 |
104 BorderImageLengthBox animatableValueToBorderImageLengthBox(const AnimatableValue
* value, const StyleResolverState& state, NumberRange range = AllValues) | 104 BorderImageLengthBox animatableValueToBorderImageLengthBox(const AnimatableValue
* value, const StyleResolverState& state) |
105 { | 105 { |
106 const AnimatableLengthBox* animatableLengthBox = toAnimatableLengthBox(value
); | 106 const AnimatableLengthBox* animatableLengthBox = toAnimatableLengthBox(value
); |
107 return BorderImageLengthBox( | 107 return BorderImageLengthBox( |
108 animatableValueToBorderImageLength(animatableLengthBox->top(), state, ra
nge), | 108 animatableValueToBorderImageLength(animatableLengthBox->top(), state), |
109 animatableValueToBorderImageLength(animatableLengthBox->right(), state,
range), | 109 animatableValueToBorderImageLength(animatableLengthBox->right(), state), |
110 animatableValueToBorderImageLength(animatableLengthBox->bottom(), state,
range), | 110 animatableValueToBorderImageLength(animatableLengthBox->bottom(), state)
, |
111 animatableValueToBorderImageLength(animatableLengthBox->left(), state, r
ange)); | 111 animatableValueToBorderImageLength(animatableLengthBox->left(), state)); |
112 } | 112 } |
113 | 113 |
114 LengthPoint animatableValueToLengthPoint(const AnimatableValue* value, const Sty
leResolverState& state, NumberRange range = AllValues) | 114 LengthPoint animatableValueToLengthPoint(const AnimatableValue* value, const Sty
leResolverState& state, NumberRange range = AllValues) |
115 { | 115 { |
116 const AnimatableLengthPoint* animatableLengthPoint = toAnimatableLengthPoint
(value); | 116 const AnimatableLengthPoint* animatableLengthPoint = toAnimatableLengthPoint
(value); |
117 return LengthPoint( | 117 return LengthPoint( |
118 animatableValueToLength(animatableLengthPoint->x(), state, range), | 118 animatableValueToLength(animatableLengthPoint->x(), state, range), |
119 animatableValueToLength(animatableLengthPoint->y(), state, range)); | 119 animatableValueToLength(animatableLengthPoint->y(), state, range)); |
120 } | 120 } |
121 | 121 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 case CSSPropertyBorderBottomLeftRadius: | 264 case CSSPropertyBorderBottomLeftRadius: |
265 style->setBorderBottomLeftRadius(animatableValueToLengthSize(value, stat
e, NonNegativeValues)); | 265 style->setBorderBottomLeftRadius(animatableValueToLengthSize(value, stat
e, NonNegativeValues)); |
266 return; | 266 return; |
267 case CSSPropertyBorderBottomRightRadius: | 267 case CSSPropertyBorderBottomRightRadius: |
268 style->setBorderBottomRightRadius(animatableValueToLengthSize(value, sta
te, NonNegativeValues)); | 268 style->setBorderBottomRightRadius(animatableValueToLengthSize(value, sta
te, NonNegativeValues)); |
269 return; | 269 return; |
270 case CSSPropertyBorderBottomWidth: | 270 case CSSPropertyBorderBottomWidth: |
271 style->setBorderBottomWidth(animatableValueRoundClampTo<unsigned>(value)
); | 271 style->setBorderBottomWidth(animatableValueRoundClampTo<unsigned>(value)
); |
272 return; | 272 return; |
273 case CSSPropertyBorderImageOutset: | 273 case CSSPropertyBorderImageOutset: |
274 style->setBorderImageOutset(animatableValueToBorderImageLengthBox(value,
state, NonNegativeValues)); | 274 style->setBorderImageOutset(animatableValueToBorderImageLengthBox(value,
state)); |
275 return; | 275 return; |
276 case CSSPropertyBorderImageSlice: | 276 case CSSPropertyBorderImageSlice: |
277 style->setBorderImageSlices(animatableValueToLengthBox(value, state, Non
NegativeValues)); | 277 style->setBorderImageSlices(animatableValueToLengthBox(value, state, Non
NegativeValues)); |
278 return; | 278 return; |
279 case CSSPropertyBorderImageSource: | 279 case CSSPropertyBorderImageSource: |
280 style->setBorderImageSource(toAnimatableImage(value)->toStyleImage()); | 280 style->setBorderImageSource(toAnimatableImage(value)->toStyleImage()); |
281 return; | 281 return; |
282 case CSSPropertyBorderImageWidth: | 282 case CSSPropertyBorderImageWidth: |
283 style->setBorderImageWidth(animatableValueToBorderImageLengthBox(value,
state, NonNegativeValues)); | 283 style->setBorderImageWidth(animatableValueToBorderImageLengthBox(value,
state)); |
284 return; | 284 return; |
285 case CSSPropertyBorderLeftColor: | 285 case CSSPropertyBorderLeftColor: |
286 style->setBorderLeftColor(toAnimatableColor(value)->color()); | 286 style->setBorderLeftColor(toAnimatableColor(value)->color()); |
287 style->setVisitedLinkBorderLeftColor(toAnimatableColor(value)->visitedLi
nkColor()); | 287 style->setVisitedLinkBorderLeftColor(toAnimatableColor(value)->visitedLi
nkColor()); |
288 return; | 288 return; |
289 case CSSPropertyBorderLeftWidth: | 289 case CSSPropertyBorderLeftWidth: |
290 style->setBorderLeftWidth(animatableValueRoundClampTo<unsigned>(value)); | 290 style->setBorderLeftWidth(animatableValueRoundClampTo<unsigned>(value)); |
291 return; | 291 return; |
292 case CSSPropertyBorderRightColor: | 292 case CSSPropertyBorderRightColor: |
293 style->setBorderRightColor(toAnimatableColor(value)->color()); | 293 style->setBorderRightColor(toAnimatableColor(value)->color()); |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 case CSSPropertyWebkitColumnWidth: | 498 case CSSPropertyWebkitColumnWidth: |
499 style->setColumnWidth(clampTo(toAnimatableDouble(value)->toDouble(), std
::numeric_limits<float>::epsilon())); | 499 style->setColumnWidth(clampTo(toAnimatableDouble(value)->toDouble(), std
::numeric_limits<float>::epsilon())); |
500 return; | 500 return; |
501 case CSSPropertyWebkitColumnRuleWidth: | 501 case CSSPropertyWebkitColumnRuleWidth: |
502 style->setColumnRuleWidth(animatableValueRoundClampTo<unsigned short>(va
lue)); | 502 style->setColumnRuleWidth(animatableValueRoundClampTo<unsigned short>(va
lue)); |
503 return; | 503 return; |
504 case CSSPropertyWebkitFilter: | 504 case CSSPropertyWebkitFilter: |
505 style->setFilter(toAnimatableFilterOperations(value)->operations()); | 505 style->setFilter(toAnimatableFilterOperations(value)->operations()); |
506 return; | 506 return; |
507 case CSSPropertyWebkitMaskBoxImageOutset: | 507 case CSSPropertyWebkitMaskBoxImageOutset: |
508 style->setMaskBoxImageOutset(animatableValueToBorderImageLengthBox(value
, state, NonNegativeValues)); | 508 style->setMaskBoxImageOutset(animatableValueToBorderImageLengthBox(value
, state)); |
509 return; | 509 return; |
510 case CSSPropertyWebkitMaskBoxImageSlice: | 510 case CSSPropertyWebkitMaskBoxImageSlice: |
511 style->setMaskBoxImageSlices(animatableValueToLengthBox(toAnimatableLeng
thBoxAndBool(value)->box(), state, NonNegativeValues)); | 511 style->setMaskBoxImageSlices(animatableValueToLengthBox(toAnimatableLeng
thBoxAndBool(value)->box(), state, NonNegativeValues)); |
512 style->setMaskBoxImageSlicesFill(toAnimatableLengthBoxAndBool(value)->fl
ag()); | 512 style->setMaskBoxImageSlicesFill(toAnimatableLengthBoxAndBool(value)->fl
ag()); |
513 return; | 513 return; |
514 case CSSPropertyWebkitMaskBoxImageSource: | 514 case CSSPropertyWebkitMaskBoxImageSource: |
515 style->setMaskBoxImageSource(toAnimatableImage(value)->toStyleImage()); | 515 style->setMaskBoxImageSource(toAnimatableImage(value)->toStyleImage()); |
516 return; | 516 return; |
517 case CSSPropertyWebkitMaskBoxImageWidth: | 517 case CSSPropertyWebkitMaskBoxImageWidth: |
518 style->setMaskBoxImageWidth(animatableValueToBorderImageLengthBox(value,
state, NonNegativeValues)); | 518 style->setMaskBoxImageWidth(animatableValueToBorderImageLengthBox(value,
state)); |
519 return; | 519 return; |
520 case CSSPropertyWebkitMaskImage: | 520 case CSSPropertyWebkitMaskImage: |
521 setOnFillLayers<CSSPropertyWebkitMaskImage>(style->accessMaskLayers(), v
alue, state); | 521 setOnFillLayers<CSSPropertyWebkitMaskImage>(style->accessMaskLayers(), v
alue, state); |
522 return; | 522 return; |
523 case CSSPropertyWebkitMaskPositionX: | 523 case CSSPropertyWebkitMaskPositionX: |
524 setOnFillLayers<CSSPropertyWebkitMaskPositionX>(style->accessMaskLayers(
), value, state); | 524 setOnFillLayers<CSSPropertyWebkitMaskPositionX>(style->accessMaskLayers(
), value, state); |
525 return; | 525 return; |
526 case CSSPropertyWebkitMaskPositionY: | 526 case CSSPropertyWebkitMaskPositionY: |
527 setOnFillLayers<CSSPropertyWebkitMaskPositionY>(style->accessMaskLayers(
), value, state); | 527 setOnFillLayers<CSSPropertyWebkitMaskPositionY>(style->accessMaskLayers(
), value, state); |
528 return; | 528 return; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 case CSSPropertyZoom: | 581 case CSSPropertyZoom: |
582 style->setZoom(clampTo<float>(toAnimatableDouble(value)->toDouble(), std
::numeric_limits<float>::denorm_min())); | 582 style->setZoom(clampTo<float>(toAnimatableDouble(value)->toDouble(), std
::numeric_limits<float>::denorm_min())); |
583 return; | 583 return; |
584 default: | 584 default: |
585 ASSERT_WITH_MESSAGE(!CSSAnimations::isAnimatableProperty(property), "Web
Animations not yet implemented: Unable to apply AnimatableValue to RenderStyle:
%s", getPropertyNameString(property).utf8().data()); | 585 ASSERT_WITH_MESSAGE(!CSSAnimations::isAnimatableProperty(property), "Web
Animations not yet implemented: Unable to apply AnimatableValue to RenderStyle:
%s", getPropertyNameString(property).utf8().data()); |
586 ASSERT_NOT_REACHED(); | 586 ASSERT_NOT_REACHED(); |
587 } | 587 } |
588 } | 588 } |
589 | 589 |
590 } // namespace WebCore | 590 } // namespace WebCore |
OLD | NEW |