Line data Source code
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 NS_ISMILATTR_H_
8 : #define NS_ISMILATTR_H_
9 :
10 : #include "nscore.h"
11 :
12 : class nsSMILValue;
13 : class nsIContent;
14 : class nsAString;
15 :
16 : namespace mozilla {
17 : namespace dom {
18 : class SVGAnimationElement;
19 : } // namespace dom
20 : } // namespace mozilla
21 :
22 : ////////////////////////////////////////////////////////////////////////
23 : // nsISMILAttr: A variable targeted by SMIL for animation and can therefore have
24 : // an underlying (base) value and an animated value For example, an attribute of
25 : // a particular SVG element.
26 : //
27 : // These objects only exist during the compositing phase of SMIL animation
28 : // calculations. They have a single owner who is responsible for deleting the
29 : // object.
30 :
31 0 : class nsISMILAttr
32 : {
33 : public:
34 : /**
35 : * Creates a new nsSMILValue 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(const nsAString& aStr,
54 : const mozilla::dom::SVGAnimationElement* aSrcElement,
55 : nsSMILValue& aValue,
56 : bool& aPreventCachingOfSandwich) const = 0;
57 :
58 : /**
59 : * Gets the underlying value of this attribute.
60 : *
61 : * @return an nsSMILValue object. returned_object.IsNull() will be true if an
62 : * error occurred.
63 : */
64 : virtual nsSMILValue 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 nsSMILValue& aValue) = 0;
81 :
82 : /**
83 : * Returns the targeted content node, for any nsISMILAttr implementations
84 : * that want to expose that to the animation logic. Otherwise, returns
85 : * null.
86 : *
87 : * @return the targeted content node, if this nsISMILAttr implementation
88 : * wishes to make it avaiable. Otherwise, nullptr.
89 : */
90 0 : virtual const nsIContent* GetTargetNode() const { return nullptr; }
91 :
92 : /**
93 : * Virtual destructor, to make sure subclasses can clean themselves up.
94 : */
95 0 : virtual ~nsISMILAttr() {}
96 : };
97 :
98 : #endif // NS_ISMILATTR_H_
|