0bfe9ac96fce9bf767d6b33991ac8d47726740ab
[WebKit-https.git] / Tools / WebKitTestRunner / InjectedBundle / atk / AccessibilityUIElementAtk.cpp
1 /*
2  * Copyright (C) 2011 Apple Inc. All Rights Reserved.
3  * Copyright (C) 2012 Igalia S.L.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
15  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
18  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26
27 #include "config.h"
28 #include "AccessibilityUIElement.h"
29
30 #include "InjectedBundle.h"
31 #include "InjectedBundlePage.h"
32 #include <JavaScriptCore/JSStringRef.h>
33 #include <atk/atk.h>
34 #include <gtk/gtk.h>
35 #include <wtf/Assertions.h>
36 #include <wtf/gobject/GOwnPtr.h>
37 #include <wtf/gobject/GRefPtr.h>
38 #include <wtf/text/CString.h>
39 #include <wtf/text/WTFString.h>
40 #include <wtf/unicode/CharacterNames.h>
41
42 namespace WTR {
43
44 static gchar* attributeSetToString(AtkAttributeSet* attributeSet)
45 {
46     GString* str = g_string_new(0);
47     for (GSList* attributes = attributeSet; attributes; attributes = attributes->next) {
48         AtkAttribute* attribute = static_cast<AtkAttribute*>(attributes->data);
49         GOwnPtr<gchar> attributeData(g_strconcat(attribute->name, ":", attribute->value, NULL));
50         g_string_append(str, attributeData.get());
51         if (attributes->next)
52             g_string_append(str, ", ");
53     }
54
55     return g_string_free(str, FALSE);
56 }
57
58 static bool checkElementState(PlatformUIElement element, AtkStateType stateType)
59 {
60     if (!ATK_IS_OBJECT(element))
61         return false;
62
63     GRefPtr<AtkStateSet> stateSet = adoptGRef(atk_object_ref_state_set(ATK_OBJECT(element)));
64     return atk_state_set_contains_state(stateSet.get(), stateType);
65 }
66
67 static JSStringRef indexRangeInTable(PlatformUIElement element, bool isRowRange)
68 {
69     GOwnPtr<gchar> rangeString(g_strdup("{0, 0}"));
70
71     if (!element || !ATK_IS_OBJECT(element))
72         return JSStringCreateWithUTF8CString(rangeString.get());
73
74     AtkObject* axTable = atk_object_get_parent(ATK_OBJECT(element));
75     if (!axTable || !ATK_IS_TABLE(axTable))
76         return JSStringCreateWithUTF8CString(rangeString.get());
77
78     // Look for the cell in the table.
79     gint indexInParent = atk_object_get_index_in_parent(ATK_OBJECT(element));
80     if (indexInParent == -1)
81         return JSStringCreateWithUTF8CString(rangeString.get());
82
83     int row = -1;
84     int column = -1;
85     row = atk_table_get_row_at_index(ATK_TABLE(axTable), indexInParent);
86     column = atk_table_get_column_at_index(ATK_TABLE(axTable), indexInParent);
87
88     // Get the actual values, if row and columns are valid values.
89     if (row != -1 && column != -1) {
90         int base = 0;
91         int length = 0;
92         if (isRowRange) {
93             base = row;
94             length = atk_table_get_row_extent_at(ATK_TABLE(axTable), row, column);
95         } else {
96             base = column;
97             length = atk_table_get_column_extent_at(ATK_TABLE(axTable), row, column);
98         }
99         rangeString.set(g_strdup_printf("{%d, %d}", base, length));
100     }
101
102     return JSStringCreateWithUTF8CString(rangeString.get());
103 }
104
105 static void alterCurrentValue(PlatformUIElement element, int factor)
106 {
107     if (!element || !ATK_IS_VALUE(element))
108         return;
109
110     GValue currentValue = G_VALUE_INIT;
111     atk_value_get_current_value(ATK_VALUE(element), &currentValue);
112
113     GValue increment = G_VALUE_INIT;
114     atk_value_get_minimum_increment(ATK_VALUE(element), &increment);
115
116     GValue newValue = G_VALUE_INIT;
117     g_value_init(&newValue, G_TYPE_DOUBLE);
118
119     g_value_set_float(&newValue, g_value_get_float(&currentValue) + factor * g_value_get_float(&increment));
120     atk_value_set_current_value(ATK_VALUE(element), &newValue);
121
122     g_value_unset(&newValue);
123     g_value_unset(&increment);
124     g_value_unset(&currentValue);
125 }
126
127 static gchar* replaceCharactersForResults(gchar* str)
128 {
129     WTF::String uString = WTF::String::fromUTF8(str);
130
131     // The object replacement character is passed along to ATs so we need to be
132     // able to test for their presence and do so without causing test failures.
133     uString.replace(objectReplacementCharacter, "<obj>");
134
135     // The presence of newline characters in accessible text of a single object
136     // is appropriate, but it makes test results (especially the accessible tree)
137     // harder to read.
138     uString.replace("\n", "<\\n>");
139
140     return g_strdup(uString.utf8().data());
141 }
142
143 AccessibilityUIElement::AccessibilityUIElement(PlatformUIElement element)
144     : m_element(element)
145 {
146 }
147
148 AccessibilityUIElement::AccessibilityUIElement(const AccessibilityUIElement& other)
149     : JSWrappable()
150     , m_element(other.m_element)
151 {
152 }
153
154 AccessibilityUIElement::~AccessibilityUIElement()
155 {
156 }
157
158 bool AccessibilityUIElement::isEqual(AccessibilityUIElement* otherElement)
159 {
160     return m_element == otherElement->platformUIElement();
161 }
162
163 void AccessibilityUIElement::getChildren(Vector<RefPtr<AccessibilityUIElement> >& children)
164 {
165     if (!m_element || !ATK_IS_OBJECT(m_element))
166         return;
167
168     int count = childrenCount();
169     for (int i = 0; i < count; i++) {
170         AtkObject* child = atk_object_ref_accessible_child(ATK_OBJECT(m_element), i);
171         children.append(AccessibilityUIElement::create(child));
172     }
173 }
174
175 void AccessibilityUIElement::getChildrenWithRange(Vector<RefPtr<AccessibilityUIElement> >& children, unsigned location, unsigned length)
176 {
177     if (!m_element || !ATK_IS_OBJECT(m_element))
178         return;
179     unsigned end = location + length;
180     for (unsigned i = location; i < end; i++) {
181         AtkObject* child = atk_object_ref_accessible_child(ATK_OBJECT(m_element), i);
182         children.append(AccessibilityUIElement::create(child));
183     }
184 }
185
186 int AccessibilityUIElement::childrenCount()
187 {
188     if (!m_element)
189         return 0;
190
191     return atk_object_get_n_accessible_children(ATK_OBJECT(m_element));
192 }
193
194 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::elementAtPoint(int x, int y)
195 {
196     // FIXME: implement
197     return 0;
198 }
199
200 unsigned AccessibilityUIElement::indexOfChild(AccessibilityUIElement* element)
201 {
202     if (!m_element || !ATK_IS_OBJECT(m_element))
203         return 0;
204
205     Vector<RefPtr<AccessibilityUIElement> > children;
206     getChildren(children);
207
208     unsigned count = children.size();
209     for (unsigned i = 0; i < count; i++)
210         if (children[i]->isEqual(element))
211             return i;
212
213     return 0;
214 }
215
216 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::childAtIndex(unsigned index)
217 {
218     Vector<RefPtr<AccessibilityUIElement> > children;
219     getChildrenWithRange(children, index, 1);
220
221     if (children.size() == 1)
222         return children[0];
223
224     return 0;
225 }
226
227 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::linkedUIElementAtIndex(unsigned index)
228 {
229     // FIXME: implement
230     return 0;
231 }
232
233 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::ariaOwnsElementAtIndex(unsigned index)
234 {
235     // FIXME: implement
236     return 0;
237 }
238
239 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::ariaFlowToElementAtIndex(unsigned index)
240 {
241     // FIXME: implement
242     return 0;
243 }
244
245 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::disclosedRowAtIndex(unsigned index)
246 {
247     // FIXME: implement
248     return 0;
249 }
250
251 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::rowAtIndex(unsigned index)
252 {
253     // FIXME: implement
254     return 0;
255 }
256
257 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::selectedChildAtIndex(unsigned index) const
258 {
259     // FIXME: implement
260     return 0;
261 }
262
263 unsigned AccessibilityUIElement::selectedChildrenCount() const
264 {
265     // FIXME: implement
266     return 0;
267 }
268
269 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::selectedRowAtIndex(unsigned index)
270 {
271     // FIXME: implement
272     return 0;
273 }
274
275 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::titleUIElement()
276 {
277     // FIXME: implement
278     return 0;
279 }
280
281 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::parentElement()
282 {
283     if (!m_element || !ATK_IS_OBJECT(m_element))
284         return 0;
285
286     AtkObject* parent = atk_object_get_parent(ATK_OBJECT(m_element));
287     return parent ? AccessibilityUIElement::create(parent) : 0;
288 }
289
290 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::disclosedByRow()
291 {
292     // FIXME: implement
293     return 0;
294 }
295
296 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfLinkedUIElements()
297 {
298     // FIXME: implement
299     return JSStringCreateWithCharacters(0, 0);
300 }
301
302 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfDocumentLinks()
303 {
304     // FIXME: implement
305     return JSStringCreateWithCharacters(0, 0);
306 }
307
308 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfChildren()
309 {
310     // FIXME: implement
311     return JSStringCreateWithCharacters(0, 0);
312 }
313
314 JSRetainPtr<JSStringRef> AccessibilityUIElement::allAttributes()
315 {
316     if (!m_element || !ATK_IS_OBJECT(m_element))
317         return JSStringCreateWithCharacters(0, 0);
318
319     GOwnPtr<gchar> attributeData(attributeSetToString(atk_object_get_attributes(ATK_OBJECT(m_element))));
320     return JSStringCreateWithUTF8CString(attributeData.get());
321 }
322
323 JSRetainPtr<JSStringRef> AccessibilityUIElement::stringAttributeValue(JSStringRef attribute)
324 {
325     // FIXME: implement
326     return JSStringCreateWithCharacters(0, 0);
327 }
328
329 double AccessibilityUIElement::numberAttributeValue(JSStringRef attribute)
330 {
331     // FIXME: implement
332     return 0.0f;
333 }
334
335 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::uiElementAttributeValue(JSStringRef attribute) const
336 {
337     // FIXME: implement
338     return 0;
339 }
340
341 bool AccessibilityUIElement::boolAttributeValue(JSStringRef attribute)
342 {
343     // FIXME: implement
344     return false;
345 }
346
347 bool AccessibilityUIElement::isAttributeSettable(JSStringRef attribute)
348 {
349     // FIXME: implement
350     return false;
351 }
352
353 bool AccessibilityUIElement::isAttributeSupported(JSStringRef attribute)
354 {
355     // FIXME: implement
356     return false;
357 }
358
359 JSRetainPtr<JSStringRef> AccessibilityUIElement::parameterizedAttributeNames()
360 {
361     // FIXME: implement
362     return JSStringCreateWithCharacters(0, 0);
363 }
364
365 JSRetainPtr<JSStringRef> AccessibilityUIElement::role()
366 {
367     if (!m_element || !ATK_IS_OBJECT(m_element))
368         return JSStringCreateWithCharacters(0, 0);
369
370     AtkRole role = atk_object_get_role(ATK_OBJECT(m_element));
371     if (!role)
372         return JSStringCreateWithCharacters(0, 0);
373
374     const gchar* roleName = atk_role_get_name(role);
375     GOwnPtr<gchar> axRole(g_strdup_printf("AXRole: %s", roleName));
376
377     return JSStringCreateWithUTF8CString(axRole.get());
378 }
379
380 JSRetainPtr<JSStringRef> AccessibilityUIElement::subrole()
381 {
382     // FIXME: implement
383     return JSStringCreateWithCharacters(0, 0);
384 }
385
386 JSRetainPtr<JSStringRef> AccessibilityUIElement::roleDescription()
387 {
388     // FIXME: implement
389     return JSStringCreateWithCharacters(0, 0);
390 }
391
392 JSRetainPtr<JSStringRef> AccessibilityUIElement::title()
393 {
394     if (!m_element || !ATK_IS_OBJECT(m_element))
395         return JSStringCreateWithCharacters(0, 0);
396
397     const gchar* name = atk_object_get_name(ATK_OBJECT(m_element));
398     if (!name)
399         return JSStringCreateWithCharacters(0, 0);
400
401     GOwnPtr<gchar> axTitle(g_strdup_printf("AXTitle: %s", name));
402
403     return JSStringCreateWithUTF8CString(axTitle.get());
404 }
405
406 JSRetainPtr<JSStringRef> AccessibilityUIElement::description()
407 {
408     if (!m_element || !ATK_IS_OBJECT(m_element))
409         return JSStringCreateWithCharacters(0, 0);
410
411     const gchar* description = atk_object_get_description(ATK_OBJECT(m_element));
412     if (!description)
413         return JSStringCreateWithCharacters(0, 0);
414
415     GOwnPtr<gchar> axDesc(g_strdup_printf("AXDescription: %s", description));
416
417     return JSStringCreateWithUTF8CString(axDesc.get());
418 }
419
420 JSRetainPtr<JSStringRef> AccessibilityUIElement::orientation() const
421 {
422     // FIXME: implement
423     return JSStringCreateWithCharacters(0, 0);
424 }
425
426 JSRetainPtr<JSStringRef> AccessibilityUIElement::stringValue()
427 {
428     if (!m_element || !ATK_IS_TEXT(m_element))
429         return JSStringCreateWithCharacters(0, 0);
430
431     GOwnPtr<gchar> text(atk_text_get_text(ATK_TEXT(m_element), 0, -1));
432     GOwnPtr<gchar> textWithReplacedCharacters(replaceCharactersForResults(text.get()));
433     GOwnPtr<gchar> axValue(g_strdup_printf("AXValue: %s", textWithReplacedCharacters.get()));
434
435     return JSStringCreateWithUTF8CString(axValue.get());
436 }
437
438 JSRetainPtr<JSStringRef> AccessibilityUIElement::language()
439 {
440     // FIXME: implement
441     return JSStringCreateWithCharacters(0, 0);
442 }
443
444 JSRetainPtr<JSStringRef> AccessibilityUIElement::helpText() const
445 {
446     // FIXME: implement
447     // We need a way to call WebCore::AccessibilityObject::helpText()
448     // from here, probably a new helper class in WebProcess/WebCoreSupport.
449     return JSStringCreateWithCharacters(0, 0);
450 }
451
452 double AccessibilityUIElement::x()
453 {
454     if (!m_element || !ATK_IS_OBJECT(m_element))
455         return 0.0f;
456
457     int x, y;
458     atk_component_get_position(ATK_COMPONENT(m_element), &x, &y, ATK_XY_SCREEN);
459     return x;
460 }
461
462 double AccessibilityUIElement::y()
463 {
464     if (!m_element || !ATK_IS_OBJECT(m_element))
465         return 0.0f;
466
467     int x, y;
468     atk_component_get_position(ATK_COMPONENT(m_element), &x, &y, ATK_XY_SCREEN);
469     return y;
470 }
471
472 double AccessibilityUIElement::width()
473 {
474     if (!m_element || !ATK_IS_OBJECT(m_element))
475         return 0.0f;
476
477     int width, height;
478     atk_component_get_size(ATK_COMPONENT(m_element), &width, &height);
479     return width;
480 }
481
482 double AccessibilityUIElement::height()
483 {
484     if (!m_element || !ATK_IS_OBJECT(m_element))
485         return 0.0f;
486
487     int width, height;
488     atk_component_get_size(ATK_COMPONENT(m_element), &width, &height);
489     return height;
490 }
491
492 double AccessibilityUIElement::clickPointX()
493 {
494     // FIXME: implement
495     return 0.0f;
496 }
497
498 double AccessibilityUIElement::clickPointY()
499 {
500     // FIXME: implement
501     return 0.0f;
502 }
503
504 double AccessibilityUIElement::intValue() const
505 {
506     if (!m_element || !ATK_IS_OBJECT(m_element))
507         return 0.0f;
508
509     GValue value = G_VALUE_INIT;
510     atk_value_get_current_value(ATK_VALUE(m_element), &value);
511     if (!G_VALUE_HOLDS_FLOAT(&value))
512         return 0.0f;
513
514     return g_value_get_float(&value);
515 }
516
517 double AccessibilityUIElement::minValue()
518 {
519     if (!m_element || !ATK_IS_OBJECT(m_element))
520         return 0.0f;
521
522     GValue value = G_VALUE_INIT;
523     atk_value_get_minimum_value(ATK_VALUE(m_element), &value);
524     if (!G_VALUE_HOLDS_FLOAT(&value))
525         return 0.0f;
526
527     return g_value_get_float(&value);
528 }
529
530 double AccessibilityUIElement::maxValue()
531 {
532     if (!m_element || !ATK_IS_OBJECT(m_element))
533         return 0.0f;
534
535     GValue value = G_VALUE_INIT;
536     atk_value_get_maximum_value(ATK_VALUE(m_element), &value);
537     if (!G_VALUE_HOLDS_FLOAT(&value))
538         return 0.0f;
539
540     return g_value_get_float(&value);
541 }
542
543 JSRetainPtr<JSStringRef> AccessibilityUIElement::valueDescription()
544 {
545     // FIXME: implement
546     return JSStringCreateWithCharacters(0, 0);
547 }
548
549 int AccessibilityUIElement::insertionPointLineNumber()
550 {
551     // FIXME: implement
552     return -1;
553 }
554
555 bool AccessibilityUIElement::isActionSupported(JSStringRef action)
556 {
557     // FIXME: implement
558     return false;
559 }
560
561 bool AccessibilityUIElement::isEnabled()
562 {
563     return checkElementState(m_element, ATK_STATE_ENABLED);
564 }
565
566 bool AccessibilityUIElement::isRequired() const
567 {
568     // FIXME: implement
569     return false;
570 }
571
572 bool AccessibilityUIElement::isFocused() const
573 {
574     return checkElementState(m_element, ATK_STATE_FOCUSED);
575 }
576
577 bool AccessibilityUIElement::isSelected() const
578 {
579     return checkElementState(m_element, ATK_STATE_SELECTED);
580 }
581
582 bool AccessibilityUIElement::isExpanded() const
583 {
584     return checkElementState(m_element, ATK_STATE_EXPANDED);
585 }
586
587 bool AccessibilityUIElement::isChecked() const
588 {
589     return checkElementState(m_element, ATK_STATE_CHECKED);
590 }
591
592 int AccessibilityUIElement::hierarchicalLevel() const
593 {
594     // FIXME: implement
595     return 0;
596 }
597
598 JSRetainPtr<JSStringRef> AccessibilityUIElement::speak()
599 {
600     // FIXME: implement
601     return JSStringCreateWithCharacters(0, 0);
602 }
603
604 bool AccessibilityUIElement::ariaIsGrabbed() const
605 {
606     // FIXME: implement
607     return false;
608 }
609
610 JSRetainPtr<JSStringRef> AccessibilityUIElement::ariaDropEffects() const
611 {
612     // FIXME: implement
613     return JSStringCreateWithCharacters(0, 0);
614 }
615
616 // parameterized attributes
617 int AccessibilityUIElement::lineForIndex(int index)
618 {
619     // FIXME: implement
620     return 0;
621 }
622
623 JSRetainPtr<JSStringRef> AccessibilityUIElement::rangeForLine(int line)
624 {
625     // FIXME: implement
626     return JSStringCreateWithCharacters(0, 0);
627 }
628
629 JSRetainPtr<JSStringRef> AccessibilityUIElement::rangeForPosition(int x, int y)
630 {
631     // FIXME: implement
632     return JSStringCreateWithCharacters(0, 0);
633 }
634
635 JSRetainPtr<JSStringRef> AccessibilityUIElement::boundsForRange(unsigned location, unsigned length)
636 {
637     // FIXME: implement
638     return JSStringCreateWithCharacters(0, 0);
639 }
640
641 JSRetainPtr<JSStringRef> AccessibilityUIElement::stringForRange(unsigned location, unsigned length)
642 {
643     // FIXME: implement
644     return JSStringCreateWithCharacters(0, 0);
645 }
646
647 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributedStringForRange(unsigned location, unsigned length)
648 {
649     // FIXME: implement
650     return JSStringCreateWithCharacters(0, 0);
651 }
652
653 bool AccessibilityUIElement::attributedStringRangeIsMisspelled(unsigned location, unsigned length)
654 {
655     // FIXME: implement
656     return false;
657 }
658
659 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::uiElementForSearchPredicate(AccessibilityUIElement* startElement, bool isDirectionNext, JSStringRef searchKey, JSStringRef searchText)
660 {
661     // FIXME: implement
662     return 0;
663 }
664
665 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfColumnHeaders()
666 {
667     // FIXME: implement
668     return JSStringCreateWithCharacters(0, 0);
669 }
670
671 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfRowHeaders()
672 {
673     // FIXME: implement
674     return JSStringCreateWithCharacters(0, 0);
675 }
676
677 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfColumns()
678 {
679     // FIXME: implement
680     return JSStringCreateWithCharacters(0, 0);
681 }
682
683 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfRows()
684 {
685     // FIXME: implement
686     return JSStringCreateWithCharacters(0, 0);
687 }
688
689 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfVisibleCells()
690 {
691     // FIXME: implement
692     return JSStringCreateWithCharacters(0, 0);
693 }
694
695 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributesOfHeader()
696 {
697     // FIXME: implement
698     return JSStringCreateWithCharacters(0, 0);
699 }
700
701 int AccessibilityUIElement::rowCount()
702 {
703     if (!m_element || !ATK_IS_TABLE(m_element))
704         return 0;
705
706     return atk_table_get_n_rows(ATK_TABLE(m_element));
707 }
708
709 int AccessibilityUIElement::columnCount()
710 {
711     if (!m_element || !ATK_IS_TABLE(m_element))
712         return 0;
713
714     return atk_table_get_n_columns(ATK_TABLE(m_element));
715 }
716
717 int AccessibilityUIElement::indexInTable()
718 {
719     // FIXME: implement
720     return -1;
721 }
722
723 JSRetainPtr<JSStringRef> AccessibilityUIElement::rowIndexRange()
724 {
725     // Range in table for rows.
726     return indexRangeInTable(m_element, true);
727 }
728
729 JSRetainPtr<JSStringRef> AccessibilityUIElement::columnIndexRange()
730 {
731     // Range in table for columns.
732     return indexRangeInTable(m_element, false);
733 }
734
735 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::cellForColumnAndRow(unsigned col, unsigned row)
736 {
737     if (!m_element || !ATK_IS_TABLE(m_element))
738         return 0;
739
740     AtkObject* foundCell = atk_table_ref_at(ATK_TABLE(m_element), row, col);
741     return foundCell ? AccessibilityUIElement::create(foundCell) : 0;
742 }
743
744 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::horizontalScrollbar() const
745 {
746     // FIXME: implement
747     return 0;
748 }
749
750 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::verticalScrollbar() const
751 {
752     // FIXME: implement
753     return 0;
754 }
755
756 JSRetainPtr<JSStringRef> AccessibilityUIElement::selectedTextRange()
757 {
758     // FIXME: implement
759     return JSStringCreateWithCharacters(0, 0);
760 }
761
762 void AccessibilityUIElement::setSelectedTextRange(unsigned location, unsigned length)
763 {
764     // FIXME: implement
765 }
766
767 void AccessibilityUIElement::increment()
768 {
769     alterCurrentValue(m_element, 1);
770 }
771
772 void AccessibilityUIElement::decrement()
773 {
774     alterCurrentValue(m_element, -1);
775 }
776
777 void AccessibilityUIElement::showMenu()
778 {
779     // FIXME: implement
780 }
781
782 void AccessibilityUIElement::press()
783 {
784     if (!m_element || !ATK_IS_OBJECT(m_element))
785         return;
786
787     if (!ATK_IS_ACTION(m_element))
788         return;
789
790     // Only one action per object is supported so far.
791     atk_action_do_action(ATK_ACTION(m_element), 0);
792 }
793
794 void AccessibilityUIElement::setSelectedChild(AccessibilityUIElement* element) const
795 {
796     // FIXME: implement
797 }
798
799 JSRetainPtr<JSStringRef> AccessibilityUIElement::accessibilityValue() const
800 {
801     // FIXME: implement
802     return JSStringCreateWithCharacters(0, 0);
803 }
804
805 JSRetainPtr<JSStringRef> AccessibilityUIElement::documentEncoding()
806 {
807     if (!m_element || !ATK_IS_OBJECT(m_element))
808         return JSStringCreateWithCharacters(0, 0);
809
810     AtkRole role = atk_object_get_role(ATK_OBJECT(m_element));
811     if (role != ATK_ROLE_DOCUMENT_FRAME)
812         return JSStringCreateWithCharacters(0, 0);
813
814     return JSStringCreateWithUTF8CString(atk_document_get_attribute_value(ATK_DOCUMENT(m_element), "Encoding"));
815 }
816
817 JSRetainPtr<JSStringRef> AccessibilityUIElement::documentURI()
818 {
819     if (!m_element || !ATK_IS_OBJECT(m_element))
820         return JSStringCreateWithCharacters(0, 0);
821
822     AtkRole role = atk_object_get_role(ATK_OBJECT(m_element));
823     if (role != ATK_ROLE_DOCUMENT_FRAME)
824         return JSStringCreateWithCharacters(0, 0);
825
826     return JSStringCreateWithUTF8CString(atk_document_get_attribute_value(ATK_DOCUMENT(m_element), "URI"));
827 }
828
829 JSRetainPtr<JSStringRef> AccessibilityUIElement::url()
830 {
831     // FIXME: implement
832     return JSStringCreateWithCharacters(0, 0);
833 }
834
835 bool AccessibilityUIElement::addNotificationListener(JSValueRef functionCallback)
836 {
837     // FIXME: implement
838     return true;
839 }
840
841 bool AccessibilityUIElement::removeNotificationListener()
842 {
843     // FIXME: implement
844     return true;
845 }
846
847 bool AccessibilityUIElement::isFocusable() const
848 {
849     return checkElementState(m_element, ATK_STATE_FOCUSABLE);
850 }
851
852 bool AccessibilityUIElement::isSelectable() const
853 {
854     return checkElementState(m_element, ATK_STATE_SELECTABLE);
855 }
856
857 bool AccessibilityUIElement::isMultiSelectable() const
858 {
859     return checkElementState(m_element, ATK_STATE_MULTISELECTABLE);
860 }
861
862 bool AccessibilityUIElement::isVisible() const
863 {
864     return checkElementState(m_element, ATK_STATE_VISIBLE);
865 }
866
867 bool AccessibilityUIElement::isOffScreen() const
868 {
869     // FIXME: implement
870     return false;
871 }
872
873 bool AccessibilityUIElement::isCollapsed() const
874 {
875     // FIXME: implement
876     return false;
877 }
878
879 bool AccessibilityUIElement::isIgnored() const
880 {
881     // FIXME: implement
882     return false;
883 }
884
885 bool AccessibilityUIElement::hasPopup() const
886 {
887     // FIXME: implement
888     return false;
889 }
890
891 void AccessibilityUIElement::takeFocus()
892 {
893     // FIXME: implement
894 }
895
896 void AccessibilityUIElement::takeSelection()
897 {
898     // FIXME: implement
899 }
900
901 void AccessibilityUIElement::addSelection()
902 {
903     // FIXME: implement
904 }
905
906 void AccessibilityUIElement::removeSelection()
907 {
908     // FIXME: implement
909 }
910
911 // Text markers
912 PassRefPtr<AccessibilityTextMarkerRange> AccessibilityUIElement::textMarkerRangeForElement(AccessibilityUIElement* element)
913 {
914     // FIXME: implement
915     return 0;
916 }
917
918 int AccessibilityUIElement::textMarkerRangeLength(AccessibilityTextMarkerRange* range)
919 {
920     // FIXME: implement
921     return 0;
922 }
923
924 PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::previousTextMarker(AccessibilityTextMarker* textMarker)
925 {
926     // FIXME: implement
927     return 0;
928 }
929
930 PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::nextTextMarker(AccessibilityTextMarker* textMarker)
931 {
932     // FIXME: implement
933     return 0;
934 }
935
936 JSRetainPtr<JSStringRef> AccessibilityUIElement::stringForTextMarkerRange(AccessibilityTextMarkerRange* markerRange)
937 {
938     // FIXME: implement
939     return JSStringCreateWithCharacters(0, 0);
940 }
941
942 PassRefPtr<AccessibilityTextMarkerRange> AccessibilityUIElement::textMarkerRangeForMarkers(AccessibilityTextMarker* startMarker, AccessibilityTextMarker* endMarker)
943 {
944     // FIXME: implement
945     return 0;
946 }
947
948 PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::startTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange* range)
949 {
950     // FIXME: implement
951     return 0;
952 }
953
954 PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::endTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange* range)
955 {
956     // FIXME: implement
957     return 0;
958 }
959
960 PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::textMarkerForPoint(int x, int y)
961 {
962     // FIXME: implement
963     return 0;
964 }
965
966 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::accessibilityElementForTextMarker(AccessibilityTextMarker* marker)
967 {
968     // FIXME: implement
969     return 0;
970 }
971
972 bool AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute(JSStringRef attribute, AccessibilityTextMarkerRange* range)
973 {
974     // FIXME: implement
975     return false;
976 }
977
978 int AccessibilityUIElement::indexForTextMarker(AccessibilityTextMarker* marker)
979 {
980     // FIXME: implement
981     return -1;
982 }
983
984 bool AccessibilityUIElement::isTextMarkerValid(AccessibilityTextMarker* textMarker)
985 {
986     // FIXME: implement
987     return false;
988 }
989
990 PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::textMarkerForIndex(int textIndex)
991 {
992     // FIXME: implement
993     return 0;
994 }
995
996
997 } // namespace WTR