123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806 |
- /*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- * Copyright (C) 2009 Jan Michael Alonzo
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
- #include "config.h"
- #include "AccessibilityUIElement.h"
- #include "WebCoreSupport/DumpRenderTreeSupportManx.h"
- #include <JavaScriptCore/JSStringRef.h>
- #include <wtf/Assertions.h>
- #include <wtf/gobject/GOwnPtr.h>
- #include <wtf/gobject/GRefPtr.h>
- // dummy
- #define ATK_ACTION(x) (0)
- #define ATK_IS_ACTION(x) (1)
- #define ATK_OBJECT(x) (0)
- #define ATK_COMPONENT(x) (0)
- #define ATK_IS_VALUE(x) (1)
- #define ATK_VALUE(x) (0)
- #define ATK_XY_SCREEN (1)
- #define G_VALUE_HOLDS_DOUBLE(x) (0)
- #define G_VALUE_HOLDS_INT(x) (0)
- #define ATK_IS_OBJECT(x) (0)
- #define ATK_ROLE_DOCUMENT_FRAME (0)
- static void atk_action_do_action(int, int)
- {
- }
- static void* atk_object_ref_accessible_child(int, int)
- {
- return 0;
- }
- static void atk_component_get_position(int, int*, int*, int)
- {
- }
- static void atk_component_get_size(int, int*, int*)
- {
- }
- // - dummy
- AccessibilityUIElement::AccessibilityUIElement(PlatformUIElement element)
- : m_element(element)
- {
- }
- AccessibilityUIElement::AccessibilityUIElement(const AccessibilityUIElement& other)
- : m_element(other.m_element)
- {
- }
- AccessibilityUIElement::~AccessibilityUIElement()
- {
- }
- void AccessibilityUIElement::getLinkedUIElements(Vector<AccessibilityUIElement>&)
- {
- }
- void AccessibilityUIElement::getDocumentLinks(Vector<AccessibilityUIElement>&)
- {
- }
- void AccessibilityUIElement::getChildren(Vector<AccessibilityUIElement>&)
- {
- #if 0
- int count = childrenCount();
- for (int i = 0; i < count; i++) {
- AtkObject* child = atk_object_ref_accessible_child(ATK_OBJECT(m_element), i);
- children.append(AccessibilityUIElement(child));
- }
- #endif
- }
- void AccessibilityUIElement::getChildrenWithRange(Vector<AccessibilityUIElement>&, unsigned location, unsigned length)
- {
- #if 0
- for (unsigned i = start; i < end; i++) {
- AtkObject* child = atk_object_ref_accessible_child(ATK_OBJECT(m_element), i);
- elementVector.append(AccessibilityUIElement(child));
- }
- #endif
- }
- AccessibilityUIElement AccessibilityUIElement::elementAtPoint(int x, int y)
- {
- return 0;
- }
- AccessibilityUIElement AccessibilityUIElement::getChildAtIndex(unsigned index)
- {
- Vector<AccessibilityUIElement> children;
- getChildrenWithRange(children, index, index + 1);
- if (children.size() == 1)
- return children.at(0);
- return 0;
- }
- unsigned AccessibilityUIElement::indexOfChild(AccessibilityUIElement*)
- {
- return 0;
- }
- int AccessibilityUIElement::childrenCount()
- {
- if (!m_element)
- return 0;
- ASSERT(ATK_IS_OBJECT(m_element));
- // return atk_object_get_n_accessible_children(ATK_OBJECT(m_element))
- }
- AccessibilityUIElement AccessibilityUIElement::titleUIElement()
- {
- return 0;
- }
- AccessibilityUIElement AccessibilityUIElement::parentElement()
- {
- if (!m_element)
- return 0;
- ASSERT(ATK_IS_OBJECT(m_element));
- void* parent = 0;
- // AtkObject* parent = atk_object_get_parent(ATK_OBJECT(m_element));
- return parent ? AccessibilityUIElement(parent) : 0;
- }
- void AccessibilityUIElement::takeFocus()
- {
- }
- void AccessibilityUIElement::takeSelection()
- {
- }
- void AccessibilityUIElement::addSelection()
- {
- }
- void AccessibilityUIElement::removeSelection()
- {
- }
- JSStringRef AccessibilityUIElement::allAttributes()
- {
- if (!m_element)
- return JSStringCreateWithCharacters(0, 0);
- ASSERT(ATK_IS_OBJECT(m_element));
- // return JSStringCreateWithUTF8CString(attributeSetToString(atk_object_get_attributes(ATK_OBJECT(m_element))));
- }
- JSStringRef AccessibilityUIElement::attributesOfLinkedUIElements()
- {
- return JSStringCreateWithCharacters(0, 0);
- }
- AccessibilityUIElement AccessibilityUIElement::linkedUIElementAtIndex(unsigned)
- {
- return 0;
- }
- JSStringRef AccessibilityUIElement::attributesOfDocumentLinks()
- {
- return JSStringCreateWithCharacters(0, 0);
- }
- JSStringRef AccessibilityUIElement::attributesOfChildren()
- {
- return JSStringCreateWithCharacters(0, 0);
- }
- JSStringRef AccessibilityUIElement::parameterizedAttributeNames()
- {
- return JSStringCreateWithCharacters(0, 0);
- }
- void AccessibilityUIElement::increment()
- {
- if (!m_element)
- return;
- ASSERT(ATK_IS_OBJECT(m_element));
- // DumpRenderTreeSupportGtk::incrementAccessibilityValue(ATK_OBJECT(m_element));
- }
- void AccessibilityUIElement::decrement()
- {
- if (!m_element)
- return;
- ASSERT(ATK_IS_OBJECT(m_element));
- // DumpRenderTreeSupportGtk::decrementAccessibilityValue(ATK_OBJECT(m_element));
- }
- void AccessibilityUIElement::showMenu()
- {
- }
- void AccessibilityUIElement::press()
- {
- if (!m_element)
- return;
- ASSERT(ATK_IS_OBJECT(m_element));
- if (!ATK_IS_ACTION(m_element))
- return;
- // Only one action per object is supported so far.
- atk_action_do_action(ATK_ACTION(m_element), 0);
- }
- JSStringRef AccessibilityUIElement::stringAttributeValue(JSStringRef attribute)
- {
- return JSStringCreateWithCharacters(0, 0);
- }
- double AccessibilityUIElement::numberAttributeValue(JSStringRef attribute)
- {
- return 0.0f;
- }
- bool AccessibilityUIElement::boolAttributeValue(JSStringRef attribute)
- {
- return false;
- }
- bool AccessibilityUIElement::isAttributeSupported(JSStringRef attribute)
- {
- return false;
- }
- bool AccessibilityUIElement::isAttributeSettable(JSStringRef attribute)
- {
- return false;
- }
- bool AccessibilityUIElement::isActionSupported(JSStringRef action)
- {
- return false;
- }
- JSStringRef AccessibilityUIElement::role()
- {
- return JSStringRef();
- #if 0
- AtkRole role = atk_object_get_role(ATK_OBJECT(m_element));
- if (!role)
- return JSStringCreateWithCharacters(0, 0);
- const gchar* roleName = atk_role_get_name(role);
- GOwnPtr<gchar> axRole(g_strdup_printf("AXRole: %s", roleName));
- return JSStringCreateWithUTF8CString(axRole.get());
- #endif
- }
- JSStringRef AccessibilityUIElement::subrole()
- {
- return 0;
- }
- JSStringRef AccessibilityUIElement::roleDescription()
- {
- return 0;
- }
- JSStringRef AccessibilityUIElement::title()
- {
- return JSStringRef();
- #if 0
- const gchar* name = atk_object_get_name(ATK_OBJECT(m_element));
- if (!name)
- return JSStringCreateWithCharacters(0, 0);
- GOwnPtr<gchar> axTitle(g_strdup_printf("AXTitle: %s", name));
- return JSStringCreateWithUTF8CString(axTitle.get());
- #endif
- }
- JSStringRef AccessibilityUIElement::description()
- {
- return JSStringCreateWithUTF8CString("AccessibilityUIElement::description");
- #if 0
- const gchar* description = atk_object_get_description(ATK_OBJECT(m_element));
- if (!description)
- return JSStringCreateWithCharacters(0, 0);
- GOwnPtr<gchar> axDesc(g_strdup_printf("AXDescription: %s", description));
- return JSStringCreateWithUTF8CString(axDesc.get());
- #endif
- }
- JSStringRef AccessibilityUIElement::language()
- {
- return JSStringCreateWithCharacters(0, 0);
- }
- JSStringRef AccessibilityUIElement::stringValue()
- {
- return JSStringCreateWithCharacters(0, 0);
- }
- JSStringRef AccessibilityUIElement::accessibilityValue() const
- {
- return JSStringCreateWithCharacters(0, 0);
- }
- JSStringRef AccessibilityUIElement::helpText() const
- {
- return JSStringRef();
- #if 0
- if (!m_element)
- return JSStringCreateWithCharacters(0, 0);
- ASSERT(ATK_IS_OBJECT(m_element));
- CString helpText = DumpRenderTreeSupportGtk::accessibilityHelpText(ATK_OBJECT(m_element));
- GOwnPtr<gchar> axHelpText(g_strdup_printf("AXHelp: %s", helpText.data()));
- return JSStringCreateWithUTF8CString(axHelpText.get());
- #endif
- }
- JSStringRef AccessibilityUIElement::orientation() const
- {
- return 0;
- }
- double AccessibilityUIElement::x()
- {
- int x, y;
- atk_component_get_position(ATK_COMPONENT(m_element), &x, &y, ATK_XY_SCREEN);
- return x;
- }
- double AccessibilityUIElement::y()
- {
- int x, y;
- atk_component_get_position(ATK_COMPONENT(m_element), &x, &y, ATK_XY_SCREEN);
- return y;
- }
- double AccessibilityUIElement::width()
- {
- int width, height;
- atk_component_get_size(ATK_COMPONENT(m_element), &width, &height);
- return width;
- }
- double AccessibilityUIElement::height()
- {
- int width, height;
- atk_component_get_size(ATK_COMPONENT(m_element), &width, &height);
- return height;
- }
- double AccessibilityUIElement::intValue() const
- {
- return 0.0f;
- #if 0
- GValue value = {0, {{0}}};
- if (!ATK_IS_VALUE(m_element))
- return 0.0f;
- atk_value_get_current_value(ATK_VALUE(m_element), &value);
- if (G_VALUE_HOLDS_DOUBLE(&value))
- return g_value_get_double(&value);
- else if (G_VALUE_HOLDS_INT(&value))
- return static_cast<double>(g_value_get_int(&value));
- else
- return 0.0f;
- #endif
- }
- double AccessibilityUIElement::minValue()
- {
- return 0.0f;
- #if 0
- GValue value = {0, {{0}}};
- if (!ATK_IS_VALUE(m_element))
- return 0.0f;
- atk_value_get_minimum_value(ATK_VALUE(m_element), &value);
- if (G_VALUE_HOLDS_DOUBLE(&value))
- return g_value_get_double(&value);
- else if (G_VALUE_HOLDS_INT(&value))
- return static_cast<double>(g_value_get_int(&value));
- else
- return 0.0f;
- #endif
- }
- double AccessibilityUIElement::maxValue()
- {
- return 0.0f;
- #if 0
- GValue value = {0, {{0}}};
- if (!ATK_IS_VALUE(m_element))
- return 0.0f;
- atk_value_get_maximum_value(ATK_VALUE(m_element), &value);
- if (G_VALUE_HOLDS_DOUBLE(&value))
- return g_value_get_double(&value);
- else if (G_VALUE_HOLDS_INT(&value))
- return static_cast<double>(g_value_get_int(&value));
- else
- return 0.0f;
- #endif
- }
- JSStringRef AccessibilityUIElement::valueDescription()
- {
- // FIXME: implement
- return JSStringCreateWithCharacters(0, 0);
- }
- int AccessibilityUIElement::insertionPointLineNumber()
- {
- return 0;
- }
- JSStringRef AccessibilityUIElement::selectedTextRange()
- {
- return JSStringCreateWithCharacters(0, 0);
- }
- bool AccessibilityUIElement::isEnabled()
- {
- return false;
- // return checkElementState(m_element, ATK_STATE_ENABLED);
- }
- bool AccessibilityUIElement::isRequired() const
- {
- return false;
- }
- bool AccessibilityUIElement::isFocused() const
- {
- return false;
- #if 0
- if (!ATK_IS_OBJECT(m_element))
- return false;
- GRefPtr<AtkStateSet> stateSet = adoptGRef(atk_object_ref_state_set(ATK_OBJECT(m_element)));
- gboolean isFocused = atk_state_set_contains_state(stateSet.get(), ATK_STATE_FOCUSED);
- return isFocused;
- #endif
- }
- bool AccessibilityUIElement::isFocusable() const
- {
- return false;
- #if 0
- if (!ATK_IS_OBJECT(m_element))
- return false;
- GRefPtr<AtkStateSet> stateSet = adoptGRef(atk_object_ref_state_set(ATK_OBJECT(m_element)));
- gboolean isFocusable = atk_state_set_contains_state(stateSet.get(), ATK_STATE_FOCUSABLE);
- return isFocusable;
- #endif
- }
- bool AccessibilityUIElement::isSelected() const
- {
- return false;
- // return checkElementState(m_element, ATK_STATE_SELECTED);
- }
- bool AccessibilityUIElement::isSelectable() const
- {
- return false;
- }
- bool AccessibilityUIElement::isMultiSelectable() const
- {
- return false;
- }
- bool AccessibilityUIElement::isSelectedOptionActive() const
- {
- return false;
- }
- bool AccessibilityUIElement::isExpanded() const
- {
- return false;
- #if 0
- if (!ATK_IS_OBJECT(m_element))
- return false;
- GRefPtr<AtkStateSet> stateSet = adoptGRef(atk_object_ref_state_set(ATK_OBJECT(m_element)));
- gboolean isExpanded = atk_state_set_contains_state(stateSet.get(), ATK_STATE_EXPANDED);
- return isExpanded;
- #endif
- }
- bool AccessibilityUIElement::isChecked() const
- {
- return false;
- #if 0
- if (!ATK_IS_OBJECT(m_element))
- return false;
- GRefPtr<AtkStateSet> stateSet = adoptGRef(atk_object_ref_state_set(ATK_OBJECT(m_element)));
- gboolean isChecked = atk_state_set_contains_state(stateSet.get(), ATK_STATE_CHECKED);
- return isChecked;
- #endif
- }
- bool AccessibilityUIElement::isVisible() const
- {
- return false;
- }
- bool AccessibilityUIElement::isOffScreen() const
- {
- return false;
- }
- bool AccessibilityUIElement::isCollapsed() const
- {
- return false;
- }
- bool AccessibilityUIElement::isIgnored() const
- {
- return false;
- }
- bool AccessibilityUIElement::hasPopup() const
- {
- return false;
- }
- int AccessibilityUIElement::hierarchicalLevel() const
- {
- return 0;
- }
- double AccessibilityUIElement::clickPointX()
- {
- return 0.f;
- }
- double AccessibilityUIElement::clickPointY()
- {
- return 0.f;
- }
- JSStringRef AccessibilityUIElement::documentEncoding()
- {
- return JSStringRef();
- #if 0
- AtkRole role = atk_object_get_role(ATK_OBJECT(m_element));
- if (role != ATK_ROLE_DOCUMENT_FRAME)
- return JSStringCreateWithCharacters(0, 0);
- return JSStringCreateWithUTF8CString(atk_document_get_attribute_value(ATK_DOCUMENT(m_element), "Encoding"));
- #endif
- }
- JSStringRef AccessibilityUIElement::documentURI()
- {
- return JSStringRef();
- #if 0
- AtkRole role = atk_object_get_role(ATK_OBJECT(m_element));
- if (role != ATK_ROLE_DOCUMENT_FRAME)
- return JSStringCreateWithCharacters(0, 0);
- return JSStringCreateWithUTF8CString(atk_document_get_attribute_value(ATK_DOCUMENT(m_element), "URI"));
- #endif
- }
- JSStringRef AccessibilityUIElement::url()
- {
- return JSStringCreateWithCharacters(0, 0);
- }
- JSStringRef AccessibilityUIElement::attributesOfColumnHeaders()
- {
- return JSStringCreateWithCharacters(0, 0);
- }
- JSStringRef AccessibilityUIElement::attributesOfRowHeaders()
- {
- return JSStringCreateWithCharacters(0, 0);
- }
- JSStringRef AccessibilityUIElement::attributesOfColumns()
- {
- return JSStringCreateWithCharacters(0, 0);
- }
- JSStringRef AccessibilityUIElement::attributesOfRows()
- {
- return JSStringCreateWithCharacters(0, 0);
- }
- JSStringRef AccessibilityUIElement::attributesOfVisibleCells()
- {
- return JSStringCreateWithCharacters(0, 0);
- }
- JSStringRef AccessibilityUIElement::attributesOfHeader()
- {
- return JSStringCreateWithCharacters(0, 0);
- }
- int AccessibilityUIElement::indexInTable()
- {
- return 0;
- }
- JSStringRef AccessibilityUIElement::rowIndexRange()
- {
- // Range in table for rows.
- // return indexRangeInTable(m_element, true);
- return JSStringRef();
- }
- JSStringRef AccessibilityUIElement::columnIndexRange()
- {
- // Range in table for columns.
- // return indexRangeInTable(m_element, false);
- return JSStringRef();
- }
- int AccessibilityUIElement::rowCount()
- {
- return 0;
- #if 0
- if (!m_element)
- return 0;
- ASSERT(ATK_IS_TABLE(m_element));
- return atk_table_get_n_rows(ATK_TABLE(m_element));
- #endif
- }
- int AccessibilityUIElement::columnCount()
- {
- return 0;
- #if 0
- if (!m_element)
- return 0;
- ASSERT(ATK_IS_TABLE(m_element));
- return atk_table_get_n_columns(ATK_TABLE(m_element));
- #endif
- }
- AccessibilityUIElement AccessibilityUIElement::selectedRowAtIndex(unsigned)
- {
- return 0;
- }
- AccessibilityUIElement AccessibilityUIElement::disclosedByRow()
- {
- return 0;
- }
- AccessibilityUIElement AccessibilityUIElement::disclosedRowAtIndex(unsigned)
- {
- return 0;
- }
- AccessibilityUIElement AccessibilityUIElement::rowAtIndex(unsigned)
- {
- return 0;
- }
- AccessibilityUIElement AccessibilityUIElement::ariaOwnsElementAtIndex(unsigned index)
- {
- return 0;
- }
- AccessibilityUIElement AccessibilityUIElement::ariaFlowToElementAtIndex(unsigned index)
- {
- return 0;
- }
- bool AccessibilityUIElement::ariaIsGrabbed() const
- {
- return false;
- }
-
- JSStringRef AccessibilityUIElement::ariaDropEffects() const
- {
- return 0;
- }
- int AccessibilityUIElement::lineForIndex(int)
- {
- return 0;
- }
- void AccessibilityUIElement::setSelectedTextRange(unsigned location, unsigned length)
- {
- }
- JSStringRef AccessibilityUIElement::stringForRange(unsigned, unsigned)
- {
- return JSStringCreateWithCharacters(0, 0);
- }
- JSStringRef AccessibilityUIElement::attributedStringForRange(unsigned, unsigned)
- {
- return JSStringCreateWithCharacters(0, 0);
- }
- bool AccessibilityUIElement::attributedStringRangeIsMisspelled(unsigned location, unsigned length)
- {
- return false;
- }
- AccessibilityUIElement AccessibilityUIElement::uiElementForSearchPredicate(AccessibilityUIElement* startElement, bool isDirectionNext, JSStringRef searchKey, JSStringRef searchText)
- {
- return 0;
- }
- AccessibilityUIElement AccessibilityUIElement::cellForColumnAndRow(unsigned column, unsigned row)
- {
- return 0;
- #if 0
- if (!m_element)
- return 0;
- ASSERT(ATK_IS_TABLE(m_element));
- AtkObject* foundCell = atk_table_ref_at(ATK_TABLE(m_element), row, column);
- return foundCell ? AccessibilityUIElement(foundCell) : 0;
- #endif
- }
- void AccessibilityUIElement::scrollToMakeVisible()
- {
- }
- void AccessibilityUIElement::scrollToMakeVisibleWithSubFocus(int x, int y, int width, int height)
- {
- }
- void AccessibilityUIElement::scrollToGlobalPoint(int x, int y)
- {
- }
- bool AccessibilityUIElement::addNotificationListener(JSObjectRef functionCallback)
- {
- return false;
- }
- void AccessibilityUIElement::removeNotificationListener()
- {
- }
- JSStringRef AccessibilityUIElement::boundsForRange(unsigned location, unsigned length)
- {
- return JSStringCreateWithCharacters(0, 0);
- }
|