Commit 5732f0bc authored by David Tseng's avatar David Tseng Committed by Commit Bot

provide output for table column headers

Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I364949b358db73b125d7687b73bf2239648352d1
Reviewed-on: https://chromium-review.googlesource.com/887426Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarMichael Giuffrida <michaelpg@chromium.org>
Commit-Queue: David Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532918}
parent f38cfe3c
...@@ -1394,3 +1394,43 @@ TEST_F('BackgroundTest', 'TextSelectionAndLiveRegion', function() { ...@@ -1394,3 +1394,43 @@ TEST_F('BackgroundTest', 'TextSelectionAndLiveRegion', function() {
.replay(); .replay();
}); });
}); });
TEST_F('BackgroundTest', 'TableColumnHeaders', function() {
var mockFeedback = this.createMockFeedback();
this.runWithLoadedTree(function(root) {/*!
<div role="grid">
<div role="rowgroup">
<div role="row">
<div role="columnheader">city</div>
<div role="columnheader">state</div>
<div role="columnheader">zip</div>
</div>
</div>
<div role="rowgroup">
<div role="row">
<div role="gridcell">Mountain View</div>
<div role="gridcell">CA</div>
<div role="gridcell">94043</div>
</div>
<div role="row">
<div role="gridcell">San Jose</div>
<div role="gridcell">CA</div>
<div role="gridcell">95128</div>
</div>
</div>
</div>
*/}, function(root) {
mockFeedback.call(doCmd('nextRow'))
.expectSpeech('Mountain View', 'row 2 column 1')
.call(doCmd('nextRow'))
.expectNextSpeechUtteranceIsNot('city')
.expectSpeech('San Jose', 'row 3 column 1')
.call(doCmd('nextCol'))
.expectSpeech('CA', 'row 3 column 2', 'state')
.call(doCmd('previousRow'))
.expectSpeech('CA', 'row 2 column 2')
.call(doCmd('previousRow'))
.expectSpeech('state', 'row 1 column 2')
.replay();
});
});
...@@ -1211,10 +1211,41 @@ Output.prototype = { ...@@ -1211,10 +1211,41 @@ Output.prototype = {
buff); buff);
} }
} else if (token == 'node') { } else if (token == 'node') {
if (!tree.firstChild || !node[tree.firstChild.value]) if (!tree.firstChild)
return; return;
var related = node[tree.firstChild.value];
this.node_(related, related, Output.EventType.NAVIGATE, buff); var relationName = tree.firstChild.value;
if (node[relationName]) {
var related = node[relationName];
this.node_(related, related, Output.EventType.NAVIGATE, buff);
} else if (
relationName == 'tableColumnHeader' &&
node.role == RoleType.CELL) {
// Because table columns do not contain cells as descendants, we
// must search for the correct column.
var columnIndex = node.tableCellColumnIndex;
if (opt_prevNode) {
// Skip output when previous position falls on the same column.
while (opt_prevNode &&
!AutomationPredicate.cellLike(opt_prevNode)) {
opt_prevNode = opt_prevNode.parent;
}
if (opt_prevNode &&
opt_prevNode.tableCellColumnIndex == columnIndex)
return;
}
var tableLike = node.parent && node.parent.parent;
if (!tableLike || !AutomationPredicate.table(tableLike))
return;
var column = tableLike.children.find(function(candidate) {
return columnIndex === candidate.tableColumnIndex;
});
if (column && column.tableColumnHeader &&
column.tableColumnHeader.name) {
this.append_(buff, column.tableColumnHeader.name, options);
}
}
} else if (token == 'nameOrTextContent') { } else if (token == 'nameOrTextContent') {
if (node.name) { if (node.name) {
this.format_(node, '$name', buff); this.format_(node, '$name', buff);
......
...@@ -611,6 +611,12 @@ ...@@ -611,6 +611,12 @@
// The corresponding row header for this cell. // The corresponding row header for this cell.
AutomationNode? tableRowHeader; AutomationNode? tableRowHeader;
// The column index of this column node.
long? tableColumnIndex;
// The row index of this row node.
long? tableRowIndex;
// //
// Live region attributes. // Live region attributes.
// //
......
...@@ -837,6 +837,20 @@ chrome.automation.AutomationNode.prototype.tableColumnHeader; ...@@ -837,6 +837,20 @@ chrome.automation.AutomationNode.prototype.tableColumnHeader;
*/ */
chrome.automation.AutomationNode.prototype.tableRowHeader; chrome.automation.AutomationNode.prototype.tableRowHeader;
/**
* The column index of this column node.
* @type {(number|undefined)}
* @see https://developer.chrome.com/extensions/automation#type-tableColumnIndex
*/
chrome.automation.AutomationNode.prototype.tableColumnIndex;
/**
* The row index of this row node.
* @type {(number|undefined)}
* @see https://developer.chrome.com/extensions/automation#type-tableRowIndex
*/
chrome.automation.AutomationNode.prototype.tableRowIndex;
/** /**
* The type of region if this is the root of a live region. Possible values are 'polite' and 'assertive'. * The type of region if this is the root of a live region. Possible values are 'polite' and 'assertive'.
* @type {(string|undefined)} * @type {(string|undefined)}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment