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_HTMLAreaElement_h
8 #define mozilla_dom_HTMLAreaElement_h
10 #include "mozilla/Attributes.h"
11 #include "mozilla/dom/Link.h"
12 #include "nsGenericHTMLElement.h"
13 #include "nsGkAtoms.h"
16 class EventChainPostVisitor
;
17 class EventChainPreVisitor
;
20 class HTMLAreaElement final
: public nsGenericHTMLElement
, public Link
{
22 explicit HTMLAreaElement(
23 already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
);
26 NS_DECL_ISUPPORTS_INHERITED
29 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLAreaElement
,
32 NS_DECL_ADDSIZEOFEXCLUDINGTHIS
34 NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLAreaElement
, area
)
36 virtual int32_t TabIndexDefault() override
;
38 void GetEventTargetParent(EventChainPreVisitor
& aVisitor
) override
;
40 nsresult
PostHandleEvent(EventChainPostVisitor
& aVisitor
) override
;
41 virtual bool IsLink(nsIURI
** aURI
) const override
;
42 virtual void GetLinkTarget(nsAString
& aTarget
) override
;
43 virtual already_AddRefed
<nsIURI
> GetHrefURI() const override
;
45 virtual nsresult
BindToTree(BindContext
&, nsINode
& aParent
) override
;
46 virtual void UnbindFromTree(bool aNullParent
= true) override
;
48 virtual nsresult
Clone(dom::NodeInfo
*, nsINode
** aResult
) const override
;
50 virtual EventStates
IntrinsicState() const override
;
53 void GetAlt(DOMString
& aValue
) { GetHTMLAttr(nsGkAtoms::alt
, aValue
); }
54 void SetAlt(const nsAString
& aAlt
, ErrorResult
& aError
) {
55 SetHTMLAttr(nsGkAtoms::alt
, aAlt
, aError
);
58 void GetCoords(DOMString
& aValue
) { GetHTMLAttr(nsGkAtoms::coords
, aValue
); }
59 void SetCoords(const nsAString
& aCoords
, ErrorResult
& aError
) {
60 SetHTMLAttr(nsGkAtoms::coords
, aCoords
, aError
);
63 // argument type nsAString for HTMLImageMapAccessible
64 void GetShape(nsAString
& aValue
) { GetHTMLAttr(nsGkAtoms::shape
, aValue
); }
65 void SetShape(const nsAString
& aShape
, ErrorResult
& aError
) {
66 SetHTMLAttr(nsGkAtoms::shape
, aShape
, aError
);
69 // argument type nsAString for nsContextMenuInfo
70 void GetHref(nsAString
& aValue
) {
71 GetURIAttr(nsGkAtoms::href
, nullptr, aValue
);
73 void SetHref(const nsAString
& aHref
, ErrorResult
& aError
) {
74 SetHTMLAttr(nsGkAtoms::href
, aHref
, aError
);
77 void GetTarget(DOMString
& aValue
);
78 void SetTarget(const nsAString
& aTarget
, ErrorResult
& aError
) {
79 SetHTMLAttr(nsGkAtoms::target
, aTarget
, aError
);
82 void GetDownload(DOMString
& aValue
) {
83 GetHTMLAttr(nsGkAtoms::download
, aValue
);
85 void SetDownload(const nsAString
& aDownload
, ErrorResult
& aError
) {
86 SetHTMLAttr(nsGkAtoms::download
, aDownload
, aError
);
89 void GetPing(DOMString
& aValue
) { GetHTMLAttr(nsGkAtoms::ping
, aValue
); }
91 void SetPing(const nsAString
& aPing
, ErrorResult
& aError
) {
92 SetHTMLAttr(nsGkAtoms::ping
, aPing
, aError
);
95 void GetRel(DOMString
& aValue
) { GetHTMLAttr(nsGkAtoms::rel
, aValue
); }
97 void SetRel(const nsAString
& aRel
, ErrorResult
& aError
) {
98 SetHTMLAttr(nsGkAtoms::rel
, aRel
, aError
);
100 nsDOMTokenList
* RelList();
102 void SetReferrerPolicy(const nsAString
& aValue
, mozilla::ErrorResult
& rv
) {
103 SetHTMLAttr(nsGkAtoms::referrerpolicy
, aValue
, rv
);
105 void GetReferrerPolicy(nsAString
& aReferrer
) {
106 GetEnumAttr(nsGkAtoms::referrerpolicy
, EmptyCString().get(), aReferrer
);
109 // The Link::GetOrigin is OK for us
111 // Link::Link::GetProtocol is OK for us
112 // Link::Link::SetProtocol is OK for us
114 // The Link::GetUsername is OK for us
115 // The Link::SetUsername is OK for us
117 // The Link::GetPassword is OK for us
118 // The Link::SetPassword is OK for us
120 // Link::Link::GetHost is OK for us
121 // Link::Link::SetHost is OK for us
123 // Link::Link::GetHostname is OK for us
124 // Link::Link::SetHostname is OK for us
126 // Link::Link::GetPort is OK for us
127 // Link::Link::SetPort is OK for us
129 // Link::Link::GetPathname is OK for us
130 // Link::Link::SetPathname is OK for us
132 // Link::Link::GetSearch is OK for us
133 // Link::Link::SetSearch is OK for us
135 // Link::Link::GetHash is OK for us
136 // Link::Link::SetHash is OK for us
138 // The Link::GetSearchParams is OK for us
140 bool NoHref() const { return GetBoolAttr(nsGkAtoms::nohref
); }
142 void SetNoHref(bool aValue
, ErrorResult
& aError
) {
143 SetHTMLBoolAttr(nsGkAtoms::nohref
, aValue
, aError
);
146 void ToString(nsAString
& aSource
);
147 void Stringify(nsAString
& aResult
) { GetHref(aResult
); }
149 void NodeInfoChanged(Document
* aOldDoc
) final
{
150 ClearHasPendingLinkUpdate();
151 nsGenericHTMLElement::NodeInfoChanged(aOldDoc
);
155 virtual ~HTMLAreaElement();
157 virtual JSObject
* WrapNode(JSContext
* aCx
,
158 JS::Handle
<JSObject
*> aGivenProto
) override
;
160 virtual nsresult
AfterSetAttr(int32_t aNamespaceID
, nsAtom
* aName
,
161 const nsAttrValue
* aValue
,
162 const nsAttrValue
* aOldValue
,
163 nsIPrincipal
* aSubjectPrincipal
,
164 bool aNotify
) override
;
166 RefPtr
<nsDOMTokenList
> mRelList
;
170 } // namespace mozilla
172 #endif /* mozilla_dom_HTMLAreaElement_h */