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"
18 class OnBeforeUnloadEventHandlerNonNull
;
20 class HTMLBodyElement final
: public nsGenericHTMLElement
{
22 using Element::GetText
;
24 explicit HTMLBodyElement(already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
)
25 : nsGenericHTMLElement(std::move(aNodeInfo
)) {}
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
45 #undef WINDOW_EVENT_HELPER
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();
106 virtual ~HTMLBodyElement();
108 JSObject
* WrapNode(JSContext
*, JS::Handle
<JSObject
*> aGivenProto
) override
;
111 static void MapAttributesIntoRule(MappedDeclarationsBuilder
&);
115 } // namespace mozilla
117 #endif /* HTMLBodyElement_h___ */