SVGSwitchElement.h (2259B)
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 DOM_SVG_SVGSWITCHELEMENT_H_ 8 #define DOM_SVG_SVGSWITCHELEMENT_H_ 9 10 #include "mozilla/dom/SVGGraphicsElement.h" 11 #include "nsCOMPtr.h" 12 13 nsresult NS_NewSVGSwitchElement( 14 nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo); 15 16 namespace mozilla { 17 class ErrorResult; 18 namespace dom { 19 20 using SVGSwitchElementBase = SVGGraphicsElement; 21 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; 32 33 public: 34 NS_IMPL_FROMNODE_WITH_TAG(SVGSwitchElement, kNameSpaceID_SVG, svgSwitch) 35 36 nsIContent* GetActiveChild() const { return mActiveChild; } 37 void MaybeInvalidate(); 38 39 // interfaces: 40 41 NS_DECL_ISUPPORTS_INHERITED 42 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGSwitchElement, 43 SVGSwitchElementBase) 44 // nsINode 45 void InsertChildBefore( 46 nsIContent* aKid, nsIContent* aBeforeThis, bool aNotify, ErrorResult& aRv, 47 nsINode* aOldParent = nullptr, 48 MutationEffectOnScript aMutationEffectOnScript = 49 MutationEffectOnScript::DropTrustWorthiness) override; 50 void RemoveChildNode( 51 nsIContent* aKid, bool aNotify, const BatchRemovalState* aState, 52 nsINode* aNewParent = nullptr, 53 MutationEffectOnScript aMutationEffectOnScript = 54 MutationEffectOnScript::DropTrustWorthiness) override; 55 56 // nsIContent 57 nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override; 58 59 private: 60 // only this child will be displayed 61 nsCOMPtr<nsIContent> mActiveChild; 62 }; 63 64 } // namespace dom 65 } // namespace mozilla 66 67 #endif // DOM_SVG_SVGSWITCHELEMENT_H_