Bug 1732219 - Add API for fetching the preview image. r=geckoview-reviewers,agi,mconley
[gecko.git] / dom / html / HTMLStyleElement.h
blob031ea7f0a3d26b88eb16a613f15e56f3a436c962
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 namespace mozilla {
16 namespace dom {
18 class HTMLStyleElement final : public nsGenericHTMLElement,
19 public LinkStyle,
20 public nsStubMutationObserver {
21 public:
22 explicit HTMLStyleElement(
23 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
25 // nsISupports
26 NS_DECL_ISUPPORTS_INHERITED
28 // CC
29 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLStyleElement,
30 nsGenericHTMLElement)
32 void GetInnerHTML(nsAString& aInnerHTML, OOMReporter& aError) override;
33 using nsGenericHTMLElement::SetInnerHTML;
34 virtual void SetInnerHTML(const nsAString& aInnerHTML,
35 nsIPrincipal* aSubjectPrincipal,
36 mozilla::ErrorResult& aError) override;
37 virtual void SetTextContentInternal(const nsAString& aTextContent,
38 nsIPrincipal* aSubjectPrincipal,
39 mozilla::ErrorResult& aError) override;
40 /**
41 * Mark this style element with a devtools-specific principal that
42 * skips Content Security Policy unsafe-inline checks. This triggering
43 * principal will be overwritten by any callers that set textContent
44 * or innerHTML on this element.
46 void SetDevtoolsAsTriggeringPrincipal();
48 virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
49 virtual void UnbindFromTree(bool aNullParent = true) override;
50 virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
51 const nsAttrValue* aValue,
52 const nsAttrValue* aOldValue,
53 nsIPrincipal* aSubjectPrincipal,
54 bool aNotify) override;
56 virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
58 // nsIMutationObserver
59 NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
60 NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
61 NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
62 NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
64 bool Disabled() const;
65 void SetDisabled(bool aDisabled);
66 void GetMedia(nsAString& aValue) { GetHTMLAttr(nsGkAtoms::media, aValue); }
67 void SetMedia(const nsAString& aMedia, ErrorResult& aError) {
68 SetHTMLAttr(nsGkAtoms::media, aMedia, aError);
70 void GetType(nsAString& aValue) { GetHTMLAttr(nsGkAtoms::type, aValue); }
71 void SetType(const nsAString& aType, ErrorResult& aError) {
72 SetHTMLAttr(nsGkAtoms::type, aType, aError);
75 virtual JSObject* WrapNode(JSContext* aCx,
76 JS::Handle<JSObject*> aGivenProto) override;
78 protected:
79 virtual ~HTMLStyleElement();
81 nsIContent& AsContent() final { return *this; }
82 const LinkStyle* AsLinkStyle() const final { return this; }
83 Maybe<SheetInfo> GetStyleSheetInfo() final;
85 /**
86 * Common method to call from the various mutation observer methods.
87 * aContent is a content node that's either the one that changed or its
88 * parent; we should only respond to the change if aContent is non-anonymous.
90 void ContentChanged(nsIContent* aContent);
93 } // namespace dom
94 } // namespace mozilla
96 #endif