[Win] Update DRT Accessibility implementation to better match Mac.
[WebKit-https.git] / Tools / DumpRenderTree / win / AccessibilityUIElementWin.cpp
1 /*
2  * Copyright (C) 2008, 2013, 2014-2015 Apple Inc. All Rights Reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24  */
25
26 #include "config.h"
27 #include "AccessibilityUIElement.h"
28
29 #include "AccessibilityController.h"
30 #include "DumpRenderTree.h"
31 #include "FrameLoadDelegate.h"
32 #include <JavaScriptCore/JSStringRef.h>
33 #include <JavaScriptCore/JSStringRefBSTR.h>
34 #include <wtf/text/WTFString.h>
35 #include <comutil.h>
36 #include <tchar.h>
37 #include <string>
38
39 using std::wstring;
40
41 static COMPtr<IAccessibleComparable> comparableObject(IAccessible* accessible)
42 {
43     COMPtr<IServiceProvider> serviceProvider(Query, accessible);
44     if (!serviceProvider)
45         return 0;
46     COMPtr<IAccessibleComparable> comparable;
47     serviceProvider->QueryService(SID_AccessibleComparable, __uuidof(IAccessibleComparable), reinterpret_cast<void**>(&comparable));
48     return comparable;
49 }
50
51 AccessibilityUIElement::AccessibilityUIElement(PlatformUIElement element)
52     : m_element(element)
53 {
54 }
55
56 AccessibilityUIElement::AccessibilityUIElement(const AccessibilityUIElement& other)
57     : m_element(other.m_element)
58 {
59 }
60
61 AccessibilityUIElement::~AccessibilityUIElement()
62 {
63 }
64
65 bool AccessibilityUIElement::isEqual(AccessibilityUIElement* otherElement)
66 {
67     COMPtr<IAccessibleComparable> comparable = comparableObject(m_element.get());
68     COMPtr<IAccessibleComparable> otherComparable = comparableObject(otherElement->m_element.get());
69     if (!comparable || !otherComparable)
70         return false;
71     BOOL isSame = FALSE;
72     if (FAILED(comparable->isSameObject(otherComparable.get(), &isSame)))
73         return false;
74     return isSame;
75 }
76
77 void AccessibilityUIElement::getLinkedUIElements(Vector<AccessibilityUIElement>&)
78 {
79 }
80
81 void AccessibilityUIElement::getDocumentLinks(Vector<AccessibilityUIElement>&)
82 {
83 }
84
85 void AccessibilityUIElement::getChildren(Vector<AccessibilityUIElement>& children)
86 {
87     if (!m_element)
88         return;
89
90     long childCount;
91     if (FAILED(m_element->get_accChildCount(&childCount)))
92         return;
93     for (long i = 0; i < childCount; ++i)
94         children.append(getChildAtIndex(i));
95 }
96
97 void AccessibilityUIElement::getChildrenWithRange(Vector<AccessibilityUIElement>& elementVector, unsigned location, unsigned length)
98 {
99     if (!m_element)
100         return;
101
102     long childCount;
103     unsigned appendedCount = 0;
104     if (FAILED(m_element->get_accChildCount(&childCount)))
105         return;
106     for (long i = location; i < childCount && appendedCount < length; ++i, ++appendedCount)
107         elementVector.append(getChildAtIndex(i));
108 }
109
110 int AccessibilityUIElement::childrenCount()
111 {
112     if (!m_element)
113         return 0;
114
115     long childCount;
116     if (FAILED(m_element->get_accChildCount(&childCount)))
117         return 0;
118
119     return childCount;
120 }
121
122 int AccessibilityUIElement::rowCount()
123 {
124     // FIXME: implement
125     return 0;
126 }
127  
128 int AccessibilityUIElement::columnCount()
129 {
130     // FIXME: implement
131     return 0;
132 }
133
134 AccessibilityUIElement AccessibilityUIElement::elementAtPoint(int x, int y)
135 {
136     return 0;
137 }
138
139 AccessibilityUIElement AccessibilityUIElement::linkedUIElementAtIndex(unsigned index)
140 {
141     // FIXME: implement
142     return 0;
143 }
144
145 AccessibilityUIElement AccessibilityUIElement::getChildAtIndex(unsigned index)
146 {
147     if (!m_element)
148         return nullptr;
149
150     COMPtr<IDispatch> child;
151     _variant_t vChild;
152     V_VT(&vChild) = VT_I4;
153     // In MSAA, index 0 is the object itself.
154     V_I4(&vChild) = index + 1;
155     if (FAILED(m_element->get_accChild(vChild.GetVARIANT(), &child)))
156         return nullptr;
157     return COMPtr<IAccessible>(Query, child);
158 }
159
160 unsigned AccessibilityUIElement::indexOfChild(AccessibilityUIElement* element)
161
162     // FIXME: implement
163     return 0;
164 }
165
166 JSStringRef AccessibilityUIElement::allAttributes()
167 {
168     return JSStringCreateWithCharacters(0, 0);
169 }
170
171 JSStringRef AccessibilityUIElement::attributesOfLinkedUIElements()
172 {
173     return JSStringCreateWithCharacters(0, 0);
174 }
175
176 JSStringRef AccessibilityUIElement::attributesOfDocumentLinks()
177 {
178     return JSStringCreateWithCharacters(0, 0);
179 }
180
181 AccessibilityUIElement AccessibilityUIElement::titleUIElement()
182 {
183     COMPtr<IAccessible> platformElement = platformUIElement();
184
185     COMPtr<IAccessibleComparable> comparable = comparableObject(platformElement.get());
186     if (!comparable)
187         return 0;
188
189     _variant_t value;
190     _bstr_t titleUIElementAttributeKey(L"AXTitleUIElementAttribute");
191     if (FAILED(comparable->get_attribute(titleUIElementAttributeKey, &value.GetVARIANT())))
192         return nullptr;
193
194     if (V_VT(&value) == VT_EMPTY)
195         return nullptr;
196
197     ASSERT(V_VT(&value) == VT_UNKNOWN);
198
199     if (V_VT(&value) != VT_UNKNOWN)
200         return nullptr;
201
202     COMPtr<IAccessible> titleElement(Query, value.punkVal);
203     if (value.punkVal)
204         value.punkVal->Release();
205
206     return titleElement;
207 }
208
209 AccessibilityUIElement AccessibilityUIElement::parentElement()
210 {
211     if (!m_element)
212         return nullptr;
213
214     COMPtr<IDispatch> parent;
215     m_element->get_accParent(&parent);
216
217     COMPtr<IAccessible> parentAccessible(Query, parent);
218     return parentAccessible;
219 }
220
221 JSStringRef AccessibilityUIElement::attributesOfChildren()
222 {
223     return JSStringCreateWithCharacters(0, 0);
224 }
225
226 JSStringRef AccessibilityUIElement::parameterizedAttributeNames()
227 {
228     return JSStringCreateWithCharacters(0, 0);
229 }
230
231 static VARIANT& self()
232 {
233     static _variant_t vSelf;
234     static bool haveInitialized;
235
236     if (!haveInitialized) {
237         V_VT(&vSelf) = VT_I4;
238         V_I4(&vSelf) = CHILDID_SELF;
239     }
240     return vSelf;
241 }
242
243 static _bstr_t convertToDRTLabel(const _bstr_t roleName)
244 {
245     if (!wcscmp(roleName, L"cell"))
246         return _bstr_t(L"AXCell");
247     if (!wcscmp(roleName, L"check box"))
248         return _bstr_t(L"AXCheckBox");
249     if (!wcscmp(roleName, L"client"))
250         return _bstr_t(L"AXWebArea");
251     if (!wcscmp(roleName, L"column"))
252         return _bstr_t(L"AXColumn");
253     if (!wcscmp(roleName, L"combo box"))
254         return _bstr_t(L"AXComboBox");
255     if (!wcscmp(roleName, L"grouping"))
256         return _bstr_t(L"AXGroup");
257     if (!wcscmp(roleName, L"editable text"))
258         return _bstr_t(L"AXStaticText"); // Might be AXTextField, too.
259     if (!wcscmp(roleName, L"graphic"))
260         return _bstr_t(L"AXImage");
261     if (!wcscmp(roleName, L"link"))
262         return _bstr_t(L"AXLink");
263     if (!wcscmp(roleName, L"list item"))
264         return _bstr_t(L"AXTab");
265     if (!wcscmp(roleName, L"list"))
266         return _bstr_t(L"AXList");
267     if (!wcscmp(roleName, L"menu bar"))
268         return _bstr_t(L"AXMenuBar");
269     if (!wcscmp(roleName, L"page tab list"))
270         return _bstr_t(L"AXTabGroup");
271     if (!wcscmp(roleName, L"page tab"))
272         return _bstr_t(L"AXTab");
273     if (!wcscmp(roleName, L"push button"))
274         return _bstr_t(L"AXButton");
275     if (!wcscmp(roleName, L"progress bar"))
276         return _bstr_t(L"AXProgressIndicator");
277     if (!wcscmp(roleName, L"radio button"))
278         return _bstr_t(L"AXRadioButton");
279     if (!wcscmp(roleName, L"row"))
280         return _bstr_t(L"AXRow");
281     if (!wcscmp(roleName, L"table"))
282         return _bstr_t(L"AXTable");
283     if (!wcscmp(roleName, L"text"))
284         return _bstr_t(L"AXStaticText");
285
286     return roleName;
287 }
288
289 JSStringRef AccessibilityUIElement::role()
290 {
291     if (!m_element)
292         return JSStringCreateWithBSTR(_bstr_t(L"AXRole: "));
293
294     _variant_t vRole;
295     if (FAILED(m_element->get_accRole(self(), &vRole.GetVARIANT())))
296         return JSStringCreateWithBSTR(_bstr_t(L"AXRole: "));
297
298     ASSERT(V_VT(&vRole) == VT_I4 || V_VT(&vRole) == VT_BSTR);
299
300     _bstr_t result;
301     if (V_VT(&vRole) == VT_I4) {
302         unsigned roleTextLength = ::GetRoleText(V_I4(&vRole), nullptr, 0) + 1;
303
304         Vector<TCHAR> roleText(roleTextLength);
305
306         ::GetRoleText(V_I4(&vRole), roleText.data(), roleTextLength);
307
308         result = roleText.data();
309     } else if (V_VT(&vRole) == VT_BSTR)
310         result = V_BSTR(&vRole);
311
312     return JSStringCreateWithBSTR(_bstr_t(L"AXRole: ") + convertToDRTLabel(result));
313 }
314
315 JSStringRef AccessibilityUIElement::subrole()
316 {
317     return 0;
318 }
319
320 JSStringRef AccessibilityUIElement::roleDescription()
321 {
322     return 0;
323 }
324
325 JSStringRef AccessibilityUIElement::computedRoleString()
326 {
327     return 0;
328 }
329
330 JSStringRef AccessibilityUIElement::title()
331 {
332     if (!m_element)
333         return JSStringCreateWithBSTR(_bstr_t(L"AXTitle: "));
334
335     _bstr_t titleBSTR;
336     if (FAILED(m_element->get_accName(self(), &titleBSTR.GetBSTR())))
337         return JSStringCreateWithBSTR(_bstr_t(L"AXTitle: "));
338
339     return JSStringCreateWithBSTR(_bstr_t(L"AXTitle: ") + titleBSTR);
340 }
341
342 JSStringRef AccessibilityUIElement::description()
343 {
344     if (!m_element)
345         return JSStringCreateWithBSTR(_bstr_t(L"AXDescription: "));
346
347     _bstr_t descriptionBSTR;
348     if (FAILED(m_element->get_accDescription(self(), &descriptionBSTR.GetBSTR())))
349         return JSStringCreateWithBSTR(_bstr_t(L"AXDescription: "));
350
351     if (!descriptionBSTR.length())
352         return JSStringCreateWithBSTR(_bstr_t(L"AXDescription: "));
353
354     if (wcsstr(static_cast<wchar_t*>(descriptionBSTR), L"Description: ") == static_cast<wchar_t*>(descriptionBSTR)) {
355         // The Mozilla MSAA implementation requires that the string returned to us be prefixed with "Description: "
356         // To match the Mac test results, we will just prefix with AX -> AXDescription:
357         return JSStringCreateWithBSTR(_bstr_t(L"AX") + descriptionBSTR);
358     }
359
360     return JSStringCreateWithBSTR(descriptionBSTR);
361 }
362
363 JSStringRef AccessibilityUIElement::stringValue()
364 {
365     if (!m_element)
366         return JSStringCreateWithBSTR(_bstr_t(L"AXValue: "));
367
368     _bstr_t valueBSTR;
369     if (FAILED(m_element->get_accValue(self(), &valueBSTR.GetBSTR())))
370         return JSStringCreateWithBSTR(_bstr_t(L"AXValue: "));
371
372     return JSStringCreateWithBSTR(_bstr_t(L"AXValue: ") + valueBSTR);
373 }
374
375 JSStringRef AccessibilityUIElement::language()
376 {
377     return JSStringCreateWithCharacters(0, 0);
378 }
379
380 JSStringRef AccessibilityUIElement::helpText() const
381 {
382     if (!m_element)
383         return JSStringCreateWithBSTR(_bstr_t(L"AXHelp: "));
384
385     _bstr_t helpTextBSTR;
386     if (FAILED(m_element->get_accHelp(self(), &helpTextBSTR.GetBSTR())))
387         return JSStringCreateWithBSTR(_bstr_t(L"AXHelp: "));
388
389     return JSStringCreateWithBSTR(_bstr_t(L"AXHelp: ") + helpTextBSTR);
390 }
391
392 double AccessibilityUIElement::x()
393 {
394     if (!m_element)
395         return 0;
396
397     long x, y, width, height;
398     if (FAILED(m_element->accLocation(&x, &y, &width, &height, self())))
399         return 0;
400     return x;
401 }
402
403 double AccessibilityUIElement::y()
404 {
405     if (!m_element)
406         return 0;
407
408     long x, y, width, height;
409     if (FAILED(m_element->accLocation(&x, &y, &width, &height, self())))
410         return 0;
411     return y;
412 }
413
414 double AccessibilityUIElement::width()
415 {
416     if (!m_element)
417         return 0;
418
419     long x, y, width, height;
420     if (FAILED(m_element->accLocation(&x, &y, &width, &height, self())))
421         return 0;
422     return width;
423 }
424
425 double AccessibilityUIElement::height()
426 {
427     if (!m_element)
428         return 0;
429
430     long x, y, width, height;
431     if (FAILED(m_element->accLocation(&x, &y, &width, &height, self())))
432         return 0;
433     return height;
434 }
435
436 double AccessibilityUIElement::clickPointX()
437 {
438     return 0;
439 }
440
441 double AccessibilityUIElement::clickPointY()
442 {
443     return 0;
444 }
445
446 JSStringRef AccessibilityUIElement::valueDescription()
447 {
448     return nullptr;
449 }
450
451 static DWORD accessibilityState(COMPtr<IAccessible> element)
452 {
453     _variant_t state;
454     if (FAILED(element->get_accState(self(), &state.GetVARIANT())))
455         return 0;
456
457     ASSERT(V_VT(&state) == VT_I4);
458
459     DWORD result = state.lVal;
460
461     return result;
462 }
463
464 bool AccessibilityUIElement::isFocused() const
465 {
466     DWORD state = accessibilityState(m_element);
467     return (state & STATE_SYSTEM_FOCUSED) == STATE_SYSTEM_FOCUSED;
468 }
469
470 bool AccessibilityUIElement::isSelected() const
471 {
472     DWORD state = accessibilityState(m_element);
473     return (state & STATE_SYSTEM_SELECTED) == STATE_SYSTEM_SELECTED;
474 }
475
476 int AccessibilityUIElement::hierarchicalLevel() const
477 {
478     return 0;
479 }
480
481 bool AccessibilityUIElement::ariaIsGrabbed() const
482 {
483     return false;
484 }
485  
486 JSStringRef AccessibilityUIElement::ariaDropEffects() const
487 {
488     return 0;
489 }
490
491 bool AccessibilityUIElement::isExpanded() const
492 {
493     return false;
494 }
495
496 bool AccessibilityUIElement::isChecked() const
497 {
498     if (!m_element)
499         return false;
500
501     _variant_t vState;
502     if (FAILED(m_element->get_accState(self(), &vState.GetVARIANT())))
503         return false;
504
505     return vState.lVal & STATE_SYSTEM_CHECKED;
506 }
507
508 bool AccessibilityUIElement::isIndeterminate() const
509 {
510     // FIXME: implement
511     return false;
512 }
513
514 JSStringRef AccessibilityUIElement::orientation() const
515 {
516     return 0;
517 }
518
519 double AccessibilityUIElement::intValue() const
520 {
521     if (!m_element)
522         return 0;
523
524     _bstr_t valueBSTR;
525     if (FAILED(m_element->get_accValue(self(), &valueBSTR.GetBSTR())) || !valueBSTR.length())
526         return 0;
527
528     TCHAR* ignored;
529     return _tcstod(static_cast<TCHAR*>(valueBSTR), &ignored);
530 }
531
532 double AccessibilityUIElement::minValue()
533 {
534     return 0;
535 }
536
537 double AccessibilityUIElement::maxValue()
538 {
539     return 0;
540 }
541
542 bool AccessibilityUIElement::isPressActionSupported()
543 {
544     if (!m_element)
545         return 0;
546
547     _bstr_t valueBSTR;
548     if (FAILED(m_element->get_accDefaultAction(self(), &valueBSTR.GetBSTR())))
549         return false;
550
551     if (!valueBSTR.length())
552         return false;
553
554     return true;
555 }
556
557 bool AccessibilityUIElement::isIncrementActionSupported()
558 {
559     return false;
560 }
561
562 bool AccessibilityUIElement::isDecrementActionSupported()
563 {
564     return false;
565 }
566
567 bool AccessibilityUIElement::isEnabled()
568 {
569     DWORD state = accessibilityState(m_element);
570     return (state & STATE_SYSTEM_UNAVAILABLE) != STATE_SYSTEM_UNAVAILABLE;
571 }
572
573 bool AccessibilityUIElement::isRequired() const
574 {
575     return false;
576 }
577
578
579 int AccessibilityUIElement::insertionPointLineNumber()
580 {
581     return 0;
582 }
583
584 JSStringRef AccessibilityUIElement::attributesOfColumnHeaders()
585 {
586     return JSStringCreateWithCharacters(0, 0);
587 }
588
589 JSStringRef AccessibilityUIElement::attributesOfRowHeaders()
590 {
591     return JSStringCreateWithCharacters(0, 0);
592 }
593
594 JSStringRef AccessibilityUIElement::attributesOfColumns()
595 {
596     return JSStringCreateWithCharacters(0, 0);
597 }
598
599 JSStringRef AccessibilityUIElement::attributesOfRows()
600 {
601     return JSStringCreateWithCharacters(0, 0);
602 }
603
604 JSStringRef AccessibilityUIElement::attributesOfVisibleCells()
605 {
606     return JSStringCreateWithCharacters(0, 0);
607 }
608
609 JSStringRef AccessibilityUIElement::attributesOfHeader()
610 {
611     return JSStringCreateWithCharacters(0, 0);
612 }
613
614 int AccessibilityUIElement::indexInTable()
615 {
616     return 0;
617 }
618
619 JSStringRef AccessibilityUIElement::rowIndexRange()
620 {
621     return JSStringCreateWithCharacters(0, 0);
622 }
623
624 JSStringRef AccessibilityUIElement::columnIndexRange()
625 {
626     return JSStringCreateWithCharacters(0, 0);
627 }
628
629 int AccessibilityUIElement::lineForIndex(int)
630 {
631     return 0;
632 }
633
634 JSStringRef AccessibilityUIElement::boundsForRange(unsigned location, unsigned length)
635 {
636     return JSStringCreateWithCharacters(0, 0);
637 }
638
639 JSStringRef AccessibilityUIElement::stringForRange(unsigned, unsigned)
640 {
641     return JSStringCreateWithCharacters(0, 0);
642 }
643
644 JSStringRef AccessibilityUIElement::attributedStringForRange(unsigned, unsigned)
645 {
646     return JSStringCreateWithCharacters(0, 0);
647 }
648
649 bool AccessibilityUIElement::attributedStringRangeIsMisspelled(unsigned, unsigned)
650 {
651     return false;
652 }
653
654 unsigned AccessibilityUIElement::uiElementCountForSearchPredicate(JSContextRef context, AccessibilityUIElement* startElement, bool isDirectionNext, JSValueRef searchKey, JSStringRef searchText, bool visibleOnly, bool immediateDescendantsOnly)
655 {
656     return 0;
657 }
658
659 AccessibilityUIElement AccessibilityUIElement::uiElementForSearchPredicate(JSContextRef context, AccessibilityUIElement* startElement, bool isDirectionNext, JSValueRef searchKey, JSStringRef searchText, bool visibleOnly, bool immediateDescendantsOnly)
660 {
661     return 0;
662 }
663
664 JSStringRef AccessibilityUIElement::selectTextWithCriteria(JSContextRef context, JSStringRef ambiguityResolution, JSValueRef searchStrings, JSStringRef replacementString, JSStringRef activity)
665 {
666     return 0;
667 }
668
669 AccessibilityUIElement AccessibilityUIElement::cellForColumnAndRow(unsigned column, unsigned row)
670 {
671     return 0;
672 }
673
674 JSStringRef AccessibilityUIElement::selectedTextRange()
675 {
676     return JSStringCreateWithCharacters(0, 0);    
677 }
678
679 void AccessibilityUIElement::setSelectedTextRange(unsigned location, unsigned length)
680 {
681 }
682
683 JSStringRef AccessibilityUIElement::stringAttributeValue(JSStringRef attribute)
684 {
685     // FIXME: implement
686     return JSStringCreateWithCharacters(0, 0);
687 }
688
689 double AccessibilityUIElement::numberAttributeValue(JSStringRef attribute)
690 {
691     // FIXME: implement
692     return 0;
693 }
694
695 bool AccessibilityUIElement::boolAttributeValue(JSStringRef attribute)
696 {
697     // FIXME: implement
698     return false;
699 }
700
701 bool AccessibilityUIElement::isAttributeSettable(JSStringRef attribute)
702 {
703     return false;
704 }
705
706 bool AccessibilityUIElement::isAttributeSupported(JSStringRef attribute)
707 {
708     return false;
709 }
710
711 void AccessibilityUIElement::increment()
712 {
713 }
714
715 void AccessibilityUIElement::decrement()
716 {
717 }
718
719 void AccessibilityUIElement::showMenu()
720 {
721     if (!m_element)
722         return;
723
724     ASSERT(hasPopup());
725     m_element->accDoDefaultAction(self());
726 }
727
728 void AccessibilityUIElement::press()
729 {
730     if (!m_element)
731         return;
732
733     m_element->accDoDefaultAction(self());
734 }
735
736 AccessibilityUIElement AccessibilityUIElement::disclosedRowAtIndex(unsigned index)
737 {
738     return 0;
739 }
740
741 AccessibilityUIElement AccessibilityUIElement::ariaOwnsElementAtIndex(unsigned index)
742 {
743     return 0;
744 }
745
746 AccessibilityUIElement AccessibilityUIElement::ariaFlowToElementAtIndex(unsigned index)
747 {
748     return 0;
749 }
750
751 AccessibilityUIElement AccessibilityUIElement::ariaControlsElementAtIndex(unsigned index)
752 {
753     return 0;
754 }
755
756 AccessibilityUIElement AccessibilityUIElement::selectedRowAtIndex(unsigned index)
757 {
758     return 0;
759 }
760
761 AccessibilityUIElement AccessibilityUIElement::rowAtIndex(unsigned index)
762 {
763     return 0;
764 }
765
766 AccessibilityUIElement AccessibilityUIElement::disclosedByRow()
767 {
768     return 0;
769 }
770
771 JSStringRef AccessibilityUIElement::accessibilityValue() const
772 {
773     if (!m_element)
774         return JSStringCreateWithCharacters(0, 0);
775
776     _bstr_t valueBSTR;
777     if (FAILED(m_element->get_accValue(self(), &valueBSTR.GetBSTR())) || !valueBSTR.length())
778         return JSStringCreateWithCharacters(0, 0);
779
780     return JSStringCreateWithBSTR(valueBSTR);
781 }
782
783
784 JSStringRef AccessibilityUIElement::documentEncoding()
785 {
786     return JSStringCreateWithCharacters(0, 0);
787 }
788
789 JSStringRef AccessibilityUIElement::documentURI()
790 {
791     return JSStringCreateWithCharacters(0, 0);
792 }
793
794 JSStringRef AccessibilityUIElement::url()
795 {
796     // FIXME: implement
797     return JSStringCreateWithCharacters(0, 0);
798 }
799
800 bool AccessibilityUIElement::addNotificationListener(JSObjectRef functionCallback)
801 {
802     if (!functionCallback)
803         return false;
804
805     sharedFrameLoadDelegate->accessibilityController()->winAddNotificationListener(m_element, functionCallback);
806     return true;
807 }
808
809 void AccessibilityUIElement::removeNotificationListener()
810 {
811     // FIXME: implement
812 }
813
814 bool AccessibilityUIElement::isFocusable() const
815 {
816     // FIXME: implement
817     return false;
818 }
819
820 bool AccessibilityUIElement::isSelectable() const
821 {
822     DWORD state = accessibilityState(m_element);
823     return (state & STATE_SYSTEM_SELECTABLE) == STATE_SYSTEM_SELECTABLE;
824 }
825
826 bool AccessibilityUIElement::isMultiSelectable() const
827 {
828     DWORD multiSelectable = STATE_SYSTEM_EXTSELECTABLE | STATE_SYSTEM_MULTISELECTABLE;
829     DWORD state = accessibilityState(m_element);
830     return (state & multiSelectable) == multiSelectable;
831 }
832
833 bool AccessibilityUIElement::isSelectedOptionActive() const
834 {
835     // FIXME: implement
836     return false;
837 }
838
839 bool AccessibilityUIElement::isVisible() const
840 {
841     DWORD state = accessibilityState(m_element);
842     return (state & STATE_SYSTEM_INVISIBLE) != STATE_SYSTEM_INVISIBLE;
843 }
844
845 bool AccessibilityUIElement::isOffScreen() const
846 {
847     DWORD state = accessibilityState(m_element);
848     return (state & STATE_SYSTEM_OFFSCREEN) == STATE_SYSTEM_OFFSCREEN;
849 }
850
851 bool AccessibilityUIElement::isCollapsed() const
852 {
853     DWORD state = accessibilityState(m_element);
854     return (state & STATE_SYSTEM_COLLAPSED) == STATE_SYSTEM_COLLAPSED;
855 }
856
857 bool AccessibilityUIElement::isIgnored() const
858 {
859     // FIXME: implement
860     return false;
861 }
862
863 bool AccessibilityUIElement::hasPopup() const
864 {
865     DWORD state = accessibilityState(m_element);
866     return (state & STATE_SYSTEM_HASPOPUP) == STATE_SYSTEM_HASPOPUP;
867 }
868
869 void AccessibilityUIElement::takeFocus()
870 {
871     if (!m_element)
872         return;
873
874     m_element->accSelect(SELFLAG_TAKEFOCUS, self());
875 }
876
877 void AccessibilityUIElement::takeSelection()
878 {
879     if (!m_element)
880         return;
881
882     m_element->accSelect(SELFLAG_TAKESELECTION, self());
883 }
884
885 void AccessibilityUIElement::addSelection()
886 {
887     if (!m_element)
888         return;
889
890     m_element->accSelect(SELFLAG_ADDSELECTION, self());
891 }
892
893 void AccessibilityUIElement::removeSelection()
894 {
895     if (!m_element)
896         return;
897
898     m_element->accSelect(SELFLAG_REMOVESELECTION, self());
899 }
900
901 void AccessibilityUIElement::scrollToMakeVisible()
902 {
903     // FIXME: implement
904 }
905
906 void AccessibilityUIElement::scrollToMakeVisibleWithSubFocus(int x, int y, int width, int height)
907 {
908     // FIXME: implement
909 }
910
911 void AccessibilityUIElement::scrollToGlobalPoint(int x, int y)
912 {
913     // FIXME: implement
914 }
915
916 JSStringRef AccessibilityUIElement::classList() const
917 {
918     // FIXME: implement
919     return 0;
920 }
921
922 unsigned AccessibilityUIElement::selectedChildrenCount() const
923 {
924     // FIXME: implement
925     return 0;
926 }
927
928 AccessibilityUIElement AccessibilityUIElement::selectedChildAtIndex(unsigned) const
929 {
930     // FIXME: implement
931     return 0;
932 }
933
934 void AccessibilityUIElement::columnHeaders(Vector<AccessibilityUIElement>&) const
935 {
936     // FIXME: implement
937 }
938
939 void AccessibilityUIElement::rowHeaders(Vector<AccessibilityUIElement>&) const
940 {
941     // FIXME: implement
942 }