Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / html / HTMLAreaElement.h
blob6e9744ae624fc56ffafe33455812b91f57e390e5
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"
15 namespace mozilla {
16 class EventChainPostVisitor;
17 class EventChainPreVisitor;
18 namespace dom {
20 class HTMLAreaElement final : public nsGenericHTMLElement, public Link {
21 public:
22 explicit HTMLAreaElement(
23 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
25 // nsISupports
26 NS_DECL_ISUPPORTS_INHERITED
28 // CC
29 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLAreaElement,
30 nsGenericHTMLElement)
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;
39 MOZ_CAN_RUN_SCRIPT
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;
50 // WebIDL
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 void GetHref(nsACString& aValue) {
68 GetURIAttr(nsGkAtoms::href, nullptr, aValue);
70 void SetHref(const nsACString& aHref, ErrorResult& aError) {
71 SetHTMLAttr(nsGkAtoms::href, NS_ConvertUTF8toUTF16(aHref), aError);
74 void GetTarget(DOMString& aValue);
75 void SetTarget(const nsAString& aTarget, ErrorResult& aError) {
76 SetHTMLAttr(nsGkAtoms::target, aTarget, aError);
79 void GetDownload(DOMString& aValue) {
80 GetHTMLAttr(nsGkAtoms::download, aValue);
82 void SetDownload(const nsAString& aDownload, ErrorResult& aError) {
83 SetHTMLAttr(nsGkAtoms::download, aDownload, aError);
86 void GetPing(DOMString& aValue) { GetHTMLAttr(nsGkAtoms::ping, aValue); }
87 void SetPing(const nsAString& aPing, ErrorResult& aError) {
88 SetHTMLAttr(nsGkAtoms::ping, aPing, aError);
91 void GetRel(DOMString& aValue) { GetHTMLAttr(nsGkAtoms::rel, aValue); }
92 void SetRel(const nsAString& aRel, ErrorResult& aError) {
93 SetHTMLAttr(nsGkAtoms::rel, aRel, aError);
95 nsDOMTokenList* RelList();
97 void SetReferrerPolicy(const nsAString& aValue, mozilla::ErrorResult& rv) {
98 SetHTMLAttr(nsGkAtoms::referrerpolicy, aValue, rv);
100 void GetReferrerPolicy(nsAString& aReferrer) {
101 GetEnumAttr(nsGkAtoms::referrerpolicy, "", aReferrer);
104 // The Link::GetOrigin is OK for us
106 // Link::Link::GetProtocol is OK for us
107 // Link::Link::SetProtocol is OK for us
109 // The Link::GetUsername is OK for us
110 // The Link::SetUsername is OK for us
112 // The Link::GetPassword is OK for us
113 // The Link::SetPassword is OK for us
115 // Link::Link::GetHost is OK for us
116 // Link::Link::SetHost is OK for us
118 // Link::Link::GetHostname is OK for us
119 // Link::Link::SetHostname is OK for us
121 // Link::Link::GetPort is OK for us
122 // Link::Link::SetPort is OK for us
124 // Link::Link::GetPathname is OK for us
125 // Link::Link::SetPathname is OK for us
127 // Link::Link::GetSearch is OK for us
128 // Link::Link::SetSearch is OK for us
130 // Link::Link::GetHash is OK for us
131 // Link::Link::SetHash is OK for us
133 // The Link::GetSearchParams is OK for us
135 bool NoHref() const { return GetBoolAttr(nsGkAtoms::nohref); }
137 void SetNoHref(bool aValue, ErrorResult& aError) {
138 SetHTMLBoolAttr(nsGkAtoms::nohref, aValue, aError);
141 void NodeInfoChanged(Document* aOldDoc) final {
142 ClearHasPendingLinkUpdate();
143 nsGenericHTMLElement::NodeInfoChanged(aOldDoc);
146 protected:
147 virtual ~HTMLAreaElement();
149 virtual JSObject* WrapNode(JSContext* aCx,
150 JS::Handle<JSObject*> aGivenProto) override;
152 virtual void AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
153 const nsAttrValue* aValue,
154 const nsAttrValue* aOldValue,
155 nsIPrincipal* aSubjectPrincipal,
156 bool aNotify) override;
158 RefPtr<nsDOMTokenList> mRelList;
161 } // namespace dom
162 } // namespace mozilla
164 #endif /* mozilla_dom_HTMLAreaElement_h */