Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / html / HTMLStyleElement.h
blob8f637dc60d91bea070d0123909d7033d73a3068e
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_HTMLStyleElement_h
8 #define mozilla_dom_HTMLStyleElement_h
10 #include "mozilla/Attributes.h"
11 #include "mozilla/dom/LinkStyle.h"
12 #include "nsGenericHTMLElement.h"
13 #include "nsStubMutationObserver.h"
15 class nsDOMTokenList;
17 namespace mozilla::dom {
19 class HTMLStyleElement final : public nsGenericHTMLElement,
20 public LinkStyle,
21 public nsStubMutationObserver {
22 public:
23 explicit HTMLStyleElement(
24 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
26 // nsISupports
27 NS_DECL_ISUPPORTS_INHERITED
29 // CC
30 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLStyleElement,
31 nsGenericHTMLElement)
33 void GetInnerHTML(nsAString& aInnerHTML, OOMReporter& aError) override;
34 using nsGenericHTMLElement::SetInnerHTML;
35 virtual void SetInnerHTML(const nsAString& aInnerHTML,
36 nsIPrincipal* aSubjectPrincipal,
37 mozilla::ErrorResult& aError) override;
38 virtual void SetTextContentInternal(const nsAString& aTextContent,
39 nsIPrincipal* aSubjectPrincipal,
40 mozilla::ErrorResult& aError) override;
41 /**
42 * Mark this style element with a devtools-specific principal that
43 * skips Content Security Policy unsafe-inline checks. This triggering
44 * principal will be overwritten by any callers that set textContent
45 * or innerHTML on this element.
47 void SetDevtoolsAsTriggeringPrincipal();
49 virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
50 virtual void UnbindFromTree(UnbindContext&) override;
51 bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
52 const nsAString& aValue,
53 nsIPrincipal* aMaybeScriptedPrincipal,
54 nsAttrValue& aResult) override;
55 virtual void AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
56 const nsAttrValue* aValue,
57 const nsAttrValue* aOldValue,
58 nsIPrincipal* aSubjectPrincipal,
59 bool aNotify) override;
61 virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
63 // nsIMutationObserver
64 NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
65 NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
66 NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
67 NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
69 bool Disabled() const;
70 void SetDisabled(bool aDisabled);
71 void GetMedia(nsAString& aValue) { GetHTMLAttr(nsGkAtoms::media, aValue); }
72 void SetMedia(const nsAString& aMedia, ErrorResult& aError) {
73 SetHTMLAttr(nsGkAtoms::media, aMedia, aError);
75 void GetType(nsAString& aValue) { GetHTMLAttr(nsGkAtoms::type, aValue); }
76 void SetType(const nsAString& aType, ErrorResult& aError) {
77 SetHTMLAttr(nsGkAtoms::type, aType, aError);
80 nsDOMTokenList* Blocking();
81 bool IsPotentiallyRenderBlocking() override;
83 virtual JSObject* WrapNode(JSContext* aCx,
84 JS::Handle<JSObject*> aGivenProto) override;
86 protected:
87 virtual ~HTMLStyleElement();
89 nsIContent& AsContent() final { return *this; }
90 const LinkStyle* AsLinkStyle() const final { return this; }
91 Maybe<SheetInfo> GetStyleSheetInfo() final;
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.
98 void ContentChanged(nsIContent* aContent);
100 RefPtr<nsDOMTokenList> mBlocking;
103 } // namespace mozilla::dom
105 #endif