accessible/src/atk/nsMaiInterfaceSelection.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ts=2 et sw=2 tw=80: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #include "InterfaceInitFuncs.h"
michael@0 8
michael@0 9 #include "Accessible-inl.h"
michael@0 10 #include "AccessibleWrap.h"
michael@0 11 #include "nsMai.h"
michael@0 12 #include "mozilla/Likely.h"
michael@0 13
michael@0 14 #include <atk/atk.h>
michael@0 15
michael@0 16 using namespace mozilla::a11y;
michael@0 17
michael@0 18 extern "C" {
michael@0 19
michael@0 20 static gboolean
michael@0 21 addSelectionCB(AtkSelection *aSelection, gint i)
michael@0 22 {
michael@0 23 AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
michael@0 24 if (!accWrap || !accWrap->IsSelect())
michael@0 25 return FALSE;
michael@0 26
michael@0 27 return accWrap->AddItemToSelection(i);
michael@0 28 }
michael@0 29
michael@0 30 static gboolean
michael@0 31 clearSelectionCB(AtkSelection *aSelection)
michael@0 32 {
michael@0 33 AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
michael@0 34 if (!accWrap || !accWrap->IsSelect())
michael@0 35 return FALSE;
michael@0 36
michael@0 37 return accWrap->UnselectAll();
michael@0 38 }
michael@0 39
michael@0 40 static AtkObject*
michael@0 41 refSelectionCB(AtkSelection *aSelection, gint i)
michael@0 42 {
michael@0 43 AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
michael@0 44 if (!accWrap || !accWrap->IsSelect())
michael@0 45 return nullptr;
michael@0 46
michael@0 47 Accessible* selectedItem = accWrap->GetSelectedItem(i);
michael@0 48 if (!selectedItem)
michael@0 49 return nullptr;
michael@0 50
michael@0 51 AtkObject* atkObj = AccessibleWrap::GetAtkObject(selectedItem);
michael@0 52 if (atkObj)
michael@0 53 g_object_ref(atkObj);
michael@0 54
michael@0 55 return atkObj;
michael@0 56 }
michael@0 57
michael@0 58 static gint
michael@0 59 getSelectionCountCB(AtkSelection *aSelection)
michael@0 60 {
michael@0 61 AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
michael@0 62 if (!accWrap || !accWrap->IsSelect())
michael@0 63 return -1;
michael@0 64
michael@0 65 return accWrap->SelectedItemCount();
michael@0 66 }
michael@0 67
michael@0 68 static gboolean
michael@0 69 isChildSelectedCB(AtkSelection *aSelection, gint i)
michael@0 70 {
michael@0 71 AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
michael@0 72 if (!accWrap || !accWrap->IsSelect())
michael@0 73 return FALSE;
michael@0 74
michael@0 75 return accWrap->IsItemSelected(i);
michael@0 76 }
michael@0 77
michael@0 78 static gboolean
michael@0 79 removeSelectionCB(AtkSelection *aSelection, gint i)
michael@0 80 {
michael@0 81 AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
michael@0 82 if (!accWrap || !accWrap->IsSelect())
michael@0 83 return FALSE;
michael@0 84
michael@0 85 return accWrap->RemoveItemFromSelection(i);
michael@0 86 }
michael@0 87
michael@0 88 static gboolean
michael@0 89 selectAllSelectionCB(AtkSelection *aSelection)
michael@0 90 {
michael@0 91 AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
michael@0 92 if (!accWrap || !accWrap->IsSelect())
michael@0 93 return FALSE;
michael@0 94
michael@0 95 return accWrap->SelectAll();
michael@0 96 }
michael@0 97 }
michael@0 98
michael@0 99 void
michael@0 100 selectionInterfaceInitCB(AtkSelectionIface* aIface)
michael@0 101 {
michael@0 102 NS_ASSERTION(aIface, "Invalid aIface");
michael@0 103 if (MOZ_UNLIKELY(!aIface))
michael@0 104 return;
michael@0 105
michael@0 106 aIface->add_selection = addSelectionCB;
michael@0 107 aIface->clear_selection = clearSelectionCB;
michael@0 108 aIface->ref_selection = refSelectionCB;
michael@0 109 aIface->get_selection_count = getSelectionCountCB;
michael@0 110 aIface->is_child_selected = isChildSelectedCB;
michael@0 111 aIface->remove_selection = removeSelectionCB;
michael@0 112 aIface->select_all_selection = selectAllSelectionCB;
michael@0 113 }

mercurial