From 9665c7cafbc7882234e12e719e951b89dbe8de7b Mon Sep 17 00:00:00 2001 From: "commit-queue@webkit.org" Date: Mon, 11 Feb 2013 11:51:43 +0000 Subject: [PATCH] [GTK][EFL] Shares WebKit-GTK's DumpRenderTree accessibility implementation with other Webkit ports https://bugs.webkit.org/show_bug.cgi?id=105007 Patch by Krzysztof Czech on 2013-02-11 Reviewed by Martin Robinson. Shares specific ATK's accessibility implementation. Keeps platform specific methods in EFL and GTK's directories. * DumpRenderTree/atk/AccessibilityCallbacks.h: Renamed from Tools/DumpRenderTree/gtk/AccessibilityCallbacks.h. * DumpRenderTree/atk/AccessibilityCallbacksAtk.cpp: Renamed from Tools/DumpRenderTree/gtk/AccessibilityCallbacks.cpp. (printAccessibilityEvent): (axObjectEventListener): (connectAccessibilityCallbacks): (disconnectAccessibilityCallbacks): * DumpRenderTree/atk/AccessibilityControllerAtk.cpp: Copied from Tools/DumpRenderTree/gtk/AccessibilityControllerGtk.cpp. (AccessibilityController::AccessibilityController): (AccessibilityController::~AccessibilityController): (AccessibilityController::elementAtPoint): (AccessibilityController::setLogFocusEvents): (AccessibilityController::setLogScrollingStartEvents): (AccessibilityController::setLogValueChangeEvents): (AccessibilityController::setLogAccessibilityEvents): (AccessibilityController::addNotificationListener): (AccessibilityController::removeNotificationListener): * DumpRenderTree/atk/AccessibilityUIElementAtk.cpp: Copied from Tools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp. (coreAttributeToAtkAttribute): (roleToString): (replaceCharactersForResults): (AccessibilityUIElement::AccessibilityUIElement): (AccessibilityUIElement::~AccessibilityUIElement): (AccessibilityUIElement::getLinkedUIElements): (AccessibilityUIElement::getDocumentLinks): (AccessibilityUIElement::getChildren): (AccessibilityUIElement::getChildrenWithRange): (AccessibilityUIElement::rowCount): (AccessibilityUIElement::columnCount): (AccessibilityUIElement::childrenCount): (AccessibilityUIElement::elementAtPoint): (AccessibilityUIElement::linkedUIElementAtIndex): (AccessibilityUIElement::getChildAtIndex): (AccessibilityUIElement::indexOfChild): (attributeSetToString): (AccessibilityUIElement::allAttributes): (AccessibilityUIElement::attributesOfLinkedUIElements): (AccessibilityUIElement::attributesOfDocumentLinks): (AccessibilityUIElement::titleUIElement): (AccessibilityUIElement::parentElement): (AccessibilityUIElement::attributesOfChildren): (AccessibilityUIElement::parameterizedAttributeNames): (AccessibilityUIElement::role): (AccessibilityUIElement::subrole): (AccessibilityUIElement::roleDescription): (AccessibilityUIElement::title): (AccessibilityUIElement::description): (AccessibilityUIElement::stringValue): (AccessibilityUIElement::language): (AccessibilityUIElement::x): (AccessibilityUIElement::y): (AccessibilityUIElement::width): (AccessibilityUIElement::height): (AccessibilityUIElement::clickPointX): (AccessibilityUIElement::clickPointY): (AccessibilityUIElement::orientation): (AccessibilityUIElement::intValue): (AccessibilityUIElement::minValue): (AccessibilityUIElement::maxValue): (AccessibilityUIElement::valueDescription): (checkElementState): (AccessibilityUIElement::isEnabled): (AccessibilityUIElement::insertionPointLineNumber): (AccessibilityUIElement::isPressActionSupported): (AccessibilityUIElement::isIncrementActionSupported): (AccessibilityUIElement::isDecrementActionSupported): (AccessibilityUIElement::isRequired): (AccessibilityUIElement::isFocused): (AccessibilityUIElement::isSelected): (AccessibilityUIElement::hierarchicalLevel): (AccessibilityUIElement::ariaIsGrabbed): (AccessibilityUIElement::ariaDropEffects): (AccessibilityUIElement::isExpanded): (AccessibilityUIElement::isChecked): (AccessibilityUIElement::attributesOfColumnHeaders): (AccessibilityUIElement::attributesOfRowHeaders): (AccessibilityUIElement::attributesOfColumns): (AccessibilityUIElement::attributesOfRows): (AccessibilityUIElement::attributesOfVisibleCells): (AccessibilityUIElement::attributesOfHeader): (AccessibilityUIElement::indexInTable): (indexRangeInTable): (AccessibilityUIElement::rowIndexRange): (AccessibilityUIElement::columnIndexRange): (AccessibilityUIElement::lineForIndex): (AccessibilityUIElement::boundsForRange): (AccessibilityUIElement::stringForRange): (AccessibilityUIElement::attributedStringForRange): (AccessibilityUIElement::attributedStringRangeIsMisspelled): (AccessibilityUIElement::uiElementForSearchPredicate): (AccessibilityUIElement::cellForColumnAndRow): (AccessibilityUIElement::selectedTextRange): (AccessibilityUIElement::setSelectedTextRange): (AccessibilityUIElement::stringAttributeValue): (AccessibilityUIElement::numberAttributeValue): (AccessibilityUIElement::boolAttributeValue): (AccessibilityUIElement::isAttributeSettable): (AccessibilityUIElement::isAttributeSupported): (alterCurrentValue): (AccessibilityUIElement::increment): (AccessibilityUIElement::decrement): (AccessibilityUIElement::press): (AccessibilityUIElement::showMenu): (AccessibilityUIElement::disclosedRowAtIndex): (AccessibilityUIElement::ariaOwnsElementAtIndex): (AccessibilityUIElement::ariaFlowToElementAtIndex): (AccessibilityUIElement::selectedRowAtIndex): (AccessibilityUIElement::rowAtIndex): (AccessibilityUIElement::disclosedByRow): (AccessibilityUIElement::accessibilityValue): (AccessibilityUIElement::documentEncoding): (AccessibilityUIElement::documentURI): (AccessibilityUIElement::url): (AccessibilityUIElement::addNotificationListener): (AccessibilityUIElement::removeNotificationListener): (AccessibilityUIElement::isFocusable): (AccessibilityUIElement::isSelectable): (AccessibilityUIElement::isMultiSelectable): (AccessibilityUIElement::isSelectedOptionActive): (AccessibilityUIElement::isVisible): (AccessibilityUIElement::isOffScreen): (AccessibilityUIElement::isCollapsed): (AccessibilityUIElement::isIgnored): (AccessibilityUIElement::hasPopup): (AccessibilityUIElement::takeFocus): (AccessibilityUIElement::takeSelection): (AccessibilityUIElement::addSelection): (AccessibilityUIElement::removeSelection): (AccessibilityUIElement::scrollToMakeVisible): (AccessibilityUIElement::scrollToMakeVisibleWithSubFocus): (AccessibilityUIElement::scrollToGlobalPoint): * DumpRenderTree/efl/CMakeLists.txt: Adds ATK headers, libraries, new sources. * DumpRenderTree/gtk/AccessibilityControllerGtk.cpp: (AccessibilityController::focusedElement): (AccessibilityController::rootElement): (AccessibilityController::accessibleElementById): * DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp: (AccessibilityUIElement::helpText): * GNUmakefile.am: Adds renamed sources. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@142451 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Tools/ChangeLog | 149 +++ .../{gtk => atk}/AccessibilityCallbacks.h | 0 .../AccessibilityCallbacksAtk.cpp} | 55 +- .../atk/AccessibilityControllerAtk.cpp | 91 ++ .../atk/AccessibilityUIElementAtk.cpp | 1049 +++++++++++++++++ Tools/DumpRenderTree/efl/CMakeLists.txt | 2 + .../gtk/AccessibilityControllerGtk.cpp | 88 +- .../gtk/AccessibilityUIElementGtk.cpp | 1008 ---------------- Tools/GNUmakefile.am | 7 +- 9 files changed, 1347 insertions(+), 1102 deletions(-) rename Tools/DumpRenderTree/{gtk => atk}/AccessibilityCallbacks.h (100%) rename Tools/DumpRenderTree/{gtk/AccessibilityCallbacks.cpp => atk/AccessibilityCallbacksAtk.cpp} (83%) create mode 100644 Tools/DumpRenderTree/atk/AccessibilityControllerAtk.cpp create mode 100644 Tools/DumpRenderTree/atk/AccessibilityUIElementAtk.cpp diff --git a/Tools/ChangeLog b/Tools/ChangeLog index bec38daa14b3..1b6ac20259e9 100644 --- a/Tools/ChangeLog +++ b/Tools/ChangeLog @@ -1,3 +1,152 @@ +2013-02-11 Krzysztof Czech + + [GTK][EFL] Shares WebKit-GTK's DumpRenderTree accessibility implementation with other Webkit ports + https://bugs.webkit.org/show_bug.cgi?id=105007 + + Reviewed by Martin Robinson. + + Shares specific ATK's accessibility implementation. + Keeps platform specific methods in EFL and GTK's directories. + + * DumpRenderTree/atk/AccessibilityCallbacks.h: Renamed from Tools/DumpRenderTree/gtk/AccessibilityCallbacks.h. + * DumpRenderTree/atk/AccessibilityCallbacksAtk.cpp: Renamed from Tools/DumpRenderTree/gtk/AccessibilityCallbacks.cpp. + (printAccessibilityEvent): + (axObjectEventListener): + (connectAccessibilityCallbacks): + (disconnectAccessibilityCallbacks): + * DumpRenderTree/atk/AccessibilityControllerAtk.cpp: Copied from Tools/DumpRenderTree/gtk/AccessibilityControllerGtk.cpp. + (AccessibilityController::AccessibilityController): + (AccessibilityController::~AccessibilityController): + (AccessibilityController::elementAtPoint): + (AccessibilityController::setLogFocusEvents): + (AccessibilityController::setLogScrollingStartEvents): + (AccessibilityController::setLogValueChangeEvents): + (AccessibilityController::setLogAccessibilityEvents): + (AccessibilityController::addNotificationListener): + (AccessibilityController::removeNotificationListener): + * DumpRenderTree/atk/AccessibilityUIElementAtk.cpp: Copied from Tools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp. + (coreAttributeToAtkAttribute): + (roleToString): + (replaceCharactersForResults): + (AccessibilityUIElement::AccessibilityUIElement): + (AccessibilityUIElement::~AccessibilityUIElement): + (AccessibilityUIElement::getLinkedUIElements): + (AccessibilityUIElement::getDocumentLinks): + (AccessibilityUIElement::getChildren): + (AccessibilityUIElement::getChildrenWithRange): + (AccessibilityUIElement::rowCount): + (AccessibilityUIElement::columnCount): + (AccessibilityUIElement::childrenCount): + (AccessibilityUIElement::elementAtPoint): + (AccessibilityUIElement::linkedUIElementAtIndex): + (AccessibilityUIElement::getChildAtIndex): + (AccessibilityUIElement::indexOfChild): + (attributeSetToString): + (AccessibilityUIElement::allAttributes): + (AccessibilityUIElement::attributesOfLinkedUIElements): + (AccessibilityUIElement::attributesOfDocumentLinks): + (AccessibilityUIElement::titleUIElement): + (AccessibilityUIElement::parentElement): + (AccessibilityUIElement::attributesOfChildren): + (AccessibilityUIElement::parameterizedAttributeNames): + (AccessibilityUIElement::role): + (AccessibilityUIElement::subrole): + (AccessibilityUIElement::roleDescription): + (AccessibilityUIElement::title): + (AccessibilityUIElement::description): + (AccessibilityUIElement::stringValue): + (AccessibilityUIElement::language): + (AccessibilityUIElement::x): + (AccessibilityUIElement::y): + (AccessibilityUIElement::width): + (AccessibilityUIElement::height): + (AccessibilityUIElement::clickPointX): + (AccessibilityUIElement::clickPointY): + (AccessibilityUIElement::orientation): + (AccessibilityUIElement::intValue): + (AccessibilityUIElement::minValue): + (AccessibilityUIElement::maxValue): + (AccessibilityUIElement::valueDescription): + (checkElementState): + (AccessibilityUIElement::isEnabled): + (AccessibilityUIElement::insertionPointLineNumber): + (AccessibilityUIElement::isPressActionSupported): + (AccessibilityUIElement::isIncrementActionSupported): + (AccessibilityUIElement::isDecrementActionSupported): + (AccessibilityUIElement::isRequired): + (AccessibilityUIElement::isFocused): + (AccessibilityUIElement::isSelected): + (AccessibilityUIElement::hierarchicalLevel): + (AccessibilityUIElement::ariaIsGrabbed): + (AccessibilityUIElement::ariaDropEffects): + (AccessibilityUIElement::isExpanded): + (AccessibilityUIElement::isChecked): + (AccessibilityUIElement::attributesOfColumnHeaders): + (AccessibilityUIElement::attributesOfRowHeaders): + (AccessibilityUIElement::attributesOfColumns): + (AccessibilityUIElement::attributesOfRows): + (AccessibilityUIElement::attributesOfVisibleCells): + (AccessibilityUIElement::attributesOfHeader): + (AccessibilityUIElement::indexInTable): + (indexRangeInTable): + (AccessibilityUIElement::rowIndexRange): + (AccessibilityUIElement::columnIndexRange): + (AccessibilityUIElement::lineForIndex): + (AccessibilityUIElement::boundsForRange): + (AccessibilityUIElement::stringForRange): + (AccessibilityUIElement::attributedStringForRange): + (AccessibilityUIElement::attributedStringRangeIsMisspelled): + (AccessibilityUIElement::uiElementForSearchPredicate): + (AccessibilityUIElement::cellForColumnAndRow): + (AccessibilityUIElement::selectedTextRange): + (AccessibilityUIElement::setSelectedTextRange): + (AccessibilityUIElement::stringAttributeValue): + (AccessibilityUIElement::numberAttributeValue): + (AccessibilityUIElement::boolAttributeValue): + (AccessibilityUIElement::isAttributeSettable): + (AccessibilityUIElement::isAttributeSupported): + (alterCurrentValue): + (AccessibilityUIElement::increment): + (AccessibilityUIElement::decrement): + (AccessibilityUIElement::press): + (AccessibilityUIElement::showMenu): + (AccessibilityUIElement::disclosedRowAtIndex): + (AccessibilityUIElement::ariaOwnsElementAtIndex): + (AccessibilityUIElement::ariaFlowToElementAtIndex): + (AccessibilityUIElement::selectedRowAtIndex): + (AccessibilityUIElement::rowAtIndex): + (AccessibilityUIElement::disclosedByRow): + (AccessibilityUIElement::accessibilityValue): + (AccessibilityUIElement::documentEncoding): + (AccessibilityUIElement::documentURI): + (AccessibilityUIElement::url): + (AccessibilityUIElement::addNotificationListener): + (AccessibilityUIElement::removeNotificationListener): + (AccessibilityUIElement::isFocusable): + (AccessibilityUIElement::isSelectable): + (AccessibilityUIElement::isMultiSelectable): + (AccessibilityUIElement::isSelectedOptionActive): + (AccessibilityUIElement::isVisible): + (AccessibilityUIElement::isOffScreen): + (AccessibilityUIElement::isCollapsed): + (AccessibilityUIElement::isIgnored): + (AccessibilityUIElement::hasPopup): + (AccessibilityUIElement::takeFocus): + (AccessibilityUIElement::takeSelection): + (AccessibilityUIElement::addSelection): + (AccessibilityUIElement::removeSelection): + (AccessibilityUIElement::scrollToMakeVisible): + (AccessibilityUIElement::scrollToMakeVisibleWithSubFocus): + (AccessibilityUIElement::scrollToGlobalPoint): + * DumpRenderTree/efl/CMakeLists.txt: Adds ATK headers, libraries, new sources. + * DumpRenderTree/gtk/AccessibilityControllerGtk.cpp: + (AccessibilityController::focusedElement): + (AccessibilityController::rootElement): + (AccessibilityController::accessibleElementById): + * DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp: + (AccessibilityUIElement::helpText): + * GNUmakefile.am: Adds renamed sources. + 2013-02-11 Jochen Eisinger [chromium] clear the webcache from within the TestRunner library diff --git a/Tools/DumpRenderTree/gtk/AccessibilityCallbacks.h b/Tools/DumpRenderTree/atk/AccessibilityCallbacks.h similarity index 100% rename from Tools/DumpRenderTree/gtk/AccessibilityCallbacks.h rename to Tools/DumpRenderTree/atk/AccessibilityCallbacks.h diff --git a/Tools/DumpRenderTree/gtk/AccessibilityCallbacks.cpp b/Tools/DumpRenderTree/atk/AccessibilityCallbacksAtk.cpp similarity index 83% rename from Tools/DumpRenderTree/gtk/AccessibilityCallbacks.cpp rename to Tools/DumpRenderTree/atk/AccessibilityCallbacksAtk.cpp index 8f2c802c9d88..1ea4f4aac40c 100644 --- a/Tools/DumpRenderTree/gtk/AccessibilityCallbacks.cpp +++ b/Tools/DumpRenderTree/atk/AccessibilityCallbacksAtk.cpp @@ -29,12 +29,22 @@ #include "config.h" #include "AccessibilityCallbacks.h" +#if HAVE(ACCESSIBILITY) + #include "AccessibilityController.h" #include "DumpRenderTree.h" +#include +#include + +#if PLATFORM(GTK) #include "WebCoreSupport/DumpRenderTreeSupportGtk.h" -#include #include -#include +#endif + +#if PLATFORM(EFL) +#include "DumpRenderTreeChrome.h" +#include "WebCoreSupport/DumpRenderTreeSupportEfl.h" +#endif static guint stateChangeListenerId = 0; static guint focusEventListenerId = 0; @@ -61,14 +71,10 @@ static void printAccessibilityEvent(AtkObject* accessible, const gchar* signalNa objectName = "(No name)"; GOwnPtr signalNameAndValue(signalValue ? g_strdup_printf("%s = %s", signalName, signalValue) : g_strdup(signalName)); - printf("Accessibility object emitted \"%s\" / Name: \"%s\" / Role: %d\n", - signalNameAndValue.get(), objectName, objectRole); + printf("Accessibility object emitted \"%s\" / Name: \"%s\" / Role: %d\n", signalNameAndValue.get(), objectName, objectRole); } -static gboolean axObjectEventListener(GSignalInvocationHint *signalHint, - guint numParamValues, - const GValue *paramValues, - gpointer data) +static gboolean axObjectEventListener(GSignalInvocationHint *signalHint, guint numParamValues, const GValue *paramValues, gpointer data) { // At least we should receive the instance emitting the signal. if (numParamValues < 1) @@ -78,25 +84,25 @@ static gboolean axObjectEventListener(GSignalInvocationHint *signalHint, if (!accessible || !ATK_IS_OBJECT(accessible)) return TRUE; - GSignalQuery signal_query; + GSignalQuery signalQuery; GOwnPtr signalName; GOwnPtr signalValue; - g_signal_query(signalHint->signal_id, &signal_query); + g_signal_query(signalHint->signal_id, &signalQuery); - if (!g_strcmp0(signal_query.signal_name, "state-change")) { + if (!g_strcmp0(signalQuery.signal_name, "state-change")) { signalName.set(g_strdup_printf("state-change:%s", g_value_get_string(¶mValues[1]))); signalValue.set(g_strdup_printf("%d", g_value_get_boolean(¶mValues[2]))); - } else if (!g_strcmp0(signal_query.signal_name, "focus-event")) { + } else if (!g_strcmp0(signalQuery.signal_name, "focus-event")) { signalName.set(g_strdup("focus-event")); signalValue.set(g_strdup_printf("%d", g_value_get_boolean(¶mValues[1]))); - } else if (!g_strcmp0(signal_query.signal_name, "children-changed")) { + } else if (!g_strcmp0(signalQuery.signal_name, "children-changed")) { signalName.set(g_strdup("children-changed")); signalValue.set(g_strdup_printf("%d", g_value_get_uint(¶mValues[1]))); - } else if (!g_strcmp0(signal_query.signal_name, "property-change")) { + } else if (!g_strcmp0(signalQuery.signal_name, "property-change")) signalName.set(g_strdup_printf("property-change:%s", g_quark_to_string(signalHint->detail))); - } else - signalName.set(g_strdup(signal_query.signal_name)); + else + signalName.set(g_strdup(signalQuery.signal_name)); printAccessibilityEvent(accessible, signalName.get(), signalValue.get()); @@ -110,15 +116,19 @@ void connectAccessibilityCallbacks() // Ensure that accessibility is initialized for the WebView by querying for // the root accessible object, which will create the full hierarchy. +#if PLATFORM(GTK) DumpRenderTreeSupportGtk::getRootAccessibleElement(mainFrame); +#elif PLATFORM(EFL) + DumpRenderTreeSupportEfl::rootAccessibleElement(browser->mainFrame()); +#endif // Add global listeners for AtkObject's signals. - stateChangeListenerId = atk_add_global_event_listener(axObjectEventListener, "Gtk:AtkObject:state-change"); - focusEventListenerId = atk_add_global_event_listener(axObjectEventListener, "Gtk:AtkObject:focus-event"); - activeDescendantChangedListenerId = atk_add_global_event_listener(axObjectEventListener, "Gtk:AtkObject:active-descendant-changed"); - childrenChangedListenerId = atk_add_global_event_listener(axObjectEventListener, "Gtk:AtkObject:children-changed"); - propertyChangedListenerId = atk_add_global_event_listener(axObjectEventListener, "Gtk:AtkObject:property-change"); - visibleDataChangedListenerId = atk_add_global_event_listener(axObjectEventListener, "Gtk:AtkObject:visible-data-changed"); + stateChangeListenerId = atk_add_global_event_listener(axObjectEventListener, "ATK:AtkObject:state-change"); + focusEventListenerId = atk_add_global_event_listener(axObjectEventListener, "ATK:AtkObject:focus-event"); + activeDescendantChangedListenerId = atk_add_global_event_listener(axObjectEventListener, "ATK:AtkObject:active-descendant-changed"); + childrenChangedListenerId = atk_add_global_event_listener(axObjectEventListener, "ATK:AtkObject:children-changed"); + propertyChangedListenerId = atk_add_global_event_listener(axObjectEventListener, "ATK:AtkObject:property-change"); + visibleDataChangedListenerId = atk_add_global_event_listener(axObjectEventListener, "ATK:AtkObject:visible-data-changed"); // Ensure the Atk interface types are registered, otherwise // the AtkDocument signal handlers below won't get registered. @@ -157,3 +167,4 @@ void disconnectAccessibilityCallbacks() } } +#endif diff --git a/Tools/DumpRenderTree/atk/AccessibilityControllerAtk.cpp b/Tools/DumpRenderTree/atk/AccessibilityControllerAtk.cpp new file mode 100644 index 000000000000..0510319acf54 --- /dev/null +++ b/Tools/DumpRenderTree/atk/AccessibilityControllerAtk.cpp @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2008, 2009, 2010 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 "AccessibilityController.h" + +#if HAVE(ACCESSIBILITY) + +#include "AccessibilityCallbacks.h" +#include "AccessibilityUIElement.h" +#include "DumpRenderTree.h" + +#include + +static bool loggingAccessibilityEvents = false; + +AccessibilityController::AccessibilityController() +{ +} + +AccessibilityController::~AccessibilityController() +{ +} + +AccessibilityUIElement AccessibilityController::elementAtPoint(int x, int y) +{ + // FIXME: implement + return 0; +} + + +void AccessibilityController::setLogFocusEvents(bool) +{ +} + +void AccessibilityController::setLogScrollingStartEvents(bool) +{ +} + +void AccessibilityController::setLogValueChangeEvents(bool) +{ +} + +void AccessibilityController::setLogAccessibilityEvents(bool logAccessibilityEvents) +{ + if (logAccessibilityEvents == loggingAccessibilityEvents) + return; + + if (!logAccessibilityEvents) { + disconnectAccessibilityCallbacks(); + loggingAccessibilityEvents = false; + return; + } + + connectAccessibilityCallbacks(); + loggingAccessibilityEvents = true; +} + +bool AccessibilityController::addNotificationListener(JSObjectRef) +{ + return false; +} + +void AccessibilityController::removeNotificationListener() +{ +} + +#endif diff --git a/Tools/DumpRenderTree/atk/AccessibilityUIElementAtk.cpp b/Tools/DumpRenderTree/atk/AccessibilityUIElementAtk.cpp new file mode 100644 index 000000000000..0cf206631e6a --- /dev/null +++ b/Tools/DumpRenderTree/atk/AccessibilityUIElementAtk.cpp @@ -0,0 +1,1049 @@ +/* + * 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" + +#if HAVE(ACCESSIBILITY) + +#include +#include +#include +#include +#include +#include +#include +#include + +static String coreAttributeToAtkAttribute(JSStringRef attribute) +{ + size_t bufferSize = JSStringGetMaximumUTF8CStringSize(attribute); + GOwnPtr buffer(static_cast(g_malloc(bufferSize))); + JSStringGetUTF8CString(attribute, buffer.get(), bufferSize); + + String attributeString = String::fromUTF8(buffer.get()); + if (attributeString == "AXPlaceholderValue") + return "placeholder-text"; + + return ""; +} + +static inline String roleToString(AtkRole role) +{ + switch (role) { + case ATK_ROLE_ALERT: + return "AXRole: AXAlert"; + case ATK_ROLE_CANVAS: + return "AXRole: AXCanvas"; + case ATK_ROLE_CHECK_BOX: + return "AXRole: AXCheckBox"; + case ATK_ROLE_COLUMN_HEADER: + return "AXRole: AXColumnHeader"; + case ATK_ROLE_COMBO_BOX: + return "AXRole: AXComboBox"; + case ATK_ROLE_DOCUMENT_FRAME: + return "AXRole: AXWebArea"; + case ATK_ROLE_ENTRY: + return "AXRole: AXTextField"; + case ATK_ROLE_FOOTER: + return "AXRole: AXFooter"; + case ATK_ROLE_FORM: + return "AXRole: AXForm"; + case ATK_ROLE_GROUPING: + return "AXRole: AXGroup"; + case ATK_ROLE_HEADING: + return "AXRole: AXHeading"; + case ATK_ROLE_IMAGE: + return "AXRole: AXImage"; + case ATK_ROLE_IMAGE_MAP: + return "AXRole: AXImageMap"; + case ATK_ROLE_LABEL: + return "AXRole: AXLabel"; + case ATK_ROLE_LINK: + return "AXRole: AXLink"; + case ATK_ROLE_LIST: + return "AXRole: AXList"; + case ATK_ROLE_LIST_BOX: + return "AXRole: AXListBox"; + case ATK_ROLE_LIST_ITEM: + return "AXRole: AXListItem"; + case ATK_ROLE_MENU: + return "AXRole: AXMenu"; + case ATK_ROLE_MENU_BAR: + return "AXRole: AXMenuBar"; + case ATK_ROLE_MENU_ITEM: + return "AXRole: AXMenuItem"; + case ATK_ROLE_PAGE_TAB: + return "AXRole: AXTab"; + case ATK_ROLE_PAGE_TAB_LIST: + return "AXRole: AXTabGroup"; + case ATK_ROLE_PANEL: + return "AXRole: AXGroup"; + case ATK_ROLE_PARAGRAPH: + return "AXRole: AXParagraph"; + case ATK_ROLE_PASSWORD_TEXT: + return "AXRole: AXPasswordField"; + case ATK_ROLE_PUSH_BUTTON: + return "AXRole: AXButton"; + case ATK_ROLE_RADIO_BUTTON: + return "AXRole: AXRadioButton"; + case ATK_ROLE_ROW_HEADER: + return "AXRole: AXRowHeader"; + case ATK_ROLE_RULER: + return "AXRole: AXRuler"; + case ATK_ROLE_SCROLL_BAR: + return "AXRole: AXScrollBar"; + case ATK_ROLE_SCROLL_PANE: + return "AXRole: AXScrollArea"; + case ATK_ROLE_SECTION: + return "AXRole: AXDiv"; + case ATK_ROLE_SEPARATOR: + return "AXRole: AXHorizontalRule"; + case ATK_ROLE_SLIDER: + return "AXRole: AXSlider"; + case ATK_ROLE_SPIN_BUTTON: + return "AXRole: AXSpinButton"; + case ATK_ROLE_TABLE: + return "AXRole: AXTable"; + case ATK_ROLE_TABLE_CELL: + return "AXRole: AXCell"; + case ATK_ROLE_TABLE_COLUMN_HEADER: + return "AXRole: AXColumnHeader"; + case ATK_ROLE_TABLE_ROW: + return "AXRole: AXRow"; + case ATK_ROLE_TABLE_ROW_HEADER: + return "AXRole: AXRowHeader"; + case ATK_ROLE_TOGGLE_BUTTON: + return "AXRole: AXToggleButton"; + case ATK_ROLE_TOOL_BAR: + return "AXRole: AXToolbar"; + case ATK_ROLE_TOOL_TIP: + return "AXRole: AXUserInterfaceTooltip"; + case ATK_ROLE_TREE: + return "AXRole: AXTree"; + case ATK_ROLE_TREE_TABLE: + return "AXRole: AXTreeGrid"; + case ATK_ROLE_TREE_ITEM: + return "AXRole: AXTreeItem"; + case ATK_ROLE_WINDOW: + return "AXRole: AXWindow"; + case ATK_ROLE_UNKNOWN: + return "AXRole: AXUnknown"; + default: + // We want to distinguish ATK_ROLE_UNKNOWN from a known AtkRole which + // our DRT isn't properly handling. + return "AXRole: FIXME not identified"; + } +} + +static inline gchar* replaceCharactersForResults(gchar* str) +{ + String uString = String::fromUTF8(str); + + // The object replacement character is passed along to ATs so we need to be + // able to test for their presence and do so without causing test failures. + uString.replace(objectReplacementCharacter, ""); + + // The presence of newline characters in accessible text of a single object + // is appropriate, but it makes test results (especially the accessible tree) + // harder to read. + uString.replace("\n", "<\\n>"); + + return g_strdup(uString.utf8().data()); +} + +AccessibilityUIElement::AccessibilityUIElement(PlatformUIElement element) + : m_element(element) +{ + if (m_element) + g_object_ref(m_element); +} + +AccessibilityUIElement::AccessibilityUIElement(const AccessibilityUIElement& other) + : m_element(other.m_element) +{ + if (m_element) + g_object_ref(m_element); +} + +AccessibilityUIElement::~AccessibilityUIElement() +{ + if (m_element) + g_object_unref(m_element); +} + +void AccessibilityUIElement::getLinkedUIElements(Vector& elements) +{ + // FIXME: implement +} + +void AccessibilityUIElement::getDocumentLinks(Vector&) +{ + // FIXME: implement +} + +void AccessibilityUIElement::getChildren(Vector& children) +{ + 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)); + } +} + +void AccessibilityUIElement::getChildrenWithRange(Vector& elementVector, unsigned start, unsigned end) +{ + for (unsigned i = start; i < end; i++) { + AtkObject* child = atk_object_ref_accessible_child(ATK_OBJECT(m_element), i); + elementVector.append(AccessibilityUIElement(child)); + } +} + +int AccessibilityUIElement::rowCount() +{ + if (!m_element) + return 0; + + ASSERT(ATK_IS_TABLE(m_element)); + + return atk_table_get_n_rows(ATK_TABLE(m_element)); +} + +int AccessibilityUIElement::columnCount() +{ + if (!m_element) + return 0; + + ASSERT(ATK_IS_TABLE(m_element)); + + return atk_table_get_n_columns(ATK_TABLE(m_element)); +} + +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::elementAtPoint(int x, int y) +{ + if (!m_element) + return 0; + + return AccessibilityUIElement(atk_component_ref_accessible_at_point(ATK_COMPONENT(m_element), x, y, ATK_XY_WINDOW)); +} + +AccessibilityUIElement AccessibilityUIElement::linkedUIElementAtIndex(unsigned index) +{ + // FIXME: implement + return 0; +} + +AccessibilityUIElement AccessibilityUIElement::getChildAtIndex(unsigned index) +{ + Vector children; + getChildrenWithRange(children, index, index + 1); + + if (children.size() == 1) + return children.at(0); + + return 0; +} + +unsigned AccessibilityUIElement::indexOfChild(AccessibilityUIElement* element) +{ + // FIXME: implement + return 0; +} + +gchar* attributeSetToString(AtkAttributeSet* attributeSet) +{ + GString* str = g_string_new(0); + for (GSList* attributes = attributeSet; attributes; attributes = attributes->next) { + AtkAttribute* attribute = static_cast(attributes->data); + GOwnPtr attributeData(g_strconcat(attribute->name, ":", attribute->value, NULL)); + g_string_append(str, attributeData.get()); + if (attributes->next) + g_string_append(str, ", "); + } + + return g_string_free(str, FALSE); +} + +JSStringRef AccessibilityUIElement::allAttributes() +{ + if (!m_element) + return JSStringCreateWithCharacters(0, 0); + + ASSERT(ATK_IS_OBJECT(m_element)); + GOwnPtr attributeData(attributeSetToString(atk_object_get_attributes(ATK_OBJECT(m_element)))); + return JSStringCreateWithUTF8CString(attributeData.get()); +} + +JSStringRef AccessibilityUIElement::attributesOfLinkedUIElements() +{ + // FIXME: implement + return JSStringCreateWithCharacters(0, 0); +} + +JSStringRef AccessibilityUIElement::attributesOfDocumentLinks() +{ + // FIXME: implement + return JSStringCreateWithCharacters(0, 0); +} + +AccessibilityUIElement AccessibilityUIElement::titleUIElement() +{ + if (!m_element) + return 0; + + AtkRelationSet* set = atk_object_ref_relation_set(ATK_OBJECT(m_element)); + if (!set) + return 0; + + AtkObject* target = 0; + int count = atk_relation_set_get_n_relations(set); + for (int i = 0; i < count; i++) { + AtkRelation* relation = atk_relation_set_get_relation(set, i); + if (atk_relation_get_relation_type(relation) == ATK_RELATION_LABELLED_BY) { + GPtrArray* targetList = atk_relation_get_target(relation); + if (targetList->len) + target = static_cast(g_ptr_array_index(targetList, 0)); + } + } + + g_object_unref(set); + return target ? AccessibilityUIElement(target) : 0; +} + +AccessibilityUIElement AccessibilityUIElement::parentElement() +{ + if (!m_element) + return 0; + + ASSERT(ATK_IS_OBJECT(m_element)); + + AtkObject* parent = atk_object_get_parent(ATK_OBJECT(m_element)); + return parent ? AccessibilityUIElement(parent) : 0; +} + +JSStringRef AccessibilityUIElement::attributesOfChildren() +{ + // FIXME: implement + return JSStringCreateWithCharacters(0, 0); +} + +JSStringRef AccessibilityUIElement::parameterizedAttributeNames() +{ + // FIXME: implement + return JSStringCreateWithCharacters(0, 0); +} + +JSStringRef AccessibilityUIElement::role() +{ + AtkRole role = atk_object_get_role(ATK_OBJECT(m_element)); + if (!role) + return JSStringCreateWithCharacters(0, 0); + + String roleString = roleToString(role); + return JSStringCreateWithUTF8CString(roleString.utf8().data()); +} + +JSStringRef AccessibilityUIElement::subrole() +{ + return 0; +} + +JSStringRef AccessibilityUIElement::roleDescription() +{ + return 0; +} + +JSStringRef AccessibilityUIElement::title() +{ + const gchar* name = atk_object_get_name(ATK_OBJECT(m_element)); + GOwnPtr axTitle(g_strdup_printf("AXTitle: %s", name ? name : "")); + + return JSStringCreateWithUTF8CString(axTitle.get()); +} + +JSStringRef AccessibilityUIElement::description() +{ + const gchar* description = atk_object_get_description(ATK_OBJECT(m_element)); + + if (!description) + return JSStringCreateWithCharacters(0, 0); + + GOwnPtr axDesc(g_strdup_printf("AXDescription: %s", description)); + + return JSStringCreateWithUTF8CString(axDesc.get()); +} + +JSStringRef AccessibilityUIElement::stringValue() +{ + if (!m_element || !ATK_IS_TEXT(m_element)) + return JSStringCreateWithCharacters(0, 0); + + gchar* text = atk_text_get_text(ATK_TEXT(m_element), 0, -1); + GOwnPtr axValue(g_strdup_printf("AXValue: %s", replaceCharactersForResults(text))); + g_free(text); + + return JSStringCreateWithUTF8CString(axValue.get()); +} + +JSStringRef AccessibilityUIElement::language() +{ + if (!m_element) + return JSStringCreateWithCharacters(0, 0); + + // In ATK, the document language is exposed as the document's locale. + if (atk_object_get_role(ATK_OBJECT(m_element)) == ATK_ROLE_DOCUMENT_FRAME) + return JSStringCreateWithUTF8CString(g_strdup_printf("AXLanguage: %s", atk_document_get_locale(ATK_DOCUMENT(m_element)))); + + // For all other objects, the language is exposed as an AtkText attribute. + if (!ATK_IS_TEXT(m_element)) + return JSStringCreateWithCharacters(0, 0); + + for (GSList* textAttributes = atk_text_get_default_attributes(ATK_TEXT(m_element)); textAttributes; textAttributes = textAttributes->next) { + AtkAttribute* atkAttribute = static_cast(textAttributes->data); + if (!strcmp(atkAttribute->name, atk_text_attribute_get_name(ATK_TEXT_ATTR_LANGUAGE))) + return JSStringCreateWithUTF8CString(g_strdup_printf("AXLanguage: %s", atkAttribute->value)); + } + + return JSStringCreateWithCharacters(0, 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::clickPointX() +{ + // Note: This is not something we have in ATK. + return 0.f; +} + +double AccessibilityUIElement::clickPointY() +{ + // Note: This is not something we have in ATK. + return 0.f; +} + +JSStringRef AccessibilityUIElement::orientation() const +{ + return 0; +} + +double AccessibilityUIElement::intValue() const +{ + 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_FLOAT(&value)) + return 0.0f; + return g_value_get_float(&value); +} + +double AccessibilityUIElement::minValue() +{ + 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_FLOAT(&value)) + return 0.0f; + return g_value_get_float(&value); +} + +double AccessibilityUIElement::maxValue() +{ + 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_FLOAT(&value)) + return 0.0f; + return g_value_get_float(&value); +} + +JSStringRef AccessibilityUIElement::valueDescription() +{ + // FIXME: implement after it has been implemented in ATK. + // See: https://bugzilla.gnome.org/show_bug.cgi?id=684576 + return JSStringCreateWithCharacters(0, 0); +} + +static bool checkElementState(PlatformUIElement element, AtkStateType stateType) +{ + if (!ATK_IS_OBJECT(element)) + return false; + + GRefPtr stateSet = adoptGRef(atk_object_ref_state_set(ATK_OBJECT(element))); + return atk_state_set_contains_state(stateSet.get(), stateType); +} + +bool AccessibilityUIElement::isEnabled() +{ + return checkElementState(m_element, ATK_STATE_ENABLED); +} + +int AccessibilityUIElement::insertionPointLineNumber() +{ + // FIXME: implement + return 0; +} + +bool AccessibilityUIElement::isPressActionSupported() +{ + // FIXME: implement + return false; +} + +bool AccessibilityUIElement::isIncrementActionSupported() +{ + // FIXME: implement + return false; +} + +bool AccessibilityUIElement::isDecrementActionSupported() +{ + // FIXME: implement + return false; +} + +bool AccessibilityUIElement::isRequired() const +{ + // FIXME: implement + return false; +} + +bool AccessibilityUIElement::isFocused() const +{ + if (!ATK_IS_OBJECT(m_element)) + return false; + + GRefPtr 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; +} + +bool AccessibilityUIElement::isSelected() const +{ + return checkElementState(m_element, ATK_STATE_SELECTED); +} + +int AccessibilityUIElement::hierarchicalLevel() const +{ + // FIXME: implement + return 0; +} + +bool AccessibilityUIElement::ariaIsGrabbed() const +{ + return false; +} + +JSStringRef AccessibilityUIElement::ariaDropEffects() const +{ + return 0; +} + +bool AccessibilityUIElement::isExpanded() const +{ + if (!ATK_IS_OBJECT(m_element)) + return false; + + GRefPtr 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; +} + +bool AccessibilityUIElement::isChecked() const +{ + if (!ATK_IS_OBJECT(m_element)) + return false; + + GRefPtr 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; +} + +JSStringRef AccessibilityUIElement::attributesOfColumnHeaders() +{ + // FIXME: implement + return JSStringCreateWithCharacters(0, 0); +} + +JSStringRef AccessibilityUIElement::attributesOfRowHeaders() +{ + // FIXME: implement + return JSStringCreateWithCharacters(0, 0); +} + +JSStringRef AccessibilityUIElement::attributesOfColumns() +{ + // FIXME: implement + return JSStringCreateWithCharacters(0, 0); +} + +JSStringRef AccessibilityUIElement::attributesOfRows() +{ + // FIXME: implement + return JSStringCreateWithCharacters(0, 0); +} + +JSStringRef AccessibilityUIElement::attributesOfVisibleCells() +{ + // FIXME: implement + return JSStringCreateWithCharacters(0, 0); +} + +JSStringRef AccessibilityUIElement::attributesOfHeader() +{ + // FIXME: implement + return JSStringCreateWithCharacters(0, 0); +} + +int AccessibilityUIElement::indexInTable() +{ + // FIXME: implement + return 0; +} + +static JSStringRef indexRangeInTable(PlatformUIElement element, bool isRowRange) +{ + GOwnPtr rangeString(g_strdup("{0, 0}")); + + if (!element) + return JSStringCreateWithUTF8CString(rangeString.get()); + + ASSERT(ATK_IS_OBJECT(element)); + + AtkObject* axTable = atk_object_get_parent(ATK_OBJECT(element)); + if (!axTable || !ATK_IS_TABLE(axTable)) + return JSStringCreateWithUTF8CString(rangeString.get()); + + // Look for the cell in the table. + gint indexInParent = atk_object_get_index_in_parent(ATK_OBJECT(element)); + if (indexInParent == -1) + return JSStringCreateWithUTF8CString(rangeString.get()); + + int row = -1; + int column = -1; + row = atk_table_get_row_at_index(ATK_TABLE(axTable), indexInParent); + column = atk_table_get_column_at_index(ATK_TABLE(axTable), indexInParent); + + // Get the actual values, if row and columns are valid values. + if (row != -1 && column != -1) { + int base = 0; + int length = 0; + if (isRowRange) { + base = row; + length = atk_table_get_row_extent_at(ATK_TABLE(axTable), row, column); + } else { + base = column; + length = atk_table_get_column_extent_at(ATK_TABLE(axTable), row, column); + } + rangeString.set(g_strdup_printf("{%d, %d}", base, length)); + } + + return JSStringCreateWithUTF8CString(rangeString.get()); +} + +JSStringRef AccessibilityUIElement::rowIndexRange() +{ + // Range in table for rows. + return indexRangeInTable(m_element, true); +} + +JSStringRef AccessibilityUIElement::columnIndexRange() +{ + // Range in table for columns. + return indexRangeInTable(m_element, false); +} + +int AccessibilityUIElement::lineForIndex(int) +{ + // FIXME: implement + return 0; +} + +JSStringRef AccessibilityUIElement::boundsForRange(unsigned location, unsigned length) +{ + // FIXME: implement + return JSStringCreateWithCharacters(0, 0); +} + +JSStringRef AccessibilityUIElement::stringForRange(unsigned, unsigned) +{ + // FIXME: implement + return JSStringCreateWithCharacters(0, 0); +} + +JSStringRef AccessibilityUIElement::attributedStringForRange(unsigned, unsigned) +{ + // FIXME: implement + return JSStringCreateWithCharacters(0, 0); +} + +bool AccessibilityUIElement::attributedStringRangeIsMisspelled(unsigned location, unsigned length) +{ + // FIXME: implement + return false; +} + +AccessibilityUIElement AccessibilityUIElement::uiElementForSearchPredicate(AccessibilityUIElement* startElement, bool isDirectionNext, JSStringRef searchKey, JSStringRef searchText) +{ + // FIXME: implement + return 0; +} + +AccessibilityUIElement AccessibilityUIElement::cellForColumnAndRow(unsigned column, unsigned row) +{ + 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; +} + +JSStringRef AccessibilityUIElement::selectedTextRange() +{ + // FIXME: implement + return JSStringCreateWithCharacters(0, 0); +} + +void AccessibilityUIElement::setSelectedTextRange(unsigned location, unsigned length) +{ + // FIXME: implement +} + +JSStringRef AccessibilityUIElement::stringAttributeValue(JSStringRef attribute) +{ + if (!m_element) + return JSStringCreateWithCharacters(0, 0); + + String atkAttributeName = coreAttributeToAtkAttribute(attribute); + if (atkAttributeName.isEmpty()) + return JSStringCreateWithCharacters(0, 0); + + for (GSList* atkAttributes = atk_object_get_attributes(ATK_OBJECT(m_element)); atkAttributes; atkAttributes = atkAttributes->next) { + AtkAttribute* atkAttribute = static_cast(atkAttributes->data); + if (!strcmp(atkAttribute->name, atkAttributeName.utf8().data())) + return JSStringCreateWithUTF8CString(atkAttribute->value); + } + + return JSStringCreateWithCharacters(0, 0); +} + +double AccessibilityUIElement::numberAttributeValue(JSStringRef attribute) +{ + // FIXME: implement + return 0.0f; +} + +bool AccessibilityUIElement::boolAttributeValue(JSStringRef attribute) +{ + // FIXME: implement + return false; +} + +bool AccessibilityUIElement::isAttributeSettable(JSStringRef attribute) +{ + // FIXME: implement + return false; +} + +bool AccessibilityUIElement::isAttributeSupported(JSStringRef attribute) +{ + return false; +} + +static void alterCurrentValue(PlatformUIElement element, int factor) +{ + if (!element) + return; + + ASSERT(ATK_IS_VALUE(element)); + + GValue currentValue = G_VALUE_INIT; + atk_value_get_current_value(ATK_VALUE(element), ¤tValue); + + GValue increment = G_VALUE_INIT; + atk_value_get_minimum_increment(ATK_VALUE(element), &increment); + + GValue newValue = G_VALUE_INIT; + g_value_init(&newValue, G_TYPE_FLOAT); + + g_value_set_float(&newValue, g_value_get_float(¤tValue) + factor * g_value_get_float(&increment)); + atk_value_set_current_value(ATK_VALUE(element), &newValue); + + g_value_unset(&newValue); + g_value_unset(&increment); + g_value_unset(¤tValue); +} + +void AccessibilityUIElement::increment() +{ + alterCurrentValue(m_element, 1); +} + +void AccessibilityUIElement::decrement() +{ + alterCurrentValue(m_element, -1); +} + +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); +} + +void AccessibilityUIElement::showMenu() +{ + // FIXME: implement +} + +AccessibilityUIElement AccessibilityUIElement::disclosedRowAtIndex(unsigned index) +{ + return 0; +} + +AccessibilityUIElement AccessibilityUIElement::ariaOwnsElementAtIndex(unsigned index) +{ + return 0; +} + +AccessibilityUIElement AccessibilityUIElement::ariaFlowToElementAtIndex(unsigned index) +{ + return 0; +} + +AccessibilityUIElement AccessibilityUIElement::selectedRowAtIndex(unsigned index) +{ + return 0; +} + +AccessibilityUIElement AccessibilityUIElement::rowAtIndex(unsigned index) +{ + return 0; +} + +AccessibilityUIElement AccessibilityUIElement::disclosedByRow() +{ + return 0; +} + +JSStringRef AccessibilityUIElement::accessibilityValue() const +{ + // FIXME: implement + return JSStringCreateWithCharacters(0, 0); +} + +JSStringRef AccessibilityUIElement::documentEncoding() +{ + 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")); +} + +JSStringRef AccessibilityUIElement::documentURI() +{ + 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")); +} + +JSStringRef AccessibilityUIElement::url() +{ + // FIXME: implement + return JSStringCreateWithCharacters(0, 0); +} + +bool AccessibilityUIElement::addNotificationListener(JSObjectRef functionCallback) +{ + // FIXME: implement + return false; +} + +void AccessibilityUIElement::removeNotificationListener() +{ + // FIXME: implement +} + +bool AccessibilityUIElement::isFocusable() const +{ + if (!ATK_IS_OBJECT(m_element)) + return false; + + GRefPtr 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; +} + +bool AccessibilityUIElement::isSelectable() const +{ + return checkElementState(m_element, ATK_STATE_SELECTABLE); +} + +bool AccessibilityUIElement::isMultiSelectable() const +{ + return checkElementState(m_element, ATK_STATE_MULTISELECTABLE); +} + +bool AccessibilityUIElement::isSelectedOptionActive() const +{ + // FIXME: implement + return false; +} + +bool AccessibilityUIElement::isVisible() const +{ + // FIXME: implement + return false; +} + +bool AccessibilityUIElement::isOffScreen() const +{ + // FIXME: implement + return false; +} + +bool AccessibilityUIElement::isCollapsed() const +{ + // FIXME: implement + return false; +} + +bool AccessibilityUIElement::isIgnored() const +{ + // FIXME: implement + return false; +} + +bool AccessibilityUIElement::hasPopup() const +{ + // FIXME: implement + return false; +} + +void AccessibilityUIElement::takeFocus() +{ + // FIXME: implement +} + +void AccessibilityUIElement::takeSelection() +{ + // FIXME: implement +} + +void AccessibilityUIElement::addSelection() +{ + // FIXME: implement +} + +void AccessibilityUIElement::removeSelection() +{ + // FIXME: implement +} + +void AccessibilityUIElement::scrollToMakeVisible() +{ + // FIXME: implement +} + +void AccessibilityUIElement::scrollToMakeVisibleWithSubFocus(int x, int y, int width, int height) +{ + // FIXME: implement +} + +void AccessibilityUIElement::scrollToGlobalPoint(int x, int y) +{ + // FIXME: implement +} + +#endif diff --git a/Tools/DumpRenderTree/efl/CMakeLists.txt b/Tools/DumpRenderTree/efl/CMakeLists.txt index c068ea7b2cd4..67f905d508df 100644 --- a/Tools/DumpRenderTree/efl/CMakeLists.txt +++ b/Tools/DumpRenderTree/efl/CMakeLists.txt @@ -1,4 +1,5 @@ set(DumpRenderTree_SOURCES + ${TOOLS_DIR}/DumpRenderTree/atk/AccessibilityCallbacksAtk.cpp ${TOOLS_DIR}/DumpRenderTree/DumpRenderTreeCommon.cpp ${TOOLS_DIR}/DumpRenderTree/CyclicRedundancyCheck.cpp ${TOOLS_DIR}/DumpRenderTree/GCController.cpp @@ -88,6 +89,7 @@ set(DumpRenderTree_INCLUDE_DIRECTORIES ${JAVASCRIPTCORE_DIR}/runtime ${JAVASCRIPTCORE_DIR}/ForwardingHeaders ${TOOLS_DIR}/DumpRenderTree + ${TOOLS_DIR}/DumpRenderTree/atk ${TOOLS_DIR}/DumpRenderTree/cairo ${TOOLS_DIR}/DumpRenderTree/efl ${WTF_DIR} diff --git a/Tools/DumpRenderTree/gtk/AccessibilityControllerGtk.cpp b/Tools/DumpRenderTree/gtk/AccessibilityControllerGtk.cpp index 70f081a9ef92..848baa17884f 100644 --- a/Tools/DumpRenderTree/gtk/AccessibilityControllerGtk.cpp +++ b/Tools/DumpRenderTree/gtk/AccessibilityControllerGtk.cpp @@ -37,40 +37,6 @@ #include #include -static bool loggingAccessibilityEvents = false; - -AccessibilityController::AccessibilityController() -{ -} - -AccessibilityController::~AccessibilityController() -{ -} - -AccessibilityUIElement AccessibilityController::elementAtPoint(int x, int y) -{ - // FIXME: implement - return 0; -} - -AccessibilityUIElement AccessibilityController::focusedElement() -{ - AtkObject* accessible = DumpRenderTreeSupportGtk::getFocusedAccessibleElement(mainFrame); - if (!accessible) - return 0; - - return AccessibilityUIElement(accessible); -} - -AccessibilityUIElement AccessibilityController::rootElement() -{ - AtkObject* accessible = DumpRenderTreeSupportGtk::getRootAccessibleElement(mainFrame); - if (!accessible) - return 0; - - return AccessibilityUIElement(accessible); -} - static AtkObject* childElementById(AtkObject* parent, const char* id) { if (!ATK_IS_OBJECT(parent)) @@ -96,6 +62,24 @@ static AtkObject* childElementById(AtkObject* parent, const char* id) return 0; } +AccessibilityUIElement AccessibilityController::focusedElement() +{ + AtkObject* accessible = DumpRenderTreeSupportGtk::getFocusedAccessibleElement(mainFrame); + if (!accessible) + return 0; + + return AccessibilityUIElement(accessible); +} + +AccessibilityUIElement AccessibilityController::rootElement() +{ + AtkObject* accessible = DumpRenderTreeSupportGtk::getRootAccessibleElement(mainFrame); + if (!accessible) + return 0; + + return AccessibilityUIElement(accessible); +} + AccessibilityUIElement AccessibilityController::accessibleElementById(JSStringRef id) { AtkObject* root = DumpRenderTreeSupportGtk::getRootAccessibleElement(mainFrame); @@ -113,39 +97,3 @@ AccessibilityUIElement AccessibilityController::accessibleElementById(JSStringRe return 0; } - -void AccessibilityController::setLogFocusEvents(bool) -{ -} - -void AccessibilityController::setLogScrollingStartEvents(bool) -{ -} - -void AccessibilityController::setLogValueChangeEvents(bool) -{ -} - -void AccessibilityController::setLogAccessibilityEvents(bool logAccessibilityEvents) -{ - if (logAccessibilityEvents == loggingAccessibilityEvents) - return; - - if (!logAccessibilityEvents) { - disconnectAccessibilityCallbacks(); - loggingAccessibilityEvents = false; - return; - } - - connectAccessibilityCallbacks(); - loggingAccessibilityEvents = true; -} - -bool AccessibilityController::addNotificationListener(JSObjectRef) -{ - return false; -} - -void AccessibilityController::removeNotificationListener() -{ -} diff --git a/Tools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp b/Tools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp index 4ab99955085d..30f7b643695f 100644 --- a/Tools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp +++ b/Tools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp @@ -37,408 +37,6 @@ #include #include -static String coreAttributeToAtkAttribute(JSStringRef attribute) -{ - size_t bufferSize = JSStringGetMaximumUTF8CStringSize(attribute); - GOwnPtr buffer(static_cast(g_malloc(bufferSize))); - JSStringGetUTF8CString(attribute, buffer.get(), bufferSize); - - String attributeString = String::fromUTF8(buffer.get()); - if (attributeString == "AXPlaceholderValue") - return "placeholder-text"; - - return ""; -} - -static inline String roleToString(AtkRole role) -{ - switch (role) { - case ATK_ROLE_ALERT: - return "AXRole: AXAlert"; - case ATK_ROLE_CANVAS: - return "AXRole: AXCanvas"; - case ATK_ROLE_CHECK_BOX: - return "AXRole: AXCheckBox"; - case ATK_ROLE_COLUMN_HEADER: - return "AXRole: AXColumnHeader"; - case ATK_ROLE_COMBO_BOX: - return "AXRole: AXComboBox"; - case ATK_ROLE_DOCUMENT_FRAME: - return "AXRole: AXWebArea"; - case ATK_ROLE_ENTRY: - return "AXRole: AXTextField"; - case ATK_ROLE_FOOTER: - return "AXRole: AXFooter"; - case ATK_ROLE_FORM: - return "AXRole: AXForm"; - case ATK_ROLE_GROUPING: - return "AXRole: AXGroup"; - case ATK_ROLE_HEADING: - return "AXRole: AXHeading"; - case ATK_ROLE_IMAGE: - return "AXRole: AXImage"; - case ATK_ROLE_IMAGE_MAP: - return "AXRole: AXImageMap"; - case ATK_ROLE_LABEL: - return "AXRole: AXLabel"; - case ATK_ROLE_LINK: - return "AXRole: AXLink"; - case ATK_ROLE_LIST: - return "AXRole: AXList"; - case ATK_ROLE_LIST_BOX: - return "AXRole: AXListBox"; - case ATK_ROLE_LIST_ITEM: - return "AXRole: AXListItem"; - case ATK_ROLE_MENU: - return "AXRole: AXMenu"; - case ATK_ROLE_MENU_BAR: - return "AXRole: AXMenuBar"; - case ATK_ROLE_MENU_ITEM: - return "AXRole: AXMenuItem"; - case ATK_ROLE_PAGE_TAB: - return "AXRole: AXTab"; - case ATK_ROLE_PAGE_TAB_LIST: - return "AXRole: AXTabGroup"; - case ATK_ROLE_PANEL: - return "AXRole: AXGroup"; - case ATK_ROLE_PARAGRAPH: - return "AXRole: AXParagraph"; - case ATK_ROLE_PASSWORD_TEXT: - return "AXRole: AXPasswordField"; - case ATK_ROLE_PUSH_BUTTON: - return "AXRole: AXButton"; - case ATK_ROLE_RADIO_BUTTON: - return "AXRole: AXRadioButton"; - case ATK_ROLE_ROW_HEADER: - return "AXRole: AXRowHeader"; - case ATK_ROLE_RULER: - return "AXRole: AXRuler"; - case ATK_ROLE_SCROLL_BAR: - return "AXRole: AXScrollBar"; - case ATK_ROLE_SCROLL_PANE: - return "AXRole: AXScrollArea"; - case ATK_ROLE_SECTION: - return "AXRole: AXDiv"; - case ATK_ROLE_SEPARATOR: - return "AXRole: AXHorizontalRule"; - case ATK_ROLE_SLIDER: - return "AXRole: AXSlider"; - case ATK_ROLE_SPIN_BUTTON: - return "AXRole: AXSpinButton"; - case ATK_ROLE_TABLE: - return "AXRole: AXTable"; - case ATK_ROLE_TABLE_CELL: - return "AXRole: AXCell"; - case ATK_ROLE_TABLE_COLUMN_HEADER: - return "AXRole: AXColumnHeader"; - case ATK_ROLE_TABLE_ROW: - return "AXRole: AXRow"; - case ATK_ROLE_TABLE_ROW_HEADER: - return "AXRole: AXRowHeader"; - case ATK_ROLE_TOGGLE_BUTTON: - return "AXRole: AXToggleButton"; - case ATK_ROLE_TOOL_BAR: - return "AXRole: AXToolbar"; - case ATK_ROLE_TOOL_TIP: - return "AXRole: AXUserInterfaceTooltip"; - case ATK_ROLE_TREE: - return "AXRole: AXTree"; - case ATK_ROLE_TREE_TABLE: - return "AXRole: AXTreeGrid"; - case ATK_ROLE_TREE_ITEM: - return "AXRole: AXTreeItem"; - case ATK_ROLE_WINDOW: - return "AXRole: AXWindow"; - case ATK_ROLE_UNKNOWN: - return "AXRole: AXUnknown"; - default: - // We want to distinguish ATK_ROLE_UNKNOWN from a known AtkRole which - // our DRT isn't properly handling. - return "AXRole: FIXME not identified"; - } -} - -static inline gchar* replaceCharactersForResults(gchar* str) -{ - String uString = String::fromUTF8(str); - - // The object replacement character is passed along to ATs so we need to be - // able to test for their presence and do so without causing test failures. - uString.replace(objectReplacementCharacter, ""); - - // The presence of newline characters in accessible text of a single object - // is appropriate, but it makes test results (especially the accessible tree) - // harder to read. - uString.replace("\n", "<\\n>"); - - return g_strdup(uString.utf8().data()); -} - -AccessibilityUIElement::AccessibilityUIElement(PlatformUIElement element) - : m_element(element) -{ - if (m_element) - g_object_ref(m_element); -} - -AccessibilityUIElement::AccessibilityUIElement(const AccessibilityUIElement& other) - : m_element(other.m_element) -{ - if (m_element) - g_object_ref(m_element); -} - -AccessibilityUIElement::~AccessibilityUIElement() -{ - if (m_element) - g_object_unref(m_element); -} - -void AccessibilityUIElement::getLinkedUIElements(Vector& elements) -{ - // FIXME: implement -} - -void AccessibilityUIElement::getDocumentLinks(Vector&) -{ - // FIXME: implement -} - -void AccessibilityUIElement::getChildren(Vector& children) -{ - 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)); - } -} - -void AccessibilityUIElement::getChildrenWithRange(Vector& elementVector, unsigned start, unsigned end) -{ - for (unsigned i = start; i < end; i++) { - AtkObject* child = atk_object_ref_accessible_child(ATK_OBJECT(m_element), i); - elementVector.append(AccessibilityUIElement(child)); - } -} - -int AccessibilityUIElement::rowCount() -{ - if (!m_element) - return 0; - - ASSERT(ATK_IS_TABLE(m_element)); - - return atk_table_get_n_rows(ATK_TABLE(m_element)); -} - -int AccessibilityUIElement::columnCount() -{ - if (!m_element) - return 0; - - ASSERT(ATK_IS_TABLE(m_element)); - - return atk_table_get_n_columns(ATK_TABLE(m_element)); -} - -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::elementAtPoint(int x, int y) -{ - if (!m_element) - return 0; - - return AccessibilityUIElement(atk_component_ref_accessible_at_point(ATK_COMPONENT(m_element), x, y, ATK_XY_WINDOW)); -} - -AccessibilityUIElement AccessibilityUIElement::linkedUIElementAtIndex(unsigned index) -{ - // FIXME: implement - return 0; -} - -AccessibilityUIElement AccessibilityUIElement::getChildAtIndex(unsigned index) -{ - Vector children; - getChildrenWithRange(children, index, index + 1); - - if (children.size() == 1) - return children.at(0); - - return 0; -} - -unsigned AccessibilityUIElement::indexOfChild(AccessibilityUIElement* element) -{ - // FIXME: implement - return 0; -} - -gchar* attributeSetToString(AtkAttributeSet* attributeSet) -{ - GString* str = g_string_new(0); - for (GSList* attributes = attributeSet; attributes; attributes = attributes->next) { - AtkAttribute* attribute = static_cast(attributes->data); - GOwnPtr attributeData(g_strconcat(attribute->name, ":", attribute->value, NULL)); - g_string_append(str, attributeData.get()); - if (attributes->next) - g_string_append(str, ", "); - } - - return g_string_free(str, FALSE); -} - -JSStringRef AccessibilityUIElement::allAttributes() -{ - if (!m_element) - return JSStringCreateWithCharacters(0, 0); - - ASSERT(ATK_IS_OBJECT(m_element)); - GOwnPtr attributeData(attributeSetToString(atk_object_get_attributes(ATK_OBJECT(m_element)))); - return JSStringCreateWithUTF8CString(attributeData.get()); -} - -JSStringRef AccessibilityUIElement::attributesOfLinkedUIElements() -{ - // FIXME: implement - return JSStringCreateWithCharacters(0, 0); -} - -JSStringRef AccessibilityUIElement::attributesOfDocumentLinks() -{ - // FIXME: implement - return JSStringCreateWithCharacters(0, 0); -} - -AccessibilityUIElement AccessibilityUIElement::titleUIElement() -{ - if (!m_element) - return 0; - - AtkRelationSet* set = atk_object_ref_relation_set(ATK_OBJECT(m_element)); - if (!set) - return 0; - - AtkObject* target = 0; - int count = atk_relation_set_get_n_relations(set); - for (int i = 0; i < count; i++) { - AtkRelation* relation = atk_relation_set_get_relation(set, i); - if (atk_relation_get_relation_type(relation) == ATK_RELATION_LABELLED_BY) { - GPtrArray* targetList = atk_relation_get_target(relation); - if (targetList->len) - target = static_cast(g_ptr_array_index(targetList, 0)); - } - } - - g_object_unref(set); - return target ? AccessibilityUIElement(target) : 0; -} - -AccessibilityUIElement AccessibilityUIElement::parentElement() -{ - if (!m_element) - return 0; - - ASSERT(ATK_IS_OBJECT(m_element)); - - AtkObject* parent = atk_object_get_parent(ATK_OBJECT(m_element)); - return parent ? AccessibilityUIElement(parent) : 0; -} - -JSStringRef AccessibilityUIElement::attributesOfChildren() -{ - // FIXME: implement - return JSStringCreateWithCharacters(0, 0); -} - -JSStringRef AccessibilityUIElement::parameterizedAttributeNames() -{ - // FIXME: implement - return JSStringCreateWithCharacters(0, 0); -} - -JSStringRef AccessibilityUIElement::role() -{ - AtkRole role = atk_object_get_role(ATK_OBJECT(m_element)); - if (!role) - return JSStringCreateWithCharacters(0, 0); - - String roleString = roleToString(role); - return JSStringCreateWithUTF8CString(roleString.utf8().data()); -} - -JSStringRef AccessibilityUIElement::subrole() -{ - return 0; -} - -JSStringRef AccessibilityUIElement::roleDescription() -{ - return 0; -} - -JSStringRef AccessibilityUIElement::title() -{ - const gchar* name = atk_object_get_name(ATK_OBJECT(m_element)); - GOwnPtr axTitle(g_strdup_printf("AXTitle: %s", name ? name : "")); - - return JSStringCreateWithUTF8CString(axTitle.get()); -} - -JSStringRef AccessibilityUIElement::description() -{ - const gchar* description = atk_object_get_description(ATK_OBJECT(m_element)); - - if (!description) - return JSStringCreateWithCharacters(0, 0); - - GOwnPtr axDesc(g_strdup_printf("AXDescription: %s", description)); - - return JSStringCreateWithUTF8CString(axDesc.get()); -} - -JSStringRef AccessibilityUIElement::stringValue() -{ - if (!m_element || !ATK_IS_TEXT(m_element)) - return JSStringCreateWithCharacters(0, 0); - - gchar* text = atk_text_get_text(ATK_TEXT(m_element), 0, -1); - GOwnPtr axValue(g_strdup_printf("AXValue: %s", replaceCharactersForResults(text))); - g_free(text); - - return JSStringCreateWithUTF8CString(axValue.get()); -} - -JSStringRef AccessibilityUIElement::language() -{ - if (!m_element) - return JSStringCreateWithCharacters(0, 0); - - // In ATK, the document language is exposed as the document's locale. - if (atk_object_get_role(ATK_OBJECT(m_element)) == ATK_ROLE_DOCUMENT_FRAME) - return JSStringCreateWithUTF8CString(g_strdup_printf("AXLanguage: %s", atk_document_get_locale(ATK_DOCUMENT(m_element)))); - - // For all other objects, the language is exposed as an AtkText attribute. - if (!ATK_IS_TEXT(m_element)) - return JSStringCreateWithCharacters(0, 0); - - for (GSList* textAttributes = atk_text_get_default_attributes(ATK_TEXT(m_element)); textAttributes; textAttributes = textAttributes->next) { - AtkAttribute* atkAttribute = static_cast(textAttributes->data); - if (!strcmp(atkAttribute->name, atk_text_attribute_get_name(ATK_TEXT_ATTR_LANGUAGE))) - return JSStringCreateWithUTF8CString(g_strdup_printf("AXLanguage: %s", atkAttribute->value)); - } - - return JSStringCreateWithCharacters(0, 0); -} - JSStringRef AccessibilityUIElement::helpText() const { if (!m_element) @@ -450,609 +48,3 @@ JSStringRef AccessibilityUIElement::helpText() const GOwnPtr axHelpText(g_strdup_printf("AXHelp: %s", helpText.data())); return JSStringCreateWithUTF8CString(axHelpText.get()); } - -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::clickPointX() -{ - // Note: This is not something we have in ATK. - return 0.f; -} - -double AccessibilityUIElement::clickPointY() -{ - // Note: This is not something we have in ATK. - return 0.f; -} - -JSStringRef AccessibilityUIElement::orientation() const -{ - return 0; -} - -double AccessibilityUIElement::intValue() const -{ - 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_FLOAT(&value)) - return 0.0f; - return g_value_get_float(&value); -} - -double AccessibilityUIElement::minValue() -{ - 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_FLOAT(&value)) - return 0.0f; - return g_value_get_float(&value); -} - -double AccessibilityUIElement::maxValue() -{ - 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_FLOAT(&value)) - return 0.0f; - return g_value_get_float(&value); -} - -JSStringRef AccessibilityUIElement::valueDescription() -{ - // FIXME: implement after it has been implemented in ATK. - // See: https://bugzilla.gnome.org/show_bug.cgi?id=684576 - return JSStringCreateWithCharacters(0, 0); -} - -static bool checkElementState(PlatformUIElement element, AtkStateType stateType) -{ - if (!ATK_IS_OBJECT(element)) - return false; - - GRefPtr stateSet = adoptGRef(atk_object_ref_state_set(ATK_OBJECT(element))); - return atk_state_set_contains_state(stateSet.get(), stateType); -} - -bool AccessibilityUIElement::isEnabled() -{ - return checkElementState(m_element, ATK_STATE_ENABLED); -} - -int AccessibilityUIElement::insertionPointLineNumber() -{ - // FIXME: implement - return 0; -} - -bool AccessibilityUIElement::isPressActionSupported() -{ - // FIXME: implement - return false; -} - -bool AccessibilityUIElement::isIncrementActionSupported() -{ - // FIXME: implement - return false; -} - -bool AccessibilityUIElement::isDecrementActionSupported() -{ - // FIXME: implement - return false; -} - -bool AccessibilityUIElement::isRequired() const -{ - // FIXME: implement - return false; -} - -bool AccessibilityUIElement::isFocused() const -{ - if (!ATK_IS_OBJECT(m_element)) - return false; - - GRefPtr 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; -} - -bool AccessibilityUIElement::isSelected() const -{ - return checkElementState(m_element, ATK_STATE_SELECTED); -} - -int AccessibilityUIElement::hierarchicalLevel() const -{ - // FIXME: implement - return 0; -} - -bool AccessibilityUIElement::ariaIsGrabbed() const -{ - return false; -} - -JSStringRef AccessibilityUIElement::ariaDropEffects() const -{ - return 0; -} - -bool AccessibilityUIElement::isExpanded() const -{ - if (!ATK_IS_OBJECT(m_element)) - return false; - - GRefPtr 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; -} - -bool AccessibilityUIElement::isChecked() const -{ - if (!ATK_IS_OBJECT(m_element)) - return false; - - GRefPtr 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; -} - -JSStringRef AccessibilityUIElement::attributesOfColumnHeaders() -{ - // FIXME: implement - return JSStringCreateWithCharacters(0, 0); -} - -JSStringRef AccessibilityUIElement::attributesOfRowHeaders() -{ - // FIXME: implement - return JSStringCreateWithCharacters(0, 0); -} - -JSStringRef AccessibilityUIElement::attributesOfColumns() -{ - // FIXME: implement - return JSStringCreateWithCharacters(0, 0); -} - -JSStringRef AccessibilityUIElement::attributesOfRows() -{ - // FIXME: implement - return JSStringCreateWithCharacters(0, 0); -} - -JSStringRef AccessibilityUIElement::attributesOfVisibleCells() -{ - // FIXME: implement - return JSStringCreateWithCharacters(0, 0); -} - -JSStringRef AccessibilityUIElement::attributesOfHeader() -{ - // FIXME: implement - return JSStringCreateWithCharacters(0, 0); -} - -int AccessibilityUIElement::indexInTable() -{ - // FIXME: implement - return 0; -} - -static JSStringRef indexRangeInTable(PlatformUIElement element, bool isRowRange) -{ - GOwnPtr rangeString(g_strdup("{0, 0}")); - - if (!element) - return JSStringCreateWithUTF8CString(rangeString.get()); - - ASSERT(ATK_IS_OBJECT(element)); - - AtkObject* axTable = atk_object_get_parent(ATK_OBJECT(element)); - if (!axTable || !ATK_IS_TABLE(axTable)) - return JSStringCreateWithUTF8CString(rangeString.get()); - - // Look for the cell in the table. - gint indexInParent = atk_object_get_index_in_parent(ATK_OBJECT(element)); - if (indexInParent == -1) - return JSStringCreateWithUTF8CString(rangeString.get()); - - int row = -1; - int column = -1; - row = atk_table_get_row_at_index(ATK_TABLE(axTable), indexInParent); - column = atk_table_get_column_at_index(ATK_TABLE(axTable), indexInParent); - - // Get the actual values, if row and columns are valid values. - if (row != -1 && column != -1) { - int base = 0; - int length = 0; - if (isRowRange) { - base = row; - length = atk_table_get_row_extent_at(ATK_TABLE(axTable), row, column); - } else { - base = column; - length = atk_table_get_column_extent_at(ATK_TABLE(axTable), row, column); - } - rangeString.set(g_strdup_printf("{%d, %d}", base, length)); - } - - return JSStringCreateWithUTF8CString(rangeString.get()); -} - -JSStringRef AccessibilityUIElement::rowIndexRange() -{ - // Range in table for rows. - return indexRangeInTable(m_element, true); -} - -JSStringRef AccessibilityUIElement::columnIndexRange() -{ - // Range in table for columns. - return indexRangeInTable(m_element, false); -} - -int AccessibilityUIElement::lineForIndex(int) -{ - // FIXME: implement - return 0; -} - -JSStringRef AccessibilityUIElement::boundsForRange(unsigned location, unsigned length) -{ - // FIXME: implement - return JSStringCreateWithCharacters(0, 0); -} - -JSStringRef AccessibilityUIElement::stringForRange(unsigned, unsigned) -{ - // FIXME: implement - return JSStringCreateWithCharacters(0, 0); -} - -JSStringRef AccessibilityUIElement::attributedStringForRange(unsigned, unsigned) -{ - // FIXME: implement - return JSStringCreateWithCharacters(0, 0); -} - -bool AccessibilityUIElement::attributedStringRangeIsMisspelled(unsigned location, unsigned length) -{ - // FIXME: implement - return false; -} - -AccessibilityUIElement AccessibilityUIElement::uiElementForSearchPredicate(AccessibilityUIElement* startElement, bool isDirectionNext, JSStringRef searchKey, JSStringRef searchText) -{ - // FIXME: implement - return 0; -} - -AccessibilityUIElement AccessibilityUIElement::cellForColumnAndRow(unsigned column, unsigned row) -{ - 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; -} - -JSStringRef AccessibilityUIElement::selectedTextRange() -{ - // FIXME: implement - return JSStringCreateWithCharacters(0, 0); -} - -void AccessibilityUIElement::setSelectedTextRange(unsigned location, unsigned length) -{ - // FIXME: implement -} - -JSStringRef AccessibilityUIElement::stringAttributeValue(JSStringRef attribute) -{ - if (!m_element) - return JSStringCreateWithCharacters(0, 0); - - String atkAttributeName = coreAttributeToAtkAttribute(attribute); - if (atkAttributeName.isEmpty()) - return JSStringCreateWithCharacters(0, 0); - - for (GSList* atkAttributes = atk_object_get_attributes(ATK_OBJECT(m_element)); atkAttributes; atkAttributes = atkAttributes->next) { - AtkAttribute* atkAttribute = static_cast(atkAttributes->data); - if (!strcmp(atkAttribute->name, atkAttributeName.utf8().data())) - return JSStringCreateWithUTF8CString(atkAttribute->value); - } - - return JSStringCreateWithCharacters(0, 0); -} - -double AccessibilityUIElement::numberAttributeValue(JSStringRef attribute) -{ - // FIXME: implement - return 0.0f; -} - -bool AccessibilityUIElement::boolAttributeValue(JSStringRef attribute) -{ - // FIXME: implement - return false; -} - -bool AccessibilityUIElement::isAttributeSettable(JSStringRef attribute) -{ - // FIXME: implement - return false; -} - -bool AccessibilityUIElement::isAttributeSupported(JSStringRef attribute) -{ - return false; -} - -static void alterCurrentValue(PlatformUIElement element, int factor) -{ - if (!element) - return; - - ASSERT(ATK_IS_VALUE(element)); - - GValue currentValue = G_VALUE_INIT; - atk_value_get_current_value(ATK_VALUE(element), ¤tValue); - - GValue increment = G_VALUE_INIT; - atk_value_get_minimum_increment(ATK_VALUE(element), &increment); - - GValue newValue = G_VALUE_INIT; - g_value_init(&newValue, G_TYPE_FLOAT); - - g_value_set_float(&newValue, g_value_get_float(¤tValue) + factor * g_value_get_float(&increment)); - atk_value_set_current_value(ATK_VALUE(element), &newValue); - - g_value_unset(&newValue); - g_value_unset(&increment); - g_value_unset(¤tValue); -} - -void AccessibilityUIElement::increment() -{ - alterCurrentValue(m_element, 1); -} - -void AccessibilityUIElement::decrement() -{ - alterCurrentValue(m_element, -1); -} - -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); -} - -void AccessibilityUIElement::showMenu() -{ - // FIXME: implement -} - -AccessibilityUIElement AccessibilityUIElement::disclosedRowAtIndex(unsigned index) -{ - return 0; -} - -AccessibilityUIElement AccessibilityUIElement::ariaOwnsElementAtIndex(unsigned index) -{ - return 0; -} - -AccessibilityUIElement AccessibilityUIElement::ariaFlowToElementAtIndex(unsigned index) -{ - return 0; -} - -AccessibilityUIElement AccessibilityUIElement::selectedRowAtIndex(unsigned index) -{ - return 0; -} - -AccessibilityUIElement AccessibilityUIElement::rowAtIndex(unsigned index) -{ - return 0; -} - -AccessibilityUIElement AccessibilityUIElement::disclosedByRow() -{ - return 0; -} - -JSStringRef AccessibilityUIElement::accessibilityValue() const -{ - // FIXME: implement - return JSStringCreateWithCharacters(0, 0); -} - -JSStringRef AccessibilityUIElement::documentEncoding() -{ - 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")); -} - -JSStringRef AccessibilityUIElement::documentURI() -{ - 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")); -} - -JSStringRef AccessibilityUIElement::url() -{ - // FIXME: implement - return JSStringCreateWithCharacters(0, 0); -} - -bool AccessibilityUIElement::addNotificationListener(JSObjectRef functionCallback) -{ - // FIXME: implement - return false; -} - -void AccessibilityUIElement::removeNotificationListener() -{ - // FIXME: implement -} - -bool AccessibilityUIElement::isFocusable() const -{ - if (!ATK_IS_OBJECT(m_element)) - return false; - - GRefPtr 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; -} - -bool AccessibilityUIElement::isSelectable() const -{ - return checkElementState(m_element, ATK_STATE_SELECTABLE); -} - -bool AccessibilityUIElement::isMultiSelectable() const -{ - return checkElementState(m_element, ATK_STATE_MULTISELECTABLE); -} - -bool AccessibilityUIElement::isSelectedOptionActive() const -{ - // FIXME: implement - return false; -} - -bool AccessibilityUIElement::isVisible() const -{ - // FIXME: implement - return false; -} - -bool AccessibilityUIElement::isOffScreen() const -{ - // FIXME: implement - return false; -} - -bool AccessibilityUIElement::isCollapsed() const -{ - // FIXME: implement - return false; -} - -bool AccessibilityUIElement::isIgnored() const -{ - // FIXME: implement - return false; -} - -bool AccessibilityUIElement::hasPopup() const -{ - // FIXME: implement - return false; -} - -void AccessibilityUIElement::takeFocus() -{ - // FIXME: implement -} - -void AccessibilityUIElement::takeSelection() -{ - // FIXME: implement -} - -void AccessibilityUIElement::addSelection() -{ - // FIXME: implement -} - -void AccessibilityUIElement::removeSelection() -{ - // FIXME: implement -} - -void AccessibilityUIElement::scrollToMakeVisible() -{ - // FIXME: implement -} - -void AccessibilityUIElement::scrollToMakeVisibleWithSubFocus(int x, int y, int width, int height) -{ - // FIXME: implement -} - -void AccessibilityUIElement::scrollToGlobalPoint(int x, int y) -{ - // FIXME: implement -} diff --git a/Tools/GNUmakefile.am b/Tools/GNUmakefile.am index 63bcfb2a5f35..e674ae17069d 100644 --- a/Tools/GNUmakefile.am +++ b/Tools/GNUmakefile.am @@ -106,6 +106,7 @@ Programs_DumpRenderTree_CPPFLAGS = \ $(global_cppflags) \ -DTOP_LEVEL_DIR=\"${shell pwd}/${srcdir}\" \ -I$(srcdir)/Tools/DumpRenderTree \ + -I$(srcdir)/Tools/DumpRenderTree/atk \ -I$(srcdir)/Tools/DumpRenderTree/cairo \ -I$(srcdir)/Tools/DumpRenderTree/gtk \ -I$(srcdir)/Source/WebKit/gtk \ @@ -145,10 +146,12 @@ Programs_DumpRenderTree_SOURCES = \ Tools/DumpRenderTree/WorkQueue.h \ Tools/DumpRenderTree/WorkQueueItem.h \ Tools/DumpRenderTree/config.h \ + Tools/DumpRenderTree/atk/AccessibilityCallbacks.h \ + Tools/DumpRenderTree/atk/AccessibilityCallbacksAtk.cpp \ + Tools/DumpRenderTree/atk/AccessibilityControllerAtk.cpp \ + Tools/DumpRenderTree/atk/AccessibilityUIElementAtk.cpp \ Tools/DumpRenderTree/cairo/PixelDumpSupportCairo.cpp \ Tools/DumpRenderTree/cairo/PixelDumpSupportCairo.h \ - Tools/DumpRenderTree/gtk/AccessibilityCallbacks.h \ - Tools/DumpRenderTree/gtk/AccessibilityCallbacks.cpp \ Tools/DumpRenderTree/gtk/AccessibilityControllerGtk.cpp \ Tools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp \ Tools/DumpRenderTree/gtk/DumpRenderTree.cpp \ -- 2.36.0