Bug 1878930 - s/RawBuffer/Span/: UniformData. r=gfx-reviewers,lsalzman
[gecko.git] / dom / html / HTMLAreaElement.cpp
blobe07150cc0608fcb71b3fcc1eb96e816f1763ac78
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 #include "mozilla/dom/HTMLAreaElement.h"
9 #include "mozilla/Attributes.h"
10 #include "mozilla/dom/BindContext.h"
11 #include "mozilla/dom/Document.h"
12 #include "mozilla/dom/HTMLAnchorElement.h"
13 #include "mozilla/dom/HTMLAreaElementBinding.h"
14 #include "mozilla/EventDispatcher.h"
15 #include "mozilla/MemoryReporting.h"
16 #include "nsWindowSizes.h"
18 NS_IMPL_NS_NEW_HTML_ELEMENT(Area)
20 namespace mozilla::dom {
22 HTMLAreaElement::HTMLAreaElement(
23 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
24 : nsGenericHTMLElement(std::move(aNodeInfo)), Link(this) {}
26 HTMLAreaElement::~HTMLAreaElement() = default;
28 NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(HTMLAreaElement,
29 nsGenericHTMLElement, Link)
31 NS_IMPL_CYCLE_COLLECTION_INHERITED(HTMLAreaElement, nsGenericHTMLElement,
32 mRelList)
34 NS_IMPL_ELEMENT_CLONE(HTMLAreaElement)
36 int32_t HTMLAreaElement::TabIndexDefault() { return 0; }
38 void HTMLAreaElement::GetTarget(DOMString& aValue) {
39 if (!GetAttr(nsGkAtoms::target, aValue)) {
40 GetBaseTarget(aValue);
44 void HTMLAreaElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) {
45 GetEventTargetParentForAnchors(aVisitor);
48 nsresult HTMLAreaElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {
49 return PostHandleEventForAnchors(aVisitor);
52 void HTMLAreaElement::GetLinkTarget(nsAString& aTarget) {
53 GetAttr(nsGkAtoms::target, aTarget);
54 if (aTarget.IsEmpty()) {
55 GetBaseTarget(aTarget);
59 nsDOMTokenList* HTMLAreaElement::RelList() {
60 if (!mRelList) {
61 mRelList =
62 new nsDOMTokenList(this, nsGkAtoms::rel, sAnchorAndFormRelValues);
64 return mRelList;
67 nsresult HTMLAreaElement::BindToTree(BindContext& aContext, nsINode& aParent) {
68 nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
69 NS_ENSURE_SUCCESS(rv, rv);
71 Link::BindToTree(aContext);
72 return rv;
75 void HTMLAreaElement::UnbindFromTree(UnbindContext& aContext) {
76 nsGenericHTMLElement::UnbindFromTree(aContext);
77 // Without removing the link state we risk a dangling pointer in the
78 // mStyledLinks hashtable
79 Link::UnbindFromTree();
82 void HTMLAreaElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
83 const nsAttrValue* aValue,
84 const nsAttrValue* aOldValue,
85 nsIPrincipal* aSubjectPrincipal,
86 bool aNotify) {
87 if (aNamespaceID == kNameSpaceID_None && aName == nsGkAtoms::href) {
88 Link::ResetLinkState(aNotify, !!aValue);
91 return nsGenericHTMLElement::AfterSetAttr(
92 aNamespaceID, aName, aValue, aOldValue, aSubjectPrincipal, aNotify);
95 void HTMLAreaElement::ToString(nsAString& aSource) { GetHref(aSource); }
97 already_AddRefed<nsIURI> HTMLAreaElement::GetHrefURI() const {
98 if (nsCOMPtr<nsIURI> uri = GetCachedURI()) {
99 return uri.forget();
101 return GetHrefURIForAnchors();
104 void HTMLAreaElement::AddSizeOfExcludingThis(nsWindowSizes& aSizes,
105 size_t* aNodeSize) const {
106 nsGenericHTMLElement::AddSizeOfExcludingThis(aSizes, aNodeSize);
107 *aNodeSize += Link::SizeOfExcludingThis(aSizes.mState);
110 JSObject* HTMLAreaElement::WrapNode(JSContext* aCx,
111 JS::Handle<JSObject*> aGivenProto) {
112 return HTMLAreaElement_Binding::Wrap(aCx, this, aGivenProto);
115 } // namespace mozilla::dom