SMILAttr.h (3519B)
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 #ifndef DOM_SMIL_SMILATTR_H_ 8 #define DOM_SMIL_SMILATTR_H_ 9 10 #include "nsStringFwd.h" 11 #include "nscore.h" 12 13 class nsIContent; 14 15 namespace mozilla { 16 17 class SMILValue; 18 19 namespace dom { 20 class SVGAnimationElement; 21 } // namespace dom 22 23 //////////////////////////////////////////////////////////////////////// 24 // SMILAttr: A variable targeted by SMIL for animation and can therefore have 25 // an underlying (base) value and an animated value For example, an attribute of 26 // a particular SVG element. 27 // 28 // These objects only exist during the compositing phase of SMIL animation 29 // calculations. They have a single owner who is responsible for deleting the 30 // object. 31 32 class SMILAttr { 33 public: 34 /** 35 * Creates a new SMILValue for this attribute from a string. The string is 36 * parsed in the context of this attribute so that context-dependent values 37 * such as em-based units can be resolved into a canonical form suitable for 38 * animation (including interpolation etc.). 39 * 40 * @param aStr A string defining the new value to be created. 41 * @param aSrcElement The source animation element. This may be needed to 42 * provided additional context data such as for 43 * animateTransform where the 'type' attribute is needed to 44 * parse the value. 45 * @param[out] aValue Outparam for storing the parsed value. 46 * @param[out] aPreventCachingOfSandwich 47 * Outparam to indicate whether the attribute contains 48 * dependencies on its context that should prevent the 49 * result of the animation sandwich from being cached and 50 * reused in future samples. 51 * @return NS_OK on success or an error code if creation failed. 52 */ 53 virtual nsresult ValueFromString( 54 const nsAString& aStr, 55 const mozilla::dom::SVGAnimationElement* aSrcElement, SMILValue& aValue, 56 bool& aPreventCachingOfSandwich) const = 0; 57 58 /** 59 * Gets the underlying value of this attribute. 60 * 61 * @return a SMILValue object. returned_object.IsNull() will be true if an 62 * error occurred. 63 */ 64 virtual SMILValue GetBaseValue() const = 0; 65 66 /** 67 * Clears the animated value of this attribute. 68 * 69 * NOTE: The animation target is not guaranteed to be in a document when this 70 * method is called. (See bug 523188) 71 */ 72 virtual void ClearAnimValue() = 0; 73 74 /** 75 * Sets the presentation value of this attribute. 76 * 77 * @param aValue The value to set. 78 * @return NS_OK on success or an error code if setting failed. 79 */ 80 virtual nsresult SetAnimValue(const SMILValue& aValue) = 0; 81 82 /** 83 * Returns the targeted content node, for any SMILAttr implementations 84 * that want to expose that to the animation logic. Otherwise, returns 85 * null. 86 * 87 * @return the targeted content node, if this SMILAttr implementation 88 * wishes to make it avaiable. Otherwise, nullptr. 89 */ 90 virtual const nsIContent* GetTargetNode() const { return nullptr; } 91 92 /** 93 * Virtual destructor, to make sure subclasses can clean themselves up. 94 */ 95 virtual ~SMILAttr() = default; 96 }; 97 98 } // namespace mozilla 99 100 #endif // DOM_SMIL_SMILATTR_H_