Bug 1732219 - Add API for fetching the preview image. r=geckoview-reviewers,agi,mconley
[gecko.git] / dom / html / HTMLAnchorElement.h
blob702dd3bf334742190ed3517c95ebf3ee7e56875e
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 virtual int32_t TabIndexDefault() override;
41 virtual bool Draggable() const override;
43 // Element
44 virtual bool IsInteractiveHTMLContent() const override;
46 // DOM memory reporter participant
47 NS_DECL_ADDSIZEOFEXCLUDINGTHIS
49 virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
50 virtual void UnbindFromTree(bool aNullParent = true) override;
51 virtual 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;
57 virtual bool IsLink(nsIURI** aURI) const override;
58 virtual void GetLinkTarget(nsAString& aTarget) override;
59 virtual already_AddRefed<nsIURI> GetHrefURI() const override;
61 virtual nsresult BeforeSetAttr(int32_t aNamespaceID, nsAtom* aName,
62 const nsAttrValueOrString* aValue,
63 bool aNotify) override;
64 virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
65 const nsAttrValue* aValue,
66 const nsAttrValue* aOldValue,
67 nsIPrincipal* aSubjectPrincipal,
68 bool aNotify) override;
70 virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
72 virtual EventStates IntrinsicState() const override;
74 // WebIDL API
76 void GetHref(nsAString& aValue) {
77 GetURIAttr(nsGkAtoms::href, nullptr, aValue);
79 void SetHref(const nsAString& aValue, mozilla::ErrorResult& rv) {
80 SetHTMLAttr(nsGkAtoms::href, aValue, rv);
82 void GetTarget(nsAString& aValue);
83 void SetTarget(const nsAString& aValue, mozilla::ErrorResult& rv) {
84 SetHTMLAttr(nsGkAtoms::target, aValue, rv);
86 void GetDownload(DOMString& aValue) {
87 GetHTMLAttr(nsGkAtoms::download, aValue);
89 void SetDownload(const nsAString& aValue, mozilla::ErrorResult& rv) {
90 SetHTMLAttr(nsGkAtoms::download, aValue, rv);
92 void GetPing(DOMString& aValue) { GetHTMLAttr(nsGkAtoms::ping, aValue); }
93 void SetPing(const nsAString& aValue, mozilla::ErrorResult& rv) {
94 SetHTMLAttr(nsGkAtoms::ping, aValue, rv);
96 void GetRel(DOMString& aValue) { GetHTMLAttr(nsGkAtoms::rel, aValue); }
97 void SetRel(const nsAString& aValue, mozilla::ErrorResult& rv) {
98 SetHTMLAttr(nsGkAtoms::rel, aValue, rv);
100 void SetReferrerPolicy(const nsAString& aValue, mozilla::ErrorResult& rv) {
101 SetHTMLAttr(nsGkAtoms::referrerpolicy, aValue, rv);
103 void GetReferrerPolicy(DOMString& aPolicy) {
104 GetEnumAttr(nsGkAtoms::referrerpolicy, "", aPolicy);
106 nsDOMTokenList* RelList();
107 void GetHreflang(DOMString& aValue) {
108 GetHTMLAttr(nsGkAtoms::hreflang, aValue);
110 void SetHreflang(const nsAString& aValue, mozilla::ErrorResult& rv) {
111 SetHTMLAttr(nsGkAtoms::hreflang, aValue, rv);
113 // Needed for docshell
114 void GetType(nsAString& aValue) { GetHTMLAttr(nsGkAtoms::type, aValue); }
115 void GetType(DOMString& aValue) { GetHTMLAttr(nsGkAtoms::type, aValue); }
116 void SetType(const nsAString& aValue, mozilla::ErrorResult& rv) {
117 SetHTMLAttr(nsGkAtoms::type, aValue, rv);
119 void GetText(nsAString& aValue, mozilla::ErrorResult& rv);
120 void SetText(const nsAString& aValue, mozilla::ErrorResult& rv);
122 // Link::GetOrigin is OK for us
124 // Link::GetProtocol is OK for us
125 // Link::SetProtocol is OK for us
127 // Link::GetUsername is OK for us
128 // Link::SetUsername is OK for us
130 // Link::GetPassword is OK for us
131 // Link::SetPassword is OK for us
133 // Link::Link::GetHost is OK for us
134 // Link::Link::SetHost is OK for us
136 // Link::Link::GetHostname is OK for us
137 // Link::Link::SetHostname is OK for us
139 // Link::Link::GetPort is OK for us
140 // Link::Link::SetPort is OK for us
142 // Link::Link::GetPathname is OK for us
143 // Link::Link::SetPathname is OK for us
145 // Link::Link::GetSearch is OK for us
146 // Link::Link::SetSearch is OK for us
148 // Link::Link::GetHash is OK for us
149 // Link::Link::SetHash is OK for us
151 void GetCoords(DOMString& aValue) { GetHTMLAttr(nsGkAtoms::coords, aValue); }
152 void SetCoords(const nsAString& aValue, mozilla::ErrorResult& rv) {
153 SetHTMLAttr(nsGkAtoms::coords, aValue, rv);
155 void GetCharset(DOMString& aValue) {
156 GetHTMLAttr(nsGkAtoms::charset, aValue);
158 void SetCharset(const nsAString& aValue, mozilla::ErrorResult& rv) {
159 SetHTMLAttr(nsGkAtoms::charset, aValue, rv);
161 void GetName(DOMString& aValue) { GetHTMLAttr(nsGkAtoms::name, aValue); }
162 void GetName(nsAString& aValue) { GetHTMLAttr(nsGkAtoms::name, aValue); }
163 void SetName(const nsAString& aValue, mozilla::ErrorResult& rv) {
164 SetHTMLAttr(nsGkAtoms::name, aValue, rv);
166 void GetRev(DOMString& aValue) { GetHTMLAttr(nsGkAtoms::rev, aValue); }
167 void SetRev(const nsAString& aValue, mozilla::ErrorResult& rv) {
168 SetHTMLAttr(nsGkAtoms::rev, aValue, rv);
170 void GetShape(DOMString& aValue) { GetHTMLAttr(nsGkAtoms::shape, aValue); }
171 void SetShape(const nsAString& aValue, mozilla::ErrorResult& rv) {
172 SetHTMLAttr(nsGkAtoms::shape, aValue, rv);
174 void Stringify(nsAString& aResult) { GetHref(aResult); }
175 void ToString(nsAString& aSource);
177 void NodeInfoChanged(Document* aOldDoc) final {
178 ClearHasPendingLinkUpdate();
179 nsGenericHTMLElement::NodeInfoChanged(aOldDoc);
182 static DOMTokenListSupportedToken sSupportedRelValues[];
184 protected:
185 virtual ~HTMLAnchorElement();
187 virtual JSObject* WrapNode(JSContext* aCx,
188 JS::Handle<JSObject*> aGivenProto) override;
189 RefPtr<nsDOMTokenList> mRelList;
192 } // namespace dom
193 } // namespace mozilla
195 #endif // mozilla_dom_HTMLAnchorElement_h