OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 11 matching lines...) Expand all Loading... |
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 */ | 27 */ |
28 | 28 |
29 #include "config.h" | 29 #include "config.h" |
30 #include "modules/accessibility/AXImageMapLink.h" | 30 #include "modules/accessibility/AXImageMapLink.h" |
31 | 31 |
| 32 #include "core/dom/ElementTraversal.h" |
32 #include "modules/accessibility/AXLayoutObject.h" | 33 #include "modules/accessibility/AXLayoutObject.h" |
33 #include "modules/accessibility/AXObjectCacheImpl.h" | 34 #include "modules/accessibility/AXObjectCacheImpl.h" |
34 | 35 |
35 namespace blink { | 36 namespace blink { |
36 | 37 |
37 using namespace HTMLNames; | 38 using namespace HTMLNames; |
38 | 39 |
39 AXImageMapLink::AXImageMapLink(AXObjectCacheImpl& axObjectCache) | 40 AXImageMapLink::AXImageMapLink(HTMLAreaElement* area, AXObjectCacheImpl& axObjec
tCache) |
40 : AXMockObject(axObjectCache) | 41 : AXNodeObject(area, axObjectCache) |
41 , m_areaElement(nullptr) | |
42 , m_mapElement(nullptr) | |
43 { | 42 { |
44 } | 43 } |
45 | 44 |
46 AXImageMapLink::~AXImageMapLink() | 45 AXImageMapLink::~AXImageMapLink() |
47 { | 46 { |
48 ASSERT(!m_areaElement); | |
49 ASSERT(!m_mapElement); | |
50 } | 47 } |
51 | 48 |
52 void AXImageMapLink::detach() | 49 AXImageMapLink* AXImageMapLink::create(HTMLAreaElement* area, AXObjectCacheImpl&
axObjectCache) |
53 { | 50 { |
54 AXMockObject::detach(); | 51 return new AXImageMapLink(area, axObjectCache); |
55 m_areaElement = nullptr; | |
56 m_mapElement = nullptr; | |
57 } | 52 } |
58 | 53 |
59 void AXImageMapLink::detachFromParent() | 54 HTMLMapElement* AXImageMapLink::mapElement() const |
60 { | 55 { |
61 AXMockObject::detachFromParent(); | 56 HTMLAreaElement* area = areaElement(); |
62 m_areaElement = nullptr; | 57 if (!area) |
63 m_mapElement = nullptr; | 58 return nullptr; |
64 } | 59 return Traversal<HTMLMapElement>::firstAncestor(*area); |
65 | |
66 AXImageMapLink* AXImageMapLink::create(AXObjectCacheImpl& axObjectCache) | |
67 { | |
68 return new AXImageMapLink(axObjectCache); | |
69 } | 60 } |
70 | 61 |
71 AXObject* AXImageMapLink::computeParent() const | 62 AXObject* AXImageMapLink::computeParent() const |
72 { | 63 { |
73 if (m_parent) | 64 if (m_parent) |
74 return m_parent; | 65 return m_parent; |
75 | 66 |
76 if (!m_mapElement.get() || !m_mapElement->layoutObject()) | 67 if (!mapElement()) |
77 return 0; | 68 return nullptr; |
78 | 69 |
79 return axObjectCache().getOrCreate(m_mapElement->layoutObject()); | 70 return axObjectCache().getOrCreate(mapElement()->layoutObject()); |
80 } | 71 } |
81 | 72 |
82 AccessibilityRole AXImageMapLink::roleValue() const | 73 AccessibilityRole AXImageMapLink::roleValue() const |
83 { | 74 { |
84 if (!m_areaElement) | |
85 return LinkRole; | |
86 | |
87 const AtomicString& ariaRole = getAttribute(roleAttr); | 75 const AtomicString& ariaRole = getAttribute(roleAttr); |
88 if (!ariaRole.isEmpty()) | 76 if (!ariaRole.isEmpty()) |
89 return AXObject::ariaRoleToWebCoreRole(ariaRole); | 77 return AXObject::ariaRoleToWebCoreRole(ariaRole); |
90 | 78 |
91 return LinkRole; | 79 return LinkRole; |
92 } | 80 } |
93 | 81 |
| 82 bool AXImageMapLink::computeAccessibilityIsIgnored(IgnoredReasons* ignoredReason
s) const |
| 83 { |
| 84 return accessibilityIsIgnoredByDefault(ignoredReasons); |
| 85 } |
| 86 |
94 Element* AXImageMapLink::actionElement() const | 87 Element* AXImageMapLink::actionElement() const |
95 { | 88 { |
96 return anchorElement(); | 89 return anchorElement(); |
97 } | 90 } |
98 | 91 |
99 Element* AXImageMapLink::anchorElement() const | 92 Element* AXImageMapLink::anchorElement() const |
100 { | 93 { |
101 return m_areaElement.get(); | 94 return node() ? toElement(node()) : nullptr; |
102 } | 95 } |
103 | 96 |
104 KURL AXImageMapLink::url() const | 97 KURL AXImageMapLink::url() const |
105 { | 98 { |
106 if (!m_areaElement.get()) | 99 if (!areaElement()) |
107 return KURL(); | 100 return KURL(); |
108 | 101 |
109 return m_areaElement->href(); | 102 return areaElement()->href(); |
110 } | 103 } |
111 | 104 |
112 String AXImageMapLink::deprecatedAccessibilityDescription() const | 105 String AXImageMapLink::deprecatedAccessibilityDescription() const |
113 { | 106 { |
114 const AtomicString& ariaLabel = getAttribute(aria_labelAttr); | 107 const AtomicString& ariaLabel = getAttribute(aria_labelAttr); |
115 if (!ariaLabel.isEmpty()) | 108 if (!ariaLabel.isEmpty()) |
116 return ariaLabel; | 109 return ariaLabel; |
117 const AtomicString& alt = getAttribute(altAttr); | 110 const AtomicString& alt = getAttribute(altAttr); |
118 if (!alt.isEmpty()) | 111 if (!alt.isEmpty()) |
119 return alt; | 112 return alt; |
120 | 113 |
121 return String(); | 114 return String(); |
122 } | 115 } |
123 | 116 |
124 String AXImageMapLink::deprecatedTitle(TextUnderElementMode mode) const | 117 String AXImageMapLink::deprecatedTitle(TextUnderElementMode mode) const |
125 { | 118 { |
126 const AtomicString& title = getAttribute(titleAttr); | 119 const AtomicString& title = getAttribute(titleAttr); |
127 if (!title.isEmpty()) | 120 if (!title.isEmpty()) |
128 return title; | 121 return title; |
129 const AtomicString& summary = getAttribute(summaryAttr); | 122 const AtomicString& summary = getAttribute(summaryAttr); |
130 if (!summary.isEmpty()) | 123 if (!summary.isEmpty()) |
131 return summary; | 124 return summary; |
132 | 125 |
133 return String(); | 126 return String(); |
134 } | 127 } |
135 | 128 |
136 LayoutRect AXImageMapLink::elementRect() const | 129 LayoutRect AXImageMapLink::elementRect() const |
137 { | 130 { |
138 if (!m_mapElement.get() || !m_areaElement.get()) | 131 HTMLAreaElement* area = areaElement(); |
| 132 HTMLMapElement* map = mapElement(); |
| 133 if (!area || !map) |
139 return LayoutRect(); | 134 return LayoutRect(); |
140 | 135 |
141 LayoutObject* layoutObject; | 136 LayoutObject* layoutObject; |
142 if (m_parent && m_parent->isAXLayoutObject()) | 137 if (m_parent && m_parent->isAXLayoutObject()) |
143 layoutObject = toAXLayoutObject(m_parent)->layoutObject(); | 138 layoutObject = toAXLayoutObject(m_parent)->layoutObject(); |
144 else | 139 else |
145 layoutObject = m_mapElement->layoutObject(); | 140 layoutObject = map->layoutObject(); |
146 | 141 |
147 if (!layoutObject) | 142 if (!layoutObject) |
148 return LayoutRect(); | 143 return LayoutRect(); |
149 | 144 |
150 return m_areaElement->computeRect(layoutObject); | 145 return area->computeRect(layoutObject); |
151 } | 146 } |
152 | 147 |
153 DEFINE_TRACE(AXImageMapLink) | 148 DEFINE_TRACE(AXImageMapLink) |
154 { | 149 { |
155 visitor->trace(m_areaElement); | 150 AXNodeObject::trace(visitor); |
156 visitor->trace(m_mapElement); | |
157 AXMockObject::trace(visitor); | |
158 } | 151 } |
159 | 152 |
160 } // namespace blink | 153 } // namespace blink |
OLD | NEW |