B2G/gecko/accessible/tests/mochitest/table.js
/**
 * Test selectRow method of accessible table.
 */
Test selectRow method of accessible table.
Test selectRow method of accessible table .
function testSelectTableRow(aIdentifier, aRowIdx, aCellsArray)
{
  var acc = getAccessible(aIdentifier, [nsIAccessibleTable]);
  if (!acc)
    return;
  var rowCount = aCellsArray.length;
  var colsCount = aCellsArray[0].length;
  for (var rowIdx = 0; rowIdx < rowCount; rowIdx++) {
    for (var colIdx = 0; colIdx < colsCount; colIdx++) {
      var cellState = aCellsArray[rowIdx][colIdx];
      if (rowIdx == aRowIdx) { 
        if (!(cellState & kSpanned)) {
          aCellsArray[rowIdx][colIdx] = true;
        } else {
          var [origRowIdx, origColIdx] = getOrigRowAndColumn(aCellsArray,
                                                             rowIdx, colIdx);
          aCellsArray[origRowIdx][origColIdx] = true;
        }
      } else if (!(cellState & kSpanned)) { 
        if (rowIdx > aRowIdx) {
          aCellsArray[rowIdx][colIdx] = false;
        } else if (!(aCellsArray[aRowIdx][colIdx] & kRowSpanned)) {
          aCellsArray[rowIdx][colIdx] = false;
        } else {
          for (var spannedRowIdx = rowIdx + 1; spannedRowIdx < aRowIdx;
               spannedRowIdx++) {
            var spannedCellState = aCellsArray[spannedRowIdx][colIdx];
            if (!(spannedCellState & kRowSpanned)) {
              aCellsArray[rowIdx][colIdx] = false;
              break;
            }
          }
        }
      }
    }
  }
  acc.selectRow(aRowIdx);
  testTableSelection(aIdentifier, aCellsArray,
                     "Select " + aRowIdx + " row: ");
}
function testSelectTableRow ( aIdentifier , aRowIdx , aCellsArray ) { var acc = getAccessible ( aIdentifier , [ nsIAccessibleTable ] ) ; if ( ! acc ) return ; var rowCount = aCellsArray . length ; var colsCount = aCellsArray [ 0 ] . length ; for ( var rowIdx = 0 ; rowIdx < rowCount ; rowIdx ++ ) { for ( var colIdx = 0 ; colIdx < colsCount ; colIdx ++ ) { var cellState = aCellsArray [ rowIdx ] [ colIdx ] ; if ( rowIdx == aRowIdx ) { if ( ! ( cellState & kSpanned ) ) { aCellsArray [ rowIdx ] [ colIdx ] = true ; } else { var [ origRowIdx , origColIdx ] = getOrigRowAndColumn ( aCellsArray , rowIdx , colIdx ) ; aCellsArray [ origRowIdx ] [ origColIdx ] = true ; } } else if ( ! ( cellState & kSpanned ) ) { if ( rowIdx > aRowIdx ) { aCellsArray [ rowIdx ] [ colIdx ] = false ; } else if ( ! ( aCellsArray [ aRowIdx ] [ colIdx ] & kRowSpanned ) ) { aCellsArray [ rowIdx ] [ colIdx ] = false ; } else { for ( var spannedRowIdx = rowIdx + 1 ; spannedRowIdx < aRowIdx ; spannedRowIdx ++ ) { var spannedCellState = aCellsArray [ spannedRowIdx ] [ colIdx ] ; if ( ! ( spannedCellState & kRowSpanned ) ) { aCellsArray [ rowIdx ] [ colIdx ] = false ; break ; } } } } } } acc . selectRow ( aRowIdx ) ; testTableSelection ( aIdentifier , aCellsArray , "Select " + aRowIdx + " row: " ) ; }
Test selectRow method of accessible table.
Test selectRow method of accessible table .
// select the given row // Select the cell if it is origin. // If the cell is spanned then search origin cell and select it. // unselect other rows // Unselect the cell if traversed row index is greater than row // index of target cell. // Unselect the cell if the target cell is not row spanned. // Unselect the cell if it is not spanned to the target cell.