Bug 1554951 [wpt PR 17043] - wake-lock: Fix invalid types test in wakelock-type.https...
[gecko.git] / dom / html / HTMLAnchorElement.h
blob01fb88b4dcf54aecd391fbfdf35889e130cb8321
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, public Link {
21 public:
22 using Element::GetText;
24 explicit HTMLAnchorElement(
25 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
26 : nsGenericHTMLElement(std::move(aNodeInfo)), Link(this) {}
28 // nsISupports
29 NS_DECL_ISUPPORTS_INHERITED
31 // CC
32 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLAnchorElement,
33 nsGenericHTMLElement)
35 NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLAnchorElement, a);
37 virtual int32_t TabIndexDefault() override;
38 virtual bool Draggable() const override;
40 // Element
41 virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const override;
43 // DOM memory reporter participant
44 NS_DECL_ADDSIZEOFEXCLUDINGTHIS
46 virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
47 virtual void UnbindFromTree(bool aNullParent = true) override;
48 virtual bool IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable,
49 int32_t* aTabIndex) override;
51 void GetEventTargetParent(EventChainPreVisitor& aVisitor) override;
52 MOZ_CAN_RUN_SCRIPT
53 nsresult PostHandleEvent(EventChainPostVisitor& aVisitor) override;
54 virtual bool IsLink(nsIURI** aURI) const override;
55 virtual void GetLinkTarget(nsAString& aTarget) override;
56 virtual already_AddRefed<nsIURI> GetHrefURI() const override;
58 virtual nsresult BeforeSetAttr(int32_t aNamespaceID, nsAtom* aName,
59 const nsAttrValueOrString* aValue,
60 bool aNotify) override;
61 virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
62 const nsAttrValue* aValue,
63 const nsAttrValue* aOldValue,
64 nsIPrincipal* aSubjectPrincipal,
65 bool aNotify) override;
67 virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
69 virtual EventStates IntrinsicState() const override;
71 virtual void OnDNSPrefetchDeferred() override;
72 virtual void OnDNSPrefetchRequested() override;
73 virtual bool HasDeferredDNSPrefetchRequest() override;
75 // WebIDL API
77 void GetHref(nsAString& aValue) {
78 GetURIAttr(nsGkAtoms::href, nullptr, aValue);
80 void SetHref(const nsAString& aValue, mozilla::ErrorResult& rv) {
81 SetHTMLAttr(nsGkAtoms::href, aValue, rv);
83 void GetTarget(nsAString& aValue);
84 void SetTarget(const nsAString& aValue, mozilla::ErrorResult& rv) {
85 SetHTMLAttr(nsGkAtoms::target, aValue, rv);
87 void GetDownload(DOMString& aValue) {
88 GetHTMLAttr(nsGkAtoms::download, aValue);
90 void SetDownload(const nsAString& aValue, mozilla::ErrorResult& rv) {
91 SetHTMLAttr(nsGkAtoms::download, aValue, rv);
93 void GetPing(DOMString& aValue) { GetHTMLAttr(nsGkAtoms::ping, aValue); }
94 void SetPing(const nsAString& aValue, mozilla::ErrorResult& rv) {
95 SetHTMLAttr(nsGkAtoms::ping, aValue, rv);
97 void GetRel(DOMString& aValue) { GetHTMLAttr(nsGkAtoms::rel, aValue); }
98 void SetRel(const nsAString& aValue, mozilla::ErrorResult& rv) {
99 SetHTMLAttr(nsGkAtoms::rel, aValue, rv);
101 void SetReferrerPolicy(const nsAString& aValue, mozilla::ErrorResult& rv) {
102 SetHTMLAttr(nsGkAtoms::referrerpolicy, aValue, rv);
104 void GetReferrerPolicy(DOMString& aPolicy) {
105 GetEnumAttr(nsGkAtoms::referrerpolicy, EmptyCString().get(), aPolicy);
107 nsDOMTokenList* RelList();
108 void GetHreflang(DOMString& aValue) {
109 GetHTMLAttr(nsGkAtoms::hreflang, aValue);
111 void SetHreflang(const nsAString& aValue, mozilla::ErrorResult& rv) {
112 SetHTMLAttr(nsGkAtoms::hreflang, aValue, rv);
114 // Needed for docshell
115 void GetType(nsAString& aValue) { GetHTMLAttr(nsGkAtoms::type, aValue); }
116 void GetType(DOMString& aValue) { GetHTMLAttr(nsGkAtoms::type, aValue); }
117 void SetType(const nsAString& aValue, mozilla::ErrorResult& rv) {
118 SetHTMLAttr(nsGkAtoms::type, aValue, rv);
120 void GetText(nsAString& aValue, mozilla::ErrorResult& rv);
121 void SetText(const nsAString& aValue, mozilla::ErrorResult& rv);
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) { GetHTMLAttr(nsGkAtoms::coords, aValue); }
153 void SetCoords(const nsAString& aValue, mozilla::ErrorResult& rv) {
154 SetHTMLAttr(nsGkAtoms::coords, aValue, rv);
156 void GetCharset(DOMString& aValue) {
157 GetHTMLAttr(nsGkAtoms::charset, aValue);
159 void SetCharset(const nsAString& aValue, mozilla::ErrorResult& rv) {
160 SetHTMLAttr(nsGkAtoms::charset, aValue, rv);
162 void GetName(DOMString& aValue) { GetHTMLAttr(nsGkAtoms::name, aValue); }
163 void GetName(nsAString& aValue) { GetHTMLAttr(nsGkAtoms::name, aValue); }
164 void SetName(const nsAString& aValue, mozilla::ErrorResult& rv) {
165 SetHTMLAttr(nsGkAtoms::name, aValue, rv);
167 void GetRev(DOMString& aValue) { GetHTMLAttr(nsGkAtoms::rev, aValue); }
168 void SetRev(const nsAString& aValue, mozilla::ErrorResult& rv) {
169 SetHTMLAttr(nsGkAtoms::rev, aValue, rv);
171 void GetShape(DOMString& aValue) { GetHTMLAttr(nsGkAtoms::shape, aValue); }
172 void SetShape(const nsAString& aValue, mozilla::ErrorResult& rv) {
173 SetHTMLAttr(nsGkAtoms::shape, aValue, rv);
175 void Stringify(nsAString& aResult) { GetHref(aResult); }
176 void ToString(nsAString& aSource);
178 void NodeInfoChanged(Document* aOldDoc) final {
179 ClearHasPendingLinkUpdate();
180 nsGenericHTMLElement::NodeInfoChanged(aOldDoc);
183 static DOMTokenListSupportedToken sSupportedRelValues[];
185 protected:
186 virtual ~HTMLAnchorElement();
188 virtual JSObject* WrapNode(JSContext* aCx,
189 JS::Handle<JSObject*> aGivenProto) override;
190 RefPtr<nsDOMTokenList> mRelList;
193 } // namespace dom
194 } // namespace mozilla
196 #endif // mozilla_dom_HTMLAnchorElement_h