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
);
20 using SVGSwitchElementBase
= SVGGraphicsElement
;
22 class SVGSwitchElement final
: public SVGSwitchElementBase
{
24 friend nsresult(::NS_NewSVGSwitchElement(
26 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
));
27 explicit SVGSwitchElement(
28 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
);
29 ~SVGSwitchElement() = default;
30 JSObject
* WrapNode(JSContext
* aCx
,
31 JS::Handle
<JSObject
*> aGivenProto
) override
;
34 NS_IMPL_FROMNODE_WITH_TAG(SVGSwitchElement
, kNameSpaceID_SVG
, svgSwitch
)
36 nsIContent
* GetActiveChild() const { return mActiveChild
; }
37 void MaybeInvalidate();
41 NS_DECL_ISUPPORTS_INHERITED
42 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGSwitchElement
,
45 virtual void InsertChildBefore(nsIContent
* aKid
, nsIContent
* aBeforeThis
,
46 bool aNotify
, ErrorResult
& aRv
) override
;
47 void RemoveChildNode(nsIContent
* aKid
, bool aNotify
) override
;
50 nsresult
Clone(dom::NodeInfo
*, nsINode
** aResult
) const override
;
53 void UpdateActiveChild() { mActiveChild
= FindActiveChild(); }
54 nsIContent
* FindActiveChild() const;
56 // only this child will be displayed
57 nsCOMPtr
<nsIContent
> mActiveChild
;
61 } // namespace mozilla
63 #endif // DOM_SVG_SVGSWITCHELEMENT_H_