summaryrefstree
path: root/usr/bin/Ve5/resources/inspector/accessibility_module.js
blob: 66e57bff919eed49dd17a1abb2db8a872c87dcfd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
WebInspector.AccessibilityModel=function(target)
{WebInspector.SDKModel.call(this,WebInspector.AccessibilityModel,target);this._agent=target.accessibilityAgent();};WebInspector.AccessibilityModel.prototype={getAXNode:function(nodeId,userCallback)
{var wrappedCallback=InspectorBackend.wrapClientCallback(userCallback,"AccessibilityAgent.getAXNode(): ");this._agent.getAXNode(nodeId,wrappedCallback);},__proto__:WebInspector.SDKModel.prototype}
WebInspector.AccessibilityModel._symbol=Symbol("AccessibilityModel");WebInspector.AccessibilityModel.fromTarget=function(target)
{if(!target[WebInspector.AccessibilityModel._symbol])
target[WebInspector.AccessibilityModel._symbol]=new WebInspector.AccessibilityModel(target);return target[WebInspector.AccessibilityModel._symbol];};WebInspector.AccessibilitySidebarView=function()
{WebInspector.ThrottledWidget.call(this);this._computedTextSubPane=null;this._axNodeSubPane=null;this._node=null;this._sidebarPaneStack=null;WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode,this._pullNode,this);this._pullNode();}
WebInspector.AccessibilitySidebarView.prototype={node:function()
{return this._node;},doUpdate:function(finishCallback)
{function accessibilityNodeCallback(accessibilityNode)
{if(this._computedTextSubPane)
this._computedTextSubPane.setAXNode(accessibilityNode);if(this._axNodeSubPane)
this._axNodeSubPane.setAXNode(accessibilityNode);finishCallback();}
var node=this.node();WebInspector.AccessibilityModel.fromTarget(node.target()).getAXNode(node.id,accessibilityNodeCallback.bind(this));},wasShown:function()
{WebInspector.ThrottledWidget.prototype.wasShown.call(this);if(!this._sidebarPaneStack){this._computedTextSubPane=new WebInspector.AXComputedTextSubPane();this._computedTextSubPane.setNode(this.node());this._computedTextSubPane.show(this.element);this._computedTextSubPane.expand();this._axNodeSubPane=new WebInspector.AXNodeSubPane();this._axNodeSubPane.setNode(this.node());this._axNodeSubPane.show(this.element);this._axNodeSubPane.expand();this._sidebarPaneStack=new WebInspector.SidebarPaneStack();this._sidebarPaneStack.element.classList.add("flex-auto");this._sidebarPaneStack.show(this.element);this._sidebarPaneStack.addPane(this._computedTextSubPane);this._sidebarPaneStack.addPane(this._axNodeSubPane);}
WebInspector.targetManager.addModelListener(WebInspector.DOMModel,WebInspector.DOMModel.Events.AttrModified,this._onAttrChange,this);WebInspector.targetManager.addModelListener(WebInspector.DOMModel,WebInspector.DOMModel.Events.AttrRemoved,this._onAttrChange,this);WebInspector.targetManager.addModelListener(WebInspector.DOMModel,WebInspector.DOMModel.Events.CharacterDataModified,this._onNodeChange,this);WebInspector.targetManager.addModelListener(WebInspector.DOMModel,WebInspector.DOMModel.Events.ChildNodeCountUpdated,this._onNodeChange,this);},willHide:function()
{WebInspector.targetManager.removeModelListener(WebInspector.DOMModel,WebInspector.DOMModel.Events.AttrModified,this._onAttrChange,this);WebInspector.targetManager.removeModelListener(WebInspector.DOMModel,WebInspector.DOMModel.Events.AttrRemoved,this._onAttrChange,this);WebInspector.targetManager.removeModelListener(WebInspector.DOMModel,WebInspector.DOMModel.Events.CharacterDataModified,this._onNodeChange,this);WebInspector.targetManager.removeModelListener(WebInspector.DOMModel,WebInspector.DOMModel.Events.ChildNodeCountUpdated,this._onNodeChange,this);},_pullNode:function()
{this._node=WebInspector.context.flavor(WebInspector.DOMNode);if(this._computedTextSubPane)
this._computedTextSubPane.setNode(this._node);if(this._axNodeSubPane)
this._axNodeSubPane.setNode(this._node);this.update();},_onAttrChange:function(event)
{if(!this.node())
return;var node=event.data.node;if(this.node()!==node)
return;this.update();},_onNodeChange:function(event)
{if(!this.node())
return;var node=event.data;if(this.node()!==node)
return;this.update();},__proto__:WebInspector.ThrottledWidget.prototype};WebInspector.AccessibilitySubPane=function(name)
{WebInspector.SidebarPane.call(this,name);this._axNode=null;this.registerRequiredCSS("accessibility/accessibilityNode.css");}
WebInspector.AccessibilitySubPane.prototype={setAXNode:function(axNode)
{},node:function()
{return this._node;},setNode:function(node)
{this._node=node;},createInfo:function(textContent,className)
{var classNameOrDefault=className||"info";var info=createElementWithClass("div",classNameOrDefault);info.textContent=textContent;this.element.appendChild(info);return info;},createTreeOutline:function(className)
{var treeOutline=new TreeOutlineInShadow(className);treeOutline.registerRequiredCSS("accessibility/accessibilityNode.css");treeOutline.registerRequiredCSS("components/objectValue.css");treeOutline.element.classList.add("hidden");this.element.appendChild(treeOutline.element);return treeOutline;},__proto__:WebInspector.SidebarPane.prototype}
WebInspector.AXComputedTextSubPane=function()
{WebInspector.AccessibilitySubPane.call(this,WebInspector.UIString("Computed Text"));this._computedTextElement=this.element.createChild("div","ax-computed-text hidden");this._noTextInfo=this.createInfo(WebInspector.UIString("Node has no text alternative."));this._treeOutline=this.createTreeOutline();};WebInspector.AXComputedTextSubPane.prototype={setAXNode:function(axNode)
{if(this._axNode===axNode)
return;this._axNode=axNode;var treeOutline=this._treeOutline;treeOutline.removeChildren();var target=this.node().target();if(!axNode||axNode.ignored){this._computedTextElement.classList.add("hidden");treeOutline.element.classList.add("hidden");this._noTextInfo.classList.remove("hidden");return;}
this._computedTextElement.removeChildren();this._computedTextElement.classList.toggle("hidden",!axNode.name||!axNode.name.value);if(axNode.name&&axNode.name.value)
this._computedTextElement.createChild("div").textContent=axNode.name.value;var foundProperty=false;function addProperty(property)
{foundProperty=true;treeOutline.appendChild(new WebInspector.AXNodePropertyTreeElement(property,target));}
if("value"in axNode&&axNode.value.type==="string")
addProperty(({name:"value",value:axNode.value}));var propertiesArray=(axNode.properties);for(var property of propertiesArray){if(property.name==AccessibilityAgent.AXWidgetAttributes.Valuetext){addProperty(property);break;}}
treeOutline.element.classList.toggle("hidden",!foundProperty)
this._noTextInfo.classList.toggle("hidden",!treeOutline.element.classList.contains("hidden")||!this._computedTextElement.classList.contains("hidden"));},__proto__:WebInspector.AccessibilitySubPane.prototype};WebInspector.AXNodeSubPane=function()
{WebInspector.AccessibilitySubPane.call(this,WebInspector.UIString("Accessibility Node"));this._noNodeInfo=this.createInfo(WebInspector.UIString("No accessibility node"));this._ignoredInfo=this.createInfo(WebInspector.UIString("Accessibility node not exposed"),"ax-ignored-info hidden");this._treeOutline=this.createTreeOutline();this._ignoredReasonsTree=this.createTreeOutline();};WebInspector.AXNodeSubPane.prototype={setAXNode:function(axNode)
{if(this._axNode===axNode)
return;this._axNode=axNode;var treeOutline=this._treeOutline;treeOutline.removeChildren();var ignoredReasons=this._ignoredReasonsTree;ignoredReasons.removeChildren();var target=this.node().target();if(!axNode){treeOutline.element.classList.add("hidden");this._ignoredInfo.classList.add("hidden");ignoredReasons.element.classList.add("hidden");this._noNodeInfo.classList.remove("hidden");this.element.classList.add("ax-ignored-node-pane");return;}else if(axNode.ignored){this._noNodeInfo.classList.add("hidden");treeOutline.element.classList.add("hidden");this.element.classList.add("ax-ignored-node-pane");this._ignoredInfo.classList.remove("hidden");ignoredReasons.element.classList.remove("hidden");function addIgnoredReason(property)
{ignoredReasons.appendChild(new WebInspector.AXNodeIgnoredReasonTreeElement(property,axNode,target));}
var ignoredReasonsArray=(axNode.ignoredReasons);for(var reason of ignoredReasonsArray)
addIgnoredReason(reason);if(!ignoredReasons.firstChild())
ignoredReasons.element.classList.add("hidden");return;}
this.element.classList.remove("ax-ignored-node-pane");this._ignoredInfo.classList.add("hidden");ignoredReasons.element.classList.add("hidden");this._noNodeInfo.classList.add("hidden");treeOutline.element.classList.remove("hidden");function addProperty(property)
{treeOutline.appendChild(new WebInspector.AXNodePropertyTreeElement(property,target));}
for(var propertyName of["name","description","help","value"]){if(propertyName in axNode){var defaultProperty=({name:propertyName,value:axNode[propertyName]});addProperty(defaultProperty);}}
var roleProperty=({name:"role",value:axNode.role});addProperty(roleProperty);var propertyMap={};var propertiesArray=(axNode.properties);for(var property of propertiesArray)
propertyMap[property.name]=property;for(var propertySet of[AccessibilityAgent.AXWidgetAttributes,AccessibilityAgent.AXWidgetStates,AccessibilityAgent.AXGlobalStates,AccessibilityAgent.AXLiveRegionAttributes,AccessibilityAgent.AXRelationshipAttributes]){for(var propertyKey in propertySet){var property=propertySet[propertyKey];if(property in propertyMap)
addProperty(propertyMap[property]);}}},__proto__:WebInspector.AccessibilitySubPane.prototype};WebInspector.AXNodePropertyTreeElement=function(property,target)
{this._property=property;this._target=target;TreeElement.call(this,"");this.toggleOnClick=true;this.selectable=false;}
WebInspector.AXNodePropertyTreeElement.prototype={onattach:function()
{this._update();},_update:function()
{this._nameElement=WebInspector.AXNodePropertyTreeElement.createNameElement(this._property.name);var value=this._property.value;if(value.type==="idref"){this._valueElement=WebInspector.AXNodePropertyTreeElement.createRelationshipValueElement(value,this._target);}else if(value.type==="idrefList"){var relatedNodes=value.relatedNodeArrayValue;var numNodes=relatedNodes.length;var description="("+numNodes+(numNodes==1?" node":" nodes")+")";value.value=description;for(var i=0;i<relatedNodes.length;i++){var backendId=relatedNodes[i].backendNodeId;var deferredNode=new WebInspector.DeferredDOMNode(this._target,relatedNodes[i].backendNodeId);var child=new WebInspector.AXRelatedNodeTreeElement(deferredNode);this.appendChild(child);}
this._valueElement=WebInspector.AXNodePropertyTreeElement.createValueElement(value,this.listItemElement);if(relatedNodes.length<=3)
this.expand();else
this.collapse();}else{this._valueElement=WebInspector.AXNodePropertyTreeElement.createValueElement(value,this.listItemElement);}
var separatorElement=createElementWithClass("span","separator");separatorElement.textContent=": ";this.listItemElement.removeChildren();this.listItemElement.appendChildren(this._nameElement,separatorElement,this._valueElement);},__proto__:TreeElement.prototype}
WebInspector.AXNodePropertyTreeElement.populateWithNode=function(treeNode,axNode,target)
{}
WebInspector.AXNodePropertyTreeElement.createNameElement=function(name)
{var nameElement=createElement("span");var AXAttributes=WebInspector.AccessibilityStrings.AXAttributes;if(name in AXAttributes){nameElement.textContent=WebInspector.UIString(AXAttributes[name].name);nameElement.title=WebInspector.UIString(AXAttributes[name].description);nameElement.classList.add("ax-readable-name");}else{nameElement.textContent=name;nameElement.classList.add("ax-name");}
return nameElement;}
WebInspector.AXNodePropertyTreeElement.createRelationshipValueElement=function(value,target)
{var deferredNode=new WebInspector.DeferredDOMNode(target,value.relatedNodeValue.backendNodeId);var valueElement=createElement("span");function onNodeResolved(node)
{valueElement.appendChild(WebInspector.DOMPresentationUtils.linkifyNodeReference(node));}
deferredNode.resolve(onNodeResolved);return valueElement;}
WebInspector.AXNodePropertyTreeElement.createValueElement=function(value,parentElement)
{var valueElement=createElementWithClass("span","monospace");var type=value.type;var prefix;var valueText;var suffix;if(type==="string"){prefix="\"";valueText=value.value.replace(/\n/g,"\u21B5");suffix="\"";valueElement._originalTextContent="\""+value.value+"\"";}else{valueText=String(value.value);}
if(type in WebInspector.AXNodePropertyTreeElement.TypeStyles)
valueElement.classList.add(WebInspector.AXNodePropertyTreeElement.TypeStyles[type]);valueElement.setTextContentTruncatedIfNeeded(valueText||"");if(prefix)
valueElement.insertBefore(createTextNode(prefix),valueElement.firstChild);if(suffix)
valueElement.createTextChild(suffix);valueElement.title=String(value.value)||"";return valueElement;}
WebInspector.AXRelatedNodeTreeElement=function(deferredNode)
{this._deferredNode=deferredNode;TreeElement.call(this,"");};WebInspector.AXRelatedNodeTreeElement.prototype={onattach:function()
{this._update();},_update:function()
{var valueElement=createElement("div");this.listItemElement.appendChild(valueElement);function onNodeResolved(node)
{valueElement.appendChild(WebInspector.DOMPresentationUtils.linkifyNodeReference(node));}
this._deferredNode.resolve(onNodeResolved);},__proto__:TreeElement.prototype};WebInspector.AXNodePropertyTreeElement.TypeStyles={boolean:"object-value-boolean",booleanOrUndefined:"object-value-boolean",tristate:"object-value-boolean",number:"object-value-number",integer:"object-value-number",string:"object-value-string",role:"ax-role",internalRole:"ax-internal-role"};WebInspector.AXNodeIgnoredReasonTreeElement=function(property,axNode,target)
{this._property=property;this._axNode=axNode;this._target=target;TreeElement.call(this,"");this.toggleOnClick=true;this.selectable=false;}
WebInspector.AXNodeIgnoredReasonTreeElement.prototype={onattach:function()
{this.listItemElement.removeChildren();this._reasonElement=WebInspector.AXNodeIgnoredReasonTreeElement.createReasonElement(this._property.name,this._axNode);this.listItemElement.appendChild(this._reasonElement);var value=this._property.value;if(value.type==="idref"){this._valueElement=WebInspector.AXNodePropertyTreeElement.createRelationshipValueElement(value,this._target);this.listItemElement.appendChild(this._valueElement);}},__proto__:TreeElement.prototype};WebInspector.AXNodeIgnoredReasonTreeElement.createReasonElement=function(reason,axNode)
{var reasonElement=null;switch(reason){case"activeModalDialog":reasonElement=WebInspector.formatLocalized("Element is hidden by active modal dialog: ",[],"");break;case"ancestorDisallowsChild":reasonElement=WebInspector.formatLocalized("Element is not permitted as child of ",[],"");break;case"ancestorIsLeafNode":reasonElement=WebInspector.formatLocalized("Ancestor's children are all presentational: ",[],"");break;case"ariaHidden":var ariaHiddenSpan=createElement("span","source-code").textContent="aria-hidden";reasonElement=WebInspector.formatLocalized("Element is %s.",[ariaHiddenSpan],"");break;case"ariaHiddenRoot":var ariaHiddenSpan=createElement("span","source-code").textContent="aria-hidden";var trueSpan=createElement("span","source-code").textContent="true";reasonElement=WebInspector.formatLocalized("%s is %s on ancestor: ",[ariaHiddenSpan,trueSpan],"");break;case"emptyAlt":reasonElement=WebInspector.formatLocalized("Element has empty alt text.",[],"");break;case"emptyText":reasonElement=WebInspector.formatLocalized("No text content.",[],"");break;case"inert":reasonElement=WebInspector.formatLocalized("Element is inert.",[],"");break;case"inheritsPresentation":reasonElement=WebInspector.formatLocalized("Element inherits presentational role from ",[],"");break;case"labelContainer":reasonElement=WebInspector.formatLocalized("Part of label element: ",[],"");break;case"labelFor":reasonElement=WebInspector.formatLocalized("Label for ",[],"");break;case"notRendered":reasonElement=WebInspector.formatLocalized("Element is not rendered.",[],"");break;case"notVisible":reasonElement=WebInspector.formatLocalized("Element is not visible.",[],"");break;case"presentationalRole":var rolePresentationSpan=createElement("span","source-code").textContent="role="+axNode.role.value;reasonElement=WebInspector.formatLocalized("Element has %s.",[rolePresentationSpan],"");break;case"probablyPresentational":reasonElement=WebInspector.formatLocalized("Element is presentational.",[],"");break;case"staticTextUsedAsNameFor":reasonElement=WebInspector.formatLocalized("Static text node is used as name for ",[],"");break;case"uninteresting":reasonElement=WebInspector.formatLocalized("Element not interesting for accessibility.",[],"")
break;}
if(reasonElement)
reasonElement.classList.add("ax-reason");return reasonElement;};WebInspector.AccessibilityStrings={};WebInspector.AccessibilityStrings.AXAttributes={"disabled":{name:"Disabled",description:"If true, this element currently cannot be interacted with.",group:"AXGlobalStates"},"invalid":{name:"Invalid user entry",description:"If true, this element's user-entered value does not conform to validation requirement.",group:"AXGlobalStates"},"live":{name:"Live region",description:"Whether and what priority of live updates may be expected for this element.",group:"AXLiveRegionAttributes"},"atomic":{name:"Atomic (live regions)",description:"If this element may receive live updates, whether the entire live region should be presented to the user on changes, or only changed nodes.",group:"AXLiveRegionAttributes"},"relevant":{name:"Relevant (live regions)",description:"If this element may receive live updates, what type of updates should trigger a notification.",group:"AXLiveRegionAttributes"},"busy":{name:"Busy (live regions)",description:"Whether this element or its subtree are currently being updated (and thus may be in an inconsistent state).",group:"AXLiveRegionAttributes"},"root":{name:"Live region root",description:"If this element may receive live updates, the root element of the containing live region.",group:"AXLiveRegionAttributes"},"autocomplete":{name:"Has autocomplete",description:"Whether and what type of autocomplete suggestions are currently provided by this element.",group:"AXWidgetAttributes"},"haspopup":{name:"Has popup",description:"Whether this element has caused some kind of pop-up (such as a menu) to appear.",group:"AXWidgetAttributes"},"level":{name:"Level",description:"The hierarchical level of this element.",group:"AXWidgetAttributes"},"multiselectable":{name:"Multi-selectable",description:"Whether a user may select more than one option from this widget.",group:"AXWidgetAttributes"},"orientation":{name:"Orientation",description:"Whether this linear element's orientation is horizontal or vertical.",group:"AXWidgetAttributes"},"multiline":{name:"Multi-line",description:"Whether this textbox may have more than one line.",group:"AXWidgetAttributes"},"readonly":{name:"Read-only",description:"If true, this element may be interacted with, but its value cannot be changed.",group:"AXWidgetAttributes"},"required":{name:"Required",description:"Whether this element is a required field in a form.",group:"AXWidgetAttributes"},"valuemin":{name:"Minimum value",description:"For a range widget, the minimum allowed value.",group:"AXWidgetAttributes"},"valuemax":{name:"Maximum value",description:"For a range widget, the maximum allowed value.",group:"AXWidgetAttributes"},"valuetext":{name:"Value description",description:"A human-readable version of the value of a range widget (where necessary).",group:"AXWidgetAttributes"},"checked":{name:"Checked",description:"Whether this checkbox, radio button or tree item is checked, unchecked, or mixed (e.g. has both checked and un-checked children).",group:"AXWidgetStates"},"expanded":{name:"Expanded",description:"Whether this element, or another grouping element it controls, is expanded.",group:"AXWidgetStates"},"pressed":{name:"Pressed",description:"Whether this toggle button is currently in a pressed state.",group:"AXWidgetStates"},"selected":{name:"Selected",description:"Whether the option represented by this element is currently selected.",group:"AXWidgetStates"},"activedescendant":{name:"Active descendant",description:"The descendant of this element which is active; i.e. the element to which focus should be delegated.",group:"AXRelationshipAttributes"},"flowto":{name:"Flows to",description:"Element to which the user may choose to navigate after this one, instead of the next element in the DOM order.",group:"AXRelationshipAttributes"},"controls":{name:"Controls",description:"Element or elements whose content or presence is/are controlled by this widget.",group:"AXRelationshipAttributes"},"describedby":{name:"Described by",description:"Element or elements which form the description of this element.",group:"AXRelationshipAttributes"},"labelledby":{name:"Labeled by",description:"Element or elements which may form the name of this element.",group:"AXRelationshipAttributes"},"owns":{name:"Owns",description:"Element or elements which should be considered descendants of this element, despite not being descendants in the DOM.",group:"AXRelationshipAttributes"},"name":{name:"Name",description:"The computed name of this element.",group:"Default"},"role":{name:"Role",description:"Indicates the purpose of this element, such as a user interface idiom for a widget, or structural role within a document.",group:"Default"},"value":{name:"Value",description:"The value of this element; this may be user-provided or developer-provided, depending on the element.",group:"Default"},"help":{name:"Help",descrption:"The computed help text for this element.",group:"Default"}};;Runtime.cachedResources["accessibility/accessibilityNode.css"]="/*\n * Copyright 2015 The Chromium Authors. All rights reserved.\n * Use of this source code is governed by a BSD-style license that can be\n * found in the LICENSE file.\n */\n\n.ax-computed-text {\n    padding: 3px 5px 0;\n    background-image: url(Images/speech.png);\n    background-repeat: no-repeat;\n    background-position: 16px center;\n    padding: 4px 4px 0 4px;\n    padding-left: 36px;\n    min-height: 18px;\n}\n\n.ax-computed-text div {\n    display: inline-block;\n    padding: 2px;\n    width: 100%;\n    text-overflow: ellipsis;\n    white-space: nowrap;\n    overflow: hidden;\n    width: 100%;\n}\n\ndiv.ax-text-alternatives {\n    margin-bottom: 3px;\n    border-bottom: 1px solid #BFBFBF;\n}\n\n.ax-name {\n    color: rgb(136, 19, 145);\n    flex-shrink: 0;\n}\n\n.ax-readable-name {\n    flex-shrink: 0;\n}\n\nspan.ax-role {\n    font-weight: bold;\n}\n\nspan.ax-internal-role {\n    font-style: italic;\n}\n\n.ax-ignored-info {\n    padding: 6px;\n}\n\n.ax-ignored-node-pane {\n    background-color: hsl(0, 0%, 96%);\n}\n\n.tree-outline li {\n    padding-top: 5px;\n}\n\n/*# sourceURL=accessibility/accessibilityNode.css */";