Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / html / HTMLAnchorElement.h
blob9eeee2d867eb86badac939c650e7cbd77983e335
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_HTMLAnchorElement_h
8 #define mozilla_dom_HTMLAnchorElement_h
10 #include "mozilla/Attributes.h"
11 #include "mozilla/dom/Link.h"
12 #include "mozilla/dom/HTMLDNSPrefetch.h"
13 #include "nsGenericHTMLElement.h"
14 #include "nsDOMTokenList.h"
16 namespace mozilla {
17 class EventChainPostVisitor;
18 class EventChainPreVisitor;
19 namespace dom {
21 class HTMLAnchorElement final : public nsGenericHTMLElement,
22 public Link,
23 public SupportsDNSPrefetch {
24 public:
25 using Element::GetText;
27 explicit HTMLAnchorElement(
28 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
29 : nsGenericHTMLElement(std::move(aNodeInfo)), Link(this) {}
31 // nsISupports
32 NS_DECL_ISUPPORTS_INHERITED
34 // CC
35 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLAnchorElement,
36 nsGenericHTMLElement)
38 NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLAnchorElement, a);
40 int32_t TabIndexDefault() override;
41 bool Draggable() const override;
43 // Element
44 bool IsInteractiveHTMLContent() const override;
46 // DOM memory reporter participant
47 NS_DECL_ADDSIZEOFEXCLUDINGTHIS
49 nsresult BindToTree(BindContext&, nsINode& aParent) override;
50 void UnbindFromTree(UnbindContext&) override;
51 bool IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable,
52 int32_t* aTabIndex) override;
54 void GetEventTargetParent(EventChainPreVisitor& aVisitor) override;
55 MOZ_CAN_RUN_SCRIPT
56 nsresult PostHandleEvent(EventChainPostVisitor& aVisitor) override;
58 void GetLinkTarget(nsAString& aTarget) override;
59 already_AddRefed<nsIURI> GetHrefURI() const override;
61 void BeforeSetAttr(int32_t aNamespaceID, nsAtom* aName,
62 const nsAttrValue* aValue, bool aNotify) override;
63 void AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
64 const nsAttrValue* aValue, const nsAttrValue* aOldValue,
65 nsIPrincipal* aSubjectPrincipal, bool aNotify) override;
67 nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
69 // WebIDL API
71 void GetHref(nsACString& aValue) const {
72 GetURIAttr(nsGkAtoms::href, nullptr, aValue);
74 void SetHref(const nsACString& aValue, ErrorResult& aRv) {
75 SetHTMLAttr(nsGkAtoms::href, NS_ConvertUTF8toUTF16(aValue), aRv);
77 void GetTarget(nsAString& aValue) const;
78 void SetTarget(const nsAString& aValue, mozilla::ErrorResult& rv) {
79 SetHTMLAttr(nsGkAtoms::target, aValue, rv);
81 void GetDownload(DOMString& aValue) const {
82 GetHTMLAttr(nsGkAtoms::download, aValue);
84 void SetDownload(const nsAString& aValue, mozilla::ErrorResult& rv) {
85 SetHTMLAttr(nsGkAtoms::download, aValue, rv);
87 void GetPing(DOMString& aValue) const {
88 GetHTMLAttr(nsGkAtoms::ping, aValue);
90 void SetPing(const nsAString& aValue, mozilla::ErrorResult& rv) {
91 SetHTMLAttr(nsGkAtoms::ping, aValue, rv);
93 void GetRel(DOMString& aValue) const { GetHTMLAttr(nsGkAtoms::rel, aValue); }
94 void SetRel(const nsAString& aValue, mozilla::ErrorResult& rv) {
95 SetHTMLAttr(nsGkAtoms::rel, aValue, rv);
97 void SetReferrerPolicy(const nsAString& aValue, mozilla::ErrorResult& rv) {
98 SetHTMLAttr(nsGkAtoms::referrerpolicy, aValue, rv);
100 void GetReferrerPolicy(DOMString& aPolicy) const {
101 GetEnumAttr(nsGkAtoms::referrerpolicy, "", aPolicy);
103 nsDOMTokenList* RelList();
104 void GetHreflang(DOMString& aValue) const {
105 GetHTMLAttr(nsGkAtoms::hreflang, aValue);
107 void SetHreflang(const nsAString& aValue, mozilla::ErrorResult& rv) {
108 SetHTMLAttr(nsGkAtoms::hreflang, aValue, rv);
110 // Needed for docshell
111 void GetType(nsAString& aValue) const {
112 GetHTMLAttr(nsGkAtoms::type, aValue);
114 void GetType(DOMString& aValue) const {
115 GetHTMLAttr(nsGkAtoms::type, aValue);
117 void SetType(const nsAString& aValue, mozilla::ErrorResult& rv) {
118 SetHTMLAttr(nsGkAtoms::type, aValue, rv);
120 void GetText(nsAString& aText, mozilla::ErrorResult& aRv) const;
121 void SetText(const nsAString& aText, mozilla::ErrorResult& aRv);
123 // Link::GetOrigin is OK for us
125 // Link::GetProtocol is OK for us
126 // Link::SetProtocol is OK for us
128 // Link::GetUsername is OK for us
129 // Link::SetUsername is OK for us
131 // Link::GetPassword is OK for us
132 // Link::SetPassword is OK for us
134 // Link::Link::GetHost is OK for us
135 // Link::Link::SetHost is OK for us
137 // Link::Link::GetHostname is OK for us
138 // Link::Link::SetHostname is OK for us
140 // Link::Link::GetPort is OK for us
141 // Link::Link::SetPort is OK for us
143 // Link::Link::GetPathname is OK for us
144 // Link::Link::SetPathname is OK for us
146 // Link::Link::GetSearch is OK for us
147 // Link::Link::SetSearch is OK for us
149 // Link::Link::GetHash is OK for us
150 // Link::Link::SetHash is OK for us
152 void GetCoords(DOMString& aValue) const {
153 GetHTMLAttr(nsGkAtoms::coords, aValue);
155 void SetCoords(const nsAString& aValue, mozilla::ErrorResult& rv) {
156 SetHTMLAttr(nsGkAtoms::coords, aValue, rv);
158 void GetCharset(DOMString& aValue) const {
159 GetHTMLAttr(nsGkAtoms::charset, aValue);
161 void SetCharset(const nsAString& aValue, mozilla::ErrorResult& rv) {
162 SetHTMLAttr(nsGkAtoms::charset, aValue, rv);
164 void GetName(DOMString& aValue) const {
165 GetHTMLAttr(nsGkAtoms::name, aValue);
167 void GetName(nsAString& aValue) const {
168 GetHTMLAttr(nsGkAtoms::name, aValue);
170 void SetName(const nsAString& aValue, mozilla::ErrorResult& rv) {
171 SetHTMLAttr(nsGkAtoms::name, aValue, rv);
173 void GetRev(DOMString& aValue) const { GetHTMLAttr(nsGkAtoms::rev, aValue); }
174 void SetRev(const nsAString& aValue, mozilla::ErrorResult& rv) {
175 SetHTMLAttr(nsGkAtoms::rev, aValue, rv);
177 void GetShape(DOMString& aValue) const {
178 GetHTMLAttr(nsGkAtoms::shape, aValue);
180 void SetShape(const nsAString& aValue, mozilla::ErrorResult& rv) {
181 SetHTMLAttr(nsGkAtoms::shape, aValue, rv);
184 void NodeInfoChanged(Document* aOldDoc) final {
185 ClearHasPendingLinkUpdate();
186 nsGenericHTMLElement::NodeInfoChanged(aOldDoc);
189 protected:
190 virtual ~HTMLAnchorElement();
192 void MaybeTryDNSPrefetch();
194 JSObject* WrapNode(JSContext*, JS::Handle<JSObject*> aGivenProto) override;
195 RefPtr<nsDOMTokenList> mRelList;
198 } // namespace dom
199 } // namespace mozilla
201 #endif // mozilla_dom_HTMLAnchorElement_h