Bug 377800 Too many warnings in console for accessibilityr=surkov.alexander

This commit is contained in:
ginn.chen@sun.com 2007-06-08 02:09:24 -07:00
parent 4616663331
commit 4a8bbe11c1
16 changed files with 218 additions and 204 deletions

View File

@ -39,7 +39,6 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsMai.h"
#include "nsAccessibleWrap.h"
#include "nsAccessibleEventData.h"
#include "nsString.h"
@ -391,6 +390,16 @@ nsAccessibleWrap::GetAtkObject(void)
return NS_STATIC_CAST(AtkObject *, atkObj);
}
// Get AtkObject from nsIAccessible interface
/* static */
AtkObject *
nsAccessibleWrap::GetAtkObject(nsIAccessible * acc)
{
void *atkObjPtr = nsnull;
acc->GetNativeInterface(&atkObjPtr);
return atkObjPtr ? ATK_OBJECT(atkObjPtr) : nsnull;
}
/* private */
PRUint16
nsAccessibleWrap::CreateMaiInterfaces(void)
@ -707,24 +716,20 @@ finalizeCB(GObject *aObj)
const gchar *
getNameCB(AtkObject *aAtkObj)
{
if (NS_FAILED(CheckMaiAtkObject(aAtkObj))) {
return nsnull;
nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj);
if (!accWrap) {
return nsnull;
}
nsAutoString uniName;
nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj);
/* nsIAccessible is responsible for the non-NULL name */
nsAutoString uniName;
nsresult rv = accWrap->GetName(uniName);
NS_ENSURE_SUCCESS(rv, nsnull);
if (uniName.Length() > 0) {
NS_ConvertUTF8toUTF16 objName(aAtkObj->name);
if (!uniName.Equals(objName)) {
atk_object_set_name(aAtkObj,
NS_ConvertUTF16toUTF8(uniName).get());
}
NS_ConvertUTF8toUTF16 objName(aAtkObj->name);
if (!uniName.Equals(objName)) {
atk_object_set_name(aAtkObj,
NS_ConvertUTF16toUTF8(uniName).get());
}
return aAtkObj->name;
}
@ -732,24 +737,20 @@ getNameCB(AtkObject *aAtkObj)
const gchar *
getDescriptionCB(AtkObject *aAtkObj)
{
if (NS_FAILED(CheckMaiAtkObject(aAtkObj))) {
return nsnull;
nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj);
if (!accWrap) {
return nsnull;
}
if (!aAtkObj->description) {
gint len;
nsAutoString uniDesc;
/* nsIAccessible is responsible for the non-NULL description */
nsAutoString uniDesc;
nsresult rv = accWrap->GetDescription(uniDesc);
NS_ENSURE_SUCCESS(rv, nsnull);
nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj);
/* nsIAccessible is responsible for the non-NULL description */
nsresult rv = accWrap->GetDescription(uniDesc);
NS_ENSURE_SUCCESS(rv, nsnull);
len = uniDesc.Length();
if (len > 0) {
atk_object_set_description(aAtkObj,
NS_ConvertUTF16toUTF8(uniDesc).get());
}
NS_ConvertUTF8toUTF16 objDesc(aAtkObj->description);
if (!uniDesc.Equals(objDesc)) {
atk_object_set_description(aAtkObj,
NS_ConvertUTF16toUTF8(uniDesc).get());
}
return aAtkObj->description;
}
@ -757,18 +758,16 @@ getDescriptionCB(AtkObject *aAtkObj)
AtkRole
getRoleCB(AtkObject *aAtkObj)
{
if (NS_FAILED(CheckMaiAtkObject(aAtkObj))) {
return ATK_ROLE_INVALID;
nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj);
if (!accWrap) {
return ATK_ROLE_INVALID;
}
#ifdef DEBUG_A11Y
nsAccessibleWrap *testAccWrap = GetAccessibleWrap(aAtkObj);
NS_ASSERTION(nsAccessible::IsTextInterfaceSupportCorrect(testAccWrap), "Does not support nsIAccessibleText when it should");
NS_ASSERTION(nsAccessible::IsTextInterfaceSupportCorrect(accWrap), "Does not support nsIAccessibleText when it should");
#endif
if (aAtkObj->role == ATK_ROLE_INVALID) {
nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj);
PRUint32 accRole, atkRole;
nsresult rv = accWrap->GetFinalRole(&accRole);
NS_ENSURE_SUCCESS(rv, ATK_ROLE_INVALID);
@ -821,32 +820,27 @@ GetAttributeSet(nsIAccessible* aAccessible)
AtkAttributeSet *
getAttributesCB(AtkObject *aAtkObj)
{
if (NS_FAILED(CheckMaiAtkObject(aAtkObj))) {
return nsnull;
}
nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj);
return GetAttributeSet(accWrap);
return accWrap ? GetAttributeSet(accWrap) : nsnull;
}
AtkObject *
getParentCB(AtkObject *aAtkObj)
{
if (NS_FAILED(CheckMaiAtkObject(aAtkObj))) {
return nsnull;
}
nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj);
if (!aAtkObj->accessible_parent) {
nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj);
if (!accWrap) {
return nsnull;
}
nsCOMPtr<nsIAccessible> accParent;
nsresult rv = accWrap->GetParent(getter_AddRefs(accParent));
if (NS_FAILED(rv) || !accParent)
return nsnull;
nsCOMPtr<nsIAccessible> accParent;
nsresult rv = accWrap->GetParent(getter_AddRefs(accParent));
if (NS_FAILED(rv) || !accParent)
return nsnull;
void *parentAtkObj = nsnull;
accParent->GetNativeInterface(&parentAtkObj);
if (parentAtkObj && !aAtkObj->accessible_parent) {
atk_object_set_parent(aAtkObj, ATK_OBJECT(parentAtkObj));
atk_object_set_parent(aAtkObj,
nsAccessibleWrap::GetAtkObject(accParent));
}
return aAtkObj->accessible_parent;
}
@ -854,10 +848,10 @@ getParentCB(AtkObject *aAtkObj)
gint
getChildCountCB(AtkObject *aAtkObj)
{
if (NS_FAILED(CheckMaiAtkObject(aAtkObj))) {
return 0;
}
nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj);
if (!accWrap) {
return 0;
}
PRInt32 count = 0;
nsCOMPtr<nsIAccessibleHyperText> hyperText;
@ -888,10 +882,10 @@ refChildCB(AtkObject *aAtkObj, gint aChildIndex)
// Either we can cache the last accessed child so that we can just GetNextSibling()
// or we should cache an array of children in each nsAccessible
// (instead of mNextSibling on the children)
if (NS_FAILED(CheckMaiAtkObject(aAtkObj))) {
return nsnull;
}
nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj);
if (!accWrap) {
return nsnull;
}
nsresult rv;
nsCOMPtr<nsIAccessible> accChild;
@ -914,14 +908,12 @@ refChildCB(AtkObject *aAtkObj, gint aChildIndex)
if (NS_FAILED(rv) || !accChild)
return nsnull;
void* childAtkObjPtr = nsnull;
accChild->GetNativeInterface(&childAtkObjPtr);
AtkObject* childAtkObj = nsAccessibleWrap::GetAtkObject(accChild);
NS_ASSERTION(childAtkObjPtr, "Fail to get AtkObj");
if (!childAtkObjPtr)
NS_ASSERTION(childAtkObj, "Fail to get AtkObj");
if (!childAtkObj)
return nsnull;
AtkObject* childAtkObj = ATK_OBJECT(childAtkObjPtr);
//this will addref parent
atk_object_set_parent(childAtkObj, aAtkObj);
g_object_ref(childAtkObj);
@ -933,10 +925,10 @@ getIndexInParentCB(AtkObject *aAtkObj)
{
// We don't use nsIAccessible::GetIndexInParent() because
// for ATK we don't want to include text leaf nodes as children
if (NS_FAILED(CheckMaiAtkObject(aAtkObj))) {
return -1;
}
nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj);
if (!accWrap) {
return -1;
}
nsCOMPtr<nsIAccessible> parent;
accWrap->GetParent(getter_AddRefs(parent));
@ -1000,14 +992,13 @@ refStateSetCB(AtkObject *aAtkObj)
AtkStateSet *state_set = nsnull;
state_set = ATK_OBJECT_CLASS(parent_class)->ref_state_set(aAtkObj);
if (NS_FAILED(CheckMaiAtkObject(aAtkObj))) {
nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj);
if (!accWrap) {
TranslateStates(nsIAccessibleStates::EXT_STATE_DEFUNCT,
gAtkStateMapExt, state_set);
return state_set;
}
nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj);
// Map states
PRUint32 accState = 0, accExtState = 0;
nsresult rv = accWrap->GetFinalState(&accState, &accExtState);
@ -1025,10 +1016,10 @@ refRelationSetCB(AtkObject *aAtkObj)
AtkRelationSet *relation_set = nsnull;
relation_set = ATK_OBJECT_CLASS(parent_class)->ref_relation_set(aAtkObj);
if (NS_FAILED(CheckMaiAtkObject(aAtkObj))) {
return relation_set;
}
nsAccessibleWrap *accWrap = GetAccessibleWrap(aAtkObj);
if (!accWrap) {
return relation_set;
}
AtkObject *accessible_array[1];
AtkRelation* relation;
@ -1054,9 +1045,7 @@ refRelationSetCB(AtkObject *aAtkObj)
nsIAccessible* accRelated;
nsresult rv = accWrap->GetAccessibleRelated(relationType[i], &accRelated);
if (NS_SUCCEEDED(rv) && accRelated) {
void *relatedAtkObj = nsnull;
accRelated->GetNativeInterface(&relatedAtkObj);
accessible_array[0] = ATK_OBJECT(relatedAtkObj);
accessible_array[0] = nsAccessibleWrap::GetAtkObject(accRelated);
relation = atk_relation_new(accessible_array, 1,
NS_STATIC_CAST(AtkRelationType, relationType[i]));
atk_relation_set_add(relation_set, relation);
@ -1067,38 +1056,28 @@ refRelationSetCB(AtkObject *aAtkObj)
return relation_set;
}
// Check if aAtkObj is a valid MaiAtkObject
nsresult
CheckMaiAtkObject(AtkObject *aAtkObj)
// Check if aAtkObj is a valid MaiAtkObject, and return the nsAccessibleWrap
// for it.
nsAccessibleWrap *GetAccessibleWrap(AtkObject *aAtkObj)
{
NS_ENSURE_ARG(IS_MAI_OBJECT(aAtkObj));
nsAccessibleWrap * tmpAccWrap = GetAccessibleWrap(aAtkObj);
NS_ENSURE_TRUE(IS_MAI_OBJECT(aAtkObj), nsnull);
nsAccessibleWrap *tmpAccWrap = MAI_ATK_OBJECT(aAtkObj)->accWrap;
// Check if AccessibleWrap was deconstructed
if (tmpAccWrap == nsnull) {
return NS_ERROR_NULL_POINTER;
return nsnull;
}
NS_ENSURE_TRUE(tmpAccWrap->GetAtkObject() == aAtkObj, nsnull);
nsRefPtr<nsApplicationAccessibleWrap> appAccWrap =
nsAccessNode::GetApplicationAccessible();
nsAccessibleWrap* tmpAppAccWrap =
NS_STATIC_CAST(nsAccessibleWrap*, appAccWrap.get());
if (tmpAppAccWrap != tmpAccWrap && !tmpAccWrap->IsValidObject())
return NS_ERROR_INVALID_POINTER;
return nsnull;
NS_ENSURE_TRUE(tmpAccWrap->GetAtkObject() == aAtkObj, NS_ERROR_FAILURE);
return NS_OK;
}
// Check if aAtkObj is a valid MaiAtkObject, and return the nsAccessibleWrap
// for it.
nsAccessibleWrap *GetAccessibleWrap(AtkObject *aAtkObj)
{
NS_ENSURE_TRUE(IS_MAI_OBJECT(aAtkObj), nsnull);
nsAccessibleWrap * tmpAccWrap = MAI_ATK_OBJECT(aAtkObj)->accWrap;
NS_ENSURE_TRUE(tmpAccWrap != nsnull, nsnull);
NS_ENSURE_TRUE(tmpAccWrap->GetAtkObject() == aAtkObj, nsnull);
return tmpAccWrap;
}
@ -1112,14 +1091,12 @@ nsAccessibleWrap::FireAccessibleEvent(nsIAccessibleEvent *aEvent)
aEvent->GetAccessible(getter_AddRefs(accessible));
NS_ENSURE_TRUE(accessible, NS_ERROR_FAILURE);
void *atkObjPtr = nsnull;
accessible->GetNativeInterface(&atkObjPtr);
PRUint32 type = 0;
rv = aEvent->GetEventType(&type);
NS_ENSURE_SUCCESS(rv, rv);
AtkObject *atkObj = ATK_OBJECT(atkObjPtr);
AtkObject *atkObj = nsAccessibleWrap::GetAtkObject(accessible);
// We don't create ATK objects for nsIAccessible plain text leaves,
// just return NS_OK in such case
if (!atkObj) {

View File

@ -100,6 +100,7 @@ public:
NS_IMETHOD FireAccessibleEvent(nsIAccessibleEvent *aEvent);
AtkObject * GetAtkObject(void);
static AtkObject * GetAtkObject(nsIAccessible * acc);
PRBool IsValidObject();

View File

@ -591,9 +591,9 @@ nsApplicationAccessibleWrap::AddRootAccessible(nsIAccessible *aRootAccWrap)
nsresult rv = nsApplicationAccessible::AddRootAccessible(aRootAccWrap);
NS_ENSURE_SUCCESS(rv, rv);
void* atkAccessible;
aRootAccWrap->GetNativeInterface(&atkAccessible);
atk_object_set_parent((AtkObject*)atkAccessible, mAtkObject);
AtkObject *atkAccessible = nsAccessibleWrap::GetAtkObject(aRootAccWrap);
atk_object_set_parent(atkAccessible, mAtkObject);
PRUint32 count = 0;
mChildren->GetLength(&count);
g_signal_emit_by_name(mAtkObject, "children_changed::add", count - 1,
@ -624,9 +624,8 @@ nsApplicationAccessibleWrap::RemoveRootAccessible(nsIAccessible *aRootAccWrap)
nsCOMPtr<nsIWeakReference> weakPtr = do_GetWeakReference(aRootAccWrap);
rv = mChildren->IndexOf(0, weakPtr, &index);
void* atkAccessible;
aRootAccWrap->GetNativeInterface(&atkAccessible);
atk_object_set_parent((AtkObject*)atkAccessible, NULL);
AtkObject *atkAccessible = nsAccessibleWrap::GetAtkObject(aRootAccWrap);
atk_object_set_parent(atkAccessible, NULL);
g_signal_emit_by_name(mAtkObject, "children_changed::remove", index,
atkAccessible, NULL);

View File

@ -78,17 +78,18 @@ NS_IMETHODIMP nsDocAccessibleWrap::FireToolkitEvent(PRUint32 aEvent,
MAI_LOG_DEBUG(("\n\nReceived event: aEvent=%u, obj=0x%x, data=0x%x \n",
aEvent, aAccessible, aEventData));
void *atkObjPtr = nsnull;
aAccessible->GetNativeInterface(&atkObjPtr);
AtkObject *atkObj = nsAccessibleWrap::GetAtkObject(aAccessible);
// We don't create ATK objects for nsIAccessible plain text leaves,
// just return NS_OK in such case
if (!atkObjPtr) {
if (!atkObj) {
NS_ASSERTION(aEvent == nsIAccessibleEvent::EVENT_SHOW ||
aEvent == nsIAccessibleEvent::EVENT_HIDE,
"Event other than SHOW and HIDE fired for plain text leaves");
return NS_OK;
}
AtkObject *atkObj = ATK_OBJECT(atkObjPtr);
nsAccessibleWrap *accWrap = GetAccessibleWrap(atkObj);
AtkTableChange * pAtkTableChange = nsnull;

View File

@ -81,7 +81,6 @@ PR_END_MACRO
MAI_TYPE_ATK_OBJECT, \
MaiAtkObjectClass))
GType mai_atk_object_get_type(void);
nsresult CheckMaiAtkObject(AtkObject *aAtkObj);
nsAccessibleWrap *GetAccessibleWrap(AtkObject *aAtkObj);
#endif /* __NS_MAI_H__ */

View File

@ -246,13 +246,9 @@ getObjectCB(AtkHyperlink *aLink, gint aLinkIndex)
accHyperlink->GetObject(aLinkIndex, getter_AddRefs(accObj));
NS_ENSURE_TRUE(accObj, nsnull);
void *atkObj = nsnull;
accObj->GetNativeInterface(&atkObj);
if (!atkObj) {
return nsnull;
}
AtkObject *atkObj = nsAccessibleWrap::GetAtkObject(accObj);
//no need to add ref it, because it is "get" not "ref"
return ATK_OBJECT(atkObj);
return atkObj;
}
gint

View File

@ -59,7 +59,8 @@ gboolean
doActionCB(AtkAction *aAction, gint aActionIndex)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
NS_ENSURE_TRUE(accWrap, FALSE);
if (!accWrap)
return FALSE;
nsresult rv = accWrap->DoAction(aActionIndex);
return (NS_FAILED(rv)) ? FALSE : TRUE;
@ -69,7 +70,8 @@ gint
getActionCountCB(AtkAction *aAction)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
NS_ENSURE_TRUE(accWrap, 0);
if (!accWrap)
return 0;
PRUint8 num = 0;
nsresult rv = accWrap->GetNumActions(&num);
@ -80,7 +82,8 @@ const gchar *
getActionDescriptionCB(AtkAction *aAction, gint aActionIndex)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
NS_ENSURE_TRUE(accWrap, nsnull);
if (!accWrap)
return nsnull;
nsAutoString description;
nsresult rv = accWrap->GetActionDescription(aActionIndex, description);
@ -92,7 +95,8 @@ const gchar *
getActionNameCB(AtkAction *aAction, gint aActionIndex)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
NS_ENSURE_TRUE(accWrap, nsnull);
if (!accWrap)
return nsnull;
nsAutoString autoStr;
nsresult rv = accWrap->GetActionName(aActionIndex, autoStr);
@ -104,7 +108,8 @@ const gchar *
getKeyBindingCB(AtkAction *aAction, gint aActionIndex)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aAction));
NS_ENSURE_TRUE(accWrap, nsnull);
if (!accWrap)
return nsnull;
//return all KeyBindings including accesskey and shortcut
nsAutoString allKeyBinding;

