Bug 1265584 [wpt PR 11167] - [Gecko Bug 1265584] Move wptrunner marionette usage...
[gecko.git] / dom / html / HTMLAnchorElement.h
blob7c4ec3de5d9beb98e9bea40b70f666bb258d220f
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 "nsGenericHTMLElement.h"
13 #include "nsDOMTokenList.h"
15 namespace mozilla {
16 class EventChainPostVisitor;
17 class EventChainPreVisitor;
18 namespace dom {
20 class HTMLAnchorElement final : public nsGenericHTMLElement,
21 public Link
23 public:
24 using Element::GetText;
26 explicit HTMLAnchorElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
27 : nsGenericHTMLElement(aNodeInfo)
28 , Link(this)
32 // nsISupports
33 NS_DECL_ISUPPORTS_INHERITED
35 // CC
36 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLAnchorElement,
37 nsGenericHTMLElement)
39 NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLAnchorElement, a);
41 virtual int32_t TabIndexDefault() override;
42 virtual bool Draggable() const override;
44 // Element
45 virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const override;
47 // DOM memory reporter participant
48 NS_DECL_ADDSIZEOFEXCLUDINGTHIS
50 virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
51 nsIContent* aBindingParent,
52 bool aCompileEventHandlers) override;
53 virtual void UnbindFromTree(bool aDeep = true,
54 bool aNullParent = true) override;
55 virtual bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, int32_t *aTabIndex) override;
57 void GetEventTargetParent(EventChainPreVisitor& aVisitor) override;
58 virtual nsresult PostHandleEvent(
59 EventChainPostVisitor& aVisitor) override;
60 virtual bool IsLink(nsIURI** aURI) const override;
61 virtual void GetLinkTarget(nsAString& aTarget) override;
62 virtual already_AddRefed<nsIURI> GetHrefURI() const override;
64 virtual nsresult BeforeSetAttr(int32_t aNamespaceID, nsAtom* aName,
65 const nsAttrValueOrString* aValue,
66 bool aNotify) override;
67 virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
68 const nsAttrValue* aValue,
69 const nsAttrValue* aOldValue,
70 nsIPrincipal* aSubjectPrincipal,
71 bool aNotify) override;
73 virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
74 bool aPreallocateChildren) const override;
76 virtual EventStates IntrinsicState() const override;
78 virtual void OnDNSPrefetchDeferred() override;
79 virtual void OnDNSPrefetchRequested() override;
80 virtual bool HasDeferredDNSPrefetchRequest() override;
82 // WebIDL API
84 void GetHref(nsAString& aValue)
86 GetURIAttr(nsGkAtoms::href, nullptr, aValue);
88 void SetHref(const nsAString& aValue, mozilla::ErrorResult& rv)
90 SetHTMLAttr(nsGkAtoms::href, aValue, rv);
92 void GetTarget(nsAString& aValue);
93 void SetTarget(const nsAString& aValue, mozilla::ErrorResult& rv)
95 SetHTMLAttr(nsGkAtoms::target, aValue, rv);
97 void GetDownload(DOMString& aValue)
99 GetHTMLAttr(nsGkAtoms::download, aValue);
101 void SetDownload(const nsAString& aValue, mozilla::ErrorResult& rv)
103 SetHTMLAttr(nsGkAtoms::download, aValue, rv);
105 void GetPing(DOMString& aValue)
107 GetHTMLAttr(nsGkAtoms::ping, aValue);
109 void SetPing(const nsAString& aValue, mozilla::ErrorResult& rv)
111 SetHTMLAttr(nsGkAtoms::ping, aValue, rv);
113 void GetRel(DOMString& aValue)
115 GetHTMLAttr(nsGkAtoms::rel, aValue);
117 void SetRel(const nsAString& aValue, mozilla::ErrorResult& rv)
119 SetHTMLAttr(nsGkAtoms::rel, aValue, rv);
121 void SetReferrerPolicy(const nsAString& aValue, mozilla::ErrorResult& rv)
123 SetHTMLAttr(nsGkAtoms::referrerpolicy, aValue, rv);
125 void GetReferrerPolicy(DOMString& aPolicy)
127 GetEnumAttr(nsGkAtoms::referrerpolicy, EmptyCString().get(), aPolicy);
129 nsDOMTokenList* RelList();
130 void GetHreflang(DOMString& aValue)
132 GetHTMLAttr(nsGkAtoms::hreflang, aValue);
134 void SetHreflang(const nsAString& aValue, mozilla::ErrorResult& rv)
136 SetHTMLAttr(nsGkAtoms::hreflang, aValue, rv);
138 // Needed for docshell
139 void GetType(nsAString& aValue)
141 GetHTMLAttr(nsGkAtoms::type, aValue);
143 void GetType(DOMString& aValue)
145 GetHTMLAttr(nsGkAtoms::type, aValue);
147 void SetType(const nsAString& aValue, mozilla::ErrorResult& rv)
149 SetHTMLAttr(nsGkAtoms::type, aValue, rv);
151 void GetText(nsAString& aValue, mozilla::ErrorResult& rv);
152 void SetText(const nsAString& aValue, mozilla::ErrorResult& rv);
154 // Link::GetOrigin is OK for us
156 // Link::GetProtocol is OK for us
157 // Link::SetProtocol is OK for us
159 // Link::GetUsername is OK for us
160 // Link::SetUsername is OK for us
162 // Link::GetPassword is OK for us
163 // Link::SetPassword is OK for us
165 // Link::Link::GetHost is OK for us
166 // Link::Link::SetHost is OK for us
168 // Link::Link::GetHostname is OK for us
169 // Link::Link::SetHostname is OK for us
171 // Link::Link::GetPort is OK for us
172 // Link::Link::SetPort is OK for us
174 // Link::Link::GetPathname is OK for us
175 // Link::Link::SetPathname is OK for us
177 // Link::Link::GetSearch is OK for us
178 // Link::Link::SetSearch is OK for us
180 // Link::Link::GetHash is OK for us
181 // Link::Link::SetHash is OK for us
183 void GetCoords(DOMString& aValue)
185 GetHTMLAttr(nsGkAtoms::coords, aValue);
187 void SetCoords(const nsAString& aValue, mozilla::ErrorResult& rv)
189 SetHTMLAttr(nsGkAtoms::coords, aValue, rv);
191 void GetCharset(DOMString& aValue)
193 GetHTMLAttr(nsGkAtoms::charset, aValue);
195 void SetCharset(const nsAString& aValue, mozilla::ErrorResult& rv)
197 SetHTMLAttr(nsGkAtoms::charset, aValue, rv);
199 void GetName(DOMString& aValue)
201 GetHTMLAttr(nsGkAtoms::name, aValue);
203 void GetName(nsAString& aValue)
205 GetHTMLAttr(nsGkAtoms::name, aValue);
207 void SetName(const nsAString& aValue, mozilla::ErrorResult& rv)
209 SetHTMLAttr(nsGkAtoms::name, aValue, rv);
211 void GetRev(DOMString& aValue)
213 GetHTMLAttr(nsGkAtoms::rev, aValue);
215 void SetRev(const nsAString& aValue, mozilla::ErrorResult& rv)
217 SetHTMLAttr(nsGkAtoms::rev, aValue, rv);
219 void GetShape(DOMString& aValue)
221 GetHTMLAttr(nsGkAtoms::shape, aValue);
223 void SetShape(const nsAString& aValue, mozilla::ErrorResult& rv)
225 SetHTMLAttr(nsGkAtoms::shape, aValue, rv);
227 void Stringify(nsAString& aResult)
229 GetHref(aResult);
231 void ToString(nsAString& aSource);
233 void NodeInfoChanged(nsIDocument* aOldDoc) final
235 ClearHasPendingLinkUpdate();
236 nsGenericHTMLElement::NodeInfoChanged(aOldDoc);
239 static DOMTokenListSupportedToken sSupportedRelValues[];
241 protected:
242 virtual ~HTMLAnchorElement();
244 virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
245 RefPtr<nsDOMTokenList > mRelList;
248 } // namespace dom
249 } // namespace mozilla
251 #endif // mozilla_dom_HTMLAnchorElement_h