Permalink
Browse files

AX: WebKit needs heuristics to differentiate lists used for layout fr…

…om semantic data lists, similar to the heuristics for layout tables versus data tables.

https://bugs.webkit.org/show_bug.cgi?id=122320

Reviewed by Mario Sanchez Prada.

Source/WebCore: 

Many authors use lists for layout, rather than presenting data. Exposing these kinds of lists to accessibility users
makes the web harder to process and listen, while degrading the importance of real lists.

This introduces heuristics to filter out layout lists with the following:
   1. If it's a named list, like ol or aria=list, then it's a list.
     1a. Unless the list has no children, then it's not a list.
   2. If it displays visible list markers, it's a list.
   3. If it does not display list markers and has only one child, it's not a list.
   4. If it does not have any listitem children, it's not a list.
   5. Otherwise it's a list (for now).

Test: accessibility/list-detection.html

* accessibility/AccessibilityList.cpp:
(WebCore::AccessibilityList::determineAccessibilityRole):
(WebCore::AccessibilityList::roleValue):
* accessibility/AccessibilityList.h:

LayoutTests: 

* accessibility/aria-roles.html:
* accessibility/list-detection-expected.txt: Added.
* accessibility/list-detection.html: Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164107 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information...
cfleizach@apple.com
cfleizach@apple.com committed Feb 14, 2014
1 parent cb9f3a7 commit 9ee768fd0a2fc2104c9a94542545f60e51421c07
@@ -1,3 +1,14 @@
2014-02-14 Chris Fleizach <cfleizach@apple.com>

AX: WebKit needs heuristics to differentiate lists used for layout from semantic data lists, similar to the heuristics for layout tables versus data tables.
https://bugs.webkit.org/show_bug.cgi?id=122320

Reviewed by Mario Sanchez Prada.

* accessibility/aria-roles.html:
* accessibility/list-detection-expected.txt: Added.
* accessibility/list-detection.html: Added.

2014-02-13 Brent Fulgham <bfulgham@apple.com>

Create some latched scrolling tests.
@@ -146,7 +146,7 @@ <h1 id="realHeading">Hello</h1>
<!--List-->
<div class="newRole">
<p>The following should be a list:</p>
<p><span tabindex="0" role="list" id="ariaList">X</span></p>
<p><span tabindex="0" role="list" id="ariaList"><span role="listitem">X</span></span></p>
<p>Actual list:</p>
<ul id="realList">
<li>Broccoli</li>
@@ -0,0 +1,61 @@
This tests the heuristic to determine if a 'list' is really a list, or just being used for layout.

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


Ordered list is a list.
PASS axElement.role == 'AXRole: AXList' is true


Empty ordered list is not a list.
PASS axElement.role == 'AXRole: AXList' is false


Empty description list is not a list.
PASS axElement.role == 'AXRole: AXList' is false


Description list is a list.
PASS axElement.role == 'AXRole: AXList' is true


ARIA role=list is a list.
PASS axElement.role == 'AXRole: AXList' is true


Empty ARIA list is not a list.
PASS axElement.role == 'AXRole: AXList' is false


ARIA list with one item is a list.
PASS axElement.role == 'AXRole: AXList' is true


Default styled Unordered list is a list, because it shows markers.
PASS axElement.role == 'AXRole: AXList' is true


Unordered list with more than 1 item and no style is a list.
PASS axElement.role == 'AXRole: AXList' is true


Unordered list with 1 item and no style is not list.
PASS axElement.role == 'AXRole: AXList' is false


List with non list item children is not a list
PASS axElement.role == 'AXRole: AXList' is false


Unordered list with image for markers is a list - even if image fails to load.
PASS axElement.role == 'AXRole: AXList' is true


Unordered list with aria role and at least one aria list items is a list.
PASS axElement.role == 'AXRole: AXList' is true


PASS successfullyParsed is true

TEST COMPLETE

@@ -0,0 +1,98 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
</head>
<body id="body">

<div id="content">

<ol id="list1" test-description="Ordered list is a list." is-list="true">
<li>item</li>
<li>item</li>
</ol>

<ol id="list2" test-description="Empty ordered list is not a list." is-list="false">
</ol>

<dl id="list3" test-description="Empty description list is not a list." is-list="false">
</dl>

<dl id="list4" test-description="Description list is a list." is-list="true">
<li>item</li>
<li>item</li>
</dl>

<div id="list5" role="list" test-description="ARIA role=list is a list." is-list="true">
<div role="listitem">item</div>
<div role="listitem">item</div>
</div>

<div id="list6" role="list" test-description="Empty ARIA list is not a list." is-list="false">
</div>

<div id="list7" role="list" test-description="ARIA list with one item is a list." is-list="true">
<div role="listitem">item</div>
</div>

<ul id="list8" test-description="Default styled Unordered list is a list, because it shows markers." is-list="true">
<li>item</li>
<li>item</li>
</ul>

<ul id="list9" style="list-style-type: none;" test-description="Unordered list with more than 1 item and no style is a list." is-list="true">
<li>item</li>
<li>item</li>
</ul>

<ul id="list10" style="list-style-type: none;" test-description="Unordered list with 1 item and no style is not list." is-list="false">
<li>item</li>
</ul>

<ul id="list11" test-description="List with non list item children is not a list" is-list="false">
<div>item</div>
</ul>

