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 1515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1526 nameSources->append(NameSource(foundTextAlternative)); | 1526 nameSources->append(NameSource(foundTextAlternative)); |
1527 nameSources->last().type = nameFrom; | 1527 nameSources->last().type = nameFrom; |
1528 } | 1528 } |
1529 | 1529 |
1530 Node* node = this->node(); | 1530 Node* node = this->node(); |
1531 if (node && node->isTextNode()) | 1531 if (node && node->isTextNode()) |
1532 textAlternative = toText(node)->wholeText(); | 1532 textAlternative = toText(node)->wholeText(); |
1533 else if (isHTMLBRElement(node)) | 1533 else if (isHTMLBRElement(node)) |
1534 textAlternative = String("\n"); | 1534 textAlternative = String("\n"); |
1535 else | 1535 else |
1536 textAlternative = textFromDescendants(visited); | 1536 textAlternative = textFromDescendants(visited, false); |
1537 | 1537 |
1538 if (!textAlternative.isEmpty()) { | 1538 if (!textAlternative.isEmpty()) { |
1539 if (nameSources) { | 1539 if (nameSources) { |
1540 foundTextAlternative = true; | 1540 foundTextAlternative = true; |
1541 nameSources->last().text = textAlternative; | 1541 nameSources->last().text = textAlternative; |
1542 } else { | 1542 } else { |
1543 return textAlternative; | 1543 return textAlternative; |
1544 } | 1544 } |
1545 } | 1545 } |
1546 } | 1546 } |
(...skipping 25 matching lines...) Expand all Loading... |
1572 if (!nameSource.relatedObjects.isEmpty()) | 1572 if (!nameSource.relatedObjects.isEmpty()) |
1573 *relatedObjects = nameSource.relatedObjects; | 1573 *relatedObjects = nameSource.relatedObjects; |
1574 return nameSource.text; | 1574 return nameSource.text; |
1575 } | 1575 } |
1576 } | 1576 } |
1577 } | 1577 } |
1578 | 1578 |
1579 return String(); | 1579 return String(); |
1580 } | 1580 } |
1581 | 1581 |
1582 String AXNodeObject::textFromDescendants(AXObjectSet& visited) const | 1582 String AXNodeObject::textFromDescendants(AXObjectSet& visited, bool recursive) c
onst |
1583 { | 1583 { |
| 1584 if (!canHaveChildren() && recursive) |
| 1585 return String(); |
| 1586 |
1584 StringBuilder accumulatedText; | 1587 StringBuilder accumulatedText; |
1585 AXObject* previous = nullptr; | 1588 AXObject* previous = nullptr; |
1586 for (AXObject* child = rawFirstChild(); child; child = child->rawFirstSiblin
g()) { | 1589 |
| 1590 AXObjectVector children; |
| 1591 |
| 1592 HeapVector<Member<AXObject>> ownedChildren; |
| 1593 computeAriaOwnsChildren(ownedChildren); |
| 1594 for (AXObject* obj = rawFirstChild(); obj; obj = obj->rawNextSibling()) { |
| 1595 if (!axObjectCache().isAriaOwned(obj)) |
| 1596 children.append(obj); |
| 1597 } |
| 1598 for (const auto& ownedChild : ownedChildren) |
| 1599 children.append(ownedChild); |
| 1600 |
| 1601 for (AXObject* child : children) { |
1587 // Skip hidden children | 1602 // Skip hidden children |
1588 if (child->isInertOrAriaHidden()) | 1603 if (child->isInertOrAriaHidden()) |
1589 continue; | 1604 continue; |
1590 | 1605 |
1591 // If we're going between two layoutObjects that are in separate LayoutB
oxes, add | 1606 // If we're going between two layoutObjects that are in separate LayoutB
oxes, add |
1592 // whitespace if it wasn't there already. Intuitively if you have | 1607 // whitespace if it wasn't there already. Intuitively if you have |
1593 // <span>Hello</span><span>World</span>, those are part of the same Layo
utBox | 1608 // <span>Hello</span><span>World</span>, those are part of the same Layo
utBox |
1594 // so we should return "HelloWorld", but given <div>Hello</div><div>Worl
d</div> the | 1609 // so we should return "HelloWorld", but given <div>Hello</div><div>Worl
d</div> the |
1595 // strings are in separate boxes so we should return "Hello World". | 1610 // strings are in separate boxes so we should return "Hello World". |
1596 if (previous && accumulatedText.length() && !isHTMLSpace(accumulatedText
[accumulatedText.length() - 1])) { | 1611 if (previous && accumulatedText.length() && !isHTMLSpace(accumulatedText
[accumulatedText.length() - 1])) { |
1597 if (!isInSameNonInlineBlockFlow(child->layoutObject(), previous->lay
outObject())) | 1612 if (!isInSameNonInlineBlockFlow(child->layoutObject(), previous->lay
outObject())) |
1598 accumulatedText.append(' '); | 1613 accumulatedText.append(' '); |
1599 } | 1614 } |
1600 | 1615 |
1601 String result = recursiveTextAlternative(*child, false, visited); | 1616 String result; |
| 1617 if (child->isPresentational()) |
| 1618 result = child->textFromDescendants(visited, true); |
| 1619 else |
| 1620 result = recursiveTextAlternative(*child, false, visited); |
1602 accumulatedText.append(result); | 1621 accumulatedText.append(result); |
1603 previous = child; | 1622 previous = child; |
1604 } | 1623 } |
1605 | 1624 |
1606 return accumulatedText.toString(); | 1625 return accumulatedText.toString(); |
1607 } | 1626 } |
1608 | 1627 |
1609 bool AXNodeObject::nameFromLabelElement() const | 1628 bool AXNodeObject::nameFromLabelElement() const |
1610 { | 1629 { |
1611 // This unfortunately duplicates a bit of logic from textAlternative and nat
iveTextAlternative, | 1630 // This unfortunately duplicates a bit of logic from textAlternative and nat
iveTextAlternative, |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1728 return 0; | 1747 return 0; |
1729 | 1748 |
1730 Node* firstChild = node()->firstChild(); | 1749 Node* firstChild = node()->firstChild(); |
1731 | 1750 |
1732 if (!firstChild) | 1751 if (!firstChild) |
1733 return 0; | 1752 return 0; |
1734 | 1753 |
1735 return axObjectCache().getOrCreate(firstChild); | 1754 return axObjectCache().getOrCreate(firstChild); |
1736 } | 1755 } |
1737 | 1756 |
1738 AXObject* AXNodeObject::rawFirstSibling() const | 1757 AXObject* AXNodeObject::rawNextSibling() const |
1739 { | 1758 { |
1740 if (!node()) | 1759 if (!node()) |
1741 return 0; | 1760 return 0; |
1742 | 1761 |
1743 Node* nextSibling = node()->nextSibling(); | 1762 Node* nextSibling = node()->nextSibling(); |
1744 if (!nextSibling) | 1763 if (!nextSibling) |
1745 return 0; | 1764 return 0; |
1746 | 1765 |
1747 return axObjectCache().getOrCreate(nextSibling); | 1766 return axObjectCache().getOrCreate(nextSibling); |
1748 } | 1767 } |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2064 void AXNodeObject::updateAccessibilityRole() | 2083 void AXNodeObject::updateAccessibilityRole() |
2065 { | 2084 { |
2066 bool ignoredStatus = accessibilityIsIgnored(); | 2085 bool ignoredStatus = accessibilityIsIgnored(); |
2067 m_role = determineAccessibilityRole(); | 2086 m_role = determineAccessibilityRole(); |
2068 | 2087 |
2069 // The AX hierarchy only needs to be updated if the ignored status of an ele
ment has changed. | 2088 // The AX hierarchy only needs to be updated if the ignored status of an ele
ment has changed. |
2070 if (ignoredStatus != accessibilityIsIgnored()) | 2089 if (ignoredStatus != accessibilityIsIgnored()) |
2071 childrenChanged(); | 2090 childrenChanged(); |
2072 } | 2091 } |
2073 | 2092 |
2074 void AXNodeObject::computeAriaOwnsChildren(HeapVector<Member<AXObject>>& ownedCh
ildren) | 2093 void AXNodeObject::computeAriaOwnsChildren(HeapVector<Member<AXObject>>& ownedCh
ildren) const |
2075 { | 2094 { |
2076 if (!hasAttribute(aria_ownsAttr)) | 2095 if (!hasAttribute(aria_ownsAttr)) |
2077 return; | 2096 return; |
2078 | 2097 |
2079 Vector<String> idVector; | 2098 Vector<String> idVector; |
2080 tokenVectorFromAttribute(idVector, aria_ownsAttr); | 2099 tokenVectorFromAttribute(idVector, aria_ownsAttr); |
2081 | 2100 |
2082 axObjectCache().updateAriaOwns(this, idVector, ownedChildren); | 2101 axObjectCache().updateAriaOwns(this, idVector, ownedChildren); |
2083 } | 2102 } |
2084 | 2103 |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2589 | 2608 |
2590 // summary, 5.6.2 from: http://rawgit.com/w3c/aria/master/html-aam/html-aam.
html | 2609 // summary, 5.6.2 from: http://rawgit.com/w3c/aria/master/html-aam/html-aam.
html |
2591 if (nameFrom != AXNameFromContents && isHTMLSummaryElement(node())) { | 2610 if (nameFrom != AXNameFromContents && isHTMLSummaryElement(node())) { |
2592 descriptionFrom = AXDescriptionFromContents; | 2611 descriptionFrom = AXDescriptionFromContents; |
2593 if (descriptionSources) { | 2612 if (descriptionSources) { |
2594 descriptionSources->append(DescriptionSource(foundDescription)); | 2613 descriptionSources->append(DescriptionSource(foundDescription)); |
2595 descriptionSources->last().type = descriptionFrom; | 2614 descriptionSources->last().type = descriptionFrom; |
2596 } | 2615 } |
2597 | 2616 |
2598 AXObjectSet visited; | 2617 AXObjectSet visited; |
2599 description = textFromDescendants(visited); | 2618 description = textFromDescendants(visited, false); |
2600 | 2619 |
2601 if (!description.isEmpty()) { | 2620 if (!description.isEmpty()) { |
2602 if (descriptionSources) { | 2621 if (descriptionSources) { |
2603 foundDescription = true; | 2622 foundDescription = true; |
2604 descriptionSources->last().text = description; | 2623 descriptionSources->last().text = description; |
2605 } else { | 2624 } else { |
2606 return description; | 2625 return description; |
2607 } | 2626 } |
2608 } | 2627 } |
2609 } | 2628 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2684 return placeholder; | 2703 return placeholder; |
2685 } | 2704 } |
2686 | 2705 |
2687 DEFINE_TRACE(AXNodeObject) | 2706 DEFINE_TRACE(AXNodeObject) |
2688 { | 2707 { |
2689 visitor->trace(m_node); | 2708 visitor->trace(m_node); |
2690 AXObject::trace(visitor); | 2709 AXObject::trace(visitor); |
2691 } | 2710 } |
2692 | 2711 |
2693 } // namespace blin | 2712 } // namespace blin |
OLD | NEW |