| 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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 case CSSPropertyZoom: | 581 case CSSPropertyZoom: |
| 584 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())); |
| 585 return; | 583 return; |
| 586 default: | 584 default: |
| 587 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()); |
| 588 ASSERT_NOT_REACHED(); | 586 ASSERT_NOT_REACHED(); |
| 589 } | 587 } |
| 590 } | 588 } |
| 591 | 589 |
| 592 } // namespace WebCore | 590 } // namespace WebCore |
| OLD | NEW |