AccessibilityUIElementMac.mm 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573
  1. /*
  2. * Copyright (C) 2011 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. #import "config.h"
  26. #import "AccessibilityCommonMac.h"
  27. #import "AccessibilityNotificationHandler.h"
  28. #import "AccessibilityUIElement.h"
  29. #import "InjectedBundle.h"
  30. #import "InjectedBundlePage.h"
  31. #import <AppKit/NSAccessibility.h>
  32. #import <Foundation/Foundation.h>
  33. #import <JavaScriptCore/JSRetainPtr.h>
  34. #import <JavaScriptCore/JSStringRef.h>
  35. #import <JavaScriptCore/JSStringRefCF.h>
  36. #import <JavaScriptCore/JSObjectRef.h>
  37. #import <WebKit2/WKBundleFrame.h>
  38. #import <wtf/RetainPtr.h>
  39. #import <wtf/Vector.h>
  40. #ifndef NSAccessibilityOwnsAttribute
  41. #define NSAccessibilityOwnsAttribute @"AXOwns"
  42. #endif
  43. #ifndef NSAccessibilityGrabbedAttribute
  44. #define NSAccessibilityGrabbedAttribute @"AXGrabbed"
  45. #endif
  46. #ifndef NSAccessibilityDropEffectsAttribute
  47. #define NSAccessibilityDropEffectsAttribute @"AXDropEffects"
  48. #endif
  49. #ifndef NSAccessibilityPathAttribute
  50. #define NSAccessibilityPathAttribute @"AXPath"
  51. #endif
  52. typedef void (*AXPostedNotificationCallback)(id element, NSString* notification, void* context);
  53. @interface NSObject (WebKitAccessibilityAdditions)
  54. - (NSArray *)accessibilityArrayAttributeValues:(NSString *)attribute index:(NSUInteger)index maxCount:(NSUInteger)maxCount;
  55. - (NSUInteger)accessibilityIndexOfChild:(id)child;
  56. - (NSUInteger)accessibilityArrayAttributeCount:(NSString *)attribute;
  57. @end
  58. namespace WTR {
  59. AccessibilityUIElement::AccessibilityUIElement(PlatformUIElement element)
  60. : m_element(element)
  61. , m_notificationHandler(0)
  62. {
  63. // FIXME: ap@webkit.org says ObjC objects need to be CFRetained/CFRelease to be GC-compliant on the mac.
  64. [m_element retain];
  65. }
  66. AccessibilityUIElement::AccessibilityUIElement(const AccessibilityUIElement& other)
  67. : JSWrappable()
  68. , m_element(other.m_element)
  69. , m_notificationHandler(0)
  70. {
  71. [m_element retain];
  72. }
  73. AccessibilityUIElement::~AccessibilityUIElement()
  74. {
  75. // The notification handler should be nil because removeNotificationListener() should have been called in the test.
  76. ASSERT(!m_notificationHandler);
  77. [m_element release];
  78. }
  79. bool AccessibilityUIElement::isEqual(AccessibilityUIElement* otherElement)
  80. {
  81. if (!otherElement)
  82. return false;
  83. return platformUIElement() == otherElement->platformUIElement();
  84. }
  85. static NSString* descriptionOfValue(id valueObject, id focusedAccessibilityObject)
  86. {
  87. if (!valueObject)
  88. return NULL;
  89. if ([valueObject isKindOfClass:[NSArray class]])
  90. return [NSString stringWithFormat:@"<array of size %lu>", static_cast<unsigned long>([(NSArray*)valueObject count])];
  91. if ([valueObject isKindOfClass:[NSNumber class]])
  92. return [(NSNumber*)valueObject stringValue];
  93. if ([valueObject isKindOfClass:[NSValue class]]) {
  94. NSString* type = [NSString stringWithCString:[valueObject objCType] encoding:NSASCIIStringEncoding];
  95. NSValue* value = (NSValue*)valueObject;
  96. if ([type rangeOfString:@"NSRect"].length > 0)
  97. return [NSString stringWithFormat:@"NSRect: %@", NSStringFromRect([value rectValue])];
  98. if ([type rangeOfString:@"NSPoint"].length > 0)
  99. return [NSString stringWithFormat:@"NSPoint: %@", NSStringFromPoint([value pointValue])];
  100. if ([type rangeOfString:@"NSSize"].length > 0)
  101. return [NSString stringWithFormat:@"NSSize: %@", NSStringFromSize([value sizeValue])];
  102. if ([type rangeOfString:@"NSRange"].length > 0)
  103. return [NSString stringWithFormat:@"NSRange: %@", NSStringFromRange([value rangeValue])];
  104. }
  105. // Strip absolute URL paths
  106. NSString* description = [valueObject description];
  107. NSRange range = [description rangeOfString:@"LayoutTests"];
  108. if (range.length)
  109. return [description substringFromIndex:range.location];
  110. // Strip pointer locations
  111. if ([description rangeOfString:@"0x"].length) {
  112. NSString* role = [focusedAccessibilityObject accessibilityAttributeValue:NSAccessibilityRoleAttribute];
  113. NSString* title = [focusedAccessibilityObject accessibilityAttributeValue:NSAccessibilityTitleAttribute];
  114. if ([title length])
  115. return [NSString stringWithFormat:@"<%@: '%@'>", role, title];
  116. return [NSString stringWithFormat:@"<%@>", role];
  117. }
  118. return [valueObject description];
  119. }
  120. static NSString* attributesOfElement(id accessibilityObject)
  121. {
  122. NSArray* supportedAttributes = [accessibilityObject accessibilityAttributeNames];
  123. NSMutableString* attributesString = [NSMutableString string];
  124. for (NSUInteger i = 0; i < [supportedAttributes count]; ++i) {
  125. NSString* attribute = [supportedAttributes objectAtIndex:i];
  126. // Right now, position provides useless and screen-specific information, so we do not
  127. // want to include it for the sake of universally passing tests.
  128. if ([attribute isEqualToString:@"AXPosition"])
  129. continue;
  130. // accessibilityAttributeValue: can throw an if an attribute is not returned.
  131. // For DumpRenderTree's purpose, we should ignore those exceptions
  132. BEGIN_AX_OBJC_EXCEPTIONS
  133. id valueObject = [accessibilityObject accessibilityAttributeValue:attribute];
  134. NSString* value = descriptionOfValue(valueObject, accessibilityObject);
  135. [attributesString appendFormat:@"%@: %@\n", attribute, value];
  136. END_AX_OBJC_EXCEPTIONS
  137. }
  138. return attributesString;
  139. }
  140. static JSStringRef concatenateAttributeAndValue(NSString* attribute, NSString* value)
  141. {
  142. Vector<UniChar> buffer([attribute length]);
  143. [attribute getCharacters:buffer.data()];
  144. buffer.append(':');
  145. buffer.append(' ');
  146. Vector<UniChar> valueBuffer([value length]);
  147. [value getCharacters:valueBuffer.data()];
  148. buffer.appendVector(valueBuffer);
  149. return JSStringCreateWithCharacters(buffer.data(), buffer.size());
  150. }
  151. static void convertNSArrayToVector(NSArray* array, Vector<RefPtr<AccessibilityUIElement> >& elementVector)
  152. {
  153. NSUInteger count = [array count];
  154. for (NSUInteger i = 0; i < count; ++i)
  155. elementVector.append(AccessibilityUIElement::create([array objectAtIndex:i]));
  156. }
  157. static JSStringRef descriptionOfElements(Vector<RefPtr<AccessibilityUIElement> >& elementVector)
  158. {
  159. NSMutableString* allElementString = [NSMutableString string];
  160. size_t size = elementVector.size();
  161. for (size_t i = 0; i < size; ++i) {
  162. RefPtr<AccessibilityUIElement> uiElement = elementVector[i];
  163. NSString* attributes = attributesOfElement(uiElement->platformUIElement());
  164. [allElementString appendFormat:@"%@\n------------\n", attributes];
  165. }
  166. return [allElementString createJSStringRef];
  167. }
  168. void AccessibilityUIElement::getLinkedUIElements(Vector<RefPtr<AccessibilityUIElement> >& elementVector)
  169. {
  170. BEGIN_AX_OBJC_EXCEPTIONS
  171. NSArray* linkedElements = [m_element accessibilityAttributeValue:NSAccessibilityLinkedUIElementsAttribute];
  172. convertNSArrayToVector(linkedElements, elementVector);
  173. END_AX_OBJC_EXCEPTIONS
  174. }
  175. void AccessibilityUIElement::getDocumentLinks(Vector<RefPtr<AccessibilityUIElement> >& elementVector)
  176. {
  177. BEGIN_AX_OBJC_EXCEPTIONS
  178. NSArray* linkElements = [m_element accessibilityAttributeValue:@"AXLinkUIElements"];
  179. convertNSArrayToVector(linkElements, elementVector);
  180. END_AX_OBJC_EXCEPTIONS
  181. }
  182. void AccessibilityUIElement::getChildren(Vector<RefPtr<AccessibilityUIElement> >& elementVector)
  183. {
  184. BEGIN_AX_OBJC_EXCEPTIONS
  185. NSArray* children = [m_element accessibilityAttributeValue:NSAccessibilityChildrenAttribute];
  186. convertNSArrayToVector(children, elementVector);
  187. END_AX_OBJC_EXCEPTIONS
  188. }
  189. void AccessibilityUIElement::getChildrenWithRange(Vector<RefPtr<AccessibilityUIElement> >& elementVector, unsigned location, unsigned length)
  190. {
  191. BEGIN_AX_OBJC_EXCEPTIONS
  192. NSArray* children = [m_element accessibilityArrayAttributeValues:NSAccessibilityChildrenAttribute index:location maxCount:length];
  193. convertNSArrayToVector(children, elementVector);
  194. END_AX_OBJC_EXCEPTIONS
  195. }
  196. int AccessibilityUIElement::childrenCount()
  197. {
  198. Vector<RefPtr<AccessibilityUIElement> > children;
  199. getChildren(children);
  200. return children.size();
  201. }
  202. PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::elementAtPoint(int x, int y)
  203. {
  204. id element = [m_element accessibilityHitTest:NSMakePoint(x, y)];
  205. if (!element)
  206. return nil;
  207. return AccessibilityUIElement::create(element);
  208. }
  209. unsigned AccessibilityUIElement::indexOfChild(AccessibilityUIElement* element)
  210. {
  211. return [m_element accessibilityIndexOfChild:element->platformUIElement()];
  212. }
  213. PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::childAtIndex(unsigned index)
  214. {
  215. Vector<RefPtr<AccessibilityUIElement> > children;
  216. getChildrenWithRange(children, index, 1);
  217. if (children.size() == 1)
  218. return children[0];
  219. return 0;
  220. }
  221. PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::linkedUIElementAtIndex(unsigned index)
  222. {
  223. BEGIN_AX_OBJC_EXCEPTIONS
  224. NSArray* objects = [m_element accessibilityAttributeValue:NSAccessibilityLinkedUIElementsAttribute];
  225. if (index < [objects count])
  226. return AccessibilityUIElement::create([objects objectAtIndex:index]);
  227. END_AX_OBJC_EXCEPTIONS
  228. return 0;
  229. }
  230. PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::ariaOwnsElementAtIndex(unsigned index)
  231. {
  232. BEGIN_AX_OBJC_EXCEPTIONS
  233. NSArray* objects = [m_element accessibilityAttributeValue:NSAccessibilityOwnsAttribute];
  234. if (index < [objects count])
  235. return AccessibilityUIElement::create([objects objectAtIndex:index]);
  236. END_AX_OBJC_EXCEPTIONS
  237. return 0;
  238. }
  239. PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::ariaFlowToElementAtIndex(unsigned index)
  240. {
  241. BEGIN_AX_OBJC_EXCEPTIONS
  242. NSArray* objects = [m_element accessibilityAttributeValue:NSAccessibilityLinkedUIElementsAttribute];
  243. if (index < [objects count])
  244. return AccessibilityUIElement::create([objects objectAtIndex:index]);
  245. END_AX_OBJC_EXCEPTIONS
  246. return 0;
  247. }
  248. PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::disclosedRowAtIndex(unsigned index)
  249. {
  250. BEGIN_AX_OBJC_EXCEPTIONS
  251. NSArray* rows = [m_element accessibilityAttributeValue:NSAccessibilityDisclosedRowsAttribute];
  252. if (index < [rows count])
  253. return AccessibilityUIElement::create([rows objectAtIndex:index]);
  254. END_AX_OBJC_EXCEPTIONS
  255. return 0;
  256. }
  257. PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::rowAtIndex(unsigned index)
  258. {
  259. BEGIN_AX_OBJC_EXCEPTIONS
  260. NSArray* rows = [m_element accessibilityAttributeValue:NSAccessibilityRowsAttribute];
  261. if (index < [rows count])
  262. return AccessibilityUIElement::create([rows objectAtIndex:index]);
  263. END_AX_OBJC_EXCEPTIONS
  264. return 0;
  265. }
  266. PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::selectedChildAtIndex(unsigned index) const
  267. {
  268. BEGIN_AX_OBJC_EXCEPTIONS
  269. NSArray* array = [m_element accessibilityAttributeValue:NSAccessibilitySelectedChildrenAttribute];
  270. if (index < [array count])
  271. return AccessibilityUIElement::create([array objectAtIndex:index]);
  272. END_AX_OBJC_EXCEPTIONS
  273. return 0;
  274. }
  275. unsigned AccessibilityUIElement::selectedChildrenCount() const
  276. {
  277. BEGIN_AX_OBJC_EXCEPTIONS
  278. return [m_element accessibilityArrayAttributeCount:NSAccessibilitySelectedChildrenAttribute];
  279. END_AX_OBJC_EXCEPTIONS
  280. return 0;
  281. }
  282. PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::selectedRowAtIndex(unsigned index)
  283. {
  284. BEGIN_AX_OBJC_EXCEPTIONS
  285. NSArray* rows = [m_element accessibilityAttributeValue:NSAccessibilitySelectedRowsAttribute];
  286. if (index < [rows count])
  287. return AccessibilityUIElement::create([rows objectAtIndex:index]);
  288. END_AX_OBJC_EXCEPTIONS
  289. return 0;
  290. }
  291. PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::titleUIElement()
  292. {
  293. BEGIN_AX_OBJC_EXCEPTIONS
  294. id accessibilityObject = [m_element accessibilityAttributeValue:NSAccessibilityTitleUIElementAttribute];
  295. if (accessibilityObject)
  296. return AccessibilityUIElement::create(accessibilityObject);
  297. END_AX_OBJC_EXCEPTIONS
  298. return 0;
  299. }
  300. PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::parentElement()
  301. {
  302. BEGIN_AX_OBJC_EXCEPTIONS
  303. id accessibilityObject = [m_element accessibilityAttributeValue:NSAccessibilityParentAttribute];
  304. if (accessibilityObject)
  305. return AccessibilityUIElement::create(accessibilityObject);
  306. END_AX_OBJC_EXCEPTIONS
  307. return 0;
  308. }
  309. PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::disclosedByRow()
  310. {
  311. BEGIN_AX_OBJC_EXCEPTIONS
  312. id accessibilityObject = [m_element accessibilityAttributeValue:NSAccessibilityDisclosedByRowAttribute];
  313. if (accessibilityObject)
  314. return AccessibilityUIElement::create(accessibilityObject);
  315. END_AX_OBJC_EXCEPTIONS
  316. return 0;
  317. }
  318. JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfLinkedUIElements()
  319. {
  320. Vector<RefPtr<AccessibilityUIElement> > linkedElements;
  321. getLinkedUIElements(linkedElements);
  322. return descriptionOfElements(linkedElements);
  323. }
  324. JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfDocumentLinks()
  325. {
  326. Vector<RefPtr<AccessibilityUIElement> > linkElements;
  327. getDocumentLinks(linkElements);
  328. return descriptionOfElements(linkElements);
  329. }
  330. JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfChildren()
  331. {
  332. Vector<RefPtr<AccessibilityUIElement> > children;
  333. getChildren(children);
  334. return descriptionOfElements(children);
  335. }
  336. JSRetainPtr<JSStringRef> AccessibilityUIElement::allAttributes()
  337. {
  338. NSString* attributes = attributesOfElement(m_element);
  339. return [attributes createJSStringRef];
  340. }
  341. JSRetainPtr<JSStringRef> AccessibilityUIElement::stringAttributeValue(JSStringRef attribute)
  342. {
  343. BEGIN_AX_OBJC_EXCEPTIONS
  344. id value = [m_element accessibilityAttributeValue:[NSString stringWithJSStringRef:attribute]];
  345. if ([value isKindOfClass:[NSString class]])
  346. return [value createJSStringRef];
  347. END_AX_OBJC_EXCEPTIONS
  348. return 0;
  349. }
  350. double AccessibilityUIElement::numberAttributeValue(JSStringRef attribute)
  351. {
  352. BEGIN_AX_OBJC_EXCEPTIONS
  353. id value = [m_element accessibilityAttributeValue:[NSString stringWithJSStringRef:attribute]];
  354. if ([value isKindOfClass:[NSNumber class]])
  355. return [value doubleValue];
  356. END_AX_OBJC_EXCEPTIONS
  357. return 0;
  358. }
  359. PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::uiElementAttributeValue(JSStringRef attribute) const
  360. {
  361. BEGIN_AX_OBJC_EXCEPTIONS
  362. id uiElement = [m_element accessibilityAttributeValue:[NSString stringWithJSStringRef:attribute]];
  363. return AccessibilityUIElement::create(uiElement);
  364. END_AX_OBJC_EXCEPTIONS
  365. return 0;
  366. }
  367. bool AccessibilityUIElement::boolAttributeValue(JSStringRef attribute)
  368. {
  369. BEGIN_AX_OBJC_EXCEPTIONS
  370. id value = [m_element accessibilityAttributeValue:[NSString stringWithJSStringRef:attribute]];
  371. if ([value isKindOfClass:[NSNumber class]])
  372. return [value boolValue];
  373. END_AX_OBJC_EXCEPTIONS
  374. return false;
  375. }
  376. bool AccessibilityUIElement::isAttributeSettable(JSStringRef attribute)
  377. {
  378. BEGIN_AX_OBJC_EXCEPTIONS
  379. return [m_element accessibilityIsAttributeSettable:[NSString stringWithJSStringRef:attribute]];
  380. END_AX_OBJC_EXCEPTIONS
  381. return false;
  382. }
  383. bool AccessibilityUIElement::isAttributeSupported(JSStringRef attribute)
  384. {
  385. BEGIN_AX_OBJC_EXCEPTIONS
  386. return [[m_element accessibilityAttributeNames] containsObject:[NSString stringWithJSStringRef:attribute]];
  387. END_AX_OBJC_EXCEPTIONS
  388. return false;
  389. }
  390. JSRetainPtr<JSStringRef> AccessibilityUIElement::parameterizedAttributeNames()
  391. {
  392. NSArray* supportedParameterizedAttributes = [m_element accessibilityParameterizedAttributeNames];
  393. NSMutableString* attributesString = [NSMutableString string];
  394. for (NSUInteger i = 0; i < [supportedParameterizedAttributes count]; ++i) {
  395. [attributesString appendFormat:@"%@\n", [supportedParameterizedAttributes objectAtIndex:i]];
  396. }
  397. return [attributesString createJSStringRef];
  398. }
  399. JSRetainPtr<JSStringRef> AccessibilityUIElement::role()
  400. {
  401. BEGIN_AX_OBJC_EXCEPTIONS
  402. NSString *role = descriptionOfValue([m_element accessibilityAttributeValue:NSAccessibilityRoleAttribute], m_element);
  403. return concatenateAttributeAndValue(@"AXRole", role);
  404. END_AX_OBJC_EXCEPTIONS
  405. return 0;
  406. }
  407. JSRetainPtr<JSStringRef> AccessibilityUIElement::subrole()
  408. {
  409. BEGIN_AX_OBJC_EXCEPTIONS
  410. NSString* role = descriptionOfValue([m_element accessibilityAttributeValue:NSAccessibilitySubroleAttribute], m_element);
  411. return concatenateAttributeAndValue(@"AXSubrole", role);
  412. END_AX_OBJC_EXCEPTIONS
  413. return 0;
  414. }
  415. JSRetainPtr<JSStringRef> AccessibilityUIElement::roleDescription()
  416. {
  417. BEGIN_AX_OBJC_EXCEPTIONS
  418. NSString* role = descriptionOfValue([m_element accessibilityAttributeValue:NSAccessibilityRoleDescriptionAttribute], m_element);
  419. return concatenateAttributeAndValue(@"AXRoleDescription", role);
  420. END_AX_OBJC_EXCEPTIONS
  421. return 0;
  422. }
  423. JSRetainPtr<JSStringRef> AccessibilityUIElement::title()
  424. {
  425. BEGIN_AX_OBJC_EXCEPTIONS
  426. NSString* title = descriptionOfValue([m_element accessibilityAttributeValue:NSAccessibilityTitleAttribute], m_element);
  427. return concatenateAttributeAndValue(@"AXTitle", title);
  428. END_AX_OBJC_EXCEPTIONS
  429. return 0;
  430. }
  431. JSRetainPtr<JSStringRef> AccessibilityUIElement::description()
  432. {
  433. BEGIN_AX_OBJC_EXCEPTIONS
  434. id description = descriptionOfValue([m_element accessibilityAttributeValue:NSAccessibilityDescriptionAttribute], m_element);
  435. return concatenateAttributeAndValue(@"AXDescription", description);
  436. END_AX_OBJC_EXCEPTIONS
  437. return 0;
  438. }
  439. JSRetainPtr<JSStringRef> AccessibilityUIElement::orientation() const
  440. {
  441. BEGIN_AX_OBJC_EXCEPTIONS
  442. id description = descriptionOfValue([m_element accessibilityAttributeValue:NSAccessibilityOrientationAttribute], m_element);
  443. return concatenateAttributeAndValue(@"AXOrientation", description);
  444. END_AX_OBJC_EXCEPTIONS
  445. return 0;
  446. }
  447. JSRetainPtr<JSStringRef> AccessibilityUIElement::stringValue()
  448. {
  449. BEGIN_AX_OBJC_EXCEPTIONS
  450. id description = descriptionOfValue([m_element accessibilityAttributeValue:NSAccessibilityValueAttribute], m_element);
  451. return concatenateAttributeAndValue(@"AXValue", description);
  452. END_AX_OBJC_EXCEPTIONS
  453. return 0;
  454. }
  455. JSRetainPtr<JSStringRef> AccessibilityUIElement::language()
  456. {
  457. BEGIN_AX_OBJC_EXCEPTIONS
  458. id description = descriptionOfValue([m_element accessibilityAttributeValue:@"AXLanguage"], m_element);
  459. return concatenateAttributeAndValue(@"AXLanguage", description);
  460. END_AX_OBJC_EXCEPTIONS
  461. return 0;
  462. }
  463. JSRetainPtr<JSStringRef> AccessibilityUIElement::helpText() const
  464. {
  465. BEGIN_AX_OBJC_EXCEPTIONS
  466. id description = descriptionOfValue([m_element accessibilityAttributeValue:NSAccessibilityHelpAttribute], m_element);
  467. return concatenateAttributeAndValue(@"AXHelp", description);
  468. END_AX_OBJC_EXCEPTIONS
  469. return 0;
  470. }
  471. double AccessibilityUIElement::x()
  472. {
  473. BEGIN_AX_OBJC_EXCEPTIONS
  474. NSValue* positionValue = [m_element accessibilityAttributeValue:NSAccessibilityPositionAttribute];
  475. return static_cast<double>([positionValue pointValue].x);
  476. END_AX_OBJC_EXCEPTIONS
  477. return 0.0f;
  478. }
  479. double AccessibilityUIElement::y()
  480. {
  481. BEGIN_AX_OBJC_EXCEPTIONS
  482. NSValue* positionValue = [m_element accessibilityAttributeValue:NSAccessibilityPositionAttribute];
  483. return static_cast<double>([positionValue pointValue].y);
  484. END_AX_OBJC_EXCEPTIONS
  485. return 0.0f;
  486. }
  487. double AccessibilityUIElement::width()
  488. {
  489. BEGIN_AX_OBJC_EXCEPTIONS
  490. NSValue* sizeValue = [m_element accessibilityAttributeValue:NSAccessibilitySizeAttribute];
  491. return static_cast<double>([sizeValue sizeValue].width);
  492. END_AX_OBJC_EXCEPTIONS
  493. return 0.0f;
  494. }
  495. double AccessibilityUIElement::height()
  496. {
  497. BEGIN_AX_OBJC_EXCEPTIONS
  498. NSValue* sizeValue = [m_element accessibilityAttributeValue:NSAccessibilitySizeAttribute];
  499. return static_cast<double>([sizeValue sizeValue].height);
  500. END_AX_OBJC_EXCEPTIONS
  501. return 0.0f;
  502. }
  503. double AccessibilityUIElement::clickPointX()
  504. {
  505. BEGIN_AX_OBJC_EXCEPTIONS
  506. NSValue* positionValue = [m_element accessibilityAttributeValue:@"AXClickPoint"];
  507. return static_cast<double>([positionValue pointValue].x);
  508. END_AX_OBJC_EXCEPTIONS
  509. return 0.0f;
  510. }
  511. double AccessibilityUIElement::clickPointY()
  512. {
  513. BEGIN_AX_OBJC_EXCEPTIONS
  514. NSValue* positionValue = [m_element accessibilityAttributeValue:@"AXClickPoint"];
  515. return static_cast<double>([positionValue pointValue].y);
  516. END_AX_OBJC_EXCEPTIONS
  517. return 0.0f;
  518. }
  519. double AccessibilityUIElement::intValue() const
  520. {
  521. BEGIN_AX_OBJC_EXCEPTIONS
  522. id value = [m_element accessibilityAttributeValue:NSAccessibilityValueAttribute];
  523. if ([value isKindOfClass:[NSNumber class]])
  524. return [(NSNumber*)value doubleValue];
  525. END_AX_OBJC_EXCEPTIONS
  526. return 0.0f;
  527. }
  528. double AccessibilityUIElement::minValue()
  529. {
  530. BEGIN_AX_OBJC_EXCEPTIONS
  531. id value = [m_element accessibilityAttributeValue:NSAccessibilityMinValueAttribute];
  532. if ([value isKindOfClass:[NSNumber class]])
  533. return [(NSNumber*)value doubleValue];
  534. END_AX_OBJC_EXCEPTIONS
  535. return 0.0f;
  536. }
  537. double AccessibilityUIElement::maxValue()
  538. {
  539. BEGIN_AX_OBJC_EXCEPTIONS
  540. id value = [m_element accessibilityAttributeValue:NSAccessibilityMaxValueAttribute];
  541. if ([value isKindOfClass:[NSNumber class]])
  542. return [(NSNumber*)value doubleValue];
  543. END_AX_OBJC_EXCEPTIONS
  544. return 0.0;
  545. }
  546. JSRetainPtr<JSStringRef> AccessibilityUIElement::valueDescription()
  547. {
  548. BEGIN_AX_OBJC_EXCEPTIONS
  549. NSString* valueDescription = [m_element accessibilityAttributeValue:NSAccessibilityValueDescriptionAttribute];
  550. if ([valueDescription isKindOfClass:[NSString class]])
  551. return [valueDescription createJSStringRef];
  552. END_AX_OBJC_EXCEPTIONS
  553. return 0;
  554. }
  555. int AccessibilityUIElement::insertionPointLineNumber()
  556. {
  557. BEGIN_AX_OBJC_EXCEPTIONS
  558. id value = [m_element accessibilityAttributeValue:NSAccessibilityInsertionPointLineNumberAttribute];
  559. if ([value isKindOfClass:[NSNumber class]])
  560. return [(NSNumber *)value intValue];
  561. END_AX_OBJC_EXCEPTIONS
  562. return -1;
  563. }
  564. bool AccessibilityUIElement::isPressActionSupported()
  565. {
  566. BEGIN_AX_OBJC_EXCEPTIONS
  567. NSArray* actions = [m_element accessibilityActionNames];
  568. return [actions containsObject:NSAccessibilityPressAction];
  569. END_AX_OBJC_EXCEPTIONS
  570. return false;
  571. }
  572. bool AccessibilityUIElement::isIncrementActionSupported()
  573. {
  574. BEGIN_AX_OBJC_EXCEPTIONS
  575. NSArray* actions = [m_element accessibilityActionNames];
  576. return [actions containsObject:NSAccessibilityIncrementAction];
  577. END_AX_OBJC_EXCEPTIONS
  578. return false;
  579. }
  580. bool AccessibilityUIElement::isDecrementActionSupported()
  581. {
  582. BEGIN_AX_OBJC_EXCEPTIONS
  583. NSArray* actions = [m_element accessibilityActionNames];
  584. return [actions containsObject:NSAccessibilityDecrementAction];
  585. END_AX_OBJC_EXCEPTIONS
  586. return false;
  587. }
  588. bool AccessibilityUIElement::isEnabled()
  589. {
  590. BEGIN_AX_OBJC_EXCEPTIONS
  591. id value = [m_element accessibilityAttributeValue:NSAccessibilityEnabledAttribute];
  592. if ([value isKindOfClass:[NSNumber class]])
  593. return [value boolValue];
  594. END_AX_OBJC_EXCEPTIONS
  595. return false;
  596. }
  597. bool AccessibilityUIElement::isRequired() const
  598. {
  599. BEGIN_AX_OBJC_EXCEPTIONS
  600. id value = [m_element accessibilityAttributeValue:@"AXRequired"];
  601. if ([value isKindOfClass:[NSNumber class]])
  602. return [value boolValue];
  603. END_AX_OBJC_EXCEPTIONS
  604. return false;
  605. }
  606. bool AccessibilityUIElement::isFocused() const
  607. {
  608. // FIXME: implement
  609. return false;
  610. }
  611. bool AccessibilityUIElement::isSelected() const
  612. {
  613. BEGIN_AX_OBJC_EXCEPTIONS
  614. id value = [m_element accessibilityAttributeValue:NSAccessibilitySelectedAttribute];
  615. if ([value isKindOfClass:[NSNumber class]])
  616. return [value boolValue];
  617. END_AX_OBJC_EXCEPTIONS
  618. return false;
  619. }
  620. bool AccessibilityUIElement::isExpanded() const
  621. {
  622. BEGIN_AX_OBJC_EXCEPTIONS
  623. id value = [m_element accessibilityAttributeValue:NSAccessibilityExpandedAttribute];
  624. if ([value isKindOfClass:[NSNumber class]])
  625. return [value boolValue];
  626. END_AX_OBJC_EXCEPTIONS
  627. return false;
  628. }
  629. bool AccessibilityUIElement::isChecked() const
  630. {
  631. // On the Mac, intValue()==1 if a a checkable control is checked.
  632. return intValue() == 1;
  633. }
  634. int AccessibilityUIElement::hierarchicalLevel() const
  635. {
  636. BEGIN_AX_OBJC_EXCEPTIONS
  637. id value = [m_element accessibilityAttributeValue:NSAccessibilityDisclosureLevelAttribute];
  638. if ([value isKindOfClass:[NSNumber class]])
  639. return [value intValue];
  640. END_AX_OBJC_EXCEPTIONS
  641. return 0;
  642. }
  643. JSRetainPtr<JSStringRef> AccessibilityUIElement::speak()
  644. {
  645. BEGIN_AX_OBJC_EXCEPTIONS
  646. id value = [m_element accessibilityAttributeValue:@"AXDRTSpeechAttribute"];
  647. if ([value isKindOfClass:[NSString class]])
  648. return [value createJSStringRef];
  649. END_AX_OBJC_EXCEPTIONS
  650. return 0;
  651. }
  652. bool AccessibilityUIElement::ariaIsGrabbed() const
  653. {
  654. BEGIN_AX_OBJC_EXCEPTIONS
  655. id value = [m_element accessibilityAttributeValue:NSAccessibilityGrabbedAttribute];
  656. if ([value isKindOfClass:[NSNumber class]])
  657. return [value boolValue];
  658. END_AX_OBJC_EXCEPTIONS
  659. return false;
  660. }
  661. JSRetainPtr<JSStringRef> AccessibilityUIElement::ariaDropEffects() const
  662. {
  663. BEGIN_AX_OBJC_EXCEPTIONS
  664. id value = [m_element accessibilityAttributeValue:NSAccessibilityDropEffectsAttribute];
  665. if (![value isKindOfClass:[NSArray class]])
  666. return 0;
  667. NSMutableString* dropEffects = [NSMutableString string];
  668. NSInteger length = [value count];
  669. for (NSInteger k = 0; k < length; ++k) {
  670. [dropEffects appendString:[value objectAtIndex:k]];
  671. if (k < length - 1)
  672. [dropEffects appendString:@","];
  673. }
  674. return [dropEffects createJSStringRef];
  675. END_AX_OBJC_EXCEPTIONS
  676. return 0;
  677. }
  678. // parameterized attributes
  679. int AccessibilityUIElement::lineForIndex(int index)
  680. {
  681. BEGIN_AX_OBJC_EXCEPTIONS
  682. id value = [m_element accessibilityAttributeValue:NSAccessibilityLineForIndexParameterizedAttribute forParameter:[NSNumber numberWithInt:index]];
  683. if ([value isKindOfClass:[NSNumber class]])
  684. return [(NSNumber *)value intValue];
  685. END_AX_OBJC_EXCEPTIONS
  686. return -1;
  687. }
  688. JSRetainPtr<JSStringRef> AccessibilityUIElement::rangeForLine(int line)
  689. {
  690. BEGIN_AX_OBJC_EXCEPTIONS
  691. id value = [m_element accessibilityAttributeValue:NSAccessibilityRangeForLineParameterizedAttribute forParameter:[NSNumber numberWithInt:line]];
  692. if ([value isKindOfClass:[NSValue class]])
  693. return [NSStringFromRange([value rangeValue]) createJSStringRef];
  694. END_AX_OBJC_EXCEPTIONS
  695. return 0;
  696. }
  697. JSRetainPtr<JSStringRef> AccessibilityUIElement::rangeForPosition(int x, int y)
  698. {
  699. BEGIN_AX_OBJC_EXCEPTIONS
  700. id value = [m_element accessibilityAttributeValue:NSAccessibilityRangeForPositionParameterizedAttribute forParameter:[NSValue valueWithPoint:NSMakePoint(x, y)]];
  701. if ([value isKindOfClass:[NSValue class]])
  702. return [NSStringFromRange([value rangeValue]) createJSStringRef];
  703. END_AX_OBJC_EXCEPTIONS
  704. return 0;
  705. }
  706. JSRetainPtr<JSStringRef> AccessibilityUIElement::boundsForRange(unsigned location, unsigned length)
  707. {
  708. NSRange range = NSMakeRange(location, length);
  709. BEGIN_AX_OBJC_EXCEPTIONS
  710. id value = [m_element accessibilityAttributeValue:NSAccessibilityBoundsForRangeParameterizedAttribute forParameter:[NSValue valueWithRange:range]];
  711. NSRect rect = NSMakeRect(0,0,0,0);
  712. if ([value isKindOfClass:[NSValue class]])
  713. rect = [value rectValue];
  714. // don't return position information because it is platform dependent
  715. NSMutableString* boundsDescription = [NSMutableString stringWithFormat:@"{{%f, %f}, {%f, %f}}",-1.0f,-1.0f,rect.size.width,rect.size.height];
  716. return [boundsDescription createJSStringRef];
  717. END_AX_OBJC_EXCEPTIONS
  718. return 0;
  719. }
  720. JSRetainPtr<JSStringRef> AccessibilityUIElement::stringForRange(unsigned location, unsigned length)
  721. {
  722. NSRange range = NSMakeRange(location, length);
  723. BEGIN_AX_OBJC_EXCEPTIONS
  724. id string = [m_element accessibilityAttributeValue:NSAccessibilityStringForRangeParameterizedAttribute forParameter:[NSValue valueWithRange:range]];
  725. if (![string isKindOfClass:[NSString class]])
  726. return 0;
  727. return [string createJSStringRef];
  728. END_AX_OBJC_EXCEPTIONS
  729. return 0;
  730. }
  731. JSRetainPtr<JSStringRef> AccessibilityUIElement::attributedStringForRange(unsigned location, unsigned length)
  732. {
  733. NSRange range = NSMakeRange(location, length);
  734. BEGIN_AX_OBJC_EXCEPTIONS
  735. NSAttributedString* string = [m_element accessibilityAttributeValue:NSAccessibilityAttributedStringForRangeParameterizedAttribute forParameter:[NSValue valueWithRange:range]];
  736. if (![string isKindOfClass:[NSAttributedString class]])
  737. return 0;
  738. NSString* stringWithAttrs = [string description];
  739. return [stringWithAttrs createJSStringRef];
  740. END_AX_OBJC_EXCEPTIONS
  741. return 0;
  742. }
  743. bool AccessibilityUIElement::attributedStringRangeIsMisspelled(unsigned location, unsigned length)
  744. {
  745. NSRange range = NSMakeRange(location, length);
  746. BEGIN_AX_OBJC_EXCEPTIONS
  747. NSAttributedString* string = [m_element accessibilityAttributeValue:NSAccessibilityAttributedStringForRangeParameterizedAttribute forParameter:[NSValue valueWithRange:range]];
  748. if (![string isKindOfClass:[NSAttributedString class]])
  749. return false;
  750. NSDictionary* attrs = [string attributesAtIndex:0 effectiveRange:nil];
  751. BOOL misspelled = [[attrs objectForKey:NSAccessibilityMisspelledTextAttribute] boolValue];
  752. #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
  753. if (misspelled)
  754. misspelled = [[attrs objectForKey:NSAccessibilityMarkedMisspelledTextAttribute] boolValue];
  755. #endif
  756. return misspelled;
  757. END_AX_OBJC_EXCEPTIONS
  758. return false;
  759. }
  760. PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::uiElementForSearchPredicate(JSContextRef context, AccessibilityUIElement* startElement, bool isDirectionNext, JSValueRef searchKey, JSStringRef searchText, bool visibleOnly)
  761. {
  762. BEGIN_AX_OBJC_EXCEPTIONS
  763. NSMutableDictionary* parameter = [NSMutableDictionary dictionary];
  764. [parameter setObject:(isDirectionNext) ? @"AXDirectionNext" : @"AXDirectionPrevious" forKey:@"AXDirection"];
  765. if (visibleOnly)
  766. [parameter setObject:[NSNumber numberWithBool:YES] forKey:@"AXVisibleOnly"];
  767. [parameter setObject:[NSNumber numberWithInt:1] forKey:@"AXResultsLimit"];
  768. if (startElement && startElement->platformUIElement())
  769. [parameter setObject:(id)startElement->platformUIElement() forKey:@"AXStartElement"];
  770. if (searchKey) {
  771. if (JSValueIsString(context, searchKey)) {
  772. NSString *searchKeyParameter = nil;
  773. JSStringRef singleSearchKey = JSValueToStringCopy(context, searchKey, 0);
  774. if (singleSearchKey) {
  775. searchKeyParameter = [NSString stringWithJSStringRef:singleSearchKey];
  776. JSStringRelease(singleSearchKey);
  777. if (searchKeyParameter)
  778. [parameter setObject:searchKeyParameter forKey:@"AXSearchKey"];
  779. }
  780. }
  781. else if (JSValueIsObject(context, searchKey)) {
  782. NSMutableArray *searchKeyParameter = nil;
  783. JSObjectRef array = const_cast<JSObjectRef>(searchKey);
  784. unsigned arrayLength = 0;
  785. JSRetainPtr<JSStringRef> arrayLengthString(Adopt, JSStringCreateWithUTF8CString("length"));
  786. JSValueRef arrayLengthValue = JSObjectGetProperty(context, array, arrayLengthString.get(), 0);
  787. if (arrayLengthValue && JSValueIsNumber(context, arrayLengthValue))
  788. arrayLength = static_cast<unsigned>(JSValueToNumber(context, arrayLengthValue, 0));
  789. for (unsigned i = 0; i < arrayLength; ++i) {
  790. JSValueRef exception = 0;
  791. JSValueRef value = JSObjectGetPropertyAtIndex(context, array, i, &exception);
  792. if (exception)
  793. break;
  794. JSStringRef singleSearchKey = JSValueToStringCopy(context, value, &exception);
  795. if (exception)
  796. break;
  797. if (singleSearchKey) {
  798. if (!searchKeyParameter)
  799. searchKeyParameter = [NSMutableArray array];
  800. [searchKeyParameter addObject:[NSString stringWithJSStringRef:singleSearchKey]];
  801. JSStringRelease(singleSearchKey);
  802. }
  803. }
  804. if (searchKeyParameter)
  805. [parameter setObject:searchKeyParameter forKey:@"AXSearchKey"];
  806. }
  807. }
  808. if (searchText && JSStringGetLength(searchText))
  809. [parameter setObject:[NSString stringWithJSStringRef:searchText] forKey:@"AXSearchText"];
  810. id uiElement = [[m_element accessibilityAttributeValue:@"AXUIElementsForSearchPredicate" forParameter:parameter] lastObject];
  811. return AccessibilityUIElement::create(uiElement);
  812. END_AX_OBJC_EXCEPTIONS
  813. return 0;
  814. }
  815. JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfColumnHeaders()
  816. {
  817. // not yet defined in AppKit... odd
  818. BEGIN_AX_OBJC_EXCEPTIONS
  819. NSArray* columnHeadersArray = [m_element accessibilityAttributeValue:@"AXColumnHeaderUIElements"];
  820. Vector<RefPtr<AccessibilityUIElement> > columnHeadersVector;
  821. convertNSArrayToVector(columnHeadersArray, columnHeadersVector);
  822. return descriptionOfElements(columnHeadersVector);
  823. END_AX_OBJC_EXCEPTIONS
  824. return 0;
  825. }
  826. JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfRowHeaders()
  827. {
  828. BEGIN_AX_OBJC_EXCEPTIONS
  829. NSArray* rowHeadersArray = [m_element accessibilityAttributeValue:@"AXRowHeaderUIElements"];
  830. Vector<RefPtr<AccessibilityUIElement> > rowHeadersVector;
  831. convertNSArrayToVector(rowHeadersArray, rowHeadersVector);
  832. return descriptionOfElements(rowHeadersVector);
  833. END_AX_OBJC_EXCEPTIONS
  834. return 0;
  835. }
  836. JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfColumns()
  837. {
  838. BEGIN_AX_OBJC_EXCEPTIONS
  839. NSArray* columnsArray = [m_element accessibilityAttributeValue:NSAccessibilityColumnsAttribute];
  840. Vector<RefPtr<AccessibilityUIElement> > columnsVector;
  841. convertNSArrayToVector(columnsArray, columnsVector);
  842. return descriptionOfElements(columnsVector);
  843. END_AX_OBJC_EXCEPTIONS
  844. return 0;
  845. }
  846. JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfRows()
  847. {
  848. BEGIN_AX_OBJC_EXCEPTIONS
  849. NSArray* rowsArray = [m_element accessibilityAttributeValue:NSAccessibilityRowsAttribute];
  850. Vector<RefPtr<AccessibilityUIElement> > rowsVector;
  851. convertNSArrayToVector(rowsArray, rowsVector);
  852. return descriptionOfElements(rowsVector);
  853. END_AX_OBJC_EXCEPTIONS
  854. return 0;
  855. }
  856. JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfVisibleCells()
  857. {
  858. BEGIN_AX_OBJC_EXCEPTIONS
  859. NSArray* cellsArray = [m_element accessibilityAttributeValue:@"AXVisibleCells"];
  860. Vector<RefPtr<AccessibilityUIElement> > cellsVector;
  861. convertNSArrayToVector(cellsArray, cellsVector);
  862. return descriptionOfElements(cellsVector);
  863. END_AX_OBJC_EXCEPTIONS
  864. return 0;
  865. }
  866. JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfHeader()
  867. {
  868. BEGIN_AX_OBJC_EXCEPTIONS
  869. id headerObject = [m_element accessibilityAttributeValue:NSAccessibilityHeaderAttribute];
  870. if (!headerObject)
  871. return [@"" createJSStringRef];
  872. Vector<RefPtr<AccessibilityUIElement> > headerVector;
  873. headerVector.append(AccessibilityUIElement::create(headerObject));
  874. return descriptionOfElements(headerVector);
  875. END_AX_OBJC_EXCEPTIONS
  876. return 0;
  877. }
  878. int AccessibilityUIElement::rowCount()
  879. {
  880. BEGIN_AX_OBJC_EXCEPTIONS
  881. return [m_element accessibilityArrayAttributeCount:NSAccessibilityRowsAttribute];
  882. END_AX_OBJC_EXCEPTIONS
  883. return 0;
  884. }
  885. int AccessibilityUIElement::columnCount()
  886. {
  887. BEGIN_AX_OBJC_EXCEPTIONS
  888. return [m_element accessibilityArrayAttributeCount:NSAccessibilityColumnsAttribute];
  889. END_AX_OBJC_EXCEPTIONS
  890. return 0;
  891. }
  892. int AccessibilityUIElement::indexInTable()
  893. {
  894. BEGIN_AX_OBJC_EXCEPTIONS
  895. NSNumber* indexNumber = [m_element accessibilityAttributeValue:NSAccessibilityIndexAttribute];
  896. if (indexNumber)
  897. return [indexNumber intValue];
  898. END_AX_OBJC_EXCEPTIONS
  899. return -1;
  900. }
  901. JSRetainPtr<JSStringRef> AccessibilityUIElement::rowIndexRange()
  902. {
  903. NSRange range = NSMakeRange(0, 0);
  904. BEGIN_AX_OBJC_EXCEPTIONS
  905. NSValue* indexRange = [m_element accessibilityAttributeValue:@"AXRowIndexRange"];
  906. if (indexRange)
  907. range = [indexRange rangeValue];
  908. NSMutableString* rangeDescription = [NSMutableString stringWithFormat:@"{%lu, %lu}", static_cast<unsigned long>(range.location), static_cast<unsigned long>(range.length)];
  909. return [rangeDescription createJSStringRef];
  910. END_AX_OBJC_EXCEPTIONS
  911. return 0;
  912. }
  913. JSRetainPtr<JSStringRef> AccessibilityUIElement::columnIndexRange()
  914. {
  915. NSRange range = NSMakeRange(0, 0);
  916. BEGIN_AX_OBJC_EXCEPTIONS
  917. NSNumber* indexRange = [m_element accessibilityAttributeValue:@"AXColumnIndexRange"];
  918. if (indexRange)
  919. range = [indexRange rangeValue];
  920. NSMutableString* rangeDescription = [NSMutableString stringWithFormat:@"{%lu, %lu}", static_cast<unsigned long>(range.location), static_cast<unsigned long>(range.length)];
  921. return [rangeDescription createJSStringRef];
  922. END_AX_OBJC_EXCEPTIONS
  923. return 0;
  924. }
  925. PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::cellForColumnAndRow(unsigned col, unsigned row)
  926. {
  927. NSArray *colRowArray = [NSArray arrayWithObjects:[NSNumber numberWithUnsignedInt:col], [NSNumber numberWithUnsignedInt:row], nil];
  928. BEGIN_AX_OBJC_EXCEPTIONS
  929. return AccessibilityUIElement::create([m_element accessibilityAttributeValue:@"AXCellForColumnAndRow" forParameter:colRowArray]);
  930. END_AX_OBJC_EXCEPTIONS
  931. return 0;
  932. }
  933. PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::horizontalScrollbar() const
  934. {
  935. BEGIN_AX_OBJC_EXCEPTIONS
  936. return AccessibilityUIElement::create([m_element accessibilityAttributeValue:NSAccessibilityHorizontalScrollBarAttribute]);
  937. END_AX_OBJC_EXCEPTIONS
  938. return 0;
  939. }
  940. PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::verticalScrollbar() const
  941. {
  942. BEGIN_AX_OBJC_EXCEPTIONS
  943. return AccessibilityUIElement::create([m_element accessibilityAttributeValue:NSAccessibilityVerticalScrollBarAttribute]);
  944. END_AX_OBJC_EXCEPTIONS
  945. return 0;
  946. }
  947. void AccessibilityUIElement::scrollToMakeVisible()
  948. {
  949. BEGIN_AX_OBJC_EXCEPTIONS
  950. [m_element accessibilityPerformAction:@"AXScrollToVisible"];
  951. END_AX_OBJC_EXCEPTIONS
  952. }
  953. JSRetainPtr<JSStringRef> AccessibilityUIElement::selectedTextRange()
  954. {
  955. NSRange range = NSMakeRange(NSNotFound, 0);
  956. BEGIN_AX_OBJC_EXCEPTIONS
  957. NSValue *indexRange = [m_element accessibilityAttributeValue:NSAccessibilitySelectedTextRangeAttribute];
  958. if (indexRange)
  959. range = [indexRange rangeValue];
  960. NSMutableString* rangeDescription = [NSMutableString stringWithFormat:@"{%lu, %lu}", static_cast<unsigned long>(range.location), static_cast<unsigned long>(range.length)];
  961. return [rangeDescription createJSStringRef];
  962. END_AX_OBJC_EXCEPTIONS
  963. return 0;
  964. }
  965. void AccessibilityUIElement::setSelectedTextRange(unsigned location, unsigned length)
  966. {
  967. NSRange textRange = NSMakeRange(location, length);
  968. NSValue *textRangeValue = [NSValue valueWithRange:textRange];
  969. BEGIN_AX_OBJC_EXCEPTIONS
  970. [m_element accessibilitySetValue:textRangeValue forAttribute:NSAccessibilitySelectedTextRangeAttribute];
  971. END_AX_OBJC_EXCEPTIONS
  972. }
  973. void AccessibilityUIElement::increment()
  974. {
  975. BEGIN_AX_OBJC_EXCEPTIONS
  976. [m_element accessibilityPerformAction:NSAccessibilityIncrementAction];
  977. END_AX_OBJC_EXCEPTIONS
  978. }
  979. void AccessibilityUIElement::decrement()
  980. {
  981. BEGIN_AX_OBJC_EXCEPTIONS
  982. [m_element accessibilityPerformAction:NSAccessibilityDecrementAction];
  983. END_AX_OBJC_EXCEPTIONS
  984. }
  985. void AccessibilityUIElement::showMenu()
  986. {
  987. BEGIN_AX_OBJC_EXCEPTIONS
  988. [m_element accessibilityPerformAction:NSAccessibilityShowMenuAction];
  989. END_AX_OBJC_EXCEPTIONS
  990. }
  991. void AccessibilityUIElement::press()
  992. {
  993. BEGIN_AX_OBJC_EXCEPTIONS
  994. [m_element accessibilityPerformAction:NSAccessibilityPressAction];
  995. END_AX_OBJC_EXCEPTIONS
  996. }
  997. void AccessibilityUIElement::setSelectedChild(AccessibilityUIElement* element) const
  998. {
  999. BEGIN_AX_OBJC_EXCEPTIONS
  1000. NSArray* array = [NSArray arrayWithObject:element->platformUIElement()];
  1001. [m_element accessibilitySetValue:array forAttribute:NSAccessibilitySelectedChildrenAttribute];
  1002. END_AX_OBJC_EXCEPTIONS
  1003. }
  1004. JSRetainPtr<JSStringRef> AccessibilityUIElement::accessibilityValue() const
  1005. {
  1006. // FIXME: implement
  1007. return JSStringCreateWithCharacters(0, 0);
  1008. }
  1009. JSRetainPtr<JSStringRef> AccessibilityUIElement::documentEncoding()
  1010. {
  1011. return JSStringCreateWithCharacters(0, 0);
  1012. }
  1013. JSRetainPtr<JSStringRef> AccessibilityUIElement::documentURI()
  1014. {
  1015. return JSStringCreateWithCharacters(0, 0);
  1016. }
  1017. JSRetainPtr<JSStringRef> AccessibilityUIElement::url()
  1018. {
  1019. BEGIN_AX_OBJC_EXCEPTIONS
  1020. NSURL *url = [m_element accessibilityAttributeValue:NSAccessibilityURLAttribute];
  1021. return [[url absoluteString] createJSStringRef];
  1022. END_AX_OBJC_EXCEPTIONS
  1023. return nil;
  1024. }
  1025. bool AccessibilityUIElement::addNotificationListener(JSValueRef functionCallback)
  1026. {
  1027. if (!functionCallback)
  1028. return false;
  1029. // Mac programmers should not be adding more than one notification listener per element.
  1030. // Other platforms may be different.
  1031. if (m_notificationHandler)
  1032. return false;
  1033. m_notificationHandler = [[AccessibilityNotificationHandler alloc] init];
  1034. [m_notificationHandler setPlatformElement:platformUIElement()];
  1035. [m_notificationHandler setCallback:functionCallback];
  1036. [m_notificationHandler startObserving];
  1037. return true;
  1038. }
  1039. bool AccessibilityUIElement::removeNotificationListener()
  1040. {
  1041. // Mac programmers should not be trying to remove a listener that's already removed.
  1042. ASSERT(m_notificationHandler);
  1043. [m_notificationHandler release];
  1044. m_notificationHandler = nil;
  1045. return true;
  1046. }
  1047. bool AccessibilityUIElement::isFocusable() const
  1048. {
  1049. bool result = false;
  1050. BEGIN_AX_OBJC_EXCEPTIONS
  1051. result = [m_element accessibilityIsAttributeSettable:NSAccessibilityFocusedAttribute];
  1052. END_AX_OBJC_EXCEPTIONS
  1053. return result;
  1054. }
  1055. bool AccessibilityUIElement::isSelectable() const
  1056. {
  1057. // FIXME: implement
  1058. return false;
  1059. }
  1060. bool AccessibilityUIElement::isMultiSelectable() const
  1061. {
  1062. // FIXME: implement
  1063. return false;
  1064. }
  1065. bool AccessibilityUIElement::isVisible() const
  1066. {
  1067. // FIXME: implement
  1068. return false;
  1069. }
  1070. bool AccessibilityUIElement::isOffScreen() const
  1071. {
  1072. // FIXME: implement
  1073. return false;
  1074. }
  1075. bool AccessibilityUIElement::isCollapsed() const
  1076. {
  1077. // FIXME: implement
  1078. return false;
  1079. }
  1080. bool AccessibilityUIElement::isIgnored() const
  1081. {
  1082. BOOL result = NO;
  1083. BEGIN_AX_OBJC_EXCEPTIONS
  1084. result = [m_element accessibilityIsIgnored];
  1085. END_AX_OBJC_EXCEPTIONS
  1086. return result;
  1087. }
  1088. bool AccessibilityUIElement::hasPopup() const
  1089. {
  1090. BEGIN_AX_OBJC_EXCEPTIONS
  1091. id value = [m_element accessibilityAttributeValue:@"AXHasPopup"];
  1092. if ([value isKindOfClass:[NSNumber class]])
  1093. return [value boolValue];
  1094. END_AX_OBJC_EXCEPTIONS
  1095. return false;
  1096. }
  1097. void AccessibilityUIElement::takeFocus()
  1098. {
  1099. // FIXME: implement
  1100. }
  1101. void AccessibilityUIElement::takeSelection()
  1102. {
  1103. // FIXME: implement
  1104. }
  1105. void AccessibilityUIElement::addSelection()
  1106. {
  1107. // FIXME: implement
  1108. }
  1109. void AccessibilityUIElement::removeSelection()
  1110. {
  1111. // FIXME: implement
  1112. }
  1113. // Text markers
  1114. PassRefPtr<AccessibilityTextMarkerRange> AccessibilityUIElement::textMarkerRangeForElement(AccessibilityUIElement* element)
  1115. {
  1116. BEGIN_AX_OBJC_EXCEPTIONS
  1117. id textMarkerRange = [m_element accessibilityAttributeValue:@"AXTextMarkerRangeForUIElement" forParameter:element->platformUIElement()];
  1118. return AccessibilityTextMarkerRange::create(textMarkerRange);
  1119. END_AX_OBJC_EXCEPTIONS
  1120. return 0;
  1121. }
  1122. int AccessibilityUIElement::textMarkerRangeLength(AccessibilityTextMarkerRange* range)
  1123. {
  1124. BEGIN_AX_OBJC_EXCEPTIONS
  1125. NSNumber* lengthValue = [m_element accessibilityAttributeValue:@"AXLengthForTextMarkerRange" forParameter:(id)range->platformTextMarkerRange()];
  1126. return [lengthValue intValue];
  1127. END_AX_OBJC_EXCEPTIONS
  1128. return 0;
  1129. }
  1130. PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::previousTextMarker(AccessibilityTextMarker* textMarker)
  1131. {
  1132. BEGIN_AX_OBJC_EXCEPTIONS
  1133. id previousMarker = [m_element accessibilityAttributeValue:@"AXPreviousTextMarkerForTextMarker" forParameter:(id)textMarker->platformTextMarker()];
  1134. return AccessibilityTextMarker::create(previousMarker);
  1135. END_AX_OBJC_EXCEPTIONS
  1136. return 0;
  1137. }
  1138. PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::nextTextMarker(AccessibilityTextMarker* textMarker)
  1139. {
  1140. BEGIN_AX_OBJC_EXCEPTIONS
  1141. id nextMarker = [m_element accessibilityAttributeValue:@"AXNextTextMarkerForTextMarker" forParameter:(id)textMarker->platformTextMarker()];
  1142. return AccessibilityTextMarker::create(nextMarker);
  1143. END_AX_OBJC_EXCEPTIONS
  1144. return 0;
  1145. }
  1146. JSRetainPtr<JSStringRef> AccessibilityUIElement::stringForTextMarkerRange(AccessibilityTextMarkerRange* markerRange)
  1147. {
  1148. BEGIN_AX_OBJC_EXCEPTIONS
  1149. id textString = [m_element accessibilityAttributeValue:@"AXStringForTextMarkerRange" forParameter:(id)markerRange->platformTextMarkerRange()];
  1150. return [textString createJSStringRef];
  1151. END_AX_OBJC_EXCEPTIONS
  1152. return 0;
  1153. }
  1154. PassRefPtr<AccessibilityTextMarkerRange> AccessibilityUIElement::textMarkerRangeForMarkers(AccessibilityTextMarker* startMarker, AccessibilityTextMarker* endMarker)
  1155. {
  1156. BEGIN_AX_OBJC_EXCEPTIONS
  1157. NSArray* textMarkers = [NSArray arrayWithObjects:(id)startMarker->platformTextMarker(), (id)endMarker->platformTextMarker(), nil];
  1158. id textMarkerRange = [m_element accessibilityAttributeValue:@"AXTextMarkerRangeForUnorderedTextMarkers" forParameter:textMarkers];
  1159. return AccessibilityTextMarkerRange::create(textMarkerRange);
  1160. END_AX_OBJC_EXCEPTIONS
  1161. return 0;
  1162. }
  1163. PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::startTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange* range)
  1164. {
  1165. BEGIN_AX_OBJC_EXCEPTIONS
  1166. id textMarker = [m_element accessibilityAttributeValue:@"AXStartTextMarkerForTextMarkerRange" forParameter:(id)range->platformTextMarkerRange()];
  1167. return AccessibilityTextMarker::create(textMarker);
  1168. END_AX_OBJC_EXCEPTIONS
  1169. return 0;
  1170. }
  1171. PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::endTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange* range)
  1172. {
  1173. BEGIN_AX_OBJC_EXCEPTIONS
  1174. id textMarker = [m_element accessibilityAttributeValue:@"AXEndTextMarkerForTextMarkerRange" forParameter:(id)range->platformTextMarkerRange()];
  1175. return AccessibilityTextMarker::create(textMarker);
  1176. END_AX_OBJC_EXCEPTIONS
  1177. return 0;
  1178. }
  1179. PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::textMarkerForPoint(int x, int y)
  1180. {
  1181. BEGIN_AX_OBJC_EXCEPTIONS
  1182. id textMarker = [m_element accessibilityAttributeValue:@"AXTextMarkerForPosition" forParameter:[NSValue valueWithPoint:NSMakePoint(x, y)]];
  1183. return AccessibilityTextMarker::create(textMarker);
  1184. END_AX_OBJC_EXCEPTIONS
  1185. return 0;
  1186. }
  1187. PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::accessibilityElementForTextMarker(AccessibilityTextMarker* marker)
  1188. {
  1189. BEGIN_AX_OBJC_EXCEPTIONS
  1190. id uiElement = [m_element accessibilityAttributeValue:@"AXUIElementForTextMarker" forParameter:(id)marker->platformTextMarker()];
  1191. return AccessibilityUIElement::create(uiElement);
  1192. END_AX_OBJC_EXCEPTIONS
  1193. return 0;
  1194. }
  1195. bool AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute(JSStringRef attribute, AccessibilityTextMarkerRange* range)
  1196. {
  1197. BEGIN_AX_OBJC_EXCEPTIONS
  1198. NSAttributedString* string = [m_element accessibilityAttributeValue:@"AXAttributedStringForTextMarkerRange" forParameter:(id)range->platformTextMarkerRange()];
  1199. if (![string isKindOfClass:[NSAttributedString class]])
  1200. return false;
  1201. NSDictionary* attrs = [string attributesAtIndex:0 effectiveRange:nil];
  1202. if ([attrs objectForKey:[NSString stringWithJSStringRef:attribute]])
  1203. return true;
  1204. END_AX_OBJC_EXCEPTIONS
  1205. return false;
  1206. }
  1207. int AccessibilityUIElement::indexForTextMarker(AccessibilityTextMarker* marker)
  1208. {
  1209. BEGIN_AX_OBJC_EXCEPTIONS
  1210. NSNumber* indexNumber = [m_element accessibilityAttributeValue:@"AXIndexForTextMarker" forParameter:(id)marker->platformTextMarker()];
  1211. return [indexNumber intValue];
  1212. END_AX_OBJC_EXCEPTIONS
  1213. return -1;
  1214. }
  1215. bool AccessibilityUIElement::isTextMarkerValid(AccessibilityTextMarker* textMarker)
  1216. {
  1217. BEGIN_AX_OBJC_EXCEPTIONS
  1218. NSNumber* validNumber = [m_element accessibilityAttributeValue:@"AXTextMarkerIsValid" forParameter:(id)textMarker->platformTextMarker()];
  1219. return [validNumber boolValue];
  1220. END_AX_OBJC_EXCEPTIONS
  1221. return false;
  1222. }
  1223. PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::textMarkerForIndex(int textIndex)
  1224. {
  1225. BEGIN_AX_OBJC_EXCEPTIONS
  1226. id textMarker = [m_element accessibilityAttributeValue:@"AXTextMarkerForIndex" forParameter:[NSNumber numberWithInteger:textIndex]];
  1227. return AccessibilityTextMarker::create(textMarker);
  1228. END_AX_OBJC_EXCEPTIONS
  1229. return 0;
  1230. }
  1231. static NSString *_convertMathMultiscriptPairsToString(NSArray *pairs)
  1232. {
  1233. __block NSMutableString *result = [NSMutableString string];
  1234. [pairs enumerateObjectsUsingBlock:^(id pair, NSUInteger index, BOOL *stop) {
  1235. for (NSString *key in pair)
  1236. [result appendFormat:@"\t%lu. %@ = %@\n", (unsigned long)index, key, [[pair objectForKey:key] accessibilityAttributeValue:NSAccessibilitySubroleAttribute]];
  1237. }];
  1238. return result;
  1239. }
  1240. JSRetainPtr<JSStringRef> AccessibilityUIElement::mathPostscriptsDescription() const
  1241. {
  1242. BEGIN_AX_OBJC_EXCEPTIONS
  1243. NSArray *pairs = [m_element accessibilityAttributeValue:@"AXMathPostscripts"];
  1244. return [_convertMathMultiscriptPairsToString(pairs) createJSStringRef];
  1245. END_AX_OBJC_EXCEPTIONS
  1246. return 0;
  1247. }
  1248. JSRetainPtr<JSStringRef> AccessibilityUIElement::mathPrescriptsDescription() const
  1249. {
  1250. BEGIN_AX_OBJC_EXCEPTIONS
  1251. NSArray *pairs = [m_element accessibilityAttributeValue:@"AXMathPrescripts"];
  1252. return [_convertMathMultiscriptPairsToString(pairs) createJSStringRef];
  1253. END_AX_OBJC_EXCEPTIONS
  1254. return 0;
  1255. }
  1256. JSRetainPtr<JSStringRef> AccessibilityUIElement::pathDescription() const
  1257. {
  1258. BEGIN_AX_OBJC_EXCEPTIONS
  1259. NSMutableString *result = [NSMutableString stringWithString:@"\nStart Path\n"];
  1260. NSBezierPath *bezierPath = [m_element accessibilityAttributeValue:NSAccessibilityPathAttribute];
  1261. NSUInteger elementCount = [bezierPath elementCount];
  1262. NSPoint points[3];
  1263. for (NSUInteger i = 0; i < elementCount; i++) {
  1264. switch ([bezierPath elementAtIndex:i associatedPoints:points]) {
  1265. case NSMoveToBezierPathElement:
  1266. [result appendString:@"\tMove to point\n"];
  1267. break;
  1268. case NSLineToBezierPathElement:
  1269. [result appendString:@"\tLine to\n"];
  1270. break;
  1271. case NSCurveToBezierPathElement:
  1272. [result appendString:@"\tCurve to\n"];
  1273. break;
  1274. case NSClosePathBezierPathElement:
  1275. [result appendString:@"\tClose\n"];
  1276. break;
  1277. }
  1278. }
  1279. return [result createJSStringRef];
  1280. END_AX_OBJC_EXCEPTIONS
  1281. return 0;
  1282. }
  1283. JSRetainPtr<JSStringRef> AccessibilityUIElement::supportedActions() const
  1284. {
  1285. BEGIN_AX_OBJC_EXCEPTIONS
  1286. NSArray *names = [m_element accessibilityActionNames];
  1287. return [[names componentsJoinedByString:@","] createJSStringRef];
  1288. END_AX_OBJC_EXCEPTIONS
  1289. return 0;
  1290. }
  1291. } // namespace WTR