View File

@ -69,7 +69,8 @@ refAccessibleAtPointCB(AtkComponent *aComponent,
AtkCoordType aCoordType)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aComponent));
NS_ENSURE_TRUE(accWrap, nsnull);
if (!accWrap)
return nsnull;
// or ATK_XY_SCREEN what is definition this in nsIAccessible ???
if (aCoordType == ATK_XY_WINDOW) {
@ -82,13 +83,10 @@ refAccessibleAtPointCB(AtkComponent *aComponent,
return nsnull;
}
void *atkObjPtr = nsnull;
pointAcc->GetNativeInterface(&atkObjPtr);
if (!atkObjPtr) {
return nsnull;
AtkObject *atkObj = nsAccessibleWrap::GetAtkObject(pointAcc);
if (atkObj) {
g_object_ref(atkObj);
}
AtkObject *atkObj = ATK_OBJECT(atkObjPtr);
g_object_ref(atkObj);
return atkObj;
}
@ -151,7 +149,8 @@ gboolean
grabFocusCB(AtkComponent *aComponent)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aComponent));
NS_ENSURE_TRUE(accWrap, FALSE);
if (!accWrap)
return FALSE;
nsresult rv = accWrap->TakeFocus();
return (NS_FAILED(rv)) ? FALSE : TRUE;

View File

@ -67,7 +67,8 @@ const gchar *
getDocumentLocaleCB(AtkDocument *aDocument)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument));
NS_ENSURE_TRUE(accWrap, nsnull);
if (!accWrap)
return nsnull;
nsCOMPtr<nsIAccessNode> docAccessNode;
accWrap->QueryInterface(NS_GET_IID(nsIAccessNode),
@ -86,7 +87,8 @@ const gchar *
getDocumentTypeCB(AtkDocument *aDocument)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument));
NS_ENSURE_TRUE(accWrap, nsnull);
if (!accWrap)
return nsnull;
nsCOMPtr<nsIAccessibleDocument> accDocument;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleDocument),
@ -113,7 +115,8 @@ AtkAttributeSet *
getDocumentAttributesCB(AtkDocument *aDocument)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument));
NS_ENSURE_TRUE(accWrap, nsnull);
if (!accWrap)
return nsnull;
nsCOMPtr<nsIAccessibleDocument> accDocument;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleDocument),
@ -147,7 +150,8 @@ getDocumentAttributeValueCB(AtkDocument *aDocument,
const gchar *aAttrName)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument));
NS_ENSURE_TRUE(accWrap, nsnull);
if (!accWrap)
return nsnull;
nsCOMPtr<nsIAccessibleDocument> accDocument;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleDocument),

