SVGAElement.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef mozilla_dom_SVGAElement_h
  6. #define mozilla_dom_SVGAElement_h
  7. #include "Link.h"
  8. #include "nsSVGString.h"
  9. #include "mozilla/dom/SVGGraphicsElement.h"
  10. nsresult NS_NewSVGAElement(nsIContent **aResult,
  11. already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
  12. namespace mozilla {
  13. class EventChainPostVisitor;
  14. class EventChainPreVisitor;
  15. namespace dom {
  16. typedef SVGGraphicsElement SVGAElementBase;
  17. class SVGAElement final : public SVGAElementBase,
  18. public Link
  19. {
  20. protected:
  21. explicit SVGAElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
  22. friend nsresult (::NS_NewSVGAElement(nsIContent **aResult,
  23. already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
  24. virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
  25. public:
  26. NS_DECL_ISUPPORTS_INHERITED
  27. NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGAElement, SVGAElementBase)
  28. // nsINode interface methods
  29. virtual nsresult GetEventTargetParent(
  30. EventChainPreVisitor& aVisitor) override;
  31. virtual nsresult PostHandleEvent(
  32. EventChainPostVisitor& aVisitor) override;
  33. virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
  34. // nsIContent
  35. virtual nsresult BindToTree(nsIDocument *aDocument, nsIContent *aParent,
  36. nsIContent *aBindingParent,
  37. bool aCompileEventHandlers) override;
  38. virtual void UnbindFromTree(bool aDeep = true,
  39. bool aNullParent = true) override;
  40. NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const override;
  41. virtual bool IsFocusableInternal(int32_t* aTabIndex, bool aWithMouse) override;
  42. virtual bool IsLink(nsIURI** aURI) const override;
  43. virtual void GetLinkTarget(nsAString& aTarget) override;
  44. virtual already_AddRefed<nsIURI> GetHrefURI() const override;
  45. virtual EventStates IntrinsicState() const override;
  46. nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
  47. const nsAString& aValue, bool aNotify)
  48. {
  49. return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify);
  50. }
  51. virtual nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName,
  52. nsIAtom* aPrefix, const nsAString& aValue,
  53. bool aNotify) override;
  54. virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
  55. bool aNotify) override;
  56. // WebIDL
  57. already_AddRefed<SVGAnimatedString> Href();
  58. already_AddRefed<SVGAnimatedString> Target();
  59. void GetDownload(nsAString & aDownload);
  60. void SetDownload(const nsAString & aDownload, ErrorResult& rv);
  61. protected:
  62. virtual ~SVGAElement();
  63. virtual StringAttributesInfo GetStringInfo() override;
  64. enum { HREF, XLINK_HREF, TARGET };
  65. nsSVGString mStringAttributes[3];
  66. static StringInfo sStringInfo[3];
  67. };
  68. } // namespace dom
  69. } // namespace mozilla
  70. #endif // mozilla_dom_SVGAElement_h