AccessibilityUIElement.cpp 74 KB

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