| 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 14 matching lines...) Expand all Loading... |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 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/AnimatableValue.h" | 32 #include "core/animation/AnimatableValue.h" |
| 33 | 33 |
| 34 #include "core/animation/AnimatableNeutral.h" | 34 #include "core/animation/AnimatableNeutral.h" |
| 35 #include "core/animation/AnimatableNumber.h" | |
| 36 #include "core/animation/AnimatableUnknown.h" | |
| 37 | 35 |
| 38 #include <algorithm> | 36 #include <algorithm> |
| 39 | 37 |
| 40 namespace WebCore { | 38 namespace WebCore { |
| 41 | 39 |
| 42 PassRefPtr<AnimatableValue> AnimatableValue::create(CSSValue* value) | |
| 43 { | |
| 44 // FIXME: Move this logic to a separate factory class. | |
| 45 // FIXME: Handle all animatable CSSValue types. | |
| 46 if (AnimatableNumber::canCreateFrom(value)) | |
| 47 return AnimatableNumber::create(value); | |
| 48 return AnimatableUnknown::create(value); | |
| 49 } | |
| 50 | |
| 51 const AnimatableValue* AnimatableValue::neutralValue() | 40 const AnimatableValue* AnimatableValue::neutralValue() |
| 52 { | 41 { |
| 53 static AnimatableNeutral* neutralSentinelValue = AnimatableNeutral::create()
.leakRef(); | 42 static AnimatableNeutral* neutralSentinelValue = AnimatableNeutral::create()
.leakRef(); |
| 54 return neutralSentinelValue; | 43 return neutralSentinelValue; |
| 55 } | 44 } |
| 56 | 45 |
| 57 PassRefPtr<AnimatableValue> AnimatableValue::interpolate(const AnimatableValue*
left, const AnimatableValue* right, double fraction) | 46 PassRefPtr<AnimatableValue> AnimatableValue::interpolate(const AnimatableValue*
left, const AnimatableValue* right, double fraction) |
| 58 { | 47 { |
| 59 ASSERT(left); | 48 ASSERT(left); |
| 60 ASSERT(right); | 49 ASSERT(right); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 77 if (right->isNeutral()) | 66 if (right->isNeutral()) |
| 78 return takeConstRef(left); | 67 return takeConstRef(left); |
| 79 | 68 |
| 80 if (left->isSameType(right)) | 69 if (left->isSameType(right)) |
| 81 return left->addWith(right); | 70 return left->addWith(right); |
| 82 | 71 |
| 83 return defaultAddWith(left, right); | 72 return defaultAddWith(left, right); |
| 84 } | 73 } |
| 85 | 74 |
| 86 } // namespace WebCore | 75 } // namespace WebCore |
| OLD | NEW |