Line data Source code
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/. */
6 :
7 : #include "InterfaceInitFuncs.h"
8 :
9 : #include "AccessibleWrap.h"
10 : #include "ImageAccessible.h"
11 : #include "mozilla/Likely.h"
12 : #include "nsMai.h"
13 : #include "nsIAccessibleTypes.h"
14 : #include "nsIURI.h"
15 : #include "ProxyAccessible.h"
16 :
17 : using namespace mozilla;
18 : using namespace mozilla::a11y;
19 :
20 : extern "C" {
21 : const gchar* getDescriptionCB(AtkObject* aAtkObj);
22 :
23 : static void
24 0 : getImagePositionCB(AtkImage* aImage, gint* aAccX, gint* aAccY,
25 : AtkCoordType aCoordType)
26 : {
27 0 : nsIntPoint pos;
28 0 : uint32_t geckoCoordType = (aCoordType == ATK_XY_WINDOW) ?
29 : nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE :
30 0 : nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE;
31 :
32 0 : AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
33 0 : if (accWrap && accWrap->IsImage()) {
34 0 : ImageAccessible* image = accWrap->AsImage();
35 0 : pos = image->Position(geckoCoordType);
36 0 : } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aImage))) {
37 0 : pos = proxy->ImagePosition(geckoCoordType);
38 : }
39 :
40 0 : *aAccX = pos.x;
41 0 : *aAccY = pos.y;
42 0 : }
43 :
44 : static const gchar*
45 0 : getImageDescriptionCB(AtkImage* aImage)
46 : {
47 0 : return getDescriptionCB(ATK_OBJECT(aImage));
48 : }
49 :
50 : static void
51 0 : getImageSizeCB(AtkImage* aImage, gint* aAccWidth, gint* aAccHeight)
52 : {
53 0 : nsIntSize size;
54 0 : AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
55 0 : if (accWrap && accWrap->IsImage()) {
56 0 : size = accWrap->AsImage()->Size();
57 0 : } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aImage))) {
58 0 : size = proxy->ImageSize();
59 : }
60 :
61 0 : *aAccWidth = size.width;
62 0 : *aAccHeight = size.height;
63 0 : }
64 :
65 : } // extern "C"
66 :
67 : void
68 0 : imageInterfaceInitCB(AtkImageIface* aIface)
69 : {
70 0 : NS_ASSERTION(aIface, "no interface!");
71 0 : if (MOZ_UNLIKELY(!aIface))
72 0 : return;
73 :
74 0 : aIface->get_image_position = getImagePositionCB;
75 0 : aIface->get_image_description = getImageDescriptionCB;
76 0 : aIface->get_image_size = getImageSizeCB;
77 : }
|