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