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/. */
7 #ifndef DOM_SMIL_SMILATTR_H_
8 #define DOM_SMIL_SMILATTR_H_
11 #include "nsStringFwd.h"
20 class SVGAnimationElement
;
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.
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
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.).
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
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.
53 virtual nsresult
ValueFromString(
54 const nsAString
& aStr
,
55 const mozilla::dom::SVGAnimationElement
* aSrcElement
, SMILValue
& aValue
,
56 bool& aPreventCachingOfSandwich
) const = 0;
59 * Gets the underlying value of this attribute.
61 * @return a SMILValue object. returned_object.IsNull() will be true if an
64 virtual SMILValue
GetBaseValue() const = 0;
67 * Clears the animated value of this attribute.
69 * NOTE: The animation target is not guaranteed to be in a document when this
70 * method is called. (See bug 523188)
72 virtual void ClearAnimValue() = 0;
75 * Sets the presentation value of this attribute.
77 * @param aValue The value to set.
78 * @return NS_OK on success or an error code if setting failed.
80 virtual nsresult
SetAnimValue(const SMILValue
& aValue
) = 0;
83 * Returns the targeted content node, for any SMILAttr implementations
84 * that want to expose that to the animation logic. Otherwise, returns
87 * @return the targeted content node, if this SMILAttr implementation
88 * wishes to make it avaiable. Otherwise, nullptr.
90 virtual const nsIContent
* GetTargetNode() const { return nullptr; }
93 * Virtual destructor, to make sure subclasses can clean themselves up.
95 virtual ~SMILAttr() = default;
98 } // namespace mozilla
100 #endif // DOM_SMIL_SMILATTR_H_