HTMLAreaElement.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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_HTMLAreaElement_h
  6. #define mozilla_dom_HTMLAreaElement_h
  7. #include "mozilla/Attributes.h"
  8. #include "mozilla/dom/Link.h"
  9. #include "nsGenericHTMLElement.h"
  10. #include "nsGkAtoms.h"
  11. #include "nsDOMTokenList.h"
  12. #include "nsIDOMHTMLAreaElement.h"
  13. #include "nsIURL.h"
  14. class nsIDocument;
  15. namespace mozilla {
  16. class EventChainPostVisitor;
  17. class EventChainPreVisitor;
  18. namespace dom {
  19. class HTMLAreaElement final : public nsGenericHTMLElement,
  20. public nsIDOMHTMLAreaElement,
  21. public Link
  22. {
  23. public:
  24. explicit HTMLAreaElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
  25. // nsISupports
  26. NS_DECL_ISUPPORTS_INHERITED
  27. // CC
  28. NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLAreaElement,
  29. nsGenericHTMLElement)
  30. // DOM memory reporter participant
  31. NS_DECL_SIZEOF_EXCLUDING_THIS
  32. virtual int32_t TabIndexDefault() override;
  33. // nsIDOMHTMLAreaElement
  34. NS_DECL_NSIDOMHTMLAREAELEMENT
  35. virtual nsresult GetEventTargetParent(
  36. EventChainPreVisitor& aVisitor) override;
  37. virtual nsresult PostHandleEvent(EventChainPostVisitor& aVisitor) override;
  38. virtual bool IsLink(nsIURI** aURI) const override;
  39. virtual void GetLinkTarget(nsAString& aTarget) override;
  40. virtual already_AddRefed<nsIURI> GetHrefURI() const override;
  41. virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
  42. nsIContent* aBindingParent,
  43. bool aCompileEventHandlers) override;
  44. virtual void UnbindFromTree(bool aDeep = true,
  45. bool aNullParent = true) override;
  46. virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult) const override;
  47. virtual EventStates IntrinsicState() const override;
  48. // WebIDL
  49. // The XPCOM GetAlt is OK for us
  50. void SetAlt(const nsAString& aAlt, ErrorResult& aError)
  51. {
  52. SetHTMLAttr(nsGkAtoms::alt, aAlt, aError);
  53. }
  54. // The XPCOM GetCoords is OK for us
  55. void SetCoords(const nsAString& aCoords, ErrorResult& aError)
  56. {
  57. SetHTMLAttr(nsGkAtoms::coords, aCoords, aError);
  58. }
  59. // The XPCOM GetShape is OK for us
  60. void SetShape(const nsAString& aShape, ErrorResult& aError)
  61. {
  62. SetHTMLAttr(nsGkAtoms::shape, aShape, aError);
  63. }
  64. // The XPCOM GetHref is OK for us
  65. void SetHref(const nsAString& aHref, ErrorResult& aError)
  66. {
  67. aError = SetHref(aHref);
  68. }
  69. // The XPCOM GetTarget is OK for us
  70. void SetTarget(const nsAString& aTarget, ErrorResult& aError)
  71. {
  72. SetHTMLAttr(nsGkAtoms::target, aTarget, aError);
  73. }
  74. // The XPCOM GetDownload is OK for us
  75. void SetDownload(const nsAString& aDownload, ErrorResult& aError)
  76. {
  77. SetHTMLAttr(nsGkAtoms::download, aDownload, aError);
  78. }
  79. // The XPCOM GetPing is OK for us
  80. void SetPing(const nsAString& aPing, ErrorResult& aError)
  81. {
  82. SetHTMLAttr(nsGkAtoms::ping, aPing, aError);
  83. }
  84. void GetRel(DOMString& aValue)
  85. {
  86. GetHTMLAttr(nsGkAtoms::rel, aValue);
  87. }
  88. void SetRel(const nsAString& aRel, ErrorResult& aError)
  89. {
  90. SetHTMLAttr(nsGkAtoms::rel, aRel, aError);
  91. }
  92. nsDOMTokenList* RelList();
  93. void SetReferrerPolicy(const nsAString& aValue, mozilla::ErrorResult& rv)
  94. {
  95. SetHTMLAttr(nsGkAtoms::referrerpolicy, aValue, rv);
  96. }
  97. void GetReferrerPolicy(nsAString& aReferrer)
  98. {
  99. GetEnumAttr(nsGkAtoms::referrerpolicy, EmptyCString().get(), aReferrer);
  100. }
  101. // The Link::GetOrigin is OK for us
  102. // Link::Link::GetProtocol is OK for us
  103. // Link::Link::SetProtocol is OK for us
  104. // The Link::GetUsername is OK for us
  105. // The Link::SetUsername is OK for us
  106. // The Link::GetPassword is OK for us
  107. // The Link::SetPassword is OK for us
  108. // Link::Link::GetHost is OK for us
  109. // Link::Link::SetHost is OK for us
  110. // Link::Link::GetHostname is OK for us
  111. // Link::Link::SetHostname is OK for us
  112. // Link::Link::GetPort is OK for us
  113. // Link::Link::SetPort is OK for us
  114. // Link::Link::GetPathname is OK for us
  115. // Link::Link::SetPathname is OK for us
  116. // Link::Link::GetSearch is OK for us
  117. // Link::Link::SetSearch is OK for us
  118. // Link::Link::GetHash is OK for us
  119. // Link::Link::SetHash is OK for us
  120. // The Link::GetSearchParams is OK for us
  121. bool NoHref() const
  122. {
  123. return GetBoolAttr(nsGkAtoms::nohref);
  124. }
  125. void SetNoHref(bool aValue, ErrorResult& aError)
  126. {
  127. SetHTMLBoolAttr(nsGkAtoms::nohref, aValue, aError);
  128. }
  129. void Stringify(nsAString& aResult)
  130. {
  131. GetHref(aResult);
  132. }
  133. protected:
  134. virtual ~HTMLAreaElement();
  135. virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
  136. virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
  137. const nsAttrValue* aValue,
  138. const nsAttrValue* aOldValue,
  139. bool aNotify) override;
  140. RefPtr<nsDOMTokenList > mRelList;
  141. };
  142. } // namespace dom
  143. } // namespace mozilla
  144. #endif /* mozilla_dom_HTMLAreaElement_h */