WebKitAccessibleInterfaceImage.cpp [plain text]
#include "config.h"
#include "WebKitAccessibleInterfaceImage.h"
#if HAVE(ACCESSIBILITY)
#include "AccessibilityObject.h"
#include "IntRect.h"
#include "WebKitAccessibleUtil.h"
#include "WebKitAccessibleWrapperAtk.h"
using namespace WebCore;
static AccessibilityObject* core(AtkImage* image)
{
if (!WEBKIT_IS_ACCESSIBLE(image))
return 0;
return webkitAccessibleGetAccessibilityObject(WEBKIT_ACCESSIBLE(image));
}
static void webkitAccessibleImageGetImagePosition(AtkImage* image, gint* x, gint* y, AtkCoordType coordType)
{
g_return_if_fail(ATK_IMAGE(image));
returnIfWebKitAccessibleIsInvalid(WEBKIT_ACCESSIBLE(image));
IntRect rect = snappedIntRect(core(image)->elementRect());
contentsRelativeToAtkCoordinateType(core(image), coordType, rect, x, y);
}
static const gchar* webkitAccessibleImageGetImageDescription(AtkImage* image)
{
g_return_val_if_fail(ATK_IMAGE(image), 0);
returnValIfWebKitAccessibleIsInvalid(WEBKIT_ACCESSIBLE(image), 0);
return cacheAndReturnAtkProperty(ATK_OBJECT(image), AtkCachedImageDescription, accessibilityDescription(core(image)));
}
static void webkitAccessibleImageGetImageSize(AtkImage* image, gint* width, gint* height)
{
g_return_if_fail(ATK_IMAGE(image));
returnIfWebKitAccessibleIsInvalid(WEBKIT_ACCESSIBLE(image));
IntSize size = core(image)->elementRect().pixelSnappedSize();
if (width)
*width = size.width();
if (height)
*height = size.height();
}
void webkitAccessibleImageInterfaceInit(AtkImageIface* iface)
{
iface->get_image_position = webkitAccessibleImageGetImagePosition;
iface->get_image_description = webkitAccessibleImageGetImageDescription;
iface->get_image_size = webkitAccessibleImageGetImageSize;
}
#endif