Bug 1890793: Assert CallArgs::newTarget is not gray. r=spidermonkey-reviewers,sfink...
[gecko.git] / dom / svg / SVGSwitchElement.h
blobc244c0fe5160e9d91711e59583441b0f0aae385d
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"
11 #include "nsCOMPtr.h"
13 nsresult NS_NewSVGSwitchElement(
14 nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
16 namespace mozilla {
17 class ErrorResult;
18 namespace dom {
20 using SVGSwitchElementBase = SVGGraphicsElement;
22 class SVGSwitchElement final : public SVGSwitchElementBase {
23 protected:
24 friend nsresult(::NS_NewSVGSwitchElement(
25 nsIContent** aResult,
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;
33 public:
34 NS_IMPL_FROMNODE_WITH_TAG(SVGSwitchElement, kNameSpaceID_SVG, svgSwitch)
36 nsIContent* GetActiveChild() const { return mActiveChild; }
37 void MaybeInvalidate();
39 // interfaces:
41 NS_DECL_ISUPPORTS_INHERITED
42 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGSwitchElement,
43 SVGSwitchElementBase)
44 // nsINode
45 virtual void InsertChildBefore(nsIContent* aKid, nsIContent* aBeforeThis,
46 bool aNotify, ErrorResult& aRv) override;
47 void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
49 // nsIContent
50 nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
52 private:
53 void UpdateActiveChild() { mActiveChild = FindActiveChild(); }
54 nsIContent* FindActiveChild() const;
56 // only this child will be displayed
57 nsCOMPtr<nsIContent> mActiveChild;
60 } // namespace dom
61 } // namespace mozilla
63 #endif // DOM_SVG_SVGSWITCHELEMENT_H_