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_SVGSWITCHELEMENT_H_
8 #define DOM_SVG_SVGSWITCHELEMENT_H_
10 #include "mozilla/dom/SVGGraphicsElement.h"
13 nsresult
NS_NewSVGSwitchElement(
14 nsIContent
** aResult
, already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
);
19 using SVGSwitchElementBase
= SVGGraphicsElement
;
21 class SVGSwitchElement final
: public SVGSwitchElementBase
{
23 friend nsresult(::NS_NewSVGSwitchElement(
25 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
));
26 explicit SVGSwitchElement(
27 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
);
28 ~SVGSwitchElement() = default;
29 virtual JSObject
* WrapNode(JSContext
* aCx
,
30 JS::Handle
<JSObject
*> aGivenProto
) override
;
33 nsIContent
* GetActiveChild() const { return mActiveChild
; }
34 void MaybeInvalidate();
38 NS_DECL_ISUPPORTS_INHERITED
39 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGSwitchElement
,
42 virtual nsresult
InsertChildBefore(nsIContent
* aKid
, nsIContent
* aBeforeThis
,
43 bool aNotify
) override
;
44 virtual void RemoveChildNode(nsIContent
* aKid
, bool aNotify
) override
;
47 NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom
* aAttribute
) const override
;
49 virtual nsresult
Clone(dom::NodeInfo
*, nsINode
** aResult
) const override
;
52 void UpdateActiveChild() { mActiveChild
= FindActiveChild(); }
53 nsIContent
* FindActiveChild() const;
55 // only this child will be displayed
56 nsCOMPtr
<nsIContent
> mActiveChild
;
60 } // namespace mozilla
62 #endif // DOM_SVG_SVGSWITCHELEMENT_H_