Add "VisibleOnly" key to search predicate
[WebKit-https.git] / Tools / DumpRenderTree / AccessibilityUIElement.cpp
1 /*
2  * Copyright (C) 2008, 2009 Apple Inc. All Rights Reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24  */
25
26 #include "config.h"
27
28 #if HAVE(ACCESSIBILITY)
29
30 #include "AccessibilityUIElement.h"
31
32 #include <JavaScriptCore/JSObjectRef.h>
33 #include <JavaScriptCore/JSRetainPtr.h>
34 #include <limits.h>
35
36 // Static Functions
37
38 static inline AccessibilityUIElement* toAXElement(JSObjectRef object)
39 {
40     // FIXME: We should ASSERT that it is the right class here.
41     return static_cast<AccessibilityUIElement*>(JSObjectGetPrivate(object));
42 }
43
44 static JSValueRef allAttributesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
45 {
46     JSRetainPtr<JSStringRef> attributes(Adopt, toAXElement(thisObject)->allAttributes());
47     return JSValueMakeString(context, attributes.get());
48 }
49
50 static JSValueRef attributesOfLinkedUIElementsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
51 {
52     JSRetainPtr<JSStringRef> linkedUIDescription(Adopt, toAXElement(thisObject)->attributesOfLinkedUIElements());
53     return JSValueMakeString(context, linkedUIDescription.get());
54 }
55
56 static JSValueRef attributesOfDocumentLinksCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
57 {
58     JSRetainPtr<JSStringRef> linkedUIDescription(Adopt, toAXElement(thisObject)->attributesOfDocumentLinks());
59     return JSValueMakeString(context, linkedUIDescription.get());
60 }
61
62 static JSValueRef attributesOfChildrenCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
63 {
64     JSRetainPtr<JSStringRef> childrenDescription(Adopt, toAXElement(thisObject)->attributesOfChildren());
65     return JSValueMakeString(context, childrenDescription.get());
66 }
67
68 static JSValueRef parameterizedAttributeNamesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
69 {
70     JSRetainPtr<JSStringRef> parameterizedAttributeNames(Adopt, toAXElement(thisObject)->parameterizedAttributeNames());
71     return JSValueMakeString(context, parameterizedAttributeNames.get());
72 }
73
74 static JSValueRef attributesOfColumnHeadersCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
75 {
76     JSRetainPtr<JSStringRef> attributesOfColumnHeaders(Adopt, toAXElement(thisObject)->attributesOfColumnHeaders());
77     return JSValueMakeString(context, attributesOfColumnHeaders.get());
78 }
79
80 static JSValueRef attributesOfRowHeadersCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
81 {
82     JSRetainPtr<JSStringRef> attributesOfRowHeaders(Adopt, toAXElement(thisObject)->attributesOfRowHeaders());
83     return JSValueMakeString(context, attributesOfRowHeaders.get());
84 }
85
86 static JSValueRef attributesOfColumnsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
87 {
88     JSRetainPtr<JSStringRef> attributesOfColumns(Adopt, toAXElement(thisObject)->attributesOfColumns());
89     return JSValueMakeString(context, attributesOfColumns.get());
90 }
91
92 static JSValueRef attributesOfRowsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
93 {
94     JSRetainPtr<JSStringRef> attributesOfRows(Adopt, toAXElement(thisObject)->attributesOfRows());
95     return JSValueMakeString(context, attributesOfRows.get());
96 }
97
98 static JSValueRef attributesOfVisibleCellsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
99 {
100     JSRetainPtr<JSStringRef> attributesOfVisibleCells(Adopt, toAXElement(thisObject)->attributesOfVisibleCells());
101     return JSValueMakeString(context, attributesOfVisibleCells.get());
102 }
103
104 static JSValueRef attributesOfHeaderCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
105 {
106     JSRetainPtr<JSStringRef> attributesOfHeader(Adopt, toAXElement(thisObject)->attributesOfHeader());
107     return JSValueMakeString(context, attributesOfHeader.get());
108 }
109
110 static JSValueRef indexInTableCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
111 {
112     return JSValueMakeNumber(context, toAXElement(thisObject)->indexInTable());
113 }
114
115 static JSValueRef rowIndexRangeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
116 {
117     JSRetainPtr<JSStringRef> rowIndexRange(Adopt, toAXElement(thisObject)->rowIndexRange());
118     return JSValueMakeString(context, rowIndexRange.get());
119 }
120
121 static JSValueRef columnIndexRangeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
122 {
123     JSRetainPtr<JSStringRef> columnIndexRange(Adopt, toAXElement(thisObject)->columnIndexRange());
124     return JSValueMakeString(context, columnIndexRange.get());
125 }
126
127 static JSValueRef lineForIndexCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
128 {
129     int indexNumber = -1;
130     if (argumentCount == 1)
131         indexNumber = JSValueToNumber(context, arguments[0], exception);
132     
133     return JSValueMakeNumber(context, toAXElement(thisObject)->lineForIndex(indexNumber));
134 }
135
136 static JSValueRef rangeForLineCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
137 {
138     int indexNumber = -1;
139     if (argumentCount == 1)
140         indexNumber = JSValueToNumber(context, arguments[0], exception);
141     
142     JSRetainPtr<JSStringRef> rangeLine(Adopt, toAXElement(thisObject)->rangeForLine(indexNumber));
143     return JSValueMakeString(context, rangeLine.get());
144 }
145
146 static JSValueRef boundsForRangeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
147 {
148     unsigned location = UINT_MAX, length = 0;
149     if (argumentCount == 2) {
150         location = JSValueToNumber(context, arguments[0], exception);
151         length = JSValueToNumber(context, arguments[1], exception);
152     }
153
154     JSRetainPtr<JSStringRef> boundsDescription(Adopt, toAXElement(thisObject)->boundsForRange(location, length));
155     return JSValueMakeString(context, boundsDescription.get());    
156 }
157
158 static JSValueRef rangeForPositionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
159 {
160     int x = 0, y = 0;
161     if (argumentCount == 2) {
162         x = JSValueToNumber(context, arguments[0], exception);
163         y = JSValueToNumber(context, arguments[1], exception);
164     }
165     
166     JSRetainPtr<JSStringRef> rangeDescription(Adopt, toAXElement(thisObject)->rangeForPosition(x, y));
167     return JSValueMakeString(context, rangeDescription.get());    
168 }
169
170 static JSValueRef stringForRangeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
171 {
172     unsigned location = UINT_MAX, length = 0;
173     if (argumentCount == 2) {
174         location = JSValueToNumber(context, arguments[0], exception);
175         length = JSValueToNumber(context, arguments[1], exception);
176     }
177     
178     JSRetainPtr<JSStringRef> stringDescription(Adopt, toAXElement(thisObject)->stringForRange(location, length));
179     return JSValueMakeString(context, stringDescription.get());    
180 }
181
182 static JSValueRef attributedStringForRangeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
183 {
184     unsigned location = UINT_MAX, length = 0;
185     if (argumentCount == 2) {
186         location = JSValueToNumber(context, arguments[0], exception);
187         length = JSValueToNumber(context, arguments[1], exception);
188     }
189     
190     JSRetainPtr<JSStringRef> stringDescription(Adopt, toAXElement(thisObject)->attributedStringForRange(location, length));
191     return JSValueMakeString(context, stringDescription.get());    
192 }
193
194 static JSValueRef attributedStringRangeIsMisspelledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
195 {
196     unsigned location = UINT_MAX, length = 0;
197     if (argumentCount == 2) {
198         location = JSValueToNumber(context, arguments[0], exception);
199         length = JSValueToNumber(context, arguments[1], exception);
200     }
201     
202     return JSValueMakeBoolean(context, toAXElement(thisObject)->attributedStringRangeIsMisspelled(location, length));
203 }
204
205 static JSValueRef uiElementForSearchPredicateCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
206 {
207     AccessibilityUIElement* startElement = 0;
208     bool isDirectionNext = true;
209     bool visibleOnly = false;
210     JSValueRef searchKey = 0;
211     JSStringRef searchText = 0;
212     if (argumentCount == 5) {
213         JSObjectRef startElementObject = JSValueToObject(context, arguments[0], exception);
214         if (startElementObject)
215             startElement = toAXElement(startElementObject);
216         isDirectionNext = JSValueToBoolean(context, arguments[1]);      
217         
218         searchKey = arguments[2];
219         
220         if (JSValueIsString(context, arguments[3]))
221             searchText = JSValueToStringCopy(context, arguments[3], exception);
222         
223         visibleOnly = JSValueToBoolean(context, arguments[4]);
224     }
225     JSObjectRef resultObject = AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->uiElementForSearchPredicate(context, startElement, isDirectionNext, searchKey, searchText, visibleOnly));
226
227     if (searchText)
228         JSStringRelease(searchText);
229     
230     return resultObject;
231 }
232
233 static JSValueRef indexOfChildCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
234 {
235     if (argumentCount != 1)
236         return 0;
237     
238     JSObjectRef otherElement = JSValueToObject(context, arguments[0], exception);
239     AccessibilityUIElement* childElement = toAXElement(otherElement);
240     return JSValueMakeNumber(context, (double)toAXElement(thisObject)->indexOfChild(childElement));
241 }
242
243 #if PLATFORM(IOS)
244
245 static JSValueRef headerElementAtIndexCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
246 {
247     if (argumentCount != 1)
248         return 0;
249     
250     unsigned index = JSValueToNumber(context, arguments[0], exception);
251     return AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->headerElementAtIndex(index));
252 }
253
254 static JSValueRef linkedElementCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
255 {
256     return AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->linkedElement());
257 }
258
259 static JSValueRef elementsForRangeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
260 {
261     if (argumentCount != 2)
262         return 0;
263     
264     unsigned location = JSValueToNumber(context, arguments[0], exception);
265     unsigned length = JSValueToNumber(context, arguments[1], exception);
266     
267     Vector<AccessibilityUIElement> elements;
268     toAXElement(thisObject)->elementsForRange(location, length, elements);
269     
270     unsigned elementsSize = elements.size();
271     JSValueRef valueElements[elementsSize];
272     for (unsigned k = 0; k < elementsSize; ++k)
273         valueElements[k] = AccessibilityUIElement::makeJSAccessibilityUIElement(context, elements[k]);
274     
275     return JSObjectMakeArray(context, elementsSize, valueElements, 0);
276 }
277
278 static JSValueRef increaseTextSelectionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
279 {
280     toAXElement(thisObject)->increaseTextSelection();
281     return JSValueMakeUndefined(context);
282 }
283
284 static JSValueRef decreaseTextSelectionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
285 {
286     toAXElement(thisObject)->decreaseTextSelection();
287     return JSValueMakeUndefined(context);
288 }
289
290 static JSValueRef assistiveTechnologySimulatedFocusCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
291 {
292     toAXElement(thisObject)->assistiveTechnologySimulatedFocus();
293     return JSValueMakeUndefined(context);
294 }
295
296 #endif
297
298 static JSValueRef childAtIndexCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
299 {
300     int indexNumber = -1;
301     if (argumentCount == 1)
302         indexNumber = JSValueToNumber(context, arguments[0], exception);
303     
304     return AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->getChildAtIndex(indexNumber));
305 }
306
307 static JSValueRef selectedChildAtIndexCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
308 {
309     int indexNumber = -1;
310     if (argumentCount == 1)
311         indexNumber = JSValueToNumber(context, arguments[0], exception);
312     
313     return AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->selectedChildAtIndex(indexNumber));
314 }
315
316 static JSValueRef linkedUIElementAtIndexCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
317 {
318     int indexNumber = -1;
319     if (argumentCount == 1)
320         indexNumber = JSValueToNumber(context, arguments[0], exception);
321     
322     return AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->linkedUIElementAtIndex(indexNumber));
323 }
324
325 static JSValueRef disclosedRowAtIndexCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
326 {
327     int indexNumber = 0;
328     if (argumentCount == 1)
329         indexNumber = JSValueToNumber(context, arguments[0], exception);
330     
331     return AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->disclosedRowAtIndex(indexNumber));
332 }
333
334 static JSValueRef ariaOwnsElementAtIndexCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
335 {
336     int indexNumber = 0;
337     if (argumentCount == 1)
338         indexNumber = JSValueToNumber(context, arguments[0], exception);
339     
340     return AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->ariaOwnsElementAtIndex(indexNumber));
341 }
342
343 static JSValueRef ariaFlowToElementAtIndexCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
344 {
345     int indexNumber = 0;
346     if (argumentCount == 1)
347         indexNumber = JSValueToNumber(context, arguments[0], exception);
348     
349     return AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->ariaFlowToElementAtIndex(indexNumber));
350 }
351
352 static JSValueRef selectedRowAtIndexCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
353 {
354     int indexNumber = 0;
355     if (argumentCount == 1)
356         indexNumber = JSValueToNumber(context, arguments[0], exception);
357     
358     return AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->selectedRowAtIndex(indexNumber));
359 }
360
361 static JSValueRef rowAtIndexCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
362 {
363     int indexNumber = 0;
364     if (argumentCount == 1)
365         indexNumber = JSValueToNumber(context, arguments[0], exception);
366     
367     return AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->rowAtIndex(indexNumber));
368 }
369
370 static JSValueRef isEqualCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
371 {
372     JSObjectRef otherElement = 0;
373     if (argumentCount == 1)
374         otherElement = JSValueToObject(context, arguments[0], exception);
375     else
376         return JSValueMakeBoolean(context, false);
377     
378     return JSValueMakeBoolean(context, toAXElement(thisObject)->isEqual(toAXElement(otherElement)));
379 }
380
381 static JSValueRef setSelectedChildCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
382 {
383     JSObjectRef element = 0;
384     if (argumentCount == 1)
385         element = JSValueToObject(context, arguments[0], exception);
386
387     toAXElement(thisObject)->setSelectedChild(toAXElement(element));
388
389     return JSValueMakeUndefined(context);
390 }
391
392 static JSValueRef elementAtPointCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
393 {
394     int x = 0;
395     int y = 0;
396     if (argumentCount == 2) {
397         x = JSValueToNumber(context, arguments[0], exception);
398         y = JSValueToNumber(context, arguments[1], exception);
399     }
400     
401     return AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->elementAtPoint(x, y));
402 }
403
404 static JSValueRef isAttributeSupportedCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
405 {
406     JSStringRef attribute = 0;
407     if (argumentCount == 1)
408         attribute = JSValueToStringCopy(context, arguments[0], exception);    
409     JSValueRef result = JSValueMakeBoolean(context, toAXElement(thisObject)->isAttributeSupported(attribute));
410     if (attribute)
411         JSStringRelease(attribute);
412     return result;
413 }
414
415 static JSValueRef isAttributeSettableCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
416 {
417     JSStringRef attribute = 0;
418     if (argumentCount == 1)
419         attribute = JSValueToStringCopy(context, arguments[0], exception);    
420     JSValueRef result = JSValueMakeBoolean(context, toAXElement(thisObject)->isAttributeSettable(attribute));
421     if (attribute)
422         JSStringRelease(attribute);
423     return result;
424 }
425
426 static JSValueRef isPressActionSupportedCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
427 {
428     return JSValueMakeBoolean(context, toAXElement(thisObject)->isPressActionSupported());
429 }
430
431 static JSValueRef isIncrementActionSupportedCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
432 {
433     return JSValueMakeBoolean(context, toAXElement(thisObject)->isIncrementActionSupported());
434 }
435
436 static JSValueRef isDecrementActionSupportedCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
437 {
438     return JSValueMakeBoolean(context, toAXElement(thisObject)->isDecrementActionSupported());
439 }
440
441 static JSValueRef boolAttributeValueCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
442 {
443     JSStringRef attribute = 0;
444     if (argumentCount == 1)
445         attribute = JSValueToStringCopy(context, arguments[0], exception);
446     bool val = toAXElement(thisObject)->boolAttributeValue(attribute);
447     JSValueRef result = JSValueMakeBoolean(context, val);
448     if (attribute)
449         JSStringRelease(attribute);
450     return result;
451 }
452
453 static JSValueRef stringAttributeValueCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
454 {
455     JSStringRef attribute = 0;
456     if (argumentCount == 1)
457         attribute = JSValueToStringCopy(context, arguments[0], exception);
458     JSRetainPtr<JSStringRef> stringAttributeValue(Adopt, toAXElement(thisObject)->stringAttributeValue(attribute));
459     JSValueRef result = JSValueMakeString(context, stringAttributeValue.get());
460     if (attribute)
461         JSStringRelease(attribute);
462     return result;
463 }
464
465 static JSValueRef uiElementAttributeValueCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
466 {
467     JSRetainPtr<JSStringRef> attribute;
468     if (argumentCount == 1)
469         attribute.adopt(JSValueToStringCopy(context, arguments[0], exception));
470     
471     return AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->uiElementAttributeValue(attribute.get()));
472 }
473
474 static JSValueRef numberAttributeValueCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
475 {
476     JSStringRef attribute = 0;
477     if (argumentCount == 1)
478         attribute = JSValueToStringCopy(context, arguments[0], exception);
479     double val = toAXElement(thisObject)->numberAttributeValue(attribute);
480     JSValueRef result = JSValueMakeNumber(context, val);
481     if (attribute)
482         JSStringRelease(attribute);
483     return result;
484 }
485
486 static JSValueRef cellForColumnAndRowCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
487 {
488     unsigned column = 0, row = 0;
489     if (argumentCount == 2) {
490         column = JSValueToNumber(context, arguments[0], exception);
491         row = JSValueToNumber(context, arguments[1], exception);
492     }
493     
494     return AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->cellForColumnAndRow(column, row));
495 }
496
497 static JSValueRef titleUIElementCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
498 {
499     return AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->titleUIElement());
500 }
501
502 static JSValueRef parentElementCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
503 {
504     return AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->parentElement());
505 }
506
507 static JSValueRef disclosedByRowCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
508 {
509     return AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->disclosedByRow());
510 }
511
512 static JSValueRef setSelectedTextRangeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
513 {
514     unsigned location = UINT_MAX, length = 0;
515     if (argumentCount == 2) {
516         location = JSValueToNumber(context, arguments[0], exception);
517         length = JSValueToNumber(context, arguments[1], exception);
518     }
519     
520     toAXElement(thisObject)->setSelectedTextRange(location, length);
521     return JSValueMakeUndefined(context);
522 }
523
524 static JSValueRef incrementCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
525 {
526     toAXElement(thisObject)->increment();
527     return JSValueMakeUndefined(context);
528 }
529
530 static JSValueRef decrementCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
531 {
532     toAXElement(thisObject)->decrement();
533     return JSValueMakeUndefined(context);
534 }
535
536 static JSValueRef showMenuCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
537 {
538     toAXElement(thisObject)->showMenu();
539     return JSValueMakeUndefined(context);
540 }
541
542 static JSValueRef pressCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
543 {
544     toAXElement(thisObject)->press();
545     return JSValueMakeUndefined(context);
546 }
547
548 static JSValueRef scrollToMakeVisibleCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
549 {
550     toAXElement(thisObject)->scrollToMakeVisible();
551     return JSValueMakeUndefined(context);
552 }
553
554 static JSValueRef takeFocusCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
555 {
556     toAXElement(thisObject)->takeFocus();
557     return JSValueMakeUndefined(context);
558 }
559
560 static JSValueRef takeSelectionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
561 {
562     toAXElement(thisObject)->takeSelection();
563     return JSValueMakeUndefined(context);
564 }
565
566 static JSValueRef addSelectionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
567 {
568     toAXElement(thisObject)->addSelection();
569     return JSValueMakeUndefined(context);
570 }
571
572 static JSValueRef removeSelectionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
573 {
574     toAXElement(thisObject)->removeSelection();
575     return JSValueMakeUndefined(context);
576 }
577
578 static JSValueRef textMarkerRangeForElementCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
579 {
580     AccessibilityUIElement* uiElement = 0;
581     if (argumentCount == 1)
582         uiElement = toAXElement(JSValueToObject(context, arguments[0], exception));
583     
584     return AccessibilityTextMarkerRange::makeJSAccessibilityTextMarkerRange(context, toAXElement(thisObject)->textMarkerRangeForElement(uiElement));
585 }
586
587 static JSValueRef attributedStringForTextMarkerRangeContainsAttributeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
588 {
589     AccessibilityTextMarkerRange* markerRange = 0;
590     JSStringRef attribute = 0;
591     if (argumentCount == 2) {
592         attribute = JSValueToStringCopy(context, arguments[0], exception);
593         markerRange = toTextMarkerRange(JSValueToObject(context, arguments[1], exception));
594     }
595     
596     JSValueRef result = JSValueMakeBoolean(context, toAXElement(thisObject)->attributedStringForTextMarkerRangeContainsAttribute(attribute, markerRange));
597     if (attribute)
598         JSStringRelease(attribute);
599     
600     return result;    
601 }
602
603 static JSValueRef indexForTextMarkerCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
604 {
605     AccessibilityTextMarker* marker = 0;
606     if (argumentCount == 1)
607         marker = toTextMarker(JSValueToObject(context, arguments[0], exception));
608     
609     return JSValueMakeNumber(context, toAXElement(thisObject)->indexForTextMarker(marker));
610 }
611
612 static JSValueRef isTextMarkerValidCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
613 {
614     AccessibilityTextMarker* marker = 0;
615     if (argumentCount == 1)
616         marker = toTextMarker(JSValueToObject(context, arguments[0], exception));
617     
618     return JSValueMakeBoolean(context, toAXElement(thisObject)->isTextMarkerValid(marker));
619 }
620
621 static JSValueRef textMarkerForIndexCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
622 {
623     int textIndex = 0;
624     if (argumentCount == 1)
625         textIndex = JSValueToNumber(context, arguments[0], exception);
626     
627     return AccessibilityTextMarker::makeJSAccessibilityTextMarker(context, toAXElement(thisObject)->textMarkerForIndex(textIndex));
628 }
629
630 static JSValueRef textMarkerRangeLengthCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
631 {
632     AccessibilityTextMarkerRange* range = 0;
633     if (argumentCount == 1)
634         range = toTextMarkerRange(JSValueToObject(context, arguments[0], exception));
635     
636     return JSValueMakeNumber(context, (int)toAXElement(thisObject)->textMarkerRangeLength(range));
637 }
638
639 static JSValueRef nextTextMarkerCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
640 {
641     AccessibilityTextMarker* marker = 0;
642     if (argumentCount == 1)
643         marker = toTextMarker(JSValueToObject(context, arguments[0], exception));
644     
645     return AccessibilityTextMarker::makeJSAccessibilityTextMarker(context, toAXElement(thisObject)->nextTextMarker(marker));
646 }
647
648 static JSValueRef previousTextMarkerCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
649 {
650     AccessibilityTextMarker* marker = 0;
651     if (argumentCount == 1)
652         marker = toTextMarker(JSValueToObject(context, arguments[0], exception));
653     
654     return AccessibilityTextMarker::makeJSAccessibilityTextMarker(context, toAXElement(thisObject)->previousTextMarker(marker));
655 }
656
657 static JSValueRef stringForTextMarkerRangeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
658 {
659     AccessibilityTextMarkerRange* markerRange = 0;
660     if (argumentCount == 1)
661         markerRange = toTextMarkerRange(JSValueToObject(context, arguments[0], exception));
662     
663     JSRetainPtr<JSStringRef> markerRangeString(Adopt, toAXElement(thisObject)->stringForTextMarkerRange(markerRange));
664     return JSValueMakeString(context, markerRangeString.get());    
665 }
666
667 static JSValueRef textMarkerForPointCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
668 {
669     int x = 0;
670     int y = 0;
671     if (argumentCount == 2) {
672         x = JSValueToNumber(context, arguments[0], exception);
673         y = JSValueToNumber(context, arguments[1], exception);
674     }
675     
676     return AccessibilityTextMarker::makeJSAccessibilityTextMarker(context, toAXElement(thisObject)->textMarkerForPoint(x, y));
677 }
678
679 static JSValueRef textMarkerRangeForMarkersCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
680 {
681     AccessibilityTextMarker* startMarker = 0;
682     AccessibilityTextMarker* endMarker = 0;
683     if (argumentCount == 2) {
684         startMarker = toTextMarker(JSValueToObject(context, arguments[0], exception));
685         endMarker = toTextMarker(JSValueToObject(context, arguments[1], exception));
686     }
687     
688     return AccessibilityTextMarkerRange::makeJSAccessibilityTextMarkerRange(context, toAXElement(thisObject)->textMarkerRangeForMarkers(startMarker, endMarker));
689 }
690
691 static JSValueRef startTextMarkerForTextMarkerRangeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
692 {
693     AccessibilityTextMarkerRange* markerRange = 0;
694     if (argumentCount == 1)
695         markerRange = toTextMarkerRange(JSValueToObject(context, arguments[0], exception));
696     
697     return AccessibilityTextMarker::makeJSAccessibilityTextMarker(context, toAXElement(thisObject)->startTextMarkerForTextMarkerRange(markerRange));
698 }
699
700 static JSValueRef endTextMarkerForTextMarkerRangeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
701 {
702     AccessibilityTextMarkerRange* markerRange = 0;
703     if (argumentCount == 1)
704         markerRange = toTextMarkerRange(JSValueToObject(context, arguments[0], exception));
705     
706     return AccessibilityTextMarker::makeJSAccessibilityTextMarker(context, toAXElement(thisObject)->endTextMarkerForTextMarkerRange(markerRange));
707 }
708
709 static JSValueRef accessibilityElementForTextMarkerCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
710 {
711     AccessibilityTextMarker* marker = 0;
712     if (argumentCount == 1)
713         marker = toTextMarker(JSValueToObject(context, arguments[0], exception));
714     
715     return AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->accessibilityElementForTextMarker(marker));
716 }
717
718 // Static Value Getters
719
720 static JSValueRef getARIADropEffectsCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
721 {
722     JSRetainPtr<JSStringRef> dropEffects(Adopt, toAXElement(thisObject)->ariaDropEffects());
723     return JSValueMakeString(context, dropEffects.get());
724 }
725
726 static JSValueRef getARIAIsGrabbedCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
727 {
728     return JSValueMakeBoolean(context, toAXElement(thisObject)->ariaIsGrabbed());
729 }
730
731 static JSValueRef getIsValidCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
732 {
733     AccessibilityUIElement* uiElement = toAXElement(thisObject);
734     if (!uiElement->platformUIElement())
735         return JSValueMakeBoolean(context, false);
736     
737     // There might be other platform logic that one could check here...
738     
739     return JSValueMakeBoolean(context, true);
740 }
741
742 static JSValueRef getRoleCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
743 {
744     JSRetainPtr<JSStringRef> role(Adopt, toAXElement(thisObject)->role());
745     return JSValueMakeString(context, role.get());
746 }
747
748 static JSValueRef getSubroleCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
749 {
750     JSRetainPtr<JSStringRef> role(Adopt, toAXElement(thisObject)->subrole());
751     return JSValueMakeString(context, role.get());
752 }
753
754 static JSValueRef getRoleDescriptionCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
755 {
756     JSRetainPtr<JSStringRef> roleDesc(Adopt, toAXElement(thisObject)->roleDescription());
757     return JSValueMakeString(context, roleDesc.get());
758 }
759
760 static JSValueRef getTitleCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
761 {
762     JSRetainPtr<JSStringRef> title(Adopt, toAXElement(thisObject)->title());
763     return JSValueMakeString(context, title.get());
764 }
765
766 static JSValueRef getDescriptionCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
767 {
768     JSRetainPtr<JSStringRef> description(Adopt, toAXElement(thisObject)->description());
769     return JSValueMakeString(context, description.get());
770 }
771
772 static JSValueRef getStringValueCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
773 {
774     JSRetainPtr<JSStringRef> stringValue(Adopt, toAXElement(thisObject)->stringValue());
775     return JSValueMakeString(context, stringValue.get());
776 }
777
778 static JSValueRef getLanguageCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
779 {
780     JSRetainPtr<JSStringRef> language(Adopt, toAXElement(thisObject)->language());
781     return JSValueMakeString(context, language.get());
782 }
783
784 static JSValueRef getHelpTextCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
785 {
786     JSRetainPtr<JSStringRef> language(Adopt, toAXElement(thisObject)->helpText());
787     return JSValueMakeString(context, language.get());
788 }
789
790 static JSValueRef getOrientationCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
791 {
792     JSRetainPtr<JSStringRef> orientation(Adopt, toAXElement(thisObject)->orientation());
793     return JSValueMakeString(context, orientation.get());
794 }
795
796 static JSValueRef getChildrenCountCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
797 {
798     return JSValueMakeNumber(context, toAXElement(thisObject)->childrenCount());
799 }
800
801 static JSValueRef rowCountCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
802 {
803     return JSValueMakeNumber(context, toAXElement(thisObject)->rowCount());
804 }
805
806 static JSValueRef columnCountCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
807 {
808     return JSValueMakeNumber(context, toAXElement(thisObject)->columnCount());
809 }
810
811 static JSValueRef getXCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
812 {
813     return JSValueMakeNumber(context, toAXElement(thisObject)->x());
814 }
815
816 static JSValueRef getYCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
817 {
818     return JSValueMakeNumber(context, toAXElement(thisObject)->y());
819 }
820
821 static JSValueRef getWidthCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
822 {
823     return JSValueMakeNumber(context, toAXElement(thisObject)->width());
824 }
825
826 static JSValueRef getHeightCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
827 {
828     return JSValueMakeNumber(context, toAXElement(thisObject)->height());
829 }
830
831 static JSValueRef getClickPointXCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
832 {
833     return JSValueMakeNumber(context, toAXElement(thisObject)->clickPointX());
834 }
835
836 static JSValueRef getClickPointYCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
837 {
838     return JSValueMakeNumber(context, toAXElement(thisObject)->clickPointY());
839 }
840
841 static JSValueRef getIntValueCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
842 {
843     return JSValueMakeNumber(context, toAXElement(thisObject)->intValue());
844 }
845
846 static JSValueRef getMinValueCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
847 {
848     return JSValueMakeNumber(context, toAXElement(thisObject)->minValue());
849 }
850
851 static JSValueRef getMaxValueCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
852 {
853     return JSValueMakeNumber(context, toAXElement(thisObject)->maxValue());
854 }
855
856 static JSValueRef getInsertionPointLineNumberCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
857 {
858     return JSValueMakeNumber(context, toAXElement(thisObject)->insertionPointLineNumber());
859 }
860
861 static JSValueRef getPathDescriptionCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
862 {
863     JSRetainPtr<JSStringRef> pathDescription(Adopt, toAXElement(thisObject)->pathDescription());
864     return JSValueMakeString(context, pathDescription.get());
865 }
866
867 static JSValueRef getSelectedTextRangeCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
868 {
869     JSRetainPtr<JSStringRef> selectedTextRange(Adopt, toAXElement(thisObject)->selectedTextRange());
870     return JSValueMakeString(context, selectedTextRange.get());
871 }
872
873 static JSValueRef getIsEnabledCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
874 {
875     return JSValueMakeBoolean(context, toAXElement(thisObject)->isEnabled());
876 }
877
878 static JSValueRef getIsRequiredCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef*)
879 {
880     return JSValueMakeBoolean(context, toAXElement(thisObject)->isRequired());
881 }
882
883 static JSValueRef getIsFocusedCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef*)
884 {
885     return JSValueMakeBoolean(context, toAXElement(thisObject)->isFocused());
886 }
887
888 static JSValueRef getIsFocusableCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef*)
889 {
890     return JSValueMakeBoolean(context, toAXElement(thisObject)->isFocusable());
891 }
892
893 static JSValueRef getIsSelectedCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef*)
894 {
895     return JSValueMakeBoolean(context, toAXElement(thisObject)->isSelected());
896 }
897
898 static JSValueRef getIsSelectableCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef*)
899 {
900     return JSValueMakeBoolean(context, toAXElement(thisObject)->isSelectable());
901 }
902
903 static JSValueRef getIsMultiSelectableCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef*)
904 {
905     return JSValueMakeBoolean(context, toAXElement(thisObject)->isMultiSelectable());
906 }
907
908 static JSValueRef getIsSelectedOptionActiveCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef*)
909 {
910     return JSValueMakeBoolean(context, toAXElement(thisObject)->isSelectedOptionActive());
911 }
912
913 static JSValueRef getIsExpandedCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef*)
914 {
915     return JSValueMakeBoolean(context, toAXElement(thisObject)->isExpanded());
916 }
917
918 static JSValueRef getIsCheckedCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef*)
919 {
920     return JSValueMakeBoolean(context, toAXElement(thisObject)->isChecked());
921 }
922
923 static JSValueRef getIsVisibleCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef*)
924 {
925     return JSValueMakeBoolean(context, toAXElement(thisObject)->isVisible());
926 }
927
928 static JSValueRef getIsOffScreenCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef*)
929 {
930     return JSValueMakeBoolean(context, toAXElement(thisObject)->isOffScreen());
931 }
932
933 static JSValueRef getIsCollapsedCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef*)
934 {
935     return JSValueMakeBoolean(context, toAXElement(thisObject)->isCollapsed());
936 }
937
938 static JSValueRef isIgnoredCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef*)
939 {
940     return JSValueMakeBoolean(context, toAXElement(thisObject)->isIgnored());
941 }
942
943 static JSValueRef speakCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef*)
944 {
945     JSRetainPtr<JSStringRef> speakString(Adopt, toAXElement(thisObject)->speak());
946     return JSValueMakeString(context, speakString.get());
947 }
948
949 static JSValueRef selectedChildrenCountCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
950 {
951     return JSValueMakeNumber(context, toAXElement(thisObject)->selectedChildrenCount());
952 }
953
954 static JSValueRef horizontalScrollbarCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
955 {
956     return AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->horizontalScrollbar());
957 }
958
959 static JSValueRef verticalScrollbarCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
960 {
961     return AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->verticalScrollbar());
962 }
963
964 static JSValueRef getHasPopupCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef*)
965 {
966     return JSValueMakeBoolean(context, toAXElement(thisObject)->hasPopup());
967 }
968
969 static JSValueRef hierarchicalLevelCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef*)
970 {
971     return JSValueMakeNumber(context, toAXElement(thisObject)->hierarchicalLevel());
972 }
973
974 static JSValueRef getValueDescriptionCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
975 {
976     JSRetainPtr<JSStringRef> valueDescription(Adopt, toAXElement(thisObject)->valueDescription());
977     return JSValueMakeString(context, valueDescription.get());
978 }
979
980 static JSValueRef getAccessibilityValueCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
981 {
982     JSRetainPtr<JSStringRef> accessibilityValue(Adopt, toAXElement(thisObject)->accessibilityValue());
983     return JSValueMakeString(context, accessibilityValue.get());
984 }
985
986 static JSValueRef getDocumentEncodingCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
987 {
988     JSRetainPtr<JSStringRef> documentEncoding(Adopt, toAXElement(thisObject)->documentEncoding());
989     return JSValueMakeString(context, documentEncoding.get());
990 }
991
992 static JSValueRef getDocumentURICallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
993 {
994     JSRetainPtr<JSStringRef> documentURI(Adopt, toAXElement(thisObject)->documentURI());
995     return JSValueMakeString(context, documentURI.get());
996 }
997
998 static JSValueRef getURLCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
999 {
1000     JSRetainPtr<JSStringRef> url(Adopt, toAXElement(thisObject)->url());
1001     return JSValueMakeString(context, url.get());
1002 }
1003
1004 static JSValueRef addNotificationListenerCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1005 {
1006     if (argumentCount != 1)
1007         return JSValueMakeBoolean(context, false);
1008     
1009     JSObjectRef callback = JSValueToObject(context, arguments[0], exception);
1010     bool succeeded = toAXElement(thisObject)->addNotificationListener(callback);
1011     return JSValueMakeBoolean(context, succeeded);
1012 }
1013
1014 static JSValueRef removeNotificationListenerCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
1015 {
1016     toAXElement(thisObject)->removeNotificationListener();
1017     return JSValueMakeUndefined(context);
1018 }
1019
1020 #if PLATFORM(IOS)
1021
1022 static JSValueRef stringForSelectionCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
1023 {
1024     JSRetainPtr<JSStringRef> labelString(Adopt, toAXElement(thisObject)->stringForSelection());
1025     return JSValueMakeString(context, labelString.get());
1026 }
1027
1028 static JSValueRef getIPhoneLabelCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
1029 {
1030     JSRetainPtr<JSStringRef> labelString(Adopt, toAXElement(thisObject)->iphoneLabel());
1031     return JSValueMakeString(context, labelString.get());
1032 }
1033
1034 static JSValueRef getIPhoneHintCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
1035 {
1036     JSRetainPtr<JSStringRef> hintString(Adopt, toAXElement(thisObject)->iphoneHint());
1037     return JSValueMakeString(context, hintString.get());
1038 }
1039
1040 static JSValueRef getIPhoneValueCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
1041 {
1042     JSRetainPtr<JSStringRef> valueString(Adopt, toAXElement(thisObject)->iphoneValue());
1043     return JSValueMakeString(context, valueString.get());
1044 }
1045
1046 static JSValueRef getIPhoneIdentifierCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
1047 {
1048     JSRetainPtr<JSStringRef> valueString(Adopt, toAXElement(thisObject)->iphoneIdentifier());
1049     return JSValueMakeString(context, valueString.get());
1050 }
1051
1052
1053 static JSValueRef getIPhoneTraitsCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
1054 {
1055     JSRetainPtr<JSStringRef> valueString(Adopt, toAXElement(thisObject)->iphoneTraits());
1056     return JSValueMakeString(context, valueString.get());
1057 }
1058
1059 static JSValueRef getIPhoneIsElementCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
1060 {
1061     return JSValueMakeBoolean(context, toAXElement(thisObject)->iphoneIsElement());
1062 }
1063
1064 static JSValueRef getIPhoneElementTextPositionCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
1065 {
1066     return JSValueMakeNumber(context, toAXElement(thisObject)->iphoneElementTextPosition());
1067 }
1068
1069 static JSValueRef getIPhoneElementTextLengthCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
1070 {
1071     return JSValueMakeNumber(context, toAXElement(thisObject)->iphoneElementTextLength());
1072 }
1073
1074 #endif // PLATFORM(IOS)
1075
1076 #if PLATFORM(MAC) && !PLATFORM(IOS)
1077 static JSValueRef supportedActionsCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
1078 {
1079     JSRetainPtr<JSStringRef> valueString(Adopt, toAXElement(thisObject)->supportedActions());
1080     return JSValueMakeString(context, valueString.get());
1081 }
1082
1083 static JSValueRef mathPostscriptsDescriptionCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
1084 {
1085     JSRetainPtr<JSStringRef> valueString(Adopt, toAXElement(thisObject)->mathPostscriptsDescription());
1086     return JSValueMakeString(context, valueString.get());
1087 }
1088
1089 static JSValueRef mathPrescriptsDescriptionCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
1090 {
1091     JSRetainPtr<JSStringRef> valueString(Adopt, toAXElement(thisObject)->mathPrescriptsDescription());
1092     return JSValueMakeString(context, valueString.get());
1093 }
1094
1095 #endif
1096
1097 // Implementation
1098
1099 // Unsupported methods on various platforms.
1100 #if !PLATFORM(MAC) || PLATFORM(IOS)
1101 JSStringRef AccessibilityUIElement::speak() { return 0; }
1102 JSStringRef AccessibilityUIElement::rangeForLine(int line) { return 0; }
1103 JSStringRef AccessibilityUIElement::rangeForPosition(int, int) { return 0; }
1104 void AccessibilityUIElement::setSelectedChild(AccessibilityUIElement*) const { }
1105 unsigned AccessibilityUIElement::selectedChildrenCount() const { return 0; }
1106 AccessibilityUIElement AccessibilityUIElement::selectedChildAtIndex(unsigned) const { return 0; }
1107 AccessibilityUIElement AccessibilityUIElement::horizontalScrollbar() const { return 0; }
1108 AccessibilityUIElement AccessibilityUIElement::verticalScrollbar() const { return 0; }
1109 AccessibilityUIElement AccessibilityUIElement::uiElementAttributeValue(JSStringRef) const { return 0; }
1110 #endif
1111
1112 #if !PLATFORM(MAC) && !PLATFORM(IOS)
1113 JSStringRef AccessibilityUIElement::pathDescription() const { return 0; }
1114 #endif
1115
1116 #if !PLATFORM(WIN)
1117 bool AccessibilityUIElement::isEqual(AccessibilityUIElement* otherElement)
1118 {
1119     if (!otherElement)
1120         return false;
1121     return platformUIElement() == otherElement->platformUIElement();
1122 }
1123 #endif
1124
1125 #if !SUPPORTS_AX_TEXTMARKERS
1126
1127 AccessibilityTextMarkerRange AccessibilityUIElement::textMarkerRangeForElement(AccessibilityUIElement*)
1128 {
1129     return 0;
1130 }
1131
1132 int AccessibilityUIElement::textMarkerRangeLength(AccessibilityTextMarkerRange*)
1133 {
1134     return 0;
1135 }
1136
1137 AccessibilityTextMarkerRange AccessibilityUIElement::textMarkerRangeForMarkers(AccessibilityTextMarker*, AccessibilityTextMarker*)
1138 {
1139     return 0;
1140 }
1141
1142 AccessibilityTextMarker AccessibilityUIElement::startTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange*)
1143 {
1144     return 0;
1145 }
1146
1147 AccessibilityTextMarker AccessibilityUIElement::endTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange*)
1148 {
1149     return 0;   
1150 }
1151
1152 AccessibilityUIElement AccessibilityUIElement::accessibilityElementForTextMarker(AccessibilityTextMarker*)
1153 {
1154     return 0;
1155 }
1156
1157 AccessibilityTextMarker AccessibilityUIElement::textMarkerForPoint(int x, int y)
1158 {
1159     return 0;
1160 }
1161
1162 AccessibilityTextMarker AccessibilityUIElement::previousTextMarker(AccessibilityTextMarker*)
1163 {
1164     return 0;    
1165 }
1166
1167 AccessibilityTextMarker AccessibilityUIElement::nextTextMarker(AccessibilityTextMarker*)
1168 {
1169     return 0;
1170 }
1171
1172 JSStringRef AccessibilityUIElement::stringForTextMarkerRange(AccessibilityTextMarkerRange*)
1173 {
1174     return 0;
1175 }
1176
1177 bool AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute(JSStringRef, AccessibilityTextMarkerRange*)
1178 {
1179     return false;
1180 }
1181
1182 int AccessibilityUIElement::indexForTextMarker(AccessibilityTextMarker*)
1183 {
1184     return -1;
1185 }
1186
1187 bool AccessibilityUIElement::isTextMarkerValid(AccessibilityTextMarker*)
1188 {
1189     return false;
1190 }
1191
1192 AccessibilityTextMarker AccessibilityUIElement::textMarkerForIndex(int)
1193 {
1194     return 0;
1195 }
1196
1197 #endif
1198
1199 // Destruction
1200
1201 static void finalize(JSObjectRef thisObject)
1202 {
1203     delete toAXElement(thisObject);
1204 }
1205
1206 // Object Creation
1207
1208 JSObjectRef AccessibilityUIElement::makeJSAccessibilityUIElement(JSContextRef context, const AccessibilityUIElement& element)
1209 {
1210     return JSObjectMake(context, AccessibilityUIElement::getJSClass(), new AccessibilityUIElement(element));
1211 }
1212
1213 JSClassRef AccessibilityUIElement::getJSClass()
1214 {
1215     static JSStaticValue staticValues[] = {
1216         { "accessibilityValue", getAccessibilityValueCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1217         { "role", getRoleCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1218         { "subrole", getSubroleCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1219         { "roleDescription", getRoleDescriptionCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1220         { "title", getTitleCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1221         { "description", getDescriptionCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1222         { "language", getLanguageCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1223         { "helpText", getHelpTextCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1224         { "stringValue", getStringValueCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1225         { "x", getXCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1226         { "y", getYCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1227         { "width", getWidthCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1228         { "height", getHeightCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1229         { "clickPointX", getClickPointXCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1230         { "clickPointY", getClickPointYCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1231         { "intValue", getIntValueCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1232         { "minValue", getMinValueCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1233         { "maxValue", getMaxValueCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1234         { "pathDescription", getPathDescriptionCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1235         { "childrenCount", getChildrenCountCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1236         { "rowCount", rowCountCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1237         { "columnCount", columnCountCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1238         { "insertionPointLineNumber", getInsertionPointLineNumberCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1239         { "selectedTextRange", getSelectedTextRangeCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1240         { "isEnabled", getIsEnabledCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1241         { "isRequired", getIsRequiredCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1242         { "isFocused", getIsFocusedCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1243         { "isFocusable", getIsFocusableCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1244         { "isSelected", getIsSelectedCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1245         { "isSelectable", getIsSelectableCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1246         { "isMultiSelectable", getIsMultiSelectableCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1247         { "isSelectedOptionActive", getIsSelectedOptionActiveCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1248         { "isExpanded", getIsExpandedCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1249         { "isChecked", getIsCheckedCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1250         { "isVisible", getIsVisibleCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1251         { "isOffScreen", getIsOffScreenCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1252         { "isCollapsed", getIsCollapsedCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1253         { "hasPopup", getHasPopupCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1254         { "valueDescription", getValueDescriptionCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1255         { "hierarchicalLevel", hierarchicalLevelCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1256         { "documentEncoding", getDocumentEncodingCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1257         { "documentURI", getDocumentURICallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1258         { "url", getURLCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1259         { "isValid", getIsValidCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1260         { "orientation", getOrientationCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1261         { "ariaIsGrabbed", getARIAIsGrabbedCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1262         { "ariaDropEffects", getARIADropEffectsCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1263         { "isIgnored", isIgnoredCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1264         { "speak", speakCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1265         { "selectedChildrenCount", selectedChildrenCountCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1266         { "horizontalScrollbar", horizontalScrollbarCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1267         { "verticalScrollbar", verticalScrollbarCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1268 #if PLATFORM(IOS)
1269         { "iphoneLabel", getIPhoneLabelCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1270         { "iphoneHint", getIPhoneHintCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1271         { "iphoneValue", getIPhoneValueCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1272         { "iphoneIdentifier", getIPhoneIdentifierCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1273         { "iphoneTraits", getIPhoneTraitsCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1274         { "iphoneIsElement", getIPhoneIsElementCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1275         { "iphoneElementTextPosition", getIPhoneElementTextPositionCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1276         { "iphoneElementTextLength", getIPhoneElementTextLengthCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1277         { "stringForSelection", stringForSelectionCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1278 #endif // PLATFORM(IOS)
1279 #if PLATFORM(MAC) && !PLATFORM(IOS)
1280         { "supportedActions", supportedActionsCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1281         { "mathPostscriptsDescription", mathPostscriptsDescriptionCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1282         { "mathPrescriptsDescription", mathPrescriptsDescriptionCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1283 #endif
1284         { 0, 0, 0, 0 }
1285     };
1286
1287     static JSStaticFunction staticFunctions[] = {
1288         { "allAttributes", allAttributesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1289         { "attributesOfLinkedUIElements", attributesOfLinkedUIElementsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1290         { "attributesOfDocumentLinks", attributesOfDocumentLinksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1291         { "attributesOfChildren", attributesOfChildrenCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1292         { "parameterizedAttributeNames", parameterizedAttributeNamesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1293         { "lineForIndex", lineForIndexCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1294         { "rangeForLine", rangeForLineCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1295         { "boundsForRange", boundsForRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1296         { "rangeForPosition", rangeForPositionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1297         { "stringForRange", stringForRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1298         { "attributedStringForRange", attributedStringForRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1299         { "attributedStringRangeIsMisspelled", attributedStringRangeIsMisspelledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1300         { "uiElementForSearchPredicate", uiElementForSearchPredicateCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1301         { "childAtIndex", childAtIndexCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1302         { "linkedUIElementAtIndex", linkedUIElementAtIndexCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1303         { "indexOfChild", indexOfChildCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1304         { "elementAtPoint", elementAtPointCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1305         { "attributesOfColumnHeaders", attributesOfColumnHeadersCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1306         { "attributesOfRowHeaders", attributesOfRowHeadersCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1307         { "attributesOfColumns", attributesOfColumnsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1308         { "attributesOfRows", attributesOfRowsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1309         { "attributesOfVisibleCells", attributesOfVisibleCellsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1310         { "attributesOfHeader", attributesOfHeaderCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1311         { "indexInTable", indexInTableCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1312         { "rowIndexRange", rowIndexRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1313         { "columnIndexRange", columnIndexRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1314         { "cellForColumnAndRow", cellForColumnAndRowCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1315         { "titleUIElement", titleUIElementCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1316         { "setSelectedTextRange", setSelectedTextRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1317         { "stringAttributeValue", stringAttributeValueCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1318         { "uiElementAttributeValue", uiElementAttributeValueCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1319         { "numberAttributeValue", numberAttributeValueCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1320         { "boolAttributeValue", boolAttributeValueCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1321         { "isAttributeSupported", isAttributeSupportedCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1322         { "isAttributeSettable", isAttributeSettableCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1323         { "isPressActionSupported", isPressActionSupportedCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1324         { "isIncrementActionSupported", isIncrementActionSupportedCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1325         { "isDecrementActionSupported", isDecrementActionSupportedCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1326         { "parentElement", parentElementCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1327         { "disclosedByRow", disclosedByRowCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1328         { "increment", incrementCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1329         { "decrement", decrementCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1330         { "showMenu", showMenuCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1331         { "press", pressCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1332         { "disclosedRowAtIndex", disclosedRowAtIndexCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1333         { "ariaOwnsElementAtIndex", ariaOwnsElementAtIndexCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1334         { "ariaFlowToElementAtIndex", ariaFlowToElementAtIndexCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1335         { "selectedRowAtIndex", selectedRowAtIndexCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1336         { "rowAtIndex", rowAtIndexCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1337         { "isEqual", isEqualCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1338         { "addNotificationListener", addNotificationListenerCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1339         { "removeNotificationListener", removeNotificationListenerCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1340         { "takeFocus", takeFocusCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1341         { "takeSelection", takeSelectionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1342         { "addSelection", addSelectionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1343         { "removeSelection", removeSelectionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1344         { "textMarkerRangeForElement", textMarkerRangeForElementCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1345         { "attributedStringForTextMarkerRangeContainsAttribute", attributedStringForTextMarkerRangeContainsAttributeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1346         { "indexForTextMarker", indexForTextMarkerCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1347         { "isTextMarkerValid", isTextMarkerValidCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1348         { "textMarkerRangeForMarkers", textMarkerRangeForMarkersCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1349         { "textMarkerForIndex", textMarkerForIndexCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1350         { "startTextMarkerForTextMarkerRange", startTextMarkerForTextMarkerRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1351         { "endTextMarkerForTextMarkerRange", endTextMarkerForTextMarkerRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1352         { "accessibilityElementForTextMarker", accessibilityElementForTextMarkerCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1353         { "textMarkerRangeLength", textMarkerRangeLengthCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1354         { "textMarkerForPoint", textMarkerForPointCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1355         { "nextTextMarker", nextTextMarkerCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1356         { "previousTextMarker", previousTextMarkerCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1357         { "stringForTextMarkerRange", stringForTextMarkerRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1358         { "setSelectedChild", setSelectedChildCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1359         { "selectedChildAtIndex", selectedChildAtIndexCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1360         { "scrollToMakeVisible", scrollToMakeVisibleCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1361 #if PLATFORM(IOS)
1362         { "linkedElement", linkedElementCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1363         { "headerElementAtIndex", headerElementAtIndexCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1364         { "elementsForRange", elementsForRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1365         { "increaseTextSelection", increaseTextSelectionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1366         { "decreaseTextSelection", decreaseTextSelectionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1367         { "assistiveTechnologySimulatedFocus", assistiveTechnologySimulatedFocusCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
1368         
1369 #endif
1370         { 0, 0, 0 }
1371     };
1372
1373     static JSClassDefinition classDefinition = {
1374         0, kJSClassAttributeNone, "AccessibilityUIElement", 0, staticValues, staticFunctions,
1375         0, finalize, 0, 0, 0, 0, 0, 0, 0, 0, 0
1376     };
1377
1378     static JSClassRef accessibilityUIElementClass = JSClassCreate(&classDefinition);
1379     return accessibilityUIElementClass;
1380 }
1381 #endif