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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 | 275 |
276 Node* node = m_layoutObject->node(); | 276 Node* node = m_layoutObject->node(); |
277 LayoutBoxModelObject* cssBox = layoutBoxModelObject(); | 277 LayoutBoxModelObject* cssBox = layoutBoxModelObject(); |
278 | 278 |
279 if ((cssBox && cssBox->isListItem()) || isHTMLLIElement(node)) | 279 if ((cssBox && cssBox->isListItem()) || isHTMLLIElement(node)) |
280 return ListItemRole; | 280 return ListItemRole; |
281 if (m_layoutObject->isListMarker()) | 281 if (m_layoutObject->isListMarker()) |
282 return ListMarkerRole; | 282 return ListMarkerRole; |
283 if (m_layoutObject->isBR()) | 283 if (m_layoutObject->isBR()) |
284 return LineBreakRole; | 284 return LineBreakRole; |
285 if (isHTMLLegendElement(node)) | |
286 return LegendRole; | |
287 if (m_layoutObject->isText()) | 285 if (m_layoutObject->isText()) |
288 return StaticTextRole; | 286 return StaticTextRole; |
289 if (cssBox && isImageOrAltText(cssBox, node)) { | 287 if (cssBox && isImageOrAltText(cssBox, node)) { |
290 if (node && node->isLink()) | 288 if (node && node->isLink()) |
291 return ImageMapRole; | 289 return ImageMapRole; |
292 if (isHTMLInputElement(node)) | 290 if (isHTMLInputElement(node)) |
293 return ariaHasPopup() ? PopUpButtonRole : ButtonRole; | 291 return ariaHasPopup() ? PopUpButtonRole : ButtonRole; |
294 if (isSVGImage()) | 292 if (isSVGImage()) |
295 return SVGRootRole; | 293 return SVGRootRole; |
296 return ImageRole; | 294 return ImageRole; |
297 } | 295 } |
298 // Note: if JavaScript is disabled, the layoutObject won't be a LayoutHTMLCa
nvas. | 296 // Note: if JavaScript is disabled, the layoutObject won't be a LayoutHTMLCa
nvas. |
299 if (isHTMLCanvasElement(node) && m_layoutObject->isCanvas()) | 297 if (isHTMLCanvasElement(node) && m_layoutObject->isCanvas()) |
300 return CanvasRole; | 298 return CanvasRole; |
301 | 299 |
302 if (cssBox && cssBox->isLayoutView()) | 300 if (cssBox && cssBox->isLayoutView()) |
303 return WebAreaRole; | 301 return WebAreaRole; |
304 | 302 |
305 if (m_layoutObject->isSVGImage()) | 303 if (m_layoutObject->isSVGImage()) |
306 return ImageRole; | 304 return ImageRole; |
307 if (m_layoutObject->isSVGRoot()) | 305 if (m_layoutObject->isSVGRoot()) |
308 return SVGRootRole; | 306 return SVGRootRole; |
309 | 307 |
310 if (node && node->hasTagName(ddTag)) | |
311 return DescriptionListDetailRole; | |
312 | |
313 if (node && node->hasTagName(dtTag)) | |
314 return DescriptionListTermRole; | |
315 | |
316 if (node && (node->nodeName() == "math")) | |
317 return MathRole; | |
318 | |
319 if (node && (node->hasTagName(rpTag) || node->hasTagName(rtTag))) | |
320 return AnnotationRole; | |
321 | |
322 // Table sections should be ignored. | 308 // Table sections should be ignored. |
323 if (m_layoutObject->isTableSection()) | 309 if (m_layoutObject->isTableSection()) |
324 return IgnoredRole; | 310 return IgnoredRole; |
325 | 311 |
326 if (m_layoutObject->isHR()) | 312 if (m_layoutObject->isHR()) |
327 return SplitterRole; | 313 return SplitterRole; |
328 | 314 |
329 if (isHTMLFormElement(node)) | |
330 return FormRole; | |
331 | |
332 if (node && node->hasTagName(articleTag)) | |
333 return ArticleRole; | |
334 | |
335 if (node && node->hasTagName(mainTag)) | |
336 return MainRole; | |
337 | |
338 if (node && node->hasTagName(navTag)) | |
339 return NavigationRole; | |
340 | |
341 if (node && node->hasTagName(asideTag)) | |
342 return ComplementaryRole; | |
343 | |
344 if (node && node->hasTagName(preTag)) | |
345 return PreRole; | |
346 | |
347 if (node && node->hasTagName(sectionTag)) | |
348 return RegionRole; | |
349 | |
350 if (node && node->hasTagName(addressTag)) | |
351 return ContentInfoRole; | |
352 | |
353 if (node && node->hasTagName(dialogTag)) | |
354 return DialogRole; | |
355 | |
356 // The HTML element should not be exposed as an element. That's what the Lay
outView element does. | |
357 if (isHTMLHtmlElement(node)) | |
358 return IgnoredRole; | |
359 | |
360 if (node && node->hasTagName(iframeTag)) { | |
361 const AtomicString& ariaRole = getAttribute(roleAttr); | |
362 if (ariaRole == "none" || ariaRole == "presentation") | |
363 return IframePresentationalRole; | |
364 return IframeRole; | |
365 } | |
366 | |
367 // There should only be one banner/contentInfo per page. If header/footer ar
e being used within an article or section | |
368 // then it should not be exposed as whole page's banner/contentInfo | |
369 if (node && node->hasTagName(headerTag) && !isDescendantOfElementType(articl
eTag) && !isDescendantOfElementType(sectionTag)) | |
370 return BannerRole; | |
371 if (node && node->hasTagName(footerTag) && !isDescendantOfElementType(articl
eTag) && !isDescendantOfElementType(sectionTag)) | |
372 return FooterRole; | |
373 | |
374 AccessibilityRole role = AXNodeObject::determineAccessibilityRoleUtil(); | 315 AccessibilityRole role = AXNodeObject::determineAccessibilityRoleUtil(); |
375 if (role != UnknownRole) | 316 if (role != UnknownRole) |
376 return role; | 317 return role; |
377 | 318 |
378 if (m_layoutObject->isLayoutBlockFlow()) | 319 if (m_layoutObject->isLayoutBlockFlow()) |
379 return GroupRole; | 320 return GroupRole; |
380 | 321 |
381 // If the element does not have role, but it has ARIA attributes, accessibil
ity should fallback to exposing it as a group. | 322 // If the element does not have role, but it has ARIA attributes, accessibil
ity should fallback to exposing it as a group. |
382 if (supportsARIAAttributes()) | 323 if (supportsARIAAttributes()) |
383 return GroupRole; | 324 return GroupRole; |
(...skipping 1702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2086 break; | 2027 break; |
2087 firstChild = newFirstChild; | 2028 firstChild = newFirstChild; |
2088 if (!firstChild->node()) | 2029 if (!firstChild->node()) |
2089 break; | 2030 break; |
2090 } | 2031 } |
2091 } | 2032 } |
2092 | 2033 |
2093 return parent; | 2034 return parent; |
2094 } | 2035 } |
2095 | 2036 |
2096 bool AXLayoutObject::isDescendantOfElementType(const HTMLQualifiedName& tagName)
const | |
2097 { | |
2098 for (LayoutObject* parent = m_layoutObject->parent(); parent; parent = paren
t->parent()) { | |
2099 if (parent->node() && parent->node()->hasTagName(tagName)) | |
2100 return true; | |
2101 } | |
2102 return false; | |
2103 } | |
2104 | |
2105 bool AXLayoutObject::isSVGImage() const | 2037 bool AXLayoutObject::isSVGImage() const |
2106 { | 2038 { |
2107 return remoteSVGRootElement(); | 2039 return remoteSVGRootElement(); |
2108 } | 2040 } |
2109 | 2041 |
2110 void AXLayoutObject::detachRemoteSVGRoot() | 2042 void AXLayoutObject::detachRemoteSVGRoot() |
2111 { | 2043 { |
2112 if (AXSVGRoot* root = remoteSVGRootElement()) | 2044 if (AXSVGRoot* root = remoteSVGRootElement()) |
2113 root->setParent(0); | 2045 root->setParent(0); |
2114 } | 2046 } |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2396 if (label && label->layoutObject()) { | 2328 if (label && label->layoutObject()) { |
2397 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR
ect(); | 2329 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR
ect(); |
2398 result.unite(labelRect); | 2330 result.unite(labelRect); |
2399 } | 2331 } |
2400 } | 2332 } |
2401 | 2333 |
2402 return result; | 2334 return result; |
2403 } | 2335 } |
2404 | 2336 |
2405 } // namespace blink | 2337 } // namespace blink |
OLD | NEW |