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 :
7 : #ifndef mozilla_dom_HTMLAreaElement_h
8 : #define mozilla_dom_HTMLAreaElement_h
9 :
10 : #include "mozilla/Attributes.h"
11 : #include "mozilla/dom/Link.h"
12 : #include "nsGenericHTMLElement.h"
13 : #include "nsGkAtoms.h"
14 : #include "nsDOMTokenList.h"
15 : #include "nsIDOMHTMLAreaElement.h"
16 : #include "nsIURL.h"
17 :
18 : class nsIDocument;
19 :
20 : namespace mozilla {
21 : class EventChainPostVisitor;
22 : class EventChainPreVisitor;
23 : namespace dom {
24 :
25 : class HTMLAreaElement final : public nsGenericHTMLElement,
26 : public nsIDOMHTMLAreaElement,
27 : public Link
28 : {
29 : public:
30 : explicit HTMLAreaElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
31 :
32 : // nsISupports
33 : NS_DECL_ISUPPORTS_INHERITED
34 :
35 : // CC
36 0 : NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLAreaElement,
37 : nsGenericHTMLElement)
38 :
39 : // DOM memory reporter participant
40 : NS_DECL_SIZEOF_EXCLUDING_THIS
41 :
42 : virtual int32_t TabIndexDefault() override;
43 :
44 : // nsIDOMHTMLAreaElement
45 : NS_DECL_NSIDOMHTMLAREAELEMENT
46 :
47 : virtual nsresult GetEventTargetParent(
48 : EventChainPreVisitor& aVisitor) override;
49 : virtual nsresult PostHandleEvent(EventChainPostVisitor& aVisitor) override;
50 : virtual bool IsLink(nsIURI** aURI) const override;
51 : virtual void GetLinkTarget(nsAString& aTarget) override;
52 : virtual already_AddRefed<nsIURI> GetHrefURI() const override;
53 :
54 : virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
55 : nsIContent* aBindingParent,
56 : bool aCompileEventHandlers) override;
57 : virtual void UnbindFromTree(bool aDeep = true,
58 : bool aNullParent = true) override;
59 :
60 : virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult,
61 : bool aPreallocateChildren) const override;
62 :
63 : virtual EventStates IntrinsicState() const override;
64 :
65 : // WebIDL
66 :
67 : // The XPCOM GetAlt is OK for us
68 0 : void SetAlt(const nsAString& aAlt, ErrorResult& aError)
69 : {
70 0 : SetHTMLAttr(nsGkAtoms::alt, aAlt, aError);
71 0 : }
72 :
73 : // The XPCOM GetCoords is OK for us
74 0 : void SetCoords(const nsAString& aCoords, ErrorResult& aError)
75 : {
76 0 : SetHTMLAttr(nsGkAtoms::coords, aCoords, aError);
77 0 : }
78 :
79 : // The XPCOM GetShape is OK for us
80 0 : void SetShape(const nsAString& aShape, ErrorResult& aError)
81 : {
82 0 : SetHTMLAttr(nsGkAtoms::shape, aShape, aError);
83 0 : }
84 :
85 : // The XPCOM GetHref is OK for us
86 0 : void SetHref(const nsAString& aHref, ErrorResult& aError)
87 : {
88 0 : aError = SetHref(aHref);
89 0 : }
90 :
91 : // The XPCOM GetTarget is OK for us
92 0 : void SetTarget(const nsAString& aTarget, ErrorResult& aError)
93 : {
94 0 : SetHTMLAttr(nsGkAtoms::target, aTarget, aError);
95 0 : }
96 :
97 : // The XPCOM GetDownload is OK for us
98 0 : void SetDownload(const nsAString& aDownload, ErrorResult& aError)
99 : {
100 0 : SetHTMLAttr(nsGkAtoms::download, aDownload, aError);
101 0 : }
102 :
103 : // The XPCOM GetPing is OK for us
104 0 : void SetPing(const nsAString& aPing, ErrorResult& aError)
105 : {
106 0 : SetHTMLAttr(nsGkAtoms::ping, aPing, aError);
107 0 : }
108 :
109 0 : void GetRel(DOMString& aValue)
110 : {
111 0 : GetHTMLAttr(nsGkAtoms::rel, aValue);
112 0 : }
113 :
114 0 : void SetRel(const nsAString& aRel, ErrorResult& aError)
115 : {
116 0 : SetHTMLAttr(nsGkAtoms::rel, aRel, aError);
117 0 : }
118 : nsDOMTokenList* RelList();
119 :
120 0 : void SetReferrerPolicy(const nsAString& aValue, mozilla::ErrorResult& rv)
121 : {
122 0 : SetHTMLAttr(nsGkAtoms::referrerpolicy, aValue, rv);
123 0 : }
124 0 : void GetReferrerPolicy(nsAString& aReferrer)
125 : {
126 0 : GetEnumAttr(nsGkAtoms::referrerpolicy, EmptyCString().get(), aReferrer);
127 0 : }
128 :
129 : // The Link::GetOrigin is OK for us
130 :
131 : // Link::Link::GetProtocol is OK for us
132 : // Link::Link::SetProtocol is OK for us
133 :
134 : // The Link::GetUsername is OK for us
135 : // The Link::SetUsername is OK for us
136 :
137 : // The Link::GetPassword is OK for us
138 : // The Link::SetPassword is OK for us
139 :
140 : // Link::Link::GetHost is OK for us
141 : // Link::Link::SetHost is OK for us
142 :
143 : // Link::Link::GetHostname is OK for us
144 : // Link::Link::SetHostname is OK for us
145 :
146 : // Link::Link::GetPort is OK for us
147 : // Link::Link::SetPort is OK for us
148 :
149 : // Link::Link::GetPathname is OK for us
150 : // Link::Link::SetPathname is OK for us
151 :
152 : // Link::Link::GetSearch is OK for us
153 : // Link::Link::SetSearch is OK for us
154 :
155 : // Link::Link::GetHash is OK for us
156 : // Link::Link::SetHash is OK for us
157 :
158 : // The Link::GetSearchParams is OK for us
159 :
160 0 : bool NoHref() const
161 : {
162 0 : return GetBoolAttr(nsGkAtoms::nohref);
163 : }
164 :
165 0 : void SetNoHref(bool aValue, ErrorResult& aError)
166 : {
167 0 : SetHTMLBoolAttr(nsGkAtoms::nohref, aValue, aError);
168 0 : }
169 :
170 0 : void Stringify(nsAString& aResult)
171 : {
172 0 : GetHref(aResult);
173 0 : }
174 :
175 0 : virtual void NodeInfoChanged(nsIDocument* aOldDoc) final override
176 : {
177 0 : ClearHasPendingLinkUpdate();
178 0 : nsGenericHTMLElement::NodeInfoChanged(aOldDoc);
179 0 : }
180 :
181 : protected:
182 : virtual ~HTMLAreaElement();
183 :
184 : virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
185 :
186 : virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
187 : const nsAttrValue* aValue,
188 : const nsAttrValue* aOldValue,
189 : bool aNotify) override;
190 :
191 : RefPtr<nsDOMTokenList > mRelList;
192 : };
193 :
194 : } // namespace dom
195 : } // namespace mozilla
196 :
197 : #endif /* mozilla_dom_HTMLAreaElement_h */
|