Changeset 164107 in webkit
- Timestamp:
- Feb 14, 2014 9:52:41 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r164105 r164107 1 2014-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 1 12 2014-02-13 Brent Fulgham <bfulgham@apple.com> 2 13 -
trunk/LayoutTests/accessibility/aria-roles.html
r120111 r164107 147 147 <div class="newRole"> 148 148 <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> 150 150 <p>Actual list:</p> 151 151 <ul id="realList"> -
trunk/Source/WebCore/ChangeLog
r164106 r164107 1 2014-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 1 26 2014-02-14 Brendan Long <b.long@cablelabs.com> 2 27 -
trunk/Source/WebCore/accessibility/AccessibilityList.cpp
r161492 r164107 32 32 #include "AXObjectCache.h" 33 33 #include "HTMLNames.h" 34 #include "RenderListItem.h" 34 35 #include "RenderObject.h" 36 #include "RenderStyle.h" 35 37 36 38 namespace WebCore { … … 92 94 93 95 Node* node = m_renderer->node(); 94 return node && node->hasTagName(dlTag); 96 return node && node->hasTagName(dlTag); 95 97 } 96 98 99 AccessibilityRole 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 97 153 AccessibilityRole AccessibilityList::roleValue() const 98 154 { 99 if (isDescriptionList()) 100 return DescriptionListRole; 101 102 return ListRole; 155 ASSERT(m_role != UnknownRole); 156 return m_role; 103 157 } 104 158 -
trunk/Source/WebCore/accessibility/AccessibilityList.h
r162158 r164107 50 50 private: 51 51 virtual bool computeAccessibilityIsIgnored() const override; 52 virtual AccessibilityRole determineAccessibilityRole() override; 52 53 }; 53 54
Note: See TracChangeset
for help on using the changeset viewer.