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 : #ifndef HTMLBodyElement_h___
7 : #define HTMLBodyElement_h___
8 :
9 : #include "mozilla/Attributes.h"
10 : #include "nsGenericHTMLElement.h"
11 : #include "nsIDOMHTMLBodyElement.h"
12 : #include "nsIStyleRule.h"
13 :
14 : namespace mozilla {
15 : namespace dom {
16 :
17 : class OnBeforeUnloadEventHandlerNonNull;
18 :
19 : class HTMLBodyElement final : public nsGenericHTMLElement,
20 : public nsIDOMHTMLBodyElement
21 : {
22 : public:
23 : using Element::GetText;
24 : using Element::SetText;
25 :
26 7 : explicit HTMLBodyElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
27 7 : : nsGenericHTMLElement(aNodeInfo)
28 : {
29 7 : }
30 :
31 : // nsISupports
32 : NS_DECL_ISUPPORTS_INHERITED
33 :
34 : // nsIDOMHTMLBodyElement
35 : NS_DECL_NSIDOMHTMLBODYELEMENT
36 :
37 : // Event listener stuff; we need to declare only the ones we need to
38 : // forward to window that don't come from nsIDOMHTMLBodyElement.
39 : #define EVENT(name_, id_, type_, struct_) /* nothing; handled by the shim */
40 : #define WINDOW_EVENT_HELPER(name_, type_) \
41 : type_* GetOn##name_(); \
42 : void SetOn##name_(type_* handler);
43 : #define WINDOW_EVENT(name_, id_, type_, struct_) \
44 : WINDOW_EVENT_HELPER(name_, EventHandlerNonNull)
45 : #define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_) \
46 : WINDOW_EVENT_HELPER(name_, OnBeforeUnloadEventHandlerNonNull)
47 : #include "mozilla/EventNameList.h" // IWYU pragma: keep
48 : #undef BEFOREUNLOAD_EVENT
49 : #undef WINDOW_EVENT
50 : #undef WINDOW_EVENT_HELPER
51 : #undef EVENT
52 :
53 0 : void GetText(DOMString& aText)
54 : {
55 0 : GetHTMLAttr(nsGkAtoms::text, aText);
56 0 : }
57 0 : void SetText(const nsAString& aText, ErrorResult& aError)
58 : {
59 0 : SetHTMLAttr(nsGkAtoms::text, aText, aError);
60 0 : }
61 0 : void GetLink(DOMString& aLink)
62 : {
63 0 : GetHTMLAttr(nsGkAtoms::link, aLink);
64 0 : }
65 0 : void SetLink(const nsAString& aLink, ErrorResult& aError)
66 : {
67 0 : SetHTMLAttr(nsGkAtoms::link, aLink, aError);
68 0 : }
69 0 : void GetVLink(DOMString& aVLink)
70 : {
71 0 : GetHTMLAttr(nsGkAtoms::vlink, aVLink);
72 0 : }
73 0 : void SetVLink(const nsAString& aVLink, ErrorResult& aError)
74 : {
75 0 : SetHTMLAttr(nsGkAtoms::vlink, aVLink, aError);
76 0 : }
77 0 : void GetALink(DOMString& aALink)
78 : {
79 0 : GetHTMLAttr(nsGkAtoms::alink, aALink);
80 0 : }
81 0 : void SetALink(const nsAString& aALink, ErrorResult& aError)
82 : {
83 0 : SetHTMLAttr(nsGkAtoms::alink, aALink, aError);
84 0 : }
85 0 : void GetBgColor(DOMString& aBgColor)
86 : {
87 0 : GetHTMLAttr(nsGkAtoms::bgcolor, aBgColor);
88 0 : }
89 0 : void SetBgColor(const nsAString& aBgColor, ErrorResult& aError)
90 : {
91 0 : SetHTMLAttr(nsGkAtoms::bgcolor, aBgColor, aError);
92 0 : }
93 0 : void GetBackground(DOMString& aBackground)
94 : {
95 0 : GetHTMLAttr(nsGkAtoms::background, aBackground);
96 0 : }
97 0 : void SetBackground(const nsAString& aBackground, ErrorResult& aError)
98 : {
99 0 : SetHTMLAttr(nsGkAtoms::background, aBackground, aError);
100 0 : }
101 :
102 : virtual bool ParseAttribute(int32_t aNamespaceID,
103 : nsIAtom* aAttribute,
104 : const nsAString& aValue,
105 : nsAttrValue& aResult) override;
106 : virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const override;
107 : NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const override;
108 : virtual already_AddRefed<nsIEditor> GetAssociatedEditor() override;
109 : virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
110 : bool aPreallocateChildren) const override;
111 :
112 : virtual bool IsEventAttributeNameInternal(nsIAtom* aName) override;
113 :
114 :
115 : virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
116 : nsIContent* aBindingParent,
117 : bool aCompileEventHandlers) override;
118 : /**
119 : * Called when an attribute has just been changed
120 : */
121 : virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
122 : const nsAttrValue* aValue,
123 : const nsAttrValue* aOldValue,
124 : bool aNotify) override;
125 :
126 : protected:
127 : virtual ~HTMLBodyElement();
128 :
129 : virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
130 :
131 : private:
132 : static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
133 : GenericSpecifiedValues* aGenericData);
134 : };
135 :
136 : } // namespace dom
137 : } // namespace mozilla
138 :
139 : #endif /* HTMLBodyElement_h___ */
|