Closed
Bug 151136
Opened 23 years ago
Closed 23 years ago
support nsIAccessibleSelection in MAI (Mozilla Atk Implementation)
Categories
(Core :: Disability Access APIs, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: yinbolian, Assigned: silvia.zhao)
References
Details
(Keywords: access)
Attachments
(1 file, 3 obsolete files)
|
11.45 KB,
patch
|
aaronlev
:
review+
|
Details | Diff | Splinter Review |
| Reporter | ||
Updated•23 years ago
|
| Reporter | ||
Comment 1•23 years ago
|
||
Siliva will own this bug
Assignee: bolian.yin → silvia.zhao
Status: ASSIGNED → NEW
| Assignee | ||
Comment 2•23 years ago
|
||
| Assignee | ||
Comment 3•23 years ago
|
||
Attachment #89226 -
Attachment is obsolete: true
| Reporter | ||
Comment 4•23 years ago
|
||
+MaiObject *
+MaiInterfaceSelection::RefSelection(gint i)
+{
+ MAI_IFACE_RETURN_VAL_IF_FAIL(accessInterfaceSelectable, FALSE);
^^^^^^
mismatch return value.
Status: NEW → ASSIGNED
| Assignee | ||
Comment 5•23 years ago
|
||
Comment on attachment 89229 [details] [diff] [review]
patch_v2
>Index: nsMaiInterfaceSelection.cpp
>===================================================================
>RCS file: nsMaiInterfaceSelection.cpp
>diff -N nsMaiInterfaceSelection.cpp
>--- /dev/null Wed Jun 26 14:20:48 2002
>+++ nsMaiInterfaceSelection.cpp Wed Jun 26 14:25:14 2002
>@@ -0,0 +1,308 @@
>+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
>+/* vim:expandtab:shiftwidth=4:tabstop=4:
>+ */
>+/* ***** BEGIN LICENSE BLOCK *****
>+ * Version: NPL 1.1/GPL 2.0/LGPL 2.1
>+ *
>+ *
>+ * The contents of this file are subject to the Mozilla Public
>+ * License Version 1.1 (the "License"); you may not use this file
>+ * except in compliance with the License. You may obtain a copy of
>+ * the License at http://www.mozilla.org/MPL/
>+ *
>+ * Software distributed under the License is distributed on an "AS
>+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
>+ * implied. See the License for the specific language governing
>+ * rights and limitations under the License.
>+ *
>+ * The Original Code is mozilla.org code.
>+ *
>+ * The Initial Developer of the Original Code is Sun Microsystems, Inc.
>+ * Portions created by Sun Microsystems are Copyright (C) 2002 Sun
>+ * Microsystems, Inc. All Rights Reserved.
>+ *
>+ * Original Author: Silvia Zhao (silvia.zhao@sun.com)
>+ *
>+ * Contributor(s):
>+ *
>+ * Alternatively, the contents of this file may be used under the terms of
>+ * either the GNU General Public License Version 2 or later (the "GPL"), or
>+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
>+ * in which case the provisions of the GPL or the LGPL are applicable instead
>+ * of those above. If you wish to allow use of your version of this file only
>+ * under the terms of either the GPL or the LGPL, and not to allow others to
>+ * use your version of this file under the terms of the NPL, indicate your
>+ * decision by deleting the provisions above and replace them with the notice
>+ * and other provisions required by the GPL or the LGPL. If you do not delete
>+ * the provisions above, a recipient may use your version of this file under
>+ * the terms of any one of the NPL, the GPL or the LGPL.
>+ *
>+ * ***** END LICENSE BLOCK ***** */
>+
>+#include "nsMaiInterfaceSelection.h"
>+#include "nsIAccessibleSelectable.h"
>+
>+/* helpers */
>+static MaiInterfaceSelection *getSelection(AtkSelection *aIface);
>+
>+G_BEGIN_DECLS
>+
>+/* selection interface callbacks */
>+
>+static void interfaceInitCB(AtkSelectionIface *aIface);
>+static gboolean addSelectionCB(AtkSelection *aSelection,
>+ gint i);
>+static gboolean clearSelectionCB(AtkSelection *aSelection);
>+static AtkObject *refSelectionCB(AtkSelection *aSelection,
>+ gint i);
>+static gint getSelectionCountCB(AtkSelection *aSelection);
>+static gboolean isChildSelectedCB(AtkSelection *aSelection,
>+ gint i);
>+static gboolean removeSelectionCB(AtkSelection *aSelection,
>+ gint i);
>+static gboolean selectAllSelectionCB(AtkSelection *aSelection);
>+
>+G_END_DECLS
>+
>+MaiInterfaceSelection::MaiInterfaceSelection(MaiWidget *aMaiWidget):
>+ MaiInterface(aMaiWidget)
>+{
>+}
>+
>+MaiInterfaceSelection::~MaiInterfaceSelection()
>+{
>+}
>+
>+MaiInterfaceType
>+MaiInterfaceSelection::GetType()
>+{
>+ return MAI_INTERFACE_SELECTION;
>+}
>+
>+const GInterfaceInfo *
>+MaiInterfaceSelection::GetInterfaceInfo()
>+{
>+ static const GInterfaceInfo atk_if_selection_info = {
>+ (GInterfaceInitFunc) interfaceInitCB,
>+ (GInterfaceFinalizeFunc) NULL,
>+ NULL
>+ };
>+ return &atk_if_selection_info;
>+}
>+
>+#define MAI_IFACE_RETURN_VAL_IF_FAIL(accessIface, retvalue) \
>+ nsIAccessible *tmpAccess = GetNSAccessible(); \
>+ nsCOMPtr<nsIAccessibleSelectable> \
>+ accessIface(do_QueryInterface(tmpAccess)); \
>+ if (!(accessIface)) \
>+ return (retvalue)
>+
>+/*interface virtual functions*/
>+gboolean
>+MaiInterfaceSelection::AddSelection(gint i)
>+{
>+ MAI_IFACE_RETURN_VAL_IF_FAIL(accessInterfaceSelectable, FALSE);
>+
>+ nsresult rv = accessInterfaceSelectable->AddSelection(i);
>+ if (NS_FAILED(rv))
>+ return FALSE;
>+ else
>+ return TRUE;
>+}
>+
>+gboolean
>+MaiInterfaceSelection::ClearSelection()
>+{
>+ MAI_IFACE_RETURN_VAL_IF_FAIL(accessInterfaceSelectable, FALSE);
>+
>+ nsresult rv = accessInterfaceSelectable->ClearSelection();
>+ if (NS_FAILED(rv))
>+ return FALSE;
>+ else
>+ return TRUE;
>+}
>+
>+MaiObject *
>+MaiInterfaceSelection::RefSelection(gint i)
>+{
>+ MAI_IFACE_RETURN_VAL_IF_FAIL(accessInterfaceSelectable, FALSE);
+ MAI_IFACE_RETURN_VAL_IF_FAIL(accessInterfaceSelectable, NULL);
>+
>+ nsCOMPtr<nsIAccessible> aSelection;
>+ nsresult rv =
>+ accessInterfaceSelectable->RefSelection(i, getter_AddRefs(aSelection));
>+ if (NS_FAILED(rv))
>+ return NULL;
>+ else {
>+ MaiWidget *maiWidget = new MaiWidget(aSelection);
>+ return maiWidget;
>+ }
>+}
>+
>+gint
>+MaiInterfaceSelection::GetSelectionCount()
>+{
>+ MAI_IFACE_RETURN_VAL_IF_FAIL(accessInterfaceSelectable, 0);
>+
>+ PRInt32 num = 0;
>+ nsresult rv = accessInterfaceSelectable->GetSelectionCount(&num);
>+ if (NS_FAILED(rv))
>+ return -1;
>+ else
>+ return num;
>+}
>+
>+gboolean
>+MaiInterfaceSelection::IsChildSelected(gint i)
>+{
>+ MAI_IFACE_RETURN_VAL_IF_FAIL(accessInterfaceSelectable, FALSE);
>+
>+ PRBool result = FALSE;
>+ nsresult rv = accessInterfaceSelectable->IsChildSelected(i, &result);
>+ if (NS_FAILED(rv))
>+ return FALSE;
>+ else
>+ return result;
>+}
>+
>+gboolean
>+MaiInterfaceSelection::RemoveSelection(gint i)
>+{
>+ MAI_IFACE_RETURN_VAL_IF_FAIL(accessInterfaceSelectable, FALSE);
>+
>+ nsresult rv = accessInterfaceSelectable->RemoveSelection(i);
>+ if (NS_FAILED(rv))
>+ return FALSE;
>+ else
>+ return TRUE;
>+}
>+
>+gboolean
>+MaiInterfaceSelection::SelectAllSelection()
>+{
>+ MAI_IFACE_RETURN_VAL_IF_FAIL(accessInterfaceSelectable, FALSE);
>+
>+ PRBool result = FALSE;
>+ nsresult rv = accessInterfaceSelectable->SelectAllSelection(&result);
>+ if (NS_FAILED(rv))
>+ return FALSE;
>+ else
>+ return result;
>+}
>+
>+/* static functions */
>+
>+/* do general checking for callbacks functions
>+ * return the MaiInterfaceSelection extracted from atk selection
>+ */
>+
>+MaiInterfaceSelection *
>+getSelection(AtkSelection *aSelection)
>+{
>+ MAI_CHECK_ATK_OBJECT_RETURN_VAL_IF_FAIL(aSelection, NULL);
>+ g_return_val_if_fail(MAI_IS_ATK_WIDGET(aSelection), NULL);
>+ MaiWidget *maiWidget = (MaiWidget*)(MAI_ATK_OBJECT(aSelection)->maiObject);
>+
>+ MaiInterfaceSelection *maiInterfaceSelection = (MaiInterfaceSelection*)
>+ maiWidget->GetMaiInterface(MAI_INTERFACE_SELECTION);
>+ return maiInterfaceSelection;
>+}
>+
>+void
>+interfaceInitCB(AtkSelectionIface *aIface)
>+{
>+ g_return_if_fail(aIface != NULL);
>+ 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;
>+}
>+
>+gboolean
>+addSelectionCB(AtkSelection *aSelection, gint i)
>+{
>+ MaiInterfaceSelection *maiInterfaceSelection = getSelection(aSelection);
>+
>+ if (maiInterfaceSelection)
>+ return maiInterfaceSelection->AddSelection(i);
>+ else
>+ return FALSE;
>+}
>+
>+gboolean
>+clearSelectionCB(AtkSelection *aSelection)
>+{
>+ MaiInterfaceSelection *maiInterfaceSelection = getSelection(aSelection);
>+
>+ if (maiInterfaceSelection)
>+ return maiInterfaceSelection->ClearSelection();
>+ else
>+ return FALSE;
>+}
>+
>+AtkObject *
>+refSelectionCB(AtkSelection *aSelection, gint i)
>+{
>+ MaiInterfaceSelection *maiInterfaceSelection = getSelection(aSelection);
>+
>+ if (!maiInterfaceSelection)
>+ return NULL;
>+
>+ MaiObject *maiObj =
>+ maiInterfaceSelection->RefSelection(i);
>+ if (!maiObj)
>+ return NULL;
>+
>+ AtkObject *atkObj = maiObj->GetAtkObject();
>+ if (!atkObj)
>+ return NULL;
>+ g_object_ref(atkObj);
>+ return atkObj;
>+
>+}
>+
>+gint
>+getSelectionCountCB(AtkSelection *aSelection)
>+{
>+ MaiInterfaceSelection *maiInterfaceSelection = getSelection(aSelection);
>+
>+ if (maiInterfaceSelection)
>+ return maiInterfaceSelection->GetSelectionCount();
>+ else
>+ return 0;
>+}
>+
>+gboolean
>+isChildSelectedCB(AtkSelection *aSelection, gint i)
>+{
>+ MaiInterfaceSelection *maiInterfaceSelection = getSelection(aSelection);
>+
>+ if (maiInterfaceSelection)
>+ return maiInterfaceSelection->IsChildSelected(i);
>+ else
>+ return FALSE;
>+}
>+
>+gboolean
>+removeSelectionCB(AtkSelection *aSelection, gint i)
>+{
>+ MaiInterfaceSelection *maiInterfaceSelection = getSelection(aSelection);
>+
>+ if (maiInterfaceSelection)
>+ return maiInterfaceSelection->RemoveSelection(i);
>+ else
>+ return FALSE;
>+}
>+
>+gboolean
>+selectAllSelectionCB(AtkSelection *aSelection)
>+{
>+ MaiInterfaceSelection *maiInterfaceSelection = getSelection(aSelection);
>+
>+ if (maiInterfaceSelection)
>+ return maiInterfaceSelection->SelectAllSelection();
>+ else
>+ return FALSE;
>+}
>Index: nsMaiInterfaceSelection.h
>===================================================================
>RCS file: nsMaiInterfaceSelection.h
>diff -N nsMaiInterfaceSelection.h
>--- /dev/null Wed Jun 26 14:20:48 2002
>+++ nsMaiInterfaceSelection.h Wed Jun 26 14:25:14 2002
>@@ -0,0 +1,69 @@
>+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
>+/* vim:expandtab:shiftwidth=4:tabstop=4:
>+ */
>+/* ***** BEGIN LICENSE BLOCK *****
>+ * Version: NPL 1.1/GPL 2.0/LGPL 2.1
>+ *
>+ *
>+ * The contents of this file are subject to the Mozilla Public
>+ * License Version 1.1 (the "License"); you may not use this file
>+ * except in compliance with the License. You may obtain a copy of
>+ * the License at http://www.mozilla.org/MPL/
>+ *
>+ * Software distributed under the License is distributed on an "AS
>+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
>+ * implied. See the License for the specific language governing
>+ * rights and limitations under the License.
>+ *
>+ * The Original Code is mozilla.org code.
>+ *
>+ * The Initial Developer of the Original Code is Sun Microsystems, Inc.
>+ * Portions created by Sun Microsystems are Copyright (C) 2002 Sun
>+ * Microsystems, Inc. All Rights Reserved.
>+ *
>+ * Original Author: Silvia Zhao (silvia.zhao@sun.com)
>+ *
>+ * Contributor(s):
>+ *
>+ * Alternatively, the contents of this file may be used under the terms of
>+ * either the GNU General Public License Version 2 or later (the "GPL"), or
>+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
>+ * in which case the provisions of the GPL or the LGPL are applicable instead
>+ * of those above. If you wish to allow use of your version of this file only
>+ * under the terms of either the GPL or the LGPL, and not to allow others to
>+ * use your version of this file under the terms of the NPL, indicate your
>+ * decision by deleting the provisions above and replace them with the notice
>+ * and other provisions required by the GPL or the LGPL. If you do not delete
>+ * the provisions above, a recipient may use your version of this file under
>+ * the terms of any one of the NPL, the GPL or the LGPL.
>+ *
>+ * ***** END LICENSE BLOCK ***** */
>+
>+#ifndef __MAI_INTERFACE_SELECTION_H__
>+#define __MAI_INTERFACE_SELECTION_H__
>+
>+#include "nsMaiWidget.h"
>+#include "nsIAccessibleSelectable.h"
>+
>+class MaiInterfaceSelection: public MaiInterface
>+{
>+public:
>+ MaiInterfaceSelection(MaiWidget*);
>+ ~MaiInterfaceSelection();
>+
>+ virtual MaiInterfaceType GetType();
>+ virtual const GInterfaceInfo *GetInterfaceInfo();
>+
>+public:
>+
>+ gboolean AddSelection(gint i);
>+ gboolean ClearSelection();
>+ MaiObject *RefSelection(gint i);
>+ gint GetSelectionCount();
>+ gboolean IsChildSelected(gint i);
>+ gboolean RemoveSelection(gint i);
>+ gboolean SelectAllSelection();
>+
>+};
>+
>+#endif /* __MAI_INTERFACE_SELECTION_H__ */
>
| Assignee | ||
Comment 6•23 years ago
|
||
Sorry for the wrong action just now. It makes such a long email. :-P
Attachment #89229 -
Attachment is obsolete: true
Comment 7•23 years ago
|
||
Always avoid else after return.
Also, simplify as much as possible.
+ nsresult rv = accessInterfaceSelectable->ClearSelection();
+ if (NS_FAILED(rv))
+ return FALSE;
+ else
+ return TRUE;
+}
can become
return NS_SUCCEEDED(accessInterfaceSelectable->ClearSelection()) != 0;
| Assignee | ||
Comment 8•23 years ago
|
||
removed else after return
Thanks aaronl.:-)
Attachment #89232 -
Attachment is obsolete: true
Comment 9•23 years ago
|
||
Comment on attachment 89246 [details] [diff] [review]
patch_v4
r=aaronl
Attachment #89246 -
Flags: review+
| Reporter | ||
Comment 10•23 years ago
|
||
This bug has been checked in.
It is not in the default build and we need it to do later work. Further
comments, review, and super-review is still welcome, I will file new bug if
needed. Thanks for everyone.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•