зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1835967: Remove TableAccessibleBase::Select/UnselectCol/Row. r=nlapre
Differential Revision: https://phabricator.services.mozilla.com/D179513
This commit is contained in:
Родитель
f08e08b87c
Коммит
bd9bd8733b
|
@ -216,38 +216,6 @@ Accessible* CachedTableAccessible::CellAt(uint32_t aRowIdx, uint32_t aColIdx) {
|
|||
return mCells[cellIdx].Acc(mAcc);
|
||||
}
|
||||
|
||||
void CachedTableAccessible::SelectCol(uint32_t aColIdx) {
|
||||
if (LocalAccessible* localAcc = mAcc->AsLocal()) {
|
||||
TableAccessible* table = localAcc->AsTable();
|
||||
table->SelectCol(aColIdx);
|
||||
}
|
||||
// XXX Implement support for RemoteAccessible.
|
||||
}
|
||||
|
||||
void CachedTableAccessible::UnselectCol(uint32_t aColIdx) {
|
||||
if (LocalAccessible* localAcc = mAcc->AsLocal()) {
|
||||
TableAccessible* table = localAcc->AsTable();
|
||||
table->UnselectCol(aColIdx);
|
||||
}
|
||||
// XXX Implement support for RemoteAccessible.
|
||||
}
|
||||
|
||||
void CachedTableAccessible::SelectRow(uint32_t aRowIdx) {
|
||||
if (LocalAccessible* localAcc = mAcc->AsLocal()) {
|
||||
TableAccessible* table = localAcc->AsTable();
|
||||
table->SelectRow(aRowIdx);
|
||||
}
|
||||
// XXX Implement support for RemoteAccessible.
|
||||
}
|
||||
|
||||
void CachedTableAccessible::UnselectRow(uint32_t aRowIdx) {
|
||||
if (LocalAccessible* localAcc = mAcc->AsLocal()) {
|
||||
TableAccessible* table = localAcc->AsTable();
|
||||
table->UnselectRow(aRowIdx);
|
||||
}
|
||||
// XXX Implement support for RemoteAccessible.
|
||||
}
|
||||
|
||||
bool CachedTableAccessible::IsProbablyLayoutTable() {
|
||||
if (RemoteAccessible* remoteAcc = mAcc->AsRemote()) {
|
||||
return remoteAcc->TableIsProbablyForLayout();
|
||||
|
|
|
@ -256,11 +256,6 @@ class CachedTableAccessible final : public TableAccessibleBase {
|
|||
}
|
||||
}
|
||||
|
||||
virtual void SelectCol(uint32_t aColIdx) override;
|
||||
virtual void SelectRow(uint32_t aRowIdx) override;
|
||||
virtual void UnselectCol(uint32_t aColIdx) override;
|
||||
virtual void UnselectRow(uint32_t aRowIdx) override;
|
||||
|
||||
virtual Accessible* AsAccessible() override { return mAcc; }
|
||||
|
||||
virtual bool IsProbablyLayoutTable() override;
|
||||
|
|
|
@ -155,26 +155,6 @@ class TableAccessibleBase {
|
|||
*/
|
||||
virtual void SelectedRowIndices(nsTArray<uint32_t>* aRows) {}
|
||||
|
||||
/**
|
||||
* Select the given column unselecting any other selected columns.
|
||||
*/
|
||||
virtual void SelectCol(uint32_t aColIdx) {}
|
||||
|
||||
/**
|
||||
* Select the given row unselecting all other previously selected rows.
|
||||
*/
|
||||
virtual void SelectRow(uint32_t aRowIdx) {}
|
||||
|
||||
/**
|
||||
* Unselect the given column leaving other selected columns selected.
|
||||
*/
|
||||
virtual void UnselectCol(uint32_t aColIdx) {}
|
||||
|
||||
/**
|
||||
* Unselect the given row leaving other selected rows selected.
|
||||
*/
|
||||
virtual void UnselectRow(uint32_t aRowIdx) {}
|
||||
|
||||
/**
|
||||
* Return true if the table is probably for layout.
|
||||
*/
|
||||
|
|
|
@ -12,9 +12,6 @@
|
|||
#include "Role.h"
|
||||
#include "States.h"
|
||||
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::a11y;
|
||||
|
||||
|
@ -326,125 +323,6 @@ void ARIAGridAccessible::SelectedRowIndices(nsTArray<uint32_t>* aRows) {
|
|||
}
|
||||
}
|
||||
|
||||
void ARIAGridAccessible::SelectRow(uint32_t aRowIdx) {
|
||||
if (IsARIARole(nsGkAtoms::table)) return;
|
||||
|
||||
AccIterator rowIter(this, filters::GetRow);
|
||||
|
||||
LocalAccessible* row = nullptr;
|
||||
for (uint32_t rowIdx = 0; (row = rowIter.Next()); rowIdx++) {
|
||||
DebugOnly<nsresult> rv = SetARIASelected(row, rowIdx == aRowIdx);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "SetARIASelected() Shouldn't fail!");
|
||||
}
|
||||
}
|
||||
|
||||
void ARIAGridAccessible::SelectCol(uint32_t aColIdx) {
|
||||
if (IsARIARole(nsGkAtoms::table)) return;
|
||||
|
||||
AccIterator rowIter(this, filters::GetRow);
|
||||
|
||||
LocalAccessible* row = nullptr;
|
||||
while ((row = rowIter.Next())) {
|
||||
// Unselect all cells in the row.
|
||||
DebugOnly<nsresult> rv = SetARIASelected(row, false);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "SetARIASelected() Shouldn't fail!");
|
||||
|
||||
// Select cell at the column index.
|
||||
LocalAccessible* cell = CellInRowAt(row, aColIdx);
|
||||
if (cell) SetARIASelected(cell, true);
|
||||
}
|
||||
}
|
||||
|
||||
void ARIAGridAccessible::UnselectRow(uint32_t aRowIdx) {
|
||||
if (IsARIARole(nsGkAtoms::table)) return;
|
||||
|
||||
LocalAccessible* row = RowAt(aRowIdx);
|
||||
if (row) SetARIASelected(row, false);
|
||||
}
|
||||
|
||||
void ARIAGridAccessible::UnselectCol(uint32_t aColIdx) {
|
||||
if (IsARIARole(nsGkAtoms::table)) return;
|
||||
|
||||
AccIterator rowIter(this, filters::GetRow);
|
||||
|
||||
LocalAccessible* row = nullptr;
|
||||
while ((row = rowIter.Next())) {
|
||||
LocalAccessible* cell = CellInRowAt(row, aColIdx);
|
||||
if (cell) SetARIASelected(cell, false);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Protected
|
||||
|
||||
nsresult ARIAGridAccessible::SetARIASelected(LocalAccessible* aAccessible,
|
||||
bool aIsSelected, bool aNotify) {
|
||||
if (IsARIARole(nsGkAtoms::table)) return NS_OK;
|
||||
|
||||
nsIContent* content = aAccessible->GetContent();
|
||||
NS_ENSURE_STATE(content);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
if (content->IsElement()) {
|
||||
if (aIsSelected) {
|
||||
rv = content->AsElement()->SetAttr(
|
||||
kNameSpaceID_None, nsGkAtoms::aria_selected, u"true"_ns, aNotify);
|
||||
} else {
|
||||
rv = content->AsElement()->SetAttr(
|
||||
kNameSpaceID_None, nsGkAtoms::aria_selected, u"false"_ns, aNotify);
|
||||
}
|
||||
}
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// No "smart" select/unselect for internal call.
|
||||
if (!aNotify) return NS_OK;
|
||||
|
||||
// If row or cell accessible was selected then we're able to not bother about
|
||||
// selection of its cells or its row because our algorithm is row oriented,
|
||||
// i.e. we check selection on row firstly and then on cells.
|
||||
if (aIsSelected) return NS_OK;
|
||||
|
||||
roles::Role role = aAccessible->Role();
|
||||
|
||||
// If the given accessible is row that was unselected then remove
|
||||
// aria-selected from cell accessible.
|
||||
if (role == roles::ROW) {
|
||||
AccIterator cellIter(aAccessible, filters::GetCell);
|
||||
LocalAccessible* cell = nullptr;
|
||||
|
||||
while ((cell = cellIter.Next())) {
|
||||
rv = SetARIASelected(cell, false, false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// If the given accessible is cell that was unselected and its row is selected
|
||||
// then remove aria-selected from row and put aria-selected on
|
||||
// siblings cells.
|
||||
if (role == roles::GRID_CELL || role == roles::ROWHEADER ||
|
||||
role == roles::COLUMNHEADER) {
|
||||
LocalAccessible* row = aAccessible->LocalParent();
|
||||
|
||||
if (row && row->Role() == roles::ROW && nsAccUtils::IsARIASelected(row)) {
|
||||
rv = SetARIASelected(row, false, false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
AccIterator cellIter(row, filters::GetCell);
|
||||
LocalAccessible* cell = nullptr;
|
||||
while ((cell = cellIter.Next())) {
|
||||
if (cell != aAccessible) {
|
||||
rv = SetARIASelected(cell, true, false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// ARIARowAccessible
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -44,25 +44,10 @@ class ARIAGridAccessible : public HyperTextAccessibleWrap,
|
|||
virtual void SelectedCellIndices(nsTArray<uint32_t>* aCells) override;
|
||||
virtual void SelectedColIndices(nsTArray<uint32_t>* aCols) override;
|
||||
virtual void SelectedRowIndices(nsTArray<uint32_t>* aRows) override;
|
||||
virtual void SelectCol(uint32_t aColIdx) override;
|
||||
virtual void SelectRow(uint32_t aRowIdx) override;
|
||||
virtual void UnselectCol(uint32_t aColIdx) override;
|
||||
virtual void UnselectRow(uint32_t aRowIdx) override;
|
||||
virtual LocalAccessible* AsAccessible() override { return this; }
|
||||
|
||||
protected:
|
||||
virtual ~ARIAGridAccessible() {}
|
||||
|
||||
/**
|
||||
* Set aria-selected attribute value on DOM node of the given accessible.
|
||||
*
|
||||
* @param aAccessible [in] accessible
|
||||
* @param aIsSelected [in] new value of aria-selected attribute
|
||||
* @param aNotify [in, optional] specifies if DOM should be notified
|
||||
* about attribute change (used internally).
|
||||
*/
|
||||
nsresult SetARIASelected(LocalAccessible* aAccessible, bool aIsSelected,
|
||||
bool aNotify = true);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -747,96 +747,9 @@ bool HTMLTableAccessible::IsCellSelected(uint32_t aRowIdx, uint32_t aColIdx) {
|
|||
return cellFrame ? cellFrame->IsSelected() : false;
|
||||
}
|
||||
|
||||
void HTMLTableAccessible::SelectRow(uint32_t aRowIdx) {
|
||||
DebugOnly<nsresult> rv =
|
||||
RemoveRowsOrColumnsFromSelection(aRowIdx, TableSelectionMode::Row, true);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"RemoveRowsOrColumnsFromSelection() Shouldn't fail!");
|
||||
|
||||
AddRowOrColumnToSelection(aRowIdx, TableSelectionMode::Row);
|
||||
}
|
||||
|
||||
void HTMLTableAccessible::SelectCol(uint32_t aColIdx) {
|
||||
DebugOnly<nsresult> rv = RemoveRowsOrColumnsFromSelection(
|
||||
aColIdx, TableSelectionMode::Column, true);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"RemoveRowsOrColumnsFromSelection() Shouldn't fail!");
|
||||
|
||||
AddRowOrColumnToSelection(aColIdx, TableSelectionMode::Column);
|
||||
}
|
||||
|
||||
void HTMLTableAccessible::UnselectRow(uint32_t aRowIdx) {
|
||||
RemoveRowsOrColumnsFromSelection(aRowIdx, TableSelectionMode::Row, false);
|
||||
}
|
||||
|
||||
void HTMLTableAccessible::UnselectCol(uint32_t aColIdx) {
|
||||
RemoveRowsOrColumnsFromSelection(aColIdx, TableSelectionMode::Column, false);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// HTMLTableAccessible: protected implementation
|
||||
|
||||
nsresult HTMLTableAccessible::AddRowOrColumnToSelection(
|
||||
int32_t aIndex, TableSelectionMode aTarget) {
|
||||
bool doSelectRow = (aTarget == TableSelectionMode::Row);
|
||||
|
||||
nsTableWrapperFrame* tableFrame = GetTableWrapperFrame();
|
||||
if (!tableFrame) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
uint32_t count = 0;
|
||||
if (doSelectRow) {
|
||||
count = ColCount();
|
||||
} else {
|
||||
count = RowCount();
|
||||
}
|
||||
|
||||
PresShell* presShell = mDoc->PresShellPtr();
|
||||
RefPtr<nsFrameSelection> tableSelection =
|
||||
const_cast<nsFrameSelection*>(presShell->ConstFrameSelection());
|
||||
|
||||
for (uint32_t idx = 0; idx < count; idx++) {
|
||||
int32_t rowIdx = doSelectRow ? aIndex : idx;
|
||||
int32_t colIdx = doSelectRow ? idx : aIndex;
|
||||
nsTableCellFrame* cellFrame = tableFrame->GetCellFrameAt(rowIdx, colIdx);
|
||||
if (cellFrame && !cellFrame->IsSelected()) {
|
||||
nsresult rv = tableSelection->SelectCellElement(cellFrame->GetContent());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult HTMLTableAccessible::RemoveRowsOrColumnsFromSelection(
|
||||
int32_t aIndex, TableSelectionMode aTarget, bool aIsOuter) {
|
||||
nsTableWrapperFrame* tableFrame = GetTableWrapperFrame();
|
||||
if (!tableFrame) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PresShell* presShell = mDoc->PresShellPtr();
|
||||
RefPtr<nsFrameSelection> tableSelection =
|
||||
const_cast<nsFrameSelection*>(presShell->ConstFrameSelection());
|
||||
|
||||
bool doUnselectRow = (aTarget == TableSelectionMode::Row);
|
||||
uint32_t count = doUnselectRow ? ColCount() : RowCount();
|
||||
|
||||
int32_t startRowIdx = doUnselectRow ? aIndex : 0;
|
||||
int32_t endRowIdx = doUnselectRow ? aIndex : count - 1;
|
||||
int32_t startColIdx = doUnselectRow ? 0 : aIndex;
|
||||
int32_t endColIdx = doUnselectRow ? count - 1 : aIndex;
|
||||
|
||||
if (aIsOuter) {
|
||||
return tableSelection->RestrictCellsToSelection(
|
||||
mContent, startRowIdx, startColIdx, endRowIdx, endColIdx);
|
||||
}
|
||||
|
||||
return tableSelection->RemoveCellsFromSelection(
|
||||
mContent, startRowIdx, startColIdx, endRowIdx, endColIdx);
|
||||
}
|
||||
|
||||
void HTMLTableAccessible::Description(nsString& aDescription) const {
|
||||
// Helpful for debugging layout vs. data tables
|
||||
aDescription.Truncate();
|
||||
|
|
|
@ -16,8 +16,6 @@ class nsTableWrapperFrame;
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
enum class TableSelectionMode : uint32_t;
|
||||
|
||||
namespace a11y {
|
||||
|
||||
/**
|
||||
|
@ -154,10 +152,6 @@ class HTMLTableAccessible : public HyperTextAccessibleWrap,
|
|||
virtual void SelectedCellIndices(nsTArray<uint32_t>* aCells) override;
|
||||
virtual void SelectedColIndices(nsTArray<uint32_t>* aCols) override;
|
||||
virtual void SelectedRowIndices(nsTArray<uint32_t>* aRows) override;
|
||||
virtual void SelectCol(uint32_t aColIdx) override;
|
||||
virtual void SelectRow(uint32_t aRowIdx) override;
|
||||
virtual void UnselectCol(uint32_t aColIdx) override;
|
||||
virtual void UnselectRow(uint32_t aRowIdx) override;
|
||||
virtual LocalAccessible* AsAccessible() override { return this; }
|
||||
|
||||
// LocalAccessible
|
||||
|
@ -183,29 +177,6 @@ class HTMLTableAccessible : public HyperTextAccessibleWrap,
|
|||
|
||||
// HTMLTableAccessible
|
||||
|
||||
/**
|
||||
* Add row or column to selection.
|
||||
*
|
||||
* @param aIndex [in] index of row or column to be selected
|
||||
* @param aTarget [in] indicates what should be selected, either row or
|
||||
* column (see nsFrameSelection)
|
||||
*/
|
||||
nsresult AddRowOrColumnToSelection(int32_t aIndex,
|
||||
TableSelectionMode aTarget);
|
||||
|
||||
/**
|
||||
* Removes rows or columns at the given index or outside it from selection.
|
||||
*
|
||||
* @param aIndex [in] row or column index
|
||||
* @param aTarget [in] indicates whether row or column should unselected
|
||||
* @param aIsOuter [in] indicates whether all rows or column excepting
|
||||
* the given one should be unselected or the given one
|
||||
* should be unselected only
|
||||
*/
|
||||
nsresult RemoveRowsOrColumnsFromSelection(int32_t aIndex,
|
||||
TableSelectionMode aTarget,
|
||||
bool aIsOuter);
|
||||
|
||||
#ifdef SHOW_LAYOUT_HEURISTIC
|
||||
nsString mLayoutHeuristic;
|
||||
#endif
|
||||
|
|
|
@ -180,34 +180,6 @@ interface nsIAccessibleTable : nsISupports
|
|||
*/
|
||||
Array<uint32_t> getSelectedRowIndices();
|
||||
|
||||
/**
|
||||
* Select a row and unselects all previously selected rows.
|
||||
*
|
||||
* @param rowIndex [in] the row index to select
|
||||
*/
|
||||
void selectRow(in long rowIndex);
|
||||
|
||||
/**
|
||||
* Select a column and unselects all previously selected columns.
|
||||
*
|
||||
* @param columnIndex [in] the column index to select
|
||||
*/
|
||||
void selectColumn(in long columnIndex);
|
||||
|
||||
/**
|
||||
* Unselect the given row, leaving other selected rows selected (if any).
|
||||
*
|
||||
* @param rowIndex [in] the row index to select
|
||||
*/
|
||||
void unselectRow(in long rowIndex);
|
||||
|
||||
/**
|
||||
* Unselect the given column, leaving other selected columns selected (if any).
|
||||
*
|
||||
* @param columnIndex [in] the column index to select
|
||||
*/
|
||||
void unselectColumn(in long columnIndex);
|
||||
|
||||
/**
|
||||
* Use heuristics to determine if table is most likely used for layout.
|
||||
*/
|
||||
|
|
|
@ -744,189 +744,6 @@ function testTableSelection(aIdentifier, aCellsArray, aMsg) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test unselectColumn method of accessible table.
|
||||
*/
|
||||
function testUnselectTableColumn(aIdentifier, aColIdx, aCellsArray) {
|
||||
var acc = getAccessible(aIdentifier, [nsIAccessibleTable]);
|
||||
if (!acc) {
|
||||
return;
|
||||
}
|
||||
|
||||
var rowCount = aCellsArray.length;
|
||||
for (var rowIdx = 0; rowIdx < rowCount; rowIdx++) {
|
||||
// Unselect origin cell.
|
||||
var [origRowIdx, origColIdx] = getOrigRowAndColumn(
|
||||
aCellsArray,
|
||||
rowIdx,
|
||||
aColIdx
|
||||
);
|
||||
aCellsArray[origRowIdx][origColIdx] = false;
|
||||
}
|
||||
|
||||
acc.unselectColumn(aColIdx);
|
||||
testTableSelection(
|
||||
aIdentifier,
|
||||
aCellsArray,
|
||||
"Unselect " + aColIdx + " column: "
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test selectColumn method of accessible table.
|
||||
*/
|
||||
function testSelectTableColumn(aIdentifier, aColIdx, 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 (colIdx == aColIdx) {
|
||||
// select target column
|
||||
if (!(cellState & kSpanned)) {
|
||||
// Select the cell if it is origin.
|
||||
aCellsArray[rowIdx][colIdx] = true;
|
||||
} else {
|
||||
// If the cell is spanned then search origin cell and select it.
|
||||
var [origRowIdx, origColIdx] = getOrigRowAndColumn(
|
||||
aCellsArray,
|
||||
rowIdx,
|
||||
colIdx
|
||||
);
|
||||
aCellsArray[origRowIdx][origColIdx] = true;
|
||||
}
|
||||
} else if (!(cellState & kSpanned)) {
|
||||
// unselect other columns
|
||||
if (colIdx > aColIdx) {
|
||||
// Unselect the cell if traversed column index is greater than column
|
||||
// index of target cell.
|
||||
aCellsArray[rowIdx][colIdx] = false;
|
||||
} else if (!(aCellsArray[rowIdx][aColIdx] & kColSpanned)) {
|
||||
// Unselect the cell if the target cell is not row spanned.
|
||||
aCellsArray[rowIdx][colIdx] = false;
|
||||
} else {
|
||||
// Unselect the cell if it is not spanned to the target cell.
|
||||
for (
|
||||
var spannedColIdx = colIdx + 1;
|
||||
spannedColIdx < aColIdx;
|
||||
spannedColIdx++
|
||||
) {
|
||||
var spannedCellState = aCellsArray[rowIdx][spannedColIdx];
|
||||
if (!(spannedCellState & kRowSpanned)) {
|
||||
aCellsArray[rowIdx][colIdx] = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
acc.selectColumn(aColIdx);
|
||||
testTableSelection(
|
||||
aIdentifier,
|
||||
aCellsArray,
|
||||
"Select " + aColIdx + " column: "
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test unselectRow method of accessible table.
|
||||
*/
|
||||
function testUnselectTableRow(aIdentifier, aRowIdx, aCellsArray) {
|
||||
var acc = getAccessible(aIdentifier, [nsIAccessibleTable]);
|
||||
if (!acc) {
|
||||
return;
|
||||
}
|
||||
|
||||
var colsCount = aCellsArray[0].length;
|
||||
for (var colIdx = 0; colIdx < colsCount; colIdx++) {
|
||||
// Unselect origin cell.
|
||||
var [origRowIdx, origColIdx] = getOrigRowAndColumn(
|
||||
aCellsArray,
|
||||
aRowIdx,
|
||||
colIdx
|
||||
);
|
||||
aCellsArray[origRowIdx][origColIdx] = false;
|
||||
}
|
||||
|
||||
acc.unselectRow(aRowIdx);
|
||||
testTableSelection(
|
||||
aIdentifier,
|
||||
aCellsArray,
|
||||
"Unselect " + aRowIdx + " row: "
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
// select the given row
|
||||
if (!(cellState & kSpanned)) {
|
||||
// Select the cell if it is origin.
|
||||
aCellsArray[rowIdx][colIdx] = true;
|
||||
} else {
|
||||
// If the cell is spanned then search origin cell and select it.
|
||||
var [origRowIdx, origColIdx] = getOrigRowAndColumn(
|
||||
aCellsArray,
|
||||
rowIdx,
|
||||
colIdx
|
||||
);
|
||||
|
||||
aCellsArray[origRowIdx][origColIdx] = true;
|
||||
}
|
||||
} else if (!(cellState & kSpanned)) {
|
||||
// unselect other rows
|
||||
if (rowIdx > aRowIdx) {
|
||||
// Unselect the cell if traversed row index is greater than row
|
||||
// index of target cell.
|
||||
aCellsArray[rowIdx][colIdx] = false;
|
||||
} else if (!(aCellsArray[aRowIdx][colIdx] & kRowSpanned)) {
|
||||
// Unselect the cell if the target cell is not row spanned.
|
||||
aCellsArray[rowIdx][colIdx] = false;
|
||||
} else {
|
||||
// Unselect the cell if it is not spanned to the target cell.
|
||||
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 columnHeaderCells and rowHeaderCells of accessible table.
|
||||
*/
|
||||
|
|
|
@ -33,10 +33,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=410052
|
|||
];
|
||||
|
||||
testTableSelection("table", cellsArray);
|
||||
testUnselectTableColumn("table", 3, cellsArray);
|
||||
testUnselectTableRow("table", 3, cellsArray);
|
||||
testSelectTableColumn("table", 0, cellsArray);
|
||||
testSelectTableRow("table", 0, cellsArray);
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////
|
||||
// a bit strange ARIA grid
|
||||
|
@ -47,10 +43,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=410052
|
|||
];
|
||||
|
||||
testTableSelection("grid2", cellsArray);
|
||||
testSelectTableColumn("grid2", 0, cellsArray);
|
||||
testSelectTableRow("grid2", 0, cellsArray);
|
||||
testUnselectTableColumn("grid2", 0, cellsArray);
|
||||
testUnselectTableRow("grid2", 0, cellsArray);
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////
|
||||
// ARIA grid (column and row headers)
|
||||
|
@ -62,10 +54,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=410052
|
|||
];
|
||||
|
||||
testTableSelection("grid3", cellsArray);
|
||||
testSelectTableColumn("grid3", 0, cellsArray);
|
||||
testSelectTableRow("grid3", 0, cellsArray);
|
||||
testUnselectTableColumn("grid3", 0, cellsArray);
|
||||
testUnselectTableRow("grid3", 0, cellsArray);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
|
|
@ -33,24 +33,6 @@
|
|||
|
||||
testTableSelection("table", cellsArray);
|
||||
|
||||
var rowCount = 4;
|
||||
for (let rowIdx = 0; rowIdx < rowCount; rowIdx++)
|
||||
testSelectTableRow("table", rowIdx, cellsArray);
|
||||
|
||||
for (let rowIdx = 0; rowIdx < rowCount; rowIdx++) {
|
||||
testSelectTableRow("table", rowIdx, cellsArray);
|
||||
testUnselectTableRow("table", rowIdx, cellsArray);
|
||||
}
|
||||
|
||||
var columsCount = 8;
|
||||
for (let colIdx = 0; colIdx < columsCount; colIdx++)
|
||||
testSelectTableColumn("table", colIdx, cellsArray);
|
||||
|
||||
for (let colIdx = 0; colIdx < columsCount; colIdx++) {
|
||||
testSelectTableColumn("table", colIdx, cellsArray);
|
||||
testUnselectTableColumn("table", colIdx, cellsArray);
|
||||
}
|
||||
|
||||
var accTable = getAccessible("table", [nsIAccessibleTable]);
|
||||
ok(!accTable.isProbablyForLayout(), "table is not for layout");
|
||||
|
||||
|
@ -87,11 +69,6 @@
|
|||
title="nsHTMLTableAccessible::GetSelectedCells contains index duplicates for spanned rows or columns">
|
||||
Mozilla Bug 501635
|
||||
</a>
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=417929"
|
||||
title="nsIAccessiblTable selectRows does not unselect previously selected rows">
|
||||
Mozilla Bug 417929
|
||||
</a>
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=501659"
|
||||
title="HTML table's isRowSelected/isColumnSelected shouldn't fail if row or column has cell holes">
|
||||
|
|
|
@ -39,8 +39,6 @@
|
|||
];
|
||||
|
||||
testTableSelection("tree", cellsArray);
|
||||
testSelectTableRow("tree", 0, cellsArray);
|
||||
testUnselectTableRow("tree", 0, cellsArray);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
|
|
@ -378,52 +378,16 @@ ia2AccessibleTable::get_isSelected(long aRowIdx, long aColIdx,
|
|||
}
|
||||
|
||||
STDMETHODIMP
|
||||
ia2AccessibleTable::selectRow(long aRowIdx) {
|
||||
TableAccessibleBase* table = TableAcc();
|
||||
if (!table) return CO_E_OBJNOTCONNECTED;
|
||||
|
||||
if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= table->RowCount())
|
||||
return E_INVALIDARG;
|
||||
|
||||
table->SelectRow(aRowIdx);
|
||||
return S_OK;
|
||||
}
|
||||
ia2AccessibleTable::selectRow(long aRowIdx) { return E_NOTIMPL; }
|
||||
|
||||
STDMETHODIMP
|
||||
ia2AccessibleTable::selectColumn(long aColIdx) {
|
||||
TableAccessibleBase* table = TableAcc();
|
||||
if (!table) return CO_E_OBJNOTCONNECTED;
|
||||
|
||||
if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= table->ColCount())
|
||||
return E_INVALIDARG;
|
||||
|
||||
table->SelectCol(aColIdx);
|
||||
return S_OK;
|
||||
}
|
||||
ia2AccessibleTable::selectColumn(long aColIdx) { return E_NOTIMPL; }
|
||||
|
||||
STDMETHODIMP
|
||||
ia2AccessibleTable::unselectRow(long aRowIdx) {
|
||||
TableAccessibleBase* table = TableAcc();
|
||||
if (!table) return CO_E_OBJNOTCONNECTED;
|
||||
|
||||
if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= table->RowCount())
|
||||
return E_INVALIDARG;
|
||||
|
||||
table->UnselectRow(aRowIdx);
|
||||
return S_OK;
|
||||
}
|
||||
ia2AccessibleTable::unselectRow(long aRowIdx) { return E_NOTIMPL; }
|
||||
|
||||
STDMETHODIMP
|
||||
ia2AccessibleTable::unselectColumn(long aColIdx) {
|
||||
TableAccessibleBase* table = TableAcc();
|
||||
if (!table) return CO_E_OBJNOTCONNECTED;
|
||||
|
||||
if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= table->ColCount())
|
||||
return E_INVALIDARG;
|
||||
|
||||
table->UnselectCol(aColIdx);
|
||||
return S_OK;
|
||||
}
|
||||
ia2AccessibleTable::unselectColumn(long aColIdx) { return E_NOTIMPL; }
|
||||
|
||||
STDMETHODIMP
|
||||
ia2AccessibleTable::get_rowColumnExtentsAtIndex(long aCellIdx, long* aRowIdx,
|
||||
|
|
|
@ -361,51 +361,3 @@ xpcAccessibleTable::IsProbablyForLayout(bool* aResult) {
|
|||
*aResult = Intl()->IsProbablyLayoutTable();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessibleTable::SelectColumn(int32_t aColIdx) {
|
||||
if (!Intl()) return NS_ERROR_FAILURE;
|
||||
|
||||
if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= Intl()->ColCount()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
Intl()->SelectCol(aColIdx);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessibleTable::SelectRow(int32_t aRowIdx) {
|
||||
if (!Intl()) return NS_ERROR_FAILURE;
|
||||
|
||||
if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= Intl()->RowCount()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
Intl()->SelectRow(aRowIdx);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessibleTable::UnselectColumn(int32_t aColIdx) {
|
||||
if (!Intl()) return NS_ERROR_FAILURE;
|
||||
|
||||
if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= Intl()->ColCount()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
Intl()->UnselectCol(aColIdx);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
xpcAccessibleTable::UnselectRow(int32_t aRowIdx) {
|
||||
if (!Intl()) return NS_ERROR_FAILURE;
|
||||
|
||||
if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= Intl()->RowCount()) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
Intl()->UnselectRow(aRowIdx);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -56,10 +56,6 @@ class xpcAccessibleTable : public xpcAccessibleHyperText,
|
|||
NS_IMETHOD GetSelectedCellIndices(nsTArray<uint32_t>& aCellsArray) final;
|
||||
NS_IMETHOD GetSelectedColumnIndices(nsTArray<uint32_t>& aColsArray) final;
|
||||
NS_IMETHOD GetSelectedRowIndices(nsTArray<uint32_t>& aRowsArray) final;
|
||||
NS_IMETHOD SelectColumn(int32_t aColIdx) final;
|
||||
NS_IMETHOD SelectRow(int32_t aRowIdx) final;
|
||||
NS_IMETHOD UnselectColumn(int32_t aColIdx) final;
|
||||
NS_IMETHOD UnselectRow(int32_t aRowIdx) final;
|
||||
NS_IMETHOD IsProbablyForLayout(bool* aIsForLayout) final;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -309,40 +309,6 @@ void XULListboxAccessible::SelectedRowIndices(nsTArray<uint32_t>* aRows) {
|
|||
}
|
||||
}
|
||||
|
||||
void XULListboxAccessible::SelectRow(uint32_t aRowIdx) {
|
||||
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
|
||||
Elm()->AsXULMultiSelectControl();
|
||||
NS_ASSERTION(control,
|
||||
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
|
||||
|
||||
RefPtr<dom::Element> item;
|
||||
control->GetItemAtIndex(aRowIdx, getter_AddRefs(item));
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMXULSelectControlItemElement> itemElm =
|
||||
item->AsXULSelectControlItem();
|
||||
control->SelectItem(itemElm);
|
||||
}
|
||||
|
||||
void XULListboxAccessible::UnselectRow(uint32_t aRowIdx) {
|
||||
nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
|
||||
Elm()->AsXULMultiSelectControl();
|
||||
NS_ASSERTION(control,
|
||||
"Doesn't implement nsIDOMXULMultiSelectControlElement.");
|
||||
|
||||
RefPtr<dom::Element> item;
|
||||
control->GetItemAtIndex(aRowIdx, getter_AddRefs(item));
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMXULSelectControlItemElement> itemElm =
|
||||
item->AsXULSelectControlItem();
|
||||
control->RemoveItemFromSelection(itemElm);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// XULListboxAccessible: Widgets
|
||||
|
||||
|
|
|
@ -70,8 +70,6 @@ class XULListboxAccessible : public XULSelectControlAccessible,
|
|||
virtual void SelectedCellIndices(nsTArray<uint32_t>* aCells) override;
|
||||
virtual void SelectedColIndices(nsTArray<uint32_t>* aCols) override;
|
||||
virtual void SelectedRowIndices(nsTArray<uint32_t>* aRows) override;
|
||||
virtual void SelectRow(uint32_t aRowIdx) override;
|
||||
virtual void UnselectRow(uint32_t aRowIdx) override;
|
||||
virtual LocalAccessible* AsAccessible() override { return this; }
|
||||
|
||||
// LocalAccessible
|
||||
|
|
|
@ -149,25 +149,6 @@ bool XULTreeGridAccessible::IsCellSelected(uint32_t aRowIdx, uint32_t aColIdx) {
|
|||
return IsRowSelected(aRowIdx);
|
||||
}
|
||||
|
||||
void XULTreeGridAccessible::SelectRow(uint32_t aRowIdx) {
|
||||
if (!mTreeView) return;
|
||||
|
||||
nsCOMPtr<nsITreeSelection> selection;
|
||||
mTreeView->GetSelection(getter_AddRefs(selection));
|
||||
NS_ASSERTION(selection, "GetSelection() Shouldn't fail!");
|
||||
|
||||
selection->Select(aRowIdx);
|
||||
}
|
||||
|
||||
void XULTreeGridAccessible::UnselectRow(uint32_t aRowIdx) {
|
||||
if (!mTreeView) return;
|
||||
|
||||
nsCOMPtr<nsITreeSelection> selection;
|
||||
mTreeView->GetSelection(getter_AddRefs(selection));
|
||||
|
||||
if (selection) selection->ClearRange(aRowIdx, aRowIdx);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// XULTreeGridAccessible: LocalAccessible implementation
|
||||
|
||||
|
|
|
@ -44,8 +44,6 @@ class XULTreeGridAccessible : public XULTreeAccessible, public TableAccessible {
|
|||
virtual void SelectedCellIndices(nsTArray<uint32_t>* aCells) override;
|
||||
virtual void SelectedColIndices(nsTArray<uint32_t>* aCols) override;
|
||||
virtual void SelectedRowIndices(nsTArray<uint32_t>* aRows) override;
|
||||
virtual void SelectRow(uint32_t aRowIdx) override;
|
||||
virtual void UnselectRow(uint32_t aRowIdx) override;
|
||||
virtual LocalAccessible* AsAccessible() override { return this; }
|
||||
|
||||
// LocalAccessible
|
||||
|
|
Загрузка…
Ссылка в новой задаче