Changeset 184676 in webkit


Ignore:
Timestamp:
May 20, 2015 4:42:08 PM (9 years ago)
Author:
Chris Fleizach
Message:

AX: improve list heuristics (presentational use versus actual lists)
https://bugs.webkit.org/show_bug.cgi?id=134187

Reviewed by Darin Adler.

Source/WebCore:

Improve heuristics for list detection by:

  1. Not exposing lists without list markers (unless explicitly marked as lists)
  2. Recognizing css: before-content as list markers

Test: accessibility/list-detection2.html

  • accessibility/AccessibilityList.cpp:

(WebCore::AccessibilityList::isDescriptionList):
(WebCore::AccessibilityList::childHasPseudoVisibleListItemMarkers):
(WebCore::AccessibilityList::determineAccessibilityRole):

  • accessibility/AccessibilityList.h:

LayoutTests:

  • accessibility/list-detection-expected.txt:
  • accessibility/list-detection.html:
  • accessibility/list-detection2-expected.txt: Added.
  • accessibility/list-detection2.html: Added.
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r184675 r184676  
     12015-05-20  Chris Fleizach  <cfleizach@apple.com>
     2
     3        AX: improve list heuristics (presentational use versus actual lists)
     4        https://bugs.webkit.org/show_bug.cgi?id=134187
     5
     6        Reviewed by Darin Adler.
     7
     8        * accessibility/list-detection-expected.txt:
     9        * accessibility/list-detection.html:
     10        * accessibility/list-detection2-expected.txt: Added.
     11        * accessibility/list-detection2.html: Added.
     12
    1132015-05-20  Antti Koivisto  <antti@apple.com>
    214
  • trunk/LayoutTests/accessibility/list-detection-expected.txt

    r167052 r184676  
    3636
    3737
    38 Unordered list with more than 1 item and no style is a list.
    39 PASS axElement.role == 'AXRole: AXList' is true
     38Unordered list with more than 1 item and no style is not a list.
     39PASS axElement.role == 'AXRole: AXList' is false
    4040
    4141
  • trunk/LayoutTests/accessibility/list-detection.html

    r178912 r184676  
    4141</ul>
    4242
    43 <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">
     43<ul id="list9" style="list-style-type: none;" test-description="Unordered list with more than 1 item and no style is not a list." is-list="false">
    4444<li>item</li>
    4545<li>item</li>
  • trunk/Source/WebCore/ChangeLog

    r184675 r184676  
     12015-05-20  Chris Fleizach  <cfleizach@apple.com>
     2
     3        AX: improve list heuristics (presentational use versus actual lists)
     4        https://bugs.webkit.org/show_bug.cgi?id=134187
     5
     6        Reviewed by Darin Adler.
     7
     8        Improve heuristics for list detection by:
     9            1. Not exposing lists without list markers (unless explicitly marked as lists)
     10            2. Recognizing css: before-content as list markers
     11
     12        Test: accessibility/list-detection2.html
     13
     14        * accessibility/AccessibilityList.cpp:
     15        (WebCore::AccessibilityList::isDescriptionList):
     16        (WebCore::AccessibilityList::childHasPseudoVisibleListItemMarkers):
     17        (WebCore::AccessibilityList::determineAccessibilityRole):
     18        * accessibility/AccessibilityList.h:
     19
    1202015-05-20  Antti Koivisto  <antti@apple.com>
    221
  • trunk/Source/WebCore/accessibility/AccessibilityList.cpp

    r177733 r184676  
    3333#include "HTMLElement.h"
    3434#include "HTMLNames.h"
     35#include "PseudoElement.h"
    3536#include "RenderListItem.h"
    3637#include "RenderObject.h"
     
    9899}
    99100
     101bool AccessibilityList::childHasPseudoVisibleListItemMarkers(RenderObject* listItem)
     102{
     103    // Check if the list item has a pseudo-element that should be accessible (e.g. an image or text)
     104    Element* listItemElement = downcast<Element>(listItem->node());
     105    if (!listItemElement || !listItemElement->beforePseudoElement())
     106        return false;
     107
     108    AccessibilityObject* axObj = axObjectCache()->getOrCreate(listItemElement->beforePseudoElement()->renderer());
     109    if (!axObj)
     110        return false;
     111   
     112    if (!axObj->accessibilityIsIgnored())
     113        return true;
     114   
     115    for (const auto& child : axObj->children()) {
     116        if (!child->accessibilityIsIgnored())
     117            return true;
     118    }
     119   
     120    return false;
     121}
     122   
    100123AccessibilityRole AccessibilityList::determineAccessibilityRole()
    101124{
     
    132155        else if (child->roleValue() == ListItemRole) {
    133156            RenderObject* listItem = child->renderer();
    134             if (listItem && listItem->isListItem()) {
    135                 if (listItem->style().listStyleType() != NoneListStyle || listItem->style().listStyleImage())
     157            if (!listItem)
     158                continue;
     159           
     160            // Rendered list items always count.
     161            if (listItem->isListItem()) {
     162                if (!hasVisibleMarkers && (listItem->style().listStyleType() != NoneListStyle || listItem->style().listStyleImage() || childHasPseudoVisibleListItemMarkers(listItem)))
    136163                    hasVisibleMarkers = true;
    137164                listItemCount++;
     165            } else if (listItem->node() && listItem->node()->hasTagName(liTag)) {
     166                // Inline elements that are in a list with an explicit role should also count.
     167                if (m_ariaRole == ListRole)
     168                    listItemCount++;
     169
     170                if (childHasPseudoVisibleListItemMarkers(listItem)) {
     171                    hasVisibleMarkers = true;
     172                    listItemCount++;
     173                }
    138174            }
    139175        }
    140176    }
    141177   
    142     bool unorderedList = isUnorderedList();
    143178    // Non <ul> lists and ARIA lists only need to have one child.
    144     // <ul> lists need to have 1 child, or visible markers.
    145     if (!unorderedList || ariaRoleAttribute() != UnknownRole) {
     179    // <ul>, <ol> lists need to have visible markers.
     180    if (ariaRoleAttribute() != UnknownRole) {
    146181        if (!listItemCount)
    147182            role = GroupRole;
    148     } else if (unorderedList && listItemCount <= 1 && !hasVisibleMarkers)
     183    } else if (!hasVisibleMarkers)
    149184        role = GroupRole;
    150185
  • trunk/Source/WebCore/accessibility/AccessibilityList.h

    r177733 r184676  
    5050    virtual bool computeAccessibilityIsIgnored() const override;
    5151    virtual AccessibilityRole determineAccessibilityRole() override;
     52    bool childHasPseudoVisibleListItemMarkers(RenderObject*);
    5253};
    5354
Note: See TracChangeset for help on using the changeset viewer.