LCOV - code coverage report
Current view: top level - accessible/atk - nsMaiInterfaceTableCell.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 115 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 8 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #include "InterfaceInitFuncs.h"
       8             : 
       9             : #include "Accessible-inl.h"
      10             : #include "AccessibleWrap.h"
      11             : #include "nsAccUtils.h"
      12             : #include "TableAccessible.h"
      13             : #include "TableCellAccessible.h"
      14             : #include "nsMai.h"
      15             : #include "ProxyAccessible.h"
      16             : #include "nsArrayUtils.h"
      17             : 
      18             : #include "mozilla/Likely.h"
      19             : 
      20             : using namespace mozilla::a11y;
      21             : 
      22             : extern "C" {
      23             : static gint
      24           0 : GetColumnSpanCB(AtkTableCell* aCell)
      25             : {
      26           0 :   AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell));
      27           0 :   if (accWrap) {
      28           0 :     return accWrap->AsTableCell()->ColExtent();
      29             :   }
      30             : 
      31           0 :   if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aCell))) {
      32           0 :     return proxy->ColExtent();
      33             :   }
      34             : 
      35           0 :   return 0;
      36             : }
      37             : 
      38             : static gboolean
      39           0 : GetRowSpanCB(AtkTableCell* aCell)
      40             : {
      41           0 :   AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell));
      42           0 :   if (accWrap) {
      43           0 :     return accWrap->AsTableCell()->RowExtent();
      44             :   }
      45             : 
      46           0 :   if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aCell))) {
      47           0 :     return proxy->RowExtent();
      48             :   }
      49             : 
      50           0 :   return 0;
      51             : }
      52             : 
      53             : static gboolean
      54           0 : GetPositionCB(AtkTableCell* aCell, gint* aRow, gint* aCol)
      55             : {
      56           0 :   if (AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell))) {
      57           0 :     TableCellAccessible* cell = accWrap->AsTableCell();
      58           0 :     *aRow = cell->RowIdx();
      59           0 :     *aCol = cell->ColIdx();
      60           0 :     return true;
      61             :   }
      62             : 
      63           0 :   if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aCell))) {
      64           0 :     uint32_t rowIdx = 0, colIdx = 0;
      65           0 :     proxy->GetPosition(&rowIdx, &colIdx);
      66           0 :     *aCol = colIdx;
      67           0 :     *aRow = rowIdx;
      68           0 :     return true;
      69             :   }
      70             : 
      71           0 :   return false;
      72             : }
      73             : 
      74             : static gboolean
      75           0 : GetColumnRowSpanCB(AtkTableCell* aCell, gint* aCol, gint* aRow,
      76             :                    gint* aColExtent, gint* aRowExtent) {
      77           0 :   if (AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell))) {
      78           0 :     TableCellAccessible* cellAcc = accWrap->AsTableCell();
      79           0 :     *aCol = cellAcc->ColIdx();
      80           0 :     *aRow = cellAcc->RowIdx();
      81           0 :     *aColExtent = cellAcc->ColExtent();
      82           0 :     *aRowExtent = cellAcc->ColExtent();
      83           0 :     return true;
      84             :   }
      85             : 
      86           0 :   if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aCell))) {
      87           0 :     uint32_t colIdx = 0, rowIdx = 0, colExtent = 0, rowExtent = 0;
      88           0 :     proxy->GetColRowExtents(&colIdx, &rowIdx, &colExtent, &rowExtent);
      89           0 :     *aCol = colIdx;
      90           0 :     *aRow = rowIdx;
      91           0 :     *aColExtent = colExtent;
      92           0 :     *aRowExtent = rowExtent;
      93           0 :   return true;
      94             :   }
      95             : 
      96           0 :   return false;
      97             : }
      98             : 
      99             : static AtkObject*
     100           0 : GetTableCB(AtkTableCell* aTableCell)
     101             : {
     102           0 :   AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTableCell));
     103           0 :   if (accWrap) {
     104           0 :     TableAccessible* table = accWrap->AsTableCell()->Table();
     105           0 :     if (!table) {
     106           0 :       return nullptr;
     107             :     }
     108             : 
     109           0 :     Accessible* tableAcc = table->AsAccessible();
     110           0 :     return tableAcc ? AccessibleWrap::GetAtkObject(tableAcc) : nullptr;
     111             :   }
     112             : 
     113           0 :   if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aTableCell))) {
     114           0 :     ProxyAccessible* table = proxy->TableOfACell();
     115           0 :     return table ? GetWrapperFor(table) : nullptr;
     116             :   }
     117             : 
     118           0 :   return nullptr;
     119             : }
     120             : 
     121             : static GPtrArray*
     122           0 : GetColumnHeaderCellsCB(AtkTableCell* aCell)
     123             : {
     124           0 :   if (AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell))) {
     125           0 :     AutoTArray<Accessible*, 10> headers;
     126           0 :     accWrap->AsTableCell()->ColHeaderCells(&headers);
     127           0 :     if (headers.IsEmpty()) {
     128           0 :       return nullptr;
     129             :     }
     130             : 
     131           0 :     GPtrArray* atkHeaders = g_ptr_array_sized_new(headers.Length());
     132           0 :     for (Accessible* header: headers) {
     133           0 :       AtkObject* atkHeader = AccessibleWrap::GetAtkObject(header);
     134           0 :       g_object_ref(atkHeader);
     135           0 :       g_ptr_array_add(atkHeaders, atkHeader);
     136             :     }
     137             : 
     138           0 :     return atkHeaders;
     139             :   }
     140             : 
     141           0 :   if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aCell))) {
     142           0 :     AutoTArray<ProxyAccessible*, 10> headers;
     143           0 :     proxy->ColHeaderCells(&headers);
     144           0 :     if (headers.IsEmpty()) {
     145           0 :       return nullptr;
     146             :     }
     147             : 
     148           0 :     GPtrArray* atkHeaders = g_ptr_array_sized_new(headers.Length());
     149           0 :     for (ProxyAccessible* header: headers) {
     150           0 :       AtkObject* atkHeader = GetWrapperFor(header);
     151           0 :       g_object_ref(atkHeader);
     152           0 :       g_ptr_array_add(atkHeaders, atkHeader);
     153             :     }
     154             : 
     155           0 :     return atkHeaders;
     156             :   }
     157             : 
     158           0 :   return nullptr;
     159             : }
     160             : 
     161             : static GPtrArray*
     162           0 : GetRowHeaderCellsCB(AtkTableCell* aCell)
     163             : {
     164           0 :   if (AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aCell))) {
     165           0 :     AutoTArray<Accessible*, 10> headers;
     166           0 :     accWrap->AsTableCell()->RowHeaderCells(&headers);
     167           0 :     if (headers.IsEmpty()) {
     168           0 :       return nullptr;
     169             :     }
     170             : 
     171           0 :     GPtrArray* atkHeaders = g_ptr_array_sized_new(headers.Length());
     172           0 :     for (Accessible* header: headers) {
     173           0 :       AtkObject* atkHeader = AccessibleWrap::GetAtkObject(header);
     174           0 :       g_object_ref(atkHeader);
     175           0 :       g_ptr_array_add(atkHeaders, atkHeader);
     176             :     }
     177             : 
     178           0 :     return atkHeaders;
     179             :   }
     180             : 
     181           0 :   if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aCell))) {
     182           0 :     AutoTArray<ProxyAccessible*, 10> headers;
     183           0 :     proxy->RowHeaderCells(&headers);
     184           0 :     if (headers.IsEmpty()) {
     185           0 :       return nullptr;
     186             :     }
     187             : 
     188           0 :     GPtrArray* atkHeaders = g_ptr_array_sized_new(headers.Length());
     189           0 :     for (ProxyAccessible* header: headers) {
     190           0 :       AtkObject* atkHeader = GetWrapperFor(header);
     191           0 :       g_object_ref(atkHeader);
     192           0 :       g_ptr_array_add(atkHeaders, atkHeader);
     193             :     }
     194             : 
     195           0 :     return atkHeaders;
     196             :   }
     197             : 
     198           0 :   return nullptr;
     199             : }
     200             : }
     201             : 
     202             : void
     203           0 : tableCellInterfaceInitCB(AtkTableCellIface* aIface)
     204             : {
     205           0 :   NS_ASSERTION(aIface, "no interface!");
     206           0 :   if (MOZ_UNLIKELY(!aIface))
     207           0 :     return;
     208             : 
     209           0 :   aIface->get_column_span = GetColumnSpanCB;
     210           0 :   aIface->get_column_header_cells = GetColumnHeaderCellsCB;
     211           0 :   aIface->get_position = GetPositionCB;
     212           0 :   aIface->get_row_span = GetRowSpanCB;
     213           0 :   aIface->get_row_header_cells = GetRowHeaderCellsCB;
     214           0 :   aIface->get_row_column_span = GetColumnRowSpanCB;
     215           0 :   aIface->get_table = GetTableCB;
     216             : }

Generated by: LCOV version 1.13