View File

@ -65,7 +65,8 @@ setRunAttributesCB(AtkEditableText *aText, AtkAttributeSet *aAttribSet,
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
NS_ENSURE_TRUE(accWrap, FALSE);
if (!accWrap)
return FALSE;
nsCOMPtr<nsIAccessibleEditableText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleEditableText),

View File

@ -53,7 +53,8 @@ AtkHyperlink*
getHyperlinkCB(AtkHyperlinkImpl *aImpl)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aImpl));
NS_ENSURE_TRUE(accWrap, nsnull);
if (!accWrap)
return nsnull;
nsCOMPtr<nsIAccessibleHyperLink> accHyperlink;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleHyperLink),

View File

@ -55,9 +55,9 @@ hypertextInterfaceInitCB(AtkHypertextIface *aIface)
AtkHyperlink *
getLinkCB(AtkHypertext *aText, gint aLinkIndex)
{
nsresult rv;
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
NS_ENSURE_TRUE(accWrap, nsnull);
if (!accWrap)
return nsnull;
nsCOMPtr<nsIAccessibleHyperText> hyperText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleHyperText),
@ -65,14 +65,13 @@ getLinkCB(AtkHypertext *aText, gint aLinkIndex)
NS_ENSURE_TRUE(hyperText, nsnull);
nsCOMPtr<nsIAccessibleHyperLink> hyperLink;
rv = hyperText->GetLink(aLinkIndex, getter_AddRefs(hyperLink));
nsresult rv = hyperText->GetLink(aLinkIndex, getter_AddRefs(hyperLink));
if (NS_FAILED(rv) || !hyperLink)
return nsnull;
nsCOMPtr<nsIAccessible> hyperLinkAcc(do_QueryInterface(hyperLink));
void *hyperLinkAtkObj = nsnull;
hyperLinkAcc->GetNativeInterface(&hyperLinkAtkObj);
nsAccessibleWrap *accChild = GetAccessibleWrap(ATK_OBJECT(hyperLinkAtkObj));
AtkObject *hyperLinkAtkObj = nsAccessibleWrap::GetAtkObject(hyperLinkAcc);
nsAccessibleWrap *accChild = GetAccessibleWrap(hyperLinkAtkObj);
NS_ENSURE_TRUE(accChild, nsnull);
MaiHyperlink *maiHyperlink = accChild->GetMaiHyperlink();
@ -84,7 +83,8 @@ gint
getLinkCountCB(AtkHypertext *aText)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
NS_ENSURE_TRUE(accWrap, -1);
if (!accWrap)
return -1;
nsCOMPtr<nsIAccessibleHyperText> accHyperlink;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleHyperText),
@ -102,7 +102,8 @@ gint
getLinkIndexCB(AtkHypertext *aText, gint aCharIndex)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
NS_ENSURE_TRUE(accWrap, -1);
if (!accWrap)
return -1;
nsCOMPtr<nsIAccessibleHyperText> accHyperlink;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleHyperText),

