alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 Nuanti Ltd. |
jmalonzo@webkit.org | aaaea3b | 2009-08-08 07:39:48 +0000 | [diff] [blame] | 3 | * Copyright (C) 2009 Jan Alonzo |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 4 | * Copyright (C) 2009, 2010, 2011, 2012, 2019 Igalia S.L. |
mario@webkit.org | fecbacd | 2013-03-04 17:06:15 +0000 | [diff] [blame] | 5 | * Copyright (C) 2013 Samsung Electronics |
xan@webkit.org | e438710 | 2009-04-09 11:08:48 +0000 | [diff] [blame] | 6 | * |
| 7 | * Portions from Mozilla a11y, copyright as follows: |
| 8 | * |
| 9 | * The Original Code is mozilla.org code. |
| 10 | * |
| 11 | * The Initial Developer of the Original Code is |
| 12 | * Sun Microsystems, Inc. |
| 13 | * Portions created by the Initial Developer are Copyright (C) 2002 |
| 14 | * the Initial Developer. All Rights Reserved. |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 15 | * |
| 16 | * This library is free software; you can redistribute it and/or |
| 17 | * modify it under the terms of the GNU Library General Public |
| 18 | * License as published by the Free Software Foundation; either |
| 19 | * version 2 of the License, or (at your option) any later version. |
| 20 | * |
| 21 | * This library is distributed in the hope that it will be useful, |
| 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 24 | * Library General Public License for more details. |
| 25 | * |
| 26 | * You should have received a copy of the GNU Library General Public License |
| 27 | * along with this library; see the file COPYING.LIB. If not, write to |
| 28 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 29 | * Boston, MA 02110-1301, USA. |
| 30 | */ |
| 31 | |
| 32 | #include "config.h" |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 33 | #include "WebKitAccessible.h" |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 34 | |
psaavedra@igalia.com | 5b9fe19 | 2019-07-11 21:51:24 +0000 | [diff] [blame] | 35 | #if ENABLE(ACCESSIBILITY) |
ddkilzer@apple.com | 8d87863 | 2008-11-09 19:50:37 +0000 | [diff] [blame] | 36 | |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 37 | #include "AXObjectCache.h" |
mario.prada@samsung.com | 4fb934b | 2013-12-17 18:08:34 +0000 | [diff] [blame] | 38 | #include "AccessibilityList.h" |
akling@apple.com | 88e05f6 | 2013-09-16 15:17:24 +0000 | [diff] [blame] | 39 | #include "AccessibilityListBoxOption.h" |
cdumez@apple.com | b04d574 | 2014-10-22 21:45:20 +0000 | [diff] [blame] | 40 | #include "AccessibilityTable.h" |
jdiggs@igalia.com | 466ea21 | 2017-05-01 21:19:09 +0000 | [diff] [blame] | 41 | #include "AccessibilityTableCell.h" |
jdiggs@igalia.com | 238c580 | 2017-10-04 00:03:12 +0000 | [diff] [blame] | 42 | #include "AccessibilityTableRow.h" |
alp@webkit.org | c773899 | 2008-05-27 02:48:14 +0000 | [diff] [blame] | 43 | #include "Document.h" |
commit-queue@webkit.org | 02ea7a2 | 2017-03-03 06:35:25 +0000 | [diff] [blame] | 44 | #include "Editing.h" |
alp@webkit.org | c773899 | 2008-05-27 02:48:14 +0000 | [diff] [blame] | 45 | #include "Frame.h" |
| 46 | #include "FrameView.h" |
xan@webkit.org | 9561b2c | 2009-05-20 14:33:19 +0000 | [diff] [blame] | 47 | #include "HTMLNames.h" |
xan@webkit.org | 45b26ac | 2009-10-27 12:20:35 +0000 | [diff] [blame] | 48 | #include "HTMLTableElement.h" |
mario@webkit.org | 9adab66 | 2012-01-23 10:21:03 +0000 | [diff] [blame] | 49 | #include "HostWindow.h" |
jdiggs@igalia.com | 3504d46 | 2016-03-16 01:45:57 +0000 | [diff] [blame] | 50 | #include "RenderAncestorIterator.h" |
hyatt@apple.com | 8091486 | 2017-03-06 18:00:35 +0000 | [diff] [blame] | 51 | #include "RenderBlock.h" |
mario@webkit.org | 970eaf3 | 2012-01-24 18:37:45 +0000 | [diff] [blame] | 52 | #include "RenderObject.h" |
jdiggs@igalia.com | 2f555dc | 2016-03-05 21:35:57 +0000 | [diff] [blame] | 53 | #include "SVGElement.h" |
mario@webkit.org | 6a24ba1 | 2010-12-14 15:35:22 +0000 | [diff] [blame] | 54 | #include "Settings.h" |
commit-queue@webkit.org | 74bd2e8 | 2010-09-12 11:16:14 +0000 | [diff] [blame] | 55 | #include "TextIterator.h" |
tkent@chromium.org | 8c35c12 | 2013-03-06 13:00:14 +0000 | [diff] [blame] | 56 | #include "VisibleUnits.h" |
mario@webkit.org | 7f95c62 | 2010-11-01 15:05:36 +0000 | [diff] [blame] | 57 | #include "WebKitAccessibleHyperlink.h" |
mario@webkit.org | deec839 | 2012-01-23 14:45:23 +0000 | [diff] [blame] | 58 | #include "WebKitAccessibleInterfaceAction.h" |
mario@webkit.org | be1ce55 | 2012-01-24 11:03:51 +0000 | [diff] [blame] | 59 | #include "WebKitAccessibleInterfaceComponent.h" |
mario@webkit.org | f8344ff | 2012-01-24 11:40:44 +0000 | [diff] [blame] | 60 | #include "WebKitAccessibleInterfaceDocument.h" |
mario@webkit.org | fc51ca6 | 2012-01-24 11:47:51 +0000 | [diff] [blame] | 61 | #include "WebKitAccessibleInterfaceEditableText.h" |
mario@webkit.org | 4dbd982 | 2012-01-24 11:55:18 +0000 | [diff] [blame] | 62 | #include "WebKitAccessibleInterfaceHyperlinkImpl.h" |
mario@webkit.org | 7024353 | 2012-01-24 11:58:52 +0000 | [diff] [blame] | 63 | #include "WebKitAccessibleInterfaceHypertext.h" |
mario@webkit.org | da3e608 | 2012-01-24 12:04:16 +0000 | [diff] [blame] | 64 | #include "WebKitAccessibleInterfaceImage.h" |
mario@webkit.org | 7e5931d | 2012-01-24 12:25:13 +0000 | [diff] [blame] | 65 | #include "WebKitAccessibleInterfaceSelection.h" |
mario@webkit.org | cd9f1b3 | 2012-01-24 18:28:22 +0000 | [diff] [blame] | 66 | #include "WebKitAccessibleInterfaceTable.h" |
k.czech@samsung.com | 2608de9 | 2014-02-27 11:28:31 +0000 | [diff] [blame] | 67 | #include "WebKitAccessibleInterfaceTableCell.h" |
mario@webkit.org | 987d737 | 2012-01-24 18:02:08 +0000 | [diff] [blame] | 68 | #include "WebKitAccessibleInterfaceText.h" |
mario@webkit.org | 980269e | 2012-01-24 16:22:57 +0000 | [diff] [blame] | 69 | #include "WebKitAccessibleInterfaceValue.h" |
mario@webkit.org | 7ceffa4 | 2012-01-23 11:55:01 +0000 | [diff] [blame] | 70 | #include "WebKitAccessibleUtil.h" |
xan@webkit.org | e438710 | 2009-04-09 11:08:48 +0000 | [diff] [blame] | 71 | #include <glib/gprintf.h> |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 72 | #include <wtf/glib/WTFGType.h> |
benjamin@webkit.org | 9d72cb0 | 2013-04-22 22:52:23 +0000 | [diff] [blame] | 73 | #include <wtf/text/CString.h> |
mario@webkit.org | 8c5dd90 | 2012-11-09 19:47:40 +0000 | [diff] [blame] | 74 | |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 75 | using namespace WebCore; |
| 76 | |
mario@webkit.org | fecbacd | 2013-03-04 17:06:15 +0000 | [diff] [blame] | 77 | struct _WebKitAccessiblePrivate { |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 78 | AccessibilityObject* object; |
| 79 | |
mario@webkit.org | fecbacd | 2013-03-04 17:06:15 +0000 | [diff] [blame] | 80 | // Cached data for AtkObject. |
| 81 | CString accessibleName; |
| 82 | CString accessibleDescription; |
| 83 | |
| 84 | // Cached data for AtkAction. |
| 85 | CString actionName; |
| 86 | CString actionKeyBinding; |
| 87 | |
| 88 | // Cached data for AtkDocument. |
| 89 | CString documentLocale; |
| 90 | CString documentType; |
| 91 | CString documentEncoding; |
| 92 | CString documentURI; |
| 93 | |
| 94 | // Cached data for AtkImage. |
| 95 | CString imageDescription; |
| 96 | }; |
| 97 | |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 98 | WEBKIT_DEFINE_TYPE(WebKitAccessible, webkit_accessible, ATK_TYPE_OBJECT) |
mario@webkit.org | fecbacd | 2013-03-04 17:06:15 +0000 | [diff] [blame] | 99 | |
xan@webkit.org | c886cc6 | 2009-04-09 11:17:48 +0000 | [diff] [blame] | 100 | static AccessibilityObject* fallbackObject() |
| 101 | { |
akling@apple.com | ad2beb5 | 2014-12-25 07:50:20 +0000 | [diff] [blame] | 102 | static AccessibilityObject* object = &AccessibilityListBoxOption::create().leakRef(); |
xan@webkit.org | c886cc6 | 2009-04-09 11:17:48 +0000 | [diff] [blame] | 103 | return object; |
| 104 | } |
| 105 | |
mario@webkit.org | 5c96677 | 2012-01-24 18:48:50 +0000 | [diff] [blame] | 106 | static const gchar* webkitAccessibleGetName(AtkObject* object) |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 107 | { |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 108 | auto* accessible = WEBKIT_ACCESSIBLE(object); |
| 109 | returnValIfWebKitAccessibleIsInvalid(accessible, nullptr); |
mario@webkit.org | ff8cf0f | 2013-09-27 09:44:20 +0000 | [diff] [blame] | 110 | |
jdiggs@igalia.com | e184cee | 2016-05-18 07:12:09 +0000 | [diff] [blame] | 111 | Vector<AccessibilityText> textOrder; |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 112 | accessible->priv->object->accessibilityText(textOrder); |
jdiggs@igalia.com | e184cee | 2016-05-18 07:12:09 +0000 | [diff] [blame] | 113 | |
| 114 | for (const auto& text : textOrder) { |
| 115 | // FIXME: This check is here because AccessibilityNodeObject::titleElementText() |
| 116 | // appends an empty String for the LabelByElementText source when there is a |
| 117 | // titleUIElement(). Removing this check makes some fieldsets lose their name. |
| 118 | if (text.text.isEmpty()) |
| 119 | continue; |
| 120 | |
| 121 | // WebCore Accessibility should provide us with the text alternative computation |
| 122 | // in the order defined by that spec. So take the first thing that our platform |
| 123 | // does not expose via the AtkObject description. |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 124 | if (text.textSource != AccessibilityTextSource::Help && text.textSource != AccessibilityTextSource::Summary) |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 125 | return webkitAccessibleCacheAndReturnAtkProperty(accessible, AtkCachedAccessibleName, text.text.utf8()); |
commit-queue@webkit.org | 802c012 | 2012-09-11 01:41:27 +0000 | [diff] [blame] | 126 | } |
| 127 | |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 128 | return webkitAccessibleCacheAndReturnAtkProperty(accessible, AtkCachedAccessibleName, ""); |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 129 | } |
| 130 | |
mario@webkit.org | 5c96677 | 2012-01-24 18:48:50 +0000 | [diff] [blame] | 131 | static const gchar* webkitAccessibleGetDescription(AtkObject* object) |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 132 | { |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 133 | auto* accessible = WEBKIT_ACCESSIBLE(object); |
| 134 | returnValIfWebKitAccessibleIsInvalid(accessible, nullptr); |
mario@webkit.org | ff8cf0f | 2013-09-27 09:44:20 +0000 | [diff] [blame] | 135 | |
jdiggs@igalia.com | e184cee | 2016-05-18 07:12:09 +0000 | [diff] [blame] | 136 | Vector<AccessibilityText> textOrder; |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 137 | accessible->priv->object->accessibilityText(textOrder); |
jdiggs@igalia.com | 2f555dc | 2016-03-05 21:35:57 +0000 | [diff] [blame] | 138 | |
jdiggs@igalia.com | e184cee | 2016-05-18 07:12:09 +0000 | [diff] [blame] | 139 | bool nameTextAvailable = false; |
| 140 | for (const auto& text : textOrder) { |
| 141 | // WebCore Accessibility should provide us with the text alternative computation |
| 142 | // in the order defined by that spec. So take the first thing that our platform |
| 143 | // does not expose via the AtkObject name. |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 144 | if (text.textSource == AccessibilityTextSource::Help || text.textSource == AccessibilityTextSource::Summary) |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 145 | return webkitAccessibleCacheAndReturnAtkProperty(accessible, AtkCachedAccessibleDescription, text.text.utf8()); |
jdiggs@igalia.com | 2f555dc | 2016-03-05 21:35:57 +0000 | [diff] [blame] | 146 | |
jdiggs@igalia.com | e184cee | 2016-05-18 07:12:09 +0000 | [diff] [blame] | 147 | // If there is no other text alternative, the title tag contents will have been |
| 148 | // used for the AtkObject name. We don't want to duplicate it here. |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 149 | if (text.textSource == AccessibilityTextSource::TitleTag && nameTextAvailable) |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 150 | return webkitAccessibleCacheAndReturnAtkProperty(accessible, AtkCachedAccessibleDescription, text.text.utf8()); |
jdiggs@igalia.com | e184cee | 2016-05-18 07:12:09 +0000 | [diff] [blame] | 151 | |
| 152 | nameTextAvailable = true; |
jdiggs@igalia.com | 2f555dc | 2016-03-05 21:35:57 +0000 | [diff] [blame] | 153 | } |
| 154 | |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 155 | return webkitAccessibleCacheAndReturnAtkProperty(accessible, AtkCachedAccessibleDescription, ""); |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 156 | } |
| 157 | |
m.pakula@samsung.com | e026b6a | 2013-11-06 18:17:03 +0000 | [diff] [blame] | 158 | static void removeAtkRelationByType(AtkRelationSet* relationSet, AtkRelationType relationType) |
| 159 | { |
| 160 | int count = atk_relation_set_get_n_relations(relationSet); |
| 161 | for (int i = 0; i < count; i++) { |
| 162 | AtkRelation* relation = atk_relation_set_get_relation(relationSet, i); |
| 163 | if (atk_relation_get_relation_type(relation) == relationType) { |
| 164 | atk_relation_set_remove(relationSet, relation); |
| 165 | break; |
| 166 | } |
| 167 | } |
| 168 | } |
| 169 | |
eric@webkit.org | 0f6cb45 | 2009-10-22 23:07:56 +0000 | [diff] [blame] | 170 | static void setAtkRelationSetFromCoreObject(AccessibilityObject* coreObject, AtkRelationSet* relationSet) |
| 171 | { |
jdiggs@igalia.com | 3504d46 | 2016-03-16 01:45:57 +0000 | [diff] [blame] | 172 | // Elements with aria-labelledby should have the labelled-by relation as per the ARIA AAM spec. |
| 173 | // Controls with a label element and fieldsets with a legend element should also use this relation |
| 174 | // as per the HTML AAM spec. The reciprocal label-for relation should also be used. |
| 175 | removeAtkRelationByType(relationSet, ATK_RELATION_LABELLED_BY); |
jdiggs@igalia.com | 20c43fb | 2017-06-13 12:42:04 +0000 | [diff] [blame] | 176 | removeAtkRelationByType(relationSet, ATK_RELATION_LABEL_FOR); |
mario@webkit.org | 7e9f241 | 2011-04-06 16:50:25 +0000 | [diff] [blame] | 177 | if (coreObject->isControl()) { |
jdiggs@igalia.com | 3504d46 | 2016-03-16 01:45:57 +0000 | [diff] [blame] | 178 | if (AccessibilityObject* label = coreObject->correspondingLabelForControlElement()) |
carlosgc@webkit.org | 9d3f9a4 | 2019-04-05 07:35:24 +0000 | [diff] [blame] | 179 | atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_LABELLED_BY, ATK_OBJECT(label->wrapper())); |
jdiggs@igalia.com | 3504d46 | 2016-03-16 01:45:57 +0000 | [diff] [blame] | 180 | } else if (coreObject->isFieldset()) { |
| 181 | if (AccessibilityObject* label = coreObject->titleUIElement()) |
carlosgc@webkit.org | 9d3f9a4 | 2019-04-05 07:35:24 +0000 | [diff] [blame] | 182 | atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_LABELLED_BY, ATK_OBJECT(label->wrapper())); |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 183 | } else if (coreObject->roleValue() == AccessibilityRole::Legend) { |
hyatt@apple.com | 8091486 | 2017-03-06 18:00:35 +0000 | [diff] [blame] | 184 | if (RenderBlock* renderFieldset = ancestorsOfType<RenderBlock>(*coreObject->renderer()).first()) { |
| 185 | if (renderFieldset->isFieldset()) { |
| 186 | AccessibilityObject* fieldset = coreObject->axObjectCache()->getOrCreate(renderFieldset); |
carlosgc@webkit.org | 9d3f9a4 | 2019-04-05 07:35:24 +0000 | [diff] [blame] | 187 | atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_LABEL_FOR, ATK_OBJECT(fieldset->wrapper())); |
hyatt@apple.com | 8091486 | 2017-03-06 18:00:35 +0000 | [diff] [blame] | 188 | } |
m.pakula@samsung.com | e026b6a | 2013-11-06 18:17:03 +0000 | [diff] [blame] | 189 | } |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 190 | } else if (AccessibilityObject* control = coreObject->correspondingControlForLabelElement()) |
carlosgc@webkit.org | 9d3f9a4 | 2019-04-05 07:35:24 +0000 | [diff] [blame] | 191 | atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_LABEL_FOR, ATK_OBJECT(control->wrapper())); |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 192 | else { |
jdiggs@igalia.com | 3504d46 | 2016-03-16 01:45:57 +0000 | [diff] [blame] | 193 | AccessibilityObject::AccessibilityChildrenVector ariaLabelledByElements; |
| 194 | coreObject->ariaLabelledByElements(ariaLabelledByElements); |
| 195 | for (const auto& accessibilityObject : ariaLabelledByElements) |
carlosgc@webkit.org | 9d3f9a4 | 2019-04-05 07:35:24 +0000 | [diff] [blame] | 196 | atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_LABELLED_BY, ATK_OBJECT(accessibilityObject->wrapper())); |
eric@webkit.org | 0f6cb45 | 2009-10-22 23:07:56 +0000 | [diff] [blame] | 197 | } |
k.czech@samsung.com | 2254581 | 2014-01-21 09:10:25 +0000 | [diff] [blame] | 198 | |
jdiggs@igalia.com | 20c43fb | 2017-06-13 12:42:04 +0000 | [diff] [blame] | 199 | // Elements referenced by aria-labelledby should have the label-for relation as per the ARIA AAM spec. |
| 200 | AccessibilityObject::AccessibilityChildrenVector labels; |
| 201 | coreObject->ariaLabelledByReferencingElements(labels); |
| 202 | for (const auto& accessibilityObject : labels) |
carlosgc@webkit.org | 9d3f9a4 | 2019-04-05 07:35:24 +0000 | [diff] [blame] | 203 | atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_LABEL_FOR, ATK_OBJECT(accessibilityObject->wrapper())); |
jdiggs@igalia.com | 20c43fb | 2017-06-13 12:42:04 +0000 | [diff] [blame] | 204 | |
jdiggs@igalia.com | 3504d46 | 2016-03-16 01:45:57 +0000 | [diff] [blame] | 205 | // Elements with aria-flowto should have the flows-to relation as per the ARIA AAM spec. |
| 206 | removeAtkRelationByType(relationSet, ATK_RELATION_FLOWS_TO); |
| 207 | AccessibilityObject::AccessibilityChildrenVector ariaFlowToElements; |
| 208 | coreObject->ariaFlowToElements(ariaFlowToElements); |
| 209 | for (const auto& accessibilityObject : ariaFlowToElements) |
carlosgc@webkit.org | 9d3f9a4 | 2019-04-05 07:35:24 +0000 | [diff] [blame] | 210 | atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_FLOWS_TO, ATK_OBJECT(accessibilityObject->wrapper())); |
k.czech@samsung.com | 7e9868e | 2014-01-29 13:16:27 +0000 | [diff] [blame] | 211 | |
jdiggs@igalia.com | 20c43fb | 2017-06-13 12:42:04 +0000 | [diff] [blame] | 212 | // Elements referenced by aria-flowto should have the flows-from relation as per the ARIA AAM spec. |
| 213 | removeAtkRelationByType(relationSet, ATK_RELATION_FLOWS_FROM); |
| 214 | AccessibilityObject::AccessibilityChildrenVector flowFrom; |
| 215 | coreObject->ariaFlowToReferencingElements(flowFrom); |
| 216 | for (const auto& accessibilityObject : flowFrom) |
carlosgc@webkit.org | 9d3f9a4 | 2019-04-05 07:35:24 +0000 | [diff] [blame] | 217 | atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_FLOWS_FROM, ATK_OBJECT(accessibilityObject->wrapper())); |
jdiggs@igalia.com | 20c43fb | 2017-06-13 12:42:04 +0000 | [diff] [blame] | 218 | |
jdiggs@igalia.com | 3504d46 | 2016-03-16 01:45:57 +0000 | [diff] [blame] | 219 | // Elements with aria-describedby should have the described-by relation as per the ARIA AAM spec. |
| 220 | removeAtkRelationByType(relationSet, ATK_RELATION_DESCRIBED_BY); |
| 221 | AccessibilityObject::AccessibilityChildrenVector ariaDescribedByElements; |
| 222 | coreObject->ariaDescribedByElements(ariaDescribedByElements); |
| 223 | for (const auto& accessibilityObject : ariaDescribedByElements) |
carlosgc@webkit.org | 9d3f9a4 | 2019-04-05 07:35:24 +0000 | [diff] [blame] | 224 | atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_DESCRIBED_BY, ATK_OBJECT(accessibilityObject->wrapper())); |
k.czech@samsung.com | b8ad4bf | 2014-02-03 09:16:54 +0000 | [diff] [blame] | 225 | |
jdiggs@igalia.com | 20c43fb | 2017-06-13 12:42:04 +0000 | [diff] [blame] | 226 | // Elements referenced by aria-describedby should have the description-for relation as per the ARIA AAM spec. |
| 227 | removeAtkRelationByType(relationSet, ATK_RELATION_DESCRIPTION_FOR); |
| 228 | AccessibilityObject::AccessibilityChildrenVector describers; |
| 229 | coreObject->ariaDescribedByReferencingElements(describers); |
| 230 | for (const auto& accessibilityObject : describers) |
carlosgc@webkit.org | 9d3f9a4 | 2019-04-05 07:35:24 +0000 | [diff] [blame] | 231 | atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_DESCRIPTION_FOR, ATK_OBJECT(accessibilityObject->wrapper())); |
jdiggs@igalia.com | 20c43fb | 2017-06-13 12:42:04 +0000 | [diff] [blame] | 232 | |
jdiggs@igalia.com | 3504d46 | 2016-03-16 01:45:57 +0000 | [diff] [blame] | 233 | // Elements with aria-controls should have the controller-for relation as per the ARIA AAM spec. |
| 234 | removeAtkRelationByType(relationSet, ATK_RELATION_CONTROLLER_FOR); |
| 235 | AccessibilityObject::AccessibilityChildrenVector ariaControls; |
| 236 | coreObject->ariaControlsElements(ariaControls); |
| 237 | for (const auto& accessibilityObject : ariaControls) |
carlosgc@webkit.org | 9d3f9a4 | 2019-04-05 07:35:24 +0000 | [diff] [blame] | 238 | atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_CONTROLLER_FOR, ATK_OBJECT(accessibilityObject->wrapper())); |
jdiggs@igalia.com | 20c43fb | 2017-06-13 12:42:04 +0000 | [diff] [blame] | 239 | |
| 240 | // Elements referenced by aria-controls should have the controlled-by relation as per the ARIA AAM spec. |
| 241 | removeAtkRelationByType(relationSet, ATK_RELATION_CONTROLLED_BY); |
| 242 | AccessibilityObject::AccessibilityChildrenVector controllers; |
| 243 | coreObject->ariaControlsReferencingElements(controllers); |
| 244 | for (const auto& accessibilityObject : controllers) |
carlosgc@webkit.org | 9d3f9a4 | 2019-04-05 07:35:24 +0000 | [diff] [blame] | 245 | atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_CONTROLLED_BY, ATK_OBJECT(accessibilityObject->wrapper())); |
jdiggs@igalia.com | 20c43fb | 2017-06-13 12:42:04 +0000 | [diff] [blame] | 246 | |
| 247 | // Elements with aria-owns should have the node-parent-of relation as per the ARIA AAM spec. |
| 248 | removeAtkRelationByType(relationSet, ATK_RELATION_NODE_PARENT_OF); |
| 249 | AccessibilityObject::AccessibilityChildrenVector ariaOwns; |
| 250 | coreObject->ariaOwnsElements(ariaOwns); |
| 251 | for (const auto& accessibilityObject : ariaOwns) |
carlosgc@webkit.org | 9d3f9a4 | 2019-04-05 07:35:24 +0000 | [diff] [blame] | 252 | atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_NODE_PARENT_OF, ATK_OBJECT(accessibilityObject->wrapper())); |
jdiggs@igalia.com | 20c43fb | 2017-06-13 12:42:04 +0000 | [diff] [blame] | 253 | |
| 254 | // Elements referenced by aria-owns should have the node-child-of relation as per the ARIA AAM spec. |
| 255 | removeAtkRelationByType(relationSet, ATK_RELATION_NODE_CHILD_OF); |
| 256 | AccessibilityObject::AccessibilityChildrenVector owners; |
| 257 | coreObject->ariaOwnsReferencingElements(owners); |
| 258 | for (const auto& accessibilityObject : owners) |
carlosgc@webkit.org | 9d3f9a4 | 2019-04-05 07:35:24 +0000 | [diff] [blame] | 259 | atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_NODE_CHILD_OF, ATK_OBJECT(accessibilityObject->wrapper())); |
jdiggs@igalia.com | 3a11d3f | 2017-06-26 16:45:34 +0000 | [diff] [blame] | 260 | |
| 261 | #if ATK_CHECK_VERSION(2, 25, 2) |
| 262 | // Elements with aria-details should have the details relation as per the ARIA AAM spec. |
| 263 | removeAtkRelationByType(relationSet, ATK_RELATION_DETAILS); |
| 264 | AccessibilityObject::AccessibilityChildrenVector ariaDetails; |
| 265 | coreObject->ariaDetailsElements(ariaDetails); |
| 266 | for (const auto& accessibilityObject : ariaDetails) |
carlosgc@webkit.org | 9d3f9a4 | 2019-04-05 07:35:24 +0000 | [diff] [blame] | 267 | atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_DETAILS, ATK_OBJECT(accessibilityObject->wrapper())); |
jdiggs@igalia.com | 3a11d3f | 2017-06-26 16:45:34 +0000 | [diff] [blame] | 268 | |
| 269 | // Elements referenced by aria-details should have the details-for relation as per the ARIA AAM spec. |
| 270 | removeAtkRelationByType(relationSet, ATK_RELATION_DETAILS_FOR); |
| 271 | AccessibilityObject::AccessibilityChildrenVector details; |
| 272 | coreObject->ariaDetailsReferencingElements(details); |
| 273 | for (const auto& accessibilityObject : details) |
carlosgc@webkit.org | 9d3f9a4 | 2019-04-05 07:35:24 +0000 | [diff] [blame] | 274 | atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_DETAILS_FOR, ATK_OBJECT(accessibilityObject->wrapper())); |
jdiggs@igalia.com | 3a11d3f | 2017-06-26 16:45:34 +0000 | [diff] [blame] | 275 | |
| 276 | // Elements with aria-errormessage should have the error-message relation as per the ARIA AAM spec. |
| 277 | removeAtkRelationByType(relationSet, ATK_RELATION_ERROR_MESSAGE); |
| 278 | AccessibilityObject::AccessibilityChildrenVector ariaErrorMessage; |
| 279 | coreObject->ariaErrorMessageElements(ariaErrorMessage); |
| 280 | for (const auto& accessibilityObject : ariaErrorMessage) |
carlosgc@webkit.org | 9d3f9a4 | 2019-04-05 07:35:24 +0000 | [diff] [blame] | 281 | atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_ERROR_MESSAGE, ATK_OBJECT(accessibilityObject->wrapper())); |
jdiggs@igalia.com | 3a11d3f | 2017-06-26 16:45:34 +0000 | [diff] [blame] | 282 | |
| 283 | // Elements referenced by aria-errormessage should have the error-for relation as per the ARIA AAM spec. |
| 284 | removeAtkRelationByType(relationSet, ATK_RELATION_ERROR_FOR); |
| 285 | AccessibilityObject::AccessibilityChildrenVector errors; |
| 286 | coreObject->ariaErrorMessageReferencingElements(errors); |
| 287 | for (const auto& accessibilityObject : errors) |
carlosgc@webkit.org | 9d3f9a4 | 2019-04-05 07:35:24 +0000 | [diff] [blame] | 288 | atk_relation_set_add_relation_by_type(relationSet, ATK_RELATION_ERROR_FOR, ATK_OBJECT(accessibilityObject->wrapper())); |
jdiggs@igalia.com | 3a11d3f | 2017-06-26 16:45:34 +0000 | [diff] [blame] | 289 | #endif |
eric@webkit.org | 0f6cb45 | 2009-10-22 23:07:56 +0000 | [diff] [blame] | 290 | } |
| 291 | |
mario@webkit.org | 86390a1 | 2011-01-07 17:34:02 +0000 | [diff] [blame] | 292 | static bool isRootObject(AccessibilityObject* coreObject) |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 293 | { |
mario@webkit.org | 86390a1 | 2011-01-07 17:34:02 +0000 | [diff] [blame] | 294 | // The root accessible object in WebCore is always an object with |
| 295 | // the ScrolledArea role with one child with the WebArea role. |
| 296 | if (!coreObject || !coreObject->isScrollView()) |
| 297 | return false; |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 298 | |
mario@webkit.org | 86390a1 | 2011-01-07 17:34:02 +0000 | [diff] [blame] | 299 | AccessibilityObject* firstChild = coreObject->firstChild(); |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 300 | return firstChild && firstChild->isWebArea(); |
eric@webkit.org | 1f5f7fe | 2009-11-04 10:35:56 +0000 | [diff] [blame] | 301 | } |
| 302 | |
mario@webkit.org | 5c96677 | 2012-01-24 18:48:50 +0000 | [diff] [blame] | 303 | static AtkObject* webkitAccessibleGetParent(AtkObject* object) |
eric@webkit.org | 1f5f7fe | 2009-11-04 10:35:56 +0000 | [diff] [blame] | 304 | { |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 305 | auto* accessible = WEBKIT_ACCESSIBLE(object); |
| 306 | returnValIfWebKitAccessibleIsInvalid(accessible, nullptr); |
mario@webkit.org | ff8cf0f | 2013-09-27 09:44:20 +0000 | [diff] [blame] | 307 | |
mario@webkit.org | 46e9b26 | 2011-11-17 11:50:07 +0000 | [diff] [blame] | 308 | // Check first if the parent has been already set. |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 309 | AtkObject* accessibleParent = ATK_OBJECT_CLASS(webkit_accessible_parent_class)->get_parent(object); |
mario@webkit.org | 46e9b26 | 2011-11-17 11:50:07 +0000 | [diff] [blame] | 310 | if (accessibleParent) |
| 311 | return accessibleParent; |
| 312 | |
| 313 | // Parent not set yet, so try to find it in the hierarchy. |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 314 | auto* coreObject = accessible->priv->object; |
| 315 | auto* coreParent = coreObject->parentObjectUnignored(); |
| 316 | if (!coreParent && isRootObject(coreObject)) { |
| 317 | // The top level object claims to not have a parent. This makes it |
| 318 | // impossible for assistive technologies to ascend the accessible |
| 319 | // hierarchy all the way to the application. (Bug 30489) |
| 320 | if (!coreObject->document()) |
| 321 | return nullptr; |
| 322 | } |
eric@webkit.org | 1f5f7fe | 2009-11-04 10:35:56 +0000 | [diff] [blame] | 323 | |
carlosgc@webkit.org | 9d3f9a4 | 2019-04-05 07:35:24 +0000 | [diff] [blame] | 324 | return coreParent ? ATK_OBJECT(coreParent->wrapper()) : nullptr; |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 325 | } |
| 326 | |
mario@webkit.org | 5c96677 | 2012-01-24 18:48:50 +0000 | [diff] [blame] | 327 | static gint webkitAccessibleGetNChildren(AtkObject* object) |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 328 | { |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 329 | auto* accessible = WEBKIT_ACCESSIBLE(object); |
| 330 | returnValIfWebKitAccessibleIsInvalid(accessible, 0); |
mario@webkit.org | ff8cf0f | 2013-09-27 09:44:20 +0000 | [diff] [blame] | 331 | |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 332 | return accessible->priv->object->children().size(); |
mario@webkit.org | 868b5ea | 2011-06-24 09:06:32 +0000 | [diff] [blame] | 333 | } |
| 334 | |
mario@webkit.org | 5c96677 | 2012-01-24 18:48:50 +0000 | [diff] [blame] | 335 | static AtkObject* webkitAccessibleRefChild(AtkObject* object, gint index) |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 336 | { |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 337 | auto* accessible = WEBKIT_ACCESSIBLE(object); |
| 338 | returnValIfWebKitAccessibleIsInvalid(accessible, nullptr); |
mario@webkit.org | ff8cf0f | 2013-09-27 09:44:20 +0000 | [diff] [blame] | 339 | |
mario@webkit.org | 868b5ea | 2011-06-24 09:06:32 +0000 | [diff] [blame] | 340 | if (index < 0) |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 341 | return nullptr; |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 342 | |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 343 | const auto& children = accessible->priv->object->children(); |
jdiggs@igalia.com | e8a090d | 2014-12-03 02:02:36 +0000 | [diff] [blame] | 344 | if (static_cast<size_t>(index) >= children.size()) |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 345 | return nullptr; |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 346 | |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 347 | auto& coreChild = children[index]; |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 348 | if (!coreChild) |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 349 | return nullptr; |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 350 | |
carlosgc@webkit.org | 2dd6e72 | 2019-04-22 07:58:11 +0000 | [diff] [blame] | 351 | auto* child = coreChild->wrapper(); |
| 352 | if (!child) |
| 353 | return nullptr; |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 354 | |
carlosgc@webkit.org | 2dd6e72 | 2019-04-22 07:58:11 +0000 | [diff] [blame] | 355 | atk_object_set_parent(ATK_OBJECT(child), object); |
| 356 | return ATK_OBJECT(g_object_ref(child)); |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 357 | } |
| 358 | |
mario@webkit.org | 5c96677 | 2012-01-24 18:48:50 +0000 | [diff] [blame] | 359 | static gint webkitAccessibleGetIndexInParent(AtkObject* object) |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 360 | { |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 361 | auto* accessible = WEBKIT_ACCESSIBLE(object); |
| 362 | returnValIfWebKitAccessibleIsInvalid(accessible, -1); |
mario@webkit.org | ff8cf0f | 2013-09-27 09:44:20 +0000 | [diff] [blame] | 363 | |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 364 | auto* coreObject = accessible->priv->object; |
| 365 | auto* parent = coreObject->parentObjectUnignored(); |
mario@webkit.org | 86390a1 | 2011-01-07 17:34:02 +0000 | [diff] [blame] | 366 | if (!parent && isRootObject(coreObject)) { |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 367 | if (!coreObject->document()) |
| 368 | return -1; |
| 369 | |
| 370 | auto* atkParent = parent ? ATK_OBJECT(parent->wrapper()) : nullptr; |
eric@webkit.org | 1f5f7fe | 2009-11-04 10:35:56 +0000 | [diff] [blame] | 371 | if (!atkParent) |
| 372 | return -1; |
| 373 | |
| 374 | unsigned count = atk_object_get_n_accessible_children(atkParent); |
| 375 | for (unsigned i = 0; i < count; ++i) { |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 376 | GRefPtr<AtkObject> child = adoptGRef(atk_object_ref_accessible_child(atkParent, i)); |
| 377 | if (child.get() == object) |
eric@webkit.org | 1f5f7fe | 2009-11-04 10:35:56 +0000 | [diff] [blame] | 378 | return i; |
| 379 | } |
| 380 | } |
xan@webkit.org | 1f5349a | 2009-10-27 09:20:21 +0000 | [diff] [blame] | 381 | |
commit-queue@webkit.org | 54a624e | 2013-01-16 18:00:17 +0000 | [diff] [blame] | 382 | if (!parent) |
| 383 | return -1; |
| 384 | |
commit-queue@webkit.org | bf18355 | 2012-02-22 09:28:57 +0000 | [diff] [blame] | 385 | size_t index = parent->children().find(coreObject); |
| 386 | return (index == WTF::notFound) ? -1 : index; |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 387 | } |
| 388 | |
mario@webkit.org | 5c96677 | 2012-01-24 18:48:50 +0000 | [diff] [blame] | 389 | static AtkAttributeSet* webkitAccessibleGetAttributes(AtkObject* object) |
eric@webkit.org | 8449619 | 2009-10-17 20:00:33 +0000 | [diff] [blame] | 390 | { |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 391 | auto* accessible = WEBKIT_ACCESSIBLE(object); |
| 392 | returnValIfWebKitAccessibleIsInvalid(accessible, nullptr); |
mario@webkit.org | ff8cf0f | 2013-09-27 09:44:20 +0000 | [diff] [blame] | 393 | |
commit-queue@webkit.org | 9a24e2d | 2015-05-29 04:53:35 +0000 | [diff] [blame] | 394 | AtkAttributeSet* attributeSet = nullptr; |
mario@webkit.org | 8c5dd90 | 2012-11-09 19:47:40 +0000 | [diff] [blame] | 395 | #if PLATFORM(GTK) |
mario@webkit.org | f8344ff | 2012-01-24 11:40:44 +0000 | [diff] [blame] | 396 | attributeSet = addToAtkAttributeSet(attributeSet, "toolkit", "WebKitGtk"); |
carlosgc@webkit.org | fdfb04c | 2019-05-21 12:45:08 +0000 | [diff] [blame] | 397 | #elif PLATFORM(WPE) |
| 398 | attributeSet = addToAtkAttributeSet(attributeSet, "toolkit", "WPEWebKit"); |
mario@webkit.org | 8c5dd90 | 2012-11-09 19:47:40 +0000 | [diff] [blame] | 399 | #endif |
eric@webkit.org | f4efc40 | 2010-05-15 09:55:52 +0000 | [diff] [blame] | 400 | |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 401 | auto* coreObject = accessible->priv->object; |
commit-queue@webkit.org | a9398dd | 2010-10-26 19:19:29 +0000 | [diff] [blame] | 402 | |
commit-queue@webkit.org | 357dc22 | 2013-01-10 00:09:41 +0000 | [diff] [blame] | 403 | // Hack needed for WebKit2 tests because obtaining an element by its ID |
| 404 | // cannot be done from the UIProcess. Assistive technologies have no need |
| 405 | // for this information. |
jdiggs@igalia.com | bcff952 | 2014-11-28 00:24:43 +0000 | [diff] [blame] | 406 | Element* element = coreObject->element() ? coreObject->element() : coreObject->actionElement(); |
| 407 | if (element) { |
jdiggs@igalia.com | 5a8352d | 2015-06-17 20:03:13 +0000 | [diff] [blame] | 408 | String tagName = element->tagName(); |
| 409 | if (!tagName.isEmpty()) |
darin@apple.com | 4d716f2 | 2016-02-01 05:46:20 +0000 | [diff] [blame] | 410 | attributeSet = addToAtkAttributeSet(attributeSet, "tag", tagName.convertToASCIILowercase().utf8().data()); |
jdiggs@igalia.com | bcff952 | 2014-11-28 00:24:43 +0000 | [diff] [blame] | 411 | String id = element->getIdAttribute().string(); |
commit-queue@webkit.org | 357dc22 | 2013-01-10 00:09:41 +0000 | [diff] [blame] | 412 | if (!id.isEmpty()) |
| 413 | attributeSet = addToAtkAttributeSet(attributeSet, "html-id", id.utf8().data()); |
| 414 | } |
| 415 | |
jdiggs@igalia.com | 7ccbaee | 2017-10-03 01:02:47 +0000 | [diff] [blame] | 416 | int level = coreObject->isHeading() ? coreObject->headingLevel() : coreObject->hierarchicalLevel(); |
| 417 | if (level) { |
| 418 | String value = String::number(level); |
mario@webkit.org | f8344ff | 2012-01-24 11:40:44 +0000 | [diff] [blame] | 419 | attributeSet = addToAtkAttributeSet(attributeSet, "level", value.utf8().data()); |
eric@webkit.org | 8449619 | 2009-10-17 20:00:33 +0000 | [diff] [blame] | 420 | } |
commit-queue@webkit.org | a9398dd | 2010-10-26 19:19:29 +0000 | [diff] [blame] | 421 | |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 422 | if (coreObject->roleValue() == AccessibilityRole::MathElement) { |
| 423 | if (coreObject->isMathMultiscriptObject(AccessibilityMathMultiscriptObjectType::PreSuperscript) || coreObject->isMathMultiscriptObject(AccessibilityMathMultiscriptObjectType::PreSubscript)) |
jdiggs@igalia.com | 6b8c173 | 2015-01-28 17:02:32 +0000 | [diff] [blame] | 424 | attributeSet = addToAtkAttributeSet(attributeSet, "multiscript-type", "pre"); |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 425 | else if (coreObject->isMathMultiscriptObject(AccessibilityMathMultiscriptObjectType::PostSuperscript) || coreObject->isMathMultiscriptObject(AccessibilityMathMultiscriptObjectType::PostSubscript)) |
jdiggs@igalia.com | 6b8c173 | 2015-01-28 17:02:32 +0000 | [diff] [blame] | 426 | attributeSet = addToAtkAttributeSet(attributeSet, "multiscript-type", "post"); |
| 427 | } |
| 428 | |
andresg_22@apple.com | 3374e6d | 2020-02-24 00:54:42 +0000 | [diff] [blame] | 429 | if (is<AccessibilityTable>(*coreObject) && downcast<AccessibilityTable>(*coreObject).isExposable()) { |
jdiggs@igalia.com | 466ea21 | 2017-05-01 21:19:09 +0000 | [diff] [blame] | 430 | auto& table = downcast<AccessibilityTable>(*coreObject); |
n_wang@apple.com | 7065037 | 2017-11-19 06:59:59 +0000 | [diff] [blame] | 431 | int rowCount = table.axRowCount(); |
jdiggs@igalia.com | 466ea21 | 2017-05-01 21:19:09 +0000 | [diff] [blame] | 432 | if (rowCount) |
| 433 | attributeSet = addToAtkAttributeSet(attributeSet, "rowcount", String::number(rowCount).utf8().data()); |
| 434 | |
n_wang@apple.com | 7065037 | 2017-11-19 06:59:59 +0000 | [diff] [blame] | 435 | int columnCount = table.axColumnCount(); |
jdiggs@igalia.com | 466ea21 | 2017-05-01 21:19:09 +0000 | [diff] [blame] | 436 | if (columnCount) |
| 437 | attributeSet = addToAtkAttributeSet(attributeSet, "colcount", String::number(columnCount).utf8().data()); |
jdiggs@igalia.com | 238c580 | 2017-10-04 00:03:12 +0000 | [diff] [blame] | 438 | } else if (is<AccessibilityTableRow>(*coreObject)) { |
| 439 | auto& row = downcast<AccessibilityTableRow>(*coreObject); |
n_wang@apple.com | 7065037 | 2017-11-19 06:59:59 +0000 | [diff] [blame] | 440 | int rowIndex = row.axRowIndex(); |
jdiggs@igalia.com | 238c580 | 2017-10-04 00:03:12 +0000 | [diff] [blame] | 441 | if (rowIndex != -1) |
| 442 | attributeSet = addToAtkAttributeSet(attributeSet, "rowindex", String::number(rowIndex).utf8().data()); |
| 443 | } else if (is<AccessibilityTableCell>(*coreObject)) { |
jdiggs@igalia.com | 466ea21 | 2017-05-01 21:19:09 +0000 | [diff] [blame] | 444 | auto& cell = downcast<AccessibilityTableCell>(*coreObject); |
n_wang@apple.com | 7065037 | 2017-11-19 06:59:59 +0000 | [diff] [blame] | 445 | int rowIndex = cell.axRowIndex(); |
jdiggs@igalia.com | 466ea21 | 2017-05-01 21:19:09 +0000 | [diff] [blame] | 446 | if (rowIndex != -1) |
| 447 | attributeSet = addToAtkAttributeSet(attributeSet, "rowindex", String::number(rowIndex).utf8().data()); |
| 448 | |
n_wang@apple.com | 7065037 | 2017-11-19 06:59:59 +0000 | [diff] [blame] | 449 | int columnIndex = cell.axColumnIndex(); |
jdiggs@igalia.com | 466ea21 | 2017-05-01 21:19:09 +0000 | [diff] [blame] | 450 | if (columnIndex != -1) |
| 451 | attributeSet = addToAtkAttributeSet(attributeSet, "colindex", String::number(columnIndex).utf8().data()); |
| 452 | |
n_wang@apple.com | 7065037 | 2017-11-19 06:59:59 +0000 | [diff] [blame] | 453 | int rowSpan = cell.axRowSpan(); |
jdiggs@igalia.com | 466ea21 | 2017-05-01 21:19:09 +0000 | [diff] [blame] | 454 | if (rowSpan != -1) |
| 455 | attributeSet = addToAtkAttributeSet(attributeSet, "rowspan", String::number(rowSpan).utf8().data()); |
| 456 | |
n_wang@apple.com | 7065037 | 2017-11-19 06:59:59 +0000 | [diff] [blame] | 457 | int columnSpan = cell.axColumnSpan(); |
jdiggs@igalia.com | 466ea21 | 2017-05-01 21:19:09 +0000 | [diff] [blame] | 458 | if (columnSpan != -1) |
| 459 | attributeSet = addToAtkAttributeSet(attributeSet, "colspan", String::number(columnSpan).utf8().data()); |
| 460 | } |
commit-queue@webkit.org | a9398dd | 2010-10-26 19:19:29 +0000 | [diff] [blame] | 461 | |
commit-queue@webkit.org | 2db4aaa | 2012-12-10 01:09:32 +0000 | [diff] [blame] | 462 | String placeholder = coreObject->placeholderValue(); |
| 463 | if (!placeholder.isEmpty()) |
| 464 | attributeSet = addToAtkAttributeSet(attributeSet, "placeholder-text", placeholder.utf8().data()); |
| 465 | |
n_wang@apple.com | 319609c | 2017-11-17 02:24:53 +0000 | [diff] [blame] | 466 | if (coreObject->supportsAutoComplete()) |
| 467 | attributeSet = addToAtkAttributeSet(attributeSet, "autocomplete", coreObject->autoCompleteValue().utf8().data()); |
jdiggs@igalia.com | 6d1214c | 2017-04-30 18:12:30 +0000 | [diff] [blame] | 468 | |
n_wang@apple.com | 319609c | 2017-11-17 02:24:53 +0000 | [diff] [blame] | 469 | if (coreObject->supportsHasPopup()) |
commit-queue@webkit.org | 4e345dc | 2019-07-02 20:24:24 +0000 | [diff] [blame] | 470 | attributeSet = addToAtkAttributeSet(attributeSet, "haspopup", coreObject->popupValue().utf8().data()); |
commit-queue@webkit.org | 5945f76 | 2013-07-16 12:55:56 +0000 | [diff] [blame] | 471 | |
n_wang@apple.com | 319609c | 2017-11-17 02:24:53 +0000 | [diff] [blame] | 472 | if (coreObject->supportsCurrent()) |
| 473 | attributeSet = addToAtkAttributeSet(attributeSet, "current", coreObject->currentValue().utf8().data()); |
jdiggs@igalia.com | 1975e35 | 2017-04-26 23:26:49 +0000 | [diff] [blame] | 474 | |
jdiggs@igalia.com | 7f1cb42 | 2017-10-09 17:12:34 +0000 | [diff] [blame] | 475 | // The Core AAM states that an explicitly-set value should be exposed, including "none". |
| 476 | if (coreObject->hasAttribute(HTMLNames::aria_sortAttr)) { |
| 477 | switch (coreObject->sortDirection()) { |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 478 | case AccessibilitySortDirection::Invalid: |
jdiggs@igalia.com | 7f1cb42 | 2017-10-09 17:12:34 +0000 | [diff] [blame] | 479 | break; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 480 | case AccessibilitySortDirection::Ascending: |
jdiggs@igalia.com | 7f1cb42 | 2017-10-09 17:12:34 +0000 | [diff] [blame] | 481 | attributeSet = addToAtkAttributeSet(attributeSet, "sort", "ascending"); |
| 482 | break; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 483 | case AccessibilitySortDirection::Descending: |
jdiggs@igalia.com | 7f1cb42 | 2017-10-09 17:12:34 +0000 | [diff] [blame] | 484 | attributeSet = addToAtkAttributeSet(attributeSet, "sort", "descending"); |
| 485 | break; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 486 | case AccessibilitySortDirection::Other: |
jdiggs@igalia.com | 7f1cb42 | 2017-10-09 17:12:34 +0000 | [diff] [blame] | 487 | attributeSet = addToAtkAttributeSet(attributeSet, "sort", "other"); |
| 488 | break; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 489 | case AccessibilitySortDirection::None: |
jdiggs@igalia.com | 7f1cb42 | 2017-10-09 17:12:34 +0000 | [diff] [blame] | 490 | attributeSet = addToAtkAttributeSet(attributeSet, "sort", "none"); |
| 491 | } |
mario@webkit.org | e2f7e78 | 2013-09-18 08:28:59 +0000 | [diff] [blame] | 492 | } |
commit-queue@webkit.org | 88d00b6 | 2013-09-03 11:29:33 +0000 | [diff] [blame] | 493 | |
n_wang@apple.com | 7065037 | 2017-11-19 06:59:59 +0000 | [diff] [blame] | 494 | if (coreObject->supportsPosInSet()) |
| 495 | attributeSet = addToAtkAttributeSet(attributeSet, "posinset", String::number(coreObject->posInSet()).utf8().data()); |
k.czech@samsung.com | dcc76c7 | 2014-03-11 09:04:08 +0000 | [diff] [blame] | 496 | |
n_wang@apple.com | 7065037 | 2017-11-19 06:59:59 +0000 | [diff] [blame] | 497 | if (coreObject->supportsSetSize()) |
| 498 | attributeSet = addToAtkAttributeSet(attributeSet, "setsize", String::number(coreObject->setSize()).utf8().data()); |
k.czech@samsung.com | dcc76c7 | 2014-03-11 09:04:08 +0000 | [diff] [blame] | 499 | |
n_wang@apple.com | ba6eaf4 | 2017-11-17 23:14:18 +0000 | [diff] [blame] | 500 | String isReadOnly = coreObject->readOnlyValue(); |
jdiggs@igalia.com | 23022cc | 2016-05-11 07:14:31 +0000 | [diff] [blame] | 501 | if (!isReadOnly.isEmpty()) |
| 502 | attributeSet = addToAtkAttributeSet(attributeSet, "readonly", isReadOnly.utf8().data()); |
| 503 | |
jdiggs@igalia.com | 6ccb778 | 2016-05-18 18:57:33 +0000 | [diff] [blame] | 504 | String valueDescription = coreObject->valueDescription(); |
| 505 | if (!valueDescription.isEmpty()) |
| 506 | attributeSet = addToAtkAttributeSet(attributeSet, "valuetext", valueDescription.utf8().data()); |
| 507 | |
jdiggs@igalia.com | 55b9262 | 2015-05-22 06:12:05 +0000 | [diff] [blame] | 508 | // According to the W3C Core Accessibility API Mappings 1.1, section 5.4.1 General Rules: |
| 509 | // "User agents must expose the WAI-ARIA role string if the API supports a mechanism to do so." |
| 510 | // In the case of ATK, the mechanism to do so is an object attribute pair (xml-roles:"string"). |
jdiggs@igalia.com | 4106991 | 2017-04-20 08:48:53 +0000 | [diff] [blame] | 511 | // We cannot use the computedRoleString for this purpose because it is not limited to elements |
| 512 | // with ARIA roles, and it might not contain the actual ARIA role value (e.g. DPub ARIA). |
| 513 | String roleString = coreObject->getAttribute(HTMLNames::roleAttr); |
| 514 | if (!roleString.isEmpty()) |
| 515 | attributeSet = addToAtkAttributeSet(attributeSet, "xml-roles", roleString.utf8().data()); |
| 516 | |
| 517 | String computedRoleString = coreObject->computedRoleString(); |
| 518 | if (!computedRoleString.isEmpty()) { |
| 519 | attributeSet = addToAtkAttributeSet(attributeSet, "computed-role", computedRoleString.utf8().data()); |
| 520 | |
| 521 | // The HTML AAM maps several elements to ARIA landmark roles. In order for the type of landmark |
| 522 | // to be obtainable in the same fashion as an ARIA landmark, fall back on the computedRoleString. |
jdiggs@igalia.com | 69e004a | 2019-07-11 13:36:50 +0000 | [diff] [blame] | 523 | // We also want to do this for the style-format-group element types so that the type of format |
| 524 | // group it is doesn't get lost to a generic platform role. |
| 525 | if (coreObject->ariaRoleAttribute() == AccessibilityRole::Unknown |
| 526 | && (coreObject->isLandmark() || coreObject->isStyleFormatGroup())) |
jdiggs@igalia.com | 4106991 | 2017-04-20 08:48:53 +0000 | [diff] [blame] | 527 | attributeSet = addToAtkAttributeSet(attributeSet, "xml-roles", computedRoleString.utf8().data()); |
mario.prada@samsung.com | e10ceaa | 2013-12-11 19:49:39 +0000 | [diff] [blame] | 528 | } |
| 529 | |
jdiggs@igalia.com | 9cef8aa | 2016-04-29 16:44:30 +0000 | [diff] [blame] | 530 | String roleDescription = coreObject->roleDescription(); |
| 531 | if (!roleDescription.isEmpty()) |
| 532 | attributeSet = addToAtkAttributeSet(attributeSet, "roledescription", roleDescription.utf8().data()); |
| 533 | |
jdiggs@igalia.com | 3614dca | 2017-09-24 11:52:36 +0000 | [diff] [blame] | 534 | // We need to expose the live region attributes even if the live region is currently disabled/off. |
n_wang@apple.com | 319609c | 2017-11-17 02:24:53 +0000 | [diff] [blame] | 535 | if (auto liveContainer = coreObject->liveRegionAncestor(false)) { |
| 536 | String liveStatus = liveContainer->liveRegionStatus(); |
| 537 | String relevant = liveContainer->liveRegionRelevant(); |
darin@apple.com | 0ce67df | 2019-06-17 01:48:13 +0000 | [diff] [blame] | 538 | bool isAtom = liveContainer->liveRegionAtomic(); |
jdiggs@igalia.com | 3614dca | 2017-09-24 11:52:36 +0000 | [diff] [blame] | 539 | String liveRole = roleString.isEmpty() ? computedRoleString : roleString; |
| 540 | |
| 541 | // According to the Core AAM, we need to expose the above properties with "container-" prefixed |
| 542 | // object attributes regardless of whether the container is this object, or an ancestor of it. |
| 543 | attributeSet = addToAtkAttributeSet(attributeSet, "container-live", liveStatus.utf8().data()); |
| 544 | attributeSet = addToAtkAttributeSet(attributeSet, "container-relevant", relevant.utf8().data()); |
darin@apple.com | 0ce67df | 2019-06-17 01:48:13 +0000 | [diff] [blame] | 545 | if (isAtom) |
jdiggs@igalia.com | 3614dca | 2017-09-24 11:52:36 +0000 | [diff] [blame] | 546 | attributeSet = addToAtkAttributeSet(attributeSet, "container-atomic", "true"); |
| 547 | if (!liveRole.isEmpty()) |
| 548 | attributeSet = addToAtkAttributeSet(attributeSet, "container-live-role", liveRole.utf8().data()); |
| 549 | |
| 550 | // According to the Core AAM, if this object is the live region (rather than its descendant), |
| 551 | // we must expose the above properties on the object without a "container-" prefix. |
| 552 | if (liveContainer == coreObject) { |
| 553 | attributeSet = addToAtkAttributeSet(attributeSet, "live", liveStatus.utf8().data()); |
| 554 | attributeSet = addToAtkAttributeSet(attributeSet, "relevant", relevant.utf8().data()); |
darin@apple.com | 0ce67df | 2019-06-17 01:48:13 +0000 | [diff] [blame] | 555 | if (isAtom) |
jdiggs@igalia.com | 3614dca | 2017-09-24 11:52:36 +0000 | [diff] [blame] | 556 | attributeSet = addToAtkAttributeSet(attributeSet, "atomic", "true"); |
darin@apple.com | 0ce67df | 2019-06-17 01:48:13 +0000 | [diff] [blame] | 557 | } else if (!isAtom && coreObject->liveRegionAtomic()) |
jdiggs@igalia.com | 3614dca | 2017-09-24 11:52:36 +0000 | [diff] [blame] | 558 | attributeSet = addToAtkAttributeSet(attributeSet, "atomic", "true"); |
| 559 | } |
| 560 | |
jdiggs@igalia.com | 4ae31f4 | 2017-10-03 17:56:50 +0000 | [diff] [blame] | 561 | // The Core AAM states the author-provided value should be exposed as-is. |
| 562 | String dropEffect = coreObject->getAttribute(HTMLNames::aria_dropeffectAttr); |
| 563 | if (!dropEffect.isEmpty()) |
| 564 | attributeSet = addToAtkAttributeSet(attributeSet, "dropeffect", dropEffect.utf8().data()); |
| 565 | |
| 566 | if (coreObject->isARIAGrabbed()) |
| 567 | attributeSet = addToAtkAttributeSet(attributeSet, "grabbed", "true"); |
| 568 | else if (coreObject->supportsARIADragging()) |
| 569 | attributeSet = addToAtkAttributeSet(attributeSet, "grabbed", "false"); |
| 570 | |
jdiggs@igalia.com | 861dc18 | 2017-10-11 17:04:42 +0000 | [diff] [blame] | 571 | // The Core AAM states the author-provided value should be exposed as-is. |
darin@apple.com | 0ce67df | 2019-06-17 01:48:13 +0000 | [diff] [blame] | 572 | const AtomString& keyShortcuts = coreObject->keyShortcutsValue(); |
jdiggs@igalia.com | 861dc18 | 2017-10-11 17:04:42 +0000 | [diff] [blame] | 573 | if (!keyShortcuts.isEmpty()) |
| 574 | attributeSet = addToAtkAttributeSet(attributeSet, "keyshortcuts", keyShortcuts.string().utf8().data()); |
| 575 | |
eric@webkit.org | 8449619 | 2009-10-17 20:00:33 +0000 | [diff] [blame] | 576 | return attributeSet; |
| 577 | } |
| 578 | |
mario.prada@samsung.com | 4fb934b | 2013-12-17 18:08:34 +0000 | [diff] [blame] | 579 | static AtkRole atkRole(AccessibilityObject* coreObject) |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 580 | { |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 581 | switch (coreObject->roleValue()) { |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 582 | case AccessibilityRole::ApplicationAlert: |
commit-queue@webkit.org | b68dfdf | 2013-12-06 13:58:38 +0000 | [diff] [blame] | 583 | return ATK_ROLE_ALERT; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 584 | case AccessibilityRole::ApplicationAlertDialog: |
| 585 | case AccessibilityRole::ApplicationDialog: |
commit-queue@webkit.org | b68dfdf | 2013-12-06 13:58:38 +0000 | [diff] [blame] | 586 | return ATK_ROLE_DIALOG; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 587 | case AccessibilityRole::ApplicationStatus: |
commit-queue@webkit.org | b68dfdf | 2013-12-06 13:58:38 +0000 | [diff] [blame] | 588 | return ATK_ROLE_STATUSBAR; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 589 | case AccessibilityRole::Unknown: |
xan@webkit.org | 0ea2f73 | 2009-04-27 21:56:05 +0000 | [diff] [blame] | 590 | return ATK_ROLE_UNKNOWN; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 591 | case AccessibilityRole::Audio: |
jdiggs@igalia.com | c7a2f56 | 2014-11-16 07:32:08 +0000 | [diff] [blame] | 592 | return ATK_ROLE_AUDIO; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 593 | case AccessibilityRole::Video: |
jdiggs@igalia.com | c7a2f56 | 2014-11-16 07:32:08 +0000 | [diff] [blame] | 594 | return ATK_ROLE_VIDEO; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 595 | case AccessibilityRole::Button: |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 596 | return ATK_ROLE_PUSH_BUTTON; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 597 | case AccessibilityRole::Switch: |
| 598 | case AccessibilityRole::ToggleButton: |
commit-queue@webkit.org | 6152cb9 | 2012-08-23 00:36:06 +0000 | [diff] [blame] | 599 | return ATK_ROLE_TOGGLE_BUTTON; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 600 | case AccessibilityRole::RadioButton: |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 601 | return ATK_ROLE_RADIO_BUTTON; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 602 | case AccessibilityRole::CheckBox: |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 603 | return ATK_ROLE_CHECK_BOX; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 604 | case AccessibilityRole::Slider: |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 605 | return ATK_ROLE_SLIDER; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 606 | case AccessibilityRole::TabGroup: |
| 607 | case AccessibilityRole::TabList: |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 608 | return ATK_ROLE_PAGE_TAB_LIST; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 609 | case AccessibilityRole::TextField: |
| 610 | case AccessibilityRole::TextArea: |
| 611 | case AccessibilityRole::SearchField: |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 612 | return ATK_ROLE_ENTRY; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 613 | case AccessibilityRole::StaticText: |
jdiggs@igalia.com | 12f11cb | 2016-04-29 13:08:03 +0000 | [diff] [blame] | 614 | return ATK_ROLE_STATIC; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 615 | case AccessibilityRole::Outline: |
| 616 | case AccessibilityRole::Tree: |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 617 | return ATK_ROLE_TREE; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 618 | case AccessibilityRole::TreeItem: |
commit-queue@webkit.org | b68dfdf | 2013-12-06 13:58:38 +0000 | [diff] [blame] | 619 | return ATK_ROLE_TREE_ITEM; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 620 | case AccessibilityRole::MenuBar: |
xan@webkit.org | 0ea2f73 | 2009-04-27 21:56:05 +0000 | [diff] [blame] | 621 | return ATK_ROLE_MENU_BAR; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 622 | case AccessibilityRole::MenuListPopup: |
| 623 | case AccessibilityRole::Menu: |
xan@webkit.org | 0ea2f73 | 2009-04-27 21:56:05 +0000 | [diff] [blame] | 624 | return ATK_ROLE_MENU; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 625 | case AccessibilityRole::MenuListOption: |
| 626 | case AccessibilityRole::MenuItem: |
| 627 | case AccessibilityRole::MenuButton: |
xan@webkit.org | 0ea2f73 | 2009-04-27 21:56:05 +0000 | [diff] [blame] | 628 | return ATK_ROLE_MENU_ITEM; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 629 | case AccessibilityRole::MenuItemCheckbox: |
mario.prada@samsung.com | 092b72a | 2013-12-16 15:58:34 +0000 | [diff] [blame] | 630 | return ATK_ROLE_CHECK_MENU_ITEM; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 631 | case AccessibilityRole::MenuItemRadio: |
commit-queue@webkit.org | 413f75b | 2013-09-11 11:31:14 +0000 | [diff] [blame] | 632 | return ATK_ROLE_RADIO_MENU_ITEM; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 633 | case AccessibilityRole::Column: |
mario@webkit.org | 9adab66 | 2012-01-23 10:21:03 +0000 | [diff] [blame] | 634 | // return ATK_ROLE_TABLE_COLUMN_HEADER; // Is this right? |
xan@webkit.org | 0ea2f73 | 2009-04-27 21:56:05 +0000 | [diff] [blame] | 635 | return ATK_ROLE_UNKNOWN; // Matches Mozilla |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 636 | case AccessibilityRole::Row: |
jdiggs@igalia.com | e8a090d | 2014-12-03 02:02:36 +0000 | [diff] [blame] | 637 | return ATK_ROLE_TABLE_ROW; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 638 | case AccessibilityRole::Toolbar: |
xan@webkit.org | 0ea2f73 | 2009-04-27 21:56:05 +0000 | [diff] [blame] | 639 | return ATK_ROLE_TOOL_BAR; |
jdiggs@igalia.com | 959318d | 2019-03-20 13:09:02 +0000 | [diff] [blame] | 640 | case AccessibilityRole::Meter: |
| 641 | return ATK_ROLE_LEVEL_BAR; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 642 | case AccessibilityRole::BusyIndicator: |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 643 | case AccessibilityRole::ProgressIndicator: |
jdiggs@igalia.com | 959318d | 2019-03-20 13:09:02 +0000 | [diff] [blame] | 644 | return ATK_ROLE_PROGRESS_BAR; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 645 | case AccessibilityRole::Window: |
xan@webkit.org | 0ea2f73 | 2009-04-27 21:56:05 +0000 | [diff] [blame] | 646 | return ATK_ROLE_WINDOW; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 647 | case AccessibilityRole::PopUpButton: |
n_wang@apple.com | 319609c | 2017-11-17 02:24:53 +0000 | [diff] [blame] | 648 | return coreObject->hasPopup() ? ATK_ROLE_PUSH_BUTTON : ATK_ROLE_COMBO_BOX; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 649 | case AccessibilityRole::ComboBox: |
xan@webkit.org | 0ea2f73 | 2009-04-27 21:56:05 +0000 | [diff] [blame] | 650 | return ATK_ROLE_COMBO_BOX; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 651 | case AccessibilityRole::SplitGroup: |
xan@webkit.org | 0ea2f73 | 2009-04-27 21:56:05 +0000 | [diff] [blame] | 652 | return ATK_ROLE_SPLIT_PANE; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 653 | case AccessibilityRole::Splitter: |
mario.prada@samsung.com | ae97a65 | 2013-12-10 20:12:56 +0000 | [diff] [blame] | 654 | return ATK_ROLE_SEPARATOR; |
jdiggs@igalia.com | feb6f00 | 2015-02-24 17:20:01 +0000 | [diff] [blame] | 655 | #if PLATFORM(GTK) |
mcatanzaro@igalia.com | e0f103e | 2019-06-21 14:20:00 +0000 | [diff] [blame] | 656 | case AccessibilityRole::ColorWell: |
jdiggs@igalia.com | feb6f00 | 2015-02-24 17:20:01 +0000 | [diff] [blame] | 657 | // ATK_ROLE_COLOR_CHOOSER is defined as a dialog (i.e. it's what appears when you push the button). |
| 658 | return ATK_ROLE_PUSH_BUTTON; |
jdiggs@igalia.com | feb6f00 | 2015-02-24 17:20:01 +0000 | [diff] [blame] | 659 | #endif |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 660 | case AccessibilityRole::List: |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 661 | return ATK_ROLE_LIST; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 662 | case AccessibilityRole::ScrollBar: |
xan@webkit.org | 0ea2f73 | 2009-04-27 21:56:05 +0000 | [diff] [blame] | 663 | return ATK_ROLE_SCROLL_BAR; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 664 | case AccessibilityRole::ScrollArea: |
| 665 | case AccessibilityRole::TabPanel: |
mario@webkit.org | 86390a1 | 2011-01-07 17:34:02 +0000 | [diff] [blame] | 666 | return ATK_ROLE_SCROLL_PANE; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 667 | case AccessibilityRole::Grid: |
| 668 | case AccessibilityRole::Table: |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 669 | return ATK_ROLE_TABLE; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 670 | case AccessibilityRole::TreeGrid: |
jdiggs@igalia.com | 8c93478 | 2017-04-30 18:11:56 +0000 | [diff] [blame] | 671 | return ATK_ROLE_TREE_TABLE; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 672 | case AccessibilityRole::Application: |
xan@webkit.org | 0ea2f73 | 2009-04-27 21:56:05 +0000 | [diff] [blame] | 673 | return ATK_ROLE_APPLICATION; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 674 | case AccessibilityRole::ApplicationGroup: |
| 675 | case AccessibilityRole::Feed: |
| 676 | case AccessibilityRole::Figure: |
jdiggs@igalia.com | 3e7e23a | 2018-01-22 19:16:52 +0000 | [diff] [blame] | 677 | case AccessibilityRole::GraphicsObject: |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 678 | case AccessibilityRole::Group: |
| 679 | case AccessibilityRole::RadioGroup: |
| 680 | case AccessibilityRole::SVGRoot: |
xan@webkit.org | 0ea2f73 | 2009-04-27 21:56:05 +0000 | [diff] [blame] | 681 | return ATK_ROLE_PANEL; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 682 | case AccessibilityRole::RowHeader: |
commit-queue@webkit.org | c150a07 | 2014-10-10 08:32:58 +0000 | [diff] [blame] | 683 | return ATK_ROLE_ROW_HEADER; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 684 | case AccessibilityRole::ColumnHeader: |
commit-queue@webkit.org | c150a07 | 2014-10-10 08:32:58 +0000 | [diff] [blame] | 685 | return ATK_ROLE_COLUMN_HEADER; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 686 | case AccessibilityRole::Caption: |
jdiggs@igalia.com | e8a090d | 2014-12-03 02:02:36 +0000 | [diff] [blame] | 687 | return ATK_ROLE_CAPTION; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 688 | case AccessibilityRole::Cell: |
| 689 | case AccessibilityRole::GridCell: |
jdiggs@igalia.com | 63bfc54 | 2014-06-05 23:53:17 +0000 | [diff] [blame] | 690 | return coreObject->inheritsPresentationalRole() ? ATK_ROLE_SECTION : ATK_ROLE_TABLE_CELL; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 691 | case AccessibilityRole::Link: |
| 692 | case AccessibilityRole::WebCoreLink: |
| 693 | case AccessibilityRole::ImageMapLink: |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 694 | return ATK_ROLE_LINK; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 695 | case AccessibilityRole::ImageMap: |
jdiggs@igalia.com | 51d2ebf | 2014-11-22 18:18:11 +0000 | [diff] [blame] | 696 | return ATK_ROLE_IMAGE_MAP; |
jdiggs@igalia.com | 3e7e23a | 2018-01-22 19:16:52 +0000 | [diff] [blame] | 697 | case AccessibilityRole::GraphicsSymbol: |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 698 | case AccessibilityRole::Image: |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 699 | return ATK_ROLE_IMAGE; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 700 | case AccessibilityRole::ListMarker: |
jmalonzo@webkit.org | ad9783b | 2009-05-23 22:22:52 +0000 | [diff] [blame] | 701 | return ATK_ROLE_TEXT; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 702 | case AccessibilityRole::DocumentArticle: |
mario.prada@samsung.com | 2a1d562 | 2013-12-16 15:17:58 +0000 | [diff] [blame] | 703 | return ATK_ROLE_ARTICLE; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 704 | case AccessibilityRole::Document: |
jdiggs@igalia.com | 3e7e23a | 2018-01-22 19:16:52 +0000 | [diff] [blame] | 705 | case AccessibilityRole::GraphicsDocument: |
xan@webkit.org | 0ea2f73 | 2009-04-27 21:56:05 +0000 | [diff] [blame] | 706 | return ATK_ROLE_DOCUMENT_FRAME; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 707 | case AccessibilityRole::DocumentNote: |
mario.prada@samsung.com | c4a5eca | 2013-12-16 16:18:30 +0000 | [diff] [blame] | 708 | return ATK_ROLE_COMMENT; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 709 | case AccessibilityRole::Heading: |
xan@webkit.org | 0ea2f73 | 2009-04-27 21:56:05 +0000 | [diff] [blame] | 710 | return ATK_ROLE_HEADING; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 711 | case AccessibilityRole::ListBox: |
jdiggs@igalia.com | b0b6255 | 2016-11-19 21:12:24 +0000 | [diff] [blame] | 712 | // https://rawgit.com/w3c/aria/master/core-aam/core-aam.html#role-map-listbox |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 713 | return coreObject->isDescendantOfRole(AccessibilityRole::ComboBox) ? ATK_ROLE_MENU : ATK_ROLE_LIST_BOX; |
| 714 | case AccessibilityRole::ListItem: |
jdiggs@igalia.com | 63bfc54 | 2014-06-05 23:53:17 +0000 | [diff] [blame] | 715 | return coreObject->inheritsPresentationalRole() ? ATK_ROLE_SECTION : ATK_ROLE_LIST_ITEM; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 716 | case AccessibilityRole::ListBoxOption: |
| 717 | return coreObject->isDescendantOfRole(AccessibilityRole::ComboBox) ? ATK_ROLE_MENU_ITEM : ATK_ROLE_LIST_ITEM; |
| 718 | case AccessibilityRole::Paragraph: |
mario@webkit.org | 56f6bf2 | 2011-03-30 16:51:08 +0000 | [diff] [blame] | 719 | return ATK_ROLE_PARAGRAPH; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 720 | case AccessibilityRole::Label: |
| 721 | case AccessibilityRole::Legend: |
mario@webkit.org | 56f6bf2 | 2011-03-30 16:51:08 +0000 | [diff] [blame] | 722 | return ATK_ROLE_LABEL; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 723 | case AccessibilityRole::Blockquote: |
jdiggs@igalia.com | abd4d5f | 2014-11-16 16:51:08 +0000 | [diff] [blame] | 724 | return ATK_ROLE_BLOCK_QUOTE; |
jdiggs@igalia.com | 8920b74 | 2017-05-25 16:43:23 +0000 | [diff] [blame] | 725 | #if ATK_CHECK_VERSION(2, 25, 2) |
mcatanzaro@igalia.com | e0f103e | 2019-06-21 14:20:00 +0000 | [diff] [blame] | 726 | case AccessibilityRole::Footnote: |
jdiggs@igalia.com | 8920b74 | 2017-05-25 16:43:23 +0000 | [diff] [blame] | 727 | return ATK_ROLE_FOOTNOTE; |
| 728 | #endif |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 729 | case AccessibilityRole::ApplicationTextGroup: |
| 730 | case AccessibilityRole::Div: |
| 731 | case AccessibilityRole::Pre: |
| 732 | case AccessibilityRole::SVGText: |
| 733 | case AccessibilityRole::TextGroup: |
mario@webkit.org | 56f6bf2 | 2011-03-30 16:51:08 +0000 | [diff] [blame] | 734 | return ATK_ROLE_SECTION; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 735 | case AccessibilityRole::Footer: |
jdiggs@igalia.com | 45e9714 | 2014-11-16 07:26:41 +0000 | [diff] [blame] | 736 | return ATK_ROLE_FOOTER; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 737 | case AccessibilityRole::Form: |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 738 | if (coreObject->ariaRoleAttribute() != AccessibilityRole::Unknown) |
jdiggs@igalia.com | 9b67c3b | 2017-10-10 21:29:24 +0000 | [diff] [blame] | 739 | return ATK_ROLE_LANDMARK; |
mario@webkit.org | 56f6bf2 | 2011-03-30 16:51:08 +0000 | [diff] [blame] | 740 | return ATK_ROLE_FORM; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 741 | case AccessibilityRole::Canvas: |
commit-queue@webkit.org | 52f6761 | 2012-09-07 05:09:04 +0000 | [diff] [blame] | 742 | return ATK_ROLE_CANVAS; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 743 | case AccessibilityRole::HorizontalRule: |
dmazzoni@google.com | f3cf2c4 | 2012-09-07 23:46:45 +0000 | [diff] [blame] | 744 | return ATK_ROLE_SEPARATOR; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 745 | case AccessibilityRole::SpinButton: |
commit-queue@webkit.org | c985400e | 2012-09-21 20:03:57 +0000 | [diff] [blame] | 746 | return ATK_ROLE_SPIN_BUTTON; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 747 | case AccessibilityRole::Tab: |
commit-queue@webkit.org | 5255389 | 2012-12-13 15:43:38 +0000 | [diff] [blame] | 748 | return ATK_ROLE_PAGE_TAB; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 749 | case AccessibilityRole::UserInterfaceTooltip: |
commit-queue@webkit.org | b68dfdf | 2013-12-06 13:58:38 +0000 | [diff] [blame] | 750 | return ATK_ROLE_TOOL_TIP; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 751 | case AccessibilityRole::WebArea: |
commit-queue@webkit.org | b68dfdf | 2013-12-06 13:58:38 +0000 | [diff] [blame] | 752 | return ATK_ROLE_DOCUMENT_WEB; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 753 | case AccessibilityRole::WebApplication: |
mario.prada@samsung.com | e10ceaa | 2013-12-11 19:49:39 +0000 | [diff] [blame] | 754 | return ATK_ROLE_EMBEDDED; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 755 | case AccessibilityRole::ApplicationLog: |
mario.prada@samsung.com | c4a5eca | 2013-12-16 16:18:30 +0000 | [diff] [blame] | 756 | return ATK_ROLE_LOG; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 757 | case AccessibilityRole::ApplicationMarquee: |
mario.prada@samsung.com | c4a5eca | 2013-12-16 16:18:30 +0000 | [diff] [blame] | 758 | return ATK_ROLE_MARQUEE; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 759 | case AccessibilityRole::ApplicationTimer: |
mario.prada@samsung.com | c4a5eca | 2013-12-16 16:18:30 +0000 | [diff] [blame] | 760 | return ATK_ROLE_TIMER; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 761 | case AccessibilityRole::Definition: |
mario.prada@samsung.com | c4a5eca | 2013-12-16 16:18:30 +0000 | [diff] [blame] | 762 | return ATK_ROLE_DEFINITION; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 763 | case AccessibilityRole::DocumentMath: |
mario.prada@samsung.com | c4a5eca | 2013-12-16 16:18:30 +0000 | [diff] [blame] | 764 | return ATK_ROLE_MATH; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 765 | case AccessibilityRole::MathElement: |
jdiggs@igalia.com | 0f83ca3 | 2014-12-09 18:31:53 +0000 | [diff] [blame] | 766 | if (coreObject->isMathRow()) |
| 767 | return ATK_ROLE_PANEL; |
| 768 | if (coreObject->isMathTable()) |
| 769 | return ATK_ROLE_TABLE; |
| 770 | if (coreObject->isMathTableRow()) |
| 771 | return ATK_ROLE_TABLE_ROW; |
| 772 | if (coreObject->isMathTableCell()) |
| 773 | return ATK_ROLE_TABLE_CELL; |
jdiggs@igalia.com | 6b8c173 | 2015-01-28 17:02:32 +0000 | [diff] [blame] | 774 | if (coreObject->isMathSubscriptSuperscript() || coreObject->isMathMultiscript()) |
| 775 | return ATK_ROLE_SECTION; |
jdiggs@igalia.com | 6b8c173 | 2015-01-28 17:02:32 +0000 | [diff] [blame] | 776 | if (coreObject->isMathFraction()) |
| 777 | return ATK_ROLE_MATH_FRACTION; |
| 778 | if (coreObject->isMathSquareRoot() || coreObject->isMathRoot()) |
| 779 | return ATK_ROLE_MATH_ROOT; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 780 | if (coreObject->isMathScriptObject(AccessibilityMathScriptObjectType::Subscript) |
| 781 | || coreObject->isMathMultiscriptObject(AccessibilityMathMultiscriptObjectType::PreSubscript) || coreObject->isMathMultiscriptObject(AccessibilityMathMultiscriptObjectType::PostSubscript)) |
jdiggs@igalia.com | 6b8c173 | 2015-01-28 17:02:32 +0000 | [diff] [blame] | 782 | return ATK_ROLE_SUBSCRIPT; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 783 | if (coreObject->isMathScriptObject(AccessibilityMathScriptObjectType::Superscript) |
| 784 | || coreObject->isMathMultiscriptObject(AccessibilityMathMultiscriptObjectType::PreSuperscript) || coreObject->isMathMultiscriptObject(AccessibilityMathMultiscriptObjectType::PostSuperscript)) |
jdiggs@igalia.com | 6b8c173 | 2015-01-28 17:02:32 +0000 | [diff] [blame] | 785 | return ATK_ROLE_SUPERSCRIPT; |
jdiggs@igalia.com | 0f83ca3 | 2014-12-09 18:31:53 +0000 | [diff] [blame] | 786 | if (coreObject->isMathToken()) |
| 787 | return ATK_ROLE_STATIC; |
jdiggs@igalia.com | 0f83ca3 | 2014-12-09 18:31:53 +0000 | [diff] [blame] | 788 | return ATK_ROLE_UNKNOWN; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 789 | case AccessibilityRole::LandmarkBanner: |
| 790 | case AccessibilityRole::LandmarkComplementary: |
| 791 | case AccessibilityRole::LandmarkContentInfo: |
| 792 | case AccessibilityRole::LandmarkDocRegion: |
| 793 | case AccessibilityRole::LandmarkMain: |
| 794 | case AccessibilityRole::LandmarkNavigation: |
| 795 | case AccessibilityRole::LandmarkRegion: |
| 796 | case AccessibilityRole::LandmarkSearch: |
mario.prada@samsung.com | e10ceaa | 2013-12-11 19:49:39 +0000 | [diff] [blame] | 797 | return ATK_ROLE_LANDMARK; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 798 | case AccessibilityRole::DescriptionList: |
mario.prada@samsung.com | 4fb934b | 2013-12-17 18:08:34 +0000 | [diff] [blame] | 799 | return ATK_ROLE_DESCRIPTION_LIST; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 800 | case AccessibilityRole::Term: |
| 801 | case AccessibilityRole::DescriptionListTerm: |
mario.prada@samsung.com | 4fb934b | 2013-12-17 18:08:34 +0000 | [diff] [blame] | 802 | return ATK_ROLE_DESCRIPTION_TERM; |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 803 | case AccessibilityRole::DescriptionListDetail: |
mario.prada@samsung.com | 4fb934b | 2013-12-17 18:08:34 +0000 | [diff] [blame] | 804 | return ATK_ROLE_DESCRIPTION_VALUE; |
jdiggs@igalia.com | 69e004a | 2019-07-11 13:36:50 +0000 | [diff] [blame] | 805 | case AccessibilityRole::Deletion: |
| 806 | #if ATK_CHECK_VERSION(2, 33, 3) |
| 807 | return ATK_ROLE_CONTENT_DELETION; |
| 808 | #else |
jdiggs@igalia.com | 0ec0d33 | 2016-04-29 01:30:34 +0000 | [diff] [blame] | 809 | return ATK_ROLE_STATIC; |
jdiggs@igalia.com | 69e004a | 2019-07-11 13:36:50 +0000 | [diff] [blame] | 810 | #endif |
| 811 | case AccessibilityRole::Insertion: |
| 812 | #if ATK_CHECK_VERSION(2, 33, 3) |
| 813 | return ATK_ROLE_CONTENT_INSERTION; |
| 814 | #else |
| 815 | return ATK_ROLE_STATIC; |
| 816 | #endif |
| 817 | case AccessibilityRole::Subscript: |
| 818 | return ATK_ROLE_SUBSCRIPT; |
| 819 | case AccessibilityRole::Superscript: |
| 820 | return ATK_ROLE_SUPERSCRIPT; |
| 821 | case AccessibilityRole::Inline: |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 822 | case AccessibilityRole::SVGTextPath: |
| 823 | case AccessibilityRole::SVGTSpan: |
| 824 | case AccessibilityRole::Time: |
jdiggs@igalia.com | 85721d1 | 2014-12-03 19:51:28 +0000 | [diff] [blame] | 825 | return ATK_ROLE_STATIC; |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 826 | default: |
| 827 | return ATK_ROLE_UNKNOWN; |
| 828 | } |
| 829 | } |
| 830 | |
mario@webkit.org | 5c96677 | 2012-01-24 18:48:50 +0000 | [diff] [blame] | 831 | static AtkRole webkitAccessibleGetRole(AtkObject* object) |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 832 | { |
jdiggs@igalia.com | 00e44c4 | 2014-11-13 22:11:41 +0000 | [diff] [blame] | 833 | // ATK_ROLE_UNKNOWN should only be applied in cases where there is a valid |
| 834 | // WebCore accessible object for which the platform role mapping is unknown. |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 835 | auto* accessible = WEBKIT_ACCESSIBLE(object); |
| 836 | returnValIfWebKitAccessibleIsInvalid(accessible, ATK_ROLE_INVALID); |
jmalonzo@webkit.org | 7ce3714 | 2009-05-20 11:16:01 +0000 | [diff] [blame] | 837 | |
| 838 | // Note: Why doesn't WebCore have a password field for this |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 839 | if (accessible->priv->object->isPasswordField()) |
jmalonzo@webkit.org | 7ce3714 | 2009-05-20 11:16:01 +0000 | [diff] [blame] | 840 | return ATK_ROLE_PASSWORD_TEXT; |
| 841 | |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 842 | return atkRole(accessible->priv->object); |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 843 | } |
| 844 | |
mario@webkit.org | 6a24ba1 | 2010-12-14 15:35:22 +0000 | [diff] [blame] | 845 | static bool isTextWithCaret(AccessibilityObject* coreObject) |
| 846 | { |
| 847 | if (!coreObject || !coreObject->isAccessibilityRenderObject()) |
| 848 | return false; |
| 849 | |
| 850 | Document* document = coreObject->document(); |
| 851 | if (!document) |
| 852 | return false; |
| 853 | |
| 854 | Frame* frame = document->frame(); |
| 855 | if (!frame) |
| 856 | return false; |
| 857 | |
akling@apple.com | 1752350 | 2013-08-17 10:58:40 +0000 | [diff] [blame] | 858 | if (!frame->settings().caretBrowsingEnabled()) |
mario@webkit.org | 6a24ba1 | 2010-12-14 15:35:22 +0000 | [diff] [blame] | 859 | return false; |
| 860 | |
| 861 | // Check text objects and paragraphs only. |
carlosgc@webkit.org | 9d3f9a4 | 2019-04-05 07:35:24 +0000 | [diff] [blame] | 862 | auto* axObject = coreObject->wrapper(); |
| 863 | AtkRole role = axObject ? atk_object_get_role(ATK_OBJECT(axObject)) : ATK_ROLE_INVALID; |
mario@webkit.org | 6a24ba1 | 2010-12-14 15:35:22 +0000 | [diff] [blame] | 864 | if (role != ATK_ROLE_TEXT && role != ATK_ROLE_PARAGRAPH) |
| 865 | return false; |
| 866 | |
| 867 | // Finally, check whether the caret is set in the current object. |
| 868 | VisibleSelection selection = coreObject->selection(); |
| 869 | if (!selection.isCaret()) |
| 870 | return false; |
| 871 | |
| 872 | return selectionBelongsToObject(coreObject, selection); |
| 873 | } |
| 874 | |
xan@webkit.org | 8be15d6 | 2009-04-09 11:20:57 +0000 | [diff] [blame] | 875 | static void setAtkStateSetFromCoreObject(AccessibilityObject* coreObject, AtkStateSet* stateSet) |
| 876 | { |
eric@webkit.org | 2dd4734 | 2009-10-26 11:42:42 +0000 | [diff] [blame] | 877 | AccessibilityObject* parent = coreObject->parentObject(); |
| 878 | bool isListBoxOption = parent && parent->isListBox(); |
xan@webkit.org | 8be15d6 | 2009-04-09 11:20:57 +0000 | [diff] [blame] | 879 | |
eric@webkit.org | 2dd4734 | 2009-10-26 11:42:42 +0000 | [diff] [blame] | 880 | // Please keep the state list in alphabetical order |
jdiggs@igalia.com | 1975e35 | 2017-04-26 23:26:49 +0000 | [diff] [blame] | 881 | if ((isListBoxOption && coreObject->isSelectedOptionActive()) |
n_wang@apple.com | 319609c | 2017-11-17 02:24:53 +0000 | [diff] [blame] | 882 | || coreObject->currentState() != AccessibilityCurrentState::False) |
commit-queue@webkit.org | c429926 | 2013-12-02 10:40:07 +0000 | [diff] [blame] | 883 | atk_state_set_add_state(stateSet, ATK_STATE_ACTIVE); |
| 884 | |
jdiggs@igalia.com | 77cdc2a | 2016-11-19 08:08:03 +0000 | [diff] [blame] | 885 | if (coreObject->isBusy()) |
| 886 | atk_state_set_add_state(stateSet, ATK_STATE_BUSY); |
| 887 | |
jdiggs@igalia.com | 23022cc | 2016-05-11 07:14:31 +0000 | [diff] [blame] | 888 | if (coreObject->supportsChecked() && coreObject->canSetValueAttribute()) |
| 889 | atk_state_set_add_state(stateSet, ATK_STATE_CHECKABLE); |
jdiggs@igalia.com | 23022cc | 2016-05-11 07:14:31 +0000 | [diff] [blame] | 890 | |
xan@webkit.org | 8be15d6 | 2009-04-09 11:20:57 +0000 | [diff] [blame] | 891 | if (coreObject->isChecked()) |
| 892 | atk_state_set_add_state(stateSet, ATK_STATE_CHECKED); |
| 893 | |
jdiggs@igalia.com | 23022cc | 2016-05-11 07:14:31 +0000 | [diff] [blame] | 894 | if ((coreObject->isTextControl() || coreObject->isNonNativeTextControl()) && coreObject->canSetValueAttribute()) |
xan@webkit.org | 8be15d6 | 2009-04-09 11:20:57 +0000 | [diff] [blame] | 895 | atk_state_set_add_state(stateSet, ATK_STATE_EDITABLE); |
| 896 | |
xan@webkit.org | df7d13a | 2009-06-26 09:12:44 +0000 | [diff] [blame] | 897 | // FIXME: Put both ENABLED and SENSITIVE together here for now |
| 898 | if (coreObject->isEnabled()) { |
xan@webkit.org | 8be15d6 | 2009-04-09 11:20:57 +0000 | [diff] [blame] | 899 | atk_state_set_add_state(stateSet, ATK_STATE_ENABLED); |
xan@webkit.org | df7d13a | 2009-06-26 09:12:44 +0000 | [diff] [blame] | 900 | atk_state_set_add_state(stateSet, ATK_STATE_SENSITIVE); |
| 901 | } |
xan@webkit.org | 8be15d6 | 2009-04-09 11:20:57 +0000 | [diff] [blame] | 902 | |
mario@webkit.org | 8ce6a15 | 2010-11-30 21:16:14 +0000 | [diff] [blame] | 903 | if (coreObject->canSetExpandedAttribute()) |
| 904 | atk_state_set_add_state(stateSet, ATK_STATE_EXPANDABLE); |
| 905 | |
| 906 | if (coreObject->isExpanded()) |
| 907 | atk_state_set_add_state(stateSet, ATK_STATE_EXPANDED); |
| 908 | |
xan@webkit.org | 8be15d6 | 2009-04-09 11:20:57 +0000 | [diff] [blame] | 909 | if (coreObject->canSetFocusAttribute()) |
| 910 | atk_state_set_add_state(stateSet, ATK_STATE_FOCUSABLE); |
| 911 | |
jdiggs@igalia.com | 0a5cab1 | 2017-10-20 16:30:20 +0000 | [diff] [blame] | 912 | // According to the Core AAM, if the element which is focused has a valid aria-activedescendant, |
| 913 | // we should not expose the focused state on the element which is actually focused, but instead |
| 914 | // on its active descendant. |
| 915 | if ((coreObject->isFocused() && !coreObject->activeDescendant()) || isTextWithCaret(coreObject)) |
xan@webkit.org | 8be15d6 | 2009-04-09 11:20:57 +0000 | [diff] [blame] | 916 | atk_state_set_add_state(stateSet, ATK_STATE_FOCUSED); |
jdiggs@igalia.com | 0a5cab1 | 2017-10-20 16:30:20 +0000 | [diff] [blame] | 917 | else if (coreObject->isActiveDescendantOfFocusedContainer()) { |
| 918 | atk_state_set_add_state(stateSet, ATK_STATE_FOCUSABLE); |
| 919 | atk_state_set_add_state(stateSet, ATK_STATE_FOCUSED); |
| 920 | } |
xan@webkit.org | 8be15d6 | 2009-04-09 11:20:57 +0000 | [diff] [blame] | 921 | |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 922 | if (coreObject->orientation() == AccessibilityOrientation::Horizontal) |
commit-queue@webkit.org | 471dff5 | 2013-03-20 08:12:15 +0000 | [diff] [blame] | 923 | atk_state_set_add_state(stateSet, ATK_STATE_HORIZONTAL); |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 924 | else if (coreObject->orientation() == AccessibilityOrientation::Vertical) |
commit-queue@webkit.org | 471dff5 | 2013-03-20 08:12:15 +0000 | [diff] [blame] | 925 | atk_state_set_add_state(stateSet, ATK_STATE_VERTICAL); |
xan@webkit.org | 8be15d6 | 2009-04-09 11:20:57 +0000 | [diff] [blame] | 926 | |
n_wang@apple.com | 319609c | 2017-11-17 02:24:53 +0000 | [diff] [blame] | 927 | if (coreObject->hasPopup()) |
jdiggs@igalia.com | 47c0ab01 | 2017-04-26 19:30:08 +0000 | [diff] [blame] | 928 | atk_state_set_add_state(stateSet, ATK_STATE_HAS_POPUP); |
| 929 | |
xan@webkit.org | 8be15d6 | 2009-04-09 11:20:57 +0000 | [diff] [blame] | 930 | if (coreObject->isIndeterminate()) |
| 931 | atk_state_set_add_state(stateSet, ATK_STATE_INDETERMINATE); |
jdiggs@igalia.com | 06ff93c | 2017-10-04 07:33:08 +0000 | [diff] [blame] | 932 | else if (coreObject->isCheckboxOrRadio() || coreObject->isMenuItem() || coreObject->isToggleButton()) { |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 933 | if (coreObject->checkboxOrRadioValue() == AccessibilityButtonState::Mixed) |
k.czech@samsung.com | 43a8931 | 2014-01-07 11:28:04 +0000 | [diff] [blame] | 934 | atk_state_set_add_state(stateSet, ATK_STATE_INDETERMINATE); |
| 935 | } |
| 936 | |
n_wang@apple.com | ba6eaf4 | 2017-11-17 23:14:18 +0000 | [diff] [blame] | 937 | if (coreObject->isModalNode()) |
jdiggs@igalia.com | 96ae08c | 2017-04-28 18:17:26 +0000 | [diff] [blame] | 938 | atk_state_set_add_state(stateSet, ATK_STATE_MODAL); |
| 939 | |
mario@webkit.org | e0f00f1 | 2013-10-08 10:55:25 +0000 | [diff] [blame] | 940 | if (coreObject->invalidStatus() != "false") |
| 941 | atk_state_set_add_state(stateSet, ATK_STATE_INVALID_ENTRY); |
| 942 | |
jhoneycutt@apple.com | 8acea08 | 2010-01-14 01:16:15 +0000 | [diff] [blame] | 943 | if (coreObject->isMultiSelectable()) |
xan@webkit.org | 8be15d6 | 2009-04-09 11:20:57 +0000 | [diff] [blame] | 944 | atk_state_set_add_state(stateSet, ATK_STATE_MULTISELECTABLE); |
| 945 | |
| 946 | // TODO: ATK_STATE_OPAQUE |
| 947 | |
| 948 | if (coreObject->isPressed()) |
| 949 | atk_state_set_add_state(stateSet, ATK_STATE_PRESSED); |
| 950 | |
n_wang@apple.com | ba6eaf4 | 2017-11-17 23:14:18 +0000 | [diff] [blame] | 951 | if (!coreObject->canSetValueAttribute() && (coreObject->supportsReadOnly())) |
jdiggs@igalia.com | 23022cc | 2016-05-11 07:14:31 +0000 | [diff] [blame] | 952 | atk_state_set_add_state(stateSet, ATK_STATE_READ_ONLY); |
jdiggs@igalia.com | 23022cc | 2016-05-11 07:14:31 +0000 | [diff] [blame] | 953 | |
commit-queue@webkit.org | 60f8d31 | 2013-06-21 10:33:34 +0000 | [diff] [blame] | 954 | if (coreObject->isRequired()) |
| 955 | atk_state_set_add_state(stateSet, ATK_STATE_REQUIRED); |
| 956 | |
xan@webkit.org | 8be15d6 | 2009-04-09 11:20:57 +0000 | [diff] [blame] | 957 | // TODO: ATK_STATE_SELECTABLE_TEXT |
| 958 | |
eric@webkit.org | 2dd4734 | 2009-10-26 11:42:42 +0000 | [diff] [blame] | 959 | if (coreObject->canSetSelectedAttribute()) { |
| 960 | atk_state_set_add_state(stateSet, ATK_STATE_SELECTABLE); |
mario@webkit.org | 8c5dd90 | 2012-11-09 19:47:40 +0000 | [diff] [blame] | 961 | // Items in focusable lists have both STATE_SELECT{ABLE,ED} |
| 962 | // and STATE_FOCUS{ABLE,ED}. We'll fake the latter based on |
| 963 | // the former. |
eric@webkit.org | 2dd4734 | 2009-10-26 11:42:42 +0000 | [diff] [blame] | 964 | if (isListBoxOption) |
| 965 | atk_state_set_add_state(stateSet, ATK_STATE_FOCUSABLE); |
| 966 | } |
| 967 | |
| 968 | if (coreObject->isSelected()) { |
xan@webkit.org | 8be15d6 | 2009-04-09 11:20:57 +0000 | [diff] [blame] | 969 | atk_state_set_add_state(stateSet, ATK_STATE_SELECTED); |
mario@webkit.org | 8c5dd90 | 2012-11-09 19:47:40 +0000 | [diff] [blame] | 970 | // Items in focusable lists have both STATE_SELECT{ABLE,ED} |
eric@webkit.org | 2dd4734 | 2009-10-26 11:42:42 +0000 | [diff] [blame] | 971 | // and STATE_FOCUS{ABLE,ED}. We'll fake the latter based on the |
| 972 | // former. |
| 973 | if (isListBoxOption) |
| 974 | atk_state_set_add_state(stateSet, ATK_STATE_FOCUSED); |
| 975 | } |
xan@webkit.org | 8be15d6 | 2009-04-09 11:20:57 +0000 | [diff] [blame] | 976 | |
xan@webkit.org | df7d13a | 2009-06-26 09:12:44 +0000 | [diff] [blame] | 977 | // FIXME: Group both SHOWING and VISIBLE here for now |
| 978 | // Not sure how to handle this in WebKit, see bug |
| 979 | // http://bugzilla.gnome.org/show_bug.cgi?id=509650 for other |
mario@webkit.org | 8c5dd90 | 2012-11-09 19:47:40 +0000 | [diff] [blame] | 980 | // issues with SHOWING vs VISIBLE. |
xan@webkit.org | df7d13a | 2009-06-26 09:12:44 +0000 | [diff] [blame] | 981 | if (!coreObject->isOffScreen()) { |
xan@webkit.org | 8be15d6 | 2009-04-09 11:20:57 +0000 | [diff] [blame] | 982 | atk_state_set_add_state(stateSet, ATK_STATE_SHOWING); |
xan@webkit.org | df7d13a | 2009-06-26 09:12:44 +0000 | [diff] [blame] | 983 | atk_state_set_add_state(stateSet, ATK_STATE_VISIBLE); |
| 984 | } |
xan@webkit.org | 8be15d6 | 2009-04-09 11:20:57 +0000 | [diff] [blame] | 985 | |
| 986 | // Mutually exclusive, so we group these two |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 987 | if (coreObject->roleValue() == AccessibilityRole::TextArea || coreObject->ariaIsMultiline()) |
xan@webkit.org | 8be15d6 | 2009-04-09 11:20:57 +0000 | [diff] [blame] | 988 | atk_state_set_add_state(stateSet, ATK_STATE_MULTI_LINE); |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 989 | else if (coreObject->roleValue() == AccessibilityRole::TextField || coreObject->roleValue() == AccessibilityRole::SearchField) |
jdiggs@igalia.com | 18b89b8 | 2016-11-14 17:39:10 +0000 | [diff] [blame] | 990 | atk_state_set_add_state(stateSet, ATK_STATE_SINGLE_LINE); |
xan@webkit.org | 8be15d6 | 2009-04-09 11:20:57 +0000 | [diff] [blame] | 991 | |
| 992 | // TODO: ATK_STATE_SENSITIVE |
| 993 | |
n_wang@apple.com | 319609c | 2017-11-17 02:24:53 +0000 | [diff] [blame] | 994 | if (coreObject->supportsAutoComplete() && coreObject->autoCompleteValue() != "none") |
jdiggs@igalia.com | 6d1214c | 2017-04-30 18:12:30 +0000 | [diff] [blame] | 995 | atk_state_set_add_state(stateSet, ATK_STATE_SUPPORTS_AUTOCOMPLETION); |
| 996 | |
xan@webkit.org | 8be15d6 | 2009-04-09 11:20:57 +0000 | [diff] [blame] | 997 | if (coreObject->isVisited()) |
| 998 | atk_state_set_add_state(stateSet, ATK_STATE_VISITED); |
| 999 | } |
| 1000 | |
mario@webkit.org | 5c96677 | 2012-01-24 18:48:50 +0000 | [diff] [blame] | 1001 | static AtkStateSet* webkitAccessibleRefStateSet(AtkObject* object) |
xan@webkit.org | 8be15d6 | 2009-04-09 11:20:57 +0000 | [diff] [blame] | 1002 | { |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1003 | auto* accessible = WEBKIT_ACCESSIBLE(object); |
| 1004 | AtkStateSet* stateSet = ATK_OBJECT_CLASS(webkit_accessible_parent_class)->ref_state_set(object); |
xan@webkit.org | 8be15d6 | 2009-04-09 11:20:57 +0000 | [diff] [blame] | 1005 | |
mario@webkit.org | ff8cf0f | 2013-09-27 09:44:20 +0000 | [diff] [blame] | 1006 | // Make sure the layout is updated to really know whether the object |
| 1007 | // is defunct or not, so we can return the proper state. |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1008 | accessible->priv->object->updateBackingStore(); |
mario@webkit.org | ff8cf0f | 2013-09-27 09:44:20 +0000 | [diff] [blame] | 1009 | |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1010 | if (accessible->priv->object == fallbackObject()) { |
xan@webkit.org | 8be15d6 | 2009-04-09 11:20:57 +0000 | [diff] [blame] | 1011 | atk_state_set_add_state(stateSet, ATK_STATE_DEFUNCT); |
| 1012 | return stateSet; |
| 1013 | } |
| 1014 | |
mario@webkit.org | 6a24ba1 | 2010-12-14 15:35:22 +0000 | [diff] [blame] | 1015 | // Text objects must be focusable. |
| 1016 | AtkRole role = atk_object_get_role(object); |
| 1017 | if (role == ATK_ROLE_TEXT || role == ATK_ROLE_PARAGRAPH) |
| 1018 | atk_state_set_add_state(stateSet, ATK_STATE_FOCUSABLE); |
xan@webkit.org | 8be15d6 | 2009-04-09 11:20:57 +0000 | [diff] [blame] | 1019 | |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1020 | setAtkStateSetFromCoreObject(accessible->priv->object, stateSet); |
xan@webkit.org | 8be15d6 | 2009-04-09 11:20:57 +0000 | [diff] [blame] | 1021 | return stateSet; |
| 1022 | } |
| 1023 | |
mario@webkit.org | 5c96677 | 2012-01-24 18:48:50 +0000 | [diff] [blame] | 1024 | static AtkRelationSet* webkitAccessibleRefRelationSet(AtkObject* object) |
eric@webkit.org | 0f6cb45 | 2009-10-22 23:07:56 +0000 | [diff] [blame] | 1025 | { |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1026 | auto* accessible = WEBKIT_ACCESSIBLE(object); |
| 1027 | returnValIfWebKitAccessibleIsInvalid(accessible, nullptr); |
mario@webkit.org | ff8cf0f | 2013-09-27 09:44:20 +0000 | [diff] [blame] | 1028 | |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1029 | AtkRelationSet* relationSet = ATK_OBJECT_CLASS(webkit_accessible_parent_class)->ref_relation_set(object); |
| 1030 | setAtkRelationSetFromCoreObject(accessible->priv->object, relationSet); |
eric@webkit.org | 0f6cb45 | 2009-10-22 23:07:56 +0000 | [diff] [blame] | 1031 | return relationSet; |
| 1032 | } |
| 1033 | |
mario@webkit.org | 5c96677 | 2012-01-24 18:48:50 +0000 | [diff] [blame] | 1034 | static void webkitAccessibleInit(AtkObject* object, gpointer data) |
xan@webkit.org | e438710 | 2009-04-09 11:08:48 +0000 | [diff] [blame] | 1035 | { |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1036 | if (ATK_OBJECT_CLASS(webkit_accessible_parent_class)->initialize) |
| 1037 | ATK_OBJECT_CLASS(webkit_accessible_parent_class)->initialize(object, data); |
xan@webkit.org | e438710 | 2009-04-09 11:08:48 +0000 | [diff] [blame] | 1038 | |
mario@webkit.org | fecbacd | 2013-03-04 17:06:15 +0000 | [diff] [blame] | 1039 | WebKitAccessible* accessible = WEBKIT_ACCESSIBLE(object); |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1040 | accessible->priv->object = reinterpret_cast<AccessibilityObject*>(data); |
xan@webkit.org | e438710 | 2009-04-09 11:08:48 +0000 | [diff] [blame] | 1041 | } |
| 1042 | |
commit-queue@webkit.org | 120f565 | 2013-06-12 21:39:42 +0000 | [diff] [blame] | 1043 | static const gchar* webkitAccessibleGetObjectLocale(AtkObject* object) |
| 1044 | { |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1045 | auto* accessible = WEBKIT_ACCESSIBLE(object); |
| 1046 | returnValIfWebKitAccessibleIsInvalid(accessible, nullptr); |
mario@webkit.org | ff8cf0f | 2013-09-27 09:44:20 +0000 | [diff] [blame] | 1047 | |
| 1048 | if (ATK_IS_DOCUMENT(object)) { |
commit-queue@webkit.org | 120f565 | 2013-06-12 21:39:42 +0000 | [diff] [blame] | 1049 | // TODO: Should we fall back on lang xml:lang when the following comes up empty? |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1050 | String language = accessible->priv->object->language(); |
commit-queue@webkit.org | 120f565 | 2013-06-12 21:39:42 +0000 | [diff] [blame] | 1051 | if (!language.isEmpty()) |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1052 | return webkitAccessibleCacheAndReturnAtkProperty(accessible, AtkCachedDocumentLocale, language.utf8()); |
commit-queue@webkit.org | 120f565 | 2013-06-12 21:39:42 +0000 | [diff] [blame] | 1053 | |
| 1054 | } else if (ATK_IS_TEXT(object)) { |
commit-queue@webkit.org | 9a24e2d | 2015-05-29 04:53:35 +0000 | [diff] [blame] | 1055 | const gchar* locale = nullptr; |
commit-queue@webkit.org | 120f565 | 2013-06-12 21:39:42 +0000 | [diff] [blame] | 1056 | |
| 1057 | AtkAttributeSet* textAttributes = atk_text_get_default_attributes(ATK_TEXT(object)); |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1058 | for (auto* attributes = textAttributes; attributes; attributes = attributes->next) { |
| 1059 | auto* atkAttribute = static_cast<AtkAttribute*>(attributes->data); |
commit-queue@webkit.org | 120f565 | 2013-06-12 21:39:42 +0000 | [diff] [blame] | 1060 | if (!strcmp(atkAttribute->name, atk_text_attribute_get_name(ATK_TEXT_ATTR_LANGUAGE))) { |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1061 | locale = webkitAccessibleCacheAndReturnAtkProperty(accessible, AtkCachedDocumentLocale, atkAttribute->value); |
commit-queue@webkit.org | 120f565 | 2013-06-12 21:39:42 +0000 | [diff] [blame] | 1062 | break; |
| 1063 | } |
| 1064 | } |
commit-queue@webkit.org | 120f565 | 2013-06-12 21:39:42 +0000 | [diff] [blame] | 1065 | atk_attribute_set_free(textAttributes); |
| 1066 | |
| 1067 | return locale; |
| 1068 | } |
| 1069 | |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1070 | return nullptr; |
commit-queue@webkit.org | 120f565 | 2013-06-12 21:39:42 +0000 | [diff] [blame] | 1071 | } |
| 1072 | |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1073 | static void webkit_accessible_class_init(WebKitAccessibleClass* klass) |
xan@webkit.org | e438710 | 2009-04-09 11:08:48 +0000 | [diff] [blame] | 1074 | { |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1075 | auto* atkObjectClass = ATK_OBJECT_CLASS(klass); |
| 1076 | atkObjectClass->initialize = webkitAccessibleInit; |
| 1077 | atkObjectClass->get_name = webkitAccessibleGetName; |
| 1078 | atkObjectClass->get_description = webkitAccessibleGetDescription; |
| 1079 | atkObjectClass->get_parent = webkitAccessibleGetParent; |
| 1080 | atkObjectClass->get_n_children = webkitAccessibleGetNChildren; |
| 1081 | atkObjectClass->ref_child = webkitAccessibleRefChild; |
| 1082 | atkObjectClass->get_role = webkitAccessibleGetRole; |
| 1083 | atkObjectClass->ref_state_set = webkitAccessibleRefStateSet; |
| 1084 | atkObjectClass->get_index_in_parent = webkitAccessibleGetIndexInParent; |
| 1085 | atkObjectClass->get_attributes = webkitAccessibleGetAttributes; |
| 1086 | atkObjectClass->ref_relation_set = webkitAccessibleRefRelationSet; |
| 1087 | atkObjectClass->get_object_locale = webkitAccessibleGetObjectLocale; |
xan@webkit.org | e438710 | 2009-04-09 11:08:48 +0000 | [diff] [blame] | 1088 | } |
| 1089 | |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1090 | static const GInterfaceInfo atkInterfacesInitFunctions[] = { |
| 1091 | {reinterpret_cast<GInterfaceInitFunc>(reinterpret_cast<GCallback>(webkitAccessibleActionInterfaceInit)), nullptr, nullptr}, |
| 1092 | {reinterpret_cast<GInterfaceInitFunc>(reinterpret_cast<GCallback>(webkitAccessibleSelectionInterfaceInit)), nullptr, nullptr}, |
| 1093 | {reinterpret_cast<GInterfaceInitFunc>(reinterpret_cast<GCallback>(webkitAccessibleEditableTextInterfaceInit)), nullptr, nullptr}, |
| 1094 | {reinterpret_cast<GInterfaceInitFunc>(reinterpret_cast<GCallback>(webkitAccessibleTextInterfaceInit)), nullptr, nullptr}, |
| 1095 | {reinterpret_cast<GInterfaceInitFunc>(reinterpret_cast<GCallback>(webkitAccessibleComponentInterfaceInit)), nullptr, nullptr}, |
| 1096 | {reinterpret_cast<GInterfaceInitFunc>(reinterpret_cast<GCallback>(webkitAccessibleImageInterfaceInit)), nullptr, nullptr}, |
| 1097 | {reinterpret_cast<GInterfaceInitFunc>(reinterpret_cast<GCallback>(webkitAccessibleTableInterfaceInit)), nullptr, nullptr}, |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1098 | {reinterpret_cast<GInterfaceInitFunc>(reinterpret_cast<GCallback>(webkitAccessibleTableCellInterfaceInit)), nullptr, nullptr}, |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1099 | {reinterpret_cast<GInterfaceInitFunc>(reinterpret_cast<GCallback>(webkitAccessibleHypertextInterfaceInit)), nullptr, nullptr}, |
| 1100 | {reinterpret_cast<GInterfaceInitFunc>(reinterpret_cast<GCallback>(webkitAccessibleHyperlinkImplInterfaceInit)), nullptr, nullptr}, |
| 1101 | {reinterpret_cast<GInterfaceInitFunc>(reinterpret_cast<GCallback>(webkitAccessibleDocumentInterfaceInit)), nullptr, nullptr}, |
| 1102 | {reinterpret_cast<GInterfaceInitFunc>(reinterpret_cast<GCallback>(webkitAccessibleValueInterfaceInit)), nullptr, nullptr} |
xan@webkit.org | e438710 | 2009-04-09 11:08:48 +0000 | [diff] [blame] | 1103 | }; |
| 1104 | |
| 1105 | enum WAIType { |
k.czech@samsung.com | 3871a7a | 2014-02-27 14:22:14 +0000 | [diff] [blame] | 1106 | WAIAction, |
| 1107 | WAISelection, |
| 1108 | WAIEditableText, |
| 1109 | WAIText, |
| 1110 | WAIComponent, |
| 1111 | WAIImage, |
| 1112 | WAITable, |
k.czech@samsung.com | 3871a7a | 2014-02-27 14:22:14 +0000 | [diff] [blame] | 1113 | WAITableCell, |
k.czech@samsung.com | 3871a7a | 2014-02-27 14:22:14 +0000 | [diff] [blame] | 1114 | WAIHypertext, |
| 1115 | WAIHyperlink, |
| 1116 | WAIDocument, |
| 1117 | WAIValue, |
xan@webkit.org | e438710 | 2009-04-09 11:08:48 +0000 | [diff] [blame] | 1118 | }; |
| 1119 | |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1120 | static GType atkInterfaceTypeFromWAIType(WAIType type) |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 1121 | { |
mario@webkit.org | 7f95c62 | 2010-11-01 15:05:36 +0000 | [diff] [blame] | 1122 | switch (type) { |
k.czech@samsung.com | 3871a7a | 2014-02-27 14:22:14 +0000 | [diff] [blame] | 1123 | case WAIAction: |
mario@webkit.org | 7f95c62 | 2010-11-01 15:05:36 +0000 | [diff] [blame] | 1124 | return ATK_TYPE_ACTION; |
k.czech@samsung.com | 3871a7a | 2014-02-27 14:22:14 +0000 | [diff] [blame] | 1125 | case WAISelection: |
mario@webkit.org | 7f95c62 | 2010-11-01 15:05:36 +0000 | [diff] [blame] | 1126 | return ATK_TYPE_SELECTION; |
k.czech@samsung.com | 3871a7a | 2014-02-27 14:22:14 +0000 | [diff] [blame] | 1127 | case WAIEditableText: |
mario@webkit.org | 7f95c62 | 2010-11-01 15:05:36 +0000 | [diff] [blame] | 1128 | return ATK_TYPE_EDITABLE_TEXT; |
k.czech@samsung.com | 3871a7a | 2014-02-27 14:22:14 +0000 | [diff] [blame] | 1129 | case WAIText: |
mario@webkit.org | 7f95c62 | 2010-11-01 15:05:36 +0000 | [diff] [blame] | 1130 | return ATK_TYPE_TEXT; |
k.czech@samsung.com | 3871a7a | 2014-02-27 14:22:14 +0000 | [diff] [blame] | 1131 | case WAIComponent: |
mario@webkit.org | 7f95c62 | 2010-11-01 15:05:36 +0000 | [diff] [blame] | 1132 | return ATK_TYPE_COMPONENT; |
k.czech@samsung.com | 3871a7a | 2014-02-27 14:22:14 +0000 | [diff] [blame] | 1133 | case WAIImage: |
mario@webkit.org | 7f95c62 | 2010-11-01 15:05:36 +0000 | [diff] [blame] | 1134 | return ATK_TYPE_IMAGE; |
k.czech@samsung.com | 3871a7a | 2014-02-27 14:22:14 +0000 | [diff] [blame] | 1135 | case WAITable: |
mario@webkit.org | 7f95c62 | 2010-11-01 15:05:36 +0000 | [diff] [blame] | 1136 | return ATK_TYPE_TABLE; |
k.czech@samsung.com | 3871a7a | 2014-02-27 14:22:14 +0000 | [diff] [blame] | 1137 | case WAITableCell: |
k.czech@samsung.com | 2608de9 | 2014-02-27 11:28:31 +0000 | [diff] [blame] | 1138 | return ATK_TYPE_TABLE_CELL; |
k.czech@samsung.com | 3871a7a | 2014-02-27 14:22:14 +0000 | [diff] [blame] | 1139 | case WAIHypertext: |
mario@webkit.org | 7f95c62 | 2010-11-01 15:05:36 +0000 | [diff] [blame] | 1140 | return ATK_TYPE_HYPERTEXT; |
k.czech@samsung.com | 3871a7a | 2014-02-27 14:22:14 +0000 | [diff] [blame] | 1141 | case WAIHyperlink: |
mario@webkit.org | 7f95c62 | 2010-11-01 15:05:36 +0000 | [diff] [blame] | 1142 | return ATK_TYPE_HYPERLINK_IMPL; |
k.czech@samsung.com | 3871a7a | 2014-02-27 14:22:14 +0000 | [diff] [blame] | 1143 | case WAIDocument: |
mario@webkit.org | 7f95c62 | 2010-11-01 15:05:36 +0000 | [diff] [blame] | 1144 | return ATK_TYPE_DOCUMENT; |
k.czech@samsung.com | 3871a7a | 2014-02-27 14:22:14 +0000 | [diff] [blame] | 1145 | case WAIValue: |
mario@webkit.org | 04e38e9 | 2011-03-28 10:16:38 +0000 | [diff] [blame] | 1146 | return ATK_TYPE_VALUE; |
mario@webkit.org | 7f95c62 | 2010-11-01 15:05:36 +0000 | [diff] [blame] | 1147 | } |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 1148 | |
mario@webkit.org | 7f95c62 | 2010-11-01 15:05:36 +0000 | [diff] [blame] | 1149 | return G_TYPE_INVALID; |
xan@webkit.org | e438710 | 2009-04-09 11:08:48 +0000 | [diff] [blame] | 1150 | } |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 1151 | |
commit-queue@webkit.org | ca1b1d2 | 2012-08-22 01:37:04 +0000 | [diff] [blame] | 1152 | static bool roleIsTextType(AccessibilityRole role) |
| 1153 | { |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 1154 | return role == AccessibilityRole::Paragraph |
| 1155 | || role == AccessibilityRole::Heading |
| 1156 | || role == AccessibilityRole::Div |
| 1157 | || role == AccessibilityRole::Cell |
| 1158 | || role == AccessibilityRole::Link |
| 1159 | || role == AccessibilityRole::WebCoreLink |
| 1160 | || role == AccessibilityRole::ListItem |
| 1161 | || role == AccessibilityRole::Pre |
| 1162 | || role == AccessibilityRole::GridCell |
| 1163 | || role == AccessibilityRole::TextGroup |
carlosgc@webkit.org | b93535b | 2019-04-11 08:25:36 +0000 | [diff] [blame] | 1164 | || role == AccessibilityRole::ApplicationTextGroup |
| 1165 | || role == AccessibilityRole::ApplicationGroup; |
commit-queue@webkit.org | ca1b1d2 | 2012-08-22 01:37:04 +0000 | [diff] [blame] | 1166 | } |
| 1167 | |
andresg_22@apple.com | 5c90e23 | 2019-10-30 20:44:34 +0000 | [diff] [blame] | 1168 | static guint16 interfaceMaskFromObject(AXCoreObject* coreObject) |
xan@webkit.org | e438710 | 2009-04-09 11:08:48 +0000 | [diff] [blame] | 1169 | { |
| 1170 | guint16 interfaceMask = 0; |
alp@webkit.org | c773899 | 2008-05-27 02:48:14 +0000 | [diff] [blame] | 1171 | |
xan@webkit.org | 92b9169 | 2009-04-21 07:02:17 +0000 | [diff] [blame] | 1172 | // Component interface is always supported |
k.czech@samsung.com | 3871a7a | 2014-02-27 14:22:14 +0000 | [diff] [blame] | 1173 | interfaceMask |= 1 << WAIComponent; |
xan@webkit.org | 92b9169 | 2009-04-21 07:02:17 +0000 | [diff] [blame] | 1174 | |
mario@webkit.org | 7f95c62 | 2010-11-01 15:05:36 +0000 | [diff] [blame] | 1175 | AccessibilityRole role = coreObject->roleValue(); |
| 1176 | |
xan@webkit.org | b3c59bf | 2009-04-21 07:01:27 +0000 | [diff] [blame] | 1177 | // Action |
mario@webkit.org | 8ce6a15 | 2010-11-30 21:16:14 +0000 | [diff] [blame] | 1178 | // As the implementation of the AtkAction interface is a very |
| 1179 | // basic one (just relays in executing the default action for each |
| 1180 | // object, and only supports having one action per object), it is |
| 1181 | // better just to implement this interface for every instance of |
| 1182 | // the WebKitAccessible class and let WebCore decide what to do. |
k.czech@samsung.com | 3871a7a | 2014-02-27 14:22:14 +0000 | [diff] [blame] | 1183 | interfaceMask |= 1 << WAIAction; |
xan@webkit.org | b3c59bf | 2009-04-21 07:01:27 +0000 | [diff] [blame] | 1184 | |
eric@webkit.org | f84ff63 | 2009-10-29 17:34:39 +0000 | [diff] [blame] | 1185 | // Selection |
jdiggs@igalia.com | b0b6255 | 2016-11-19 21:12:24 +0000 | [diff] [blame] | 1186 | if (coreObject->canHaveSelectedChildren() || coreObject->isMenuList()) |
k.czech@samsung.com | 3871a7a | 2014-02-27 14:22:14 +0000 | [diff] [blame] | 1187 | interfaceMask |= 1 << WAISelection; |
eric@webkit.org | f84ff63 | 2009-10-29 17:34:39 +0000 | [diff] [blame] | 1188 | |
mario@webkit.org | 9f0aee1 | 2011-04-11 21:02:23 +0000 | [diff] [blame] | 1189 | // Get renderer if available. |
commit-queue@webkit.org | 9a24e2d | 2015-05-29 04:53:35 +0000 | [diff] [blame] | 1190 | RenderObject* renderer = nullptr; |
mario@webkit.org | 9f0aee1 | 2011-04-11 21:02:23 +0000 | [diff] [blame] | 1191 | if (coreObject->isAccessibilityRenderObject()) |
| 1192 | renderer = coreObject->renderer(); |
| 1193 | |
| 1194 | // Hyperlink (links and embedded objects). |
| 1195 | if (coreObject->isLink() || (renderer && renderer->isReplaced())) |
k.czech@samsung.com | 3871a7a | 2014-02-27 14:22:14 +0000 | [diff] [blame] | 1196 | interfaceMask |= 1 << WAIHyperlink; |
mario@webkit.org | 9f0aee1 | 2011-04-11 21:02:23 +0000 | [diff] [blame] | 1197 | |
mario.prada@samsung.com | 56598be | 2014-04-09 15:05:58 +0000 | [diff] [blame] | 1198 | // Text, Editable Text & Hypertext |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 1199 | if (role == AccessibilityRole::StaticText || coreObject->isMenuListOption()) |
k.czech@samsung.com | 3871a7a | 2014-02-27 14:22:14 +0000 | [diff] [blame] | 1200 | interfaceMask |= 1 << WAIText; |
jdiggs@igalia.com | 23022cc | 2016-05-11 07:14:31 +0000 | [diff] [blame] | 1201 | else if (coreObject->isTextControl() || coreObject->isNonNativeTextControl()) { |
mario.prada@samsung.com | 56598be | 2014-04-09 15:05:58 +0000 | [diff] [blame] | 1202 | interfaceMask |= 1 << WAIText; |
jdiggs@igalia.com | 23022cc | 2016-05-11 07:14:31 +0000 | [diff] [blame] | 1203 | if (coreObject->canSetValueAttribute()) |
mario.prada@samsung.com | 56598be | 2014-04-09 15:05:58 +0000 | [diff] [blame] | 1204 | interfaceMask |= 1 << WAIEditableText; |
| 1205 | } else if (!coreObject->isWebArea()) { |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 1206 | if (role != AccessibilityRole::Table) { |
mario.prada@samsung.com | 56598be | 2014-04-09 15:05:58 +0000 | [diff] [blame] | 1207 | interfaceMask |= 1 << WAIHypertext; |
jdiggs@igalia.com | ad83c35 | 2014-12-10 19:57:33 +0000 | [diff] [blame] | 1208 | if ((renderer && renderer->childrenInline()) || roleIsTextType(role) || coreObject->isMathToken()) |
mario.prada@samsung.com | 56598be | 2014-04-09 15:05:58 +0000 | [diff] [blame] | 1209 | interfaceMask |= 1 << WAIText; |
| 1210 | } |
mario@webkit.org | 7f95c62 | 2010-11-01 15:05:36 +0000 | [diff] [blame] | 1211 | |
mario.prada@samsung.com | 56598be | 2014-04-09 15:05:58 +0000 | [diff] [blame] | 1212 | // Add the TEXT interface for list items whose |
| 1213 | // first accessible child has a text renderer |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 1214 | if (role == AccessibilityRole::ListItem) { |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1215 | const auto& children = coreObject->children(); |
| 1216 | if (!children.isEmpty()) |
| 1217 | interfaceMask |= interfaceMaskFromObject(children[0].get()); |
commit-queue@webkit.org | 1f3aafe | 2010-09-22 07:49:34 +0000 | [diff] [blame] | 1218 | } |
mario@webkit.org | 7f95c62 | 2010-11-01 15:05:36 +0000 | [diff] [blame] | 1219 | } |
xan@webkit.org | e438710 | 2009-04-09 11:08:48 +0000 | [diff] [blame] | 1220 | |
xan@webkit.org | e43e70b | 2009-04-27 21:33:55 +0000 | [diff] [blame] | 1221 | // Image |
| 1222 | if (coreObject->isImage()) |
k.czech@samsung.com | 3871a7a | 2014-02-27 14:22:14 +0000 | [diff] [blame] | 1223 | interfaceMask |= 1 << WAIImage; |
xan@webkit.org | e43e70b | 2009-04-27 21:33:55 +0000 | [diff] [blame] | 1224 | |
xan@webkit.org | 45b26ac | 2009-10-27 12:20:35 +0000 | [diff] [blame] | 1225 | // Table |
jdiggs@igalia.com | 8c93478 | 2017-04-30 18:11:56 +0000 | [diff] [blame] | 1226 | if (coreObject->isTable()) |
k.czech@samsung.com | 3871a7a | 2014-02-27 14:22:14 +0000 | [diff] [blame] | 1227 | interfaceMask |= 1 << WAITable; |
xan@webkit.org | 45b26ac | 2009-10-27 12:20:35 +0000 | [diff] [blame] | 1228 | |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 1229 | if (role == AccessibilityRole::Cell || role == AccessibilityRole::GridCell || role == AccessibilityRole::ColumnHeader || role == AccessibilityRole::RowHeader) |
k.czech@samsung.com | 3871a7a | 2014-02-27 14:22:14 +0000 | [diff] [blame] | 1230 | interfaceMask |= 1 << WAITableCell; |
k.czech@samsung.com | 2608de9 | 2014-02-27 11:28:31 +0000 | [diff] [blame] | 1231 | |
eric@webkit.org | 65e12ba | 2009-11-01 21:22:30 +0000 | [diff] [blame] | 1232 | // Document |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 1233 | if (role == AccessibilityRole::WebArea) |
k.czech@samsung.com | 3871a7a | 2014-02-27 14:22:14 +0000 | [diff] [blame] | 1234 | interfaceMask |= 1 << WAIDocument; |
eric@webkit.org | 65e12ba | 2009-11-01 21:22:30 +0000 | [diff] [blame] | 1235 | |
mario@webkit.org | 04e38e9 | 2011-03-28 10:16:38 +0000 | [diff] [blame] | 1236 | // Value |
jdiggs@igalia.com | 353e872 | 2017-04-28 17:08:57 +0000 | [diff] [blame] | 1237 | if (coreObject->supportsRangeValue()) |
k.czech@samsung.com | 3871a7a | 2014-02-27 14:22:14 +0000 | [diff] [blame] | 1238 | interfaceMask |= 1 << WAIValue; |
mario@webkit.org | 04e38e9 | 2011-03-28 10:16:38 +0000 | [diff] [blame] | 1239 | |
commit-queue@webkit.org | fd70fd3 | 2013-09-04 14:19:02 +0000 | [diff] [blame] | 1240 | #if ENABLE(INPUT_TYPE_COLOR) |
| 1241 | // Color type. |
achristensen@apple.com | f80908b | 2017-10-27 00:37:06 +0000 | [diff] [blame] | 1242 | if (role == AccessibilityRole::ColorWell) |
k.czech@samsung.com | 3871a7a | 2014-02-27 14:22:14 +0000 | [diff] [blame] | 1243 | interfaceMask |= 1 << WAIText; |
commit-queue@webkit.org | fd70fd3 | 2013-09-04 14:19:02 +0000 | [diff] [blame] | 1244 | #endif |
| 1245 | |
xan@webkit.org | e438710 | 2009-04-09 11:08:48 +0000 | [diff] [blame] | 1246 | return interfaceMask; |
| 1247 | } |
| 1248 | |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1249 | static const char* uniqueAccessibilityTypeName(guint16 interfaceMask) |
xan@webkit.org | e438710 | 2009-04-09 11:08:48 +0000 | [diff] [blame] | 1250 | { |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1251 | #define WAI_TYPE_NAME_LEN (30) // Enough for prefix + 5 hex characters (max). |
xan@webkit.org | e438710 | 2009-04-09 11:08:48 +0000 | [diff] [blame] | 1252 | static char name[WAI_TYPE_NAME_LEN + 1]; |
eric@webkit.org | 4ff6fd7 | 2009-11-10 09:53:33 +0000 | [diff] [blame] | 1253 | |
xan@webkit.org | e438710 | 2009-04-09 11:08:48 +0000 | [diff] [blame] | 1254 | g_sprintf(name, "WAIType%x", interfaceMask); |
| 1255 | name[WAI_TYPE_NAME_LEN] = '\0'; |
eric@webkit.org | 4ff6fd7 | 2009-11-10 09:53:33 +0000 | [diff] [blame] | 1256 | |
xan@webkit.org | e438710 | 2009-04-09 11:08:48 +0000 | [diff] [blame] | 1257 | return name; |
| 1258 | } |
| 1259 | |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1260 | static GType accessibilityTypeFromObject(AccessibilityObject* coreObject) |
xan@webkit.org | e438710 | 2009-04-09 11:08:48 +0000 | [diff] [blame] | 1261 | { |
| 1262 | static const GTypeInfo typeInfo = { |
| 1263 | sizeof(WebKitAccessibleClass), |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1264 | nullptr, // GBaseInitFunc |
| 1265 | nullptr, // GBaseFinalizeFunc |
| 1266 | nullptr, // GClassInitFunc |
| 1267 | nullptr, // GClassFinalizeFunc |
| 1268 | nullptr, // class data |
| 1269 | sizeof(WebKitAccessible), // instance size |
| 1270 | 0, // nb preallocs |
| 1271 | nullptr, // GInstanceInitFunc |
| 1272 | nullptr // value table |
xan@webkit.org | e438710 | 2009-04-09 11:08:48 +0000 | [diff] [blame] | 1273 | }; |
| 1274 | |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1275 | guint16 interfaceMask = interfaceMaskFromObject(coreObject); |
| 1276 | const char* atkTypeName = uniqueAccessibilityTypeName(interfaceMask); |
| 1277 | if (GType type = g_type_from_name(atkTypeName)) |
xan@webkit.org | e438710 | 2009-04-09 11:08:48 +0000 | [diff] [blame] | 1278 | return type; |
| 1279 | |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1280 | GType type = g_type_register_static(WEBKIT_TYPE_ACCESSIBLE, atkTypeName, &typeInfo, static_cast<GTypeFlags>(0)); |
| 1281 | for (unsigned i = 0; i < G_N_ELEMENTS(atkInterfacesInitFunctions); ++i) { |
| 1282 | if (interfaceMask & (1 << i)) { |
xan@webkit.org | e438710 | 2009-04-09 11:08:48 +0000 | [diff] [blame] | 1283 | g_type_add_interface_static(type, |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1284 | atkInterfaceTypeFromWAIType(static_cast<WAIType>(i)), |
| 1285 | &atkInterfacesInitFunctions[i]); |
| 1286 | } |
xan@webkit.org | e438710 | 2009-04-09 11:08:48 +0000 | [diff] [blame] | 1287 | } |
| 1288 | |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 1289 | return type; |
| 1290 | } |
| 1291 | |
mario@webkit.org | aacb217 | 2012-01-23 11:43:28 +0000 | [diff] [blame] | 1292 | WebKitAccessible* webkitAccessibleNew(AccessibilityObject* coreObject) |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 1293 | { |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1294 | auto* object = ATK_OBJECT(g_object_new(accessibilityTypeFromObject(coreObject), nullptr)); |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 1295 | atk_object_initialize(object, coreObject); |
| 1296 | return WEBKIT_ACCESSIBLE(object); |
| 1297 | } |
| 1298 | |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1299 | AccessibilityObject& webkitAccessibleGetAccessibilityObject(WebKitAccessible* accessible) |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 1300 | { |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1301 | ASSERT(WEBKIT_IS_ACCESSIBLE(accessible)); |
| 1302 | return *accessible->priv->object; |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 1303 | } |
| 1304 | |
mario@webkit.org | aacb217 | 2012-01-23 11:43:28 +0000 | [diff] [blame] | 1305 | void webkitAccessibleDetach(WebKitAccessible* accessible) |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 1306 | { |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1307 | ASSERT(WEBKIT_IS_ACCESSIBLE(accessible)); |
| 1308 | ASSERT(accessible->priv->object != fallbackObject()); |
alp@webkit.org | c773899 | 2008-05-27 02:48:14 +0000 | [diff] [blame] | 1309 | |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1310 | if (accessible->priv->object->roleValue() == AccessibilityRole::WebArea) |
| 1311 | atk_object_notify_state_change(ATK_OBJECT(accessible), ATK_STATE_DEFUNCT, TRUE); |
mario@webkit.org | 92daa81 | 2011-02-16 17:12:38 +0000 | [diff] [blame] | 1312 | |
alp@webkit.org | c773899 | 2008-05-27 02:48:14 +0000 | [diff] [blame] | 1313 | // We replace the WebCore AccessibilityObject with a fallback object that |
| 1314 | // provides default implementations to avoid repetitive null-checking after |
| 1315 | // detachment. |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1316 | accessible->priv->object = fallbackObject(); |
alp@webkit.org | 3a5e7ca | 2008-05-20 01:12:20 +0000 | [diff] [blame] | 1317 | } |
| 1318 | |
mario@webkit.org | ff8cf0f | 2013-09-27 09:44:20 +0000 | [diff] [blame] | 1319 | bool webkitAccessibleIsDetached(WebKitAccessible* accessible) |
| 1320 | { |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1321 | ASSERT(WEBKIT_IS_ACCESSIBLE(accessible)); |
| 1322 | return accessible->priv->object == fallbackObject(); |
mario@webkit.org | ff8cf0f | 2013-09-27 09:44:20 +0000 | [diff] [blame] | 1323 | } |
| 1324 | |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1325 | const char* webkitAccessibleCacheAndReturnAtkProperty(WebKitAccessible* accessible, AtkCachedProperty property, CString&& value) |
eric@webkit.org | 2fade49 | 2010-01-11 12:03:36 +0000 | [diff] [blame] | 1326 | { |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1327 | ASSERT(WEBKIT_IS_ACCESSIBLE(accessible)); |
eric@webkit.org | 2fade49 | 2010-01-11 12:03:36 +0000 | [diff] [blame] | 1328 | |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1329 | WebKitAccessiblePrivate* priv = accessible->priv; |
commit-queue@webkit.org | 9a24e2d | 2015-05-29 04:53:35 +0000 | [diff] [blame] | 1330 | CString* propertyPtr = nullptr; |
mario@webkit.org | fecbacd | 2013-03-04 17:06:15 +0000 | [diff] [blame] | 1331 | |
| 1332 | switch (property) { |
| 1333 | case AtkCachedAccessibleName: |
| 1334 | propertyPtr = &priv->accessibleName; |
| 1335 | break; |
mario@webkit.org | fecbacd | 2013-03-04 17:06:15 +0000 | [diff] [blame] | 1336 | case AtkCachedAccessibleDescription: |
| 1337 | propertyPtr = &priv->accessibleDescription; |
| 1338 | break; |
mario@webkit.org | fecbacd | 2013-03-04 17:06:15 +0000 | [diff] [blame] | 1339 | case AtkCachedActionName: |
| 1340 | propertyPtr = &priv->actionName; |
| 1341 | break; |
mario@webkit.org | fecbacd | 2013-03-04 17:06:15 +0000 | [diff] [blame] | 1342 | case AtkCachedActionKeyBinding: |
| 1343 | propertyPtr = &priv->actionKeyBinding; |
| 1344 | break; |
mario@webkit.org | fecbacd | 2013-03-04 17:06:15 +0000 | [diff] [blame] | 1345 | case AtkCachedDocumentLocale: |
| 1346 | propertyPtr = &priv->documentLocale; |
| 1347 | break; |
mario@webkit.org | fecbacd | 2013-03-04 17:06:15 +0000 | [diff] [blame] | 1348 | case AtkCachedDocumentType: |
| 1349 | propertyPtr = &priv->documentType; |
| 1350 | break; |
mario@webkit.org | fecbacd | 2013-03-04 17:06:15 +0000 | [diff] [blame] | 1351 | case AtkCachedDocumentEncoding: |
| 1352 | propertyPtr = &priv->documentEncoding; |
| 1353 | break; |
mario@webkit.org | fecbacd | 2013-03-04 17:06:15 +0000 | [diff] [blame] | 1354 | case AtkCachedDocumentURI: |
| 1355 | propertyPtr = &priv->documentURI; |
| 1356 | break; |
mario@webkit.org | fecbacd | 2013-03-04 17:06:15 +0000 | [diff] [blame] | 1357 | case AtkCachedImageDescription: |
| 1358 | propertyPtr = &priv->imageDescription; |
| 1359 | break; |
mario@webkit.org | fecbacd | 2013-03-04 17:06:15 +0000 | [diff] [blame] | 1360 | default: |
| 1361 | ASSERT_NOT_REACHED(); |
| 1362 | } |
| 1363 | |
| 1364 | // Don't invalidate old memory if not stricly needed, since other |
| 1365 | // callers might be still holding on to it. |
carlosgc@webkit.org | ed2d42a | 2019-04-08 08:11:19 +0000 | [diff] [blame] | 1366 | if (*propertyPtr != value) |
| 1367 | *propertyPtr = WTFMove(value); |
mario@webkit.org | fecbacd | 2013-03-04 17:06:15 +0000 | [diff] [blame] | 1368 | |
| 1369 | return (*propertyPtr).data(); |
| 1370 | } |
| 1371 | |
psaavedra@igalia.com | 5b9fe19 | 2019-07-11 21:51:24 +0000 | [diff] [blame] | 1372 | #endif // ENABLE(ACCESSIBILITY) |