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; interfacesBits |= 1 << MAI_INTERFACE_DOCUMENT;
} }
//nsIAccessibleImage if (IsImageAccessible())
nsCOMPtr<nsIAccessibleImage> accessInterfaceImage;
QueryInterface(NS_GET_IID(nsIAccessibleImage),
getter_AddRefs(accessInterfaceImage));
if (accessInterfaceImage) {
interfacesBits |= 1 << MAI_INTERFACE_IMAGE; interfacesBits |= 1 << MAI_INTERFACE_IMAGE;
}
// HyperLinkAccessible // HyperLinkAccessible
if (IsLink()) if (IsLink())

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

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

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

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

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

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