mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 745429 - don't use QueryInterface() in CAccessibleImage, r=surkov, f=tbsaunde
--HG-- rename : accessible/src/msaa/CAccessibleImage.cpp => accessible/src/msaa/ia2AccessibleImage.cpp rename : accessible/src/msaa/CAccessibleImage.h => accessible/src/msaa/ia2AccessibleImage.h
This commit is contained in:
parent
47154609cb
commit
db5e514633
@ -362,73 +362,59 @@ nsAccessibleWrap::GetAtkObject(nsIAccessible * acc)
|
||||
PRUint16
|
||||
nsAccessibleWrap::CreateMaiInterfaces(void)
|
||||
{
|
||||
PRUint16 interfacesBits = 0;
|
||||
PRUint16 interfacesBits = 0;
|
||||
|
||||
// Add Interfaces for each nsIAccessible.ext interfaces
|
||||
|
||||
// the Component interface are supported by all nsIAccessible
|
||||
interfacesBits |= 1 << MAI_INTERFACE_COMPONENT;
|
||||
// The Component interface is supported by all accessibles.
|
||||
interfacesBits |= 1 << MAI_INTERFACE_COMPONENT;
|
||||
|
||||
// Add Action interface if the action count is more than zero.
|
||||
if (ActionCount() > 0)
|
||||
interfacesBits |= 1 << MAI_INTERFACE_ACTION;
|
||||
|
||||
//nsIAccessibleText
|
||||
nsCOMPtr<nsIAccessibleText> accessInterfaceText;
|
||||
QueryInterface(NS_GET_IID(nsIAccessibleText),
|
||||
getter_AddRefs(accessInterfaceText));
|
||||
if (accessInterfaceText) {
|
||||
interfacesBits |= 1 << MAI_INTERFACE_TEXT;
|
||||
}
|
||||
// Text, Editabletext, and Hypertext interface.
|
||||
nsHyperTextAccessible* hyperText = AsHyperText();
|
||||
if (hyperText && hyperText->IsTextRole()) {
|
||||
interfacesBits |= 1 << MAI_INTERFACE_TEXT;
|
||||
interfacesBits |= 1 << MAI_INTERFACE_EDITABLE_TEXT;
|
||||
if (!nsAccUtils::MustPrune(this))
|
||||
interfacesBits |= 1 << MAI_INTERFACE_HYPERTEXT;
|
||||
}
|
||||
|
||||
//nsIAccessibleEditableText
|
||||
nsCOMPtr<nsIAccessibleEditableText> accessInterfaceEditableText;
|
||||
QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
|
||||
getter_AddRefs(accessInterfaceEditableText));
|
||||
if (accessInterfaceEditableText) {
|
||||
interfacesBits |= 1 << MAI_INTERFACE_EDITABLE_TEXT;
|
||||
}
|
||||
// Value interface.
|
||||
nsCOMPtr<nsIAccessibleValue> accessInterfaceValue;
|
||||
QueryInterface(NS_GET_IID(nsIAccessibleValue),
|
||||
getter_AddRefs(accessInterfaceValue));
|
||||
if (accessInterfaceValue) {
|
||||
interfacesBits |= 1 << MAI_INTERFACE_VALUE;
|
||||
}
|
||||
|
||||
//nsIAccessibleValue
|
||||
nsCOMPtr<nsIAccessibleValue> accessInterfaceValue;
|
||||
QueryInterface(NS_GET_IID(nsIAccessibleValue),
|
||||
getter_AddRefs(accessInterfaceValue));
|
||||
if (accessInterfaceValue) {
|
||||
interfacesBits |= 1 << MAI_INTERFACE_VALUE;
|
||||
}
|
||||
// Document interface.
|
||||
if (IsDoc())
|
||||
interfacesBits |= 1 << MAI_INTERFACE_DOCUMENT;
|
||||
|
||||
// document accessible
|
||||
if (IsDoc())
|
||||
interfacesBits |= 1 << MAI_INTERFACE_DOCUMENT;
|
||||
if (IsImage())
|
||||
interfacesBits |= 1 << MAI_INTERFACE_IMAGE;
|
||||
|
||||
if (IsImageAccessible())
|
||||
interfacesBits |= 1 << MAI_INTERFACE_IMAGE;
|
||||
|
||||
// HyperLinkAccessible
|
||||
// HyperLink interface.
|
||||
if (IsLink())
|
||||
interfacesBits |= 1 << MAI_INTERFACE_HYPERLINK_IMPL;
|
||||
|
||||
if (!nsAccUtils::MustPrune(this)) { // These interfaces require children
|
||||
//nsIAccessibleHypertext
|
||||
if (IsHyperText()) {
|
||||
interfacesBits |= 1 << MAI_INTERFACE_HYPERTEXT;
|
||||
}
|
||||
|
||||
//nsIAccessibleTable
|
||||
nsCOMPtr<nsIAccessibleTable> accessInterfaceTable;
|
||||
QueryInterface(NS_GET_IID(nsIAccessibleTable),
|
||||
getter_AddRefs(accessInterfaceTable));
|
||||
if (accessInterfaceTable) {
|
||||
interfacesBits |= 1 << MAI_INTERFACE_TABLE;
|
||||
}
|
||||
|
||||
//nsIAccessibleSelection
|
||||
if (IsSelect()) {
|
||||
interfacesBits |= 1 << MAI_INTERFACE_SELECTION;
|
||||
}
|
||||
if (!nsAccUtils::MustPrune(this)) { // These interfaces require children
|
||||
// Table interface.
|
||||
nsCOMPtr<nsIAccessibleTable> accessInterfaceTable;
|
||||
QueryInterface(NS_GET_IID(nsIAccessibleTable),
|
||||
getter_AddRefs(accessInterfaceTable));
|
||||
if (accessInterfaceTable) {
|
||||
interfacesBits |= 1 << MAI_INTERFACE_TABLE;
|
||||
}
|
||||
|
||||
// Selection interface.
|
||||
if (IsSelect()) {
|
||||
interfacesBits |= 1 << MAI_INTERFACE_SELECTION;
|
||||
}
|
||||
}
|
||||
|
||||
return interfacesBits;
|
||||
return interfacesBits;
|
||||
}
|
||||
|
||||
static GType
|
||||
|
@ -14,35 +14,35 @@ extern "C" {
|
||||
const gchar* getDescriptionCB(AtkObject* aAtkObj);
|
||||
|
||||
static void
|
||||
getImagePositionCB(AtkImage *aImage, gint *aAccX, gint *aAccY,
|
||||
getImagePositionCB(AtkImage* aImage, gint* aAccX, gint* aAccY,
|
||||
AtkCoordType aCoordType)
|
||||
{
|
||||
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
|
||||
if (!accWrap || !accWrap->IsImageAccessible())
|
||||
return;
|
||||
nsAccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
|
||||
if (!accWrap || !accWrap->IsImage())
|
||||
return;
|
||||
|
||||
nsHTMLImageAccessible* image = accWrap->AsImage();
|
||||
PRUint32 geckoCoordType = (aCoordType == ATK_XY_WINDOW) ?
|
||||
nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE :
|
||||
nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE;
|
||||
// Returned in screen coordinates
|
||||
image->GetImagePosition(geckoCoordType, aAccX, aAccY);
|
||||
nsHTMLImageAccessible* image = accWrap->AsImage();
|
||||
PRUint32 geckoCoordType = (aCoordType == ATK_XY_WINDOW) ?
|
||||
nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE :
|
||||
nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE;
|
||||
// Returned in screen coordinates
|
||||
image->GetImagePosition(geckoCoordType, aAccX, aAccY);
|
||||
}
|
||||
|
||||
static const gchar*
|
||||
getImageDescriptionCB(AtkImage *aImage)
|
||||
getImageDescriptionCB(AtkImage* aImage)
|
||||
{
|
||||
return getDescriptionCB(ATK_OBJECT(aImage));
|
||||
return getDescriptionCB(ATK_OBJECT(aImage));
|
||||
}
|
||||
|
||||
static void
|
||||
getImageSizeCB(AtkImage *aImage, gint *aAccWidth, gint *aAccHeight)
|
||||
getImageSizeCB(AtkImage* aImage, gint* aAccWidth, gint* aAccHeight)
|
||||
{
|
||||
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
|
||||
if (!accWrap || !accWrap->IsImageAccessible())
|
||||
return;
|
||||
nsAccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
|
||||
if (!accWrap || !accWrap->IsImage())
|
||||
return;
|
||||
|
||||
accWrap->AsImage()->GetImageSize(aAccWidth, aAccHeight);
|
||||
accWrap->AsImage()->GetImageSize(aAccWidth, aAccHeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -461,7 +461,7 @@ public:
|
||||
inline bool IsHTMLListItem() const { return mFlags & eHTMLListItemAccessible; }
|
||||
mozilla::a11y::HTMLLIAccessible* AsHTMLListItem();
|
||||
|
||||
inline bool IsImageAccessible() const { return mFlags & eImageAccessible; }
|
||||
inline bool IsImage() const { return mFlags & eImageAccessible; }
|
||||
nsHTMLImageAccessible* AsImage();
|
||||
|
||||
bool IsImageMapAccessible() const { return mFlags & eImageMapAccessible; }
|
||||
|
@ -77,7 +77,7 @@ private:
|
||||
inline nsHTMLImageAccessible*
|
||||
nsAccessible::AsImage()
|
||||
{
|
||||
return IsImageAccessible() ?
|
||||
return IsImage() ?
|
||||
static_cast<nsHTMLImageAccessible*>(this) : nsnull;
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ CPPSRCS = \
|
||||
nsWinUtils.cpp \
|
||||
ia2AccessibleAction.cpp \
|
||||
ia2AccessibleComponent.cpp \
|
||||
CAccessibleImage.cpp \
|
||||
ia2AccessibleImage.cpp \
|
||||
CAccessibleText.cpp \
|
||||
CAccessibleEditableText.cpp \
|
||||
CAccessibleHyperlink.cpp \
|
||||
|
@ -5,32 +5,30 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "CAccessibleImage.h"
|
||||
#include "ia2AccessibleImage.h"
|
||||
|
||||
#include "AccessibleImage_i.c"
|
||||
|
||||
#include "nsHTMLImageAccessibleWrap.h"
|
||||
#include "nsHTMLImageAccessible.h"
|
||||
|
||||
#include "nsIAccessible.h"
|
||||
#include "nsIAccessibleImage.h"
|
||||
#include "nsIAccessibleTypes.h"
|
||||
#include "nsAccessNodeWrap.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
|
||||
// IUnknown
|
||||
|
||||
STDMETHODIMP
|
||||
CAccessibleImage::QueryInterface(REFIID iid, void** ppv)
|
||||
ia2AccessibleImage::QueryInterface(REFIID iid, void** ppv)
|
||||
{
|
||||
*ppv = NULL;
|
||||
|
||||
if (IID_IAccessibleImage == iid) {
|
||||
nsCOMPtr<nsIAccessibleImage> imageAcc(do_QueryObject(this));
|
||||
if (!imageAcc)
|
||||
return E_FAIL;
|
||||
|
||||
*ppv = static_cast<IAccessibleImage*>(this);
|
||||
(reinterpret_cast<IUnknown*>(*ppv))->AddRef();
|
||||
(static_cast<IUnknown*>(*ppv))->AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@ -40,14 +38,15 @@ CAccessibleImage::QueryInterface(REFIID iid, void** ppv)
|
||||
// IAccessibleImage
|
||||
|
||||
STDMETHODIMP
|
||||
CAccessibleImage::get_description(BSTR *aDescription)
|
||||
ia2AccessibleImage::get_description(BSTR* aDescription)
|
||||
{
|
||||
__try {
|
||||
*aDescription = NULL;
|
||||
|
||||
nsCOMPtr<nsIAccessible> acc(do_QueryObject(this));
|
||||
if (!acc)
|
||||
return E_FAIL;
|
||||
nsHTMLImageAccessibleWrap* acc =
|
||||
static_cast<nsHTMLImageAccessibleWrap*>(this);
|
||||
if (acc->IsDefunct())
|
||||
return CO_E_OBJNOTCONNECTED;
|
||||
|
||||
nsAutoString description;
|
||||
nsresult rv = acc->GetName(description);
|
||||
@ -65,23 +64,24 @@ __try {
|
||||
}
|
||||
|
||||
STDMETHODIMP
|
||||
CAccessibleImage::get_imagePosition(enum IA2CoordinateType aCoordType,
|
||||
long *aX,
|
||||
long *aY)
|
||||
ia2AccessibleImage::get_imagePosition(enum IA2CoordinateType aCoordType,
|
||||
long* aX,
|
||||
long* aY)
|
||||
{
|
||||
__try {
|
||||
*aX = 0;
|
||||
*aY = 0;
|
||||
|
||||
nsHTMLImageAccessibleWrap* imageAcc =
|
||||
static_cast<nsHTMLImageAccessibleWrap*>(this);
|
||||
if (imageAcc->IsDefunct())
|
||||
return CO_E_OBJNOTCONNECTED;
|
||||
|
||||
PRUint32 geckoCoordType = (aCoordType == IA2_COORDTYPE_SCREEN_RELATIVE) ?
|
||||
nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE :
|
||||
nsIAccessibleCoordinateType::COORDTYPE_PARENT_RELATIVE;
|
||||
|
||||
nsCOMPtr<nsIAccessibleImage> imageAcc(do_QueryObject(this));
|
||||
if (!imageAcc)
|
||||
return E_FAIL;
|
||||
|
||||
PRInt32 x = 0, y = 0;
|
||||
|
||||
nsresult rv = imageAcc->GetImagePosition(geckoCoordType, &x, &y);
|
||||
if (NS_FAILED(rv))
|
||||
return GetHRESULT(rv);
|
||||
@ -96,17 +96,18 @@ __try {
|
||||
}
|
||||
|
||||
STDMETHODIMP
|
||||
CAccessibleImage::get_imageSize(long *aHeight, long *aWidth)
|
||||
ia2AccessibleImage::get_imageSize(long* aHeight, long* aWidth)
|
||||
{
|
||||
__try {
|
||||
*aHeight = 0;
|
||||
*aWidth = 0;
|
||||
|
||||
nsCOMPtr<nsIAccessibleImage> imageAcc(do_QueryObject(this));
|
||||
if (!imageAcc)
|
||||
return E_FAIL;
|
||||
nsHTMLImageAccessibleWrap* imageAcc =
|
||||
static_cast<nsHTMLImageAccessibleWrap*>(this);
|
||||
if (imageAcc->IsDefunct())
|
||||
return CO_E_OBJNOTCONNECTED;
|
||||
|
||||
PRInt32 x = 0, y = 0, width = 0, height = 0;
|
||||
PRInt32 width = 0, height = 0;
|
||||
nsresult rv = imageAcc->GetImageSize(&width, &height);
|
||||
if (NS_FAILED(rv))
|
||||
return GetHRESULT(rv);
|
@ -8,11 +8,9 @@
|
||||
#ifndef _ACCESSIBLE_IMAGE_H
|
||||
#define _ACCESSIBLE_IMAGE_H
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
#include "AccessibleImage.h"
|
||||
|
||||
class CAccessibleImage: public IAccessibleImage
|
||||
class ia2AccessibleImage : public IAccessibleImage
|
||||
{
|
||||
public:
|
||||
|
||||
@ -31,10 +29,6 @@ public:
|
||||
virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_imageSize(
|
||||
/* [out] */ long *height,
|
||||
/* [retval][out] */ long *width);
|
||||
|
||||
// nsISupports
|
||||
NS_IMETHOD QueryInterface(const nsIID& uuid, void** result) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@ -12,5 +12,5 @@ NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLImageAccessibleWrap,
|
||||
|
||||
IMPL_IUNKNOWN_INHERITED1(nsHTMLImageAccessibleWrap,
|
||||
nsAccessibleWrap,
|
||||
CAccessibleImage);
|
||||
ia2AccessibleImage);
|
||||
|
||||
|
@ -9,10 +9,10 @@
|
||||
#define _NSHTMLIMAGEACCESSIBLEWRAP_H
|
||||
|
||||
#include "nsHTMLImageAccessible.h"
|
||||
#include "CAccessibleImage.h"
|
||||
#include "ia2AccessibleImage.h"
|
||||
|
||||
class nsHTMLImageAccessibleWrap : public nsHTMLImageAccessible,
|
||||
public CAccessibleImage
|
||||
public ia2AccessibleImage
|
||||
{
|
||||
public:
|
||||
nsHTMLImageAccessibleWrap(nsIContent* aContent, nsDocAccessible* aDoc) :
|
||||
|
Loading…
Reference in New Issue
Block a user