AccessibilityUIElementIOS.mm 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812
  1. /*
  2. * Copyright (C) 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. #import "config.h"
  26. #import "DumpRenderTree.h"
  27. #import "AccessibilityUIElement.h"
  28. #import "AccessibilityCommonMac.h"
  29. #import <Foundation/Foundation.h>
  30. #import <JavaScriptCore/JSRetainPtr.h>
  31. #import <JavaScriptCore/JSStringRef.h>
  32. #import <JavaScriptCore/JSStringRefCF.h>
  33. #import <WebCore/TextGranularity.h>
  34. #import <WebKit/WebFrame.h>
  35. #import <WebKit/WebHTMLView.h>
  36. #import <WebKit/WebTypesInternal.h>
  37. #import <wtf/RetainPtr.h>
  38. #import <wtf/Vector.h>
  39. #if PLATFORM(IOS)
  40. #import <UIKit/UIKit.h>
  41. typedef void (*AXPostedNotificationCallback)(id element, NSString* notification, void* context);
  42. AccessibilityUIElement::AccessibilityUIElement(PlatformUIElement element)
  43. : m_element(element)
  44. {
  45. [m_element retain];
  46. }
  47. AccessibilityUIElement::AccessibilityUIElement(const AccessibilityUIElement& other)
  48. : m_element(other.m_element)
  49. {
  50. [m_element retain];
  51. }
  52. AccessibilityUIElement::~AccessibilityUIElement()
  53. {
  54. [m_element release];
  55. }
  56. @interface NSObject (UIAccessibilityHidden)
  57. - (id)accessibilityHitTest:(CGPoint)point;
  58. - (id)accessibilityLinkedElement;
  59. - (NSRange)accessibilityColumnRange;
  60. - (NSRange)accessibilityRowRange;
  61. - (id)accessibilityElementForRow:(NSInteger)row andColumn:(NSInteger)column;
  62. - (NSURL *)accessibilityURL;
  63. - (NSArray *)accessibilityHeaderElements;
  64. - (NSString *)accessibilityPlaceholderValue;
  65. - (NSString *)stringForRange:(NSRange)range;
  66. - (NSArray *)elementsForRange:(NSRange)range;
  67. - (NSString *)selectionRangeString;
  68. - (CGPoint)accessibilityClickPoint;
  69. - (void)accessibilityModifySelection:(WebCore::TextGranularity)granularity increase:(BOOL)increase;
  70. - (void)accessibilitySetPostedNotificationCallback:(AXPostedNotificationCallback)function withContext:(void*)context;
  71. - (CGFloat)_accessibilityMinValue;
  72. - (CGFloat)_accessibilityMaxValue;
  73. @end
  74. @interface NSObject (WebAccessibilityObjectWrapperPrivate)
  75. - (CGPathRef)_accessibilityPath;
  76. @end
  77. static JSStringRef concatenateAttributeAndValue(NSString* attribute, NSString* value)
  78. {
  79. Vector<UniChar> buffer([attribute length]);
  80. [attribute getCharacters:buffer.data()];
  81. buffer.append(':');
  82. buffer.append(' ');
  83. Vector<UniChar> valueBuffer([value length]);
  84. [value getCharacters:valueBuffer.data()];
  85. buffer.appendVector(valueBuffer);
  86. return JSStringCreateWithCharacters(buffer.data(), buffer.size());
  87. }
  88. #pragma mark iPhone Attributes
  89. JSStringRef AccessibilityUIElement::iphoneLabel()
  90. {
  91. return concatenateAttributeAndValue(@"AXLabel", [m_element accessibilityLabel]);
  92. }
  93. JSStringRef AccessibilityUIElement::iphoneHint()
  94. {
  95. return concatenateAttributeAndValue(@"AXHint", [m_element accessibilityHint]);
  96. }
  97. JSStringRef AccessibilityUIElement::iphoneValue()
  98. {
  99. return concatenateAttributeAndValue(@"AXValue", [m_element accessibilityValue]);
  100. }
  101. JSStringRef AccessibilityUIElement::iphoneIdentifier()
  102. {
  103. return concatenateAttributeAndValue(@"AXIdentifier", [m_element accessibilityIdentifier]);
  104. }
  105. JSStringRef AccessibilityUIElement::iphoneTraits()
  106. {
  107. return concatenateAttributeAndValue(@"AXTraits", [NSString stringWithFormat:@"%qu", [m_element accessibilityTraits]]);
  108. }
  109. bool AccessibilityUIElement::iphoneIsElement()
  110. {
  111. return [m_element isAccessibilityElement];
  112. }
  113. int AccessibilityUIElement::iphoneElementTextPosition()
  114. {
  115. NSRange range = [[m_element valueForKey:@"elementTextRange"] rangeValue];
  116. return range.location;
  117. }
  118. int AccessibilityUIElement::iphoneElementTextLength()
  119. {
  120. NSRange range = [[m_element valueForKey:@"elementTextRange"] rangeValue];
  121. return range.length;
  122. }
  123. JSStringRef AccessibilityUIElement::url()
  124. {
  125. NSURL *url = [m_element accessibilityURL];
  126. return [[url absoluteString] createJSStringRef];
  127. }
  128. double AccessibilityUIElement::x()
  129. {
  130. CGRect frame = [m_element accessibilityFrame];
  131. return frame.origin.x;
  132. }
  133. double AccessibilityUIElement::y()
  134. {
  135. CGRect frame = [m_element accessibilityFrame];
  136. return frame.origin.y;
  137. }
  138. double AccessibilityUIElement::width()
  139. {
  140. CGRect frame = [m_element accessibilityFrame];
  141. return frame.size.width;
  142. }
  143. double AccessibilityUIElement::height()
  144. {
  145. CGRect frame = [m_element accessibilityFrame];
  146. return frame.size.height;
  147. }
  148. double AccessibilityUIElement::clickPointX()
  149. {
  150. CGPoint centerPoint = [m_element accessibilityClickPoint];
  151. return centerPoint.x;
  152. }
  153. double AccessibilityUIElement::clickPointY()
  154. {
  155. CGPoint centerPoint = [m_element accessibilityClickPoint];
  156. return centerPoint.y;
  157. }
  158. void AccessibilityUIElement::getChildren(Vector<AccessibilityUIElement>& elementVector)
  159. {
  160. NSInteger childCount = [m_element accessibilityElementCount];
  161. for (NSInteger k = 0; k < childCount; ++k)
  162. elementVector.append(AccessibilityUIElement([m_element accessibilityElementAtIndex:k]));
  163. }
  164. void AccessibilityUIElement::getChildrenWithRange(Vector<AccessibilityUIElement>& elementVector, unsigned location, unsigned length)
  165. {
  166. NSUInteger childCount = [m_element accessibilityElementCount];
  167. for (NSUInteger k = location; k < childCount && k < (location+length); ++k)
  168. elementVector.append(AccessibilityUIElement([m_element accessibilityElementAtIndex:k]));
  169. }
  170. int AccessibilityUIElement::childrenCount()
  171. {
  172. Vector<AccessibilityUIElement> children;
  173. getChildren(children);
  174. return children.size();
  175. }
  176. AccessibilityUIElement AccessibilityUIElement::elementAtPoint(int x, int y)
  177. {
  178. id element = [m_element accessibilityHitTest:NSMakePoint(x, y)];
  179. if (!element)
  180. return nil;
  181. return AccessibilityUIElement(element);
  182. }
  183. unsigned AccessibilityUIElement::indexOfChild(AccessibilityUIElement* element)
  184. {
  185. return 0;
  186. }
  187. AccessibilityUIElement AccessibilityUIElement::getChildAtIndex(unsigned index)
  188. {
  189. Vector<AccessibilityUIElement> children;
  190. getChildrenWithRange(children, index, 1);
  191. if (children.size() == 1)
  192. return children[0];
  193. return nil;
  194. }
  195. AccessibilityUIElement AccessibilityUIElement::headerElementAtIndex(unsigned index)
  196. {
  197. NSArray *headers = [m_element accessibilityHeaderElements];
  198. if (index < [headers count])
  199. return [headers objectAtIndex:index];
  200. return 0;
  201. }
  202. AccessibilityUIElement AccessibilityUIElement::linkedElement()
  203. {
  204. id linkedElement = [m_element accessibilityLinkedElement];
  205. if (linkedElement)
  206. return AccessibilityUIElement(linkedElement);
  207. return 0;
  208. }
  209. AccessibilityUIElement AccessibilityUIElement::linkedUIElementAtIndex(unsigned index)
  210. {
  211. // FIXME: implement
  212. return 0;
  213. }
  214. AccessibilityUIElement AccessibilityUIElement::ariaOwnsElementAtIndex(unsigned index)
  215. {
  216. return 0;
  217. }
  218. AccessibilityUIElement AccessibilityUIElement::ariaFlowToElementAtIndex(unsigned index)
  219. {
  220. return 0;
  221. }
  222. AccessibilityUIElement AccessibilityUIElement::disclosedRowAtIndex(unsigned index)
  223. {
  224. return 0;
  225. }
  226. AccessibilityUIElement AccessibilityUIElement::selectedRowAtIndex(unsigned index)
  227. {
  228. return 0;
  229. }
  230. AccessibilityUIElement AccessibilityUIElement::rowAtIndex(unsigned index)
  231. {
  232. return 0;
  233. }
  234. AccessibilityUIElement AccessibilityUIElement::titleUIElement()
  235. {
  236. return 0;
  237. }
  238. AccessibilityUIElement AccessibilityUIElement::parentElement()
  239. {
  240. id accessibilityObject = [m_element accessibilityContainer];
  241. if (accessibilityObject)
  242. return AccessibilityUIElement(accessibilityObject);
  243. return nil;
  244. }
  245. AccessibilityUIElement AccessibilityUIElement::disclosedByRow()
  246. {
  247. return 0;
  248. }
  249. void AccessibilityUIElement::increaseTextSelection()
  250. {
  251. [m_element accessibilityModifySelection:WebCore::CharacterGranularity increase:YES];
  252. }
  253. void AccessibilityUIElement::decreaseTextSelection()
  254. {
  255. [m_element accessibilityModifySelection:WebCore::CharacterGranularity increase:NO];
  256. }
  257. JSStringRef AccessibilityUIElement::stringForSelection()
  258. {
  259. NSString *stringForRange = [m_element selectionRangeString];
  260. if (!stringForRange)
  261. return 0;
  262. return [stringForRange createJSStringRef];
  263. }
  264. JSStringRef AccessibilityUIElement::stringForRange(unsigned location, unsigned length)
  265. {
  266. NSString *stringForRange = [m_element stringForRange:NSMakeRange(location, length)];
  267. if (!stringForRange)
  268. return 0;
  269. return [stringForRange createJSStringRef];
  270. }
  271. JSStringRef AccessibilityUIElement::attributedStringForRange(unsigned, unsigned)
  272. {
  273. return JSStringCreateWithCharacters(0, 0);
  274. }
  275. bool AccessibilityUIElement::attributedStringRangeIsMisspelled(unsigned, unsigned)
  276. {
  277. return false;
  278. }
  279. void AccessibilityUIElement::elementsForRange(unsigned location, unsigned length, Vector<AccessibilityUIElement>& elements)
  280. {
  281. NSArray *elementsForRange = [m_element elementsForRange:NSMakeRange(location, length)];
  282. for (id object in elementsForRange) {
  283. AccessibilityUIElement element = AccessibilityUIElement(object);
  284. elements.append(element);
  285. }
  286. }
  287. static void _CGPathEnumerationIteration(void *info, const CGPathElement *element)
  288. {
  289. NSMutableString *result = (NSMutableString *)info;
  290. switch (element->type) {
  291. case kCGPathElementMoveToPoint:
  292. [result appendString:@"\tMove to point\n"];
  293. break;
  294. case kCGPathElementAddLineToPoint:
  295. [result appendString:@"\tLine to\n"];
  296. break;
  297. case kCGPathElementAddQuadCurveToPoint:
  298. [result appendString:@"\tQuad curve to\n"];
  299. break;
  300. case kCGPathElementAddCurveToPoint:
  301. [result appendString:@"\tCurve to\n"];
  302. break;
  303. case kCGPathElementCloseSubpath:
  304. [result appendString:@"\tClose\n"];
  305. break;
  306. }
  307. }
  308. JSStringRef AccessibilityUIElement::pathDescription() const
  309. {
  310. NSMutableString *result = [NSMutableString stringWithString:@"\nStart Path\n"];
  311. CGPathRef pathRef = [m_element _accessibilityPath];
  312. CGPathApply(pathRef, result, _CGPathEnumerationIteration);
  313. return [result createJSStringRef];
  314. }
  315. #pragma mark Unused
  316. void AccessibilityUIElement::getLinkedUIElements(Vector<AccessibilityUIElement>& elementVector)
  317. {
  318. }
  319. void AccessibilityUIElement::getDocumentLinks(Vector<AccessibilityUIElement>& elementVector)
  320. {
  321. }
  322. JSStringRef AccessibilityUIElement::attributesOfLinkedUIElements()
  323. {
  324. return JSStringCreateWithCharacters(0, 0);
  325. }
  326. JSStringRef AccessibilityUIElement::attributesOfDocumentLinks()
  327. {
  328. return JSStringCreateWithCharacters(0, 0);
  329. }
  330. JSStringRef AccessibilityUIElement::attributesOfChildren()
  331. {
  332. return JSStringCreateWithCharacters(0, 0);
  333. }
  334. JSStringRef AccessibilityUIElement::allAttributes()
  335. {
  336. return JSStringCreateWithCharacters(0, 0);
  337. }
  338. JSStringRef AccessibilityUIElement::stringAttributeValue(JSStringRef attribute)
  339. {
  340. if (JSStringIsEqualToUTF8CString(attribute, "AXPlaceholderValue"))
  341. return [[m_element accessibilityPlaceholderValue] createJSStringRef];
  342. return JSStringCreateWithCharacters(0, 0);
  343. }
  344. bool AccessibilityUIElement::isPressActionSupported()
  345. {
  346. return false;
  347. }
  348. bool AccessibilityUIElement::isIncrementActionSupported()
  349. {
  350. return false;
  351. }
  352. bool AccessibilityUIElement::isDecrementActionSupported()
  353. {
  354. return false;
  355. }
  356. bool AccessibilityUIElement::boolAttributeValue(JSStringRef attribute)
  357. {
  358. return false;
  359. }
  360. bool AccessibilityUIElement::isAttributeSettable(JSStringRef attribute)
  361. {
  362. return false;
  363. }
  364. bool AccessibilityUIElement::isAttributeSupported(JSStringRef attribute)
  365. {
  366. return false;
  367. }
  368. JSStringRef AccessibilityUIElement::parameterizedAttributeNames()
  369. {
  370. return JSStringCreateWithCharacters(0, 0);
  371. }
  372. JSStringRef AccessibilityUIElement::role()
  373. {
  374. return JSStringCreateWithCharacters(0, 0);
  375. }
  376. JSStringRef AccessibilityUIElement::subrole()
  377. {
  378. return JSStringCreateWithCharacters(0, 0);
  379. }
  380. JSStringRef AccessibilityUIElement::roleDescription()
  381. {
  382. return JSStringCreateWithCharacters(0, 0);
  383. }
  384. JSStringRef AccessibilityUIElement::title()
  385. {
  386. return JSStringCreateWithCharacters(0, 0);
  387. }
  388. JSStringRef AccessibilityUIElement::description()
  389. {
  390. return JSStringCreateWithCharacters(0, 0);
  391. }
  392. JSStringRef AccessibilityUIElement::orientation() const
  393. {
  394. return JSStringCreateWithCharacters(0, 0);
  395. }
  396. JSStringRef AccessibilityUIElement::stringValue()
  397. {
  398. return JSStringCreateWithCharacters(0, 0);
  399. }
  400. JSStringRef AccessibilityUIElement::language()
  401. {
  402. return JSStringCreateWithCharacters(0, 0);
  403. }
  404. JSStringRef AccessibilityUIElement::helpText() const
  405. {
  406. return JSStringCreateWithCharacters(0, 0);
  407. }
  408. double AccessibilityUIElement::intValue() const
  409. {
  410. return 0.0f;
  411. }
  412. double AccessibilityUIElement::minValue()
  413. {
  414. return [m_element _accessibilityMinValue];
  415. }
  416. double AccessibilityUIElement::maxValue()
  417. {
  418. return [m_element _accessibilityMaxValue];
  419. }
  420. JSStringRef AccessibilityUIElement::valueDescription()
  421. {
  422. return JSStringCreateWithCharacters(0, 0);
  423. }
  424. int AccessibilityUIElement::insertionPointLineNumber()
  425. {
  426. return -1;
  427. }
  428. bool AccessibilityUIElement::isEnabled()
  429. {
  430. return false;
  431. }
  432. bool AccessibilityUIElement::isRequired() const
  433. {
  434. return false;
  435. }
  436. bool AccessibilityUIElement::isFocused() const
  437. {
  438. // FIXME: implement
  439. return false;
  440. }
  441. bool AccessibilityUIElement::isSelected() const
  442. {
  443. UIAccessibilityTraits traits = [m_element accessibilityTraits];
  444. return (traits & UIAccessibilityTraitSelected);
  445. }
  446. bool AccessibilityUIElement::isExpanded() const
  447. {
  448. return false;
  449. }
  450. bool AccessibilityUIElement::isChecked() const
  451. {
  452. return false;
  453. }
  454. int AccessibilityUIElement::hierarchicalLevel() const
  455. {
  456. return 0;
  457. }
  458. bool AccessibilityUIElement::ariaIsGrabbed() const
  459. {
  460. return false;
  461. }
  462. JSStringRef AccessibilityUIElement::ariaDropEffects() const
  463. {
  464. return JSStringCreateWithCharacters(0, 0);
  465. }
  466. int AccessibilityUIElement::lineForIndex(int index)
  467. {
  468. return -1;
  469. }
  470. JSStringRef AccessibilityUIElement::boundsForRange(unsigned location, unsigned length)
  471. {
  472. return JSStringCreateWithCharacters(0, 0);
  473. }
  474. JSStringRef AccessibilityUIElement::attributesOfColumnHeaders()
  475. {
  476. return JSStringCreateWithCharacters(0, 0);
  477. }
  478. JSStringRef AccessibilityUIElement::attributesOfRowHeaders()
  479. {
  480. return JSStringCreateWithCharacters(0, 0);
  481. }
  482. JSStringRef AccessibilityUIElement::attributesOfColumns()
  483. {
  484. return JSStringCreateWithCharacters(0, 0);
  485. }
  486. JSStringRef AccessibilityUIElement::attributesOfRows()
  487. {
  488. return JSStringCreateWithCharacters(0, 0);
  489. }
  490. JSStringRef AccessibilityUIElement::attributesOfVisibleCells()
  491. {
  492. return JSStringCreateWithCharacters(0, 0);
  493. }
  494. JSStringRef AccessibilityUIElement::attributesOfHeader()
  495. {
  496. return JSStringCreateWithCharacters(0, 0);
  497. }
  498. int AccessibilityUIElement::rowCount()
  499. {
  500. return -1;
  501. }
  502. int AccessibilityUIElement::columnCount()
  503. {
  504. return -1;
  505. }
  506. int AccessibilityUIElement::indexInTable()
  507. {
  508. return -1;
  509. }
  510. JSStringRef AccessibilityUIElement::rowIndexRange()
  511. {
  512. NSRange range = [m_element accessibilityRowRange];
  513. NSMutableString* rangeDescription = [NSMutableString stringWithFormat:@"{%lu, %lu}", (unsigned long)range.location, (unsigned long)range.length];
  514. return [rangeDescription createJSStringRef];
  515. }
  516. JSStringRef AccessibilityUIElement::columnIndexRange()
  517. {
  518. NSRange range = [m_element accessibilityColumnRange];
  519. NSMutableString* rangeDescription = [NSMutableString stringWithFormat:@"{%lu, %lu}", (unsigned long)range.location, (unsigned long)range.length];
  520. return [rangeDescription createJSStringRef];
  521. }
  522. AccessibilityUIElement AccessibilityUIElement::cellForColumnAndRow(unsigned col, unsigned row)
  523. {
  524. return AccessibilityUIElement([m_element accessibilityElementForRow:row andColumn:col]);
  525. }
  526. JSStringRef AccessibilityUIElement::selectedTextRange()
  527. {
  528. return JSStringCreateWithCharacters(0, 0);
  529. }
  530. void AccessibilityUIElement::assistiveTechnologySimulatedFocus()
  531. {
  532. [m_element accessibilityElementDidBecomeFocused];
  533. }
  534. void AccessibilityUIElement::setSelectedTextRange(unsigned location, unsigned length)
  535. {
  536. }
  537. void AccessibilityUIElement::increment()
  538. {
  539. [m_element accessibilityIncrement];
  540. }
  541. void AccessibilityUIElement::decrement()
  542. {
  543. [m_element accessibilityDecrement];
  544. }
  545. void AccessibilityUIElement::showMenu()
  546. {
  547. }
  548. void AccessibilityUIElement::press()
  549. {
  550. }
  551. JSStringRef AccessibilityUIElement::accessibilityValue() const
  552. {
  553. // FIXME: implement
  554. return JSStringCreateWithCharacters(0, 0);
  555. }
  556. JSStringRef AccessibilityUIElement::documentEncoding()
  557. {
  558. return JSStringCreateWithCharacters(0, 0);
  559. }
  560. JSStringRef AccessibilityUIElement::documentURI()
  561. {
  562. return JSStringCreateWithCharacters(0, 0);
  563. }
  564. static void _accessibilityNotificationCallback(id element, NSString* notification, void* context)
  565. {
  566. if (!context)
  567. return;
  568. JSObjectRef functionCallback = static_cast<JSObjectRef>(context);
  569. JSRetainPtr<JSStringRef> jsNotification(Adopt, [notification createJSStringRef]);
  570. JSValueRef argument = JSValueMakeString([mainFrame globalContext], jsNotification.get());
  571. JSObjectCallAsFunction([mainFrame globalContext], functionCallback, NULL, 1, &argument, NULL);
  572. }
  573. bool AccessibilityUIElement::addNotificationListener(JSObjectRef functionCallback)
  574. {
  575. if (!functionCallback)
  576. return false;
  577. m_notificationFunctionCallback = functionCallback;
  578. [platformUIElement() accessibilitySetPostedNotificationCallback:_accessibilityNotificationCallback withContext:reinterpret_cast<void*>(m_notificationFunctionCallback)];
  579. return true;
  580. }
  581. void AccessibilityUIElement::removeNotificationListener()
  582. {
  583. m_notificationFunctionCallback = 0;
  584. [platformUIElement() accessibilitySetPostedNotificationCallback:nil withContext:nil];
  585. }
  586. bool AccessibilityUIElement::isFocusable() const
  587. {
  588. // FIXME: implement
  589. return false;
  590. }
  591. bool AccessibilityUIElement::isSelectable() const
  592. {
  593. // FIXME: implement
  594. return false;
  595. }
  596. bool AccessibilityUIElement::isMultiSelectable() const
  597. {
  598. // FIXME: implement
  599. return false;
  600. }
  601. bool AccessibilityUIElement::isSelectedOptionActive() const
  602. {
  603. // FIXME: implement
  604. return false;
  605. }
  606. bool AccessibilityUIElement::isVisible() const
  607. {
  608. // FIXME: implement
  609. return false;
  610. }
  611. bool AccessibilityUIElement::isOffScreen() const
  612. {
  613. // FIXME: implement
  614. return false;
  615. }
  616. bool AccessibilityUIElement::isCollapsed() const
  617. {
  618. // FIXME: implement
  619. return false;
  620. }
  621. bool AccessibilityUIElement::isIgnored() const
  622. {
  623. // FIXME: implement
  624. return false;
  625. }
  626. bool AccessibilityUIElement::hasPopup() const
  627. {
  628. // FIXME: implement
  629. return false;
  630. }
  631. void AccessibilityUIElement::takeFocus()
  632. {
  633. // FIXME: implement
  634. }
  635. void AccessibilityUIElement::takeSelection()
  636. {
  637. // FIXME: implement
  638. }
  639. void AccessibilityUIElement::addSelection()
  640. {
  641. // FIXME: implement
  642. }
  643. void AccessibilityUIElement::removeSelection()
  644. {
  645. // FIXME: implement
  646. }
  647. AccessibilityUIElement AccessibilityUIElement::uiElementForSearchPredicate(JSContextRef context, AccessibilityUIElement* startElement, bool isDirectionNext, JSValueRef searchKey, JSStringRef searchText, bool visibleOnly)
  648. {
  649. // FIXME: implement
  650. return 0;
  651. }
  652. double AccessibilityUIElement::numberAttributeValue(JSStringRef attribute)
  653. {
  654. // FIXME: implement
  655. return 0;
  656. }
  657. #endif // PLATFORM(IOS)