1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 /* representation of a SMIL-animatable CSS property on an element */ 8 9 #ifndef NS_SMILCSSPROPERTY_H_ 10 #define NS_SMILCSSPROPERTY_H_ 11 12 #include "mozilla/Attributes.h" 13 #include "nsISMILAttr.h" 14 #include "nsIAtom.h" 15 #include "nsCSSPropertyID.h" 16 #include "nsCSSValue.h" 17 18 namespace mozilla { 19 namespace dom { 20 class Element; 21 } // namespace dom 22 } // namespace mozilla 23 24 /** 25 * nsSMILCSSProperty: Implements the nsISMILAttr interface for SMIL animations 26 * that target CSS properties. Represents a particular animation-targeted CSS 27 * property on a particular element. 28 */ 29 class nsSMILCSSProperty : public nsISMILAttr 30 { 31 public: 32 /** 33 * Constructs a new nsSMILCSSProperty. 34 * @param aPropID The CSS property we're interested in animating. 35 * @param aElement The element whose CSS property is being animated. 36 */ 37 nsSMILCSSProperty(nsCSSPropertyID aPropID, mozilla::dom::Element* aElement); 38 39 // nsISMILAttr methods 40 virtual nsresult ValueFromString(const nsAString& aStr, 41 const mozilla::dom::SVGAnimationElement* aSrcElement, 42 nsSMILValue& aValue, 43 bool& aPreventCachingOfSandwich) const override; 44 virtual nsSMILValue GetBaseValue() const override; 45 virtual nsresult SetAnimValue(const nsSMILValue& aValue) override; 46 virtual void ClearAnimValue() override; 47 48 /** 49 * Utility method - returns true if the given property is supported for 50 * SMIL animation. 51 * 52 * @param aProperty The property to check for animation support. 53 * @return true if the given property is supported for SMIL animation, or 54 * false otherwise 55 */ 56 static bool IsPropertyAnimatable(nsCSSPropertyID aPropID); 57 58 protected: 59 nsCSSPropertyID mPropID; 60 // Using non-refcounted pointer for mElement -- we know mElement will stay 61 // alive for my lifetime because a nsISMILAttr (like me) only lives as long 62 // as the Compositing step, and DOM elements don't get a chance to die during 63 // that time. 64 mozilla::dom::Element* mElement; 65 }; 66 67 #endif // NS_SMILCSSPROPERTY_H_ 68