Bug 741703 - stop using QueryInterface in CAccessibleHypertext, r=surkov, f=tbsaunde

--HG--
rename : accessible/src/msaa/CAccessibleHypertext.cpp => accessible/src/msaa/ia2AccessibleHypertext.cpp
rename : accessible/src/msaa/CAccessibleHypertext.h => accessible/src/msaa/ia2AccessibleHypertext.h
This commit is contained in:
Mark Capella 2012-04-14 10:19:41 +09:00
Родитель db1d931444
Коммит a1ca11e4ee
7 изменённых файлов: 49 добавлений и 35 удалений

Просмотреть файл

@ -93,15 +93,9 @@ nsresult nsHyperTextAccessible::QueryInterface(REFNSIID aIID, void** aInstancePt
return NS_OK;
}
if (mRoleMapEntry &&
(mRoleMapEntry->role == roles::GRAPHIC ||
mRoleMapEntry->role == roles::IMAGE_MAP ||
mRoleMapEntry->role == roles::SLIDER ||
mRoleMapEntry->role == roles::PROGRESSBAR ||
mRoleMapEntry->role == roles::SEPARATOR)) {
// ARIA roles that these interfaces are not appropriate for
// ARIA roles that these interfaces are not appropriate for.
if (!IsTextRole())
return nsAccessible::QueryInterface(aIID, aInstancePtr);
}
if (aIID.Equals(NS_GET_IID(nsIAccessibleText))) {
*aInstancePtr = static_cast<nsIAccessibleText*>(this);
@ -2398,3 +2392,17 @@ nsHyperTextAccessible::GetSpellTextAttribute(nsINode* aNode,
return NS_OK;
}
bool
nsHyperTextAccessible::IsTextRole()
{
if (mRoleMapEntry &&
(mRoleMapEntry->role == roles::GRAPHIC ||
mRoleMapEntry->role == roles::IMAGE_MAP ||
mRoleMapEntry->role == roles::SLIDER ||
mRoleMapEntry->role == roles::PROGRESSBAR ||
mRoleMapEntry->role == roles::SEPARATOR))
return false;
return true;
}

Просмотреть файл

@ -201,6 +201,12 @@ public:
nsIDOMNode **aEndNode,
PRInt32 *aEndOffset);
/**
* Return true if the used ARIA role (if any) allows the hypertext accessible
* to expose text interfaces.
*/
bool IsTextRole();
//////////////////////////////////////////////////////////////////////////////
// TextAccessible

Просмотреть файл

@ -69,7 +69,7 @@ CPPSRCS = \
CAccessibleText.cpp \
CAccessibleEditableText.cpp \
CAccessibleHyperlink.cpp \
CAccessibleHypertext.cpp \
ia2AccessibleHypertext.cpp \
ia2AccessibleRelation.cpp \
CAccessibleTable.cpp \
CAccessibleTableCell.cpp \
@ -98,7 +98,7 @@ EXPORTS = \
CAccessibleText.h \
CAccessibleEditableText.h \
CAccessibleHyperlink.h \
CAccessibleHypertext.h \
ia2AccessibleHypertext.h \
CAccessibleTable.h \
CAccessibleTableCell.h \
CAccessibleValue.h \

Просмотреть файл

