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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 #include "core/rendering/style/RenderStyle.h" | 58 #include "core/rendering/style/RenderStyle.h" |
59 #include "wtf/MathExtras.h" | 59 #include "wtf/MathExtras.h" |
60 #include "wtf/TypeTraits.h" | 60 #include "wtf/TypeTraits.h" |
61 | 61 |
62 namespace WebCore { | 62 namespace WebCore { |
63 | 63 |
64 namespace { | 64 namespace { |
65 | 65 |
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(); | |
69 if (value->isLength()) | 68 if (value->isLength()) |
70 return toAnimatableLength(value)->toLength(style, state.rootElementStyle
(), style->effectiveZoom(), range); | 69 return toAnimatableLength(value)->toLength(state.cssToLengthConversionDa
ta(), range); |
71 RefPtr<CSSValue> cssValue = toAnimatableUnknown(value)->toCSSValue(); | 70 RefPtr<CSSValue> cssValue = toAnimatableUnknown(value)->toCSSValue(); |
72 CSSPrimitiveValue* cssPrimitiveValue = toCSSPrimitiveValue(cssValue.get()); | 71 CSSPrimitiveValue* cssPrimitiveValue = toCSSPrimitiveValue(cssValue.get()); |
73 return cssPrimitiveValue->convertToLength<AnyConversion>(style, state.rootEl
ementStyle(), style->effectiveZoom()); | 72 return cssPrimitiveValue->convertToLength<AnyConversion>(state.cssToLengthCo
nversionData()); |
74 } | 73 } |
75 | 74 |
76 BorderImageLength animatableValueToBorderImageLength(const AnimatableValue* valu
e, const StyleResolverState& state) | 75 BorderImageLength animatableValueToBorderImageLength(const AnimatableValue* valu
e, const StyleResolverState& state) |
77 { | 76 { |
78 const RenderStyle* style = state.style(); | |
79 if (value->isLength()) | 77 if (value->isLength()) |
80 return BorderImageLength(toAnimatableLength(value)->toLength(style, stat
e.rootElementStyle(), style->effectiveZoom(), NonNegativeValues)); | 78 return BorderImageLength(toAnimatableLength(value)->toLength(state.cssTo
LengthConversionData(), NonNegativeValues)); |
81 if (value->isDouble()) | 79 if (value->isDouble()) |
82 return BorderImageLength(clampTo<double>(toAnimatableDouble(value)->toDo
uble(), 0)); | 80 return BorderImageLength(clampTo<double>(toAnimatableDouble(value)->toDo
uble(), 0)); |
83 RefPtr<CSSValue> cssValue = toAnimatableUnknown(value)->toCSSValue(); | 81 RefPtr<CSSValue> cssValue = toAnimatableUnknown(value)->toCSSValue(); |
84 CSSPrimitiveValue* cssPrimitiveValue = toCSSPrimitiveValue(cssValue.get()); | 82 CSSPrimitiveValue* cssPrimitiveValue = toCSSPrimitiveValue(cssValue.get()); |
85 return BorderImageLength(cssPrimitiveValue->convertToLength<AnyConversion>(s
tyle, state.rootElementStyle(), style->effectiveZoom())); | 83 return BorderImageLength(cssPrimitiveValue->convertToLength<AnyConversion>(s
tate.cssToLengthConversionData())); |
86 } | 84 } |
87 | 85 |
88 template<typename T> T animatableValueRoundClampTo(const AnimatableValue* value,
T min = defaultMinimumForClamp<T>(), T max = defaultMaximumForClamp<T>()) | 86 template<typename T> T animatableValueRoundClampTo(const AnimatableValue* value,
T min = defaultMinimumForClamp<T>(), T max = defaultMaximumForClamp<T>()) |
89 { | 87 { |
90 COMPILE_ASSERT(WTF::IsInteger<T>::value, ShouldUseIntegralTypeTWhenRoundingV
alues); | 88 COMPILE_ASSERT(WTF::IsInteger<T>::value, ShouldUseIntegralTypeTWhenRoundingV
alues); |
91 return clampTo<T>(round(toAnimatableDouble(value)->toDouble()), min, max); | 89 return clampTo<T>(round(toAnimatableDouble(value)->toDouble()), min, max); |
92 } | 90 } |
93 | 91 |
94 LengthBox animatableValueToLengthBox(const AnimatableValue* value, const StyleRe
solverState& state, NumberRange range = AllValues) | 92 LengthBox animatableValueToLengthBox(const AnimatableValue* value, const StyleRe
solverState& state, NumberRange range = AllValues) |
95 { | 93 { |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 case CSSPropertyZoom: | 584 case CSSPropertyZoom: |
587 style->setZoom(clampTo<float>(toAnimatableDouble(value)->toDouble(), std
::numeric_limits<float>::denorm_min())); | 585 style->setZoom(clampTo<float>(toAnimatableDouble(value)->toDouble(), std
::numeric_limits<float>::denorm_min())); |
588 return; | 586 return; |
589 default: | 587 default: |
590 ASSERT_WITH_MESSAGE(!CSSAnimations::isAnimatableProperty(property), "Web
Animations not yet implemented: Unable to apply AnimatableValue to RenderStyle:
%s", getPropertyNameString(property).utf8().data()); | 588 ASSERT_WITH_MESSAGE(!CSSAnimations::isAnimatableProperty(property), "Web
Animations not yet implemented: Unable to apply AnimatableValue to RenderStyle:
%s", getPropertyNameString(property).utf8().data()); |
591 ASSERT_NOT_REACHED(); | 589 ASSERT_NOT_REACHED(); |
592 } | 590 } |
593 } | 591 } |
594 | 592 |
595 } // namespace WebCore | 593 } // namespace WebCore |
OLD | NEW |