| 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 26 matching lines...) Expand all Loading... |
| 37 #include "core/animation/animatable/AnimatableDoubleAndBool.h" | 37 #include "core/animation/animatable/AnimatableDoubleAndBool.h" |
| 38 #include "core/animation/animatable/AnimatableFilterOperations.h" | 38 #include "core/animation/animatable/AnimatableFilterOperations.h" |
| 39 #include "core/animation/animatable/AnimatableImage.h" | 39 #include "core/animation/animatable/AnimatableImage.h" |
| 40 #include "core/animation/animatable/AnimatableLength.h" | 40 #include "core/animation/animatable/AnimatableLength.h" |
| 41 #include "core/animation/animatable/AnimatableLengthBox.h" | 41 #include "core/animation/animatable/AnimatableLengthBox.h" |
| 42 #include "core/animation/animatable/AnimatableLengthBoxAndBool.h" | 42 #include "core/animation/animatable/AnimatableLengthBoxAndBool.h" |
| 43 #include "core/animation/animatable/AnimatableLengthPoint.h" | 43 #include "core/animation/animatable/AnimatableLengthPoint.h" |
| 44 #include "core/animation/animatable/AnimatableLengthPoint3D.h" | 44 #include "core/animation/animatable/AnimatableLengthPoint3D.h" |
| 45 #include "core/animation/animatable/AnimatableLengthSize.h" | 45 #include "core/animation/animatable/AnimatableLengthSize.h" |
| 46 #include "core/animation/animatable/AnimatableRepeatable.h" | 46 #include "core/animation/animatable/AnimatableRepeatable.h" |
| 47 #include "core/animation/animatable/AnimatableSVGLength.h" | |
| 48 #include "core/animation/animatable/AnimatableSVGPaint.h" | 47 #include "core/animation/animatable/AnimatableSVGPaint.h" |
| 49 #include "core/animation/animatable/AnimatableShadow.h" | 48 #include "core/animation/animatable/AnimatableShadow.h" |
| 50 #include "core/animation/animatable/AnimatableShapeValue.h" | 49 #include "core/animation/animatable/AnimatableShapeValue.h" |
| 51 #include "core/animation/animatable/AnimatableStrokeDasharrayList.h" | 50 #include "core/animation/animatable/AnimatableStrokeDasharrayList.h" |
| 52 #include "core/animation/animatable/AnimatableTransform.h" | 51 #include "core/animation/animatable/AnimatableTransform.h" |
| 53 #include "core/animation/animatable/AnimatableUnknown.h" | 52 #include "core/animation/animatable/AnimatableUnknown.h" |
| 54 #include "core/animation/animatable/AnimatableValue.h" | 53 #include "core/animation/animatable/AnimatableValue.h" |
| 55 #include "core/animation/animatable/AnimatableVisibility.h" | 54 #include "core/animation/animatable/AnimatableVisibility.h" |
| 56 #include "core/css/CSSPrimitiveValueMappings.h" | 55 #include "core/css/CSSPrimitiveValueMappings.h" |
| 57 #include "core/css/CSSPropertyMetadata.h" | 56 #include "core/css/CSSPropertyMetadata.h" |
| 58 #include "core/css/resolver/StyleBuilder.h" | 57 #include "core/css/resolver/StyleBuilder.h" |
| 59 #include "core/css/resolver/StyleResolverState.h" | 58 #include "core/css/resolver/StyleResolverState.h" |
| 60 #include "core/layout/style/LayoutStyle.h" | 59 #include "core/layout/style/LayoutStyle.h" |
| 61 #include "wtf/MathExtras.h" | 60 #include "wtf/MathExtras.h" |
| 62 #include "wtf/TypeTraits.h" | 61 #include "wtf/TypeTraits.h" |
| 63 | 62 |
| 64 namespace blink { | 63 namespace blink { |
| 65 | 64 |
| 66 namespace { | 65 namespace { |
| 67 | 66 |
| 67 Length animatableValueToLengthWithZoom(const AnimatableValue* value, float zoom,
ValueRange range = ValueRangeAll) |
| 68 { |
| 69 if (value->isLength()) |
| 70 return toAnimatableLength(value)->length(zoom, range); |
| 71 ASSERT(toAnimatableUnknown(value)->toCSSValueID() == CSSValueAuto); |
| 72 return Length(Auto); |
| 73 } |
| 74 |
| 68 Length animatableValueToLength(const AnimatableValue* value, const StyleResolver
State& state, ValueRange range = ValueRangeAll) | 75 Length animatableValueToLength(const AnimatableValue* value, const StyleResolver
State& state, ValueRange range = ValueRangeAll) |
| 69 { | 76 { |
| 70 if (value->isLength()) | 77 return animatableValueToLengthWithZoom(value, state.style()->effectiveZoom()
, range); |
| 71 return toAnimatableLength(value)->length(state.style()->effectiveZoom(),
range); | 78 } |
| 72 ASSERT(toAnimatableUnknown(value)->toCSSValueID() == CSSValueAuto); | 79 |
| 73 return Length(Auto); | 80 UnzoomedLength animatableValueToUnzoomedLength(const AnimatableValue* value, con
st StyleResolverState&, ValueRange range = ValueRangeAll) |
| 81 { |
| 82 return UnzoomedLength(animatableValueToLengthWithZoom(value, 1, range)); |
| 74 } | 83 } |
| 75 | 84 |
| 76 BorderImageLength animatableValueToBorderImageLength(const AnimatableValue* valu
e, const StyleResolverState& state) | 85 BorderImageLength animatableValueToBorderImageLength(const AnimatableValue* valu
e, const StyleResolverState& state) |
| 77 { | 86 { |
| 78 if (value->isLength()) | 87 if (value->isLength()) |
| 79 return BorderImageLength(toAnimatableLength(value)->length(state.style()
->effectiveZoom(), ValueRangeNonNegative)); | 88 return BorderImageLength(toAnimatableLength(value)->length(state.style()
->effectiveZoom(), ValueRangeNonNegative)); |
| 80 if (value->isDouble()) | 89 if (value->isDouble()) |
| 81 return BorderImageLength(clampTo<double>(toAnimatableDouble(value)->toDo
uble(), 0)); | 90 return BorderImageLength(clampTo<double>(toAnimatableDouble(value)->toDo
uble(), 0)); |
| 82 ASSERT(toAnimatableUnknown(value)->toCSSValueID() == CSSValueAuto); | 91 ASSERT(toAnimatableUnknown(value)->toCSSValueID() == CSSValueAuto); |
| 83 return Length(Auto); | 92 return Length(Auto); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 } | 145 } |
| 137 | 146 |
| 138 void setFillSize(FillLayer* fillLayer, const AnimatableValue* value, StyleResolv
erState& state) | 147 void setFillSize(FillLayer* fillLayer, const AnimatableValue* value, StyleResolv
erState& state) |
| 139 { | 148 { |
| 140 if (value->isLengthSize()) | 149 if (value->isLengthSize()) |
| 141 fillLayer->setSize(FillSize(SizeLength, animatableValueToLengthSize(valu
e, state, ValueRangeNonNegative))); | 150 fillLayer->setSize(FillSize(SizeLength, animatableValueToLengthSize(valu
e, state, ValueRangeNonNegative))); |
| 142 else | 151 else |
| 143 CSSToStyleMap::mapFillSize(state, fillLayer, toAnimatableUnknown(value)-
>toCSSValue().get()); | 152 CSSToStyleMap::mapFillSize(state, fillLayer, toAnimatableUnknown(value)-
>toCSSValue().get()); |
| 144 } | 153 } |
| 145 | 154 |
| 146 PassRefPtrWillBeRawPtr<SVGLength> animatableValueToNonNegativeSVGLength(const An
imatableValue* value) | |
| 147 { | |
| 148 RefPtrWillBeRawPtr<SVGLength> length = toAnimatableSVGLength(value)->toSVGLe
ngth(); | |
| 149 if (length->valueInSpecifiedUnits() < 0) | |
| 150 length->setValueInSpecifiedUnits(0); | |
| 151 return length.release(); | |
| 152 } | |
| 153 | |
| 154 template <CSSPropertyID property> | 155 template <CSSPropertyID property> |
| 155 void setOnFillLayers(FillLayer& fillLayers, const AnimatableValue* value, StyleR
esolverState& state) | 156 void setOnFillLayers(FillLayer& fillLayers, const AnimatableValue* value, StyleR
esolverState& state) |
| 156 { | 157 { |
| 157 const WillBeHeapVector<RefPtrWillBeMember<AnimatableValue> >& values = toAni
matableRepeatable(value)->values(); | 158 const WillBeHeapVector<RefPtrWillBeMember<AnimatableValue> >& values = toAni
matableRepeatable(value)->values(); |
| 158 ASSERT(!values.isEmpty()); | 159 ASSERT(!values.isEmpty()); |
| 159 FillLayer* fillLayer = &fillLayers; | 160 FillLayer* fillLayer = &fillLayers; |
| 160 FillLayer* prev = 0; | 161 FillLayer* prev = 0; |
| 161 for (size_t i = 0; i < values.size(); ++i) { | 162 for (size_t i = 0; i < values.size(); ++i) { |
| 162 if (!fillLayer) | 163 if (!fillLayer) |
| 163 fillLayer = prev->ensureNext(); | 164 fillLayer = prev->ensureNext(); |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 case CSSPropertyPaddingRight: | 471 case CSSPropertyPaddingRight: |
| 471 style->setPaddingRight(animatableValueToLength(value, state, ValueRangeN
onNegative)); | 472 style->setPaddingRight(animatableValueToLength(value, state, ValueRangeN
onNegative)); |
| 472 return; | 473 return; |
| 473 case CSSPropertyPaddingTop: | 474 case CSSPropertyPaddingTop: |
| 474 style->setPaddingTop(animatableValueToLength(value, state, ValueRangeNon
Negative)); | 475 style->setPaddingTop(animatableValueToLength(value, state, ValueRangeNon
Negative)); |
| 475 return; | 476 return; |
| 476 case CSSPropertyRight: | 477 case CSSPropertyRight: |
| 477 style->setRight(animatableValueToLength(value, state)); | 478 style->setRight(animatableValueToLength(value, state)); |
| 478 return; | 479 return; |
| 479 case CSSPropertyStrokeWidth: | 480 case CSSPropertyStrokeWidth: |
| 480 style->setStrokeWidth(animatableValueToNonNegativeSVGLength(value)); | 481 style->setStrokeWidth(animatableValueToUnzoomedLength(value, state, Valu
eRangeNonNegative)); |
| 481 return; | 482 return; |
| 482 case CSSPropertyStopColor: | 483 case CSSPropertyStopColor: |
| 483 style->setStopColor(toAnimatableColor(value)->color()); | 484 style->setStopColor(toAnimatableColor(value)->color()); |
| 484 return; | 485 return; |
| 485 case CSSPropertyStopOpacity: | 486 case CSSPropertyStopOpacity: |
| 486 style->setStopOpacity(clampTo<float>(toAnimatableDouble(value)->toDouble
(), 0, 1)); | 487 style->setStopOpacity(clampTo<float>(toAnimatableDouble(value)->toDouble
(), 0, 1)); |
| 487 return; | 488 return; |
| 488 case CSSPropertyStrokeDasharray: | 489 case CSSPropertyStrokeDasharray: |
| 489 style->setStrokeDashArray(toAnimatableStrokeDasharrayList(value)->toSVGD
ashArray(style->effectiveZoom())); | 490 style->setStrokeDashArray(toAnimatableStrokeDasharrayList(value)->toSVGD
ashArray(style->effectiveZoom())); |
| 490 return; | 491 return; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 case CSSPropertyRy: | 639 case CSSPropertyRy: |
| 639 style->setRy(animatableValueToLength(value, state)); | 640 style->setRy(animatableValueToLength(value, state)); |
| 640 return; | 641 return; |
| 641 | 642 |
| 642 default: | 643 default: |
| 643 ASSERT_NOT_REACHED(); | 644 ASSERT_NOT_REACHED(); |
| 644 } | 645 } |
| 645 } | 646 } |
| 646 | 647 |
| 647 } // namespace blink | 648 } // namespace blink |
| OLD | NEW |