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_SVGSTYLEELEMENT_H_
8 #define DOM_SVG_SVGSTYLEELEMENT_H_
10 #include "mozilla/Attributes.h"
11 #include "mozilla/dom/LinkStyle.h"
12 #include "SVGElement.h"
13 #include "nsStubMutationObserver.h"
15 nsresult
NS_NewSVGStyleElement(
16 nsIContent
** aResult
, already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
);
18 namespace mozilla::dom
{
20 using SVGStyleElementBase
= SVGElement
;
22 class SVGStyleElement final
: public SVGStyleElementBase
,
23 public nsStubMutationObserver
,
26 friend nsresult(::NS_NewSVGStyleElement(
28 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
));
29 explicit SVGStyleElement(
30 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
);
31 ~SVGStyleElement() = default;
33 JSObject
* WrapNode(JSContext
* aCx
,
34 JS::Handle
<JSObject
*> aGivenProto
) override
;
37 NS_DECL_ISUPPORTS_INHERITED
39 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGStyleElement
, SVGStyleElementBase
)
42 nsresult
BindToTree(BindContext
&, nsINode
& aParent
) override
;
43 void UnbindFromTree(UnbindContext
&) override
;
44 virtual void AfterSetAttr(int32_t aNameSpaceID
, nsAtom
* aName
,
45 const nsAttrValue
* aValue
,
46 const nsAttrValue
* aOldValue
,
47 nsIPrincipal
* aMaybeScriptedPrincipal
,
48 bool aNotify
) override
;
49 virtual bool ParseAttribute(int32_t aNamespaceID
, nsAtom
* aAttribute
,
50 const nsAString
& aValue
,
51 nsIPrincipal
* aMaybeScriptedPrincipal
,
52 nsAttrValue
& aResult
) override
;
54 nsresult
Clone(dom::NodeInfo
*, nsINode
** aResult
) const override
;
56 // nsIMutationObserver
57 NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
58 NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
59 NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
60 NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
63 bool Disabled() const;
64 void SetDisabled(bool aDisabled
);
65 void GetMedia(nsAString
& aMedia
);
66 void SetMedia(const nsAString
& aMedia
, ErrorResult
& rv
);
67 void GetType(nsAString
& aType
);
68 void SetType(const nsAString
& aType
, ErrorResult
& rv
);
69 void GetTitle(nsAString
& aTitle
);
70 void SetTitle(const nsAString
& aTitle
, ErrorResult
& rv
);
73 // Dummy init method to make the NS_IMPL_NS_NEW_SVG_ELEMENT and
74 // NS_IMPL_ELEMENT_CLONE_WITH_INIT usable with this class. This should be
75 // completely optimized away.
76 inline nsresult
Init() { return NS_OK
; }
78 // LinkStyle overrides
79 nsIContent
& AsContent() final
{ return *this; }
80 const LinkStyle
* AsLinkStyle() const final
{ return this; }
81 Maybe
<SheetInfo
> GetStyleSheetInfo() final
;
84 * Common method to call from the various mutation observer methods.
85 * aContent is a content node that's either the one that changed or its
86 * parent; we should only respond to the change if aContent is non-anonymous.
88 void ContentChanged(nsIContent
* aContent
);
91 } // namespace mozilla::dom
93 #endif // DOM_SVG_SVGSTYLEELEMENT_H_