From 31e85b7ce242f5a79e97a026d510eb52590975b8 Mon Sep 17 00:00:00 2001 From: "ginn.chen%sun.com" Date: Mon, 29 May 2006 05:46:38 +0000 Subject: [PATCH] Bug 339314 remove the unnecessary nsMaiInterface classes r=aaronleventhal git-svn-id: svn://10.0.0.236/trunk@198550 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/accessible/public/atk/Makefile.in | 1 - mozilla/accessible/src/atk/Makefile.in | 1 - .../accessible/src/atk/nsAccessibleWrap.cpp | 179 +++++++----------- mozilla/accessible/src/atk/nsAccessibleWrap.h | 17 +- mozilla/accessible/src/atk/nsMaiHyperlink.cpp | 4 +- mozilla/accessible/src/atk/nsMaiHyperlink.h | 7 +- .../src/atk/nsMaiInterfaceAction.cpp | 89 +-------- .../accessible/src/atk/nsMaiInterfaceAction.h | 31 +-- .../src/atk/nsMaiInterfaceComponent.cpp | 60 +----- .../src/atk/nsMaiInterfaceComponent.h | 39 +++- .../src/atk/nsMaiInterfaceEditableText.cpp | 49 +---- .../src/atk/nsMaiInterfaceEditableText.h | 27 ++- .../src/atk/nsMaiInterfaceHypertext.cpp | 97 +--------- .../src/atk/nsMaiInterfaceHypertext.h | 23 +-- .../src/atk/nsMaiInterfaceSelection.cpp | 49 +---- .../src/atk/nsMaiInterfaceSelection.h | 23 ++- .../src/atk/nsMaiInterfaceTable.cpp | 131 +------------ .../accessible/src/atk/nsMaiInterfaceTable.h | 95 +++++++--- .../accessible/src/atk/nsMaiInterfaceText.cpp | 113 ++--------- .../accessible/src/atk/nsMaiInterfaceText.h | 61 +++++- .../src/atk/nsMaiInterfaceValue.cpp | 45 +---- .../accessible/src/atk/nsMaiInterfaceValue.h | 19 +- 22 files changed, 334 insertions(+), 826 deletions(-) diff --git a/mozilla/accessible/public/atk/Makefile.in b/mozilla/accessible/public/atk/Makefile.in index 58ab50e2f9e..763f9de11ac 100644 --- a/mozilla/accessible/public/atk/Makefile.in +++ b/mozilla/accessible/public/atk/Makefile.in @@ -47,7 +47,6 @@ XPIDL_MODULE = accessibility-atk GRE_MODULE = 1 XPIDLSRCS = \ - nsIAccessibleAction.idl \ nsIAccessibleEditableText.idl \ nsIAccessibleHyperLink.idl \ nsIAccessibleHyperText.idl \ diff --git a/mozilla/accessible/src/atk/Makefile.in b/mozilla/accessible/src/atk/Makefile.in index 5e3378ac061..e944a7d3c9a 100644 --- a/mozilla/accessible/src/atk/Makefile.in +++ b/mozilla/accessible/src/atk/Makefile.in @@ -74,7 +74,6 @@ CPPSRCS = \ nsHTMLLinkAccessibleWrap.cpp \ nsHTMLTableAccessibleWrap.cpp \ nsHTMLBlockAccessible.cpp \ - nsMaiInterface.cpp \ nsMaiInterfaceComponent.cpp \ nsMaiInterfaceAction.cpp \ nsMaiInterfaceText.cpp \ diff --git a/mozilla/accessible/src/atk/nsAccessibleWrap.cpp b/mozilla/accessible/src/atk/nsAccessibleWrap.cpp index f4a36165339..665aed90c73 100644 --- a/mozilla/accessible/src/atk/nsAccessibleWrap.cpp +++ b/mozilla/accessible/src/atk/nsAccessibleWrap.cpp @@ -68,6 +68,47 @@ enum { LAST_SIGNAL }; +enum MaiInterfaceType { + MAI_INTERFACE_COMPONENT, /* 0 */ + MAI_INTERFACE_ACTION, + MAI_INTERFACE_VALUE, + MAI_INTERFACE_EDITABLE_TEXT, + MAI_INTERFACE_HYPERTEXT, + MAI_INTERFACE_SELECTION, + MAI_INTERFACE_TABLE, + MAI_INTERFACE_TEXT /* 7 */ +}; + +static const GType AtkTypeForMai[] = { + ATK_TYPE_COMPONENT, + ATK_TYPE_ACTION, + ATK_TYPE_VALUE, + ATK_TYPE_EDITABLE_TEXT, + ATK_TYPE_HYPERTEXT, + ATK_TYPE_SELECTION, + ATK_TYPE_TABLE, + ATK_TYPE_TEXT +}; + +static const GInterfaceInfo atk_if_infos[] = { + {(GInterfaceInitFunc)componentInterfaceInitCB, + (GInterfaceFinalizeFunc) NULL, NULL}, + {(GInterfaceInitFunc)actionInterfaceInitCB, + (GInterfaceFinalizeFunc) NULL, NULL}, + {(GInterfaceInitFunc)valueInterfaceInitCB, + (GInterfaceFinalizeFunc) NULL, NULL}, + {(GInterfaceInitFunc)editableTextInterfaceInitCB, + (GInterfaceFinalizeFunc) NULL, NULL}, + {(GInterfaceInitFunc)hypertextInterfaceInitCB, + (GInterfaceFinalizeFunc) NULL, NULL}, + {(GInterfaceInitFunc)selectionInterfaceInitCB, + (GInterfaceFinalizeFunc) NULL, NULL}, + {(GInterfaceInitFunc)tableInterfaceInitCB, + (GInterfaceFinalizeFunc) NULL, NULL}, + {(GInterfaceInitFunc)textInterfaceInitCB, + (GInterfaceFinalizeFunc) NULL, NULL} +}; + /** * This MaiAtkObject is a thin wrapper, in the MAI namespace, for AtkObject */ @@ -144,9 +185,8 @@ static AtkRelationSet* refRelationSetCB(AtkObject *aAtkObj); */ G_END_DECLS -static GType GetMaiAtkType(const PRUint32 & interfaceCount, - MaiInterface **interfaces); -static const char * GetUniqueMaiAtkTypeName(MaiInterface **interfaces); +static GType GetMaiAtkType(PRUint16 interfacesBits); +static const char * GetUniqueMaiAtkTypeName(PRUint16 interfacesBits); static gpointer parent_class = NULL; @@ -183,9 +223,7 @@ PRInt32 nsAccessibleWrap::mAccWrapDeleted = 0; nsAccessibleWrap::nsAccessibleWrap(nsIDOMNode* aNode, nsIWeakReference *aShell) : nsAccessible(aNode, aShell), - mMaiAtkObject(nsnull), - mInterfaces(nsnull), - mInterfaceCount(0) + mMaiAtkObject(nsnull) { #ifdef MAI_LOGGING ++mAccWrapCreated; @@ -209,11 +247,6 @@ nsAccessibleWrap::~nsAccessibleWrap() MAI_ATK_OBJECT(mMaiAtkObject)->accWrap = nsnull; g_object_unref(mMaiAtkObject); } - if (mInterfaces) { - for (int index = 0; index < MAI_INTERFACE_NUM; ++index) - delete mInterfaces[index]; - delete [] mInterfaces; - } } NS_IMETHODIMP nsAccessibleWrap::GetExtState(PRUint32 *aState) @@ -230,8 +263,7 @@ NS_IMETHODIMP nsAccessibleWrap::GetNativeInterface(void **aOutAccessible) *aOutAccessible = nsnull; if (!mMaiAtkObject) { - CreateMaiInterfaces(); - GType type = GetMaiAtkType(mInterfaceCount, mInterfaces); + GType type = GetMaiAtkType(CreateMaiInterfaces()); NS_ENSURE_TRUE(type, NS_ERROR_FAILURE); mMaiAtkObject = NS_REINTERPRET_CAST(AtkObject *, @@ -256,41 +288,25 @@ nsAccessibleWrap::GetAtkObject(void) } /* private */ -nsresult +PRUint16 nsAccessibleWrap::CreateMaiInterfaces(void) { - typedef MaiInterface * MaiInterfacePointer; - if (!mInterfaces) { - mInterfaces = new MaiInterfacePointer[MAI_INTERFACE_NUM]; - for (PRUint16 index = 0; index < MAI_INTERFACE_NUM; ++index) { - mInterfaces[index] = nsnull; - } - NS_ENSURE_TRUE(mInterfaces, NS_ERROR_OUT_OF_MEMORY); - } + PRUint16 interfacesBits = 0; + // Add Interfaces for each nsIAccessible.ext interfaces - nsresult rv; - // the Component interface are supported by all nsIAccessible - MaiInterfaceComponent *maiInterfaceComponent = - new MaiInterfaceComponent(this); - NS_ENSURE_TRUE(maiInterfaceComponent, NS_ERROR_OUT_OF_MEMORY); - rv = AddMaiInterface(maiInterfaceComponent); - NS_ENSURE_SUCCESS(rv, rv); + interfacesBits |= 1 << MAI_INTERFACE_COMPONENT; // Add Action interface if the action count is more than zero. PRUint8 actionCount = 0; - rv = GetNumActions(&actionCount); + nsresult rv = GetNumActions(&actionCount); if (NS_SUCCEEDED(rv) && actionCount > 0) { - MaiInterfaceAction *maiInterfaceAction = new MaiInterfaceAction(this); - NS_ENSURE_TRUE(maiInterfaceAction, NS_ERROR_OUT_OF_MEMORY); - rv = AddMaiInterface(maiInterfaceAction); - NS_ENSURE_SUCCESS(rv, rv); + interfacesBits |= 1 << MAI_INTERFACE_ACTION; } - PRUint32 accRole; - rv = GetRole(&accRole); + GetRole(&accRole); if (accRole != nsIAccessible::ROLE_HTML_CONTAINER) { //nsIAccessibleText @@ -298,10 +314,7 @@ nsAccessibleWrap::CreateMaiInterfaces(void) QueryInterface(NS_GET_IID(nsIAccessibleText), getter_AddRefs(accessInterfaceText)); if (accessInterfaceText) { - MaiInterfaceText *maiInterfaceText = new MaiInterfaceText(this); - NS_ENSURE_TRUE(maiInterfaceText, NS_ERROR_OUT_OF_MEMORY); - rv = AddMaiInterface(maiInterfaceText); - NS_ENSURE_SUCCESS(rv, rv); + interfacesBits |= 1 << MAI_INTERFACE_TEXT; } //nsIAccessibleEditableText @@ -309,11 +322,7 @@ nsAccessibleWrap::CreateMaiInterfaces(void) QueryInterface(NS_GET_IID(nsIAccessibleEditableText), getter_AddRefs(accessInterfaceEditableText)); if (accessInterfaceEditableText) { - MaiInterfaceEditableText *maiInterfaceEditableText = - new MaiInterfaceEditableText(this); - NS_ENSURE_TRUE(maiInterfaceEditableText, NS_ERROR_OUT_OF_MEMORY); - rv = AddMaiInterface(maiInterfaceEditableText); - NS_ENSURE_SUCCESS(rv, rv); + interfacesBits |= 1 << MAI_INTERFACE_EDITABLE_TEXT; } } @@ -322,11 +331,7 @@ nsAccessibleWrap::CreateMaiInterfaces(void) QueryInterface(NS_GET_IID(nsIAccessibleSelectable), getter_AddRefs(accessInterfaceSelection)); if (accessInterfaceSelection) { - MaiInterfaceSelection *maiInterfaceSelection = - new MaiInterfaceSelection(this); - NS_ENSURE_TRUE(maiInterfaceSelection, NS_ERROR_OUT_OF_MEMORY); - rv = AddMaiInterface(maiInterfaceSelection); - NS_ENSURE_SUCCESS(rv, rv); + interfacesBits |= 1 << MAI_INTERFACE_SELECTION; } //nsIAccessibleValue @@ -334,10 +339,7 @@ nsAccessibleWrap::CreateMaiInterfaces(void) QueryInterface(NS_GET_IID(nsIAccessibleValue), getter_AddRefs(accessInterfaceValue)); if (accessInterfaceValue) { - MaiInterfaceValue *maiInterfaceValue = new MaiInterfaceValue(this); - NS_ENSURE_TRUE(maiInterfaceValue, NS_ERROR_OUT_OF_MEMORY); - rv = AddMaiInterface(maiInterfaceValue); - NS_ENSURE_SUCCESS(rv, rv); + interfacesBits |= 1 << MAI_INTERFACE_VALUE; } //nsIAccessibleHypertext @@ -346,13 +348,9 @@ nsAccessibleWrap::CreateMaiInterfaces(void) QueryInterface(NS_GET_IID(nsIAccessibleHyperText), getter_AddRefs(accessInterfaceHypertext)); if (accessInterfaceHypertext) { - rv = accessInterfaceHypertext->GetLinks(&linkCount); + nsresult rv = accessInterfaceHypertext->GetLinks(&linkCount); if (NS_SUCCEEDED(rv) && (linkCount > 0)) { - MaiInterfaceHypertext *maiInterfaceHypertext = - new MaiInterfaceHypertext(this, mWeakShell); - NS_ENSURE_TRUE(maiInterfaceHypertext, NS_ERROR_OUT_OF_MEMORY); - rv = AddMaiInterface(maiInterfaceHypertext); - NS_ENSURE_SUCCESS(rv, rv); + interfacesBits |= 1 << MAI_INTERFACE_HYPERTEXT; } } @@ -365,44 +363,15 @@ nsAccessibleWrap::CreateMaiInterfaces(void) QueryInterface(NS_GET_IID(nsIAccessibleTable), getter_AddRefs(accessInterfaceTable)); if (accessInterfaceTable) { - MaiInterfaceTable *maiInterfaceTable = new MaiInterfaceTable(this); - NS_ENSURE_TRUE(maiInterfaceTable, NS_ERROR_OUT_OF_MEMORY); - rv = AddMaiInterface(maiInterfaceTable); - NS_ENSURE_SUCCESS(rv, rv); + interfacesBits |= 1 << MAI_INTERFACE_TABLE; } } - return rv; -} - -nsresult -nsAccessibleWrap::AddMaiInterface(MaiInterface *aMaiIface) -{ - NS_ENSURE_ARG_POINTER(aMaiIface); - MaiInterfaceType aMaiIfaceType = aMaiIface->GetType(); - - if ((aMaiIfaceType <= MAI_INTERFACE_INVALID) || - (aMaiIfaceType >= MAI_INTERFACE_NUM)) - return NS_ERROR_FAILURE; - - // if same type of If has been added, release previous one - if (mInterfaces[aMaiIfaceType]) { - delete mInterfaces[aMaiIfaceType]; - } - mInterfaces[aMaiIfaceType] = aMaiIface; - mInterfaceCount++; - return NS_OK; -} -MaiInterface * -nsAccessibleWrap::GetMaiInterface(PRInt16 aIfaceType) -{ - NS_ENSURE_TRUE(aIfaceType > MAI_INTERFACE_INVALID, nsnull); - NS_ENSURE_TRUE(aIfaceType < MAI_INTERFACE_NUM, nsnull); - return mInterfaces[aIfaceType]; + return interfacesBits; } static GType -GetMaiAtkType(const PRUint32 & interfaceCount, MaiInterface **interfaces) +GetMaiAtkType(PRUint16 interfacesBits) { GType type; static const GTypeInfo tinfo = { @@ -418,16 +387,13 @@ GetMaiAtkType(const PRUint32 & interfaceCount, MaiInterface **interfaces) NULL /* value table */ }; - if (interfaceCount == 0) - return MAI_TYPE_ATK_OBJECT; - /* * The members we used to register a GType are MaiInterface::GetAtkType() * and MaiInterface::GetInterfaceInfo(), which is the same with different * MaiInterface objects. So we can reuse the registered GType when having * the same MaiInterface types. */ - const char *atkTypeName = GetUniqueMaiAtkTypeName(interfaces); + const char *atkTypeName = GetUniqueMaiAtkTypeName(interfacesBits); type = g_type_from_name(atkTypeName); if (type) { return type; @@ -447,30 +413,27 @@ GetMaiAtkType(const PRUint32 & interfaceCount, MaiInterface **interfaces) return 0; } - for (int index = 0; index < MAI_INTERFACE_NUM; index++) { - if (!interfaces[index]) - continue; + for (PRUint32 index = 0; index < NS_ARRAY_LENGTH(AtkTypeForMai); index++) { + if (interfacesBits & (1 << index)) { g_type_add_interface_static(type, - interfaces[index]->GetAtkType(), - interfaces[index]->GetInterfaceInfo()); + AtkTypeForMai[index], + &atk_if_infos[index]); + } } + return type; } static const char * -GetUniqueMaiAtkTypeName(MaiInterface **interfaces) +GetUniqueMaiAtkTypeName(PRUint16 interfacesBits) { #define MAI_ATK_TYPE_NAME_LEN (30) /* 10+sizeof(PRUint16)*8/4+1 < 30 */ - PRUint16 atkTypeNameId = 0; static gchar namePrefix[] = "MaiAtkType"; /* size = 10 */ static gchar name[MAI_ATK_TYPE_NAME_LEN + 1]; - for (int index = 0; index < MAI_INTERFACE_NUM; index++) { - if (interfaces[index]) - atkTypeNameId |= 1 << index; - } - PR_snprintf(name, MAI_ATK_TYPE_NAME_LEN, "%s%x", namePrefix, atkTypeNameId); + PR_snprintf(name, MAI_ATK_TYPE_NAME_LEN, "%s%x", namePrefix, + interfacesBits); name[MAI_ATK_TYPE_NAME_LEN] = '\0'; MAI_LOG_DEBUG(("MaiWidget::LastedTypeName=%s\n", name)); diff --git a/mozilla/accessible/src/atk/nsAccessibleWrap.h b/mozilla/accessible/src/atk/nsAccessibleWrap.h index 3f7e2720c8c..76758e8be86 100644 --- a/mozilla/accessible/src/atk/nsAccessibleWrap.h +++ b/mozilla/accessible/src/atk/nsAccessibleWrap.h @@ -51,9 +51,6 @@ #define MAI_LOGGING #endif /* #ifdef PR_LOGGING */ -class nsAccessibleWrap; -class MaiInterface; - struct _AtkObject; typedef struct _AtkObject AtkObject; @@ -79,22 +76,24 @@ public: NS_IMETHOD GetExtState(PRUint32 *aState); AtkObject * GetAtkObject(void); - MaiInterface *GetMaiInterface(PRInt16 aIfaceType); PRBool IsValidObject(); static void TranslateStates(PRUint32 aState, PRUint32 aExtState, void *aAtkStateSet); + + static const char * ReturnString(nsAString &aString) { + static nsCString returnedString; + returnedString = NS_ConvertUTF16toUTF8(aString); + return returnedString.get(); + } + protected: AtkObject *mMaiAtkObject; private: - nsresult CreateMaiInterfaces(void); - nsresult AddMaiInterface(MaiInterface *aMaiIface); - - MaiInterface **mInterfaces; - PRUint32 mInterfaceCount; + PRUint16 CreateMaiInterfaces(void); }; #endif /* __NS_ACCESSIBLE_WRAP_H__ */ diff --git a/mozilla/accessible/src/atk/nsMaiHyperlink.cpp b/mozilla/accessible/src/atk/nsMaiHyperlink.cpp index 8582fba64d6..988b0f4e8fb 100644 --- a/mozilla/accessible/src/atk/nsMaiHyperlink.cpp +++ b/mozilla/accessible/src/atk/nsMaiHyperlink.cpp @@ -123,9 +123,7 @@ mai_atk_hyperlink_get_type(void) return type; } -MaiHyperlink::MaiHyperlink(nsIAccessibleHyperLink *aAcc, - nsIDOMNode *aNode, nsIWeakReference* aShell): - nsAccessNodeWrap(aNode, aShell), +MaiHyperlink::MaiHyperlink(nsIAccessibleHyperLink *aAcc): mHyperlink(aAcc), mMaiAtkHyperlink(nsnull) { diff --git a/mozilla/accessible/src/atk/nsMaiHyperlink.h b/mozilla/accessible/src/atk/nsMaiHyperlink.h index 8974d34e300..cd5a69437a2 100644 --- a/mozilla/accessible/src/atk/nsMaiHyperlink.h +++ b/mozilla/accessible/src/atk/nsMaiHyperlink.h @@ -41,8 +41,6 @@ #ifndef __MAI_HYPERLINK_H__ #define __MAI_HYPERLINK_H__ - -#include "nsString.h" #include "nsMai.h" #include "nsIAccessibleHyperLink.h" @@ -53,11 +51,10 @@ typedef struct _AtkHyperlink AtkHyperlink; * MaiHyperlink is a auxiliary class for MaiInterfaceHyperText. */ -class MaiHyperlink : public nsAccessNodeWrap +class MaiHyperlink { public: - MaiHyperlink(nsIAccessibleHyperLink *aAcc, - nsIDOMNode *aNode, nsIWeakReference* aShell); + MaiHyperlink(nsIAccessibleHyperLink *aAcc); ~MaiHyperlink(); NS_IMETHOD GetUniqueID(void **aUniqueID); diff --git a/mozilla/accessible/src/atk/nsMaiInterfaceAction.cpp b/mozilla/accessible/src/atk/nsMaiInterfaceAction.cpp index 324b12919c8..0c905acf0a9 100644 --- a/mozilla/accessible/src/atk/nsMaiInterfaceAction.cpp +++ b/mozilla/accessible/src/atk/nsMaiInterfaceAction.cpp @@ -39,52 +39,10 @@ * ***** END LICENSE BLOCK ***** */ #include "nsMaiInterfaceAction.h" -#include "nsAccessibleWrap.h" #include "nsString.h" -G_BEGIN_DECLS - -static void interfaceInitCB(AtkActionIface *aIface); -/* action interface callbacks */ -static gboolean doActionCB(AtkAction *aAction, gint aActionIndex); -static gint getActionCountCB(AtkAction *aAction); -static const gchar *getDescriptionCB(AtkAction *aAction, gint aActionIndex); -static const gchar *getNameCB(AtkAction *aAction, gint aActionIndex); -static const gchar *getKeyBindingCB(AtkAction *aAction, gint aActionIndex); -static gboolean setDescriptionCB(AtkAction *aAction, gint aActionIndex, - const gchar *aDesc); -G_END_DECLS - -MaiInterfaceAction::MaiInterfaceAction(nsAccessibleWrap *aAccWrap): - MaiInterface(aAccWrap) -{ -} - -MaiInterfaceAction::~MaiInterfaceAction() -{ -} - -MaiInterfaceType -MaiInterfaceAction::GetType() -{ - return MAI_INTERFACE_ACTION; -} - -const GInterfaceInfo * -MaiInterfaceAction::GetInterfaceInfo() -{ - static const GInterfaceInfo atk_if_action_info = { - (GInterfaceInitFunc)interfaceInitCB, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - return &atk_if_action_info; -} - -/* static functions */ - void -interfaceInitCB(AtkActionIface *aIface) +actionInterfaceInitCB(AtkActionIface *aIface) { NS_ASSERTION(aIface, "Invalid aIface"); if (!aIface) @@ -92,10 +50,9 @@ interfaceInitCB(AtkActionIface *aIface) aIface->do_action = doActionCB; aIface->get_n_actions = getActionCountCB; - aIface->get_description = getDescriptionCB; + aIface->get_description = getActionDescriptionCB; aIface->get_keybinding = getKeyBindingCB; - aIface->get_name = getNameCB; - aIface->set_description = setDescriptionCB; + aIface->get_name = getActionNameCB; } gboolean @@ -120,29 +77,22 @@ getActionCountCB(AtkAction *aAction) } const gchar * -getDescriptionCB(AtkAction *aAction, gint aActionIndex) +getActionDescriptionCB(AtkAction *aAction, gint aActionIndex) { - // the interface in nsIAccessibleAction is empty - // use getName as default description - return getNameCB(aAction, aActionIndex); + // use getActionName as default description + return getActionNameCB(aAction, aActionIndex); } const gchar * -getNameCB(AtkAction *aAction, gint aActionIndex) +getActionNameCB(AtkAction *aAction, gint aActionIndex) { nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aAction)); NS_ENSURE_TRUE(accWrap, nsnull); - MaiInterfaceAction *action = - NS_STATIC_CAST(MaiInterfaceAction *, - accWrap->GetMaiInterface(MAI_INTERFACE_ACTION)); - NS_ENSURE_TRUE(action, nsnull); - nsAutoString autoStr; nsresult rv = accWrap->GetActionName(aActionIndex, autoStr); NS_ENSURE_SUCCESS(rv, nsnull); - action->SetName(autoStr); - return action->GetName(); + return nsAccessibleWrap::ReturnString(autoStr); } const gchar * @@ -151,16 +101,7 @@ getKeyBindingCB(AtkAction *aAction, gint aActionIndex) nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aAction)); NS_ENSURE_TRUE(accWrap, nsnull); - MaiInterfaceAction *action = - NS_STATIC_CAST(MaiInterfaceAction *, - accWrap->GetMaiInterface(MAI_INTERFACE_ACTION)); - NS_ENSURE_TRUE(action, nsnull); - - if (*action->GetKeyBinding()) - return action->GetKeyBinding(); - //return all KeyBindings including accesskey and shortcut - nsAutoString allKeyBinding; //get accesskey @@ -245,17 +186,5 @@ getKeyBindingCB(AtkAction *aAction, gint aActionIndex) } allKeyBinding += NS_LITERAL_STRING(";") + subShortcut; - action->SetKeyBinding(allKeyBinding); - return action->GetKeyBinding(); -} - -gboolean -setDescriptionCB(AtkAction *aAction, gint aActionIndex, - const gchar *aDesc) -{ - nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aAction)); - NS_ENSURE_TRUE(accWrap, nsnull); - - /* this is not supported in nsIAccessible yet */ - return FALSE; + return nsAccessibleWrap::ReturnString(allKeyBinding); } diff --git a/mozilla/accessible/src/atk/nsMaiInterfaceAction.h b/mozilla/accessible/src/atk/nsMaiInterfaceAction.h index 63946894c1b..aa23a308003 100644 --- a/mozilla/accessible/src/atk/nsMaiInterfaceAction.h +++ b/mozilla/accessible/src/atk/nsMaiInterfaceAction.h @@ -41,29 +41,18 @@ #ifndef __MAI_INTERFACE_ACTION_H__ #define __MAI_INTERFACE_ACTION_H__ -#include "nsMaiInterface.h" +#include "nsMai.h" -class MaiInterfaceAction: public MaiInterface -{ -public: - MaiInterfaceAction(nsAccessibleWrap*); - virtual ~MaiInterfaceAction(); +G_BEGIN_DECLS - virtual MaiInterfaceType GetType(); - virtual const GInterfaceInfo *GetInterfaceInfo(); +/* action interface callbacks */ +void actionInterfaceInitCB(AtkActionIface *aIface); +gboolean doActionCB(AtkAction *aAction, gint aActionIndex); +gint getActionCountCB(AtkAction *aAction); +const gchar *getActionDescriptionCB(AtkAction *aAction, gint aActionIndex); +const gchar *getActionNameCB(AtkAction *aAction, gint aActionIndex); +const gchar *getKeyBindingCB(AtkAction *aAction, gint aActionIndex); - const char *GetName() { - return mName.get(); - } - void SetName(nsAString &aString) { mName = NS_ConvertUTF16toUTF8(aString); } - - const char *GetKeyBinding() { - return mKeyBinding.get(); - } - void SetKeyBinding(nsAString &aString) { mKeyBinding = NS_ConvertUTF16toUTF8(aString); } -private: - nsCString mName; - nsCString mKeyBinding; -}; +G_END_DECLS #endif /* __MAI_INTERFACE_ACTION_H__ */ diff --git a/mozilla/accessible/src/atk/nsMaiInterfaceComponent.cpp b/mozilla/accessible/src/atk/nsMaiInterfaceComponent.cpp index 5c558126c39..dcfde0e39e2 100644 --- a/mozilla/accessible/src/atk/nsMaiInterfaceComponent.cpp +++ b/mozilla/accessible/src/atk/nsMaiInterfaceComponent.cpp @@ -41,66 +41,8 @@ #include "nsMaiInterfaceComponent.h" #include "nsAccessibleWrap.h" -G_BEGIN_DECLS - -/* component interface callbacks */ -static void interfaceInitCB(AtkComponentIface *aIface); -static AtkObject *refAccessibleAtPointCB(AtkComponent *aComponent, - gint aAccX, gint aAccY, - AtkCoordType aCoordType); -static void getExtentsCB(AtkComponent *aComponent, - gint *aAccX, gint *aAccY, - gint *aAccWidth, gint *aAccHeight, - AtkCoordType aCoordType); -/* the "contains", "get_position", "get_size" can take advantage of - * "get_extents", there is no need to implement them now. - */ -static gboolean grabFocusCB(AtkComponent *aComponent); - -/* what are missing now for atk component */ - -/* ================================================== - * add_focus_handler - * remove_focus_handler - * set_extents - * set_position - * set_size - * get_layer - * get_mdi_zorder - * ================================================== - */ -G_END_DECLS - -MaiInterfaceComponent::MaiInterfaceComponent(nsAccessibleWrap *aAccWrap): - MaiInterface(aAccWrap) -{ -} - -MaiInterfaceComponent::~MaiInterfaceComponent() -{ -} - -MaiInterfaceType -MaiInterfaceComponent::GetType() -{ - return MAI_INTERFACE_COMPONENT; -} - -const GInterfaceInfo * -MaiInterfaceComponent::GetInterfaceInfo() -{ - static const GInterfaceInfo atk_if_component_info = { - (GInterfaceInitFunc)interfaceInitCB, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - return &atk_if_component_info; -} - -/* static functions */ - void -interfaceInitCB(AtkComponentIface *aIface) +componentInterfaceInitCB(AtkComponentIface *aIface) { NS_ASSERTION(aIface, "Invalid Interface"); if(!aIface) diff --git a/mozilla/accessible/src/atk/nsMaiInterfaceComponent.h b/mozilla/accessible/src/atk/nsMaiInterfaceComponent.h index 2e9dbba3097..28cb6e72d85 100644 --- a/mozilla/accessible/src/atk/nsMaiInterfaceComponent.h +++ b/mozilla/accessible/src/atk/nsMaiInterfaceComponent.h @@ -41,15 +41,36 @@ #ifndef __MAI_INTERFACE_COMPONENT_H__ #define __MAI_INTERFACE_COMPONENT_H__ -#include "nsMaiInterface.h" -class MaiInterfaceComponent: public MaiInterface -{ -public: - MaiInterfaceComponent(nsAccessibleWrap* aAccWrap); - virtual ~MaiInterfaceComponent(); +#include "nsMai.h" - virtual MaiInterfaceType GetType(); - virtual const GInterfaceInfo *GetInterfaceInfo(); -}; +G_BEGIN_DECLS + +/* component interface callbacks */ +void componentInterfaceInitCB(AtkComponentIface *aIface); +AtkObject *refAccessibleAtPointCB(AtkComponent *aComponent, + gint aAccX, gint aAccY, + AtkCoordType aCoordType); +void getExtentsCB(AtkComponent *aComponent, + gint *aAccX, gint *aAccY, + gint *aAccWidth, gint *aAccHeight, + AtkCoordType aCoordType); +/* the "contains", "get_position", "get_size" can take advantage of + * "get_extents", there is no need to implement them now. + */ +gboolean grabFocusCB(AtkComponent *aComponent); + +/* what are missing now for atk component */ + +/* ================================================== + * add_focus_handler + * remove_focus_handler + * set_extents + * set_position + * set_size + * get_layer + * get_mdi_zorder + * ================================================== + */ +G_END_DECLS #endif /* __MAI_INTERFACE_COMPONENT_H__ */ diff --git a/mozilla/accessible/src/atk/nsMaiInterfaceEditableText.cpp b/mozilla/accessible/src/atk/nsMaiInterfaceEditableText.cpp index 7b79613efab..7fbbb6b48a1 100644 --- a/mozilla/accessible/src/atk/nsMaiInterfaceEditableText.cpp +++ b/mozilla/accessible/src/atk/nsMaiInterfaceEditableText.cpp @@ -41,55 +41,8 @@ #include "nsString.h" #include "nsMaiInterfaceEditableText.h" -G_BEGIN_DECLS - -static void interfaceInitCB(AtkEditableTextIface *aIface); - -/* editabletext interface callbacks */ -static gboolean setRunAttributesCB(AtkEditableText *aText, - AtkAttributeSet *aAttribSet, - gint aStartOffset, - gint aEndOffset); -static void setTextContentsCB(AtkEditableText *aText, const gchar *aString); -static void insertTextCB(AtkEditableText *aText, - const gchar *aString, gint aLength, gint *aPosition); -static void copyTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos); -static void cutTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos); -static void deleteTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos); -static void pasteTextCB(AtkEditableText *aText, gint aPosition); - -G_END_DECLS - -MaiInterfaceEditableText::MaiInterfaceEditableText(nsAccessibleWrap *aAccWrap): - MaiInterface(aAccWrap) -{ -} - -MaiInterfaceEditableText::~MaiInterfaceEditableText() -{ -} - -MaiInterfaceType -MaiInterfaceEditableText::GetType() -{ - return MAI_INTERFACE_EDITABLE_TEXT; -} - -const GInterfaceInfo * -MaiInterfaceEditableText::GetInterfaceInfo() -{ - static const GInterfaceInfo atk_if_editabletext_info = { - (GInterfaceInitFunc)interfaceInitCB, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - return &atk_if_editabletext_info; -} - -/* statics */ - void -interfaceInitCB(AtkEditableTextIface *aIface) +editableTextInterfaceInitCB(AtkEditableTextIface *aIface) { NS_ASSERTION(aIface, "Invalid aIface"); if (!aIface) diff --git a/mozilla/accessible/src/atk/nsMaiInterfaceEditableText.h b/mozilla/accessible/src/atk/nsMaiInterfaceEditableText.h index de78e0b99b2..1f9a7ec2e93 100644 --- a/mozilla/accessible/src/atk/nsMaiInterfaceEditableText.h +++ b/mozilla/accessible/src/atk/nsMaiInterfaceEditableText.h @@ -41,17 +41,26 @@ #ifndef __MAI_INTERFACE_EDITABLETEXT_H__ #define __MAI_INTERFACE_EDITABLETEXT_H__ -#include "nsMaiInterface.h" +#include "nsMai.h" #include "nsIAccessibleEditableText.h" -class MaiInterfaceEditableText: public MaiInterface -{ -public: - MaiInterfaceEditableText(nsAccessibleWrap*); - virtual ~MaiInterfaceEditableText(); +G_BEGIN_DECLS - virtual MaiInterfaceType GetType(); - virtual const GInterfaceInfo *GetInterfaceInfo(); -}; +void editableTextInterfaceInitCB(AtkEditableTextIface *aIface); + +/* editabletext interface callbacks */ +gboolean setRunAttributesCB(AtkEditableText *aText, + AtkAttributeSet *aAttribSet, + gint aStartOffset, + gint aEndOffset); +void setTextContentsCB(AtkEditableText *aText, const gchar *aString); +void insertTextCB(AtkEditableText *aText, + const gchar *aString, gint aLength, gint *aPosition); +void copyTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos); +void cutTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos); +void deleteTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos); +void pasteTextCB(AtkEditableText *aText, gint aPosition); + +G_END_DECLS #endif /* __MAI_INTERFACE_EDITABLETEXT_H__ */ diff --git a/mozilla/accessible/src/atk/nsMaiInterfaceHypertext.cpp b/mozilla/accessible/src/atk/nsMaiInterfaceHypertext.cpp index 5ace3ee2ff1..9d92eebf3c8 100644 --- a/mozilla/accessible/src/atk/nsMaiInterfaceHypertext.cpp +++ b/mozilla/accessible/src/atk/nsMaiInterfaceHypertext.cpp @@ -42,64 +42,8 @@ #include "nsIAccessibleDocument.h" #include "nsPIAccessNode.h" -G_BEGIN_DECLS - -static void interfaceInitCB(AtkHypertextIface *aIface); - -/* hypertext interface callbacks */ -static AtkHyperlink *getLinkCB(AtkHypertext *aText, gint aLinkIndex); -static gint getLinkCountCB(AtkHypertext *aText); -static gint getLinkIndexCB(AtkHypertext *aText, gint aCharIndex); - -G_END_DECLS - -MaiInterfaceHypertext::MaiInterfaceHypertext(nsAccessibleWrap *aAccWrap, - nsIWeakReference* aShell): - MaiInterface(aAccWrap), - mWeakShell(aShell) -{ -} - -MaiInterfaceHypertext::~MaiInterfaceHypertext() -{ - mWeakShell = nsnull; -} - -MaiInterfaceType -MaiInterfaceHypertext::GetType() -{ - return MAI_INTERFACE_HYPERTEXT; -} - -nsresult -MaiInterfaceHypertext::GetWeakShell(nsIWeakReference **aWeakShell) -{ - nsresult rv = NS_ERROR_FAILURE; - if (mWeakShell) { - *aWeakShell = mWeakShell; - NS_IF_ADDREF(*aWeakShell); - rv = NS_OK; - } - else - *aWeakShell = nsnull; - return rv; -} - -const GInterfaceInfo * -MaiInterfaceHypertext::GetInterfaceInfo() -{ - static const GInterfaceInfo atk_if_hypertext_info = { - (GInterfaceInitFunc)interfaceInitCB, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - return &atk_if_hypertext_info; -} - -/* statics */ - void -interfaceInitCB(AtkHypertextIface *aIface) +hypertextInterfaceInitCB(AtkHypertextIface *aIface) { g_return_if_fail(aIface != NULL); @@ -115,15 +59,6 @@ getLinkCB(AtkHypertext *aText, gint aLinkIndex) nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText)); NS_ENSURE_TRUE(accWrap, nsnull); - MaiInterfaceHypertext *maiHypertext = - NS_STATIC_CAST(MaiInterfaceHypertext *, - accWrap->GetMaiInterface(MAI_INTERFACE_HYPERTEXT)); - NS_ENSURE_TRUE(accWrap, nsnull); - - nsCOMPtr weakShell; - rv = maiHypertext->GetWeakShell(getter_AddRefs(weakShell)); - NS_ENSURE_SUCCESS(rv, nsnull); - nsCOMPtr accHyperlink; accWrap->QueryInterface(NS_GET_IID(nsIAccessibleHyperText), getter_AddRefs(accHyperlink)); @@ -134,35 +69,7 @@ getLinkCB(AtkHypertext *aText, gint aLinkIndex) if (NS_FAILED(rv) || !hyperLink) return nsnull; - // The MaiHyperlink and its nsIAccessibleHyperlink are in the same cache. - // we take hyperlink->get() as Id for the MaiHyperlink. - // release our ref to the previous one - - nsCOMPtr accessibleDoc = - nsAccessNode::GetDocAccessibleFor(weakShell); - if (!accessibleDoc) { - NS_WARNING("No accessible document for this presshell"); - return nsnull; - } - nsCOMPtr maiNode; - accessibleDoc->GetCachedAccessNode(NS_STATIC_CAST(void*, hyperLink.get()), - getter_AddRefs(maiNode)); - // if the maiHyperlink is not in cache, create it. - if (!maiNode) { - maiNode = new MaiHyperlink(hyperLink, nsnull, weakShell); - if (!maiNode) { - NS_WARNING("OUT OF MEMORY"); - return nsnull; - } - nsCOMPtr pMaiNode = do_QueryInterface(maiNode); - pMaiNode->Init(); // add to cache. - } - - // we can get AtkHyperlink from the MaiHyperlink - nsIAccessNode *tmpNode = maiNode; - MaiHyperlink *maiHyperlink = NS_STATIC_CAST(MaiHyperlink *, tmpNode); - - /* we should not addref the atkhyperlink because we are "get" not "ref" */ + MaiHyperlink *maiHyperlink = new MaiHyperlink(hyperLink); return maiHyperlink->GetAtkHyperlink(); } diff --git a/mozilla/accessible/src/atk/nsMaiInterfaceHypertext.h b/mozilla/accessible/src/atk/nsMaiInterfaceHypertext.h index 7252842b006..0819279d84f 100644 --- a/mozilla/accessible/src/atk/nsMaiInterfaceHypertext.h +++ b/mozilla/accessible/src/atk/nsMaiInterfaceHypertext.h @@ -41,22 +41,19 @@ #ifndef __MAI_INTERFACE_HYPERTEXT_H__ #define __MAI_INTERFACE_HYPERTEXT_H__ -#include "nsMaiInterface.h" +#include "nsMai.h" #include "nsMaiHyperlink.h" #include "nsIAccessibleHyperText.h" -class MaiInterfaceHypertext: public MaiInterface -{ -public: - MaiInterfaceHypertext(nsAccessibleWrap *aAccWrap, - nsIWeakReference* aShell); - virtual ~MaiInterfaceHypertext(); +G_BEGIN_DECLS - virtual MaiInterfaceType GetType(); - virtual const GInterfaceInfo *GetInterfaceInfo(); - nsresult GetWeakShell(nsIWeakReference **aWeakShell); -private: - nsCOMPtr mWeakShell; -}; +void hypertextInterfaceInitCB(AtkHypertextIface *aIface); + +/* hypertext interface callbacks */ +AtkHyperlink *getLinkCB(AtkHypertext *aText, gint aLinkIndex); +gint getLinkCountCB(AtkHypertext *aText); +gint getLinkIndexCB(AtkHypertext *aText, gint aCharIndex); + +G_END_DECLS #endif /* __MAI_INTERFACE_HYPERTEXT_H__ */ diff --git a/mozilla/accessible/src/atk/nsMaiInterfaceSelection.cpp b/mozilla/accessible/src/atk/nsMaiInterfaceSelection.cpp index 568956f95b7..02815f839c1 100644 --- a/mozilla/accessible/src/atk/nsMaiInterfaceSelection.cpp +++ b/mozilla/accessible/src/atk/nsMaiInterfaceSelection.cpp @@ -40,55 +40,8 @@ #include "nsMaiInterfaceSelection.h" -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(nsAccessibleWrap* aAccWrap): - MaiInterface(aAccWrap) -{ -} - -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; -} - -/* static functions */ - void -interfaceInitCB(AtkSelectionIface *aIface) +selectionInterfaceInitCB(AtkSelectionIface *aIface) { NS_ASSERTION(aIface, "Invalid aIface"); if (!aIface) diff --git a/mozilla/accessible/src/atk/nsMaiInterfaceSelection.h b/mozilla/accessible/src/atk/nsMaiInterfaceSelection.h index a20844c90d9..71d253c84c8 100644 --- a/mozilla/accessible/src/atk/nsMaiInterfaceSelection.h +++ b/mozilla/accessible/src/atk/nsMaiInterfaceSelection.h @@ -41,17 +41,22 @@ #ifndef __MAI_INTERFACE_SELECTION_H__ #define __MAI_INTERFACE_SELECTION_H__ -#include "nsMaiInterface.h" +#include "nsMai.h" #include "nsIAccessibleSelectable.h" -class MaiInterfaceSelection: public MaiInterface -{ -public: - MaiInterfaceSelection(nsAccessibleWrap*); - ~MaiInterfaceSelection(); +G_BEGIN_DECLS - virtual MaiInterfaceType GetType(); - virtual const GInterfaceInfo *GetInterfaceInfo(); -}; +/* selection interface callbacks */ + +void selectionInterfaceInitCB(AtkSelectionIface *aIface); +gboolean addSelectionCB(AtkSelection *aSelection, gint i); +gboolean clearSelectionCB(AtkSelection *aSelection); +AtkObject *refSelectionCB(AtkSelection *aSelection, gint i); +gint getSelectionCountCB(AtkSelection *aSelection); +gboolean isChildSelectedCB(AtkSelection *aSelection, gint i); +gboolean removeSelectionCB(AtkSelection *aSelection, gint i); +gboolean selectAllSelectionCB(AtkSelection *aSelection); + +G_END_DECLS #endif /* __MAI_INTERFACE_SELECTION_H__ */ diff --git a/mozilla/accessible/src/atk/nsMaiInterfaceTable.cpp b/mozilla/accessible/src/atk/nsMaiInterfaceTable.cpp index 51723e599e9..7768cca8b65 100644 --- a/mozilla/accessible/src/atk/nsMaiInterfaceTable.cpp +++ b/mozilla/accessible/src/atk/nsMaiInterfaceTable.cpp @@ -40,111 +40,8 @@ #include "nsMaiInterfaceTable.h" -G_BEGIN_DECLS - -/* table interface callbacks */ -static void interfaceInitCB(AtkTableIface *aIface); -static AtkObject* refAtCB(AtkTable *aTable, gint aRow, gint aColumn); -static gint getIndexAtCB(AtkTable *aTable, gint aRow, gint aColumn); -static gint getColumnAtIndexCB(AtkTable *aTable, gint aIndex); -static gint getRowAtIndexCB(AtkTable *aTable, gint aIndex); -static gint getColumnCountCB(AtkTable *aTable); -static gint getRowCountCB(AtkTable *aTable); -static gint getColumnExtentAtCB(AtkTable *aTable, gint aRow, gint aColumn); -static gint getRowExtentAtCB(AtkTable *aTable, gint aRow, gint aColumn); -static AtkObject* getCaptionCB(AtkTable *aTable); -static const gchar* getColumnDescriptionCB(AtkTable *aTable, gint aColumn); -static AtkObject* getColumnHeaderCB(AtkTable *aTable, gint aColumn); -static const gchar* getRowDescriptionCB(AtkTable *aTable, gint aRow); -static AtkObject* getRowHeaderCB(AtkTable *aTable, gint aRow); -static AtkObject* getSummaryCB(AtkTable *aTable); -static gint getSelectedColumnsCB(AtkTable *aTable, gint **aSelected); -static gint getSelectedRowsCB(AtkTable *aTable, gint **aSelected); -static gboolean isColumnSelectedCB(AtkTable *aTable, gint aColumn); -static gboolean isRowSelectedCB(AtkTable *aTable, gint aRow); -static gboolean isCellSelectedCB(AtkTable *aTable, gint aRow, gint aColumn); - -/* what are missing now for atk table */ - -/* ================================================== - void (* set_caption) (AtkTable *aTable, - AtkObject *caption); - void (* set_column_description) (AtkTable *aTable, - gint aColumn, - const gchar *description); - void (* set_column_header) (AtkTable *aTable, - gint aColumn, - AtkObject *header); - void (* set_row_description) (AtkTable *aTable, - gint aRow, - const gchar *description); - void (* set_row_header) (AtkTable *aTable, - gint aRow, - AtkObject *header); - void (* set_summary) (AtkTable *aTable, - AtkObject *accessible); - gboolean (* add_row_selection) (AtkTable *aTable, - gint aRow); - gboolean (* remove_row_selection) (AtkTable *aTable, - gint aRow); - gboolean (* add_column_selection) (AtkTable *aTable, - gint aColumn); - gboolean (* remove_column_selection) (AtkTable *aTable, - gint aColumn); - - //////////////////////////////////////// - // signal handlers - // - void (* row_inserted) (AtkTable *aTable, - gint aRow, - gint num_inserted); - void (* column_inserted) (AtkTable *aTable, - gint aColumn, - gint num_inserted); - void (* row_deleted) (AtkTable *aTable, - gint aRow, - gint num_deleted); - void (* column_deleted) (AtkTable *aTable, - gint aColumn, - gint num_deleted); - void (* row_reordered) (AtkTable *aTable); - void (* column_reordered) (AtkTable *aTable); - void (* model_changed) (AtkTable *aTable); - - * ================================================== - */ -G_END_DECLS - -MaiInterfaceTable::MaiInterfaceTable(nsAccessibleWrap* aAccWrap): - MaiInterface(aAccWrap) -{ -} - -MaiInterfaceTable::~MaiInterfaceTable() -{ -} - -MaiInterfaceType -MaiInterfaceTable::GetType() -{ - return MAI_INTERFACE_TABLE; -} - -const GInterfaceInfo * -MaiInterfaceTable::GetInterfaceInfo() -{ - static const GInterfaceInfo atk_if_table_info = { - (GInterfaceInitFunc)interfaceInitCB, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - return &atk_if_table_info; -} - -/* static functions */ - void -interfaceInitCB(AtkTableIface *aIface) +tableInterfaceInitCB(AtkTableIface *aIface) { g_return_if_fail(aIface != NULL); @@ -358,21 +255,11 @@ getColumnDescriptionCB(AtkTable *aTable, gint aColumn) getter_AddRefs(accTable)); NS_ENSURE_TRUE(accTable, nsnull); - MaiInterfaceTable *maiTable = - NS_STATIC_CAST(MaiInterfaceTable *, - accWrap->GetMaiInterface(MAI_INTERFACE_TABLE)); - NS_ENSURE_TRUE(maiTable, nsnull); + nsAutoString autoStr; + nsresult rv = accTable->GetColumnDescription(aColumn, autoStr); + NS_ENSURE_SUCCESS(rv, nsnull); - const char *description = maiTable->GetColumnDescription(); - if (!description) { - nsAutoString autoStr; - nsresult rv = accTable->GetColumnDescription(aColumn, autoStr); - NS_ENSURE_SUCCESS(rv, nsnull); - - maiTable->SetColumnDescription(autoStr); - description = maiTable->GetColumnDescription(); - } - return description; + return nsAccessibleWrap::ReturnString(autoStr); } AtkObject* @@ -422,17 +309,11 @@ getRowDescriptionCB(AtkTable *aTable, gint aRow) getter_AddRefs(accTable)); NS_ENSURE_TRUE(accTable, nsnull); - MaiInterfaceTable *maiTable = - NS_STATIC_CAST(MaiInterfaceTable *, - accWrap->GetMaiInterface(MAI_INTERFACE_TABLE)); - NS_ENSURE_TRUE(maiTable, nsnull); - nsAutoString autoStr; nsresult rv = accTable->GetRowDescription(aRow, autoStr); NS_ENSURE_SUCCESS(rv, nsnull); - maiTable->SetRowDescription(autoStr); - return maiTable->GetRowDescription(); + return nsAccessibleWrap::ReturnString(autoStr); } AtkObject* diff --git a/mozilla/accessible/src/atk/nsMaiInterfaceTable.h b/mozilla/accessible/src/atk/nsMaiInterfaceTable.h index 7536c37d8c6..bd290ccc6a0 100644 --- a/mozilla/accessible/src/atk/nsMaiInterfaceTable.h +++ b/mozilla/accessible/src/atk/nsMaiInterfaceTable.h @@ -41,35 +41,82 @@ #ifndef __MAI_INTERFACE_TABLE_H__ #define __MAI_INTERFACE_TABLE_H__ -#include "nsMaiInterface.h" +#include "nsMai.h" #include "nsIAccessibleTable.h" -class MaiInterfaceTable: public MaiInterface -{ -public: - MaiInterfaceTable(nsAccessibleWrap*); - virtual ~MaiInterfaceTable(); +G_BEGIN_DECLS - virtual MaiInterfaceType GetType(); - virtual const GInterfaceInfo *GetInterfaceInfo(); +/* table interface callbacks */ +void tableInterfaceInitCB(AtkTableIface *aIface); +AtkObject* refAtCB(AtkTable *aTable, gint aRow, gint aColumn); +gint getIndexAtCB(AtkTable *aTable, gint aRow, gint aColumn); +gint getColumnAtIndexCB(AtkTable *aTable, gint aIndex); +gint getRowAtIndexCB(AtkTable *aTable, gint aIndex); +gint getColumnCountCB(AtkTable *aTable); +gint getRowCountCB(AtkTable *aTable); +gint getColumnExtentAtCB(AtkTable *aTable, gint aRow, gint aColumn); +gint getRowExtentAtCB(AtkTable *aTable, gint aRow, gint aColumn); +AtkObject* getCaptionCB(AtkTable *aTable); +const gchar* getColumnDescriptionCB(AtkTable *aTable, gint aColumn); +AtkObject* getColumnHeaderCB(AtkTable *aTable, gint aColumn); +const gchar* getRowDescriptionCB(AtkTable *aTable, gint aRow); +AtkObject* getRowHeaderCB(AtkTable *aTable, gint aRow); +AtkObject* getSummaryCB(AtkTable *aTable); +gint getSelectedColumnsCB(AtkTable *aTable, gint **aSelected); +gint getSelectedRowsCB(AtkTable *aTable, gint **aSelected); +gboolean isColumnSelectedCB(AtkTable *aTable, gint aColumn); +gboolean isRowSelectedCB(AtkTable *aTable, gint aRow); +gboolean isCellSelectedCB(AtkTable *aTable, gint aRow, gint aColumn); - const char *GetColumnDescription() { - return mColumnDescription.get(); - } - void SetColumnDescription(nsAString &aString) { - CopyUTF16toUTF8(aString, mColumnDescription); - } +/* what are missing now for atk table */ - const char *GetRowDescription() { - return mRowDescription.get(); - } - void SetRowDescription(nsAString &aString) { - CopyUTF16toUTF8(aString, mRowDescription); - } +/* ================================================== + void (* set_caption) (AtkTable *aTable, + AtkObject *caption); + void (* set_column_description) (AtkTable *aTable, + gint aColumn, + const gchar *description); + void (* set_column_header) (AtkTable *aTable, + gint aColumn, + AtkObject *header); + void (* set_row_description) (AtkTable *aTable, + gint aRow, + const gchar *description); + void (* set_row_header) (AtkTable *aTable, + gint aRow, + AtkObject *header); + void (* set_summary) (AtkTable *aTable, + AtkObject *accessible); + gboolean (* add_row_selection) (AtkTable *aTable, + gint aRow); + gboolean (* remove_row_selection) (AtkTable *aTable, + gint aRow); + gboolean (* add_column_selection) (AtkTable *aTable, + gint aColumn); + gboolean (* remove_column_selection) (AtkTable *aTable, + gint aColumn); -private: - nsCString mColumnDescription; - nsCString mRowDescription; -}; + //////////////////////////////////////// + // signal handlers + // + void (* row_inserted) (AtkTable *aTable, + gint aRow, + gint num_inserted); + void (* column_inserted) (AtkTable *aTable, + gint aColumn, + gint num_inserted); + void (* row_deleted) (AtkTable *aTable, + gint aRow, + gint num_deleted); + void (* column_deleted) (AtkTable *aTable, + gint aColumn, + gint num_deleted); + void (* row_reordered) (AtkTable *aTable); + void (* column_reordered) (AtkTable *aTable); + void (* model_changed) (AtkTable *aTable); + + * ================================================== + */ +G_END_DECLS #endif /* __MAI_INTERFACE_TABLE_H__ */ diff --git a/mozilla/accessible/src/atk/nsMaiInterfaceText.cpp b/mozilla/accessible/src/atk/nsMaiInterfaceText.cpp index 6479d61a884..b770614e991 100644 --- a/mozilla/accessible/src/atk/nsMaiInterfaceText.cpp +++ b/mozilla/accessible/src/atk/nsMaiInterfaceText.cpp @@ -42,89 +42,8 @@ #include "nsMaiInterfaceText.h" #include "nsString.h" -G_BEGIN_DECLS - -static void interfaceInitCB(AtkTextIface *aIface); - -/* text interface callbacks */ -static gchar *getTextCB(AtkText *aText, - gint aStartOffset, gint aEndOffset); -static gchar *getTextAfterOffsetCB(AtkText *aText, gint aOffset, - AtkTextBoundary aBoundaryType, - gint *aStartOffset, gint *aEndOffset); -static gchar *getTextAtOffsetCB(AtkText *aText, gint aOffset, - AtkTextBoundary aBoundaryType, - gint *aStartOffset, gint *aEndOffset); -static gunichar getCharacterAtOffsetCB(AtkText *aText, gint aOffset); -static gchar *getTextBeforeOffsetCB(AtkText *aText, gint aOffset, - AtkTextBoundary aBoundaryType, - gint *aStartOffset, gint *aEndOffset); -static gint getCaretOffsetCB(AtkText *aText); -static AtkAttributeSet *getRunAttributesCB(AtkText *aText, gint aOffset, - gint *aStartOffset, - gint *aEndOffset); -static AtkAttributeSet* getDefaultAttributesCB(AtkText *aText); -static void getCharacterExtentsCB(AtkText *aText, gint aOffset, - gint *aX, gint *aY, - gint *aWidth, gint *aHeight, - AtkCoordType aCoords); -static gint getCharacterCountCB(AtkText *aText); -static gint getOffsetAtPointCB(AtkText *aText, - gint aX, gint aY, - AtkCoordType aCoords); -static gint getSelectionCountCB(AtkText *aText); -static gchar *getSelectionCB(AtkText *aText, gint aSelectionNum, - gint *aStartOffset, gint *aEndOffset); - -// set methods -static gboolean addSelectionCB(AtkText *aText, - gint aStartOffset, - gint aEndOffset); -static gboolean removeSelectionCB(AtkText *aText, - gint aSelectionNum); -static gboolean setSelectionCB(AtkText *aText, gint aSelectionNum, - gint aStartOffset, gint aEndOffset); -static gboolean setCaretOffsetCB(AtkText *aText, gint aOffset); - -/************************************************* - // signal handlers - // - static void TextChangedCB(AtkText *aText, gint aPosition, gint aLength); - static void TextCaretMovedCB(AtkText *aText, gint aLocation); - static void TextSelectionChangedCB(AtkText *aText); -*/ -G_END_DECLS - -MaiInterfaceText::MaiInterfaceText(nsAccessibleWrap *aAccWrap): - MaiInterface(aAccWrap) -{ -} - -MaiInterfaceText::~MaiInterfaceText() -{ -} - -MaiInterfaceType -MaiInterfaceText::GetType() -{ - return MAI_INTERFACE_TEXT; -} - -const GInterfaceInfo * -MaiInterfaceText::GetInterfaceInfo() -{ - static const GInterfaceInfo atk_if_text_info = { - (GInterfaceInitFunc)interfaceInitCB, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - return &atk_if_text_info; -} - -/* statics */ - void -interfaceInitCB(AtkTextIface *aIface) +textInterfaceInitCB(AtkTextIface *aIface) { NS_ASSERTION(aIface, "Invalid aIface"); if (!aIface) @@ -141,13 +60,13 @@ interfaceInitCB(AtkTextIface *aIface) aIface->get_character_extents = getCharacterExtentsCB; aIface->get_character_count = getCharacterCountCB; aIface->get_offset_at_point = getOffsetAtPointCB; - aIface->get_n_selections = getSelectionCountCB; - aIface->get_selection = getSelectionCB; + aIface->get_n_selections = getTextSelectionCountCB; + aIface->get_selection = getTextSelectionCB; // set methods - aIface->add_selection = addSelectionCB; - aIface->remove_selection = removeSelectionCB; - aIface->set_selection = setSelectionCB; + aIface->add_selection = addTextSelectionCB; + aIface->remove_selection = removeTextSelectionCB; + aIface->set_selection = setTextSelectionCB; aIface->set_caret_offset = setCaretOffsetCB; } @@ -409,7 +328,7 @@ getOffsetAtPointCB(AtkText *aText, } gint -getSelectionCountCB(AtkText *aText) +getTextSelectionCountCB(AtkText *aText) { /* no implemetation in nsIAccessibleText??? */ @@ -420,8 +339,8 @@ getSelectionCountCB(AtkText *aText) } gchar * -getSelectionCB(AtkText *aText, gint aSelectionNum, - gint *aStartOffset, gint *aEndOffset) +getTextSelectionCB(AtkText *aText, gint aSelectionNum, + gint *aStartOffset, gint *aEndOffset) { nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText)); NS_ENSURE_TRUE(accWrap, nsnull); @@ -445,9 +364,9 @@ getSelectionCB(AtkText *aText, gint aSelectionNum, // set methods gboolean -addSelectionCB(AtkText *aText, - gint aStartOffset, - gint aEndOffset) +addTextSelectionCB(AtkText *aText, + gint aStartOffset, + gint aEndOffset) { nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText)); NS_ENSURE_TRUE(accWrap, FALSE); @@ -463,8 +382,8 @@ addSelectionCB(AtkText *aText, } gboolean -removeSelectionCB(AtkText *aText, - gint aSelectionNum) +removeTextSelectionCB(AtkText *aText, + gint aSelectionNum) { nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText)); NS_ENSURE_TRUE(accWrap, FALSE); @@ -480,8 +399,8 @@ removeSelectionCB(AtkText *aText, } gboolean -setSelectionCB(AtkText *aText, gint aSelectionNum, - gint aStartOffset, gint aEndOffset) +setTextSelectionCB(AtkText *aText, gint aSelectionNum, + gint aStartOffset, gint aEndOffset) { nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText)); NS_ENSURE_TRUE(accWrap, FALSE); diff --git a/mozilla/accessible/src/atk/nsMaiInterfaceText.h b/mozilla/accessible/src/atk/nsMaiInterfaceText.h index b99cbd2e7f2..46abbd60dbf 100644 --- a/mozilla/accessible/src/atk/nsMaiInterfaceText.h +++ b/mozilla/accessible/src/atk/nsMaiInterfaceText.h @@ -41,17 +41,60 @@ #ifndef __MAI_INTERFACE_TEXT_H__ #define __MAI_INTERFACE_TEXT_H__ -#include "nsMaiInterface.h" +#include "nsMai.h" #include "nsIAccessibleText.h" -class MaiInterfaceText: public MaiInterface -{ -public: - MaiInterfaceText(nsAccessibleWrap*); - virtual ~MaiInterfaceText(); +G_BEGIN_DECLS - virtual MaiInterfaceType GetType(); - virtual const GInterfaceInfo *GetInterfaceInfo(); -}; +void textInterfaceInitCB(AtkTextIface *aIface); + +/* text interface callbacks */ +gchar *getTextCB(AtkText *aText, + gint aStartOffset, gint aEndOffset); +gchar *getTextAfterOffsetCB(AtkText *aText, gint aOffset, + AtkTextBoundary aBoundaryType, + gint *aStartOffset, gint *aEndOffset); +gchar *getTextAtOffsetCB(AtkText *aText, gint aOffset, + AtkTextBoundary aBoundaryType, + gint *aStartOffset, gint *aEndOffset); +gunichar getCharacterAtOffsetCB(AtkText *aText, gint aOffset); +gchar *getTextBeforeOffsetCB(AtkText *aText, gint aOffset, + AtkTextBoundary aBoundaryType, + gint *aStartOffset, gint *aEndOffset); +gint getCaretOffsetCB(AtkText *aText); +AtkAttributeSet *getRunAttributesCB(AtkText *aText, gint aOffset, + gint *aStartOffset, + gint *aEndOffset); +AtkAttributeSet* getDefaultAttributesCB(AtkText *aText); +void getCharacterExtentsCB(AtkText *aText, gint aOffset, + gint *aX, gint *aY, + gint *aWidth, gint *aHeight, + AtkCoordType aCoords); +gint getCharacterCountCB(AtkText *aText); +gint getOffsetAtPointCB(AtkText *aText, + gint aX, gint aY, + AtkCoordType aCoords); +gint getTextSelectionCountCB(AtkText *aText); +gchar *getTextSelectionCB(AtkText *aText, gint aSelectionNum, + gint *aStartOffset, gint *aEndOffset); + +// set methods +gboolean addTextSelectionCB(AtkText *aText, + gint aStartOffset, + gint aEndOffset); +gboolean removeTextSelectionCB(AtkText *aText, + gint aSelectionNum); +gboolean setTextSelectionCB(AtkText *aText, gint aSelectionNum, + gint aStartOffset, gint aEndOffset); +gboolean setCaretOffsetCB(AtkText *aText, gint aOffset); + +/************************************************* + // signal handlers + // + void TextChangedCB(AtkText *aText, gint aPosition, gint aLength); + void TextCaretMovedCB(AtkText *aText, gint aLocation); + void TextSelectionChangedCB(AtkText *aText); +*/ +G_END_DECLS #endif /* __MAI_INTERFACE_TEXT_H__ */ diff --git a/mozilla/accessible/src/atk/nsMaiInterfaceValue.cpp b/mozilla/accessible/src/atk/nsMaiInterfaceValue.cpp index a196fb7ccf2..db76100e203 100644 --- a/mozilla/accessible/src/atk/nsMaiInterfaceValue.cpp +++ b/mozilla/accessible/src/atk/nsMaiInterfaceValue.cpp @@ -40,51 +40,8 @@ #include "nsMaiInterfaceValue.h" -G_BEGIN_DECLS - -/*value interface callbacks*/ - -static void interfaceInitCB(AtkValueIface *aIface); -static void getCurrentValueCB(AtkValue *obj, - GValue *value); -static void getMaximumValueCB(AtkValue *obj, - GValue *value); -static void getMinimumValueCB(AtkValue *obj, - GValue *value); -static gboolean setCurrentValueCB(AtkValue *obj, - const GValue *value); -G_END_DECLS - -MaiInterfaceValue::MaiInterfaceValue(nsAccessibleWrap *aAccWrap): - MaiInterface(aAccWrap) -{ -} - -MaiInterfaceValue::~MaiInterfaceValue() -{ -} - -MaiInterfaceType -MaiInterfaceValue::GetType() -{ - return MAI_INTERFACE_VALUE; -} - -const GInterfaceInfo * -MaiInterfaceValue::GetInterfaceInfo() -{ - static const GInterfaceInfo atk_if_value_info = { - (GInterfaceInitFunc) interfaceInitCB, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - return &atk_if_value_info; -} - -/* static functions */ - void -interfaceInitCB(AtkValueIface *aIface) +valueInterfaceInitCB(AtkValueIface *aIface) { NS_ASSERTION(aIface, "Invalid aIface"); if (!aIface) diff --git a/mozilla/accessible/src/atk/nsMaiInterfaceValue.h b/mozilla/accessible/src/atk/nsMaiInterfaceValue.h index c5fea4c9395..76e15efdea9 100644 --- a/mozilla/accessible/src/atk/nsMaiInterfaceValue.h +++ b/mozilla/accessible/src/atk/nsMaiInterfaceValue.h @@ -41,17 +41,18 @@ #ifndef __MAI_INTERFACE_VALUE_H__ #define __MAI_INTERFACE_VALUE_H__ -#include "nsMaiInterface.h" +#include "nsMai.h" #include "nsIAccessibleValue.h" -class MaiInterfaceValue: public MaiInterface -{ -public: - MaiInterfaceValue(nsAccessibleWrap*); - ~MaiInterfaceValue(); +G_BEGIN_DECLS - virtual MaiInterfaceType GetType(); - virtual const GInterfaceInfo *GetInterfaceInfo(); -}; +/*value interface callbacks*/ +void valueInterfaceInitCB(AtkValueIface *aIface); +void getCurrentValueCB(AtkValue *obj, GValue *value); +void getMaximumValueCB(AtkValue *obj, GValue *value); +void getMinimumValueCB(AtkValue *obj, GValue *value); +gboolean setCurrentValueCB(AtkValue *obj, const GValue *value); + +G_END_DECLS #endif /* __MAI_INTERFACE_VALUE_H__ */