Line data Source code
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 mozilla_dom_HTMLStyleElement_h
8 : #define mozilla_dom_HTMLStyleElement_h
9 :
10 : #include "mozilla/Attributes.h"
11 : #include "nsIDOMHTMLStyleElement.h"
12 : #include "nsGenericHTMLElement.h"
13 : #include "nsStyleLinkElement.h"
14 : #include "nsStubMutationObserver.h"
15 :
16 : class nsIDocument;
17 :
18 : namespace mozilla {
19 : namespace dom {
20 :
21 : class HTMLStyleElement final : public nsGenericHTMLElement,
22 : public nsIDOMHTMLStyleElement,
23 : public nsStyleLinkElement,
24 : public nsStubMutationObserver
25 : {
26 : public:
27 : explicit HTMLStyleElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
28 :
29 : // nsISupports
30 : NS_DECL_ISUPPORTS_INHERITED
31 :
32 : // CC
33 0 : NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLStyleElement,
34 : nsGenericHTMLElement)
35 :
36 : NS_IMETHOD GetInnerHTML(nsAString& aInnerHTML) override;
37 : using nsGenericHTMLElement::SetInnerHTML;
38 : virtual void SetInnerHTML(const nsAString& aInnerHTML,
39 : mozilla::ErrorResult& aError) override;
40 :
41 : // nsIDOMHTMLStyleElement
42 : NS_DECL_NSIDOMHTMLSTYLEELEMENT
43 :
44 : virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
45 : nsIContent* aBindingParent,
46 : bool aCompileEventHandlers) override;
47 : virtual void UnbindFromTree(bool aDeep = true,
48 : bool aNullParent = true) override;
49 : virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
50 : const nsAttrValue* aValue,
51 : const nsAttrValue* aOldValue,
52 : bool aNotify) override;
53 :
54 : virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
55 : bool aPreallocateChildren) const override;
56 :
57 : // nsIMutationObserver
58 : NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
59 : NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
60 : NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
61 : NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
62 :
63 : bool Disabled();
64 : void SetDisabled(bool aDisabled);
65 0 : void SetMedia(const nsAString& aMedia, ErrorResult& aError)
66 : {
67 0 : SetHTMLAttr(nsGkAtoms::media, aMedia, aError);
68 0 : }
69 0 : void SetType(const nsAString& aType, ErrorResult& aError)
70 : {
71 0 : SetHTMLAttr(nsGkAtoms::type, aType, aError);
72 0 : }
73 0 : bool Scoped()
74 : {
75 0 : return GetBoolAttr(nsGkAtoms::scoped);
76 : }
77 0 : void SetScoped(bool aScoped, ErrorResult& aError)
78 : {
79 0 : SetHTMLBoolAttr(nsGkAtoms::scoped, aScoped, aError);
80 0 : }
81 :
82 : virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
83 :
84 : protected:
85 : virtual ~HTMLStyleElement();
86 :
87 : already_AddRefed<nsIURI> GetStyleSheetURL(bool* aIsInline) override;
88 : void GetStyleSheetInfo(nsAString& aTitle,
89 : nsAString& aType,
90 : nsAString& aMedia,
91 : bool* aIsScoped,
92 : bool* aIsAlternate) override;
93 : /**
94 : * Common method to call from the various mutation observer methods.
95 : * aContent is a content node that's either the one that changed or its
96 : * parent; we should only respond to the change if aContent is non-anonymous.
97 : */
98 : void ContentChanged(nsIContent* aContent);
99 : };
100 :
101 : } // namespace dom
102 : } // namespace mozilla
103 :
104 : #endif
105 :
|