2011-04-27 06:42:27 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2011-05-27 15:37:24 -07:00
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-19 21:02:50 -07:00
|
|
|
#include "InterfaceInitFuncs.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-12-20 19:16:44 -08:00
|
|
|
#include "Accessible-inl.h"
|
2012-05-28 18:18:45 -07:00
|
|
|
#include "AccessibleWrap.h"
|
2012-03-19 21:02:50 -07:00
|
|
|
#include "nsMai.h"
|
2012-10-26 06:32:10 -07:00
|
|
|
#include "mozilla/Likely.h"
|
2012-03-19 21:02:50 -07:00
|
|
|
|
|
|
|
#include <atk/atk.h>
|
|
|
|
|
2012-11-17 18:01:44 -08:00
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2012-03-19 21:02:50 -07:00
|
|
|
extern "C" {
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-19 21:02:50 -07:00
|
|
|
static gboolean
|
2007-03-22 10:30:00 -07:00
|
|
|
addSelectionCB(AtkSelection *aSelection, gint i)
|
|
|
|
{
|
2012-05-28 18:18:45 -07:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
|
|
|
|
if (!accWrap || !accWrap->IsSelect())
|
|
|
|
return FALSE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
return accWrap->AddItemToSelection(i);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-03-19 21:02:50 -07:00
|
|
|
static gboolean
|
2007-03-22 10:30:00 -07:00
|
|
|
clearSelectionCB(AtkSelection *aSelection)
|
|
|
|
{
|
2012-05-28 18:18:45 -07:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
|
|
|
|
if (!accWrap || !accWrap->IsSelect())
|
|
|
|
return FALSE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
return accWrap->UnselectAll();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-03-19 21:02:50 -07:00
|
|
|
static AtkObject*
|
2007-03-22 10:30:00 -07:00
|
|
|
refSelectionCB(AtkSelection *aSelection, gint i)
|
|
|
|
{
|
2012-05-28 18:18:45 -07:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
|
|
|
|
if (!accWrap || !accWrap->IsSelect())
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2012-05-28 18:18:45 -07:00
|
|
|
|
|
|
|
Accessible* selectedItem = accWrap->GetSelectedItem(i);
|
|
|
|
if (!selectedItem)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2012-05-28 18:18:45 -07:00
|
|
|
|
|
|
|
AtkObject* atkObj = AccessibleWrap::GetAtkObject(selectedItem);
|
|
|
|
if (atkObj)
|
|
|
|
g_object_ref(atkObj);
|
|
|
|
|
|
|
|
return atkObj;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-03-19 21:02:50 -07:00
|
|
|
static gint
|
2007-03-22 10:30:00 -07:00
|
|
|
getSelectionCountCB(AtkSelection *aSelection)
|
|
|
|
{
|
2012-05-28 18:18:45 -07:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
|
|
|
|
if (!accWrap || !accWrap->IsSelect())
|
|
|
|
return -1;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
return accWrap->SelectedItemCount();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-03-19 21:02:50 -07:00
|
|
|
static gboolean
|
2007-03-22 10:30:00 -07:00
|
|
|
isChildSelectedCB(AtkSelection *aSelection, gint i)
|
|
|
|
{
|
2012-05-28 18:18:45 -07:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
|
|
|
|
if (!accWrap || !accWrap->IsSelect())
|
|
|
|
return FALSE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
return accWrap->IsItemSelected(i);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-03-19 21:02:50 -07:00
|
|
|
static gboolean
|
2007-03-22 10:30:00 -07:00
|
|
|
removeSelectionCB(AtkSelection *aSelection, gint i)
|
|
|
|
{
|
2012-05-28 18:18:45 -07:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
|
|
|
|
if (!accWrap || !accWrap->IsSelect())
|
|
|
|
return FALSE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
return accWrap->RemoveItemFromSelection(i);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-03-19 21:02:50 -07:00
|
|
|
static gboolean
|
2007-03-22 10:30:00 -07:00
|
|
|
selectAllSelectionCB(AtkSelection *aSelection)
|
|
|
|
{
|
2012-05-28 18:18:45 -07:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
|
|
|
|
if (!accWrap || !accWrap->IsSelect())
|
|
|
|
return FALSE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
return accWrap->SelectAll();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-03-19 21:02:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
selectionInterfaceInitCB(AtkSelectionIface* aIface)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aIface, "Invalid aIface");
|
2012-10-26 06:32:10 -07:00
|
|
|
if (MOZ_UNLIKELY(!aIface))
|
2012-03-19 21:02:50 -07:00
|
|
|
return;
|
|
|
|
|
|
|
|
aIface->add_selection = addSelectionCB;
|
|
|
|
aIface->clear_selection = clearSelectionCB;
|
|
|
|
aIface->ref_selection = refSelectionCB;
|
|
|
|
aIface->get_selection_count = getSelectionCountCB;
|
|
|
|
aIface->is_child_selected = isChildSelectedCB;
|
|
|
|
aIface->remove_selection = removeSelectionCB;
|
|
|
|
aIface->select_all_selection = selectAllSelectionCB;
|
|
|
|
}
|