/src/mozilla-central/dom/svg/nsSVGClass.h
Line | Count | Source (jump to first uncovered line) |
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_SVGCLASS_H__ |
8 | | #define __NS_SVGCLASS_H__ |
9 | | |
10 | | #include "nsAutoPtr.h" |
11 | | #include "nsCycleCollectionParticipant.h" |
12 | | #include "nsError.h" |
13 | | #include "nsISMILAttr.h" |
14 | | #include "nsString.h" |
15 | | #include "mozilla/Attributes.h" |
16 | | #include "mozilla/UniquePtr.h" |
17 | | |
18 | | class nsSVGElement; |
19 | | |
20 | | namespace mozilla { |
21 | | namespace dom { |
22 | | class SVGAnimatedString; |
23 | | } // namespace dom |
24 | | } // namespace mozilla |
25 | | |
26 | | class nsSVGClass |
27 | | { |
28 | | |
29 | | public: |
30 | 0 | void Init() { |
31 | 0 | mAnimVal = nullptr; |
32 | 0 | } |
33 | | |
34 | | void SetBaseValue(const nsAString& aValue, |
35 | | nsSVGElement *aSVGElement, |
36 | | bool aDoSetAttr); |
37 | | void GetBaseValue(nsAString& aValue, const nsSVGElement *aSVGElement) const; |
38 | | |
39 | | void SetAnimValue(const nsAString& aValue, nsSVGElement *aSVGElement); |
40 | | void GetAnimValue(nsAString& aValue, const nsSVGElement *aSVGElement) const; |
41 | | bool IsAnimated() const |
42 | 0 | { return !!mAnimVal; } |
43 | | |
44 | | already_AddRefed<mozilla::dom::SVGAnimatedString> |
45 | | ToDOMAnimatedString(nsSVGElement* aSVGElement); |
46 | | |
47 | | mozilla::UniquePtr<nsISMILAttr> ToSMILAttr(nsSVGElement *aSVGElement); |
48 | | |
49 | | private: |
50 | | |
51 | | nsAutoPtr<nsString> mAnimVal; |
52 | | |
53 | | public: |
54 | | struct SMILString : public nsISMILAttr |
55 | | { |
56 | | public: |
57 | | SMILString(nsSVGClass *aVal, nsSVGElement *aSVGElement) |
58 | 0 | : mVal(aVal), mSVGElement(aSVGElement) {} |
59 | | |
60 | | // These will stay alive because a nsISMILAttr only lives as long |
61 | | // as the Compositing step, and DOM elements don't get a chance to |
62 | | // die during that. |
63 | | nsSVGClass* mVal; |
64 | | nsSVGElement* mSVGElement; |
65 | | |
66 | | // nsISMILAttr methods |
67 | | virtual nsresult ValueFromString(const nsAString& aStr, |
68 | | const mozilla::dom::SVGAnimationElement *aSrcElement, |
69 | | nsSMILValue& aValue, |
70 | | bool& aPreventCachingOfSandwich) const override; |
71 | | virtual nsSMILValue GetBaseValue() const override; |
72 | | virtual void ClearAnimValue() override; |
73 | | virtual nsresult SetAnimValue(const nsSMILValue& aValue) override; |
74 | | }; |
75 | | }; |
76 | | #endif //__NS_SVGCLASS_H__ |