Bug 1880216 - Migrate Fenix docs into Sphinx. r=owlish,geckoview-reviewers,android...
[gecko.git] / dom / html / HTMLBodyElement.h
blob3c836f2ed0eb2b670ae236817ea577bd2863ec43
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 #ifndef HTMLBodyElement_h___
7 #define HTMLBodyElement_h___
9 #include "mozilla/Attributes.h"
10 #include "nsGenericHTMLElement.h"
12 namespace mozilla {
14 class EditorBase;
16 namespace dom {
18 class OnBeforeUnloadEventHandlerNonNull;
20 class HTMLBodyElement final : public nsGenericHTMLElement {
21 public:
22 using Element::GetText;
24 explicit HTMLBodyElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
25 : nsGenericHTMLElement(std::move(aNodeInfo)) {}
27 // nsISupports
28 NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLBodyElement, nsGenericHTMLElement)
30 NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLBodyElement, body);
32 // Event listener stuff; we need to declare only the ones we need to
33 // forward to window that don't come from nsIDOMHTMLBodyElement.
34 #define EVENT(name_, id_, type_, struct_) /* nothing; handled by the shim */
35 #define WINDOW_EVENT_HELPER(name_, type_) \
36 type_* GetOn##name_(); \
37 void SetOn##name_(type_* handler);
38 #define WINDOW_EVENT(name_, id_, type_, struct_) \
39 WINDOW_EVENT_HELPER(name_, EventHandlerNonNull)
40 #define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_) \
41 WINDOW_EVENT_HELPER(name_, OnBeforeUnloadEventHandlerNonNull)
42 #include "mozilla/EventNameList.h" // IWYU pragma: keep
43 #undef BEFOREUNLOAD_EVENT
44 #undef WINDOW_EVENT
45 #undef WINDOW_EVENT_HELPER
46 #undef EVENT
48 void GetText(nsAString& aText) { GetHTMLAttr(nsGkAtoms::text, aText); }
49 void SetText(const nsAString& aText) { SetHTMLAttr(nsGkAtoms::text, aText); }
50 void SetText(const nsAString& aText, ErrorResult& aError) {
51 SetHTMLAttr(nsGkAtoms::text, aText, aError);
53 void GetLink(nsAString& aLink) { GetHTMLAttr(nsGkAtoms::link, aLink); }
54 void SetLink(const nsAString& aLink) { SetHTMLAttr(nsGkAtoms::link, aLink); }
55 void SetLink(const nsAString& aLink, ErrorResult& aError) {
56 SetHTMLAttr(nsGkAtoms::link, aLink, aError);
58 void GetVLink(nsAString& aVLink) { GetHTMLAttr(nsGkAtoms::vlink, aVLink); }
59 void SetVLink(const nsAString& aVLink) {
60 SetHTMLAttr(nsGkAtoms::vlink, aVLink);
62 void SetVLink(const nsAString& aVLink, ErrorResult& aError) {
63 SetHTMLAttr(nsGkAtoms::vlink, aVLink, aError);
65 void GetALink(nsAString& aALink) { GetHTMLAttr(nsGkAtoms::alink, aALink); }
66 void SetALink(const nsAString& aALink) {
67 SetHTMLAttr(nsGkAtoms::alink, aALink);
69 void SetALink(const nsAString& aALink, ErrorResult& aError) {
70 SetHTMLAttr(nsGkAtoms::alink, aALink, aError);
72 void GetBgColor(nsAString& aBgColor) {
73 GetHTMLAttr(nsGkAtoms::bgcolor, aBgColor);
75 void SetBgColor(const nsAString& aBgColor) {
76 SetHTMLAttr(nsGkAtoms::bgcolor, aBgColor);
78 void SetBgColor(const nsAString& aBgColor, ErrorResult& aError) {
79 SetHTMLAttr(nsGkAtoms::bgcolor, aBgColor, aError);
81 void GetBackground(DOMString& aBackground) {
82 GetHTMLAttr(nsGkAtoms::background, aBackground);
84 void GetBackground(nsAString& aBackground) {
85 GetHTMLAttr(nsGkAtoms::background, aBackground);
87 void SetBackground(const nsAString& aBackground, ErrorResult& aError) {
88 SetHTMLAttr(nsGkAtoms::background, aBackground, aError);
91 bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
92 const nsAString& aValue,
93 nsIPrincipal* aMaybeScriptedPrincipal,
94 nsAttrValue& aResult) override;
95 nsMapRuleToAttributesFunc GetAttributeMappingFunction() const override;
96 NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
97 already_AddRefed<EditorBase> GetAssociatedEditor() override;
98 nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
100 bool IsEventAttributeNameInternal(nsAtom* aName) override;
101 nsresult BindToTree(BindContext&, nsINode& aParent) override;
103 void FrameMarginsChanged();
105 protected:
106 virtual ~HTMLBodyElement();
108 JSObject* WrapNode(JSContext*, JS::Handle<JSObject*> aGivenProto) override;
110 private:
111 static void MapAttributesIntoRule(MappedDeclarationsBuilder&);
114 } // namespace dom
115 } // namespace mozilla
117 #endif /* HTMLBodyElement_h___ */