@ -38,26 +38,26 @@
*
* ***** END LICENSE BLOCK ***** */
#include "CAccessibleHypertext.h"
#include "ia2AccessibleHypertext.h"
#include "AccessibleHypertext_i.c"
#include "nsHyperTextAccessible.h"
#include "nsHyperTextAccessibleWrap.h"
// IUnknown
STDMETHODIMP
CAccessibleHypertext::QueryInterface(REFIID iid, void** ppv)
ia2AccessibleHypertext::QueryInterface(REFIID iid, void** ppv)
{
*ppv = NULL;
if (IID_IAccessibleHypertext == iid) {
nsCOMPtr<nsIAccessibleHyperText> hyperAcc(do_QueryObject(this));
if (!hyperAcc)
return E_NOINTERFACE;
*ppv = static_cast<IAccessibleHypertext*>(this);
(reinterpret_cast<IUnknown*>(*ppv))->AddRef();
return S_OK;
nsHyperTextAccessibleWrap* hyperAcc = static_cast<nsHyperTextAccessibleWrap*>(this);
if (hyperAcc->IsTextRole()) {
*ppv = static_cast<IAccessibleHypertext*>(this);
(reinterpret_cast<IUnknown*>(*ppv))->AddRef();
return S_OK;
}
return E_NOINTERFACE;
}
return CAccessibleText::QueryInterface(iid, ppv);
@ -66,12 +66,12 @@ CAccessibleHypertext::QueryInterface(REFIID iid, void** ppv)
// IAccessibleHypertext
STDMETHODIMP
CAccessibleHypertext::get_nHyperlinks(long *aHyperlinkCount)
ia2AccessibleHypertext::get_nHyperlinks(long* aHyperlinkCount)
{
__try {
*aHyperlinkCount = 0;
nsRefPtr<nsHyperTextAccessible> hyperText = do_QueryObject(this);
nsHyperTextAccessibleWrap* hyperText = static_cast<nsHyperTextAccessibleWrap*>(this);
if (hyperText->IsDefunct())
return CO_E_OBJNOTCONNECTED;
@ -83,13 +83,13 @@ __try {
}
STDMETHODIMP
CAccessibleHypertext::get_hyperlink(long aLinkIndex,
IAccessibleHyperlink **aHyperlink)
ia2AccessibleHypertext::get_hyperlink(long aLinkIndex,
IAccessibleHyperlink** aHyperlink)
{
__try {
*aHyperlink = NULL;
nsRefPtr<nsHyperTextAccessible> hyperText = do_QueryObject(this);
nsHyperTextAccessibleWrap* hyperText = static_cast<nsHyperTextAccessibleWrap*>(this);
if (hyperText->IsDefunct())
return CO_E_OBJNOTCONNECTED;
@ -112,12 +112,12 @@ __try {
}
STDMETHODIMP
CAccessibleHypertext::get_hyperlinkIndex(long aCharIndex, long *aHyperlinkIndex)
ia2AccessibleHypertext::get_hyperlinkIndex(long aCharIndex, long* aHyperlinkIndex)
{
__try {
*aHyperlinkIndex = 0;
nsRefPtr<nsHyperTextAccessible> hyperAcc(do_QueryObject(this));
nsHyperTextAccessibleWrap* hyperAcc = static_cast<nsHyperTextAccessibleWrap*>(this);
if (hyperAcc->IsDefunct())
return CO_E_OBJNOTCONNECTED;

Просмотреть файл

@ -46,8 +46,8 @@
#include "CAccessibleText.h"
#include "AccessibleHypertext.h"
class CAccessibleHypertext: public CAccessibleText,
public IAccessibleHypertext
class ia2AccessibleHypertext : public CAccessibleText,
public IAccessibleHypertext
{
public:
@ -59,15 +59,15 @@ public:
// IAccessibleHypertext
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_nHyperlinks(
/* [retval][out] */ long *hyperlinkCount);
/* [retval][out] */ long* hyperlinkCount);
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_hyperlink(
/* [in] */ long index,
/* [retval][out] */ IAccessibleHyperlink **hyperlink);
/* [retval][out] */ IAccessibleHyperlink** hyperlink);
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_hyperlinkIndex(
/* [in] */ long charIndex,
/* [retval][out] */ long *hyperlinkIndex);
/* [retval][out] */ long* hyperlinkIndex);
// nsISupports
NS_IMETHOD QueryInterface(const nsIID& uuid, void** result) = 0;

Просмотреть файл

@ -47,7 +47,7 @@ NS_IMPL_ISUPPORTS_INHERITED0(nsHyperTextAccessibleWrap,
IMPL_IUNKNOWN_INHERITED2(nsHyperTextAccessibleWrap,
nsAccessibleWrap,
CAccessibleHypertext,
ia2AccessibleHypertext,
CAccessibleEditableText);
nsresult

Просмотреть файл

@ -44,10 +44,10 @@
#include "nsHyperTextAccessible.h"
#include "CAccessibleText.h"
#include "CAccessibleEditableText.h"
#include "CAccessibleHyperText.h"
#include "ia2AccessibleHyperText.h"
class nsHyperTextAccessibleWrap : public nsHyperTextAccessible,
public CAccessibleHypertext,
public ia2AccessibleHypertext,
public CAccessibleEditableText
{
public: