Bug 1936278 - Prevent search mode chiclet from being dismissed when clicking in page...
[gecko.git] / dom / svg / SVGAnimatedClass.h
blobbc510b1d4d7a7316c204f7ad8aed7903f6dc03c9
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_SVG_SVGANIMATEDCLASS_H_
8 #define DOM_SVG_SVGANIMATEDCLASS_H_
10 #include "nsCycleCollectionParticipant.h"
11 #include "mozilla/SVGAnimatedClassOrString.h"
12 #include "mozilla/Attributes.h"
13 #include "mozilla/SMILAttr.h"
14 #include "mozilla/UniquePtr.h"
16 namespace mozilla {
18 class SMILValue;
20 namespace dom {
21 class DOMSVGAnimatedString;
22 class SVGElement;
23 } // namespace dom
25 class SVGAnimatedClass final : public SVGAnimatedClassOrString {
26 public:
27 using SVGElement = dom::SVGElement;
29 void Init() { mAnimVal = nullptr; }
31 void SetBaseValue(const nsAString& aValue, SVGElement* aSVGElement,
32 bool aDoSetAttr) override;
33 void GetBaseValue(nsAString& aValue,
34 const SVGElement* aSVGElement) const override;
36 void SetAnimValue(const nsAString& aValue, SVGElement* aSVGElement);
37 void GetAnimValue(nsAString& aResult,
38 const SVGElement* aSVGElement) const override;
39 bool IsAnimated() const { return !!mAnimVal; }
41 UniquePtr<SMILAttr> ToSMILAttr(SVGElement* aSVGElement);
43 private:
44 UniquePtr<nsString> mAnimVal;
46 public:
47 struct SMILString : public SMILAttr {
48 public:
49 SMILString(SVGAnimatedClass* aVal, SVGElement* aSVGElement)
50 : mVal(aVal), mSVGElement(aSVGElement) {}
52 // These will stay alive because a SMILAttr only lives as long
53 // as the Compositing step, and DOM elements don't get a chance to
54 // die during that.
55 SVGAnimatedClass* mVal;
56 SVGElement* mSVGElement;
58 // SMILAttr methods
59 nsresult ValueFromString(const nsAString& aStr,
60 const dom::SVGAnimationElement* aSrcElement,
61 SMILValue& aValue,
62 bool& aPreventCachingOfSandwich) const override;
63 SMILValue GetBaseValue() const override;
64 void ClearAnimValue() override;
65 nsresult SetAnimValue(const SMILValue& aValue) override;
69 } // namespace mozilla
71 #endif // DOM_SVG_SVGANIMATEDCLASS_H_