AX: Calling NSAccessibilityColumnsAttribute and NSAccessibilityRowsAttribute simply...
authorsamuel_white@apple.com <samuel_white@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Nov 2013 18:57:11 +0000 (18:57 +0000)
committersamuel_white@apple.com <samuel_white@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Nov 2013 18:57:11 +0000 (18:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=124293

Reviewed by Chris Fleizach.

Source/WebCore:

Added ability to get accessibility table column or row count without fetching all columns or rows.

Test: platform/mac/accessibility/table-column-and-row-count.html

* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper accessibilityAttributeNames]):
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):

LayoutTests:

Added test to ensure NSAccessibilityColumnsAttribute and NSAccessibilityRowsAttribute
behave as expected. Also updated existing table tests to reflect this additional API.

* platform/mac/accessibility/table-column-and-row-count-expected.txt: Added.
* platform/mac/accessibility/table-column-and-row-count.html: Added.
* platform/mac/accessibility/table-detection-expected.txt:
* platform/mac/accessibility/table-with-rules-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@159295 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/platform/mac/accessibility/table-column-and-row-count-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/accessibility/table-column-and-row-count.html [new file with mode: 0644]
LayoutTests/platform/mac/accessibility/table-detection-expected.txt
LayoutTests/platform/mac/accessibility/table-with-rules-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm

index 5d91b72..f3a56d9 100644 (file)
@@ -1,3 +1,18 @@
+2013-11-14  Samuel White  <samuel_white@apple.com>
+
+        AX: Calling NSAccessibilityColumnsAttribute and NSAccessibilityRowsAttribute simply to get column/row count can be very expensive.
+        https://bugs.webkit.org/show_bug.cgi?id=124293
+
+        Reviewed by Chris Fleizach.
+
+        Added test to ensure NSAccessibilityColumnsAttribute and NSAccessibilityRowsAttribute
+        behave as expected. Also updated existing table tests to reflect this additional API.
+
+        * platform/mac/accessibility/table-column-and-row-count-expected.txt: Added.
+        * platform/mac/accessibility/table-column-and-row-count.html: Added.
+        * platform/mac/accessibility/table-detection-expected.txt:
+        * platform/mac/accessibility/table-with-rules-expected.txt:
+
 2013-11-14  Alexey Proskuryakov  <ap@apple.com>
 
         Implement RSASSA-PKCS1-v1_5 sign/verify
diff --git a/LayoutTests/platform/mac/accessibility/table-column-and-row-count-expected.txt b/LayoutTests/platform/mac/accessibility/table-column-and-row-count-expected.txt
new file mode 100644 (file)
index 0000000..2ba622c
--- /dev/null
@@ -0,0 +1,18 @@
+Bill Ted
+100 99
+
+Bill   Ted
+100    99
+This tests that tables return their column and row count correctly.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS columnCount is 2
+PASS rowCount is 2
+PASS columnCount is 2
+PASS rowCount is 2
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/mac/accessibility/table-column-and-row-count.html b/LayoutTests/platform/mac/accessibility/table-column-and-row-count.html
new file mode 100644 (file)
index 0000000..4373afa
--- /dev/null
@@ -0,0 +1,56 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+<title>Table Column and Row Count</title>
+</head>
+<body>
+
+<!-- ARIA table. -->
+<div class="test" id="t0" role="grid">
+<div role="row">
+<span role="columnheader">Bill</span>
+<span role="columnheader">Ted</span>
+</div>
+<div role="row">
+<span role="gridcell">100</span>
+<span role="gridcell">99</span>
+</div>
+</div>
+
+<br>
+
+<!-- HTML table. -->
+<table class="test" id="t1">
+<tr>
+<th>Bill</th>
+<th>Ted</th>
+</tr>
+<tr>
+<td>100</td>
+<td>99</td>
+</tr>
+<table>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+    description("This tests that tables return their column and row count correctly.");
+    
+    if (window.accessibilityController) {
+        var testCount = document.getElementsByClassName("test").length;
+        for (var i = 0; i < testCount; ++i) {
+            var test = accessibilityController.accessibleElementById("t" + i);
+            var columnCount = test.numberAttributeValue("AXColumnCount");
+            shouldBe("columnCount", "2");
+            
+            var rowCount = test.numberAttributeValue("AXRowCount");
+            shouldBe("rowCount", "2");
+        }
+    }
+</script>
+
+<script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
index e3c6e87..21118df 100644 (file)
@@ -33,6 +33,8 @@ AXVisibleCells: <array of size 4>
 AXColumnHeaderUIElements: <array of size 2>
 AXRowHeaderUIElements: <array of size 0>
 AXHeader: <AXTable>
