/src/mozilla-central/dom/html/HTMLAreaElement.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | #include "mozilla/dom/HTMLAreaElement.h" |
8 | | |
9 | | #include "mozilla/Attributes.h" |
10 | | #include "mozilla/dom/HTMLAnchorElement.h" |
11 | | #include "mozilla/dom/HTMLAreaElementBinding.h" |
12 | | #include "mozilla/EventDispatcher.h" |
13 | | #include "mozilla/EventStates.h" |
14 | | #include "mozilla/MemoryReporting.h" |
15 | | #include "nsWindowSizes.h" |
16 | | |
17 | | NS_IMPL_NS_NEW_HTML_ELEMENT(Area) |
18 | | |
19 | | namespace mozilla { |
20 | | namespace dom { |
21 | | |
22 | | HTMLAreaElement::HTMLAreaElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo) |
23 | | : nsGenericHTMLElement(std::move(aNodeInfo)) |
24 | | , Link(this) |
25 | 0 | { |
26 | 0 | } |
27 | | |
28 | | HTMLAreaElement::~HTMLAreaElement() |
29 | 0 | { |
30 | 0 | } |
31 | | |
32 | | NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(HTMLAreaElement, |
33 | | nsGenericHTMLElement, |
34 | | Link) |
35 | | |
36 | | NS_IMPL_CYCLE_COLLECTION_INHERITED(HTMLAreaElement, |
37 | | nsGenericHTMLElement, |
38 | | mRelList) |
39 | | |
40 | | NS_IMPL_ELEMENT_CLONE(HTMLAreaElement) |
41 | | |
42 | | int32_t |
43 | | HTMLAreaElement::TabIndexDefault() |
44 | 0 | { |
45 | 0 | return 0; |
46 | 0 | } |
47 | | |
48 | | void |
49 | | HTMLAreaElement::GetTarget(DOMString& aValue) |
50 | 0 | { |
51 | 0 | if (!GetAttr(kNameSpaceID_None, nsGkAtoms::target, aValue)) { |
52 | 0 | GetBaseTarget(aValue); |
53 | 0 | } |
54 | 0 | } |
55 | | |
56 | | void |
57 | | HTMLAreaElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) |
58 | 0 | { |
59 | 0 | GetEventTargetParentForAnchors(aVisitor); |
60 | 0 | } |
61 | | |
62 | | nsresult |
63 | | HTMLAreaElement::PostHandleEvent(EventChainPostVisitor& aVisitor) |
64 | 0 | { |
65 | 0 | return PostHandleEventForAnchors(aVisitor); |
66 | 0 | } |
67 | | |
68 | | bool |
69 | | HTMLAreaElement::IsLink(nsIURI** aURI) const |
70 | 0 | { |
71 | 0 | return IsHTMLLink(aURI); |
72 | 0 | } |
73 | | |
74 | | void |
75 | | HTMLAreaElement::GetLinkTarget(nsAString& aTarget) |
76 | 0 | { |
77 | 0 | GetAttr(kNameSpaceID_None, nsGkAtoms::target, aTarget); |
78 | 0 | if (aTarget.IsEmpty()) { |
79 | 0 | GetBaseTarget(aTarget); |
80 | 0 | } |
81 | 0 | } |
82 | | |
83 | | nsDOMTokenList* |
84 | | HTMLAreaElement::RelList() |
85 | 0 | { |
86 | 0 | if (!mRelList) { |
87 | 0 | mRelList = new nsDOMTokenList(this, nsGkAtoms::rel, |
88 | 0 | HTMLAnchorElement::sSupportedRelValues); |
89 | 0 | } |
90 | 0 | return mRelList; |
91 | 0 | } |
92 | | |
93 | | nsresult |
94 | | HTMLAreaElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, |
95 | | nsIContent* aBindingParent) |
96 | 0 | { |
97 | 0 | Link::ResetLinkState(false, Link::ElementHasHref()); |
98 | 0 | nsresult rv = nsGenericHTMLElement::BindToTree(aDocument, aParent, |
99 | 0 | aBindingParent); |
100 | 0 | NS_ENSURE_SUCCESS(rv, rv); |
101 | 0 |
|
102 | 0 | nsIDocument* doc = GetComposedDoc(); |
103 | 0 | if (doc) { |
104 | 0 | doc->RegisterPendingLinkUpdate(this); |
105 | 0 | } |
106 | 0 | return rv; |
107 | 0 | } |
108 | | |
109 | | void |
110 | | HTMLAreaElement::UnbindFromTree(bool aDeep, bool aNullParent) |
111 | 0 | { |
112 | 0 | // If this link is ever reinserted into a document, it might |
113 | 0 | // be under a different xml:base, so forget the cached state now. |
114 | 0 | Link::ResetLinkState(false, Link::ElementHasHref()); |
115 | 0 |
|
116 | 0 | nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent); |
117 | 0 | } |
118 | | |
119 | | nsresult |
120 | | HTMLAreaElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, |
121 | | const nsAttrValue* aValue, |
122 | | const nsAttrValue* aOldValue, |
123 | | nsIPrincipal* aSubjectPrincipal, |
124 | | bool aNotify) |
125 | 0 | { |
126 | 0 | if (aNamespaceID == kNameSpaceID_None) { |
127 | 0 | // This must happen after the attribute is set. We will need the updated |
128 | 0 | // attribute value because notifying the document that content states have |
129 | 0 | // changed will call IntrinsicState, which will try to get updated |
130 | 0 | // information about the visitedness from Link. |
131 | 0 | if (aName == nsGkAtoms::href) { |
132 | 0 | Link::ResetLinkState(aNotify, !!aValue); |
133 | 0 | } |
134 | 0 | } |
135 | 0 |
|
136 | 0 | return nsGenericHTMLElement::AfterSetAttr(aNamespaceID, aName, aValue, |
137 | 0 | aOldValue, aSubjectPrincipal, aNotify); |
138 | 0 | } |
139 | | |
140 | | void |
141 | | HTMLAreaElement::ToString(nsAString& aSource) |
142 | 0 | { |
143 | 0 | GetHref(aSource); |
144 | 0 | } |
145 | | |
146 | | already_AddRefed<nsIURI> |
147 | | HTMLAreaElement::GetHrefURI() const |
148 | 0 | { |
149 | 0 | return GetHrefURIForAnchors(); |
150 | 0 | } |
151 | | |
152 | | EventStates |
153 | | HTMLAreaElement::IntrinsicState() const |
154 | 0 | { |
155 | 0 | return Link::LinkState() | nsGenericHTMLElement::IntrinsicState(); |
156 | 0 | } |
157 | | |
158 | | void |
159 | | HTMLAreaElement::AddSizeOfExcludingThis(nsWindowSizes& aSizes, |
160 | | size_t* aNodeSize) const |
161 | 0 | { |
162 | 0 | nsGenericHTMLElement::AddSizeOfExcludingThis(aSizes, aNodeSize); |
163 | 0 | *aNodeSize += Link::SizeOfExcludingThis(aSizes.mState); |
164 | 0 | } |
165 | | |
166 | | JSObject* |
167 | | HTMLAreaElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) |
168 | 0 | { |
169 | 0 | return HTMLAreaElement_Binding::Wrap(aCx, this, aGivenProto); |
170 | 0 | } |
171 | | |
172 | | } // namespace dom |
173 | | } // namespace mozilla |