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 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1013 | 1013 |
1014 return 0; | 1014 return 0; |
1015 } | 1015 } |
1016 | 1016 |
1017 void AXLayoutObject::accessibilityChildrenFromAttribute(QualifiedName attr, Acce
ssibilityChildrenVector& children) const | 1017 void AXLayoutObject::accessibilityChildrenFromAttribute(QualifiedName attr, Acce
ssibilityChildrenVector& children) const |
1018 { | 1018 { |
1019 WillBeHeapVector<RawPtrWillBeMember<Element>> elements; | 1019 WillBeHeapVector<RawPtrWillBeMember<Element>> elements; |
1020 elementsFromAttribute(elements, attr); | 1020 elementsFromAttribute(elements, attr); |
1021 | 1021 |
1022 AXObjectCacheImpl* cache = axObjectCache(); | 1022 AXObjectCacheImpl* cache = axObjectCache(); |
1023 unsigned count = elements.size(); | 1023 for (const auto& element : elements) { |
1024 for (unsigned k = 0; k < count; ++k) { | 1024 if (AXObject* child = cache->getOrCreate(element)) |
1025 Element* element = elements[k]; | |
1026 AXObject* child = cache->getOrCreate(element); | |
1027 if (child) | |
1028 children.append(child); | 1025 children.append(child); |
1029 } | 1026 } |
1030 } | 1027 } |
1031 | 1028 |
1032 void AXLayoutObject::ariaFlowToElements(AccessibilityChildrenVector& flowTo) con
st | 1029 void AXLayoutObject::ariaFlowToElements(AccessibilityChildrenVector& flowTo) con
st |
1033 { | 1030 { |
1034 accessibilityChildrenFromAttribute(aria_flowtoAttr, flowTo); | 1031 accessibilityChildrenFromAttribute(aria_flowtoAttr, flowTo); |
1035 } | 1032 } |
1036 | 1033 |
1037 void AXLayoutObject::ariaControlsElements(AccessibilityChildrenVector& controls)
const | 1034 void AXLayoutObject::ariaControlsElements(AccessibilityChildrenVector& controls)
const |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1524 | 1521 |
1525 addHiddenChildren(); | 1522 addHiddenChildren(); |
1526 addAttachmentChildren(); | 1523 addAttachmentChildren(); |
1527 addPopupChildren(); | 1524 addPopupChildren(); |
1528 addImageMapChildren(); | 1525 addImageMapChildren(); |
1529 addTextFieldChildren(); | 1526 addTextFieldChildren(); |
1530 addCanvasChildren(); | 1527 addCanvasChildren(); |
1531 addRemoteSVGChildren(); | 1528 addRemoteSVGChildren(); |
1532 addInlineTextBoxChildren(false); | 1529 addInlineTextBoxChildren(false); |
1533 | 1530 |
1534 for (unsigned i = 0; i < m_children.size(); ++i) { | 1531 for (const auto& child : m_children) { |
1535 if (!m_children[i].get()->cachedParentObject()) | 1532 if (!child->cachedParentObject()) |
1536 m_children[i].get()->setParent(this); | 1533 child->setParent(this); |
1537 } | 1534 } |
1538 } | 1535 } |
1539 | 1536 |
1540 bool AXLayoutObject::canHaveChildren() const | 1537 bool AXLayoutObject::canHaveChildren() const |
1541 { | 1538 { |
1542 if (!m_layoutObject) | 1539 if (!m_layoutObject) |
1543 return false; | 1540 return false; |
1544 | 1541 |
1545 return AXNodeObject::canHaveChildren(); | 1542 return AXNodeObject::canHaveChildren(); |
1546 } | 1543 } |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1933 if (role != TreeItemRole && role != StaticTextRole) | 1930 if (role != TreeItemRole && role != StaticTextRole) |
1934 return false; | 1931 return false; |
1935 } | 1932 } |
1936 return true; | 1933 return true; |
1937 } | 1934 } |
1938 | 1935 |
1939 void AXLayoutObject::ariaListboxSelectedChildren(AccessibilityChildrenVector& re
sult) | 1936 void AXLayoutObject::ariaListboxSelectedChildren(AccessibilityChildrenVector& re
sult) |
1940 { | 1937 { |
1941 bool isMulti = isMultiSelectable(); | 1938 bool isMulti = isMultiSelectable(); |
1942 | 1939 |
1943 const AccessibilityChildrenVector& childObjects = children(); | 1940 for (const auto& child : children()) { |
1944 unsigned childrenSize = childObjects.size(); | |
1945 for (unsigned k = 0; k < childrenSize; ++k) { | |
1946 // Every child should have aria-role option, and if so, check for select
ed attribute/state. | 1941 // Every child should have aria-role option, and if so, check for select
ed attribute/state. |
1947 AXObject* child = childObjects[k].get(); | |
1948 if (child->isSelected() && child->ariaRoleAttribute() == ListBoxOptionRo
le) { | 1942 if (child->isSelected() && child->ariaRoleAttribute() == ListBoxOptionRo
le) { |
1949 result.append(child); | 1943 result.append(child); |
1950 if (!isMulti) | 1944 if (!isMulti) |
1951 return; | 1945 return; |
1952 } | 1946 } |
1953 } | 1947 } |
1954 } | 1948 } |
1955 | 1949 |
1956 AXObject::PlainTextRange AXLayoutObject::ariaSelectedTextRange() const | 1950 AXObject::PlainTextRange AXLayoutObject::ariaSelectedTextRange() const |
1957 { | 1951 { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1994 // The ARIA spec says a tab item can also be selected if it is aria-labeled
by a tabpanel | 1988 // The ARIA spec says a tab item can also be selected if it is aria-labeled
by a tabpanel |
1995 // that has keyboard focus inside of it, or if a tabpanel in its aria-contro
ls list has KB | 1989 // that has keyboard focus inside of it, or if a tabpanel in its aria-contro
ls list has KB |
1996 // focus inside of it. | 1990 // focus inside of it. |
1997 AXObject* focusedElement = focusedUIElement(); | 1991 AXObject* focusedElement = focusedUIElement(); |
1998 if (!focusedElement) | 1992 if (!focusedElement) |
1999 return false; | 1993 return false; |
2000 | 1994 |
2001 WillBeHeapVector<RawPtrWillBeMember<Element>> elements; | 1995 WillBeHeapVector<RawPtrWillBeMember<Element>> elements; |
2002 elementsFromAttribute(elements, aria_controlsAttr); | 1996 elementsFromAttribute(elements, aria_controlsAttr); |
2003 | 1997 |
2004 unsigned count = elements.size(); | 1998 for (const auto& element : elements) { |
2005 for (unsigned k = 0; k < count; ++k) { | |
2006 Element* element = elements[k]; | |
2007 AXObject* tabPanel = axObjectCache()->getOrCreate(element); | 1999 AXObject* tabPanel = axObjectCache()->getOrCreate(element); |
2008 | 2000 |
2009 // A tab item should only control tab panels. | 2001 // A tab item should only control tab panels. |
2010 if (!tabPanel || tabPanel->roleValue() != TabPanelRole) | 2002 if (!tabPanel || tabPanel->roleValue() != TabPanelRole) |
2011 continue; | 2003 continue; |
2012 | 2004 |
2013 AXObject* checkFocusElement = focusedElement; | 2005 AXObject* checkFocusElement = focusedElement; |
2014 // Check if the focused element is a descendant of the element controlle
d by the tab item. | 2006 // Check if the focused element is a descendant of the element controlle
d by the tab item. |
2015 while (checkFocusElement) { | 2007 while (checkFocusElement) { |
2016 if (tabPanel == checkFocusElement) | 2008 if (tabPanel == checkFocusElement) |
2017 return true; | 2009 return true; |
2018 checkFocusElement = checkFocusElement->parentObject(); | 2010 checkFocusElement = checkFocusElement->parentObject(); |
2019 } | 2011 } |
2020 } | 2012 } |
2021 | 2013 |
2022 return false; | 2014 return false; |
2023 } | 2015 } |
2024 | 2016 |
2025 AXObject* AXLayoutObject::accessibilityImageMapHitTest(HTMLAreaElement* area, co
nst IntPoint& point) const | 2017 AXObject* AXLayoutObject::accessibilityImageMapHitTest(HTMLAreaElement* area, co
nst IntPoint& point) const |
2026 { | 2018 { |
2027 if (!area) | 2019 if (!area) |
2028 return 0; | 2020 return 0; |
2029 | 2021 |
2030 AXObject* parent = axObjectCache()->getOrCreate(area->imageElement()); | 2022 AXObject* parent = axObjectCache()->getOrCreate(area->imageElement()); |
2031 if (!parent) | 2023 if (!parent) |
2032 return 0; | 2024 return 0; |
2033 | 2025 |
2034 const AccessibilityChildrenVector& children = parent->children(); | 2026 for (const auto& child : parent->children()) { |
2035 unsigned count = children.size(); | 2027 if (child->elementRect().contains(point)) |
2036 for (unsigned k = 0; k < count; ++k) { | 2028 return child.get(); |
2037 if (children[k]->elementRect().contains(point)) | |
2038 return children[k].get(); | |
2039 } | 2029 } |
2040 | 2030 |
2041 return 0; | 2031 return 0; |
2042 } | 2032 } |
2043 | 2033 |
2044 bool AXLayoutObject::layoutObjectIsObservable(LayoutObject* layoutObject) const | 2034 bool AXLayoutObject::layoutObjectIsObservable(LayoutObject* layoutObject) const |
2045 { | 2035 { |
2046 // AX clients will listen for AXValueChange on a text control. | 2036 // AX clients will listen for AXValueChange on a text control. |
2047 if (layoutObject->isTextControl()) | 2037 if (layoutObject->isTextControl()) |
2048 return true; | 2038 return true; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2173 return; | 2163 return; |
2174 | 2164 |
2175 // Iterate through all of the children, including those that may have alread
y been added, and | 2165 // Iterate through all of the children, including those that may have alread
y been added, and |
2176 // try to insert hidden nodes in the correct place in the DOM order. | 2166 // try to insert hidden nodes in the correct place in the DOM order. |
2177 unsigned insertionIndex = 0; | 2167 unsigned insertionIndex = 0; |
2178 for (Node& child : NodeTraversal::childrenOf(*node)) { | 2168 for (Node& child : NodeTraversal::childrenOf(*node)) { |
2179 if (child.layoutObject()) { | 2169 if (child.layoutObject()) { |
2180 // Find out where the last layout sibling is located within m_childr
en. | 2170 // Find out where the last layout sibling is located within m_childr
en. |
2181 if (AXObject* childObject = axObjectCache()->get(child.layoutObject(
))) { | 2171 if (AXObject* childObject = axObjectCache()->get(child.layoutObject(
))) { |
2182 if (childObject->accessibilityIsIgnored()) { | 2172 if (childObject->accessibilityIsIgnored()) { |
2183 const AccessibilityChildrenVector& children = childObject->c
hildren(); | 2173 const auto& children = childObject->children(); |
2184 childObject = children.size() ? children.last().get() : 0; | 2174 childObject = children.size() ? children.last().get() : 0; |
2185 } | 2175 } |
2186 if (childObject) | 2176 if (childObject) |
2187 insertionIndex = m_children.find(childObject) + 1; | 2177 insertionIndex = m_children.find(childObject) + 1; |
2188 continue; | 2178 continue; |
2189 } | 2179 } |
2190 } | 2180 } |
2191 | 2181 |
2192 if (!isNodeAriaVisible(&child)) | 2182 if (!isNodeAriaVisible(&child)) |
2193 continue; | 2183 continue; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2280 | 2270 |
2281 void AXLayoutObject::addRemoteSVGChildren() | 2271 void AXLayoutObject::addRemoteSVGChildren() |
2282 { | 2272 { |
2283 AXSVGRoot* root = remoteSVGRootElement(); | 2273 AXSVGRoot* root = remoteSVGRootElement(); |
2284 if (!root) | 2274 if (!root) |
2285 return; | 2275 return; |
2286 | 2276 |
2287 root->setParent(this); | 2277 root->setParent(this); |
2288 | 2278 |
2289 if (root->accessibilityIsIgnored()) { | 2279 if (root->accessibilityIsIgnored()) { |
2290 const AccessibilityChildrenVector& children = root->children(); | 2280 for (const auto& child : root->children()) |
2291 unsigned length = children.size(); | 2281 m_children.append(child); |
2292 for (unsigned i = 0; i < length; ++i) | |
2293 m_children.append(children[i]); | |
2294 } else { | 2282 } else { |
2295 m_children.append(root); | 2283 m_children.append(root); |
2296 } | 2284 } |
2297 } | 2285 } |
2298 | 2286 |
2299 void AXLayoutObject::ariaSelectedRows(AccessibilityChildrenVector& result) | 2287 void AXLayoutObject::ariaSelectedRows(AccessibilityChildrenVector& result) |
2300 { | 2288 { |
2301 // Get all the rows. | 2289 // Get all the rows. |
2302 AccessibilityChildrenVector allRows; | 2290 AccessibilityChildrenVector allRows; |
2303 if (isTree()) | 2291 if (isTree()) |
2304 ariaTreeRows(allRows); | 2292 ariaTreeRows(allRows); |
2305 else if (isAXTable() && toAXTable(this)->supportsSelectedRows()) | 2293 else if (isAXTable() && toAXTable(this)->supportsSelectedRows()) |
2306 allRows = toAXTable(this)->rows(); | 2294 allRows = toAXTable(this)->rows(); |
2307 | 2295 |
2308 // Determine which rows are selected. | 2296 // Determine which rows are selected. |
2309 bool isMulti = isMultiSelectable(); | 2297 bool isMulti = isMultiSelectable(); |
2310 | 2298 |
2311 // Prefer active descendant over aria-selected. | 2299 // Prefer active descendant over aria-selected. |
2312 AXObject* activeDesc = activeDescendant(); | 2300 AXObject* activeDesc = activeDescendant(); |
2313 if (activeDesc && (activeDesc->isTreeItem() || activeDesc->isTableRow())) { | 2301 if (activeDesc && (activeDesc->isTreeItem() || activeDesc->isTableRow())) { |
2314 result.append(activeDesc); | 2302 result.append(activeDesc); |
2315 if (!isMulti) | 2303 if (!isMulti) |
2316 return; | 2304 return; |
2317 } | 2305 } |
2318 | 2306 |
2319 unsigned count = allRows.size(); | 2307 for (const auto& row : allRows) { |
2320 for (unsigned k = 0; k < count; ++k) { | 2308 if (row->isSelected()) { |
2321 if (allRows[k]->isSelected()) { | 2309 result.append(row); |
2322 result.append(allRows[k]); | |
2323 if (!isMulti) | 2310 if (!isMulti) |
2324 break; | 2311 break; |
2325 } | 2312 } |
2326 } | 2313 } |
2327 } | 2314 } |
2328 | 2315 |
2329 bool AXLayoutObject::elementAttributeValue(const QualifiedName& attributeName) c
onst | 2316 bool AXLayoutObject::elementAttributeValue(const QualifiedName& attributeName) c
onst |
2330 { | 2317 { |
2331 if (!m_layoutObject) | 2318 if (!m_layoutObject) |
2332 return false; | 2319 return false; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2408 if (label && label->layoutObject()) { | 2395 if (label && label->layoutObject()) { |
2409 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR
ect(); | 2396 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR
ect(); |
2410 result.unite(labelRect); | 2397 result.unite(labelRect); |
2411 } | 2398 } |
2412 } | 2399 } |
2413 | 2400 |
2414 return result; | 2401 return result; |
2415 } | 2402 } |
2416 | 2403 |
2417 } // namespace blink | 2404 } // namespace blink |
OLD | NEW |