| 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 21 matching lines...) Expand all Loading... |
| 32 #define AnimatableLength_h | 32 #define AnimatableLength_h |
| 33 | 33 |
| 34 #include "core/CoreExport.h" | 34 #include "core/CoreExport.h" |
| 35 #include "core/animation/animatable/AnimatableValue.h" | 35 #include "core/animation/animatable/AnimatableValue.h" |
| 36 #include "platform/Length.h" | 36 #include "platform/Length.h" |
| 37 | 37 |
| 38 namespace blink { | 38 namespace blink { |
| 39 | 39 |
| 40 class CORE_EXPORT AnimatableLength final : public AnimatableValue { | 40 class CORE_EXPORT AnimatableLength final : public AnimatableValue { |
| 41 public: | 41 public: |
| 42 static PassRefPtrWillBeRawPtr<AnimatableLength> create(const Length& length,
float zoom) | 42 static AnimatableLength* create(const Length& length, float zoom) |
| 43 { | 43 { |
| 44 return adoptRefWillBeNoop(new AnimatableLength(length, zoom)); | 44 return new AnimatableLength(length, zoom); |
| 45 } | 45 } |
| 46 Length length(float zoom, ValueRange) const; | 46 Length length(float zoom, ValueRange) const; |
| 47 | 47 |
| 48 bool hasSameUnits(const AnimatableLength* other) const | 48 bool hasSameUnits(const AnimatableLength* other) const |
| 49 { | 49 { |
| 50 return m_hasPixels == other->m_hasPixels && m_hasPercent == other->m_has
Percent; | 50 return m_hasPixels == other->m_hasPixels && m_hasPercent == other->m_has
Percent; |
| 51 } | 51 } |
| 52 | 52 |
| 53 DEFINE_INLINE_VIRTUAL_TRACE() { AnimatableValue::trace(visitor); } | 53 DEFINE_INLINE_VIRTUAL_TRACE() { AnimatableValue::trace(visitor); } |
| 54 | 54 |
| 55 protected: | 55 protected: |
| 56 virtual PassRefPtrWillBeRawPtr<AnimatableValue> interpolateTo(const Animatab
leValue*, double fraction) const override; | 56 virtual AnimatableValue* interpolateTo(const AnimatableValue*, double fracti
on) const override; |
| 57 | 57 |
| 58 private: | 58 private: |
| 59 static PassRefPtrWillBeRawPtr<AnimatableLength> create(double pixels, double
percent, bool hasPixels, bool hasPercent) | 59 static AnimatableLength* create(double pixels, double percent, bool hasPixel
s, bool hasPercent) |
| 60 { | 60 { |
| 61 return adoptRefWillBeNoop(new AnimatableLength(pixels, percent, hasPixel
s, hasPercent)); | 61 return new AnimatableLength(pixels, percent, hasPixels, hasPercent); |
| 62 } | 62 } |
| 63 AnimatableLength(const Length&, float zoom); | 63 AnimatableLength(const Length&, float zoom); |
| 64 AnimatableLength(double pixels, double percent, bool hasPixels, bool hasPerc
ent) | 64 AnimatableLength(double pixels, double percent, bool hasPixels, bool hasPerc
ent) |
| 65 : m_pixels(pixels) | 65 : m_pixels(pixels) |
| 66 , m_percent(percent) | 66 , m_percent(percent) |
| 67 , m_hasPixels(hasPixels) | 67 , m_hasPixels(hasPixels) |
| 68 , m_hasPercent(hasPercent) | 68 , m_hasPercent(hasPercent) |
| 69 { | 69 { |
| 70 ASSERT(m_hasPixels || m_hasPercent); | 70 ASSERT(m_hasPixels || m_hasPercent); |
| 71 } | 71 } |
| 72 virtual AnimatableType type() const override { return TypeLength; } | 72 virtual AnimatableType type() const override { return TypeLength; } |
| 73 virtual bool equalTo(const AnimatableValue*) const override; | 73 virtual bool equalTo(const AnimatableValue*) const override; |
| 74 | 74 |
| 75 double m_pixels; | 75 double m_pixels; |
| 76 double m_percent; | 76 double m_percent; |
| 77 bool m_hasPixels; | 77 bool m_hasPixels; |
| 78 bool m_hasPercent; | 78 bool m_hasPercent; |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 DEFINE_ANIMATABLE_VALUE_TYPE_CASTS(AnimatableLength, isLength()); | 81 DEFINE_ANIMATABLE_VALUE_TYPE_CASTS(AnimatableLength, isLength()); |
| 82 | 82 |
| 83 } // namespace blink | 83 } // namespace blink |
| 84 | 84 |
| 85 #endif // AnimatableLength_h | 85 #endif // AnimatableLength_h |
| OLD | NEW |