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