| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 return alt; | 105 return alt; |
| 106 | 106 |
| 107 const AtomicString& title = toHTMLElement(node)->getAttribute(titleAttr)
; | 107 const AtomicString& title = toHTMLElement(node)->getAttribute(titleAttr)
; |
| 108 if (!title.isEmpty()) | 108 if (!title.isEmpty()) |
| 109 return title; | 109 return title; |
| 110 } | 110 } |
| 111 | 111 |
| 112 return String(); | 112 return String(); |
| 113 } | 113 } |
| 114 | 114 |
| 115 String AXNodeObject::accessibilityDescriptionForElements(WillBeHeapVector<RawPtr
WillBeMember<Element>> &elements) const | 115 String AXNodeObject::accessibilityDescriptionForElements(HeapVector<Member<Eleme
nt>> &elements) const |
| 116 { | 116 { |
| 117 StringBuilder builder; | 117 StringBuilder builder; |
| 118 unsigned size = elements.size(); | 118 unsigned size = elements.size(); |
| 119 for (unsigned i = 0; i < size; ++i) { | 119 for (unsigned i = 0; i < size; ++i) { |
| 120 Element* idElement = elements[i]; | 120 Element* idElement = elements[i]; |
| 121 | 121 |
| 122 builder.append(accessibleNameForNode(idElement)); | 122 builder.append(accessibleNameForNode(idElement)); |
| 123 for (Node& n : NodeTraversal::descendantsOf(*idElement)) | 123 for (Node& n : NodeTraversal::descendantsOf(*idElement)) |
| 124 builder.append(accessibleNameForNode(&n)); | 124 builder.append(accessibleNameForNode(&n)); |
| 125 | 125 |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 role = remapAriaRoleDueToParent(role); | 545 role = remapAriaRoleDueToParent(role); |
| 546 | 546 |
| 547 if (role) | 547 if (role) |
| 548 return role; | 548 return role; |
| 549 | 549 |
| 550 return UnknownRole; | 550 return UnknownRole; |
| 551 } | 551 } |
| 552 | 552 |
| 553 void AXNodeObject::accessibilityChildrenFromAttribute(QualifiedName attr, AXObje
ct::AXObjectVector& children) const | 553 void AXNodeObject::accessibilityChildrenFromAttribute(QualifiedName attr, AXObje
ct::AXObjectVector& children) const |
| 554 { | 554 { |
| 555 WillBeHeapVector<RawPtrWillBeMember<Element>> elements; | 555 HeapVector<Member<Element>> elements; |
| 556 elementsFromAttribute(elements, attr); | 556 elementsFromAttribute(elements, attr); |
| 557 | 557 |
| 558 AXObjectCacheImpl& cache = axObjectCache(); | 558 AXObjectCacheImpl& cache = axObjectCache(); |
| 559 for (const auto& element : elements) { | 559 for (const auto& element : elements) { |
| 560 if (AXObject* child = cache.getOrCreate(element)) | 560 if (AXObject* child = cache.getOrCreate(element)) |
| 561 children.append(child); | 561 children.append(child); |
| 562 } | 562 } |
| 563 } | 563 } |
| 564 | 564 |
| 565 // This only returns true if this is the element that actually has the | 565 // This only returns true if this is the element that actually has the |
| (...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1293 if (equalIgnoringCase(attributeValue, "grammar")) | 1293 if (equalIgnoringCase(attributeValue, "grammar")) |
| 1294 return InvalidStateGrammar; | 1294 return InvalidStateGrammar; |
| 1295 // A yet unknown value. | 1295 // A yet unknown value. |
| 1296 if (!attributeValue.isEmpty()) | 1296 if (!attributeValue.isEmpty()) |
| 1297 return InvalidStateOther; | 1297 return InvalidStateOther; |
| 1298 } | 1298 } |
| 1299 | 1299 |
| 1300 if (getNode() && getNode()->isElementNode() | 1300 if (getNode() && getNode()->isElementNode() |
| 1301 && toElement(getNode())->isFormControlElement()) { | 1301 && toElement(getNode())->isFormControlElement()) { |
| 1302 HTMLFormControlElement* element = toHTMLFormControlElement(getNode()); | 1302 HTMLFormControlElement* element = toHTMLFormControlElement(getNode()); |
| 1303 WillBeHeapVector<RefPtrWillBeMember<HTMLFormControlElement>> | 1303 HeapVector<Member<HTMLFormControlElement>> |
| 1304 invalidControls; | 1304 invalidControls; |
| 1305 bool isInvalid = !element->checkValidity( | 1305 bool isInvalid = !element->checkValidity( |
| 1306 &invalidControls, CheckValidityDispatchNoEvent); | 1306 &invalidControls, CheckValidityDispatchNoEvent); |
| 1307 return isInvalid ? InvalidStateTrue : InvalidStateFalse; | 1307 return isInvalid ? InvalidStateTrue : InvalidStateFalse; |
| 1308 } | 1308 } |
| 1309 | 1309 |
| 1310 return InvalidStateUndefined; | 1310 return InvalidStateUndefined; |
| 1311 } | 1311 } |
| 1312 | 1312 |
| 1313 int AXNodeObject::posInSet() const | 1313 int AXNodeObject::posInSet() const |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1405 | 1405 |
| 1406 String AXNodeObject::stringValue() const | 1406 String AXNodeObject::stringValue() const |
| 1407 { | 1407 { |
| 1408 Node* node = this->getNode(); | 1408 Node* node = this->getNode(); |
| 1409 if (!node) | 1409 if (!node) |
| 1410 return String(); | 1410 return String(); |
| 1411 | 1411 |
| 1412 if (isHTMLSelectElement(*node)) { | 1412 if (isHTMLSelectElement(*node)) { |
| 1413 HTMLSelectElement& selectElement = toHTMLSelectElement(*node); | 1413 HTMLSelectElement& selectElement = toHTMLSelectElement(*node); |
| 1414 int selectedIndex = selectElement.selectedIndex(); | 1414 int selectedIndex = selectElement.selectedIndex(); |
| 1415 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& listItems = sel
ectElement.listItems(); | 1415 const HeapVector<Member<HTMLElement>>& listItems = selectElement.listIte
ms(); |
| 1416 if (selectedIndex >= 0 && static_cast<size_t>(selectedIndex) < listItems
.size()) { | 1416 if (selectedIndex >= 0 && static_cast<size_t>(selectedIndex) < listItems
.size()) { |
| 1417 const AtomicString& overriddenDescription = listItems[selectedIndex]
->fastGetAttribute(aria_labelAttr); | 1417 const AtomicString& overriddenDescription = listItems[selectedIndex]
->fastGetAttribute(aria_labelAttr); |
| 1418 if (!overriddenDescription.isNull()) | 1418 if (!overriddenDescription.isNull()) |
| 1419 return overriddenDescription; | 1419 return overriddenDescription; |
| 1420 } | 1420 } |
| 1421 if (!selectElement.multiple()) | 1421 if (!selectElement.multiple()) |
| 1422 return selectElement.value(); | 1422 return selectElement.value(); |
| 1423 return String(); | 1423 return String(); |
| 1424 } | 1424 } |
| 1425 | 1425 |
| 1426 if (isNativeTextControl()) | 1426 if (isNativeTextControl()) |
| 1427 return text(); | 1427 return text(); |
| 1428 | 1428 |
| 1429 // Handle other HTML input elements that aren't text controls, like date and
time | 1429 // Handle other HTML input elements that aren't text controls, like date and
time |
| 1430 // controls, by returning the string value, with the exception of checkboxes | 1430 // controls, by returning the string value, with the exception of checkboxes |
| 1431 // and radio buttons (which would return "on"). | 1431 // and radio buttons (which would return "on"). |
| 1432 if (isHTMLInputElement(node)) { | 1432 if (isHTMLInputElement(node)) { |
| 1433 HTMLInputElement* input = toHTMLInputElement(node); | 1433 HTMLInputElement* input = toHTMLInputElement(node); |
| 1434 if (input->type() != InputTypeNames::checkbox && input->type() != InputT
ypeNames::radio) | 1434 if (input->type() != InputTypeNames::checkbox && input->type() != InputT
ypeNames::radio) |
| 1435 return input->value(); | 1435 return input->value(); |
| 1436 } | 1436 } |
| 1437 | 1437 |
| 1438 return String(); | 1438 return String(); |
| 1439 } | 1439 } |
| 1440 | 1440 |
| 1441 String AXNodeObject::ariaDescribedByAttribute() const | 1441 String AXNodeObject::ariaDescribedByAttribute() const |
| 1442 { | 1442 { |
| 1443 WillBeHeapVector<RawPtrWillBeMember<Element>> elements; | 1443 HeapVector<Member<Element>> elements; |
| 1444 elementsFromAttribute(elements, aria_describedbyAttr); | 1444 elementsFromAttribute(elements, aria_describedbyAttr); |
| 1445 | 1445 |
| 1446 return accessibilityDescriptionForElements(elements); | 1446 return accessibilityDescriptionForElements(elements); |
| 1447 } | 1447 } |
| 1448 | 1448 |
| 1449 String AXNodeObject::ariaLabelledbyAttribute() const | 1449 String AXNodeObject::ariaLabelledbyAttribute() const |
| 1450 { | 1450 { |
| 1451 WillBeHeapVector<RawPtrWillBeMember<Element>> elements; | 1451 HeapVector<Member<Element>> elements; |
| 1452 ariaLabelledbyElementVector(elements); | 1452 ariaLabelledbyElementVector(elements); |
| 1453 | 1453 |
| 1454 return accessibilityDescriptionForElements(elements); | 1454 return accessibilityDescriptionForElements(elements); |
| 1455 } | 1455 } |
| 1456 | 1456 |
| 1457 AccessibilityRole AXNodeObject::ariaRoleAttribute() const | 1457 AccessibilityRole AXNodeObject::ariaRoleAttribute() const |
| 1458 { | 1458 { |
| 1459 return m_ariaRole; | 1459 return m_ariaRole; |
| 1460 } | 1460 } |
| 1461 | 1461 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1653 // computeAccessibilityIsIgnored, which isn't allowed to call axObjectCache-
>getOrCreate. | 1653 // computeAccessibilityIsIgnored, which isn't allowed to call axObjectCache-
>getOrCreate. |
| 1654 | 1654 |
| 1655 if (!getNode() && !getLayoutObject()) | 1655 if (!getNode() && !getLayoutObject()) |
| 1656 return false; | 1656 return false; |
| 1657 | 1657 |
| 1658 // Step 2A from: http://www.w3.org/TR/accname-aam-1.1 | 1658 // Step 2A from: http://www.w3.org/TR/accname-aam-1.1 |
| 1659 if (isHiddenForTextAlternativeCalculation()) | 1659 if (isHiddenForTextAlternativeCalculation()) |
| 1660 return false; | 1660 return false; |
| 1661 | 1661 |
| 1662 // Step 2B from: http://www.w3.org/TR/accname-aam-1.1 | 1662 // Step 2B from: http://www.w3.org/TR/accname-aam-1.1 |
| 1663 WillBeHeapVector<RawPtrWillBeMember<Element>> elements; | 1663 HeapVector<Member<Element>> elements; |
| 1664 ariaLabelledbyElementVector(elements); | 1664 ariaLabelledbyElementVector(elements); |
| 1665 if (elements.size() > 0) | 1665 if (elements.size() > 0) |
| 1666 return false; | 1666 return false; |
| 1667 | 1667 |
| 1668 // Step 2C from: http://www.w3.org/TR/accname-aam-1.1 | 1668 // Step 2C from: http://www.w3.org/TR/accname-aam-1.1 |
| 1669 const AtomicString& ariaLabel = getAttribute(aria_labelAttr); | 1669 const AtomicString& ariaLabel = getAttribute(aria_labelAttr); |
| 1670 if (!ariaLabel.isEmpty()) | 1670 if (!ariaLabel.isEmpty()) |
| 1671 return false; | 1671 return false; |
| 1672 | 1672 |
| 1673 // Based on http://rawgit.com/w3c/aria/master/html-aam/html-aam.html#accessi
ble-name-and-description-calculation | 1673 // Based on http://rawgit.com/w3c/aria/master/html-aam/html-aam.html#accessi
ble-name-and-description-calculation |
| (...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2759 return placeholder; | 2759 return placeholder; |
| 2760 } | 2760 } |
| 2761 | 2761 |
| 2762 DEFINE_TRACE(AXNodeObject) | 2762 DEFINE_TRACE(AXNodeObject) |
| 2763 { | 2763 { |
| 2764 visitor->trace(m_node); | 2764 visitor->trace(m_node); |
| 2765 AXObject::trace(visitor); | 2765 AXObject::trace(visitor); |
| 2766 } | 2766 } |
| 2767 | 2767 |
| 2768 } // namespace blink | 2768 } // namespace blink |
| OLD | NEW |