summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2014-08-08 10:50:13 +0200
committerMichael Bruning <michael.bruning@digia.com>2014-10-08 14:46:40 +0200
commit7f825cfa69cec97d14c875e43959c46996a716b9 (patch)
treed361affc84b547be395859e04be5e495aaa8dddb
parent58806890b496aef7c2880e651a8bb73b090cd72a (diff)
downloadqtwebengine-7f825cfa69cec97d14c875e43959c46996a716b9.tar.gz
Accessibility: Table interface
This is used to represent tables, lists and trees to screen readers. There are some properties still not implemented, notably selection which is also not available in blink. Change-Id: I57053881445e39a4967a1aabd85a594271402f63 Reviewed-by: Zeno Albisser <zeno.albisser@digia.com> Reviewed-by: Andras Becsi <andras.becsi@digia.com> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
-rw-r--r--src/core/browser_accessibility_qt.cpp196
-rw-r--r--src/core/browser_accessibility_qt.h36
2 files changed, 232 insertions, 0 deletions
diff --git a/src/core/browser_accessibility_qt.cpp b/src/core/browser_accessibility_qt.cpp
index 405bafb94..b5cd26f2f 100644
--- a/src/core/browser_accessibility_qt.cpp
+++ b/src/core/browser_accessibility_qt.cpp
@@ -173,6 +173,22 @@ void *BrowserAccessibilityQt::interface_cast(QAccessible::InterfaceType type)
return static_cast<QAccessibleValueInterface*>(this);
break;
}
+ case QAccessible::TableInterface: {
+ QAccessible::Role r = role();
+ if (r == QAccessible::Table ||
+ r == QAccessible::List ||
+ r == QAccessible::Tree)
+ return static_cast<QAccessibleTableInterface*>(this);
+ break;
+ }
+ case QAccessible::TableCellInterface: {
+ QAccessible::Role r = role();
+ if (r == QAccessible::Cell ||
+ r == QAccessible::ListItem ||
+ r == QAccessible::TreeItem)
+ return static_cast<QAccessibleTableCellInterface*>(this);
+ break;
+ }
default:
break;
}
@@ -701,4 +717,184 @@ QVariant BrowserAccessibilityQt::minimumStepSize() const
return QVariant();
}
+QAccessibleInterface *BrowserAccessibilityQt::cellAt(int row, int column) const
+{
+ int columns = 0;
+ int rows = 0;
+ if (!GetIntAttribute(ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns) ||
+ !GetIntAttribute(ui::AX_ATTR_TABLE_ROW_COUNT, &rows) ||
+ columns <= 0 ||
+ rows <= 0) {
+ return 0;
+ }
+
+ if (row < 0 || row >= rows || column < 0 || column >= columns)
+ return 0;
+
+ const std::vector<int32>& cell_ids = GetIntListAttribute(ui::AX_ATTR_CELL_IDS);
+ DCHECK_EQ(columns * rows, static_cast<int>(cell_ids.size()));
+
+ int cell_id = cell_ids[row * columns + column];
+ BrowserAccessibility* cell = manager()->GetFromID(cell_id);
+ if (cell) {
+ QAccessibleInterface *iface = static_cast<BrowserAccessibilityQt*>(cell);
+ return iface;
+ }
+
+ return 0;
+}
+
+QAccessibleInterface *BrowserAccessibilityQt::caption() const
+{
+ return 0;
+}
+
+QAccessibleInterface *BrowserAccessibilityQt::summary() const
+{
+ return 0;
+}
+
+QString BrowserAccessibilityQt::columnDescription(int column) const
+{
+ return QString();
+}
+
+QString BrowserAccessibilityQt::rowDescription(int row) const
+{
+ return QString();
+}
+
+int BrowserAccessibilityQt::columnCount() const
+{
+ int columns = 0;
+ if (GetIntAttribute(ui::AX_ATTR_TABLE_COLUMN_COUNT, &columns))
+ return columns;
+
+ return 0;
+}
+
+int BrowserAccessibilityQt::rowCount() const
+{
+ int rows = 0;
+ if (GetIntAttribute(ui::AX_ATTR_TABLE_ROW_COUNT, &rows))
+ return rows;
+ return 0;
+}
+
+int BrowserAccessibilityQt::selectedCellCount() const
+{
+ return 0;
+}
+
+int BrowserAccessibilityQt::selectedColumnCount() const
+{
+ return 0;
+}
+
+int BrowserAccessibilityQt::selectedRowCount() const
+{
+ return 0;
+}
+
+QList<QAccessibleInterface *> BrowserAccessibilityQt::selectedCells() const
+{
+ return QList<QAccessibleInterface *>();
+}
+
+QList<int> BrowserAccessibilityQt::selectedColumns() const
+{
+ return QList<int>();
+}
+
+QList<int> BrowserAccessibilityQt::selectedRows() const
+{
+ return QList<int>();
+}
+
+bool BrowserAccessibilityQt::isColumnSelected(int /*column*/) const
+{
+ return false;
+}
+
+bool BrowserAccessibilityQt::isRowSelected(int /*row*/) const
+{
+ return false;
+}
+
+bool BrowserAccessibilityQt::selectRow(int /*row*/)
+{
+ return false;
+}
+
+bool BrowserAccessibilityQt::selectColumn(int /*column*/)
+{
+ return false;
+}
+
+bool BrowserAccessibilityQt::unselectRow(int /*row*/)
+{
+ return false;
+}
+
+bool BrowserAccessibilityQt::unselectColumn(int /*column*/)
+{
+ return false;
+}
+
+int BrowserAccessibilityQt::columnExtent() const
+{
+ return 1;
+}
+
+QList<QAccessibleInterface *> BrowserAccessibilityQt::columnHeaderCells() const
+{
+ return QList<QAccessibleInterface*>();
+}
+
+int BrowserAccessibilityQt::columnIndex() const
+{
+ int column = 0;
+ if (GetIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX, &column))
+ return column;
+ return 0;
+}
+
+int BrowserAccessibilityQt::rowExtent() const
+{
+ return 1;
+}
+
+QList<QAccessibleInterface *> BrowserAccessibilityQt::rowHeaderCells() const
+{
+ return QList<QAccessibleInterface*>();
+}
+
+int BrowserAccessibilityQt::rowIndex() const
+{
+ int row = 0;
+ if (GetIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_INDEX, &row))
+ return row;
+ return 0;
+}
+
+bool BrowserAccessibilityQt::isSelected() const
+{
+ return false;
+}
+
+QAccessibleInterface *BrowserAccessibilityQt::table() const
+{
+ BrowserAccessibility* find_table = GetParent();
+ while (find_table && find_table->GetRole() != ui::AX_ROLE_TABLE)
+ find_table = find_table->GetParent();
+ if (!find_table)
+ return 0;
+ return static_cast<BrowserAccessibilityQt*>(find_table);
+}
+
+void BrowserAccessibilityQt::modelChange(QAccessibleTableModelChangeEvent *)
+{
+
+}
+
} // namespace content
diff --git a/src/core/browser_accessibility_qt.h b/src/core/browser_accessibility_qt.h
index 8dfffdcff..db190ffc4 100644
--- a/src/core/browser_accessibility_qt.h
+++ b/src/core/browser_accessibility_qt.h
@@ -48,6 +48,8 @@ class BrowserAccessibilityQt
, public QAccessibleActionInterface
, public QAccessibleTextInterface
, public QAccessibleValueInterface
+ , public QAccessibleTableInterface
+ , public QAccessibleTableCellInterface
{
public:
BrowserAccessibilityQt();
@@ -105,6 +107,40 @@ public:
QVariant maximumValue() const Q_DECL_OVERRIDE;
QVariant minimumValue() const Q_DECL_OVERRIDE;
QVariant minimumStepSize() const Q_DECL_OVERRIDE;
+
+ // QAccessibleTableInterface
+ virtual QAccessibleInterface *cellAt(int row, int column) const Q_DECL_OVERRIDE;
+ virtual QAccessibleInterface *caption() const Q_DECL_OVERRIDE;
+ virtual QAccessibleInterface *summary() const Q_DECL_OVERRIDE;
+ virtual QString columnDescription(int column) const Q_DECL_OVERRIDE;
+ virtual QString rowDescription(int row) const Q_DECL_OVERRIDE;
+ virtual int columnCount() const Q_DECL_OVERRIDE;
+ virtual int rowCount() const Q_DECL_OVERRIDE;
+ // selection
+ virtual int selectedCellCount() const Q_DECL_OVERRIDE;
+ virtual int selectedColumnCount() const Q_DECL_OVERRIDE;
+ virtual int selectedRowCount() const Q_DECL_OVERRIDE;
+ virtual QList<QAccessibleInterface*> selectedCells() const Q_DECL_OVERRIDE;
+ virtual QList<int> selectedColumns() const Q_DECL_OVERRIDE;
+ virtual QList<int> selectedRows() const Q_DECL_OVERRIDE;
+ virtual bool isColumnSelected(int column) const Q_DECL_OVERRIDE;
+ virtual bool isRowSelected(int row) const Q_DECL_OVERRIDE;
+ virtual bool selectRow(int row) Q_DECL_OVERRIDE;
+ virtual bool selectColumn(int column) Q_DECL_OVERRIDE;
+ virtual bool unselectRow(int row) Q_DECL_OVERRIDE;
+ virtual bool unselectColumn(int column) Q_DECL_OVERRIDE;
+
+ // QAccessibleTableCellInterface
+ virtual int columnExtent() const Q_DECL_OVERRIDE;
+ virtual QList<QAccessibleInterface*> columnHeaderCells() const Q_DECL_OVERRIDE;
+ virtual int columnIndex() const Q_DECL_OVERRIDE;
+ virtual int rowExtent() const Q_DECL_OVERRIDE;
+ virtual QList<QAccessibleInterface*> rowHeaderCells() const Q_DECL_OVERRIDE;
+ virtual int rowIndex() const Q_DECL_OVERRIDE;
+ virtual bool isSelected() const Q_DECL_OVERRIDE;
+ virtual QAccessibleInterface* table() const Q_DECL_OVERRIDE;
+
+ virtual void modelChange(QAccessibleTableModelChangeEvent *event) Q_DECL_OVERRIDE;
};
}