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 mozilla_dom_SVGStyleElement_h
8 #define mozilla_dom_SVGStyleElement_h
10 #include "mozilla/Attributes.h"
11 #include "nsSVGElement.h"
12 #include "nsStyleLinkElement.h"
13 #include "nsStubMutationObserver.h"
15 nsresult
NS_NewSVGStyleElement(nsIContent
**aResult
,
16 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
);
18 typedef nsSVGElement SVGStyleElementBase
;
23 class SVGStyleElement final
: public SVGStyleElementBase
,
24 public nsStyleLinkElement
,
25 public nsStubMutationObserver
28 friend nsresult (::NS_NewSVGStyleElement(nsIContent
**aResult
,
29 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
));
30 explicit SVGStyleElement(already_AddRefed
<mozilla::dom::NodeInfo
>& aNodeInfo
);
33 virtual JSObject
* WrapNode(JSContext
*aCx
, JS::Handle
<JSObject
*> aGivenProto
) override
;
36 NS_DECL_ISUPPORTS_INHERITED
38 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGStyleElement
,
42 virtual nsresult
BindToTree(nsIDocument
* aDocument
, nsIContent
* aParent
,
43 nsIContent
* aBindingParent
,
44 bool aCompileEventHandlers
) override
;
45 virtual void UnbindFromTree(bool aDeep
= true,
46 bool aNullParent
= true) override
;
47 virtual nsresult
AfterSetAttr(int32_t aNameSpaceID
, nsAtom
* aName
,
48 const nsAttrValue
* aValue
,
49 const nsAttrValue
* aOldValue
,
50 nsIPrincipal
* aMaybeScriptedPrincipal
,
51 bool aNotify
) override
;
52 virtual bool ParseAttribute(int32_t aNamespaceID
,
54 const nsAString
& aValue
,
55 nsIPrincipal
* aMaybeScriptedPrincipal
,
56 nsAttrValue
& aResult
) override
;
58 virtual nsresult
Clone(mozilla::dom::NodeInfo
*aNodeInfo
, nsINode
**aResult
,
59 bool aPreallocateChildren
) const override
;
61 // nsIMutationObserver
62 NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
63 NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
64 NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
65 NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
68 void GetXmlspace(nsAString
& aXmlspace
);
69 void SetXmlspace(const nsAString
& aXmlspace
, ErrorResult
& rv
);
70 void GetMedia(nsAString
& aMedia
);
71 void SetMedia(const nsAString
& aMedia
, ErrorResult
& rv
);
72 void GetType(nsAString
& aType
);
73 void SetType(const nsAString
& aType
, ErrorResult
& rv
);
74 void GetTitle(nsAString
& aTitle
);
75 void SetTitle(const nsAString
& aTitle
, ErrorResult
& rv
);
78 // Dummy init method to make the NS_IMPL_NS_NEW_SVG_ELEMENT and
79 // NS_IMPL_ELEMENT_CLONE_WITH_INIT usable with this class. This should be
80 // completely optimized away.
81 inline nsresult
Init()
86 // nsStyleLinkElement overrides
87 Maybe
<SheetInfo
> GetStyleSheetInfo() final
;
90 * Common method to call from the various mutation observer methods.
91 * aContent is a content node that's either the one that changed or its
92 * parent; we should only respond to the change if aContent is non-anonymous.
94 void ContentChanged(nsIContent
* aContent
);
98 } // namespace mozilla
100 #endif // mozilla_dom_SVGStyleElement_h