View File

@ -60,7 +60,8 @@ gboolean
addSelectionCB(AtkSelection *aSelection, gint i)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
NS_ENSURE_TRUE(accWrap, FALSE);
if (!accWrap)
return FALSE;
nsCOMPtr<nsIAccessibleSelectable> accSelection;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleSelectable),
@ -74,7 +75,8 @@ gboolean
clearSelectionCB(AtkSelection *aSelection)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
NS_ENSURE_TRUE(accWrap, FALSE);
if (!accWrap)
return FALSE;
nsCOMPtr<nsIAccessibleSelectable> accSelection;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleSelectable),
@ -88,7 +90,8 @@ AtkObject *
refSelectionCB(AtkSelection *aSelection, gint i)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
NS_ENSURE_TRUE(accWrap, nsnull);
if (!accWrap)
return nsnull;
nsCOMPtr<nsIAccessibleSelectable> accSelection;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleSelectable),
@ -100,13 +103,11 @@ refSelectionCB(AtkSelection *aSelection, gint i)
if (!accSelect) {
return nsnull;
}
void *atkObjPtr = nsnull;
accSelect->GetNativeInterface(&atkObjPtr);
if (!atkObjPtr) {
return nsnull;
AtkObject *atkObj = nsAccessibleWrap::GetAtkObject(accSelect);
if (atkObj) {
g_object_ref(atkObj);
}
AtkObject *atkObj = ATK_OBJECT(atkObjPtr);
g_object_ref(atkObj);
return atkObj;
}
@ -114,7 +115,8 @@ gint
getSelectionCountCB(AtkSelection *aSelection)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
NS_ENSURE_TRUE(accWrap, -1);
if (!accWrap)
return -1;
nsCOMPtr<nsIAccessibleSelectable> accSelection;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleSelectable),
@ -130,7 +132,8 @@ gboolean
isChildSelectedCB(AtkSelection *aSelection, gint i)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
NS_ENSURE_TRUE(accWrap, FALSE);
if (!accWrap)
return FALSE;
nsCOMPtr<nsIAccessibleSelectable> accSelection;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleSelectable),
@ -146,7 +149,8 @@ gboolean
removeSelectionCB(AtkSelection *aSelection, gint i)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
NS_ENSURE_TRUE(accWrap, FALSE);
if (!accWrap)
return FALSE;
nsCOMPtr<nsIAccessibleSelectable> accSelection;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleSelectable),
@ -161,7 +165,8 @@ gboolean
selectAllSelectionCB(AtkSelection *aSelection)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aSelection));
NS_ENSURE_TRUE(accWrap, FALSE);
if (!accWrap)
return FALSE;
nsCOMPtr<nsIAccessibleSelectable> accSelection;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleSelectable),

