Chromium Code Reviews| Index: Source/modules/accessibility/AXNodeObject.cpp |
| diff --git a/Source/modules/accessibility/AXNodeObject.cpp b/Source/modules/accessibility/AXNodeObject.cpp |
| index dc4958887d5ca315412f1e4990dcebffd809b259..828719b73b773edf9482611cecaa55096fb98d93 100644 |
| --- a/Source/modules/accessibility/AXNodeObject.cpp |
| +++ b/Source/modules/accessibility/AXNodeObject.cpp |
| @@ -42,6 +42,10 @@ |
| #include "core/html/HTMLMeterElement.h" |
| #include "core/html/HTMLPlugInElement.h" |
| #include "core/html/HTMLSelectElement.h" |
| +#include "core/html/HTMLTableCellElement.h" |
| +#include "core/html/HTMLTableElement.h" |
| +#include "core/html/HTMLTableRowElement.h" |
| +#include "core/html/HTMLTableSectionElement.h" |
| #include "core/html/HTMLTextAreaElement.h" |
| #include "core/html/parser/HTMLParserIdioms.h" |
| #include "core/html/shadow/MediaControlElements.h" |
| @@ -183,6 +187,35 @@ bool AXNodeObject::computeAccessibilityIsIgnored() const |
| return m_role == UnknownRole; |
| } |
| +bool AXNodeObject::computeHasInheritedPresentationRole() const |
| +{ |
| + // If it has none or presentation role explicitly by itself, return true. |
|
dmazzoni
2015/03/31 16:35:23
I'd delete this comment - the code is clear by its
je_julie(Not used)
2015/04/01 12:51:28
Done.
|
| + if (roleValue() == NoneRole || roleValue() == PresentationalRole) |
| + return true; |
| + |
| + // ARIA states if an item can get focus, it should not be presentational. |
| + if (canSetFocusAttribute()) |
|
dmazzoni
2015/03/31 16:35:23
Should this be above? If an element is focusable I
je_julie(Not used)
2015/04/01 12:51:28
You're right!
|
| + return false; |
| + |
| + // http://www.w3.org/TR/wai-aria/complete#presentation |
| + // ARIA spec says that the user agent MUST apply an inherited role of presentation |
| + // to any owned elements that do not have an explicit role defined. |
| + if (ariaRoleAttribute() != UnknownRole) |
| + return false; |
| + |
| + AXObject* parent = parentObject(); |
| + if (!parent) |
| + return false; |
| + |
| + // The parent should have presentationalRole. |
|
dmazzoni
2015/03/31 16:35:23
I think it's clear without this comment.
je_julie(Not used)
2015/04/01 12:51:28
Done.
|
| + if (!isPresentationRole(parent) && !isPresentationRoleInTable(parent)) |
| + return false; |
| + |
| + // ARIA spec says that when a parent object is presentational, and it has required owned elements, |
|
dmazzoni
2015/03/31 16:35:24
How about: ARIA spec says that when a parent objec
je_julie(Not used)
2015/04/01 12:51:28
Good. Thanks!
|
| + // those elements are also presentational. For example, <li> becomes presentational from <ul>. |
| + return isRequiredOwnedElement(parent); |
| +} |
| + |
| AccessibilityRole AXNodeObject::determineAccessibilityRoleUtil() |
| { |
| if (!node()) |
| @@ -2000,4 +2033,68 @@ void AXNodeObject::changeValueByPercent(float percentChange) |
| axObjectCache()->postNotification(node(), AXObjectCacheImpl::AXValueChanged); |
| } |
| +bool AXNodeObject::isListElement(Node* node) const |
|
dmazzoni
2015/03/31 16:35:23
This shouldn't be a member function since it's jus
je_julie(Not used)
2015/04/01 12:51:28
Done.
|
| +{ |
| + return isHTMLUListElement(*node) || isHTMLOListElement(*node) || isHTMLDListElement(*node); |
| +} |
| + |
| +bool AXNodeObject::isPresentationRole(const AXObject* object) const |
|
dmazzoni
2015/03/31 16:35:24
Same, looks like it should be static
je_julie(Not used)
2015/04/01 12:51:28
It's used on AXLayoutObject and AXListBoxOption.
S
|
| +{ |
| + return object->roleValue() == NoneRole || object->roleValue() == PresentationalRole |
| + || object->hasInheritedPresentationRole(); |
| +} |
| + |
| +bool AXNodeObject::isPresentationRoleInTable(AXObject* parent) const |
|
dmazzoni
2015/03/31 16:35:23
same?
je_julie(Not used)
2015/04/01 12:51:28
I added more parameter and changed it to static fu
|
| +{ |
| + Node* parentNode = parent->node(); |
| + if (!parentNode || !parentNode->isElementNode()) |
| + return false; |
| + |
| + Node* curNode = node(); |
| + // AXTable determines the role as checking isTableXXX. |
| + // If Table has explicit role including presentation, AXTable doesn't assign implicit Role |
| + // to a whole Table. That's why we should check it based on node. |
| + // Normal Table Tree is that |
| + // cell(its role)-> tr(tr role)-> tfoot, tbody, thead(ignored role) -> table(table role). |
| + // If table has presentation role, it will be like |
| + // cell(group)-> tr(unknown) -> tfoot, tbody, thead(ignored) -> table(presentation). |
| + if (isHTMLTableCellElement(curNode) && isHTMLTableRowElement(*parentNode)) |
| + return parent->hasInheritedPresentationRole(); |
| + |
| + if (isHTMLTableRowElement(curNode) && isHTMLTableSectionElement(*parentNode)) { |
| + // Because TableSections have ignored role, presentation should be checked with its parent node |
| + AXObject* tableObject = parent->parentObject(); |
| + Node* tableNode = tableObject->node(); |
| + return isHTMLTableElement(tableNode) && tableObject->hasInheritedPresentationRole(); |
| + } |
| + return false; |
| +} |
| + |
| +bool AXNodeObject::isRequiredOwnedElement(AXObject* parent) const |
|
dmazzoni
2015/03/31 16:35:23
same?
je_julie(Not used)
2015/04/01 12:51:28
I also added more parameter and changed it to stat
|
| +{ |
| + Node* parentNode = parent->node(); |
| + if (!parentNode || !parentNode->isElementNode()) |
| + return false; |
| + |
| + AccessibilityRole role = roleValue(); |
| + |
| + if (role == ListItemRole) |
| + return isListElement(parentNode); |
| + if (role == ListMarkerRole) |
| + return isHTMLLIElement(*parentNode); |
| + if (role == MenuItemCheckBoxRole || role == MenuItemRole || role == MenuItemRadioRole) |
| + return isHTMLMenuElement(*parentNode); |
| + |
| + Node* curNode = node(); |
| + if (isHTMLTableCellElement(curNode)) |
| + return isHTMLTableRowElement(*parentNode); |
| + if (isHTMLTableRowElement(curNode)) |
| + return isHTMLTableSectionElement(*parentNode); |
| + |
| + // In case of ListboxRole and it's child, ListBoxOptionRole, |
| + // Inheritance of presentation role is handled in AXListBoxOption |
| + // Because ListBoxOption Role doesn't have any child. |
| + // If it's just ignored because of presentation, we can't see any AX tree related to ListBoxOption. |
| + return false; |
| +} |
| } // namespace blink |