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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 TreeScope& scope = node->treeScope(); | 332 TreeScope& scope = node->treeScope(); |
333 | 333 |
334 String idList = getAttribute(attribute).string(); | 334 String idList = getAttribute(attribute).string(); |
335 if (idList.isEmpty()) | 335 if (idList.isEmpty()) |
336 return; | 336 return; |
337 | 337 |
338 idList.replace('\n', ' '); | 338 idList.replace('\n', ' '); |
339 Vector<String> idVector; | 339 Vector<String> idVector; |
340 idList.split(' ', idVector); | 340 idList.split(' ', idVector); |
341 | 341 |
342 unsigned size = idVector.size(); | 342 for (const auto& idName : idVector) { |
343 for (unsigned i = 0; i < size; ++i) { | 343 if (Element* idElement = scope.getElementById(AtomicString(idName))) |
344 AtomicString idName(idVector[i]); | |
345 Element* idElement = scope.getElementById(idName); | |
346 if (idElement) | |
347 elements.append(idElement); | 344 elements.append(idElement); |
348 } | 345 } |
349 } | 346 } |
350 | 347 |
351 // If you call node->hasEditableStyle() since that will return true if an ancest
or is editable. | 348 // If you call node->hasEditableStyle() since that will return true if an ancest
or is editable. |
352 // This only returns true if this is the element that actually has the contentEd
itable attribute set. | 349 // This only returns true if this is the element that actually has the contentEd
itable attribute set. |
353 bool AXNodeObject::hasContentEditableAttributeSet() const | 350 bool AXNodeObject::hasContentEditableAttributeSet() const |
354 { | 351 { |
355 if (!hasAttribute(contenteditableAttr)) | 352 if (!hasAttribute(contenteditableAttr)) |
356 return false; | 353 return false; |
(...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1626 | 1623 |
1627 m_haveChildren = true; | 1624 m_haveChildren = true; |
1628 | 1625 |
1629 // The only time we add children from the DOM tree to a node with a layoutOb
ject is when it's a canvas. | 1626 // The only time we add children from the DOM tree to a node with a layoutOb
ject is when it's a canvas. |
1630 if (layoutObject() && !isHTMLCanvasElement(*m_node)) | 1627 if (layoutObject() && !isHTMLCanvasElement(*m_node)) |
1631 return; | 1628 return; |
1632 | 1629 |
1633 for (Node& child : NodeTraversal::childrenOf(*m_node)) | 1630 for (Node& child : NodeTraversal::childrenOf(*m_node)) |
1634 addChild(axObjectCache()->getOrCreate(&child)); | 1631 addChild(axObjectCache()->getOrCreate(&child)); |
1635 | 1632 |
1636 for (unsigned i = 0; i < m_children.size(); ++i) | 1633 for (const auto& child : m_children) |
1637 m_children[i].get()->setParent(this); | 1634 child->setParent(this); |
1638 } | 1635 } |
1639 | 1636 |
1640 void AXNodeObject::addChild(AXObject* child) | 1637 void AXNodeObject::addChild(AXObject* child) |
1641 { | 1638 { |
1642 insertChild(child, m_children.size()); | 1639 insertChild(child, m_children.size()); |
1643 } | 1640 } |
1644 | 1641 |
1645 void AXNodeObject::insertChild(AXObject* child, unsigned index) | 1642 void AXNodeObject::insertChild(AXObject* child, unsigned index) |
1646 { | 1643 { |
1647 if (!child) | 1644 if (!child) |
1648 return; | 1645 return; |
1649 | 1646 |
1650 // If the parent is asking for this child's children, then either it's the f
irst time (and clearing is a no-op), | 1647 // If the parent is asking for this child's children, then either it's the f
irst time (and clearing is a no-op), |
1651 // or its visibility has changed. In the latter case, this child may have a
stale child cached. | 1648 // or its visibility has changed. In the latter case, this child may have a
stale child cached. |
1652 // This can prevent aria-hidden changes from working correctly. Hence, whene
ver a parent is getting children, ensure data is not stale. | 1649 // This can prevent aria-hidden changes from working correctly. Hence, whene
ver a parent is getting children, ensure data is not stale. |
1653 child->clearChildren(); | 1650 child->clearChildren(); |
1654 | 1651 |
1655 if (child->accessibilityIsIgnored()) { | 1652 if (child->accessibilityIsIgnored()) { |
1656 const AccessibilityChildrenVector& children = child->children(); | 1653 const auto& children = child->children(); |
1657 size_t length = children.size(); | 1654 size_t length = children.size(); |
1658 for (size_t i = 0; i < length; ++i) | 1655 for (size_t i = 0; i < length; ++i) |
1659 m_children.insert(index + i, children[i]); | 1656 m_children.insert(index + i, children[i]); |
1660 } else { | 1657 } else { |
1661 ASSERT(child->parentObject() == this); | 1658 ASSERT(child->parentObject() == this); |
1662 m_children.insert(index, child); | 1659 m_children.insert(index, child); |
1663 } | 1660 } |
1664 } | 1661 } |
1665 | 1662 |
1666 bool AXNodeObject::canHaveChildren() const | 1663 bool AXNodeObject::canHaveChildren() const |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1972 } | 1969 } |
1973 } | 1970 } |
1974 | 1971 |
1975 void AXNodeObject::ariaLabeledByText(Vector<AccessibilityText>& textOrder) const | 1972 void AXNodeObject::ariaLabeledByText(Vector<AccessibilityText>& textOrder) const |
1976 { | 1973 { |
1977 String ariaLabeledBy = ariaLabeledByAttribute(); | 1974 String ariaLabeledBy = ariaLabeledByAttribute(); |
1978 if (!ariaLabeledBy.isEmpty()) { | 1975 if (!ariaLabeledBy.isEmpty()) { |
1979 WillBeHeapVector<RawPtrWillBeMember<Element>> elements; | 1976 WillBeHeapVector<RawPtrWillBeMember<Element>> elements; |
1980 ariaLabeledByElements(elements); | 1977 ariaLabeledByElements(elements); |
1981 | 1978 |
1982 unsigned length = elements.size(); | 1979 for (const auto& element : elements) { |
1983 for (unsigned k = 0; k < length; k++) { | 1980 RefPtr<AXObject> axElement = axObjectCache()->getOrCreate(element); |
1984 RefPtr<AXObject> axElement = axObjectCache()->getOrCreate(elements[k
]); | |
1985 textOrder.append(AccessibilityText(ariaLabeledBy, AlternativeText, a
xElement)); | 1981 textOrder.append(AccessibilityText(ariaLabeledBy, AlternativeText, a
xElement)); |
1986 } | 1982 } |
1987 } | 1983 } |
1988 } | 1984 } |
1989 | 1985 |
1990 void AXNodeObject::changeValueByPercent(float percentChange) | 1986 void AXNodeObject::changeValueByPercent(float percentChange) |
1991 { | 1987 { |
1992 float range = maxValueForRange() - minValueForRange(); | 1988 float range = maxValueForRange() - minValueForRange(); |
1993 float value = valueForRange(); | 1989 float value = valueForRange(); |
1994 | 1990 |
1995 value += range * (percentChange / 100); | 1991 value += range * (percentChange / 100); |
1996 setValue(String::number(value)); | 1992 setValue(String::number(value)); |
1997 | 1993 |
1998 axObjectCache()->postNotification(node(), AXObjectCacheImpl::AXValueChanged,
true); | 1994 axObjectCache()->postNotification(node(), AXObjectCacheImpl::AXValueChanged,
true); |
1999 } | 1995 } |
2000 | 1996 |
2001 } // namespace blink | 1997 } // namespace blink |
OLD | NEW |