Bug 1719855 - Take over preventDefaulted infomation for long-tap events to the origin...
[gecko.git] / dom / html / HTMLAnchorElement.h
blobce202829c644d4ab662c96b1f33559e9b95b104f
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/AnchorAreaFormRelValues.h"
12 #include "mozilla/dom/Link.h"
13 #include "mozilla/dom/HTMLDNSPrefetch.h"
14 #include "nsGenericHTMLElement.h"
15 #include "nsDOMTokenList.h"
17 namespace mozilla {
18 class EventChainPostVisitor;
19 class EventChainPreVisitor;
20 namespace dom {
22 class HTMLAnchorElement final : public nsGenericHTMLElement,
23 public Link,
24 public SupportsDNSPrefetch,
25 public AnchorAreaFormRelValues {
26 public:
27 using Element::GetText;
29 explicit HTMLAnchorElement(
30 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
31 : nsGenericHTMLElement(std::move(aNodeInfo)), Link(this) {}
33 // nsISupports
34 NS_DECL_ISUPPORTS_INHERITED
36 // CC
37 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLAnchorElement,
38 nsGenericHTMLElement)
40 NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLAnchorElement, a);
42 int32_t TabIndexDefault() override;
43 bool Draggable() const override;
45 // Element
46 bool IsInteractiveHTMLContent() const override;
48 // DOM memory reporter participant
49 NS_DECL_ADDSIZEOFEXCLUDINGTHIS
51 nsresult BindToTree(BindContext&, nsINode& aParent) override;
52 void UnbindFromTree(bool aNullParent = true) override;
53 bool IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable,
54 int32_t* aTabIndex) override;
56 void GetEventTargetParent(EventChainPreVisitor& aVisitor) override;
57 MOZ_CAN_RUN_SCRIPT
58 nsresult PostHandleEvent(EventChainPostVisitor& aVisitor) override;
60 void GetLinkTarget(nsAString& aTarget) override;
61 already_AddRefed<nsIURI> GetHrefURI() const override;
63 void BeforeSetAttr(int32_t aNamespaceID, nsAtom* aName,
64 const nsAttrValue* aValue, bool aNotify) override;
65 void AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
66 const nsAttrValue* aValue, const nsAttrValue* aOldValue,
67 nsIPrincipal* aSubjectPrincipal, bool aNotify) override;
69 nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
71 ElementState IntrinsicState() const override;
73 // WebIDL API
75 void GetHref(nsAString& aValue) const {
76 GetURIAttr(nsGkAtoms::href, nullptr, aValue);
78 void SetHref(const nsAString& aValue, mozilla::ErrorResult& rv) {
79 SetHTMLAttr(nsGkAtoms::href, aValue, rv);
81 void GetTarget(nsAString& aValue) const;
82 void SetTarget(const nsAString& aValue, mozilla::ErrorResult& rv) {
83 SetHTMLAttr(nsGkAtoms::target, aValue, rv);
85 void GetDownload(DOMString& aValue) const {
86 GetHTMLAttr(nsGkAtoms::download, aValue);
88 void SetDownload(const nsAString& aValue, mozilla::ErrorResult& rv) {
89 SetHTMLAttr(nsGkAtoms::download, aValue, rv);
91 void GetPing(DOMString& aValue) const {
92 GetHTMLAttr(nsGkAtoms::ping, aValue);
94 void SetPing(const nsAString& aValue, mozilla::ErrorResult& rv) {
95 SetHTMLAttr(nsGkAtoms::ping, aValue, rv);
97 void GetRel(DOMString& aValue) const { 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) const {
105 GetEnumAttr(nsGkAtoms::referrerpolicy, "", aPolicy);
107 nsDOMTokenList* RelList();
108 void GetHreflang(DOMString& aValue) const {
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) const {
116 GetHTMLAttr(nsGkAtoms::type, aValue);
118 void GetType(DOMString& aValue) const {
119 GetHTMLAttr(nsGkAtoms::type, aValue);
121 void SetType(const nsAString& aValue, mozilla::ErrorResult& rv) {
122 SetHTMLAttr(nsGkAtoms::type, aValue, rv);
124 void GetText(nsAString& aText, mozilla::ErrorResult& aRv) const;
125 void SetText(const nsAString& aText, mozilla::ErrorResult& aRv);
127 // Link::GetOrigin is OK for us
129 // Link::GetProtocol is OK for us
130 // Link::SetProtocol is OK for us
132 // Link::GetUsername is OK for us
133 // Link::SetUsername is OK for us
135 // Link::GetPassword is OK for us
136 // Link::SetPassword is OK for us
138 // Link::Link::GetHost is OK for us
139 // Link::Link::SetHost is OK for us
141 // Link::Link::GetHostname is OK for us
142 // Link::Link::SetHostname is OK for us
144 // Link::Link::GetPort is OK for us
145 // Link::Link::SetPort is OK for us
147 // Link::Link::GetPathname is OK for us
148 // Link::Link::SetPathname is OK for us
150 // Link::Link::GetSearch is OK for us
151 // Link::Link::SetSearch is OK for us
153 // Link::Link::GetHash is OK for us
154 // Link::Link::SetHash is OK for us
156 void GetCoords(DOMString& aValue) const {
157 GetHTMLAttr(nsGkAtoms::coords, aValue);
159 void SetCoords(const nsAString& aValue, mozilla::ErrorResult& rv) {
160 SetHTMLAttr(nsGkAtoms::coords, aValue, rv);
162 void GetCharset(DOMString& aValue) const {
163 GetHTMLAttr(nsGkAtoms::charset, aValue);
165 void SetCharset(const nsAString& aValue, mozilla::ErrorResult& rv) {
166 SetHTMLAttr(nsGkAtoms::charset, aValue, rv);
168 void GetName(DOMString& aValue) const {
169 GetHTMLAttr(nsGkAtoms::name, aValue);
171 void GetName(nsAString& aValue) const {
172 GetHTMLAttr(nsGkAtoms::name, aValue);
174 void SetName(const nsAString& aValue, mozilla::ErrorResult& rv) {
175 SetHTMLAttr(nsGkAtoms::name, aValue, rv);
177 void GetRev(DOMString& aValue) const { GetHTMLAttr(nsGkAtoms::rev, aValue); }
178 void SetRev(const nsAString& aValue, mozilla::ErrorResult& rv) {
179 SetHTMLAttr(nsGkAtoms::rev, aValue, rv);
181 void GetShape(DOMString& aValue) const {
182 GetHTMLAttr(nsGkAtoms::shape, aValue);
184 void SetShape(const nsAString& aValue, mozilla::ErrorResult& rv) {
185 SetHTMLAttr(nsGkAtoms::shape, aValue, rv);
187 void Stringify(nsAString& aResult) const { GetHref(aResult); }
188 void ToString(nsAString& aSource) const { GetHref(aSource); }
190 void NodeInfoChanged(Document* aOldDoc) final {
191 ClearHasPendingLinkUpdate();
192 nsGenericHTMLElement::NodeInfoChanged(aOldDoc);
195 protected:
196 virtual ~HTMLAnchorElement();
198 JSObject* WrapNode(JSContext*, JS::Handle<JSObject*> aGivenProto) override;
199 RefPtr<nsDOMTokenList> mRelList;
202 } // namespace dom
203 } // namespace mozilla
205 #endif // mozilla_dom_HTMLAnchorElement_h