View File

@ -72,7 +72,8 @@ AtkObject*
refAtCB(AtkTable *aTable, gint aRow, gint aColumn)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
NS_ENSURE_TRUE(accWrap, nsnull);
if (!accWrap)
return nsnull;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@ -84,13 +85,10 @@ refAtCB(AtkTable *aTable, gint aRow, gint aColumn)
if (NS_FAILED(rv) || !cell)
return nsnull;
void *cellAtkObjPtr = nsnull;
cell->GetNativeInterface(&cellAtkObjPtr);
if (!cellAtkObjPtr)
return nsnull;
AtkObject *cellAtkObj = ATK_OBJECT(cellAtkObjPtr);
g_object_ref(cellAtkObj);
AtkObject *cellAtkObj = nsAccessibleWrap::GetAtkObject(cell);
if (cellAtkObj) {
g_object_ref(cellAtkObj);
}
return cellAtkObj;
}
@ -98,7 +96,8 @@ gint
getIndexAtCB(AtkTable *aTable, gint aRow, gint aColumn)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
NS_ENSURE_TRUE(accWrap, -1);
if (!accWrap)
return -1;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@ -116,7 +115,8 @@ gint
getColumnAtIndexCB(AtkTable *aTable, gint aIndex)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
NS_ENSURE_TRUE(accWrap, -1);
if (!accWrap)
return -1;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@ -134,7 +134,8 @@ gint
getRowAtIndexCB(AtkTable *aTable, gint aIndex)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
NS_ENSURE_TRUE(accWrap, -1);
if (!accWrap)
return -1;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@ -152,7 +153,8 @@ gint
getColumnCountCB(AtkTable *aTable)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
NS_ENSURE_TRUE(accWrap, -1);
if (!accWrap)
return -1;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@ -170,7 +172,8 @@ gint
getRowCountCB(AtkTable *aTable)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
NS_ENSURE_TRUE(accWrap, -1);
if (!accWrap)
return -1;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@ -189,7 +192,8 @@ getColumnExtentAtCB(AtkTable *aTable,
gint aRow, gint aColumn)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
NS_ENSURE_TRUE(accWrap, -1);
if (!accWrap)
return -1;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@ -208,7 +212,8 @@ getRowExtentAtCB(AtkTable *aTable,
gint aRow, gint aColumn)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
NS_ENSURE_TRUE(accWrap, -1);
if (!accWrap)
return -1;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@ -226,7 +231,8 @@ AtkObject*
getCaptionCB(AtkTable *aTable)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
NS_ENSURE_TRUE(accWrap, nsnull);
if (!accWrap)
return nsnull;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@ -238,16 +244,15 @@ getCaptionCB(AtkTable *aTable)
if (NS_FAILED(rv) || !caption)
return nsnull;
void *captionAtkObj = nsnull;
caption->GetNativeInterface(&captionAtkObj);
return ATK_OBJECT(captionAtkObj);
return nsAccessibleWrap::GetAtkObject(caption);
}
const gchar*
getColumnDescriptionCB(AtkTable *aTable, gint aColumn)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
NS_ENSURE_TRUE(accWrap, nsnull);
if (!accWrap)
return nsnull;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@ -265,7 +270,8 @@ AtkObject*
getColumnHeaderCB(AtkTable *aTable, gint aColumn)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
NS_ENSURE_TRUE(accWrap, nsnull);
if (!accWrap)
return nsnull;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@ -290,16 +296,15 @@ getColumnHeaderCB(AtkTable *aTable, gint aColumn)
header->CellRefAt(0, aColumn, getter_AddRefs(accHeader));
NS_ENSURE_TRUE(accHeader, nsnull);
void *headerAtkObj = nsnull;
accHeader->GetNativeInterface(&headerAtkObj);
return ATK_OBJECT(headerAtkObj);
return nsAccessibleWrap::GetAtkObject(accHeader);
}
const gchar*
getRowDescriptionCB(AtkTable *aTable, gint aRow)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
NS_ENSURE_TRUE(accWrap, nsnull);
if (!accWrap)
return nsnull;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@ -317,7 +322,8 @@ AtkObject*
getRowHeaderCB(AtkTable *aTable, gint aRow)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
NS_ENSURE_TRUE(accWrap, nsnull);
if (!accWrap)
return nsnull;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@ -331,9 +337,7 @@ getRowHeaderCB(AtkTable *aTable, gint aRow)
nsCOMPtr<nsIAccessible> accHeader(do_QueryInterface(header));
NS_ENSURE_TRUE(accHeader, nsnull);
void *headerAtkObj = nsnull;
accHeader->GetNativeInterface(&headerAtkObj);
return ATK_OBJECT(headerAtkObj);
return nsAccessibleWrap::GetAtkObject(accHeader);
}
AtkObject*
@ -347,7 +351,8 @@ gint
getSelectedColumnsCB(AtkTable *aTable, gint **aSelected)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
NS_ENSURE_TRUE(accWrap, 0);
if (!accWrap)
return 0;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@ -381,7 +386,8 @@ gint
getSelectedRowsCB(AtkTable *aTable, gint **aSelected)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
NS_ENSURE_TRUE(accWrap, 0);
if (!accWrap)
return 0;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@ -415,7 +421,8 @@ gboolean
isColumnSelectedCB(AtkTable *aTable, gint aColumn)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
NS_ENSURE_TRUE(accWrap, FALSE);
if (!accWrap)
return FALSE;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@ -431,7 +438,8 @@ gboolean
isRowSelectedCB(AtkTable *aTable, gint aRow)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
NS_ENSURE_TRUE(accWrap, FALSE);
if (!accWrap)
return FALSE;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
@ -447,7 +455,8 @@ gboolean
isCellSelectedCB(AtkTable *aTable, gint aRow, gint aColumn)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
NS_ENSURE_TRUE(accWrap, FALSE);
if (!accWrap)
return FALSE;
nsCOMPtr<nsIAccessibleTable> accTable;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),

