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"
|
2013-09-07 17:01:08 +04:00
|
|
|
#include "nsIURI.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-03-20 08:02:50 +04:00
|
|
|
static void
|
2012-05-22 20:40:56 +04:00
|
|
|
getImagePositionCB(AtkImage* aImage, gint* aAccX, gint* aAccY,
|
2007-02-12 10:04:58 +03:00
|
|
|
AtkCoordType aCoordType)
|
|
|
|
{
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
|
2012-05-22 20:40:56 +04:00
|
|
|
if (!accWrap || !accWrap->IsImage())
|
|
|
|
return;
|
|
|
|
|
2012-06-02 15:30:34 +04:00
|
|
|
ImageAccessible* image = accWrap->AsImage();
|
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;
|
2014-10-22 04:49:28 +04:00
|
|
|
nsIntPoint pos = image->Position(geckoCoordType);
|
|
|
|
*aAccX = pos.x;
|
|
|
|
*aAccY = pos.y;
|
2007-02-12 10:04:58 +03:00
|
|
|
}
|
|
|
|
|
2012-03-20 08:02:50 +04:00
|
|
|
static const gchar*
|
2012-05-22 20:40:56 +04:00
|
|
|
getImageDescriptionCB(AtkImage* aImage)
|
2007-02-12 10:04:58 +03:00
|
|
|
{
|
2012-05-22 20:40:56 +04:00
|
|
|
return getDescriptionCB(ATK_OBJECT(aImage));
|
2007-02-12 10:04:58 +03:00
|
|
|
}
|
|
|
|
|
2012-03-20 08:02:50 +04:00
|
|
|
static void
|
2012-05-22 20:40:56 +04:00
|
|
|
getImageSizeCB(AtkImage* aImage, gint* aAccWidth, gint* aAccHeight)
|
2007-02-12 10:04:58 +03:00
|
|
|
{
|
2012-05-29 05:18:45 +04:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
|
2012-05-22 20:40:56 +04:00
|
|
|
if (!accWrap || !accWrap->IsImage())
|
|
|
|
return;
|
2007-02-12 10:04:58 +03:00
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
nsIntSize size = accWrap->AsImage()->Size();
|
|
|
|
*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))
|
2012-03-20 08:02:50 +04:00
|
|
|
return;
|
|
|
|
|
|
|
|
aIface->get_image_position = getImagePositionCB;
|
|
|
|
aIface->get_image_description = getImageDescriptionCB;
|
|
|
|
aIface->get_image_size = getImageSizeCB;
|
|
|
|
}
|