/src/mozilla-central/accessible/atk/nsMaiInterfaceImage.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | getImagePositionCB(AtkImage* aImage, gint* aAccX, gint* aAccY, |
25 | | AtkCoordType aCoordType) |
26 | 0 | { |
27 | 0 | nsIntPoint pos; |
28 | 0 | uint32_t geckoCoordType = (aCoordType == ATK_XY_WINDOW) ? |
29 | 0 | nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE : |
30 | 0 | nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE; |
31 | 0 |
|
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 | 0 | } |
39 | 0 |
|
40 | 0 | *aAccX = pos.x; |
41 | 0 | *aAccY = pos.y; |
42 | 0 | } |
43 | | |
44 | | static const gchar* |
45 | | getImageDescriptionCB(AtkImage* aImage) |
46 | 0 | { |
47 | 0 | return getDescriptionCB(ATK_OBJECT(aImage)); |
48 | 0 | } |
49 | | |
50 | | static void |
51 | | getImageSizeCB(AtkImage* aImage, gint* aAccWidth, gint* aAccHeight) |
52 | 0 | { |
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 | 0 | } |
60 | 0 |
|
61 | 0 | *aAccWidth = size.width; |
62 | 0 | *aAccHeight = size.height; |
63 | 0 | } |
64 | | |
65 | | } // extern "C" |
66 | | |
67 | | void |
68 | | imageInterfaceInitCB(AtkImageIface* aIface) |
69 | 0 | { |
70 | 0 | NS_ASSERTION(aIface, "no interface!"); |
71 | 0 | if (MOZ_UNLIKELY(!aIface)) |
72 | 0 | return; |
73 | 0 | |
74 | 0 | aIface->get_image_position = getImagePositionCB; |
75 | 0 | aIface->get_image_description = getImageDescriptionCB; |
76 | 0 | aIface->get_image_size = getImageSizeCB; |
77 | 0 | } |