1 // Copyright 2014 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 CSSTransitionData_h 6 #define CSSTransitionData_h 7 8 #include "core/CSSPropertyNames.h" 9 #include "core/animation/css/CSSTimingData.h" 10 #include "wtf/Vector.h" 11 12 namespace blink { 13 14 class CSSTransitionData FINAL : public CSSTimingData { 15 public: 16 enum TransitionPropertyType { 17 TransitionNone, 18 TransitionSingleProperty, 19 TransitionUnknown, 20 TransitionAll 21 }; 22 23 // FIXME: We shouldn't allow 'none' to be used alongside other properties. 24 struct TransitionProperty { 25 TransitionProperty(CSSPropertyID id) 26 : propertyType(TransitionSingleProperty) 27 , propertyId(id) 28 { 29 ASSERT(id != CSSPropertyInvalid); 30 } 31 32 TransitionProperty(const String& string) 33 : propertyType(TransitionUnknown) 34 , propertyId(CSSPropertyInvalid) 35 , propertyString(string) 36 { 37 } 38 39 TransitionProperty(TransitionPropertyType type) 40 : propertyType(type) 41 , propertyId(CSSPropertyInvalid) 42 { 43 ASSERT(type == TransitionNone || type == TransitionAll); 44 } 45 46 bool operator==(const TransitionProperty& other) const { return propertyType == other.propertyType && propertyId == other.propertyId && propertyString == other.propertyString; } 47 48 TransitionPropertyType propertyType; 49 CSSPropertyID propertyId; 50 String propertyString; 51 }; 52 53 static PassOwnPtrWillBeRawPtr<CSSTransitionData> create() 54 { 55 return adoptPtrWillBeNoop(new CSSTransitionData); 56 } 57 58 static PassOwnPtrWillBeRawPtr<CSSTransitionData> create(const CSSTransitionData& transitionData) 59 { 60 return adoptPtrWillBeNoop(new CSSTransitionData(transitionData)); 61 } 62 63 bool transitionsMatchForStyleRecalc(const CSSTransitionData& other) const; 64 65 Timing convertToTiming(size_t index) const; 66 67 const Vector<TransitionProperty>& propertyList() const { return m_propertyList; } 68 Vector<TransitionProperty>& propertyList() { return m_propertyList; } 69 70 static TransitionProperty initialProperty() { return TransitionProperty(TransitionAll); } 71 72 private: 73 CSSTransitionData(); 74 explicit CSSTransitionData(const CSSTransitionData&); 75 76 Vector<TransitionProperty> m_propertyList; 77 }; 78 79 } // namespace blink 80 81 #endif // CSSTransitionData_h 82