diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /accessible/windows/ia2/ia2AccessibleTableCell.cpp | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | accessible/windows/ia2/ia2AccessibleTableCell.cpp | 186 |
1 files changed, 186 insertions, 0 deletions
diff --git a/accessible/windows/ia2/ia2AccessibleTableCell.cpp b/accessible/windows/ia2/ia2AccessibleTableCell.cpp new file mode 100644 index 0000000000..74b6c4233d --- /dev/null +++ b/accessible/windows/ia2/ia2AccessibleTableCell.cpp @@ -0,0 +1,186 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:expandtab:shiftwidth=2:tabstop=2: + */ +/* 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 "AccessibleTable2_i.c" +#include "AccessibleTableCell_i.c" + +#include "IUnknownImpl.h" +#include "mozilla/a11y/Accessible.h" +#include "mozilla/a11y/TableAccessibleBase.h" +#include "mozilla/a11y/TableCellAccessibleBase.h" +#include "nsCOMPtr.h" +#include "nsString.h" + +using namespace mozilla::a11y; + +TableCellAccessibleBase* ia2AccessibleTableCell::CellAcc() { + Accessible* acc = Acc(); + return acc ? acc->AsTableCellBase() : nullptr; +} + +// IUnknown +IMPL_IUNKNOWN_QUERY_HEAD(ia2AccessibleTableCell) +IMPL_IUNKNOWN_QUERY_IFACE(IAccessibleTableCell) +IMPL_IUNKNOWN_QUERY_TAIL_INHERITED(ia2AccessibleHypertext) + +//////////////////////////////////////////////////////////////////////////////// +// IAccessibleTableCell + +STDMETHODIMP +ia2AccessibleTableCell::get_table(IUnknown** aTable) { + if (!aTable) return E_INVALIDARG; + + *aTable = nullptr; + TableCellAccessibleBase* tableCell = CellAcc(); + if (!tableCell) return CO_E_OBJNOTCONNECTED; + + TableAccessibleBase* table = tableCell->Table(); + if (!table) return E_FAIL; + + Accessible* tableAcc = table->AsAccessible(); + RefPtr<IAccessible> result = MsaaAccessible::GetFrom(tableAcc); + result.forget(aTable); + return S_OK; +} + +STDMETHODIMP +ia2AccessibleTableCell::get_columnExtent(long* aSpan) { + if (!aSpan) return E_INVALIDARG; + + *aSpan = 0; + TableCellAccessibleBase* tableCell = CellAcc(); + if (!tableCell) return CO_E_OBJNOTCONNECTED; + + *aSpan = tableCell->ColExtent(); + + return S_OK; +} + +STDMETHODIMP +ia2AccessibleTableCell::get_columnHeaderCells(IUnknown*** aCellAccessibles, + long* aNColumnHeaderCells) { + if (!aCellAccessibles || !aNColumnHeaderCells) return E_INVALIDARG; + + *aCellAccessibles = nullptr; + *aNColumnHeaderCells = 0; + TableCellAccessibleBase* tableCell = CellAcc(); + if (!tableCell) return CO_E_OBJNOTCONNECTED; + + AutoTArray<Accessible*, 10> cells; + tableCell->ColHeaderCells(&cells); + + *aNColumnHeaderCells = cells.Length(); + *aCellAccessibles = static_cast<IUnknown**>( + ::CoTaskMemAlloc(sizeof(IUnknown*) * cells.Length())); + + if (!*aCellAccessibles) return E_OUTOFMEMORY; + + for (uint32_t i = 0; i < cells.Length(); i++) { + RefPtr<IAccessible> iaCell = MsaaAccessible::GetFrom(cells[i]); + iaCell.forget(&(*aCellAccessibles)[i]); + } + + return S_OK; +} + +STDMETHODIMP +ia2AccessibleTableCell::get_columnIndex(long* aColIdx) { + if (!aColIdx) return E_INVALIDARG; + + *aColIdx = -1; + TableCellAccessibleBase* tableCell = CellAcc(); + if (!tableCell) return CO_E_OBJNOTCONNECTED; + + *aColIdx = tableCell->ColIdx(); + return S_OK; +} + +STDMETHODIMP +ia2AccessibleTableCell::get_rowExtent(long* aSpan) { + if (!aSpan) return E_INVALIDARG; + + *aSpan = 0; + TableCellAccessibleBase* tableCell = CellAcc(); + if (!tableCell) return CO_E_OBJNOTCONNECTED; + + *aSpan = tableCell->RowExtent(); + return S_OK; +} + +STDMETHODIMP +ia2AccessibleTableCell::get_rowHeaderCells(IUnknown*** aCellAccessibles, + long* aNRowHeaderCells) { + if (!aCellAccessibles || !aNRowHeaderCells) return E_INVALIDARG; + + *aCellAccessibles = nullptr; + *aNRowHeaderCells = 0; + TableCellAccessibleBase* tableCell = CellAcc(); + if (!tableCell) return CO_E_OBJNOTCONNECTED; + + AutoTArray<Accessible*, 10> cells; + tableCell->RowHeaderCells(&cells); + + *aNRowHeaderCells = cells.Length(); + *aCellAccessibles = static_cast<IUnknown**>( + ::CoTaskMemAlloc(sizeof(IUnknown*) * cells.Length())); + if (!*aCellAccessibles) return E_OUTOFMEMORY; + + for (uint32_t i = 0; i < cells.Length(); i++) { + RefPtr<IAccessible> iaCell = MsaaAccessible::GetFrom(cells[i]); + iaCell.forget(&(*aCellAccessibles)[i]); + } + + return S_OK; +} + +STDMETHODIMP +ia2AccessibleTableCell::get_rowIndex(long* aRowIdx) { + if (!aRowIdx) return E_INVALIDARG; + + *aRowIdx = -1; + TableCellAccessibleBase* tableCell = CellAcc(); + if (!tableCell) return CO_E_OBJNOTCONNECTED; + + *aRowIdx = tableCell->RowIdx(); + return S_OK; +} + +STDMETHODIMP +ia2AccessibleTableCell::get_rowColumnExtents(long* aRowIdx, long* aColIdx, + long* aRowExtents, + long* aColExtents, + boolean* aIsSelected) { + if (!aRowIdx || !aColIdx || !aRowExtents || !aColExtents || !aIsSelected) + return E_INVALIDARG; + + *aRowIdx = *aColIdx = *aRowExtents = *aColExtents = 0; + *aIsSelected = false; + TableCellAccessibleBase* tableCell = CellAcc(); + if (!tableCell) return CO_E_OBJNOTCONNECTED; + + *aRowIdx = tableCell->RowIdx(); + *aColIdx = tableCell->ColIdx(); + *aRowExtents = tableCell->RowExtent(); + *aColExtents = tableCell->ColExtent(); + *aIsSelected = tableCell->Selected(); + + return S_OK; +} + +STDMETHODIMP +ia2AccessibleTableCell::get_isSelected(boolean* aIsSelected) { + if (!aIsSelected) return E_INVALIDARG; + + *aIsSelected = false; + TableCellAccessibleBase* tableCell = CellAcc(); + if (!tableCell) return CO_E_OBJNOTCONNECTED; + + *aIsSelected = tableCell->Selected(); + return S_OK; +} |