+AXColumnCount: 2
+AXRowCount: 2
 AXElementBusy: 0
 
 
@@ -73,6 +75,8 @@ AXVisibleCells: <array of size 2>
 AXColumnHeaderUIElements: <array of size 0>
 AXRowHeaderUIElements: <array of size 0>
 AXHeader: <AXTable>
+AXColumnCount: 2
+AXRowCount: 1
 AXElementBusy: 0
 
 
@@ -144,6 +148,8 @@ AXVisibleCells: <array of size 2>
 AXColumnHeaderUIElements: <array of size 0>
 AXRowHeaderUIElements: <array of size 0>
 AXHeader: <AXTable>
+AXColumnCount: 2
+AXRowCount: 1
 AXElementBusy: 0
 
 
@@ -183,6 +189,8 @@ AXVisibleCells: <array of size 2>
 AXColumnHeaderUIElements: <array of size 0>
 AXRowHeaderUIElements: <array of size 0>
 AXHeader: <AXTable>
+AXColumnCount: 2
+AXRowCount: 1
 AXElementBusy: 0
 
 
@@ -222,6 +230,8 @@ AXVisibleCells: <array of size 4>
 AXColumnHeaderUIElements: <array of size 0>
 AXRowHeaderUIElements: <array of size 0>
 AXHeader: <AXTable>
+AXColumnCount: 2
+AXRowCount: 2
 AXElementBusy: 0
 
 
@@ -262,6 +272,8 @@ AXVisibleCells: <array of size 2>
 AXColumnHeaderUIElements: <array of size 0>
 AXRowHeaderUIElements: <array of size 0>
 AXHeader: <AXTable>
+AXColumnCount: 2
+AXRowCount: 1
 AXElementBusy: 0
 
 
@@ -365,6 +377,8 @@ AXVisibleCells: <array of size 2>
 AXColumnHeaderUIElements: <array of size 0>
 AXRowHeaderUIElements: <array of size 0>
 AXHeader: <AXTable>
+AXColumnCount: 2
+AXRowCount: 1
 AXElementBusy: 0
 
 
@@ -474,6 +488,8 @@ AXVisibleCells: <array of size 2>
 AXColumnHeaderUIElements: <array of size 0>
 AXRowHeaderUIElements: <array of size 0>
 AXHeader: <AXTable>
+AXColumnCount: 2
+AXRowCount: 1
 AXElementBusy: 0
 
 
@@ -513,6 +529,8 @@ AXVisibleCells: <array of size 4>
 AXColumnHeaderUIElements: <array of size 0>
 AXRowHeaderUIElements: <array of size 0>
 AXHeader: <AXTable>
+AXColumnCount: 2
+AXRowCount: 2
 AXElementBusy: 0
 
 
@@ -586,6 +604,8 @@ AXVisibleCells: <array of size 6>
 AXColumnHeaderUIElements: <array of size 0>
 AXRowHeaderUIElements: <array of size 0>
 AXHeader: <AXTable>
+AXColumnCount: 2
+AXRowCount: 3
 AXElementBusy: 0
 
 
@@ -627,6 +647,8 @@ AXVisibleCells: <array of size 6>
 AXColumnHeaderUIElements: <array of size 0>
 AXRowHeaderUIElements: <array of size 0>
 AXHeader: <AXTable>
