Changeset 70554 in webkit
- Timestamp:
- Oct 26, 2010 12:19:29 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r70553 r70554 1 2010-10-26 Mario Sanchez Prada <msanchez@igalia.com> 2 3 Reviewed by Chris Fleizach. 4 5 [Gtk] Layout tables should indicate that they are not data tables via an object attribute 6 https://bugs.webkit.org/show_bug.cgi?id=35422 7 8 Set the 'layout-guess' attribute to 'true' for data tables. 9 10 Reorganized some code in AccessibilityTable so now the function 11 isDataTable() is more coherent by just answering that very 12 specific question, regardless of whether the table is being 13 exposed or not to Assistive Technologies. 14 15 Hence, now it's possible to make two questions separately instead 16 of just one, meaning that the new function isAccessibleTable() is 17 now what we formerly defined as the isDataTable() function. 18 19 * accessibility/AccessibilityObject.h: 20 (WebCore::AccessibilityObject::isAccessibilityTable): 21 New function to allow asking tables both whether they are 22 exposed and whether they are data tables, which are different 23 questions whose answers might be the same in many situations, 24 but different sometimes (as it can happen in the GTK port). 25 * accessibility/AccessibilityTable.h: 26 * accessibility/AccessibilityTable.cpp: 27 (WebCore::AccessibilityTable::hasARIARole): 28 New, checks whether the table has a valid ARIA role. 29 (WebCore::AccessibilityTable::isAccessibilityTable): 30 New, returns the value of m_isAccessibilityTable. It's 31 basically the former isDataTable() function renamed. 32 (WebCore::AccessibilityTable::isDataTable): 33 Changed behaviour. Instead of just returning the value of 34 m_isAccessibilityTable as it did so far (which was confusing 35 because of that's not what the name suggests), focus on 36 checking whether it's a data table or not and return a bool 37 value accordingly. It's basically a rename of the former 38 isTableExposableThroughAccessibility() function, but withouth 39 the GTK-specific if-endif region (which didn't make sense 40 here now, because that was answering the question "is the table 41 exposed in the GTK port?", instead of "is it a data table?"). 42 (WebCore::AccessibilityTable::isTableExposableThroughAccessibility): 43 Uses the hasAriaRole(), and isDataTable() to determine whether 44 a table should be exposed or not. Also includes the GTK-specific 45 if-region coming from the former implementation of the function 46 isTableExposableThroughAccessibility() not to check whether it's 47 a data table in case the rest of the checks succeeded (all 48 tables are exposed in the GTK port). 49 (WebCore::AccessibilityTable::addChildren): 50 Replace usage of isDataTable() with isAccessibilityTable(), to 51 keep exactly the same behaviour happening before this patch. 52 (WebCore::AccessibilityTable::roleValue): Ditto. 53 (WebCore::AccessibilityTable::accessibilityIsIgnored): Ditto. 54 (WebCore::AccessibilityTable::title): Ditto. 55 56 Updated usage of the former function isDataTable() everywhere 57 else, replacing it with the new isAccessibilityTable(), so keeping 58 exactly the same behaviour happening before this patch. 59 60 * accessibility/AccessibilityARIAGrid.cpp: 61 (WebCore::AccessibilityARIAGrid::addChildren): 62 Use isAccessibilityTable() instead of isDataTable(). 63 * accessibility/AccessibilityARIAGridCell.cpp: 64 (WebCore::AccessibilityARIAGridCell::parentTable): Ditto. 65 * accessibility/AccessibilityARIAGridRow.cpp: 66 (WebCore::AccessibilityARIAGridRow::disclosedRows): Ditto. 67 (WebCore::AccessibilityARIAGridRow::disclosedByRow): Ditto. 68 (WebCore::AccessibilityARIAGridRow::parentTable): Ditto. 69 * accessibility/AccessibilityTableCell.cpp: 70 (WebCore::AccessibilityTableCell::isTableCell): 71 Use isAccessibilityTable() instead of isDataTable(). 72 * accessibility/AccessibilityTableHeaderContainer.cpp: 73 (WebCore::AccessibilityTableHeaderContainer::addChildren): Ditto. 74 * accessibility/AccessibilityTableRow.cpp: 75 (WebCore::AccessibilityTableRow::isTableRow): Ditto 76 * accessibility/mac/AccessibilityObjectWrapper.mm: 77 (-[AccessibilityObjectWrapper additionalAccessibilityAttributeNames]): 78 Use isAccessibilityTable() instead of isDataTable(). 79 (-[AccessibilityObjectWrapper accessibilityAttributeNames]): Ditto. 80 (-[AccessibilityObjectWrapper accessibilityAttributeValue:]): Ditto. 81 (-[AccessibilityObjectWrapper accessibilityParameterizedAttributeNames]): Ditto. 82 (-[AccessibilityObjectWrapper accessibilitySetValue:forAttribute:]): Ditto. 83 (-[AccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]): Ditto. 84 85 Use the new function isAccessibilityTable() together with the 86 modified implementation of isDataTable() to set the 'layout-guess' 87 attribute when needed. 88 89 * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp: 90 (webkit_accessible_get_attributes): 91 Set the 'layout-guess' attribute to 'true' to help Assistive 92 Technologies guessing which tables are not data tables. 93 1 94 2010-10-26 Chris Marrin <cmarrin@apple.com> 2 95 -
trunk/WebCore/accessibility/AccessibilityARIAGrid.cpp
r69707 r70554 84 84 ASSERT(!m_haveChildren); 85 85 86 if (!is DataTable()) {86 if (!isAccessibilityTable()) { 87 87 AccessibilityRenderObject::addChildren(); 88 88 return; -
trunk/WebCore/accessibility/AccessibilityARIAGridCell.cpp
r44151 r70554 58 58 59 59 parent = parent->parentObjectUnignored(); 60 if (!parent || !parent->is DataTable())60 if (!parent || !parent->isAccessibilityTable()) 61 61 return 0; 62 62 -
trunk/WebCore/accessibility/AccessibilityARIAGridRow.cpp
r52159 r70554 66 66 // have an aria-level of plus 1 from this row. 67 67 AccessibilityObject* parent = parentObjectUnignored(); 68 if (!parent || !parent->is DataTable())68 if (!parent || !parent->isAccessibilityTable()) 69 69 return; 70 70 … … 93 93 // that is aria-level subtract 1 from this row. 94 94 AccessibilityObject* parent = parentObjectUnignored(); 95 if (!parent || !parent->is DataTable())95 if (!parent || !parent->isAccessibilityTable()) 96 96 return 0; 97 97 … … 120 120 { 121 121 AccessibilityObject* parent = parentObjectUnignored(); 122 if (!parent->is DataTable())122 if (!parent->isAccessibilityTable()) 123 123 return 0; 124 124 -
trunk/WebCore/accessibility/AccessibilityObject.h
r70256 r70554 286 286 virtual bool isControl() const { return false; } 287 287 virtual bool isList() const { return false; } 288 virtual bool isAccessibilityTable() const { return false; } 288 289 virtual bool isDataTable() const { return false; } 289 290 virtual bool isTableRow() const { return false; } -
trunk/WebCore/accessibility/AccessibilityTable.cpp
r64874 r70554 68 68 } 69 69 70 bool AccessibilityTable::isTableExposableThroughAccessibility() 71 { 72 // the following is a heuristic used to determine if a 73 // <table> should be exposed as an AXTable. The goal 74 // is to only show "data" tables 75 76 if (!renderer()) 77 return false; 78 79 // if the developer assigned an aria role to this, then we shouldn't 80 // expose it as a table, unless, of course, the aria role is a table 70 bool AccessibilityTable::hasARIARole() const 71 { 72 if (!m_renderer) 73 return false; 74 81 75 AccessibilityRole ariaRole = ariaRoleAttribute(); 82 76 if (ariaRole != UnknownRole) 83 return false; 77 return true; 78 79 return false; 80 } 81 82 bool AccessibilityTable::isAccessibilityTable() const 83 { 84 if (!m_renderer) 85 return false; 86 87 return m_isAccessibilityTable; 88 } 89 90 bool AccessibilityTable::isDataTable() const 91 { 92 if (!m_renderer) 93 return false; 94 95 // Do not consider it a data table is it has an ARIA role. 96 if (hasARIARole()) 97 return false; 98 99 // This employs a heuristic to determine if this table should appear. 100 // Only "data" tables should be exposed as tables. 101 // Unfortunately, there is no good way to determine the difference 102 // between a "layout" table and a "data" table. 84 103 85 104 RenderTable* table = toRenderTable(m_renderer); 86 87 // this employs a heuristic to determine if this table should appear.88 // Only "data" tables should be exposed as tables.89 // Unfortunately, there is no good way to determine the difference90 // between a "layout" table and a "data" table91 92 105 Node* tableNode = table->node(); 93 106 if (!tableNode || !tableNode->hasTagName(tableTag)) 94 107 return false; 95 108 96 // Gtk+ ATs expect all tables to be exposed as tables.97 #if PLATFORM(GTK)98 return true;99 #endif100 101 109 // if there is a caption element, summary, THEAD, or TFOOT section, it's most certainly a data table 102 110 HTMLTableElement* tableElement = static_cast<HTMLTableElement*>(tableNode); … … 243 251 } 244 252 253 bool AccessibilityTable::isTableExposableThroughAccessibility() const 254 { 255 // The following is a heuristic used to determine if a 256 // <table> should be exposed as an AXTable. The goal 257 // is to only show "data" tables. 258 259 if (!m_renderer) 260 return false; 261 262 // If the developer assigned an aria role to this, then we 263 // shouldn't expose it as a table, unless, of course, the aria 264 // role is a table. 265 if (hasARIARole()) 266 return false; 267 268 // Gtk+ ATs expect all tables to be exposed as tables. 269 #if PLATFORM(GTK) 270 Node* tableNode = toRenderTable(m_renderer)->node(); 271 return tableNode && tableNode->hasTagName(tableTag); 272 #endif 273 274 return isDataTable(); 275 } 276 245 277 void AccessibilityTable::clearChildren() 246 278 { … … 252 284 void AccessibilityTable::addChildren() 253 285 { 254 if (!is DataTable()) {286 if (!isAccessibilityTable()) { 255 287 AccessibilityRenderObject::addChildren(); 256 288 return; … … 489 521 AccessibilityRole AccessibilityTable::roleValue() const 490 522 { 491 if (!is DataTable())523 if (!isAccessibilityTable()) 492 524 return AccessibilityRenderObject::roleValue(); 493 525 … … 503 535 return true; 504 536 505 if (!is DataTable())537 if (!isAccessibilityTable()) 506 538 return AccessibilityRenderObject::accessibilityIsIgnored(); 507 539 … … 511 543 String AccessibilityTable::title() const 512 544 { 513 if (!is DataTable())545 if (!isAccessibilityTable()) 514 546 return AccessibilityRenderObject::title(); 515 547 … … 533 565 } 534 566 535 bool AccessibilityTable::isDataTable() const536 {537 if (!m_renderer)538 return false;539 540 return m_isAccessibilityTable;541 }542 543 567 } // namespace WebCore -
trunk/WebCore/accessibility/AccessibilityTable.h
r65021 r70554 52 52 virtual ~AccessibilityTable(); 53 53 54 virtual bool isAccessibilityTable() const; 54 55 virtual bool isDataTable() const; 56 55 57 virtual AccessibilityRole roleValue() const; 56 58 virtual bool isAriaTable() const { return false; } … … 87 89 mutable bool m_isAccessibilityTable; 88 90 89 bool isTableExposableThroughAccessibility(); 91 bool hasARIARole() const; 92 bool isTableExposableThroughAccessibility() const; 90 93 }; 91 94 -
trunk/WebCore/accessibility/AccessibilityTableCell.cpp
r63994 r70554 85 85 { 86 86 AccessibilityObject* table = parentTable(); 87 if (!table || !table->is DataTable())87 if (!table || !table->isAccessibilityTable()) 88 88 return false; 89 89 -
trunk/WebCore/accessibility/AccessibilityTableHeaderContainer.cpp
r55818 r70554 86 86 87 87 m_haveChildren = true; 88 if (!m_parentTable || !m_parentTable->is DataTable())88 if (!m_parentTable || !m_parentTable->isAccessibilityTable()) 89 89 return; 90 90 -
trunk/WebCore/accessibility/AccessibilityTableRow.cpp
r67407 r70554 69 69 { 70 70 AccessibilityObject* table = parentTable(); 71 if (!table || !table->is DataTable())71 if (!table || !table->isAccessibilityTable()) 72 72 return false; 73 73 -
trunk/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp
r70089 r70554 330 330 { 331 331 AtkAttributeSet* attributeSet = 0; 332 333 332 attributeSet = addAttributeToSet(attributeSet, "toolkit", "WebKitGtk"); 334 333 335 int headingLevel = core(object)->headingLevel(); 334 AccessibilityObject* coreObject = core(object); 335 if (!coreObject) 336 return attributeSet; 337 338 int headingLevel = coreObject->headingLevel(); 336 339 if (headingLevel) { 337 340 String value = String::number(headingLevel); 338 341 attributeSet = addAttributeToSet(attributeSet, "level", value.utf8().data()); 339 342 } 343 344 // Set the 'layout-guess' attribute to help Assistive 345 // Technologies know when an exposed table is not data table. 346 if (coreObject->isAccessibilityTable() && !coreObject->isDataTable()) 347 attributeSet = addAttributeToSet(attributeSet, "layout-guess", "true"); 348 340 349 return attributeSet; 341 350 } -
trunk/WebCore/accessibility/mac/AccessibilityObjectWrapper.mm
r68680 r70554 648 648 [additional addObject:NSAccessibilityDropEffectsAttribute]; 649 649 650 if (m_object->is DataTable() && static_cast<AccessibilityTable*>(m_object)->supportsSelectedRows())650 if (m_object->isAccessibilityTable() && static_cast<AccessibilityTable*>(m_object)->supportsSelectedRows()) 651 651 [additional addObject:NSAccessibilitySelectedRowsAttribute]; 652 652 … … 949 949 objectAttributes = anchorAttrs; 950 950 951 else if (m_object->is DataTable())951 else if (m_object->isAccessibilityTable()) 952 952 objectAttributes = tableAttrs; 953 953 else if (m_object->isTableColumn()) … … 1637 1637 } 1638 1638 1639 if (m_object->is DataTable()) {1639 if (m_object->isAccessibilityTable()) { 1640 1640 // TODO: distinguish between visible and non-visible rows 1641 1641 if ([attributeName isEqualToString:NSAccessibilityRowsAttribute] || … … 2087 2087 return textParamAttrs; 2088 2088 2089 if (m_object->is DataTable())2089 if (m_object->isAccessibilityTable()) 2090 2090 return tableParamAttrs; 2091 2091 … … 2248 2248 AccessibilityObject::AccessibilityChildrenVector selectedRows; 2249 2249 convertToVector(array, selectedRows); 2250 if (m_object->isTree() || m_object->is DataTable())2250 if (m_object->isTree() || m_object->isAccessibilityTable()) 2251 2251 m_object->setSelectedRows(selectedRows); 2252 2252 } else if ([attributeName isEqualToString:NSAccessibilityGrabbedAttribute]) … … 2542 2542 } 2543 2543 2544 if (m_object->is DataTable()) {2544 if (m_object->isAccessibilityTable()) { 2545 2545 if ([attribute isEqualToString:NSAccessibilityCellForColumnAndRowParameterizedAttribute]) { 2546 2546 if (array == nil || [array count] != 2) -
trunk/WebKit/gtk/ChangeLog
r70514 r70554 1 2010-10-26 Mario Sanchez Prada <msanchez@igalia.com> 2 3 Reviewed by Chris Fleizach. 4 5 [Gtk] Layout tables should indicate that they are not data tables via an object attribute 6 https://bugs.webkit.org/show_bug.cgi?id=35422 7 8 New unit test to check the 'layout-guess' attribute in tables. 9 10 * tests/testatk.c: 11 (atkAttributeSetAttributeNameHasValue): New, looks for a attribute 12 with a specific value, by the name of attribute. 13 (atkAttributeSetContainsAttributeName): New, just checks whether 14 an attribute with a specified name is present in the set. 15 (atkAttributeSetAttributeHasValue): Modified to relay on the new 16 function atkAttributeSetAttributeNameHasValue(). 17 (testWebkitAtkLayoutAndDataTables): New test. 18 (main): Added the new test. 19 1 20 2010-10-26 Xan Lopez <xlopez@igalia.com> 2 21 -
trunk/WebKit/gtk/tests/testatk.c
r68415 r70554 47 47 static const char* formWithTextInputs = "<html><body><form><input type='text' name='entry' /></form></body></html>"; 48 48 49 static const char* layoutAndDataTables = "<html><body><table><tr><th>Odd</th><th>Even</th></tr><tr><td>1</td><td>2</td></tr></table><table><tr><td>foo</td><td>bar</td></tr></table></body></html>"; 50 49 51 static const char* listsOfItems = "<html><body><ul><li>text only</li><li><a href='foo'>link only</a></li><li>text and a <a href='bar'>link</a></li></ul><ol><li>text only</li><li><a href='foo'>link only</a></li><li>text and a <a href='bar'>link</a></li></ol></body></html>"; 50 52 … … 597 599 } 598 600 601 static gboolean atkAttributeSetAttributeNameHasValue(AtkAttributeSet* set, const gchar* attributeName, const gchar* value) 602 { 603 GSList* element; 604 AtkAttribute at; 605 at.name = (gchar*)attributeName; 606 element = g_slist_find_custom(set, &at, (GCompareFunc)compAtkAttributeName); 607 return element && !g_strcmp0(((AtkAttribute*)(element->data))->value, value); 608 } 609 610 static gboolean atkAttributeSetContainsAttributeName(AtkAttributeSet* set, const gchar* attributeName) 611 { 612 AtkAttribute at; 613 at.name = (gchar*)attributeName; 614 return g_slist_find_custom(set, &at, (GCompareFunc)compAtkAttributeName) ? true : false; 615 } 616 599 617 static gboolean atkAttributeSetAttributeHasValue(AtkAttributeSet* set, AtkTextAttribute attribute, const gchar* value) 600 618 { 601 GSList *element; 602 AtkAttribute at; 603 gboolean result; 604 at.name = (gchar *)atk_text_attribute_get_name(attribute); 605 element = g_slist_find_custom(set, &at, (GCompareFunc)compAtkAttributeName); 606 result = element && !g_strcmp0(((AtkAttribute*)(element->data))->value, value); 607 return result; 619 return atkAttributeSetAttributeNameHasValue(set, atk_text_attribute_get_name(attribute), value); 608 620 } 609 621 … … 965 977 } 966 978 979 static void testWebkitAtkLayoutAndDataTables(void) 980 { 981 WebKitWebView* webView = WEBKIT_WEB_VIEW(webkit_web_view_new()); 982 g_object_ref_sink(webView); 983 GtkAllocation alloc = { 0, 0, 800, 600 }; 984 gtk_widget_size_allocate(GTK_WIDGET(webView), &alloc); 985 webkit_web_view_load_string(webView, layoutAndDataTables, 0, 0, 0); 986 987 // Manually spin the main context to get the accessible objects 988 while (g_main_context_pending(0)) 989 g_main_context_iteration(0, TRUE); 990 991 AtkObject* obj = gtk_widget_get_accessible(GTK_WIDGET(webView)); 992 g_assert(obj); 993 994 // Check the non-layout table (data table) 995 996 AtkObject* table1 = atk_object_ref_accessible_child(obj, 0); 997 g_assert(ATK_IS_TABLE(table1)); 998 AtkAttributeSet* set1 = atk_object_get_attributes(table1); 999 g_assert(set1); 1000 g_assert(!atkAttributeSetContainsAttributeName(set1, "layout-guess")); 1001 atk_attribute_set_free(set1); 1002 1003 // Check the layout table 1004 1005 AtkObject* table2 = atk_object_ref_accessible_child(obj, 1); 1006 g_assert(ATK_IS_TABLE(table2)); 1007 AtkAttributeSet* set2 = atk_object_get_attributes(table2); 1008 g_assert(set2); 1009 g_assert(atkAttributeSetContainsAttributeName(set2, "layout-guess")); 1010 g_assert(atkAttributeSetAttributeNameHasValue(set2, "layout-guess", "true")); 1011 atk_attribute_set_free(set2); 1012 1013 g_object_unref(table1); 1014 g_object_unref(table2); 1015 g_object_unref(webView); 1016 } 1017 967 1018 static void testWebkitAtkListsOfItems(void) 968 1019 { … … 1117 1168 g_test_add_func("/webkit/atk/textSelections", testWekitAtkTextSelections); 1118 1169 g_test_add_func("/webkit/atk/getExtents", testWebkitAtkGetExtents); 1170 g_test_add_func("/webkit/atk/layoutAndDataTables", testWebkitAtkLayoutAndDataTables); 1119 1171 g_test_add_func("/webkit/atk/listsOfItems", testWebkitAtkListsOfItems); 1120 1172 g_test_add_func("/webkit/atk/textChangedNotifications", testWebkitAtkTextChangedNotifications);
Note: See TracChangeset
for help on using the changeset viewer.