Chromium Code Reviews| 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 15 matching lines...) Expand all Loading... | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "core/animation/css/CSSAnimatableValueFactory.h" | 32 #include "core/animation/css/CSSAnimatableValueFactory.h" |
| 33 | 33 |
| 34 #include "CSSValueKeywords.h" | 34 #include "CSSValueKeywords.h" |
| 35 #include "core/animation/AnimatableColor.h" | 35 #include "core/animation/AnimatableColor.h" |
| 36 #include "core/animation/AnimatableDouble.h" | |
| 36 #include "core/animation/AnimatableImage.h" | 37 #include "core/animation/AnimatableImage.h" |
| 38 #include "core/animation/AnimatableLength.h" | |
| 37 #include "core/animation/AnimatableLengthBox.h" | 39 #include "core/animation/AnimatableLengthBox.h" |
| 38 #include "core/animation/AnimatableLengthSize.h" | 40 #include "core/animation/AnimatableLengthSize.h" |
| 39 #include "core/animation/AnimatableNumber.h" | |
| 40 #include "core/animation/AnimatableTransform.h" | 41 #include "core/animation/AnimatableTransform.h" |
| 41 #include "core/animation/AnimatableUnknown.h" | 42 #include "core/animation/AnimatableUnknown.h" |
| 42 #include "core/animation/AnimatableVisibility.h" | 43 #include "core/animation/AnimatableVisibility.h" |
| 43 #include "core/animation/css/CSSAnimations.h" | 44 #include "core/animation/css/CSSAnimations.h" |
| 44 #include "core/css/CSSPrimitiveValue.h" | 45 #include "core/css/CSSPrimitiveValue.h" |
| 45 #include "core/platform/Length.h" | 46 #include "core/platform/Length.h" |
| 46 #include "core/platform/LengthBox.h" | 47 #include "core/platform/LengthBox.h" |
| 47 #include "core/rendering/style/RenderStyle.h" | 48 #include "core/rendering/style/RenderStyle.h" |
| 48 | 49 |
| 49 | 50 |
| 50 namespace WebCore { | 51 namespace WebCore { |
| 51 | 52 |
| 52 static PassRefPtr<AnimatableValue> createFromLength(const Length& length, const RenderStyle* style) | 53 static PassRefPtr<AnimatableValue> createFromLength(const Length& length, const RenderStyle* style) |
| 53 { | 54 { |
| 54 switch (length.type()) { | 55 switch (length.type()) { |
| 55 case Relative: | |
| 56 return AnimatableNumber::create(length.value(), AnimatableNumber::UnitTy peNumber); | |
| 57 case Fixed: | 56 case Fixed: |
| 58 return AnimatableNumber::create(adjustFloatForAbsoluteZoom(length.value( ), style), AnimatableNumber::UnitTypeLength); | 57 return AnimatableLength::create(adjustFloatForAbsoluteZoom(length.value( ), style), AnimatableLength::UnitTypeLength); |
| 59 case Percent: | 58 case Percent: |
| 60 return AnimatableNumber::create(length.value(), AnimatableNumber::UnitTy pePercentage); | 59 return AnimatableLength::create(length.value(), AnimatableLength::UnitTy pePercentage); |
| 61 case ViewportPercentageWidth: | 60 case ViewportPercentageWidth: |
| 62 return AnimatableNumber::create(length.value(), AnimatableNumber::UnitTy peViewportWidth); | 61 return AnimatableLength::create(length.value(), AnimatableLength::UnitTy peViewportWidth); |
| 63 case ViewportPercentageHeight: | 62 case ViewportPercentageHeight: |
| 64 return AnimatableNumber::create(length.value(), AnimatableNumber::UnitTy peViewportHeight); | 63 return AnimatableLength::create(length.value(), AnimatableLength::UnitTy peViewportHeight); |
| 65 case ViewportPercentageMin: | 64 case ViewportPercentageMin: |
| 66 return AnimatableNumber::create(length.value(), AnimatableNumber::UnitTy peViewportMin); | 65 return AnimatableLength::create(length.value(), AnimatableLength::UnitTy peViewportMin); |
| 67 case ViewportPercentageMax: | 66 case ViewportPercentageMax: |
| 68 return AnimatableNumber::create(length.value(), AnimatableNumber::UnitTy peViewportMax); | 67 return AnimatableLength::create(length.value(), AnimatableLength::UnitTy peViewportMax); |
| 69 case Calculated: | 68 case Calculated: |
| 70 // FIXME: Convert platform calcs to CSS calcs. | 69 // FIXME: Convert platform calcs to CSS calcs. |
| 71 ASSERT_WITH_MESSAGE(false, "Web Animations not yet implemented: Convert platform CalculationValue to AnimatableValue"); | 70 ASSERT_WITH_MESSAGE(false, "Web Animations not yet implemented: Convert platform CalculationValue to AnimatableValue"); |
| 72 return 0; | 71 return 0; |
| 73 case Auto: | 72 case Auto: |
| 74 case Intrinsic: | 73 case Intrinsic: |
| 75 case MinIntrinsic: | 74 case MinIntrinsic: |
| 76 case MinContent: | 75 case MinContent: |
| 77 case MaxContent: | 76 case MaxContent: |
| 78 case FillAvailable: | 77 case FillAvailable: |
| 79 case FitContent: | 78 case FitContent: |
| 80 return AnimatableUnknown::create(CSSPrimitiveValue::create(length)); | 79 return AnimatableUnknown::create(CSSPrimitiveValue::create(length)); |
| 81 case Undefined: | 80 case Undefined: |
| 82 return AnimatableUnknown::create(CSSPrimitiveValue::create(CSSValueNone) ); | 81 return AnimatableUnknown::create(CSSPrimitiveValue::create(CSSValueNone) ); |
| 83 case ExtendToZoom: // Does not apply to elements. | 82 case ExtendToZoom: // Does not apply to elements. |
| 83 case Relative: | |
|
dstockwell
2013/09/30 22:01:58
Need a comment about why we don't expect this.
alancutter (OOO until 2018)
2013/09/30 23:04:43
Done.
| |
| 84 ASSERT_NOT_REACHED(); | 84 ASSERT_NOT_REACHED(); |
| 85 return 0; | 85 return 0; |
| 86 } | 86 } |
| 87 ASSERT_NOT_REACHED(); | 87 ASSERT_NOT_REACHED(); |
| 88 return 0; | 88 return 0; |
| 89 } | 89 } |
| 90 | 90 |
| 91 inline static PassRefPtr<AnimatableValue> createFromDouble(double value) | 91 inline static PassRefPtr<AnimatableValue> createFromDouble(double value) |
| 92 { | 92 { |
| 93 return AnimatableNumber::create(value, AnimatableNumber::UnitTypeNumber); | 93 return AnimatableDouble::create(value); |
| 94 } | 94 } |
| 95 | 95 |
| 96 inline static PassRefPtr<AnimatableValue> createFromLengthBox(const LengthBox le ngthBox, const RenderStyle* style) | 96 inline static PassRefPtr<AnimatableValue> createFromLengthBox(const LengthBox le ngthBox, const RenderStyle* style) |
| 97 { | 97 { |
| 98 return AnimatableLengthBox::create( | 98 return AnimatableLengthBox::create( |
| 99 createFromLength(lengthBox.left(), style), | 99 createFromLength(lengthBox.left(), style), |
| 100 createFromLength(lengthBox.right(), style), | 100 createFromLength(lengthBox.right(), style), |
| 101 createFromLength(lengthBox.top(), style), | 101 createFromLength(lengthBox.top(), style), |
| 102 createFromLength(lengthBox.bottom(), style)); | 102 createFromLength(lengthBox.bottom(), style)); |
| 103 } | 103 } |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 257 case CSSPropertyZIndex: | 257 case CSSPropertyZIndex: |
| 258 return createFromDouble(style->zIndex()); | 258 return createFromDouble(style->zIndex()); |
| 259 default: | 259 default: |
| 260 RELEASE_ASSERT_WITH_MESSAGE(!CSSAnimations::isAnimatableProperty(propert y), "Web Animations not yet implemented: Create AnimatableValue from render styl e: %s", getPropertyNameString(property).utf8().data()); | 260 RELEASE_ASSERT_WITH_MESSAGE(!CSSAnimations::isAnimatableProperty(propert y), "Web Animations not yet implemented: Create AnimatableValue from render styl e: %s", getPropertyNameString(property).utf8().data()); |
| 261 ASSERT_NOT_REACHED(); | 261 ASSERT_NOT_REACHED(); |
| 262 return 0; | 262 return 0; |
| 263 } | 263 } |
| 264 } | 264 } |
| 265 | 265 |
| 266 } // namespace WebCore | 266 } // namespace WebCore |
| OLD | NEW |