• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3  * Copyright (C) 2009 Jan Michael Alonzo
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
15  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
18  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26 
27 #include "config.h"
28 #include "AccessibilityUIElement.h"
29 
30 #include <JavaScriptCore/JSStringRef.h>
31 #include <wtf/Assertions.h>
32 
33 #include <atk/atk.h>
34 #include <gtk/gtk.h>
35 
36 
AccessibilityUIElement(PlatformUIElement element)37 AccessibilityUIElement::AccessibilityUIElement(PlatformUIElement element)
38     : m_element(element)
39 {
40 }
41 
AccessibilityUIElement(const AccessibilityUIElement & other)42 AccessibilityUIElement::AccessibilityUIElement(const AccessibilityUIElement& other)
43     : m_element(other.m_element)
44 {
45 }
46 
~AccessibilityUIElement()47 AccessibilityUIElement::~AccessibilityUIElement()
48 {
49 }
50 
getLinkedUIElements(Vector<AccessibilityUIElement> & elements)51 void AccessibilityUIElement::getLinkedUIElements(Vector<AccessibilityUIElement>& elements)
52 {
53     // FIXME: implement
54 }
55 
getDocumentLinks(Vector<AccessibilityUIElement> &)56 void AccessibilityUIElement::getDocumentLinks(Vector<AccessibilityUIElement>&)
57 {
58     // FIXME: implement
59 }
60 
getChildren(Vector<AccessibilityUIElement> & children)61 void AccessibilityUIElement::getChildren(Vector<AccessibilityUIElement>& children)
62 {
63     int count = childrenCount();
64     for (int i = 0; i < count; i++) {
65         AtkObject* child = atk_object_ref_accessible_child(ATK_OBJECT(m_element), i);
66         children.append(AccessibilityUIElement(child));
67     }
68 }
69 
getChildrenWithRange(Vector<AccessibilityUIElement> & elementVector,unsigned location,unsigned length)70 void AccessibilityUIElement::getChildrenWithRange(Vector<AccessibilityUIElement>& elementVector, unsigned location, unsigned length)
71 {
72     for (unsigned i = location; i < length; i++) {
73         AtkObject* child = atk_object_ref_accessible_child(ATK_OBJECT(m_element), i);
74         elementVector.append(AccessibilityUIElement(child));
75     }
76 }
77 
childrenCount()78 int AccessibilityUIElement::childrenCount()
79 {
80     if (!m_element)
81         return 0;
82 
83     ASSERT(ATK_IS_OBJECT(m_element));
84 
85     return atk_object_get_n_accessible_children(ATK_OBJECT(m_element));
86 }
87 
elementAtPoint(int x,int y)88 AccessibilityUIElement AccessibilityUIElement::elementAtPoint(int x, int y)
89 {
90     // FIXME: implement
91     return 0;
92 }
93 
getChildAtIndex(unsigned index)94 AccessibilityUIElement AccessibilityUIElement::getChildAtIndex(unsigned index)
95 {
96     Vector<AccessibilityUIElement> children;
97     getChildrenWithRange(children, index, 1);
98 
99     if (children.size() == 1)
100         return children.at(0);
101 
102     return 0;
103 }
104 
allAttributes()105 JSStringRef AccessibilityUIElement::allAttributes()
106 {
107     // FIXME: implement
108     return JSStringCreateWithCharacters(0, 0);
109 }
110 
attributesOfLinkedUIElements()111 JSStringRef AccessibilityUIElement::attributesOfLinkedUIElements()
112 {
113     // FIXME: implement
114     return JSStringCreateWithCharacters(0, 0);
115 }
116 
attributesOfDocumentLinks()117 JSStringRef AccessibilityUIElement::attributesOfDocumentLinks()
118 {
119     // FIXME: implement
120     return JSStringCreateWithCharacters(0, 0);
121 }
122 
titleUIElement()123 AccessibilityUIElement AccessibilityUIElement::titleUIElement()
124 {
125     // FIXME: implement
126     return 0;
127 }
128 
parentElement()129 AccessibilityUIElement AccessibilityUIElement::parentElement()
130 {
131     ASSERT(m_element);
132     AtkObject* parent =  atk_object_get_parent(ATK_OBJECT(m_element));
133 
134     return parent ? AccessibilityUIElement(parent) : 0;
135 }
136 
attributesOfChildren()137 JSStringRef AccessibilityUIElement::attributesOfChildren()
138 {
139     // FIXME: implement
140     return JSStringCreateWithCharacters(0, 0);
141 }
142 
parameterizedAttributeNames()143 JSStringRef AccessibilityUIElement::parameterizedAttributeNames()
144 {
145     // FIXME: implement
146     return JSStringCreateWithCharacters(0, 0);
147 }
148 
role()149 JSStringRef AccessibilityUIElement::role()
150 {
151     AtkRole role = atk_object_get_role(ATK_OBJECT(m_element));
152 
153     if (!role)
154         return JSStringCreateWithCharacters(0, 0);
155 
156     return JSStringCreateWithUTF8CString(atk_role_get_name(role));
157 }
158 
title()159 JSStringRef AccessibilityUIElement::title()
160 {
161     const gchar* name = atk_object_get_name(ATK_OBJECT(m_element));
162 
163     if (!name)
164         return JSStringCreateWithCharacters(0, 0);
165 
166     return JSStringCreateWithUTF8CString(name);
167 }
168 
description()169 JSStringRef AccessibilityUIElement::description()
170 {
171     const gchar* description = atk_object_get_description(ATK_OBJECT(m_element));
172 
173     if (!description)
174         return JSStringCreateWithCharacters(0, 0);
175 
176     return JSStringCreateWithUTF8CString(description);
177 }
178 
language()179 JSStringRef AccessibilityUIElement::language()
180 {
181     // FIXME: implement
182     return JSStringCreateWithCharacters(0, 0);
183 }
184 
x()185 double AccessibilityUIElement::x()
186 {
187     int x, y;
188 
189     atk_component_get_position(ATK_COMPONENT(m_element), &x, &y, ATK_XY_SCREEN);
190 
191     return x;
192 }
193 
y()194 double AccessibilityUIElement::y()
195 {
196     int x, y;
197 
198     atk_component_get_position(ATK_COMPONENT(m_element), &x, &y, ATK_XY_SCREEN);
199 
200     return y;
201 }
202 
width()203 double AccessibilityUIElement::width()
204 {
205     int width, height;
206 
207     atk_component_get_size(ATK_COMPONENT(m_element), &width, &height);
208 
209     return width;
210 }
211 
height()212 double AccessibilityUIElement::height()
213 {
214     int width, height;
215 
216     atk_component_get_size(ATK_COMPONENT(m_element), &width, &height);
217 
218     return height;
219 }
220 
clickPointX()221 double AccessibilityUIElement::clickPointX()
222 {
223     return 0.f;
224 }
225 
clickPointY()226 double AccessibilityUIElement::clickPointY()
227 {
228     return 0.f;
229 }
230 
231 
intValue()232 double AccessibilityUIElement::intValue()
233 {
234     GValue value = { 0, { { 0 } } };
235 
236     if (!ATK_IS_VALUE(m_element))
237         return 0.0f;
238 
239     atk_value_get_current_value(ATK_VALUE(m_element), &value);
240 
241     if (G_VALUE_HOLDS_DOUBLE(&value))
242         return g_value_get_double(&value);
243     else if (G_VALUE_HOLDS_INT(&value))
244         return static_cast<double>(g_value_get_int(&value));
245     else
246         return 0.0f;
247 }
248 
minValue()249 double AccessibilityUIElement::minValue()
250 {
251     GValue value = { 0, { { 0 } } };
252 
253     if (!ATK_IS_VALUE(m_element))
254         return 0.0f;
255 
256     atk_value_get_minimum_value(ATK_VALUE(m_element), &value);
257 
258     if (G_VALUE_HOLDS_DOUBLE(&value))
259         return g_value_get_double(&value);
260     else if (G_VALUE_HOLDS_INT(&value))
261         return static_cast<double>(g_value_get_int(&value));
262     else
263         return 0.0f;
264 }
265 
maxValue()266 double AccessibilityUIElement::maxValue()
267 {
268     GValue value = { 0, { { 0 } } };
269 
270     if (!ATK_IS_VALUE(m_element))
271         return 0.0f;
272 
273     atk_value_get_maximum_value(ATK_VALUE(m_element), &value);
274 
275     if (G_VALUE_HOLDS_DOUBLE(&value))
276         return g_value_get_double(&value);
277     else if (G_VALUE_HOLDS_INT(&value))
278         return static_cast<double>(g_value_get_int(&value));
279     else
280         return 0.0f;
281 }
282 
valueDescription()283 JSStringRef AccessibilityUIElement::valueDescription()
284 {
285     // FIXME: implement
286     return JSStringCreateWithCharacters(0, 0);
287 }
288 
isEnabled()289 bool AccessibilityUIElement::isEnabled()
290 {
291     // FIXME: implement
292     return false;
293 }
294 
295 
insertionPointLineNumber()296 int AccessibilityUIElement::insertionPointLineNumber()
297 {
298     // FIXME: implement
299     return 0;
300 }
301 
isActionSupported(JSStringRef action)302 bool AccessibilityUIElement::isActionSupported(JSStringRef action)
303 {
304     // FIXME: implement
305     return false;
306 }
307 
isRequired() const308 bool AccessibilityUIElement::isRequired() const
309 {
310     // FIXME: implement
311     return false;
312 }
313 
attributesOfColumnHeaders()314 JSStringRef AccessibilityUIElement::attributesOfColumnHeaders()
315 {
316     // FIXME: implement
317     return JSStringCreateWithCharacters(0, 0);
318 }
319 
attributesOfRowHeaders()320 JSStringRef AccessibilityUIElement::attributesOfRowHeaders()
321 {
322     // FIXME: implement
323     return JSStringCreateWithCharacters(0, 0);
324 }
325 
attributesOfColumns()326 JSStringRef AccessibilityUIElement::attributesOfColumns()
327 {
328     // FIXME: implement
329     return JSStringCreateWithCharacters(0, 0);
330 }
331 
attributesOfRows()332 JSStringRef AccessibilityUIElement::attributesOfRows()
333 {
334     // FIXME: implement
335     return JSStringCreateWithCharacters(0, 0);
336 }
337 
attributesOfVisibleCells()338 JSStringRef AccessibilityUIElement::attributesOfVisibleCells()
339 {
340     // FIXME: implement
341     return JSStringCreateWithCharacters(0, 0);
342 }
343 
attributesOfHeader()344 JSStringRef AccessibilityUIElement::attributesOfHeader()
345 {
346     // FIXME: implement
347     return JSStringCreateWithCharacters(0, 0);
348 }
349 
indexInTable()350 int AccessibilityUIElement::indexInTable()
351 {
352     // FIXME: implement
353     return 0;
354 }
355 
rowIndexRange()356 JSStringRef AccessibilityUIElement::rowIndexRange()
357 {
358     // FIXME: implement
359     return JSStringCreateWithCharacters(0, 0);
360 }
361 
columnIndexRange()362 JSStringRef AccessibilityUIElement::columnIndexRange()
363 {
364     // FIXME: implement
365     return JSStringCreateWithCharacters(0, 0);
366 }
367 
lineForIndex(int)368 int AccessibilityUIElement::lineForIndex(int)
369 {
370     // FIXME: implement
371     return 0;
372 }
373 
boundsForRange(unsigned location,unsigned length)374 JSStringRef AccessibilityUIElement::boundsForRange(unsigned location, unsigned length)
375 {
376     // FIXME: implement
377     return JSStringCreateWithCharacters(0, 0);
378 }
379 
cellForColumnAndRow(unsigned column,unsigned row)380 AccessibilityUIElement AccessibilityUIElement::cellForColumnAndRow(unsigned column, unsigned row)
381 {
382     // FIXME: implement
383     return 0;
384 }
385 
selectedTextRange()386 JSStringRef AccessibilityUIElement::selectedTextRange()
387 {
388     // FIXME: implement
389     return JSStringCreateWithCharacters(0, 0);
390 }
391 
setSelectedTextRange(unsigned location,unsigned length)392 void AccessibilityUIElement::setSelectedTextRange(unsigned location, unsigned length)
393 {
394     // FIXME: implement
395 }
396 
attributeValue(JSStringRef attribute)397 JSStringRef AccessibilityUIElement::attributeValue(JSStringRef attribute)
398 {
399     // FIXME: implement
400     return JSStringCreateWithCharacters(0, 0);
401 }
402 
isAttributeSettable(JSStringRef attribute)403 bool AccessibilityUIElement::isAttributeSettable(JSStringRef attribute)
404 {
405     // FIXME: implement
406     return false;
407 }
408 
increment()409 void AccessibilityUIElement::increment()
410 {
411     // FIXME: implement
412 }
413 
decrement()414 void AccessibilityUIElement::decrement()
415 {
416     // FIXME: implement
417 }
418