Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef InvalidatableStyleInterpolation_h | |
| 6 #define InvalidatableStyleInterpolation_h | |
| 7 | |
| 8 #include "core/animation/AnimationType.h" | |
| 9 #include "core/animation/AnimationValue.h" | |
| 10 #include "core/animation/InterpolationIsInvalid.h" | |
| 11 #include "core/animation/StyleInterpolation.h" | |
| 12 | |
| 13 namespace blink { | |
| 14 | |
| 15 // TODO(alancutter): This class will replace *StyleInterpolation, SVGInterpolati on, Interpolation. | |
| 16 // For now it needs to distinguish itself during the refactor and temporarily ha s an ugly name. | |
| 17 // TODO(alancutter): Make this class generic for any animation environment so it can be reused for SVG animations. | |
| 18 class CORE_EXPORT InvalidatableStyleInterpolation : public StyleInterpolation { | |
| 19 public: | |
| 20 static PassRefPtrWillBeRawPtr<InvalidatableStyleInterpolation> create( | |
| 21 const Vector<const AnimationType*>& applicableTypes, | |
| 22 PassRefPtrWillBeRawPtr<CSSPropertySpecificKeyframe> startKeyframe, | |
| 23 PassRefPtrWillBeRawPtr<CSSPropertySpecificKeyframe> endKeyframe) | |
| 24 { | |
| 25 return adoptRefWillBeNoop(new InvalidatableStyleInterpolation(applicable Types, startKeyframe, endKeyframe)); | |
| 26 } | |
| 27 | |
| 28 virtual void interpolate(int iteration, double fraction); | |
| 29 void validateCache(const StyleResolverState&) const; | |
| 30 virtual void apply(StyleResolverState&) const; | |
| 31 | |
| 32 virtual bool isInvalidatableStyleInterpolation() const { return true; } | |
| 33 | |
| 34 DEFINE_INLINE_VIRTUAL_TRACE() | |
| 35 { | |
| 36 StyleInterpolation::trace(visitor); | |
| 37 visitor->trace(m_startKeyframe); | |
| 38 visitor->trace(m_endKeyframe); | |
| 39 visitor->trace(m_cachedConversion); | |
| 40 visitor->trace(m_cachedValue); | |
| 41 } | |
| 42 | |
| 43 class CachedConversion : public NoBaseWillBeGarbageCollectedFinalized<Cached Conversion> { | |
| 44 public: | |
| 45 virtual ~CachedConversion() { } | |
| 46 bool isInvalid(const StyleResolverState& state) const { return !m_isInva lid || m_isInvalid->checkChain(state); } | |
|
Eric Willigers
2015/05/27 04:26:35
m_isInvalid && m_isInvalid->checkChain(state);
Pe
alancutter (OOO until 2018)
2015/05/27 08:27:48
Done.
| |
| 47 virtual void interpolate(double fraction, AnimationValue& result) const = 0; | |
| 48 DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(m_isInvalid); } | |
| 49 protected: | |
| 50 CachedConversion(PassRefPtrWillBeRawPtr<InterpolationIsInvalid> isInvali d) : m_isInvalid(isInvalid) { } | |
| 51 RefPtrWillBeMember<InterpolationIsInvalid> m_isInvalid; | |
| 52 }; | |
| 53 | |
| 54 private: | |
| 55 InvalidatableStyleInterpolation( | |
| 56 const Vector<const AnimationType*>& applicableTypes, | |
| 57 PassRefPtrWillBeRawPtr<CSSPropertySpecificKeyframe> startKeyframe, | |
| 58 PassRefPtrWillBeRawPtr<CSSPropertySpecificKeyframe> endKeyframe); | |
| 59 | |
| 60 bool maybeCachePairwiseConversion(const StyleResolverState*) const; | |
| 61 void cacheDefaultConversion(const StyleResolverState&) const; | |
| 62 AnimationValue convertSingleKeyframe(const StyleResolverState&, const CSSPro pertySpecificKeyframe&, RefPtrWillBeRawPtr<InterpolationIsInvalid>& resultIsInva lid) const; | |
| 63 | |
| 64 const Vector<const AnimationType*>& m_applicableTypes; | |
| 65 const RefPtrWillBeMember<CSSPropertySpecificKeyframe> m_startKeyframe; | |
| 66 const RefPtrWillBeMember<CSSPropertySpecificKeyframe> m_endKeyframe; | |
| 67 double m_currentFraction; | |
| 68 mutable OwnPtrWillBeMember<CachedConversion> m_cachedConversion; | |
| 69 mutable AnimationValue m_cachedValue; | |
| 70 }; | |
| 71 | |
| 72 DEFINE_TYPE_CASTS(InvalidatableStyleInterpolation, Interpolation, value, value-> isInvalidatableStyleInterpolation(), value.isInvalidatableStyleInterpolation()); | |
| 73 | |
| 74 } // namespace blink | |
| 75 | |
| 76 #endif // InvalidatableStyleInterpolation_h | |
| OLD | NEW |