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/. */ 6 7 #ifndef mozilla_dom_SVGAElement_h 8 #define mozilla_dom_SVGAElement_h 9 10 #include "Link.h" 11 #include "nsSVGString.h" 12 #include "mozilla/dom/SVGGraphicsElement.h" 13 14 nsresult NS_NewSVGAElement( 15 nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo); 16 17 namespace mozilla { 18 19 class EventChainPostVisitor; 20 class EventChainPreVisitor; 21 22 namespace dom { 23 24 typedef SVGGraphicsElement SVGAElementBase; 25 26 class SVGAElement final : public SVGAElementBase, public Link { 27 protected: 28 explicit SVGAElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo); 29 friend nsresult(::NS_NewSVGAElement( 30 nsIContent** aResult, 31 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)); 32 virtual JSObject* WrapNode(JSContext* cx, 33 JS::Handle<JSObject*> aGivenProto) override; 34 35 public: 36 NS_DECL_ISUPPORTS_INHERITED 37 38 // nsINode interface methods 39 virtual nsresult GetEventTargetParent( 40 EventChainPreVisitor& aVisitor) override; 41 virtual nsresult PostHandleEvent(EventChainPostVisitor& aVisitor) override; 42 virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult, 43 bool aPreallocateChildren) const override; 44 45 // nsIContent 46 virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, 47 nsIContent* aBindingParent, 48 bool aCompileEventHandlers) override; 49 virtual void UnbindFromTree(bool aDeep = true, 50 bool aNullParent = true) override; 51 NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override; 52 virtual int32_t TabIndexDefault() override; 53 virtual bool IsSVGFocusable(bool* aIsFocusable, int32_t* aTabIndex) override; 54 virtual bool IsLink(nsIURI** aURI) const override; 55 virtual void GetLinkTarget(nsAString& aTarget) override; 56 virtual already_AddRefed<nsIURI> GetHrefURI() const override; 57 virtual EventStates IntrinsicState() const override; 58 virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, 59 const nsAttrValue* aValue, 60 const nsAttrValue* aOldValue, 61 nsIPrincipal* aMaybeScriptedPrincipal, 62 bool aNotify) override; 63 64 // Link 65 virtual bool ElementHasHref() const override; 66 67 // WebIDL 68 already_AddRefed<SVGAnimatedString> Href(); 69 already_AddRefed<SVGAnimatedString> Target(); 70 void GetDownload(nsAString& aDownload); 71 void SetDownload(const nsAString& aDownload, ErrorResult& rv); 72 NodeInfoChanged(nsIDocument * aOldDoc)73 void NodeInfoChanged(nsIDocument* aOldDoc) final { 74 ClearHasPendingLinkUpdate(); 75 SVGAElementBase::NodeInfoChanged(aOldDoc); 76 } 77 78 protected: 79 virtual ~SVGAElement(); 80 81 virtual StringAttributesInfo GetStringInfo() override; 82 83 enum { HREF, XLINK_HREF, TARGET }; 84 nsSVGString mStringAttributes[3]; 85 static StringInfo sStringInfo[3]; 86 }; 87 88 } // namespace dom 89 } // namespace mozilla 90 91 #endif // mozilla_dom_SVGAElement_h 92