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
;
42 void GetLinkTarget(nsAString
& aTarget
) override
;
43 already_AddRefed
<nsIURI
> GetHrefURI() const override
;
45 virtual nsresult
BindToTree(BindContext
&, nsINode
& aParent
) override
;
46 virtual void UnbindFromTree(UnbindContext
&) override
;
48 virtual nsresult
Clone(dom::NodeInfo
*, nsINode
** aResult
) const override
;
51 void GetAlt(DOMString
& aValue
) { GetHTMLAttr(nsGkAtoms::alt
, aValue
); }
52 void SetAlt(const nsAString
& aAlt
, ErrorResult
& aError
) {
53 SetHTMLAttr(nsGkAtoms::alt
, aAlt
, aError
);
56 void GetCoords(DOMString
& aValue
) { GetHTMLAttr(nsGkAtoms::coords
, aValue
); }
57 void SetCoords(const nsAString
& aCoords
, ErrorResult
& aError
) {
58 SetHTMLAttr(nsGkAtoms::coords
, aCoords
, aError
);
61 // argument type nsAString for HTMLImageMapAccessible
62 void GetShape(nsAString
& aValue
) { GetHTMLAttr(nsGkAtoms::shape
, aValue
); }
63 void SetShape(const nsAString
& aShape
, ErrorResult
& aError
) {
64 SetHTMLAttr(nsGkAtoms::shape
, aShape
, aError
);
67 // argument type nsAString for nsContextMenuInfo
68 void GetHref(nsAString
& aValue
) {
69 GetURIAttr(nsGkAtoms::href
, nullptr, aValue
);
71 void SetHref(const nsAString
& aHref
, ErrorResult
& aError
) {
72 SetHTMLAttr(nsGkAtoms::href
, aHref
, aError
);
75 void GetTarget(DOMString
& aValue
);
76 void SetTarget(const nsAString
& aTarget
, ErrorResult
& aError
) {
77 SetHTMLAttr(nsGkAtoms::target
, aTarget
, aError
);
80 void GetDownload(DOMString
& aValue
) {
81 GetHTMLAttr(nsGkAtoms::download
, aValue
);
83 void SetDownload(const nsAString
& aDownload
, ErrorResult
& aError
) {
84 SetHTMLAttr(nsGkAtoms::download
, aDownload
, aError
);
87 void GetPing(DOMString
& aValue
) { GetHTMLAttr(nsGkAtoms::ping
, aValue
); }
89 void SetPing(const nsAString
& aPing
, ErrorResult
& aError
) {
90 SetHTMLAttr(nsGkAtoms::ping
, aPing
, aError
);
93 void GetRel(DOMString
& aValue
) { GetHTMLAttr(nsGkAtoms::rel
, aValue
); }
95 void SetRel(const nsAString
& aRel
, ErrorResult
& aError
) {
96 SetHTMLAttr(nsGkAtoms::rel
, aRel
, aError
);
98 nsDOMTokenList
* RelList();
100 void SetReferrerPolicy(const nsAString
& aValue
, mozilla::ErrorResult
& rv
) {
101 SetHTMLAttr(nsGkAtoms::referrerpolicy
, aValue
, rv
);
103 void GetReferrerPolicy(nsAString
& aReferrer
) {
104 GetEnumAttr(nsGkAtoms::referrerpolicy
, "", aReferrer
);
107 // The Link::GetOrigin is OK for us
109 // Link::Link::GetProtocol is OK for us
110 // Link::Link::SetProtocol is OK for us
112 // The Link::GetUsername is OK for us
113 // The Link::SetUsername is OK for us
115 // The Link::GetPassword is OK for us
116 // The Link::SetPassword is OK for us
118 // Link::Link::GetHost is OK for us
119 // Link::Link::SetHost is OK for us
121 // Link::Link::GetHostname is OK for us
122 // Link::Link::SetHostname is OK for us
124 // Link::Link::GetPort is OK for us
125 // Link::Link::SetPort is OK for us
127 // Link::Link::GetPathname is OK for us
128 // Link::Link::SetPathname is OK for us
130 // Link::Link::GetSearch is OK for us
131 // Link::Link::SetSearch is OK for us
133 // Link::Link::GetHash is OK for us
134 // Link::Link::SetHash is OK for us
136 // The Link::GetSearchParams is OK for us
138 bool NoHref() const { return GetBoolAttr(nsGkAtoms::nohref
); }
140 void SetNoHref(bool aValue
, ErrorResult
& aError
) {
141 SetHTMLBoolAttr(nsGkAtoms::nohref
, aValue
, aError
);
144 void ToString(nsAString
& aSource
);
145 void Stringify(nsAString
& aResult
) { GetHref(aResult
); }
147 void NodeInfoChanged(Document
* aOldDoc
) final
{
148 ClearHasPendingLinkUpdate();
149 nsGenericHTMLElement::NodeInfoChanged(aOldDoc
);
153 virtual ~HTMLAreaElement();
155 virtual JSObject
* WrapNode(JSContext
* aCx
,
156 JS::Handle
<JSObject
*> aGivenProto
) override
;
158 virtual void AfterSetAttr(int32_t aNamespaceID
, nsAtom
* aName
,
159 const nsAttrValue
* aValue
,
160 const nsAttrValue
* aOldValue
,
161 nsIPrincipal
* aSubjectPrincipal
,
162 bool aNotify
) override
;
164 RefPtr
<nsDOMTokenList
> mRelList
;
168 } // namespace mozilla
170 #endif /* mozilla_dom_HTMLAreaElement_h */