<ul id="list12" style="list-style-image: url('test.gif');" test-description="Unordered list with image for markers is a list - even if image fails to load." is-list="true">
<li>item</li>
<li>item</li>
</ul>

<ul id="list13" role="list" test-description="Unordered list with aria role and at least one aria list items is a list." is-list="true">
<div role="listitem">item</div>
<div>item</div>
</ul>

</div>

<p id="description"></p>
<div id="console"></div>

<script>
description("This tests the heuristic to determine if a 'list' is really a list, or just being used for layout.");
if (window.accessibilityController) {
var k = 1;
while (document.getElementById("list" + k)) {
var element = document.getElementById("list" + k);
var axElement = accessibilityController.accessibleElementById("list" + k);
debug(element.getAttribute("test-description"));
if (element.getAttribute("is-list") === "true") {
shouldBeTrue("axElement.role == 'AXRole: AXList'");
} else {
shouldBeFalse("axElement.role == 'AXRole: AXList'");
}
debug("\n");
k++;
}
document.getElementById("content").style.visibility = "hidden";
}
</script>

<script src="../resources/js-test-post.js"></script>
</body>
</html>
@@ -1,3 +1,28 @@
2014-02-14 Chris Fleizach <cfleizach@apple.com>

AX: WebKit needs heuristics to differentiate lists used for layout from semantic data lists, similar to the heuristics for layout tables versus data tables.
https://bugs.webkit.org/show_bug.cgi?id=122320

Reviewed by Mario Sanchez Prada.

Many authors use lists for layout, rather than presenting data. Exposing these kinds of lists to accessibility users
makes the web harder to process and listen, while degrading the importance of real lists.

This introduces heuristics to filter out layout lists with the following:
1. If it's a named list, like ol or aria=list, then it's a list.
1a. Unless the list has no children, then it's not a list.
2. If it displays visible list markers, it's a list.
3. If it does not display list markers and has only one child, it's not a list.
4. If it does not have any listitem children, it's not a list.
5. Otherwise it's a list (for now).

Test: accessibility/list-detection.html

* accessibility/AccessibilityList.cpp:
(WebCore::AccessibilityList::determineAccessibilityRole):
(WebCore::AccessibilityList::roleValue):
* accessibility/AccessibilityList.h:

2014-02-14 Brendan Long <b.long@cablelabs.com>

Use AtomicString arguments in TrackPrivateBaseClient callbacks
@@ -31,7 +31,9 @@

#include "AXObjectCache.h"
#include "HTMLNames.h"
#include "RenderListItem.h"
#include "RenderObject.h"
#include "RenderStyle.h"

namespace WebCore {

@@ -91,15 +93,67 @@ bool AccessibilityList::isDescriptionList() const
return false;

Node* node = m_renderer->node();
return node && node->hasTagName(dlTag);
return node && node->hasTagName(dlTag);
}

AccessibilityRole AccessibilityList::roleValue() const
AccessibilityRole AccessibilityList::determineAccessibilityRole()
{
if (isDescriptionList())
m_ariaRole = determineAriaRoleAttribute();

// Directory is mapped to list for now, but does not adhere to the same heuristics.
if (ariaRoleAttribute() == DirectoryRole)
return ListRole;

// Heuristic to determine if this list is being used for layout or for content.
// 1. If it's a named list, like ol or aria=list, then it's a list.
// 1a. Unless the list has no children, then it's not a list.
// 2. If it displays visible list markers, it's a list.
// 3. If it does not display list markers and has only one child, it's not a list.
// 4. If it does not have any listitem children, it's not a list.
// 5. Otherwise it's a list (for now).

AccessibilityRole role = ListRole;

// Temporarily set role so that we can query children (otherwise canHaveChildren returns false).
m_role = role;

unsigned listItemCount = 0;
bool hasVisibleMarkers = false;

const auto& children = this->children();
// DescriptionLists are always semantically a description list, so do not apply heuristics.
if (isDescriptionList() && children.size())
return DescriptionListRole;

for (const auto& child : children) {
if (child->ariaRoleAttribute() == ListItemRole)
listItemCount++;
else if (child->roleValue() == ListItemRole) {
RenderObject* listItem = child->renderer();
if (listItem && listItem->isListItem()) {
if (listItem->style().listStyleType() != NoneListStyle || listItem->style().listStyleImage())
hasVisibleMarkers = true;
listItemCount++;
}
}
}

return ListRole;
bool unorderedList = isUnorderedList();
// Non <ul> lists and ARIA lists only need to have one child.
// <ul> lists need to have 1 child, or visible markers.
if (!unorderedList || ariaRoleAttribute() != UnknownRole) {
if (!listItemCount)
role = GroupRole;
} else if (unorderedList && listItemCount <= 1 && !hasVisibleMarkers)
role = GroupRole;

return role;
}

AccessibilityRole AccessibilityList::roleValue() const
{
ASSERT(m_role != UnknownRole);
return m_role;
}

} // namespace WebCore
@@ -49,6 +49,7 @@ class AccessibilityList : public AccessibilityRenderObject {
virtual AccessibilityRole roleValue() const override final;
private:
virtual bool computeAccessibilityIsIgnored() const override;
virtual AccessibilityRole determineAccessibilityRole() override;
};

ACCESSIBILITY_OBJECT_TYPE_CASTS(AccessibilityList, isList())

0 comments on commit 9ee768f

Please sign in to comment.