no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / dom / smil / SMILAttr.h
bloba67921a9adb62d37fd7afd515252a5ac3b995d47
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_
10 #include "nscore.h"
11 #include "nsStringFwd.h"
13 class nsIContent;
15 namespace mozilla {
17 class SMILValue;
19 namespace dom {
20 class SVGAnimationElement;
21 } // namespace dom
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
30 // object.
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.).
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.
53 virtual nsresult ValueFromString(
54 const nsAString& aStr,
55 const mozilla::dom::SVGAnimationElement* aSrcElement, SMILValue& aValue,
56 bool& aPreventCachingOfSandwich) const = 0;
58 /**
59 * Gets the underlying value of this attribute.
61 * @return a SMILValue object. returned_object.IsNull() will be true if an
62 * error occurred.
64 virtual SMILValue GetBaseValue() const = 0;
66 /**
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;
74 /**
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;
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.
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; }
92 /**
93 * Virtual destructor, to make sure subclasses can clean themselves up.
95 virtual ~SMILAttr() = default;
98 } // namespace mozilla
100 #endif // DOM_SMIL_SMILATTR_H_