Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 1 | // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Tim van der Lippe | 6d1e03c | 2020-01-22 14:05:58 | [diff] [blame] | 4 | |
Tim van der Lippe | 8f15c8d | 2020-02-13 14:59:41 | [diff] [blame^] | 5 | import * as Common from '../common/common.js'; |
| 6 | import * as SDK from '../sdk/sdk.js'; |
| 7 | import * as UI from '../ui/ui.js'; |
| 8 | |
Tim van der Lippe | 6d1e03c | 2020-01-22 14:05:58 | [diff] [blame] | 9 | import {AccessibilityNode} from './AccessibilityModel.js'; // eslint-disable-line no-unused-vars |
| 10 | import {AXAttributes, AXNativeSourceTypes, AXSourceTypes} from './AccessibilityStrings.js'; |
| 11 | import {AccessibilitySubPane} from './AccessibilitySubPane.js'; |
| 12 | |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 13 | /** |
| 14 | * @unrestricted |
| 15 | */ |
Tim van der Lippe | 6d1e03c | 2020-01-22 14:05:58 | [diff] [blame] | 16 | export class AXNodeSubPane extends AccessibilitySubPane { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 17 | constructor() { |
| 18 | super(ls`Computed Properties`); |
| 19 | |
Tim van der Lippe | 6d1e03c | 2020-01-22 14:05:58 | [diff] [blame] | 20 | /** |
| 21 | * @protected |
| 22 | * @suppress {accessControls} |
| 23 | */ |
| 24 | this._axNode = null; |
| 25 | |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 26 | this.contentElement.classList.add('ax-subpane'); |
| 27 | |
| 28 | this._noNodeInfo = this.createInfo(ls`No accessibility node`); |
| 29 | this._ignoredInfo = this.createInfo(ls`Accessibility node not exposed`, 'ax-ignored-info hidden'); |
| 30 | |
| 31 | this._treeOutline = this.createTreeOutline(); |
| 32 | this._ignoredReasonsTree = this.createTreeOutline(); |
| 33 | |
| 34 | this.element.classList.add('accessibility-computed'); |
| 35 | this.registerRequiredCSS('accessibility/accessibilityNode.css'); |
Rob Paveza | 84d4144 | 2019-10-10 23:01:09 | [diff] [blame] | 36 | this._treeOutline.setFocusable(true); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | /** |
Tim van der Lippe | 6d1e03c | 2020-01-22 14:05:58 | [diff] [blame] | 40 | * @param {?AccessibilityNode} axNode |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 41 | * @override |
| 42 | */ |
| 43 | setAXNode(axNode) { |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 44 | if (this._axNode === axNode) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 45 | return; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 46 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 47 | this._axNode = axNode; |
| 48 | |
| 49 | const treeOutline = this._treeOutline; |
| 50 | treeOutline.removeChildren(); |
| 51 | const ignoredReasons = this._ignoredReasonsTree; |
| 52 | ignoredReasons.removeChildren(); |
| 53 | |
| 54 | if (!axNode) { |
| 55 | treeOutline.element.classList.add('hidden'); |
| 56 | this._ignoredInfo.classList.add('hidden'); |
| 57 | ignoredReasons.element.classList.add('hidden'); |
| 58 | |
| 59 | this._noNodeInfo.classList.remove('hidden'); |
| 60 | this.element.classList.add('ax-ignored-node-pane'); |
| 61 | |
| 62 | return; |
| 63 | } |
| 64 | |
| 65 | if (axNode.ignored()) { |
| 66 | this._noNodeInfo.classList.add('hidden'); |
| 67 | treeOutline.element.classList.add('hidden'); |
| 68 | this.element.classList.add('ax-ignored-node-pane'); |
| 69 | |
| 70 | this._ignoredInfo.classList.remove('hidden'); |
| 71 | ignoredReasons.element.classList.remove('hidden'); |
| 72 | /** |
| 73 | * @param {!Protocol.Accessibility.AXProperty} property |
| 74 | */ |
| 75 | function addIgnoredReason(property) { |
Tim van der Lippe | 6d1e03c | 2020-01-22 14:05:58 | [diff] [blame] | 76 | ignoredReasons.appendChild( |
| 77 | new AXNodeIgnoredReasonTreeElement(property, /** @type {!AccessibilityNode} */ (axNode))); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 78 | } |
| 79 | const ignoredReasonsArray = /** @type {!Array<!Protocol.Accessibility.AXProperty>} */ (axNode.ignoredReasons()); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 80 | for (const reason of ignoredReasonsArray) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 81 | addIgnoredReason(reason); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 82 | } |
| 83 | if (!ignoredReasons.firstChild()) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 84 | ignoredReasons.element.classList.add('hidden'); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 85 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 86 | return; |
| 87 | } |
| 88 | this.element.classList.remove('ax-ignored-node-pane'); |
| 89 | |
| 90 | this._ignoredInfo.classList.add('hidden'); |
| 91 | ignoredReasons.element.classList.add('hidden'); |
| 92 | this._noNodeInfo.classList.add('hidden'); |
| 93 | |
| 94 | treeOutline.element.classList.remove('hidden'); |
| 95 | |
| 96 | /** |
| 97 | * @param {!Protocol.Accessibility.AXProperty} property |
| 98 | */ |
| 99 | function addProperty(property) { |
Tim van der Lippe | 6d1e03c | 2020-01-22 14:05:58 | [diff] [blame] | 100 | treeOutline.appendChild( |
| 101 | new AXNodePropertyTreePropertyElement(property, /** @type {!AccessibilityNode} */ (axNode))); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 102 | } |
| 103 | |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 104 | for (const property of axNode.coreProperties()) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 105 | addProperty(property); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 106 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 107 | |
| 108 | const roleProperty = /** @type {!Protocol.Accessibility.AXProperty} */ ({name: 'role', value: axNode.role()}); |
| 109 | addProperty(roleProperty); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 110 | for (const property of /** @type {!Array.<!Protocol.Accessibility.AXProperty>} */ (axNode.properties())) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 111 | addProperty(property); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 112 | } |
Rob Paveza | 84d4144 | 2019-10-10 23:01:09 | [diff] [blame] | 113 | |
| 114 | const firstNode = treeOutline.firstChild(); |
| 115 | if (firstNode) { |
| 116 | firstNode.select(/* omitFocus= */ true, /* selectedByUser= */ false); |
| 117 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | /** |
| 121 | * @override |
Tim van der Lippe | 8f15c8d | 2020-02-13 14:59:41 | [diff] [blame^] | 122 | * @param {?SDK.DOMModel.DOMNode} node |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 123 | */ |
| 124 | setNode(node) { |
| 125 | super.setNode(node); |
| 126 | this._axNode = null; |
| 127 | } |
Paul Lewis | f16142c | 2019-11-07 15:56:04 | [diff] [blame] | 128 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 129 | |
| 130 | /** |
| 131 | * @unrestricted |
| 132 | */ |
Tim van der Lippe | 8f15c8d | 2020-02-13 14:59:41 | [diff] [blame^] | 133 | export class AXNodePropertyTreeElement extends UI.TreeOutline.TreeElement { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 134 | /** |
Tim van der Lippe | 6d1e03c | 2020-01-22 14:05:58 | [diff] [blame] | 135 | * @param {!AccessibilityNode} axNode |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 136 | */ |
| 137 | constructor(axNode) { |
| 138 | // Pass an empty title, the title gets made later in onattach. |
| 139 | super(''); |
| 140 | this._axNode = axNode; |
| 141 | } |
| 142 | |
| 143 | /** |
| 144 | * @param {?Protocol.Accessibility.AXValueType} type |
| 145 | * @param {string} value |
| 146 | * @return {!Element} |
| 147 | */ |
| 148 | static createSimpleValueElement(type, value) { |
| 149 | let valueElement; |
| 150 | const AXValueType = Protocol.Accessibility.AXValueType; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 151 | if (!type || type === AXValueType.ValueUndefined || type === AXValueType.ComputedString) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 152 | valueElement = createElement('span'); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 153 | } else { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 154 | valueElement = createElementWithClass('span', 'monospace'); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 155 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 156 | let valueText; |
Tim van der Lippe | 6d1e03c | 2020-01-22 14:05:58 | [diff] [blame] | 157 | const isStringProperty = type && StringProperties.has(type); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 158 | if (isStringProperty) { |
| 159 | // Render \n as a nice unicode cr symbol. |
| 160 | valueText = '"' + value.replace(/\n/g, '\u21B5') + '"'; |
| 161 | valueElement._originalTextContent = value; |
| 162 | } else { |
| 163 | valueText = String(value); |
| 164 | } |
| 165 | |
Tim van der Lippe | 6d1e03c | 2020-01-22 14:05:58 | [diff] [blame] | 166 | if (type && type in TypeStyles) { |
| 167 | valueElement.classList.add(TypeStyles[type]); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 168 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 169 | |
| 170 | valueElement.setTextContentTruncatedIfNeeded(valueText || ''); |
| 171 | |
| 172 | valueElement.title = String(value) || ''; |
| 173 | |
| 174 | return valueElement; |
| 175 | } |
| 176 | |
| 177 | /** |
| 178 | * @param {string} tooltip |
| 179 | * @return {!Element} |
| 180 | */ |
| 181 | static createExclamationMark(tooltip) { |
Joel Einbinder | 7fbe24c | 2019-01-24 05:19:01 | [diff] [blame] | 182 | const exclamationElement = createElement('span', 'dt-icon-label'); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 183 | exclamationElement.type = 'smallicon-warning'; |
| 184 | exclamationElement.title = tooltip; |
| 185 | return exclamationElement; |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * @param {string} name |
| 190 | */ |
| 191 | appendNameElement(name) { |
| 192 | const nameElement = createElement('span'); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 193 | if (name in AXAttributes) { |
Mandy Chen | ba6de38 | 2019-06-07 21:38:50 | [diff] [blame] | 194 | nameElement.textContent = AXAttributes[name].name; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 195 | nameElement.title = AXAttributes[name].description; |
| 196 | nameElement.classList.add('ax-readable-name'); |
| 197 | } else { |
| 198 | nameElement.textContent = name; |
| 199 | nameElement.classList.add('ax-name'); |
| 200 | nameElement.classList.add('monospace'); |
| 201 | } |
| 202 | this.listItemElement.appendChild(nameElement); |
| 203 | } |
| 204 | |
| 205 | /** |
| 206 | * @param {!Protocol.Accessibility.AXValue} value |
| 207 | */ |
| 208 | appendValueElement(value) { |
| 209 | const AXValueType = Protocol.Accessibility.AXValueType; |
| 210 | if (value.type === AXValueType.Idref || value.type === AXValueType.Node || value.type === AXValueType.IdrefList || |
| 211 | value.type === AXValueType.NodeList) { |
| 212 | this.appendRelatedNodeListValueElement(value); |
| 213 | return; |
| 214 | } else if (value.sources) { |
| 215 | const sources = value.sources; |
| 216 | for (let i = 0; i < sources.length; i++) { |
| 217 | const source = sources[i]; |
Tim van der Lippe | 6d1e03c | 2020-01-22 14:05:58 | [diff] [blame] | 218 | const child = new AXValueSourceTreeElement(source, this._axNode); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 219 | this.appendChild(child); |
| 220 | } |
| 221 | this.expand(); |
| 222 | } |
Tim van der Lippe | 6d1e03c | 2020-01-22 14:05:58 | [diff] [blame] | 223 | const element = AXNodePropertyTreeElement.createSimpleValueElement(value.type, String(value.value)); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 224 | this.listItemElement.appendChild(element); |
| 225 | } |
| 226 | |
| 227 | /** |
| 228 | * @param {!Protocol.Accessibility.AXRelatedNode} relatedNode |
| 229 | * @param {number} index |
| 230 | */ |
| 231 | appendRelatedNode(relatedNode, index) { |
| 232 | const deferredNode = |
Tim van der Lippe | 8f15c8d | 2020-02-13 14:59:41 | [diff] [blame^] | 233 | new SDK.DOMModel.DeferredDOMNode(this._axNode.accessibilityModel().target(), relatedNode.backendDOMNodeId); |
Tim van der Lippe | 6d1e03c | 2020-01-22 14:05:58 | [diff] [blame] | 234 | const nodeTreeElement = new AXRelatedNodeSourceTreeElement({deferredNode: deferredNode}, relatedNode); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 235 | this.appendChild(nodeTreeElement); |
| 236 | } |
| 237 | |
| 238 | /** |
| 239 | * @param {!Protocol.Accessibility.AXRelatedNode} relatedNode |
| 240 | */ |
| 241 | appendRelatedNodeInline(relatedNode) { |
| 242 | const deferredNode = |
Tim van der Lippe | 8f15c8d | 2020-02-13 14:59:41 | [diff] [blame^] | 243 | new SDK.DOMModel.DeferredDOMNode(this._axNode.accessibilityModel().target(), relatedNode.backendDOMNodeId); |
Tim van der Lippe | 6d1e03c | 2020-01-22 14:05:58 | [diff] [blame] | 244 | const linkedNode = new AXRelatedNodeElement({deferredNode: deferredNode}, relatedNode); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 245 | this.listItemElement.appendChild(linkedNode.render()); |
| 246 | } |
| 247 | |
| 248 | /** |
| 249 | * @param {!Protocol.Accessibility.AXValue} value |
| 250 | */ |
| 251 | appendRelatedNodeListValueElement(value) { |
| 252 | if (value.relatedNodes.length === 1 && !value.value) { |
| 253 | this.appendRelatedNodeInline(value.relatedNodes[0]); |
| 254 | return; |
| 255 | } |
| 256 | |
| 257 | value.relatedNodes.forEach(this.appendRelatedNode, this); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 258 | if (value.relatedNodes.length <= 3) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 259 | this.expand(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 260 | } else { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 261 | this.collapse(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 262 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 263 | } |
Paul Lewis | f16142c | 2019-11-07 15:56:04 | [diff] [blame] | 264 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 265 | |
| 266 | /** @type {!Object<string, string>} */ |
Paul Lewis | f16142c | 2019-11-07 15:56:04 | [diff] [blame] | 267 | export const TypeStyles = { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 268 | attribute: 'ax-value-string', |
| 269 | boolean: 'object-value-boolean', |
| 270 | booleanOrUndefined: 'object-value-boolean', |
| 271 | computedString: 'ax-readable-string', |
| 272 | idref: 'ax-value-string', |
| 273 | idrefList: 'ax-value-string', |
| 274 | integer: 'object-value-number', |
| 275 | internalRole: 'ax-internal-role', |
| 276 | number: 'ax-value-number', |
| 277 | role: 'ax-role', |
| 278 | string: 'ax-value-string', |
| 279 | tristate: 'object-value-boolean', |
| 280 | valueUndefined: 'ax-value-undefined' |
| 281 | }; |
| 282 | |
| 283 | /** @type {!Set.<!Protocol.Accessibility.AXValueType>} */ |
Paul Lewis | f16142c | 2019-11-07 15:56:04 | [diff] [blame] | 284 | export const StringProperties = new Set([ |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 285 | Protocol.Accessibility.AXValueType.String, Protocol.Accessibility.AXValueType.ComputedString, |
| 286 | Protocol.Accessibility.AXValueType.IdrefList, Protocol.Accessibility.AXValueType.Idref |
| 287 | ]); |
| 288 | |
| 289 | /** |
| 290 | * @unrestricted |
| 291 | */ |
Paul Lewis | f16142c | 2019-11-07 15:56:04 | [diff] [blame] | 292 | export class AXNodePropertyTreePropertyElement extends AXNodePropertyTreeElement { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 293 | /** |
| 294 | * @param {!Protocol.Accessibility.AXProperty} property |
Tim van der Lippe | 6d1e03c | 2020-01-22 14:05:58 | [diff] [blame] | 295 | * @param {!AccessibilityNode} axNode |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 296 | */ |
| 297 | constructor(property, axNode) { |
| 298 | super(axNode); |
| 299 | |
| 300 | this._property = property; |
| 301 | this.toggleOnClick = true; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 302 | |
| 303 | this.listItemElement.classList.add('property'); |
| 304 | } |
| 305 | |
| 306 | /** |
| 307 | * @override |
| 308 | */ |
| 309 | onattach() { |
| 310 | this._update(); |
| 311 | } |
| 312 | |
| 313 | _update() { |
| 314 | this.listItemElement.removeChildren(); |
| 315 | |
| 316 | this.appendNameElement(this._property.name); |
| 317 | |
Mathias Bynens | 7d8cd34 | 2019-09-17 13:32:10 | [diff] [blame] | 318 | this.listItemElement.createChild('span', 'separator').textContent = ':\xA0'; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 319 | |
| 320 | this.appendValueElement(this._property.value); |
| 321 | } |
Paul Lewis | f16142c | 2019-11-07 15:56:04 | [diff] [blame] | 322 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 323 | |
| 324 | /** |
| 325 | * @unrestricted |
| 326 | */ |
Paul Lewis | f16142c | 2019-11-07 15:56:04 | [diff] [blame] | 327 | export class AXValueSourceTreeElement extends AXNodePropertyTreeElement { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 328 | /** |
| 329 | * @param {!Protocol.Accessibility.AXValueSource} source |
Tim van der Lippe | 6d1e03c | 2020-01-22 14:05:58 | [diff] [blame] | 330 | * @param {!AccessibilityNode} axNode |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 331 | */ |
| 332 | constructor(source, axNode) { |
| 333 | super(axNode); |
| 334 | this._source = source; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | /** |
| 338 | * @override |
| 339 | */ |
| 340 | onattach() { |
| 341 | this._update(); |
| 342 | } |
| 343 | |
| 344 | /** |
| 345 | * @param {!Protocol.Accessibility.AXRelatedNode} relatedNode |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 346 | * @param {string} idref |
| 347 | */ |
Meredith Lane | 4be4e9a | 2020-02-05 06:07:02 | [diff] [blame] | 348 | appendRelatedNodeWithIdref(relatedNode, idref) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 349 | const deferredNode = |
Tim van der Lippe | 8f15c8d | 2020-02-13 14:59:41 | [diff] [blame^] | 350 | new SDK.DOMModel.DeferredDOMNode(this._axNode.accessibilityModel().target(), relatedNode.backendDOMNodeId); |
Tim van der Lippe | 6d1e03c | 2020-01-22 14:05:58 | [diff] [blame] | 351 | const nodeTreeElement = new AXRelatedNodeSourceTreeElement({deferredNode: deferredNode, idref: idref}, relatedNode); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 352 | this.appendChild(nodeTreeElement); |
| 353 | } |
| 354 | |
| 355 | /** |
| 356 | * @param {!Protocol.Accessibility.AXValue} value |
| 357 | */ |
| 358 | appendIDRefValueElement(value) { |
Meredith Lane | 4be4e9a | 2020-02-05 06:07:02 | [diff] [blame] | 359 | if (value.value === null) { |
| 360 | return; |
| 361 | } |
| 362 | |
| 363 | const relatedNodes = value.relatedNodes || []; |
| 364 | |
| 365 | // Content attribute is empty, but if the relationship was set via the IDL |
| 366 | // then there may be related nodes. |
| 367 | if (value.value === '') { |
| 368 | for (const node of relatedNodes) { |
| 369 | const idref = node.idref || ''; |
| 370 | this.appendRelatedNodeWithIdref(node, idref); |
| 371 | } |
| 372 | return; |
| 373 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 374 | |
| 375 | const idrefs = value.value.trim().split(/\s+/); |
Meredith Lane | 4be4e9a | 2020-02-05 06:07:02 | [diff] [blame] | 376 | for (const idref of idrefs) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 377 | const matchingNode = relatedNodes.find(node => node.idref === idref); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 378 | |
Meredith Lane | 4be4e9a | 2020-02-05 06:07:02 | [diff] [blame] | 379 | // If there is exactly one related node, it is rendered on the same line |
| 380 | // of the label. If there are more, they are each rendered on their own |
| 381 | // line below the label. |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 382 | // TODO(aboxhall): exclamation mark if not idreflist type |
Meredith Lane | 4be4e9a | 2020-02-05 06:07:02 | [diff] [blame] | 383 | if (matchingNode) { |
| 384 | this.appendRelatedNodeWithIdref(matchingNode, idref); |
| 385 | } else if (idrefs.length === 1) { |
| 386 | this.listItemElement.appendChild(new Accessibility.AXRelatedNodeElement({idref: idref}).render()); |
| 387 | } else { |
| 388 | this.appendChild(new Accessibility.AXRelatedNodeSourceTreeElement({idref: idref})); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 389 | } |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | /** |
| 394 | * @param {!Protocol.Accessibility.AXValue} value |
| 395 | * @override |
| 396 | */ |
| 397 | appendRelatedNodeListValueElement(value) { |
| 398 | const relatedNodes = value.relatedNodes; |
| 399 | const numNodes = relatedNodes.length; |
| 400 | |
| 401 | if (value.type === Protocol.Accessibility.AXValueType.IdrefList || |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 402 | value.type === Protocol.Accessibility.AXValueType.Idref) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 403 | this.appendIDRefValueElement(value); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 404 | } else { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 405 | super.appendRelatedNodeListValueElement(value); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 406 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 407 | |
| 408 | |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 409 | if (numNodes <= 3) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 410 | this.expand(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 411 | } else { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 412 | this.collapse(); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 413 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 414 | } |
| 415 | |
| 416 | /** |
| 417 | * @param {!Protocol.Accessibility.AXValueSource} source |
| 418 | */ |
| 419 | appendSourceNameElement(source) { |
| 420 | const nameElement = createElement('span'); |
| 421 | const AXValueSourceType = Protocol.Accessibility.AXValueSourceType; |
| 422 | const type = source.type; |
| 423 | switch (type) { |
| 424 | case AXValueSourceType.Attribute: |
| 425 | case AXValueSourceType.Placeholder: |
| 426 | case AXValueSourceType.RelatedElement: |
| 427 | if (source.nativeSource) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 428 | const nativeSource = source.nativeSource; |
Mandy Chen | ba6de38 | 2019-06-07 21:38:50 | [diff] [blame] | 429 | nameElement.textContent = AXNativeSourceTypes[nativeSource].name; |
| 430 | nameElement.title = AXNativeSourceTypes[nativeSource].description; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 431 | nameElement.classList.add('ax-readable-name'); |
| 432 | break; |
| 433 | } |
| 434 | nameElement.textContent = source.attribute; |
| 435 | nameElement.classList.add('ax-name'); |
| 436 | nameElement.classList.add('monospace'); |
| 437 | break; |
| 438 | default: |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 439 | if (type in AXSourceTypes) { |
Mandy Chen | ba6de38 | 2019-06-07 21:38:50 | [diff] [blame] | 440 | nameElement.textContent = AXSourceTypes[type].name; |
| 441 | nameElement.title = AXSourceTypes[type].description; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 442 | nameElement.classList.add('ax-readable-name'); |
| 443 | } else { |
| 444 | console.warn(type, 'not in AXSourceTypes'); |
Mandy Chen | ba6de38 | 2019-06-07 21:38:50 | [diff] [blame] | 445 | nameElement.textContent = type; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 446 | } |
| 447 | } |
| 448 | this.listItemElement.appendChild(nameElement); |
| 449 | } |
| 450 | |
| 451 | _update() { |
| 452 | this.listItemElement.removeChildren(); |
| 453 | |
| 454 | if (this._source.invalid) { |
Tim van der Lippe | 6d1e03c | 2020-01-22 14:05:58 | [diff] [blame] | 455 | const exclamationMark = AXNodePropertyTreeElement.createExclamationMark(ls`Invalid source.`); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 456 | this.listItemElement.appendChild(exclamationMark); |
| 457 | this.listItemElement.classList.add('ax-value-source-invalid'); |
| 458 | } else if (this._source.superseded) { |
| 459 | this.listItemElement.classList.add('ax-value-source-unused'); |
| 460 | } |
| 461 | |
| 462 | this.appendSourceNameElement(this._source); |
| 463 | |
Mathias Bynens | 7d8cd34 | 2019-09-17 13:32:10 | [diff] [blame] | 464 | this.listItemElement.createChild('span', 'separator').textContent = ':\xA0'; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 465 | |
| 466 | if (this._source.attributeValue) { |
| 467 | this.appendValueElement(this._source.attributeValue); |
Mathias Bynens | 7d8cd34 | 2019-09-17 13:32:10 | [diff] [blame] | 468 | this.listItemElement.createTextChild('\xA0'); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 469 | } else if (this._source.nativeSourceValue) { |
| 470 | this.appendValueElement(this._source.nativeSourceValue); |
Mathias Bynens | 7d8cd34 | 2019-09-17 13:32:10 | [diff] [blame] | 471 | this.listItemElement.createTextChild('\xA0'); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 472 | if (this._source.value) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 473 | this.appendValueElement(this._source.value); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 474 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 475 | } else if (this._source.value) { |
| 476 | this.appendValueElement(this._source.value); |
| 477 | } else { |
Tim van der Lippe | 6d1e03c | 2020-01-22 14:05:58 | [diff] [blame] | 478 | const valueElement = AXNodePropertyTreeElement.createSimpleValueElement( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 479 | Protocol.Accessibility.AXValueType.ValueUndefined, ls`Not specified`); |
| 480 | this.listItemElement.appendChild(valueElement); |
| 481 | this.listItemElement.classList.add('ax-value-source-unused'); |
| 482 | } |
| 483 | |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 484 | if (this._source.value && this._source.superseded) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 485 | this.listItemElement.classList.add('ax-value-source-superseded'); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 486 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 487 | } |
Paul Lewis | f16142c | 2019-11-07 15:56:04 | [diff] [blame] | 488 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 489 | |
| 490 | /** |
| 491 | * @unrestricted |
| 492 | */ |
Tim van der Lippe | 8f15c8d | 2020-02-13 14:59:41 | [diff] [blame^] | 493 | export class AXRelatedNodeSourceTreeElement extends UI.TreeOutline.TreeElement { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 494 | /** |
Tim van der Lippe | 8f15c8d | 2020-02-13 14:59:41 | [diff] [blame^] | 495 | * @param {{deferredNode: (!SDK.DOMModel.DeferredDOMNode|undefined), idref: (string|undefined)}} node |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 496 | * @param {!Protocol.Accessibility.AXRelatedNode=} value |
| 497 | */ |
| 498 | constructor(node, value) { |
| 499 | super(''); |
| 500 | |
| 501 | this._value = value; |
Tim van der Lippe | 6d1e03c | 2020-01-22 14:05:58 | [diff] [blame] | 502 | this._axRelatedNodeElement = new AXRelatedNodeElement(node, value); |
Rob Paveza | 84d4144 | 2019-10-10 23:01:09 | [diff] [blame] | 503 | this.selectable = true; |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 504 | } |
| 505 | |
| 506 | /** |
| 507 | * @override |
| 508 | */ |
| 509 | onattach() { |
| 510 | this.listItemElement.appendChild(this._axRelatedNodeElement.render()); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 511 | if (!this._value) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 512 | return; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 513 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 514 | |
| 515 | if (this._value.text) { |
Tim van der Lippe | 6d1e03c | 2020-01-22 14:05:58 | [diff] [blame] | 516 | this.listItemElement.appendChild(AXNodePropertyTreeElement.createSimpleValueElement( |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 517 | Protocol.Accessibility.AXValueType.ComputedString, this._value.text)); |
| 518 | } |
| 519 | } |
Rob Paveza | 84d4144 | 2019-10-10 23:01:09 | [diff] [blame] | 520 | |
| 521 | /** |
| 522 | * @override |
| 523 | */ |
| 524 | onenter() { |
| 525 | this._axRelatedNodeElement.revealNode(); |
| 526 | return true; |
| 527 | } |
Paul Lewis | f16142c | 2019-11-07 15:56:04 | [diff] [blame] | 528 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 529 | |
| 530 | /** |
| 531 | * @unrestricted |
| 532 | */ |
Paul Lewis | f16142c | 2019-11-07 15:56:04 | [diff] [blame] | 533 | export class AXRelatedNodeElement { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 534 | /** |
Tim van der Lippe | 8f15c8d | 2020-02-13 14:59:41 | [diff] [blame^] | 535 | * @param {{deferredNode: (!SDK.DOMModel.DeferredDOMNode|undefined), idref: (string|undefined)}} node |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 536 | * @param {!Protocol.Accessibility.AXRelatedNode=} value |
| 537 | */ |
| 538 | constructor(node, value) { |
| 539 | this._deferredNode = node.deferredNode; |
| 540 | this._idref = node.idref; |
| 541 | this._value = value; |
| 542 | } |
| 543 | |
| 544 | /** |
| 545 | * @return {!Element} |
| 546 | */ |
| 547 | render() { |
| 548 | const element = createElement('span'); |
| 549 | let valueElement; |
| 550 | |
| 551 | if (this._deferredNode) { |
| 552 | valueElement = createElement('span'); |
| 553 | element.appendChild(valueElement); |
Alice Boxhall | 6ac4343 | 2018-11-22 08:24:18 | [diff] [blame] | 554 | this._deferredNode.resolvePromise().then(node => { |
Tim van der Lippe | 8f15c8d | 2020-02-13 14:59:41 | [diff] [blame^] | 555 | Common.Linkifier.Linkifier.linkify(node, {preventKeyboardFocus: true}) |
Jeff Fisher | 3f5f19c | 2019-08-28 19:10:02 | [diff] [blame] | 556 | .then(linkfied => valueElement.appendChild(linkfied)); |
Alice Boxhall | 6ac4343 | 2018-11-22 08:24:18 | [diff] [blame] | 557 | }); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 558 | } else if (this._idref) { |
| 559 | element.classList.add('invalid'); |
Tim van der Lippe | 6d1e03c | 2020-01-22 14:05:58 | [diff] [blame] | 560 | valueElement = AXNodePropertyTreeElement.createExclamationMark(ls`No node with this ID.`); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 561 | valueElement.createTextChild(this._idref); |
| 562 | element.appendChild(valueElement); |
| 563 | } |
| 564 | |
| 565 | return element; |
| 566 | } |
Rob Paveza | 84d4144 | 2019-10-10 23:01:09 | [diff] [blame] | 567 | |
| 568 | /** |
| 569 | * Attempts to cause the node referred to by the related node to be selected in the tree. |
| 570 | */ |
| 571 | revealNode() { |
| 572 | this._deferredNode.resolvePromise().then(node => Common.Revealer.reveal(node)); |
| 573 | } |
Paul Lewis | f16142c | 2019-11-07 15:56:04 | [diff] [blame] | 574 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 575 | |
| 576 | /** |
| 577 | * @unrestricted |
| 578 | */ |
Paul Lewis | f16142c | 2019-11-07 15:56:04 | [diff] [blame] | 579 | export class AXNodeIgnoredReasonTreeElement extends AXNodePropertyTreeElement { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 580 | /** |
| 581 | * @param {!Protocol.Accessibility.AXProperty} property |
Tim van der Lippe | 6d1e03c | 2020-01-22 14:05:58 | [diff] [blame] | 582 | * @param {!AccessibilityNode} axNode |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 583 | */ |
| 584 | constructor(property, axNode) { |
| 585 | super(axNode); |
| 586 | this._property = property; |
| 587 | this._axNode = axNode; |
| 588 | this.toggleOnClick = true; |
| 589 | this.selectable = false; |
| 590 | } |
| 591 | |
| 592 | /** |
| 593 | * @param {?string} reason |
Tim van der Lippe | 6d1e03c | 2020-01-22 14:05:58 | [diff] [blame] | 594 | * @param {?AccessibilityNode} axNode |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 595 | * @return {?Element} |
| 596 | */ |
| 597 | static createReasonElement(reason, axNode) { |
| 598 | let reasonElement = null; |
| 599 | switch (reason) { |
| 600 | case 'activeModalDialog': |
Tim van der Lippe | 8f15c8d | 2020-02-13 14:59:41 | [diff] [blame^] | 601 | reasonElement = UI.UIUtils.formatLocalized('Element is hidden by active modal dialog:\xA0', []); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 602 | break; |
| 603 | case 'ancestorIsLeafNode': |
Tim van der Lippe | 8f15c8d | 2020-02-13 14:59:41 | [diff] [blame^] | 604 | reasonElement = UI.UIUtils.formatLocalized('Ancestor\'s children are all presentational:\xA0', []); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 605 | break; |
| 606 | case 'ariaHiddenElement': { |
| 607 | const ariaHiddenSpan = createElement('span', 'source-code').textContent = 'aria-hidden'; |
Tim van der Lippe | 8f15c8d | 2020-02-13 14:59:41 | [diff] [blame^] | 608 | reasonElement = UI.UIUtils.formatLocalized('Element is %s.', [ariaHiddenSpan]); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 609 | break; |
| 610 | } |
| 611 | case 'ariaHiddenSubtree': { |
| 612 | const ariaHiddenSpan = createElement('span', 'source-code').textContent = 'aria-hidden'; |
| 613 | const trueSpan = createElement('span', 'source-code').textContent = 'true'; |
Tim van der Lippe | 8f15c8d | 2020-02-13 14:59:41 | [diff] [blame^] | 614 | reasonElement = UI.UIUtils.formatLocalized('%s is %s on ancestor:\xA0', [ariaHiddenSpan, trueSpan]); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 615 | break; |
| 616 | } |
| 617 | case 'emptyAlt': |
Tim van der Lippe | 8f15c8d | 2020-02-13 14:59:41 | [diff] [blame^] | 618 | reasonElement = UI.UIUtils.formatLocalized('Element has empty alt text.', []); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 619 | break; |
| 620 | case 'emptyText': |
Tim van der Lippe | 8f15c8d | 2020-02-13 14:59:41 | [diff] [blame^] | 621 | reasonElement = UI.UIUtils.formatLocalized('No text content.', []); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 622 | break; |
| 623 | case 'inertElement': |
Tim van der Lippe | 8f15c8d | 2020-02-13 14:59:41 | [diff] [blame^] | 624 | reasonElement = UI.UIUtils.formatLocalized('Element is inert.', []); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 625 | break; |
| 626 | case 'inertSubtree': |
Tim van der Lippe | 8f15c8d | 2020-02-13 14:59:41 | [diff] [blame^] | 627 | reasonElement = UI.UIUtils.formatLocalized('Element is in an inert subtree from\xA0', []); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 628 | break; |
| 629 | case 'inheritsPresentation': |
Tim van der Lippe | 8f15c8d | 2020-02-13 14:59:41 | [diff] [blame^] | 630 | reasonElement = UI.UIUtils.formatLocalized('Element inherits presentational role from\xA0', []); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 631 | break; |
| 632 | case 'labelContainer': |
Tim van der Lippe | 8f15c8d | 2020-02-13 14:59:41 | [diff] [blame^] | 633 | reasonElement = UI.UIUtils.formatLocalized('Part of label element:\xA0', []); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 634 | break; |
| 635 | case 'labelFor': |
Tim van der Lippe | 8f15c8d | 2020-02-13 14:59:41 | [diff] [blame^] | 636 | reasonElement = UI.UIUtils.formatLocalized('Label for\xA0', []); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 637 | break; |
| 638 | case 'notRendered': |
Tim van der Lippe | 8f15c8d | 2020-02-13 14:59:41 | [diff] [blame^] | 639 | reasonElement = UI.UIUtils.formatLocalized('Element is not rendered.', []); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 640 | break; |
| 641 | case 'notVisible': |
Tim van der Lippe | 8f15c8d | 2020-02-13 14:59:41 | [diff] [blame^] | 642 | reasonElement = UI.UIUtils.formatLocalized('Element is not visible.', []); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 643 | break; |
| 644 | case 'presentationalRole': { |
| 645 | const rolePresentationSpan = createElement('span', 'source-code').textContent = 'role=' + axNode.role().value; |
Tim van der Lippe | 8f15c8d | 2020-02-13 14:59:41 | [diff] [blame^] | 646 | reasonElement = UI.UIUtils.formatLocalized('Element has %s.', [rolePresentationSpan]); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 647 | break; |
| 648 | } |
| 649 | case 'probablyPresentational': |
Tim van der Lippe | 8f15c8d | 2020-02-13 14:59:41 | [diff] [blame^] | 650 | reasonElement = UI.UIUtils.formatLocalized('Element is presentational.', []); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 651 | break; |
| 652 | case 'staticTextUsedAsNameFor': |
Tim van der Lippe | 8f15c8d | 2020-02-13 14:59:41 | [diff] [blame^] | 653 | reasonElement = UI.UIUtils.formatLocalized('Static text node is used as name for\xA0', []); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 654 | break; |
| 655 | case 'uninteresting': |
Tim van der Lippe | 8f15c8d | 2020-02-13 14:59:41 | [diff] [blame^] | 656 | reasonElement = UI.UIUtils.formatLocalized('Element not interesting for accessibility.', []); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 657 | break; |
| 658 | } |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 659 | if (reasonElement) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 660 | reasonElement.classList.add('ax-reason'); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 661 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 662 | return reasonElement; |
| 663 | } |
| 664 | |
| 665 | /** |
| 666 | * @override |
| 667 | */ |
| 668 | onattach() { |
| 669 | this.listItemElement.removeChildren(); |
| 670 | |
Tim van der Lippe | 6d1e03c | 2020-01-22 14:05:58 | [diff] [blame] | 671 | this._reasonElement = AXNodeIgnoredReasonTreeElement.createReasonElement(this._property.name, this._axNode); |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 672 | this.listItemElement.appendChild(this._reasonElement); |
| 673 | |
| 674 | const value = this._property.value; |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 675 | if (value.type === Protocol.Accessibility.AXValueType.Idref) { |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 676 | this.appendRelatedNodeListValueElement(value); |
Tim van der Lippe | 1d6e57a | 2019-09-30 11:55:34 | [diff] [blame] | 677 | } |
Blink Reformat | 4c46d09 | 2018-04-07 15:32:37 | [diff] [blame] | 678 | } |
Paul Lewis | f16142c | 2019-11-07 15:56:04 | [diff] [blame] | 679 | } |