+AXColumnCount: 2
+AXRowCount: 3
 AXElementBusy: 0
 
 
@@ -668,6 +690,8 @@ AXVisibleCells: <array of size 4>
 AXColumnHeaderUIElements: <array of size 0>
 AXRowHeaderUIElements: <array of size 0>
 AXHeader: <AXTable>
+AXColumnCount: 2
+AXRowCount: 2
 AXElementBusy: 0
 
 
@@ -708,6 +732,8 @@ AXVisibleCells: <array of size 24>
 AXColumnHeaderUIElements: <array of size 0>
 AXRowHeaderUIElements: <array of size 0>
 AXHeader: <AXTable>
+AXColumnCount: 1
+AXRowCount: 24
 AXElementBusy: 0
 
 
index eb38f52..9fc83d5 100644 (file)
@@ -37,6 +37,8 @@ AXVisibleCells: <array of size 2>
 AXColumnHeaderUIElements: <array of size 0>
 AXRowHeaderUIElements: <array of size 0>
 AXHeader: <AXTable>
+AXColumnCount: 2
+AXRowCount: 1
 AXElementBusy: 0
 
 
@@ -72,6 +74,8 @@ AXVisibleCells: <array of size 2>
 AXColumnHeaderUIElements: <array of size 0>
 AXRowHeaderUIElements: <array of size 0>
 AXHeader: <AXTable>
+AXColumnCount: 2
+AXRowCount: 1
 AXElementBusy: 0
 
 
@@ -107,6 +111,8 @@ AXVisibleCells: <array of size 2>
 AXColumnHeaderUIElements: <array of size 0>
 AXRowHeaderUIElements: <array of size 0>
 AXHeader: <AXTable>
+AXColumnCount: 2
+AXRowCount: 1
 AXElementBusy: 0
 
 
index 502a222..310d17c 100644 (file)
@@ -1,3 +1,18 @@
+2013-11-14  Samuel White  <samuel_white@apple.com>
+
+        AX: Calling NSAccessibilityColumnsAttribute and NSAccessibilityRowsAttribute simply to get column/row count can be very expensive.
+        https://bugs.webkit.org/show_bug.cgi?id=124293
+
+        Reviewed by Chris Fleizach.
+
+        Added ability to get accessibility table column or row count without fetching all columns or rows.
+
+        Test: platform/mac/accessibility/table-column-and-row-count.html
+
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (-[WebAccessibilityObjectWrapper accessibilityAttributeNames]):
+        (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
+
 2013-11-14  Alexey Proskuryakov  <ap@apple.com>
 
         Implement RSASSA-PKCS1-v1_5 sign/verify
index 450734f..5f61dca 100644 (file)
@@ -1309,6 +1309,8 @@ static id textMarkerRangeFromVisiblePositions(AXObjectCache *cache, VisiblePosit
         [tempArray addObject:(NSString *)kAXColumnHeaderUIElementsAttribute];
         [tempArray addObject:NSAccessibilityRowHeaderUIElementsAttribute];
         [tempArray addObject:NSAccessibilityHeaderAttribute];
+        [tempArray addObject:NSAccessibilityColumnCountAttribute];
+        [tempArray addObject:NSAccessibilityRowCountAttribute];
         tableAttrs = [[NSArray alloc] initWithArray:tempArray];
         [tempArray release];
     }
@@ -2397,6 +2399,12 @@ static NSString* roleValueToNSString(AccessibilityRole value)
             toAccessibilityTable(m_object)->cells(cells);
             return convertToNSArray(cells);
         }
+        
+        if ([attributeName isEqualToString:NSAccessibilityColumnCountAttribute])
+            return @(toAccessibilityTable(m_object)->columnCount());
+        
+        if ([attributeName isEqualToString:NSAccessibilityRowCountAttribute])
+            return @(toAccessibilityTable(m_object)->rowCount());
     }
     
     if (m_object->isTableColumn()) {