OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) 2008 Nuanti Ltd. | |
3 * Copyright (C) 2009 Jan Alonzo | |
4 * Copyright (C) 2009, 2012 Igalia S.L. | |
5 * | |
6 * Portions from Mozilla a11y, copyright as follows: | |
7 * | |
8 * The Original Code is mozilla.org code. | |
9 * | |
10 * The Initial Developer of the Original Code is | |
11 * Sun Microsystems, Inc. | |
12 * Portions created by the Initial Developer are Copyright (C) 2002 | |
13 * the Initial Developer. All Rights Reserved. | |
14 * | |
15 * This library is free software; you can redistribute it and/or | |
16 * modify it under the terms of the GNU Library General Public | |
17 * License as published by the Free Software Foundation; either | |
18 * version 2 of the License, or (at your option) any later version. | |
19 * | |
20 * This library is distributed in the hope that it will be useful, | |
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
23 * Library General Public License for more details. | |
24 * | |
25 * You should have received a copy of the GNU Library General Public License | |
26 * along with this library; see the file COPYING.LIB. If not, write to | |
27 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
28 * Boston, MA 02110-1301, USA. | |
29 */ | |
30 | |
31 #include "config.h" | |
32 #include "WebKitAccessibleInterfaceComponent.h" | |
33 | |
34 #if HAVE(ACCESSIBILITY) | |
35 | |
36 #include "AccessibilityObject.h" | |
37 #include "FrameView.h" | |
38 #include "IntRect.h" | |
39 #include "WebKitAccessibleUtil.h" | |
40 #include "WebKitAccessibleWrapperAtk.h" | |
41 | |
42 using namespace WebCore; | |
43 | |
44 static AccessibilityObject* core(AtkComponent* component) | |
45 { | |
46 if (!WEBKIT_IS_ACCESSIBLE(component)) | |
47 return 0; | |
48 | |
49 return webkitAccessibleGetAccessibilityObject(WEBKIT_ACCESSIBLE(component)); | |
50 } | |
51 | |
52 static IntPoint atkToContents(AccessibilityObject* coreObject, AtkCoordType coor
dType, gint x, gint y) | |
53 { | |
54 IntPoint pos(x, y); | |
55 | |
56 FrameView* frameView = coreObject->documentFrameView(); | |
57 if (frameView) { | |
58 switch (coordType) { | |
59 case ATK_XY_SCREEN: | |
60 return frameView->screenToContents(pos); | |
61 case ATK_XY_WINDOW: | |
62 return frameView->windowToContents(pos); | |
63 } | |
64 } | |
65 | |
66 return pos; | |
67 } | |
68 | |
69 static AtkObject* webkitAccessibleComponentRefAccessibleAtPoint(AtkComponent* co
mponent, gint x, gint y, AtkCoordType coordType) | |
70 { | |
71 IntPoint pos = atkToContents(core(component), coordType, x, y); | |
72 | |
73 AccessibilityObject* target = core(component)->accessibilityHitTest(pos); | |
74 if (!target) | |
75 return 0; | |
76 g_object_ref(target->wrapper()); | |
77 return target->wrapper(); | |
78 } | |
79 | |
80 static void webkitAccessibleComponentGetExtents(AtkComponent* component, gint* x
, gint* y, gint* width, gint* height, AtkCoordType coordType) | |
81 { | |
82 IntRect rect = pixelSnappedIntRect(core(component)->elementRect()); | |
83 contentsRelativeToAtkCoordinateType(core(component), coordType, rect, x, y,
width, height); | |
84 } | |
85 | |
86 static gboolean webkitAccessibleComponentGrabFocus(AtkComponent* component) | |
87 { | |
88 core(component)->setFocused(true); | |
89 return core(component)->isFocused(); | |
90 } | |
91 | |
92 void webkitAccessibleComponentInterfaceInit(AtkComponentIface* iface) | |
93 { | |
94 iface->ref_accessible_at_point = webkitAccessibleComponentRefAccessibleAtPoi
nt; | |
95 iface->get_extents = webkitAccessibleComponentGetExtents; | |
96 iface->grab_focus = webkitAccessibleComponentGrabFocus; | |
97 } | |
98 | |
99 #endif | |
OLD | NEW |