Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(712)

Side by Side Diff: third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp

Issue 1761633002: One accessibility tree per frame. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add ChromeVox test traversing iframes Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1514 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 if (ariaRoleAttribute() == MenuRole) { 1525 if (ariaRoleAttribute() == MenuRole) {
1526 AXObject* parent = menuButtonForMenu(); 1526 AXObject* parent = menuButtonForMenu();
1527 if (parent) 1527 if (parent)
1528 return parent; 1528 return parent;
1529 } 1529 }
1530 1530
1531 LayoutObject* parentObj = layoutParentObject(); 1531 LayoutObject* parentObj = layoutParentObject();
1532 if (parentObj) 1532 if (parentObj)
1533 return axObjectCache().getOrCreate(parentObj); 1533 return axObjectCache().getOrCreate(parentObj);
1534 1534
1535 // A WebArea's parent should be the containing frame (if local) or page popu p owner. 1535 // A WebArea's parent should be the page popup owner, if any, otherwise null .
1536 if (isWebArea()) { 1536 if (isWebArea()) {
1537 LocalFrame* frame = m_layoutObject->frame(); 1537 LocalFrame* frame = m_layoutObject->frame();
1538 if (frame->owner() && frame->owner()->isLocal()) {
1539 HTMLFrameOwnerElement* owner = toHTMLFrameOwnerElement(frame->owner( ));
1540 if (owner && owner->layoutObject())
1541 return axObjectCache().getOrCreate(owner->layoutObject());
1542 }
1543 return axObjectCache().getOrCreate(frame->pagePopupOwner()); 1538 return axObjectCache().getOrCreate(frame->pagePopupOwner());
1544 } 1539 }
1545 1540
1546 return 0; 1541 return 0;
1547 } 1542 }
1548 1543
1549 AXObject* AXLayoutObject::computeParentIfExists() const 1544 AXObject* AXLayoutObject::computeParentIfExists() const
1550 { 1545 {
1551 if (!m_layoutObject) 1546 if (!m_layoutObject)
1552 return 0; 1547 return 0;
1553 1548
1554 if (ariaRoleAttribute() == MenuBarRole) 1549 if (ariaRoleAttribute() == MenuBarRole)
1555 return axObjectCache().get(m_layoutObject->parent()); 1550 return axObjectCache().get(m_layoutObject->parent());
1556 1551
1557 // menuButton and its corresponding menu are DOM siblings, but Accessibility needs them to be parent/child 1552 // menuButton and its corresponding menu are DOM siblings, but Accessibility needs them to be parent/child
1558 if (ariaRoleAttribute() == MenuRole) { 1553 if (ariaRoleAttribute() == MenuRole) {
1559 AXObject* parent = menuButtonForMenu(); 1554 AXObject* parent = menuButtonForMenu();
1560 if (parent) 1555 if (parent)
1561 return parent; 1556 return parent;
1562 } 1557 }
1563 1558
1564 LayoutObject* parentObj = layoutParentObject(); 1559 LayoutObject* parentObj = layoutParentObject();
1565 if (parentObj) 1560 if (parentObj)
1566 return axObjectCache().get(parentObj); 1561 return axObjectCache().get(parentObj);
1567 1562
1568 // A WebArea's parent should be the containing frame (if local) or page popu p owner. 1563 // A WebArea's parent should be the page popup owner, if any, otherwise null .
1569 if (isWebArea()) { 1564 if (isWebArea()) {
1570 LocalFrame* frame = m_layoutObject->frame(); 1565 LocalFrame* frame = m_layoutObject->frame();
1571 if (frame->owner() && frame->owner()->isLocal()) {
1572 HTMLFrameOwnerElement* owner = toHTMLFrameOwnerElement(frame->owner( ));
1573 if (owner && owner->layoutObject())
1574 return axObjectCache().get(owner->layoutObject());
1575 }
1576 return axObjectCache().get(frame->pagePopupOwner()); 1566 return axObjectCache().get(frame->pagePopupOwner());
1577 } 1567 }
1578 1568
1579 return 0; 1569 return 0;
1580 } 1570 }
1581 1571
1582 // 1572 //
1583 // Low-level accessibility tree exploration, only for use within the accessibili ty module. 1573 // Low-level accessibility tree exploration, only for use within the accessibili ty module.
1584 // 1574 //
1585 1575
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1656 computeAriaOwnsChildren(ownedChildren); 1646 computeAriaOwnsChildren(ownedChildren);
1657 1647
1658 for (AXObject* obj = rawFirstChild(); obj; obj = obj->rawNextSibling()) { 1648 for (AXObject* obj = rawFirstChild(); obj; obj = obj->rawNextSibling()) {
1659 if (!axObjectCache().isAriaOwned(obj)) { 1649 if (!axObjectCache().isAriaOwned(obj)) {
1660 obj->setParent(this); 1650 obj->setParent(this);
1661 addChild(obj); 1651 addChild(obj);
1662 } 1652 }
1663 } 1653 }
1664 1654
1665 addHiddenChildren(); 1655 addHiddenChildren();
1666 addFrameChildren();
1667 addPopupChildren(); 1656 addPopupChildren();
1668 addImageMapChildren(); 1657 addImageMapChildren();
1669 addTextFieldChildren(); 1658 addTextFieldChildren();
1670 addCanvasChildren(); 1659 addCanvasChildren();
1671 addRemoteSVGChildren(); 1660 addRemoteSVGChildren();
1672 addInlineTextBoxChildren(false); 1661 addInlineTextBoxChildren(false);
1673 1662
1674 for (const auto& child : m_children) { 1663 for (const auto& child : m_children) {
1675 if (!child->cachedParentObject()) 1664 if (!child->cachedParentObject())
1676 child->setParent(this); 1665 child->setParent(this);
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
2445 if (!isHTMLCanvasElement(node())) 2434 if (!isHTMLCanvasElement(node()))
2446 return; 2435 return;
2447 2436
2448 // If it's a canvas, it won't have laid out children, but it might have acce ssible fallback content. 2437 // If it's a canvas, it won't have laid out children, but it might have acce ssible fallback content.
2449 // Clear m_haveChildren because AXNodeObject::addChildren will expect it to be false. 2438 // Clear m_haveChildren because AXNodeObject::addChildren will expect it to be false.
2450 ASSERT(!m_children.size()); 2439 ASSERT(!m_children.size());
2451 m_haveChildren = false; 2440 m_haveChildren = false;
2452 AXNodeObject::addChildren(); 2441 AXNodeObject::addChildren();
2453 } 2442 }
2454 2443
2455 void AXLayoutObject::addFrameChildren()
2456 {
2457 if (!m_layoutObject || !m_layoutObject->isLayoutPart())
2458 return;
2459
2460 Widget* widget = toLayoutPart(m_layoutObject)->widget();
2461 if (!widget || !widget->isFrameView())
2462 return;
2463
2464 Document* doc = toFrameView(widget)->frame().document();
2465 if (!doc || !doc->layoutView())
2466 return;
2467
2468 AXObject* axChildFrame = axObjectCache().getOrCreate(doc);
2469 if (!axChildFrame->accessibilityIsIgnored())
2470 m_children.append(axChildFrame);
2471 }
2472
2473 void AXLayoutObject::addPopupChildren() 2444 void AXLayoutObject::addPopupChildren()
2474 { 2445 {
2475 if (!isHTMLInputElement(node())) 2446 if (!isHTMLInputElement(node()))
2476 return; 2447 return;
2477 if (AXObject* axPopup = toHTMLInputElement(node())->popupRootAXObject()) 2448 if (AXObject* axPopup = toHTMLInputElement(node())->popupRootAXObject())
2478 m_children.append(axPopup); 2449 m_children.append(axPopup);
2479 } 2450 }
2480 2451
2481 void AXLayoutObject::addRemoteSVGChildren() 2452 void AXLayoutObject::addRemoteSVGChildren()
2482 { 2453 {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
2546 if (label && label->layoutObject()) { 2517 if (label && label->layoutObject()) {
2547 LayoutRect labelRect = axObjectCache().getOrCreate(label)->elementRe ct(); 2518 LayoutRect labelRect = axObjectCache().getOrCreate(label)->elementRe ct();
2548 result.unite(labelRect); 2519 result.unite(labelRect);
2549 } 2520 }
2550 } 2521 }
2551 2522
2552 return result; 2523 return result;
2553 } 2524 }
2554 2525
2555 } // namespace blink 2526 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698