OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012, Google Inc. All rights reserved. | 2 * Copyright (C) 2012, Google 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 return true; | 176 return true; |
177 | 177 |
178 return m_role == UnknownRole; | 178 return m_role == UnknownRole; |
179 } | 179 } |
180 | 180 |
181 static bool isListElement(Node* node) | 181 static bool isListElement(Node* node) |
182 { | 182 { |
183 return isHTMLUListElement(*node) || isHTMLOListElement(*node) || isHTMLDList
Element(*node); | 183 return isHTMLUListElement(*node) || isHTMLOListElement(*node) || isHTMLDList
Element(*node); |
184 } | 184 } |
185 | 185 |
186 static bool isPresentationRoleInTable(AXObject* parent, Node* child) | 186 static bool isPresentationalInTable(AXObject* parent, HTMLElement* currentElemen
t) |
187 { | 187 { |
| 188 if (!currentElement) |
| 189 return false; |
| 190 |
188 Node* parentNode = parent->node(); | 191 Node* parentNode = parent->node(); |
189 if (!parentNode || !parentNode->isElementNode()) | 192 if (!parentNode || !parentNode->isHTMLElement()) |
190 return false; | 193 return false; |
191 | 194 |
192 // AXTable determines the role as checking isTableXXX. | 195 // AXTable determines the role as checking isTableXXX. |
193 // If Table has explicit role including presentation, AXTable doesn't assign
implicit Role | 196 // If Table has explicit role including presentation, AXTable doesn't assign
implicit Role |
194 // to a whole Table. That's why we should check it based on node. | 197 // to a whole Table. That's why we should check it based on node. |
195 // Normal Table Tree is that | 198 // Normal Table Tree is that |
196 // cell(its role)-> tr(tr role)-> tfoot, tbody, thead(ignored role) -> table
(table role). | 199 // cell(its role)-> tr(tr role)-> tfoot, tbody, thead(ignored role) -> table
(table role). |
197 // If table has presentation role, it will be like | 200 // If table has presentation role, it will be like |
198 // cell(group)-> tr(unknown) -> tfoot, tbody, thead(ignored) -> table(presen
tation). | 201 // cell(group)-> tr(unknown) -> tfoot, tbody, thead(ignored) -> table(presen
tation). |
199 if (child && isHTMLTableCellElement(*child) && isHTMLTableRowElement(*parent
Node)) | 202 if (isHTMLTableCellElement(*currentElement) && isHTMLTableRowElement(*parent
Node)) |
200 return parent->hasInheritedPresentationalRole(); | 203 return parent->hasInheritedPresentationalRole(); |
201 | 204 |
202 if (isHTMLTableRowElement(child) && isHTMLTableSectionElement(*parentNode))
{ | 205 if (isHTMLTableRowElement(*currentElement) && isHTMLTableSectionElement(toHT
MLElement(*parentNode))) { |
203 // Because TableSections have ignored role, presentation should be check
ed with its parent node | 206 // Because TableSections have ignored role, presentation should be check
ed with its parent node |
204 AXObject* tableObject = parent->parentObject(); | 207 AXObject* tableObject = parent->parentObject(); |
205 Node* tableNode = tableObject ? tableObject->node() : 0; | 208 Node* tableNode = tableObject ? tableObject->node() : 0; |
206 return isHTMLTableElement(tableNode) && tableObject->hasInheritedPresent
ationalRole(); | 209 return isHTMLTableElement(tableNode) && tableObject->hasInheritedPresent
ationalRole(); |
207 } | 210 } |
208 return false; | 211 return false; |
209 } | 212 } |
210 | 213 |
211 static bool isRequiredOwnedElement(AXObject* parent, AccessibilityRole childRole
, Node* childNode) | 214 static bool isRequiredOwnedElement(AXObject* parent, AccessibilityRole currentRo
le, HTMLElement* currentElement) |
212 { | 215 { |
213 Node* parentNode = parent->node(); | 216 Node* parentNode = parent->node(); |
214 if (!parentNode || !parentNode->isElementNode()) | 217 if (!parentNode || !parentNode->isHTMLElement()) |
215 return false; | 218 return false; |
216 | 219 |
217 if (childRole == ListItemRole) | 220 if (currentRole == ListItemRole) |
218 return isListElement(parentNode); | 221 return isListElement(parentNode); |
219 if (childRole == ListMarkerRole) | 222 if (currentRole == ListMarkerRole) |
220 return isHTMLLIElement(*parentNode); | 223 return isHTMLLIElement(*parentNode); |
221 if (childRole == MenuItemCheckBoxRole || childRole == MenuItemRole || child
Role == MenuItemRadioRole) | 224 if (currentRole == MenuItemCheckBoxRole || currentRole == MenuItemRole || c
urrentRole == MenuItemRadioRole) |
222 return isHTMLMenuElement(*parentNode); | 225 return isHTMLMenuElement(*parentNode); |
223 | 226 |
224 if (childNode && isHTMLTableCellElement(*childNode)) | 227 if (!currentElement) |
| 228 return false; |
| 229 if (isHTMLTableCellElement(*currentElement)) |
225 return isHTMLTableRowElement(*parentNode); | 230 return isHTMLTableRowElement(*parentNode); |
226 if (isHTMLTableRowElement(childNode)) | 231 if (isHTMLTableRowElement(*currentElement)) |
227 return isHTMLTableSectionElement(*parentNode); | 232 return isHTMLTableSectionElement(toHTMLElement(*parentNode)); |
228 | 233 |
229 // In case of ListboxRole and it's child, ListBoxOptionRole, | 234 // In case of ListboxRole and it's child, ListBoxOptionRole, |
230 // Inheritance of presentation role is handled in AXListBoxOption | 235 // Inheritance of presentation role is handled in AXListBoxOption |
231 // Because ListBoxOption Role doesn't have any child. | 236 // Because ListBoxOption Role doesn't have any child. |
232 // If it's just ignored because of presentation, we can't see any AX tree re
lated to ListBoxOption. | 237 // If it's just ignored because of presentation, we can't see any AX tree re
lated to ListBoxOption. |
233 return false; | 238 return false; |
234 } | 239 } |
235 | 240 |
236 | 241 |
237 const AXObject* AXNodeObject::inheritsPresentationalRoleFrom() const | 242 const AXObject* AXNodeObject::inheritsPresentationalRoleFrom() const |
238 { | 243 { |
239 // ARIA states if an item can get focus, it should not be presentational. | 244 // ARIA states if an item can get focus, it should not be presentational. |
240 if (canSetFocusAttribute()) | 245 if (canSetFocusAttribute()) |
241 return 0; | 246 return 0; |
242 | 247 |
243 if (isPresentational()) | 248 if (isPresentational()) |
244 return this; | 249 return this; |
245 | 250 |
246 // http://www.w3.org/TR/wai-aria/complete#presentation | 251 // http://www.w3.org/TR/wai-aria/complete#presentation |
247 // ARIA spec says that the user agent MUST apply an inherited role of presen
tation | 252 // ARIA spec says that the user agent MUST apply an inherited role of presen
tation |
248 // to any owned elements that do not have an explicit role defined. | 253 // to any owned elements that do not have an explicit role defined. |
249 if (ariaRoleAttribute() != UnknownRole) | 254 if (ariaRoleAttribute() != UnknownRole) |
250 return 0; | 255 return 0; |
251 | 256 |
252 AXObject* parent = parentObject(); | 257 AXObject* parent = parentObject(); |
253 if (!parent) | 258 if (!parent) |
254 return 0; | 259 return 0; |
255 | 260 |
256 Node* curNode = node(); | 261 HTMLElement* element = nullptr; |
| 262 if (node() && node()->isHTMLElement()) |
| 263 element = toHTMLElement(node()); |
257 if (!parent->hasInheritedPresentationalRole() | 264 if (!parent->hasInheritedPresentationalRole() |
258 && !isPresentationRoleInTable(parent, curNode)) | 265 && !isPresentationalInTable(parent, element)) |
259 return 0; | 266 return 0; |
260 | |
261 // ARIA spec says that when a parent object is presentational and this objec
t | 267 // ARIA spec says that when a parent object is presentational and this objec
t |
262 // is a required owned element of that parent, then this object is also pres
entational. | 268 // is a required owned element of that parent, then this object is also pres
entational. |
263 if (isRequiredOwnedElement(parent, roleValue(), curNode)) | 269 if (isRequiredOwnedElement(parent, roleValue(), element)) |
264 return parent; | 270 return parent; |
265 return 0; | 271 return 0; |
266 } | 272 } |
267 | 273 |
268 bool AXNodeObject::isDescendantOfElementType(const HTMLQualifiedName& tagName) c
onst | 274 bool AXNodeObject::isDescendantOfElementType(const HTMLQualifiedName& tagName) c
onst |
269 { | 275 { |
270 if (!node()) | 276 if (!node()) |
271 return false; | 277 return false; |
272 | 278 |
273 for (Element* parent = node()->parentElement(); parent; parent = parent->par
entElement()) { | 279 for (Element* parent = node()->parentElement(); parent; parent = parent->par
entElement()) { |
(...skipping 1938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2212 ariaLabeledByElements(elements); | 2218 ariaLabeledByElements(elements); |
2213 | 2219 |
2214 for (const auto& element : elements) { | 2220 for (const auto& element : elements) { |
2215 RefPtr<AXObject> axElement = axObjectCache()->getOrCreate(element); | 2221 RefPtr<AXObject> axElement = axObjectCache()->getOrCreate(element); |
2216 textOrder.append(AccessibilityText(ariaLabeledBy, AlternativeText, a
xElement)); | 2222 textOrder.append(AccessibilityText(ariaLabeledBy, AlternativeText, a
xElement)); |
2217 } | 2223 } |
2218 } | 2224 } |
2219 } | 2225 } |
2220 | 2226 |
2221 } // namespace blink | 2227 } // namespace blink |
OLD | NEW |