From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- accessible/atk/nsMaiInterfaceTableCell.cpp | 148 +++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 accessible/atk/nsMaiInterfaceTableCell.cpp (limited to 'accessible/atk/nsMaiInterfaceTableCell.cpp') diff --git a/accessible/atk/nsMaiInterfaceTableCell.cpp b/accessible/atk/nsMaiInterfaceTableCell.cpp new file mode 100644 index 0000000000..06a684a87d --- /dev/null +++ b/accessible/atk/nsMaiInterfaceTableCell.cpp @@ -0,0 +1,148 @@ +/* -*- 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 "InterfaceInitFuncs.h" + +#include "mozilla/a11y/TableAccessible.h" +#include "mozilla/a11y/TableCellAccessible.h" +#include "nsAccessibilityService.h" +#include "nsMai.h" +#include "RemoteAccessible.h" +#include "nsTArray.h" + +#include "mozilla/Likely.h" + +using namespace mozilla; +using namespace mozilla::a11y; + +extern "C" { +static gint GetColumnSpanCB(AtkTableCell* aCell) { + Accessible* acc = GetInternalObj(ATK_OBJECT(aCell)); + if (!acc) { + return 0; + } + return static_cast(acc->AsTableCell()->ColExtent()); +} + +static gint GetRowSpanCB(AtkTableCell* aCell) { + Accessible* acc = GetInternalObj(ATK_OBJECT(aCell)); + if (!acc) { + return 0; + } + return static_cast(acc->AsTableCell()->RowExtent()); +} + +static gboolean GetPositionCB(AtkTableCell* aCell, gint* aRow, gint* aCol) { + Accessible* acc = GetInternalObj(ATK_OBJECT(aCell)); + if (!acc) { + return false; + } + TableCellAccessible* cell = acc->AsTableCell(); + if (!cell) { + return false; + } + *aRow = static_cast(cell->RowIdx()); + *aCol = static_cast(cell->ColIdx()); + return true; +} + +static gboolean GetColumnRowSpanCB(AtkTableCell* aCell, gint* aCol, gint* aRow, + gint* aColExtent, gint* aRowExtent) { + Accessible* acc = GetInternalObj(ATK_OBJECT(aCell)); + if (!acc) { + return false; + } + TableCellAccessible* cellAcc = acc->AsTableCell(); + if (!cellAcc) { + return false; + } + *aCol = static_cast(cellAcc->ColIdx()); + *aRow = static_cast(cellAcc->RowIdx()); + *aColExtent = static_cast(cellAcc->ColExtent()); + *aRowExtent = static_cast(cellAcc->ColExtent()); + return true; +} + +static AtkObject* GetTableCB(AtkTableCell* aTableCell) { + Accessible* acc = GetInternalObj(ATK_OBJECT(aTableCell)); + if (!acc) { + return nullptr; + } + TableCellAccessible* cell = acc->AsTableCell(); + if (!cell) { + return nullptr; + } + TableAccessible* table = cell->Table(); + if (!table) { + return nullptr; + } + Accessible* tableAcc = table->AsAccessible(); + return tableAcc ? GetWrapperFor(tableAcc) : nullptr; +} + +static GPtrArray* GetColumnHeaderCellsCB(AtkTableCell* aCell) { + Accessible* acc = GetInternalObj(ATK_OBJECT(aCell)); + if (!acc) { + return nullptr; + } + TableCellAccessible* cell = acc->AsTableCell(); + if (!cell) { + return nullptr; + } + AutoTArray headers; + cell->ColHeaderCells(&headers); + if (headers.IsEmpty()) { + return nullptr; + } + + GPtrArray* atkHeaders = g_ptr_array_sized_new(headers.Length()); + for (Accessible* header : headers) { + AtkObject* atkHeader = GetWrapperFor(header); + g_object_ref(atkHeader); + g_ptr_array_add(atkHeaders, atkHeader); + } + + return atkHeaders; +} + +static GPtrArray* GetRowHeaderCellsCB(AtkTableCell* aCell) { + Accessible* acc = GetInternalObj(ATK_OBJECT(aCell)); + if (!acc) { + return nullptr; + } + TableCellAccessible* cell = acc->AsTableCell(); + if (!cell) { + return nullptr; + } + AutoTArray headers; + cell->RowHeaderCells(&headers); + if (headers.IsEmpty()) { + return nullptr; + } + + GPtrArray* atkHeaders = g_ptr_array_sized_new(headers.Length()); + for (Accessible* header : headers) { + AtkObject* atkHeader = GetWrapperFor(header); + g_object_ref(atkHeader); + g_ptr_array_add(atkHeaders, atkHeader); + } + + return atkHeaders; +} +} + +void tableCellInterfaceInitCB(AtkTableCellIface* aIface) { + NS_ASSERTION(aIface, "no interface!"); + if (MOZ_UNLIKELY(!aIface)) return; + + aIface->get_column_span = GetColumnSpanCB; + aIface->get_column_header_cells = GetColumnHeaderCellsCB; + aIface->get_position = GetPositionCB; + aIface->get_row_span = GetRowSpanCB; + aIface->get_row_header_cells = GetRowHeaderCellsCB; + aIface->get_row_column_span = GetColumnRowSpanCB; + aIface->get_table = GetTableCB; +} -- cgit v1.2.3