mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1887799 part 2: Implement the UIA GridItem pattern. r=nlapre
Differential Revision: https://phabricator.services.mozilla.com/D208275
This commit is contained in:
parent
24ffdc9724
commit
ff9beda594
@ -22,6 +22,29 @@ async function testGridGetItem(row, col, cellId) {
|
||||
);
|
||||
}
|
||||
|
||||
async function testGridItemProps(id, row, col, rowSpan, colSpan, gridId) {
|
||||
await assignPyVarToUiaWithId(id);
|
||||
await definePyVar("pattern", `getUiaPattern(${id}, "GridItem")`);
|
||||
ok(await runPython(`bool(pattern)`), `${id} has GridItem pattern`);
|
||||
is(await runPython(`pattern.CurrentRow`), row, `${id} has correct Row`);
|
||||
is(await runPython(`pattern.CurrentColumn`), col, `${id} has correct Column`);
|
||||
is(
|
||||
await runPython(`pattern.CurrentRowSpan`),
|
||||
rowSpan,
|
||||
`${id} has correct RowSpan`
|
||||
);
|
||||
is(
|
||||
await runPython(`pattern.CurrentColumnSpan`),
|
||||
colSpan,
|
||||
`${id} has correct ColumnSpan`
|
||||
);
|
||||
is(
|
||||
await runPython(`pattern.CurrentContainingGrid.CurrentAutomationId`),
|
||||
gridId,
|
||||
`${id} ContainingGridItem is ${gridId}`
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the Grid pattern.
|
||||
*/
|
||||
@ -52,3 +75,18 @@ addUiaTask(SNIPPET, async function testGrid() {
|
||||
|
||||
await testPatternAbsent("button", "Grid");
|
||||
});
|
||||
|
||||
/**
|
||||
* Test the GridItem pattern.
|
||||
*/
|
||||
addUiaTask(SNIPPET, async function testGridItem() {
|
||||
await definePyVar("doc", `getDocUia()`);
|
||||
await testGridItemProps("a", 0, 0, 1, 1, "table");
|
||||
await testGridItemProps("b", 0, 1, 1, 1, "table");
|
||||
await testGridItemProps("c", 0, 2, 1, 1, "table");
|
||||
await testGridItemProps("dg", 1, 0, 2, 1, "table");
|
||||
await testGridItemProps("ef", 1, 1, 1, 2, "table");
|
||||
await testGridItemProps("jkl", 3, 0, 1, 3, "table");
|
||||
|
||||
await testPatternAbsent("button", "GridItem");
|
||||
});
|
||||
|
@ -27,6 +27,7 @@ TableCellAccessible* ia2AccessibleTableCell::CellAcc() {
|
||||
// IUnknown
|
||||
IMPL_IUNKNOWN_QUERY_HEAD(ia2AccessibleTableCell)
|
||||
IMPL_IUNKNOWN_QUERY_IFACE(IAccessibleTableCell)
|
||||
IMPL_IUNKNOWN_QUERY_IFACE(IGridItemProvider)
|
||||
IMPL_IUNKNOWN_QUERY_TAIL_INHERITED(ia2AccessibleHypertext)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -11,12 +11,14 @@
|
||||
#include "AccessibleTableCell.h"
|
||||
#include "ia2AccessibleHypertext.h"
|
||||
#include "IUnknownImpl.h"
|
||||
#include "UiaGridItem.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace a11y {
|
||||
class TableCellAccessible;
|
||||
|
||||
class ia2AccessibleTableCell : public IAccessibleTableCell,
|
||||
public UiaGridItem,
|
||||
public ia2AccessibleHypertext {
|
||||
public:
|
||||
// IUnknown
|
||||
|
96
accessible/windows/uia/UiaGridItem.cpp
Normal file
96
accessible/windows/uia/UiaGridItem.cpp
Normal file
@ -0,0 +1,96 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "ia2AccessibleTableCell.h"
|
||||
#include "mozilla/a11y/TableAccessible.h"
|
||||
#include "mozilla/a11y/TableCellAccessible.h"
|
||||
#include "UiaGridItem.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::a11y;
|
||||
|
||||
// UiaGridItem
|
||||
|
||||
TableCellAccessible* UiaGridItem::CellAcc() {
|
||||
auto* derived = static_cast<ia2AccessibleTableCell*>(this);
|
||||
Accessible* acc = derived->Acc();
|
||||
return acc ? acc->AsTableCell() : nullptr;
|
||||
}
|
||||
|
||||
// IGridItemProvider methods
|
||||
|
||||
STDMETHODIMP
|
||||
UiaGridItem::get_Row(__RPC__out int* aRetVal) {
|
||||
if (!aRetVal) {
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
TableCellAccessible* cell = CellAcc();
|
||||
if (!cell) {
|
||||
return CO_E_OBJNOTCONNECTED;
|
||||
}
|
||||
*aRetVal = cell->RowIdx();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP
|
||||
UiaGridItem::get_Column(__RPC__out int* aRetVal) {
|
||||
if (!aRetVal) {
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
TableCellAccessible* cell = CellAcc();
|
||||
if (!cell) {
|
||||
return CO_E_OBJNOTCONNECTED;
|
||||
}
|
||||
*aRetVal = cell->ColIdx();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP
|
||||
UiaGridItem::get_RowSpan(__RPC__out int* aRetVal) {
|
||||
if (!aRetVal) {
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
TableCellAccessible* cell = CellAcc();
|
||||
if (!cell) {
|
||||
return CO_E_OBJNOTCONNECTED;
|
||||
}
|
||||
*aRetVal = cell->RowExtent();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP
|
||||
UiaGridItem::get_ColumnSpan(__RPC__out int* aRetVal) {
|
||||
if (!aRetVal) {
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
TableCellAccessible* cell = CellAcc();
|
||||
if (!cell) {
|
||||
return CO_E_OBJNOTCONNECTED;
|
||||
}
|
||||
*aRetVal = cell->ColExtent();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP
|
||||
UiaGridItem::get_ContainingGrid(
|
||||
__RPC__deref_out_opt IRawElementProviderSimple** aRetVal) {
|
||||
if (!aRetVal) {
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
*aRetVal = nullptr;
|
||||
TableCellAccessible* cell = CellAcc();
|
||||
if (!cell) {
|
||||
return CO_E_OBJNOTCONNECTED;
|
||||
}
|
||||
TableAccessible* table = cell->Table();
|
||||
if (!table) {
|
||||
return E_FAIL;
|
||||
}
|
||||
Accessible* tableAcc = table->AsAccessible();
|
||||
RefPtr<IRawElementProviderSimple> uia = MsaaAccessible::GetFrom(tableAcc);
|
||||
uia.forget(aRetVal);
|
||||
return S_OK;
|
||||
}
|
44
accessible/windows/uia/UiaGridItem.h
Normal file
44
accessible/windows/uia/UiaGridItem.h
Normal file
@ -0,0 +1,44 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_a11y_UiaGridItem_h__
|
||||
#define mozilla_a11y_UiaGridItem_h__
|
||||
|
||||
#include "objbase.h"
|
||||
#include "uiautomation.h"
|
||||
|
||||
namespace mozilla::a11y {
|
||||
class TableCellAccessible;
|
||||
|
||||
/**
|
||||
* IGridItemProvider implementation.
|
||||
*/
|
||||
class UiaGridItem : public IGridItemProvider {
|
||||
public:
|
||||
// IGridItemProvider
|
||||
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Row(
|
||||
/* [retval][out] */ __RPC__out int* aRetVal);
|
||||
|
||||
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Column(
|
||||
/* [retval][out] */ __RPC__out int* aRetVal);
|
||||
|
||||
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_RowSpan(
|
||||
/* [retval][out] */ __RPC__out int* aRetVal);
|
||||
|
||||
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ColumnSpan(
|
||||
/* [retval][out] */ __RPC__out int* aRetVal);
|
||||
|
||||
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ContainingGrid(
|
||||
/* [retval][out] */ __RPC__deref_out_opt IRawElementProviderSimple**
|
||||
aRetVal);
|
||||
|
||||
private:
|
||||
TableCellAccessible* CellAcc();
|
||||
};
|
||||
|
||||
} // namespace mozilla::a11y
|
||||
|
||||
#endif
|
@ -6,6 +6,7 @@
|
||||
|
||||
SOURCES += [
|
||||
"UiaGrid.cpp",
|
||||
"UiaGridItem.cpp",
|
||||
"uiaRawElmProvider.cpp",
|
||||
"UiaRoot.cpp",
|
||||
]
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "ApplicationAccessible.h"
|
||||
#include "ARIAMap.h"
|
||||
#include "ia2AccessibleTable.h"
|
||||
#include "ia2AccessibleTableCell.h"
|
||||
#include "LocalAccessible-inl.h"
|
||||
#include "mozilla/a11y/RemoteAccessible.h"
|
||||
#include "mozilla/StaticPrefs_accessibility.h"
|
||||
@ -284,6 +285,13 @@ uiaRawElmProvider::GetPatternProvider(
|
||||
grid.forget(aPatternProvider);
|
||||
}
|
||||
return S_OK;
|
||||
case UIA_GridItemPatternId:
|
||||
if (acc->IsTableCell()) {
|
||||
auto item =
|
||||
GetPatternFromDerived<ia2AccessibleTableCell, IGridItemProvider>();
|
||||
item.forget(aPatternProvider);
|
||||
}
|
||||
return S_OK;
|
||||
case UIA_InvokePatternId:
|
||||
// Per the UIA documentation, we should only expose the Invoke pattern "if
|
||||
// the same behavior is not exposed through another control pattern
|
||||
|
Loading…
Reference in New Issue
Block a user