2011-04-27 06:42:27 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2011-05-27 15:37:24 -07:00
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* 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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-19 21:02:50 -07:00
|
|
|
#include "InterfaceInitFuncs.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
#include "AccessibleWrap.h"
|
2012-06-02 04:30:34 -07:00
|
|
|
#include "ImageAccessible.h"
|
2012-10-26 06:32:10 -07:00
|
|
|
#include "mozilla/Likely.h"
|
2012-03-19 21:02:50 -07:00
|
|
|
#include "nsMai.h"
|
2013-09-10 15:18:59 -07:00
|
|
|
#include "nsIAccessibleTypes.h"
|
2013-09-07 06:01:08 -07:00
|
|
|
#include "nsIURI.h"
|
2015-03-22 14:44:12 -07:00
|
|
|
#include "ProxyAccessible.h"
|
2012-01-05 20:05:03 -08:00
|
|
|
|
2012-06-02 04:30:34 -07:00
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2012-03-19 21:02:50 -07:00
|
|
|
extern "C" {
|
|
|
|
const gchar* getDescriptionCB(AtkObject* aAtkObj);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-19 21:02:50 -07:00
|
|
|
static void
|
2012-05-22 09:40:56 -07:00
|
|
|
getImagePositionCB(AtkImage* aImage, gint* aAccX, gint* aAccY,
|
2007-03-22 10:30:00 -07:00
|
|
|
AtkCoordType aCoordType)
|
|
|
|
{
|
2015-03-22 14:44:12 -07:00
|
|
|
nsIntPoint pos;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t geckoCoordType = (aCoordType == ATK_XY_WINDOW) ?
|
2012-05-22 09:40:56 -07:00
|
|
|
nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE :
|
|
|
|
nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE;
|
2015-03-22 14:44:12 -07:00
|
|
|
|
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
|
|
|
|
if (accWrap && accWrap->IsImage()) {
|
|
|
|
ImageAccessible* image = accWrap->AsImage();
|
|
|
|
pos = image->Position(geckoCoordType);
|
|
|
|
} else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aImage))) {
|
|
|
|
pos = proxy->ImagePosition(geckoCoordType);
|
|
|
|
}
|
|
|
|
|
2014-10-21 17:49:28 -07:00
|
|
|
*aAccX = pos.x;
|
|
|
|
*aAccY = pos.y;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-03-19 21:02:50 -07:00
|
|
|
static const gchar*
|
2012-05-22 09:40:56 -07:00
|
|
|
getImageDescriptionCB(AtkImage* aImage)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-05-22 09:40:56 -07:00
|
|
|
return getDescriptionCB(ATK_OBJECT(aImage));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-03-19 21:02:50 -07:00
|
|
|
static void
|
2012-05-22 09:40:56 -07:00
|
|
|
getImageSizeCB(AtkImage* aImage, gint* aAccWidth, gint* aAccHeight)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2015-03-22 14:44:12 -07:00
|
|
|
nsIntSize size;
|
2012-05-28 18:18:45 -07:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
|
2015-03-22 14:44:12 -07:00
|
|
|
if (accWrap && accWrap->IsImage()) {
|
|
|
|
size = accWrap->AsImage()->Size();
|
|
|
|
} else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aImage))) {
|
|
|
|
size = proxy->ImageSize();
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-10-21 17:49:28 -07:00
|
|
|
*aAccWidth = size.width;
|
|
|
|
*aAccHeight = size.height;
|
2012-03-19 21:02:50 -07:00
|
|
|
}
|
|
|
|
|
2014-10-21 17:49:28 -07:00
|
|
|
} // extern "C"
|
|
|
|
|
2012-03-19 21:02:50 -07:00
|
|
|
void
|
|
|
|
imageInterfaceInitCB(AtkImageIface* aIface)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aIface, "no interface!");
|
2012-10-26 06:32:10 -07:00
|
|
|
if (MOZ_UNLIKELY(!aIface))
|
2012-03-19 21:02:50 -07:00
|
|
|
return;
|
|
|
|
|
|
|
|
aIface->get_image_position = getImagePositionCB;
|
|
|
|
aIface->get_image_description = getImageDescriptionCB;
|
|
|
|
aIface->get_image_size = getImageSizeCB;
|
|
|
|
}
|