1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "InterfaceInitFuncs.h"
9 #include "AccessibleWrap.h"
10 #include "mozilla/a11y/Accessible.h"
11 #include "mozilla/Likely.h"
13 #include "nsIAccessibleTypes.h"
15 using namespace mozilla
;
16 using namespace mozilla::a11y
;
19 const gchar
* getDescriptionCB(AtkObject
* aAtkObj
);
21 static void getImagePositionCB(AtkImage
* aImage
, gint
* aAccX
, gint
* aAccY
,
22 AtkCoordType aCoordType
) {
23 LayoutDeviceIntPoint
pos(-1, -1);
24 uint32_t geckoCoordType
=
25 (aCoordType
== ATK_XY_WINDOW
)
26 ? nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE
27 : nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE
;
29 if (Accessible
* acc
= GetInternalObj(ATK_OBJECT(aImage
))) {
30 pos
= acc
->Position(geckoCoordType
);
37 static const gchar
* getImageDescriptionCB(AtkImage
* aImage
) {
38 return getDescriptionCB(ATK_OBJECT(aImage
));
41 static void getImageSizeCB(AtkImage
* aImage
, gint
* aAccWidth
,
43 LayoutDeviceIntSize
size(-1, -1);
44 if (Accessible
* acc
= GetInternalObj(ATK_OBJECT(aImage
))) {
48 *aAccWidth
= size
.width
;
49 *aAccHeight
= size
.height
;
54 void imageInterfaceInitCB(AtkImageIface
* aIface
) {
55 NS_ASSERTION(aIface
, "no interface!");
56 if (MOZ_UNLIKELY(!aIface
)) return;
58 aIface
->get_image_position
= getImagePositionCB
;
59 aIface
->get_image_description
= getImageDescriptionCB
;
60 aIface
->get_image_size
= getImageSizeCB
;