Changeset 164107 in webkit


Ignore:
Timestamp:
Feb 14, 2014 9:52:41 AM (10 years ago)
Author:
Chris Fleizach
Message:

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.

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.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r164105 r164107  
     12014-02-14  Chris Fleizach  <cfleizach@apple.com>
     2
     3        AX: WebKit needs heuristics to differentiate lists used for layout from semantic data lists, similar to the heuristics for layout tables versus data tables.
     4        https://bugs.webkit.org/show_bug.cgi?id=122320
     5
     6        Reviewed by Mario Sanchez Prada.
     7
     8        * accessibility/aria-roles.html:
     9        * accessibility/list-detection-expected.txt: Added.
     10        * accessibility/list-detection.html: Added.
     11
    1122014-02-13  Brent Fulgham  <bfulgham@apple.com>
    213
  • trunk/LayoutTests/accessibility/aria-roles.html

    r120111 r164107  
    147147  <div class="newRole">
    148148    <p>The following should be a list:</p>
    149     <p><span tabindex="0" role="list" id="ariaList">X</span></p>
     149    <p><span tabindex="0" role="list" id="ariaList"><span role="listitem">X</span></span></p>
    150150    <p>Actual list:</p>
    151151    <ul id="realList">
  • trunk/Source/WebCore/ChangeLog

    r164106 r164107  
     12014-02-14  Chris Fleizach  <cfleizach@apple.com>
     2
     3        AX: WebKit needs heuristics to differentiate lists used for layout from semantic data lists, similar to the heuristics for layout tables versus data tables.
     4        https://bugs.webkit.org/show_bug.cgi?id=122320
     5
     6        Reviewed by Mario Sanchez Prada.
     7
     8        Many authors use lists for layout, rather than presenting data. Exposing these kinds of lists to accessibility users
     9        makes the web harder to process and listen, while degrading the importance of real lists.
     10
     11        This introduces heuristics to filter out layout lists with the following:
     12           1. If it's a named list, like ol or aria=list, then it's a list.
     13             1a. Unless the list has no children, then it's not a list.
     14           2. If it displays visible list markers, it's a list.
     15           3. If it does not display list markers and has only one child, it's not a list.
     16           4. If it does not have any listitem children, it's not a list.
     17           5. Otherwise it's a list (for now).
     18
     19        Test: accessibility/list-detection.html
     20
     21        * accessibility/AccessibilityList.cpp:
     22        (WebCore::AccessibilityList::determineAccessibilityRole):
     23        (WebCore::AccessibilityList::roleValue):
     24        * accessibility/AccessibilityList.h:
     25
    1262014-02-14  Brendan Long  <b.long@cablelabs.com>
    227
  • trunk/Source/WebCore/accessibility/AccessibilityList.cpp

    r161492 r164107  
    3232#include "AXObjectCache.h"
    3333#include "HTMLNames.h"
     34#include "RenderListItem.h"
    3435#include "RenderObject.h"
     36#include "RenderStyle.h"
    3537
    3638namespace WebCore {
     
    9294   
    9395    Node* node = m_renderer->node();
    94     return node && node->hasTagName(dlTag);   
     96    return node && node->hasTagName(dlTag);
    9597}
    9698
     99AccessibilityRole AccessibilityList::determineAccessibilityRole()
     100{
     101    m_ariaRole = determineAriaRoleAttribute();
     102   
     103    // Directory is mapped to list for now, but does not adhere to the same heuristics.
     104    if (ariaRoleAttribute() == DirectoryRole)
     105        return ListRole;
     106   
     107    // Heuristic to determine if this list is being used for layout or for content.
     108    //   1. If it's a named list, like ol or aria=list, then it's a list.
     109    //      1a. Unless the list has no children, then it's not a list.
     110    //   2. If it displays visible list markers, it's a list.
     111    //   3. If it does not display list markers and has only one child, it's not a list.
     112    //   4. If it does not have any listitem children, it's not a list.
     113    //   5. Otherwise it's a list (for now).
     114   
     115    AccessibilityRole role = ListRole;
     116   
     117    // Temporarily set role so that we can query children (otherwise canHaveChildren returns false).
     118    m_role = role;
     119   
     120    unsigned listItemCount = 0;
     121    bool hasVisibleMarkers = false;
     122
     123    const auto& children = this->children();
     124    // DescriptionLists are always semantically a description list, so do not apply heuristics.
     125    if (isDescriptionList() && children.size())
     126        return DescriptionListRole;
     127
     128    for (const auto& child : children) {
     129        if (child->ariaRoleAttribute() == ListItemRole)
     130            listItemCount++;
     131        else if (child->roleValue() == ListItemRole) {
     132            RenderObject* listItem = child->renderer();
     133            if (listItem && listItem->isListItem()) {
     134                if (listItem->style().listStyleType() != NoneListStyle || listItem->style().listStyleImage())
     135                    hasVisibleMarkers = true;
     136                listItemCount++;
     137            }
     138        }
     139    }
     140   
     141    bool unorderedList = isUnorderedList();
     142    // Non <ul> lists and ARIA lists only need to have one child.
     143    // <ul> lists need to have 1 child, or visible markers.
     144    if (!unorderedList || ariaRoleAttribute() != UnknownRole) {
     145        if (!listItemCount)
     146            role = GroupRole;
     147    } else if (unorderedList && listItemCount <= 1 && !hasVisibleMarkers)
     148        role = GroupRole;
     149
     150    return role;
     151}
     152   
    97153AccessibilityRole AccessibilityList::roleValue() const
    98154{
    99     if (isDescriptionList())
    100         return DescriptionListRole;
    101    
    102     return ListRole;
     155    ASSERT(m_role != UnknownRole);
     156    return m_role;
    103157}
    104158   
  • trunk/Source/WebCore/accessibility/AccessibilityList.h

    r162158 r164107  
    5050private:
    5151    virtual bool computeAccessibilityIsIgnored() const override;
     52    virtual AccessibilityRole determineAccessibilityRole() override;
    5253};
    5354
Note: See TracChangeset for help on using the changeset viewer.