bug 713792 - stop QueryInterface()ing to nsIAccessible image internally r=tbsaunde

This commit is contained in:
Santiago Gimeno 2012-01-05 23:05:03 -05:00
Родитель 11aecab1dd
Коммит 340f536176
4 изменённых файлов: 27 добавлений и 28 удалений

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

@ -449,13 +449,8 @@ nsAccessibleWrap::CreateMaiInterfaces(void)
interfacesBits |= 1 << MAI_INTERFACE_DOCUMENT;
}
//nsIAccessibleImage
nsCOMPtr<nsIAccessibleImage> accessInterfaceImage;
QueryInterface(NS_GET_IID(nsIAccessibleImage),
getter_AddRefs(accessInterfaceImage));
if (accessInterfaceImage) {
if (IsImageAccessible())
interfacesBits |= 1 << MAI_INTERFACE_IMAGE;
}
// HyperLinkAccessible
if (IsLink())

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

@ -37,9 +37,11 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsAccessibleWrap.h"
#include "nsMaiInterfaceImage.h"
#include "nsAccessibleWrap.h"
#include "nsHTMLImageAccessible.h"
extern "C" const gchar* getDescriptionCB(AtkObject* aAtkObj);
void
@ -58,19 +60,13 @@ getImagePositionCB(AtkImage *aImage, gint *aAccX, gint *aAccY,
AtkCoordType aCoordType)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
if (!accWrap)
return;
nsCOMPtr<nsIAccessibleImage> image;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleImage),
getter_AddRefs(image));
if (!image)
if (!accWrap || !accWrap->IsImageAccessible())
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);
}
@ -85,14 +81,8 @@ void
getImageSizeCB(AtkImage *aImage, gint *aAccWidth, gint *aAccHeight)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
if (!accWrap)
if (!accWrap || !accWrap->IsImageAccessible())
return;
nsCOMPtr<nsIAccessibleImage> image;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleImage),
getter_AddRefs(image));
if (!image)
return;
image->GetImageSize(aAccWidth, aAccHeight);
accWrap->AsImage()->GetImageSize(aAccWidth, aAccHeight);
}

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

@ -60,6 +60,7 @@ class EmbeddedObjCollector;
class KeyBinding;
class nsAccessible;
class nsHyperTextAccessible;
class nsHTMLImageAccessible;
class nsHTMLLIAccessible;
struct nsRoleMapEntry;
class Relation;
@ -429,6 +430,9 @@ public:
inline bool IsHTMLListItem() const { return mFlags & eHTMLListItemAccessible; }
nsHTMLLIAccessible* AsHTMLListItem();
inline bool IsImageAccessible() const { return mFlags & eImageAccessible; }
nsHTMLImageAccessible* AsImage();
inline bool IsListControl() const { return mFlags & eListControlAccessible; }
inline bool IsMenuButton() const { return mFlags & eMenuButtonAccessible; }
@ -654,11 +658,12 @@ protected:
eHyperTextAccessible = 1 << 7,
eHTMLFileInputAccessible = 1 << 8,
eHTMLListItemAccessible = 1 << 9,
eListControlAccessible = 1 << 10,
eMenuButtonAccessible = 1 << 11,
eMenuPopupAccessible = 1 << 12,
eRootAccessible = 1 << 13,
eTextLeafAccessible = 1 << 14
eImageAccessible = 1 << 10,
eListControlAccessible = 1 << 11,
eMenuButtonAccessible = 1 << 12,
eMenuPopupAccessible = 1 << 13,
eRootAccessible = 1 << 14,
eTextLeafAccessible = 1 << 15
};
//////////////////////////////////////////////////////////////////////////////

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

@ -92,5 +92,14 @@ private:
bool IsValidLongDescIndex(PRUint8 aIndex);
};
////////////////////////////////////////////////////////////////////////////////
// nsAccessible downcasting method
inline nsHTMLImageAccessible*
nsAccessible::AsImage()
{
return IsImageAccessible() ?
static_cast<nsHTMLImageAccessible*>(this) : nsnull;
}
#endif