LCOV - code coverage report
Current view: top level - accessible/atk - nsMaiInterfaceSelection.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 68 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 "nsMai.h"
      12             : #include "ProxyAccessible.h"
      13             : #include "mozilla/Likely.h"
      14             : 
      15             : #include <atk/atk.h>
      16             : 
      17             : using namespace mozilla::a11y;
      18             : 
      19             : extern "C" {
      20             : 
      21             : static gboolean
      22           0 : addSelectionCB(AtkSelection *aSelection, gint i)
      23             : {
      24           0 :   AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
      25           0 :   if (accWrap && accWrap->IsSelect()) {
      26           0 :     return accWrap->AddItemToSelection(i);
      27             :   }
      28             : 
      29           0 :   if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aSelection))) {
      30           0 :     return proxy->AddItemToSelection(i);
      31             :   }
      32             : 
      33           0 :   return FALSE;
      34             : }
      35             : 
      36             : static gboolean
      37           0 : clearSelectionCB(AtkSelection *aSelection)
      38             : {
      39           0 :   AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
      40           0 :   if (accWrap && accWrap->IsSelect()) {
      41           0 :     return accWrap->UnselectAll();
      42             :   }
      43             : 
      44           0 :   if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aSelection))) {
      45           0 :     return proxy->UnselectAll();
      46             :   }
      47             : 
      48           0 :   return FALSE;
      49             : }
      50             : 
      51             : static AtkObject*
      52           0 : refSelectionCB(AtkSelection *aSelection, gint i)
      53             : {
      54           0 :   AtkObject* atkObj = nullptr;
      55           0 :   AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
      56           0 :   if (accWrap && accWrap->IsSelect()) {
      57           0 :     Accessible* selectedItem = accWrap->GetSelectedItem(i);
      58           0 :     if (!selectedItem) {
      59           0 :       return nullptr;
      60             :     }
      61             : 
      62           0 :     atkObj = AccessibleWrap::GetAtkObject(selectedItem);
      63           0 :   } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aSelection))) {
      64           0 :     ProxyAccessible* selectedItem = proxy->GetSelectedItem(i);
      65           0 :     if (selectedItem) {
      66           0 :       atkObj = GetWrapperFor(selectedItem);
      67             :     }
      68             :   }
      69             : 
      70           0 :   if (atkObj) {
      71           0 :     g_object_ref(atkObj);
      72             :   }
      73             : 
      74           0 :   return atkObj;
      75             : }
      76             : 
      77             : static gint
      78           0 : getSelectionCountCB(AtkSelection *aSelection)
      79             : {
      80           0 :   AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
      81           0 :   if (accWrap && accWrap->IsSelect()) {
      82           0 :     return accWrap->SelectedItemCount();
      83             :   }
      84             : 
      85           0 :   if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aSelection))) {
      86           0 :     return proxy->SelectedItemCount();
      87             :   }
      88             : 
      89           0 :   return -1;
      90             : }
      91             : 
      92             : static gboolean
      93           0 : isChildSelectedCB(AtkSelection *aSelection, gint i)
      94             : {
      95           0 :   AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
      96           0 :   if (accWrap && accWrap->IsSelect()) {
      97           0 :     return accWrap->IsItemSelected(i);
      98             :   }
      99             : 
     100           0 :   if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aSelection))) {
     101           0 :     return proxy->IsItemSelected(i);
     102             :   }
     103             : 
     104           0 :   return FALSE;
     105             : }
     106             : 
     107             : static gboolean
     108           0 : removeSelectionCB(AtkSelection *aSelection, gint i)
     109             : {
     110           0 :   AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
     111           0 :   if (accWrap && accWrap->IsSelect()) {
     112           0 :     return accWrap->RemoveItemFromSelection(i);
     113             :   }
     114             : 
     115           0 :   if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aSelection))) {
     116           0 :     return proxy->RemoveItemFromSelection(i);
     117             :   }
     118             : 
     119           0 :   return FALSE;
     120             : }
     121             : 
     122             : static gboolean
     123           0 : selectAllSelectionCB(AtkSelection *aSelection)
     124             : {
     125           0 :   AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
     126           0 :   if (accWrap && accWrap->IsSelect()) {
     127           0 :     return accWrap->SelectAll();
     128             :   }
     129             : 
     130           0 :   if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aSelection))) {
     131           0 :     return proxy->SelectAll();
     132             :   }
     133             : 
     134           0 :   return FALSE;
     135             : }
     136             : }
     137             : 
     138             : void
     139           0 : selectionInterfaceInitCB(AtkSelectionIface* aIface)
     140             : {
     141           0 :   NS_ASSERTION(aIface, "Invalid aIface");
     142           0 :   if (MOZ_UNLIKELY(!aIface))
     143           0 :     return;
     144             : 
     145           0 :   aIface->add_selection = addSelectionCB;
     146           0 :   aIface->clear_selection = clearSelectionCB;
     147           0 :   aIface->ref_selection = refSelectionCB;
     148           0 :   aIface->get_selection_count = getSelectionCountCB;
     149           0 :   aIface->is_child_selected = isChildSelectedCB;
     150           0 :   aIface->remove_selection = removeSelectionCB;
     151           0 :   aIface->select_all_selection = selectAllSelectionCB;
     152             : }

Generated by: LCOV version 1.13