View File

@ -89,7 +89,8 @@ gchar *
getTextCB(AtkText *aText, gint aStartOffset, gint aEndOffset)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
NS_ENSURE_TRUE(accWrap, nsnull);
if (!accWrap)
return nsnull;
nsCOMPtr<nsIAccessibleText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
@ -113,7 +114,8 @@ getTextAfterOffsetCB(AtkText *aText, gint aOffset,
gint *aStartOffset, gint *aEndOffset)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
NS_ENSURE_TRUE(accWrap, nsnull);
if (!accWrap)
return nsnull;
nsCOMPtr<nsIAccessibleText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
@ -141,7 +143,8 @@ getTextAtOffsetCB(AtkText *aText, gint aOffset,
gint *aStartOffset, gint *aEndOffset)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
NS_ENSURE_TRUE(accWrap, nsnull);
if (!accWrap)
return nsnull;
nsCOMPtr<nsIAccessibleText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
@ -167,7 +170,8 @@ gunichar
getCharacterAtOffsetCB(AtkText *aText, gint aOffset)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
NS_ENSURE_TRUE(accWrap, 0);
if (!accWrap)
return 0;
nsCOMPtr<nsIAccessibleText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
@ -196,7 +200,8 @@ getTextBeforeOffsetCB(AtkText *aText, gint aOffset,
gint *aStartOffset, gint *aEndOffset)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
NS_ENSURE_TRUE(accWrap, nsnull);
if (!accWrap)
return nsnull;
nsCOMPtr<nsIAccessibleText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
@ -222,7 +227,8 @@ gint
getCaretOffsetCB(AtkText *aText)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
NS_ENSURE_TRUE(accWrap, 0);
if (!accWrap)
return 0;
nsCOMPtr<nsIAccessibleText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
@ -240,7 +246,8 @@ getRunAttributesCB(AtkText *aText, gint aOffset,
gint *aEndOffset)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
NS_ENSURE_TRUE(accWrap, nsnull);
if (!accWrap)
return nsnull;
nsCOMPtr<nsIAccessibleText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
@ -341,7 +348,8 @@ gint
getCharacterCountCB(AtkText *aText)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
NS_ENSURE_TRUE(accWrap, 0);
if (!accWrap)
return 0;
nsCOMPtr<nsIAccessibleText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
@ -359,7 +367,8 @@ getOffsetAtPointCB(AtkText *aText,
AtkCoordType aCoords)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
NS_ENSURE_TRUE(accWrap, -1);
if (!accWrap)
return -1;
nsCOMPtr<nsIAccessibleText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
@ -381,7 +390,8 @@ gint
getTextSelectionCountCB(AtkText *aText)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
NS_ENSURE_TRUE(accWrap, nsnull);
if (!accWrap)
return nsnull;
nsCOMPtr<nsIAccessibleText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
@ -398,7 +408,8 @@ getTextSelectionCB(AtkText *aText, gint aSelectionNum,
gint *aStartOffset, gint *aEndOffset)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
NS_ENSURE_TRUE(accWrap, nsnull);
if (!accWrap)
return nsnull;
nsCOMPtr<nsIAccessibleText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
@ -424,7 +435,8 @@ addTextSelectionCB(AtkText *aText,
gint aEndOffset)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
NS_ENSURE_TRUE(accWrap, FALSE);
if (!accWrap)
return FALSE;
nsCOMPtr<nsIAccessibleText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
@ -441,7 +453,8 @@ removeTextSelectionCB(AtkText *aText,
gint aSelectionNum)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
NS_ENSURE_TRUE(accWrap, FALSE);
if (!accWrap)
return FALSE;
nsCOMPtr<nsIAccessibleText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
@ -458,7 +471,8 @@ setTextSelectionCB(AtkText *aText, gint aSelectionNum,
gint aStartOffset, gint aEndOffset)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
NS_ENSURE_TRUE(accWrap, FALSE);
if (!accWrap)
return FALSE;
nsCOMPtr<nsIAccessibleText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
@ -474,7 +488,8 @@ gboolean
setCaretOffsetCB(AtkText *aText, gint aOffset)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
NS_ENSURE_TRUE(accWrap, FALSE);
if (!accWrap)
return FALSE;
nsCOMPtr<nsIAccessibleText> accText;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),

View File

@ -142,7 +142,8 @@ gboolean
setCurrentValueCB(AtkValue *obj, const GValue *value)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
NS_ENSURE_TRUE(accWrap, FALSE);
if (!accWrap)
return FALSE;
nsCOMPtr<nsIAccessibleValue> accValue;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),