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 : /* representation of a SMIL-animatable CSS property on an element */
8 :
9 : #ifndef NS_SMILCSSPROPERTY_H_
10 : #define NS_SMILCSSPROPERTY_H_
11 :
12 : #include "mozilla/Attributes.h"
13 : #include "mozilla/StyleBackendType.h"
14 : #include "nsISMILAttr.h"
15 : #include "nsIAtom.h"
16 : #include "nsCSSPropertyID.h"
17 : #include "nsCSSValue.h"
18 :
19 : class nsStyleContext;
20 :
21 : namespace mozilla {
22 : namespace dom {
23 : class Element;
24 : } // namespace dom
25 : } // namespace mozilla
26 :
27 : /**
28 : * nsSMILCSSProperty: Implements the nsISMILAttr interface for SMIL animations
29 : * that target CSS properties. Represents a particular animation-targeted CSS
30 : * property on a particular element.
31 : */
32 0 : class nsSMILCSSProperty : public nsISMILAttr
33 : {
34 : public:
35 : /**
36 : * Constructs a new nsSMILCSSProperty.
37 : * @param aPropID The CSS property we're interested in animating.
38 : * @param aElement The element whose CSS property is being animated.
39 : * @param aBaseStyleContext The style context to use when getting the base
40 : * value. If this is nullptr and GetBaseValue is
41 : * called, an empty nsSMILValue initialized with
42 : * the nsSMILCSSValueType will be returned.
43 : */
44 : nsSMILCSSProperty(nsCSSPropertyID aPropID,
45 : mozilla::dom::Element* aElement,
46 : nsStyleContext* aBaseStyleContext);
47 :
48 : // nsISMILAttr methods
49 : virtual nsresult ValueFromString(const nsAString& aStr,
50 : const mozilla::dom::SVGAnimationElement* aSrcElement,
51 : nsSMILValue& aValue,
52 : bool& aPreventCachingOfSandwich) const override;
53 : virtual nsSMILValue GetBaseValue() const override;
54 : virtual nsresult SetAnimValue(const nsSMILValue& aValue) override;
55 : virtual void ClearAnimValue() override;
56 :
57 : /**
58 : * Utility method - returns true if the given property is supported for
59 : * SMIL animation.
60 : *
61 : * @param aProperty The property to check for animation support.
62 : * @param aBackend The style backend to check for animation support.
63 : * This is a temporary measure until the Servo backend
64 : * supports all animatable properties (bug 1353918).
65 : * @return true if the given property is supported for SMIL animation, or
66 : * false otherwise
67 : */
68 : static bool IsPropertyAnimatable(nsCSSPropertyID aPropID,
69 : mozilla::StyleBackendType aBackend);
70 :
71 : protected:
72 : nsCSSPropertyID mPropID;
73 : // Using non-refcounted pointer for mElement -- we know mElement will stay
74 : // alive for my lifetime because a nsISMILAttr (like me) only lives as long
75 : // as the Compositing step, and DOM elements don't get a chance to die during
76 : // that time.
77 : mozilla::dom::Element* mElement;
78 :
79 : // The style context to use when fetching base styles.
80 : // As with mElement, since an nsISMILAttr only lives as long as the
81 : // compositing step and since ComposeAttribute holds an owning reference to
82 : // the base style context, we can use a non-owning reference here.
83 : nsStyleContext* mBaseStyleContext;
84 : };
85 :
86 : #endif // NS_SMILCSSPROPERTY_H_
|