| 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 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1553 | 1553 |
| 1554 AXObject::updateChildrenIfNecessary(); | 1554 AXObject::updateChildrenIfNecessary(); |
| 1555 } | 1555 } |
| 1556 | 1556 |
| 1557 void AXLayoutObject::clearChildren() | 1557 void AXLayoutObject::clearChildren() |
| 1558 { | 1558 { |
| 1559 AXObject::clearChildren(); | 1559 AXObject::clearChildren(); |
| 1560 m_childrenDirty = false; | 1560 m_childrenDirty = false; |
| 1561 } | 1561 } |
| 1562 | 1562 |
| 1563 AXObject* AXLayoutObject::observableObject() const | |
| 1564 { | |
| 1565 // Find the object going up the parent chain that is used in accessibility t
o monitor certain notifications. | |
| 1566 for (LayoutObject* layoutObject = m_layoutObject; layoutObject && layoutObje
ct->node(); layoutObject = layoutObject->parent()) { | |
| 1567 if (layoutObjectIsObservable(layoutObject)) | |
| 1568 return axObjectCache()->getOrCreate(layoutObject); | |
| 1569 } | |
| 1570 | |
| 1571 return 0; | |
| 1572 } | |
| 1573 | |
| 1574 // | 1563 // |
| 1575 // Properties of the object's owning document or page. | 1564 // Properties of the object's owning document or page. |
| 1576 // | 1565 // |
| 1577 | 1566 |
| 1578 double AXLayoutObject::estimatedLoadingProgress() const | 1567 double AXLayoutObject::estimatedLoadingProgress() const |
| 1579 { | 1568 { |
| 1580 if (!m_layoutObject) | 1569 if (!m_layoutObject) |
| 1581 return 0; | 1570 return 0; |
| 1582 | 1571 |
| 1583 if (isLoaded()) | 1572 if (isLoaded()) |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1734 { | 1723 { |
| 1735 Element* element = toElement(layoutObject()->node()); | 1724 Element* element = toElement(layoutObject()->node()); |
| 1736 if (!element) | 1725 if (!element) |
| 1737 return; | 1726 return; |
| 1738 Document& doc = layoutObject()->document(); | 1727 Document& doc = layoutObject()->document(); |
| 1739 if (!doc.frame()->selection().isFocusedAndActive() || doc.focusedElement() !
= element) | 1728 if (!doc.frame()->selection().isFocusedAndActive() || doc.focusedElement() !
= element) |
| 1740 return; | 1729 return; |
| 1741 AXLayoutObject* activedescendant = toAXLayoutObject(activeDescendant()); | 1730 AXLayoutObject* activedescendant = toAXLayoutObject(activeDescendant()); |
| 1742 | 1731 |
| 1743 if (activedescendant && shouldNotifyActiveDescendant()) | 1732 if (activedescendant && shouldNotifyActiveDescendant()) |
| 1744 toAXObjectCacheImpl(doc.axObjectCache())->postNotification(m_layoutObjec
t, AXObjectCacheImpl::AXActiveDescendantChanged, true); | 1733 toAXObjectCacheImpl(doc.axObjectCache())->postNotification(m_layoutObjec
t, AXObjectCacheImpl::AXActiveDescendantChanged); |
| 1745 } | 1734 } |
| 1746 | 1735 |
| 1747 void AXLayoutObject::handleAriaExpandedChanged() | 1736 void AXLayoutObject::handleAriaExpandedChanged() |
| 1748 { | 1737 { |
| 1749 // Find if a parent of this object should handle aria-expanded changes. | 1738 // Find if a parent of this object should handle aria-expanded changes. |
| 1750 AXObject* containerParent = this->parentObject(); | 1739 AXObject* containerParent = this->parentObject(); |
| 1751 while (containerParent) { | 1740 while (containerParent) { |
| 1752 bool foundParent = false; | 1741 bool foundParent = false; |
| 1753 | 1742 |
| 1754 switch (containerParent->roleValue()) { | 1743 switch (containerParent->roleValue()) { |
| 1755 case TreeRole: | 1744 case TreeRole: |
| 1756 case TreeGridRole: | 1745 case TreeGridRole: |
| 1757 case GridRole: | 1746 case GridRole: |
| 1758 case TableRole: | 1747 case TableRole: |
| 1759 foundParent = true; | 1748 foundParent = true; |
| 1760 break; | 1749 break; |
| 1761 default: | 1750 default: |
| 1762 break; | 1751 break; |
| 1763 } | 1752 } |
| 1764 | 1753 |
| 1765 if (foundParent) | 1754 if (foundParent) |
| 1766 break; | 1755 break; |
| 1767 | 1756 |
| 1768 containerParent = containerParent->parentObject(); | 1757 containerParent = containerParent->parentObject(); |
| 1769 } | 1758 } |
| 1770 | 1759 |
| 1771 // Post that the row count changed. | 1760 // Post that the row count changed. |
| 1772 if (containerParent) | 1761 if (containerParent) |
| 1773 axObjectCache()->postNotification(containerParent, AXObjectCacheImpl::AX
RowCountChanged, true); | 1762 axObjectCache()->postNotification(containerParent, AXObjectCacheImpl::AX
RowCountChanged); |
| 1774 | 1763 |
| 1775 // Post that the specific row either collapsed or expanded. | 1764 // Post that the specific row either collapsed or expanded. |
| 1776 AccessibilityExpanded expanded = isExpanded(); | 1765 AccessibilityExpanded expanded = isExpanded(); |
| 1777 if (!expanded) | 1766 if (!expanded) |
| 1778 return; | 1767 return; |
| 1779 | 1768 |
| 1780 if (roleValue() == RowRole || roleValue() == TreeItemRole) { | 1769 if (roleValue() == RowRole || roleValue() == TreeItemRole) { |
| 1781 AXObjectCacheImpl::AXNotification notification = AXObjectCacheImpl::AXRo
wExpanded; | 1770 AXObjectCacheImpl::AXNotification notification = AXObjectCacheImpl::AXRo
wExpanded; |
| 1782 if (expanded == ExpandedCollapsed) | 1771 if (expanded == ExpandedCollapsed) |
| 1783 notification = AXObjectCacheImpl::AXRowCollapsed; | 1772 notification = AXObjectCacheImpl::AXRowCollapsed; |
| 1784 | 1773 |
| 1785 axObjectCache()->postNotification(this, notification, true); | 1774 axObjectCache()->postNotification(this, notification); |
| 1786 } | 1775 } |
| 1787 } | 1776 } |
| 1788 | 1777 |
| 1789 void AXLayoutObject::textChanged() | 1778 void AXLayoutObject::textChanged() |
| 1790 { | 1779 { |
| 1791 if (!m_layoutObject) | 1780 if (!m_layoutObject) |
| 1792 return; | 1781 return; |
| 1793 | 1782 |
| 1794 Settings* settings = document()->settings(); | 1783 Settings* settings = document()->settings(); |
| 1795 if (settings && settings->inlineTextBoxAccessibilityEnabled() && roleValue()
== StaticTextRole) | 1784 if (settings && settings->inlineTextBoxAccessibilityEnabled() && roleValue()
== StaticTextRole) |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2025 return 0; | 2014 return 0; |
| 2026 | 2015 |
| 2027 for (const auto& child : parent->children()) { | 2016 for (const auto& child : parent->children()) { |
| 2028 if (child->elementRect().contains(point)) | 2017 if (child->elementRect().contains(point)) |
| 2029 return child.get(); | 2018 return child.get(); |
| 2030 } | 2019 } |
| 2031 | 2020 |
| 2032 return 0; | 2021 return 0; |
| 2033 } | 2022 } |
| 2034 | 2023 |
| 2035 bool AXLayoutObject::layoutObjectIsObservable(LayoutObject* layoutObject) const | |
| 2036 { | |
| 2037 // AX clients will listen for AXValueChange on a text control. | |
| 2038 if (layoutObject->isTextControl()) | |
| 2039 return true; | |
| 2040 | |
| 2041 // AX clients will listen for AXSelectedChildrenChanged on listboxes. | |
| 2042 Node* node = layoutObject->node(); | |
| 2043 if (nodeHasRole(node, "listbox") || (layoutObject->isBoxModelObject() && toL
ayoutBoxModelObject(layoutObject)->isListBox())) | |
| 2044 return true; | |
| 2045 | |
| 2046 // Textboxes should send out notifications. | |
| 2047 if (nodeHasRole(node, "textbox")) | |
| 2048 return true; | |
| 2049 | |
| 2050 return false; | |
| 2051 } | |
| 2052 | |
| 2053 LayoutObject* AXLayoutObject::layoutParentObject() const | 2024 LayoutObject* AXLayoutObject::layoutParentObject() const |
| 2054 { | 2025 { |
| 2055 if (!m_layoutObject) | 2026 if (!m_layoutObject) |
| 2056 return 0; | 2027 return 0; |
| 2057 | 2028 |
| 2058 LayoutObject* startOfConts = m_layoutObject->isLayoutBlock() ? startOfContin
uations(m_layoutObject) : 0; | 2029 LayoutObject* startOfConts = m_layoutObject->isLayoutBlock() ? startOfContin
uations(m_layoutObject) : 0; |
| 2059 if (startOfConts) { | 2030 if (startOfConts) { |
| 2060 // Case 1: node is a block and is an inline's continuation. Parent | 2031 // Case 1: node is a block and is an inline's continuation. Parent |
| 2061 // is the start of the continuation chain. | 2032 // is the start of the continuation chain. |
| 2062 return startOfConts; | 2033 return startOfConts; |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2396 if (label && label->layoutObject()) { | 2367 if (label && label->layoutObject()) { |
| 2397 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR
ect(); | 2368 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR
ect(); |
| 2398 result.unite(labelRect); | 2369 result.unite(labelRect); |
| 2399 } | 2370 } |
| 2400 } | 2371 } |
| 2401 | 2372 |
| 2402 return result; | 2373 return result; |
| 2403 } | 2374 } |
| 2404 | 2375 |
| 2405 } // namespace blink | 2376 } // namespace blink |
| OLD | NEW |