Bug 1805294 [wpt PR 37463] - WebKit export of https://bugs.webkit.org/show_bug.cgi...
[gecko.git] / dom / svg / SVGAElement.h
blob21811ddd40bf02fe3e230d85e690db344663a103
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 DOM_SVG_SVGAELEMENT_H_
8 #define DOM_SVG_SVGAELEMENT_H_
10 #include "Link.h"
11 #include "nsDOMTokenList.h"
12 #include "SVGAnimatedString.h"
13 #include "mozilla/dom/SVGGraphicsElement.h"
15 nsresult NS_NewSVGAElement(
16 nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
18 namespace mozilla {
20 class EventChainPostVisitor;
21 class EventChainPreVisitor;
23 namespace dom {
25 using SVGAElementBase = SVGGraphicsElement;
27 class SVGAElement final : public SVGAElementBase, public Link {
28 protected:
29 using Element::GetText;
31 explicit SVGAElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
32 friend nsresult(::NS_NewSVGAElement(
33 nsIContent** aResult,
34 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
35 JSObject* WrapNode(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override;
37 public:
38 NS_DECL_ISUPPORTS_INHERITED
40 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGAElement, SVGAElementBase)
42 // nsINode interface methods
43 void GetEventTargetParent(EventChainPreVisitor& aVisitor) override;
44 MOZ_CAN_RUN_SCRIPT
45 nsresult PostHandleEvent(EventChainPostVisitor& aVisitor) override;
46 nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
48 // nsIContent
49 nsresult BindToTree(BindContext&, nsINode& aParent) override;
50 void UnbindFromTree(bool aNullParent = true) override;
51 NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
53 int32_t TabIndexDefault() override;
54 bool IsFocusableInternal(int32_t* aTabIndex, bool aWithMouse) override;
56 void GetLinkTarget(nsAString& aTarget) override;
57 already_AddRefed<nsIURI> GetHrefURI() const override;
58 bool HasHref() const;
60 ElementState IntrinsicState() const override;
61 virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
62 const nsAttrValue* aValue,
63 const nsAttrValue* aOldValue,
64 nsIPrincipal* aMaybeScriptedPrincipal,
65 bool aNotify) override;
67 // WebIDL
68 already_AddRefed<DOMSVGAnimatedString> Href();
69 already_AddRefed<DOMSVGAnimatedString> Target();
70 void GetDownload(nsAString& aDownload);
71 void SetDownload(const nsAString& aDownload, ErrorResult& rv);
72 void GetPing(nsAString& aPing);
73 void SetPing(const nsAString& aPing, mozilla::ErrorResult& rv);
74 void GetRel(nsAString& aRel);
75 void SetRel(const nsAString& aRel, mozilla::ErrorResult& rv);
76 void SetReferrerPolicy(const nsAString& aPolicy, mozilla::ErrorResult& rv);
77 void GetReferrerPolicy(nsAString& aPolicy);
78 nsDOMTokenList* RelList();
79 void GetHreflang(nsAString& aHreflang);
80 void SetHreflang(const nsAString& aHreflang, mozilla::ErrorResult& rv);
81 void GetType(nsAString& aType);
82 void SetType(const nsAString& aType, mozilla::ErrorResult& rv);
83 void GetText(nsAString& aText, mozilla::ErrorResult& rv) const;
84 void SetText(const nsAString& aText, mozilla::ErrorResult& rv);
86 void NodeInfoChanged(Document* aOldDoc) final {
87 ClearHasPendingLinkUpdate();
88 SVGAElementBase::NodeInfoChanged(aOldDoc);
91 NS_IMPL_FROMNODE_WITH_TAG(SVGAElement, kNameSpaceID_SVG, nsGkAtoms::a);
93 protected:
94 virtual ~SVGAElement() = default;
96 StringAttributesInfo GetStringInfo() override;
98 enum { HREF, XLINK_HREF, TARGET };
99 SVGAnimatedString mStringAttributes[3];
100 static StringInfo sStringInfo[3];
102 RefPtr<nsDOMTokenList> mRelList;
103 static DOMTokenListSupportedToken sSupportedRelValues[];
106 } // namespace dom
107 } // namespace mozilla
109 #endif // DOM_SVG_SVGAELEMENT_H_