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