| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 /** | 4 /** |
| 5 * @unrestricted | 5 * @unrestricted |
| 6 */ | 6 */ |
| 7 WebInspector.AccessibilitySidebarView = class extends WebInspector.ThrottledWidg
et { | 7 Accessibility.AccessibilitySidebarView = class extends UI.ThrottledWidget { |
| 8 constructor() { | 8 constructor() { |
| 9 super(); | 9 super(); |
| 10 this._node = null; | 10 this._node = null; |
| 11 this._axNode = null; | 11 this._axNode = null; |
| 12 this._sidebarPaneStack = WebInspector.viewManager.createStackLocation(); | 12 this._sidebarPaneStack = UI.viewManager.createStackLocation(); |
| 13 this._treeSubPane = new WebInspector.AXTreePane(); | 13 this._treeSubPane = new Accessibility.AXTreePane(); |
| 14 this._sidebarPaneStack.showView(this._treeSubPane); | 14 this._sidebarPaneStack.showView(this._treeSubPane); |
| 15 this._ariaSubPane = new WebInspector.ARIAAttributesPane(); | 15 this._ariaSubPane = new Accessibility.ARIAAttributesPane(); |
| 16 this._sidebarPaneStack.showView(this._ariaSubPane); | 16 this._sidebarPaneStack.showView(this._ariaSubPane); |
| 17 this._axNodeSubPane = new WebInspector.AXNodeSubPane(); | 17 this._axNodeSubPane = new Accessibility.AXNodeSubPane(); |
| 18 this._sidebarPaneStack.showView(this._axNodeSubPane); | 18 this._sidebarPaneStack.showView(this._axNodeSubPane); |
| 19 this._sidebarPaneStack.widget().show(this.element); | 19 this._sidebarPaneStack.widget().show(this.element); |
| 20 WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, this._pul
lNode, this); | 20 UI.context.addFlavorChangeListener(SDK.DOMNode, this._pullNode, this); |
| 21 this._pullNode(); | 21 this._pullNode(); |
| 22 } | 22 } |
| 23 | 23 |
| 24 /** | 24 /** |
| 25 * @return {?WebInspector.DOMNode} | 25 * @return {?SDK.DOMNode} |
| 26 */ | 26 */ |
| 27 node() { | 27 node() { |
| 28 return this._node; | 28 return this._node; |
| 29 } | 29 } |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @param {?WebInspector.AccessibilityNode} axNode | 32 * @param {?Accessibility.AccessibilityNode} axNode |
| 33 */ | 33 */ |
| 34 accessibilityNodeCallback(axNode) { | 34 accessibilityNodeCallback(axNode) { |
| 35 if (!axNode) | 35 if (!axNode) |
| 36 return; | 36 return; |
| 37 | 37 |
| 38 this._axNode = axNode; | 38 this._axNode = axNode; |
| 39 | 39 |
| 40 if (axNode.ignored()) | 40 if (axNode.ignored()) |
| 41 this._sidebarPaneStack.removeView(this._ariaSubPane); | 41 this._sidebarPaneStack.removeView(this._ariaSubPane); |
| 42 else | 42 else |
| (...skipping 10 matching lines...) Expand all Loading... |
| 53 * @protected | 53 * @protected |
| 54 * @return {!Promise.<?>} | 54 * @return {!Promise.<?>} |
| 55 */ | 55 */ |
| 56 doUpdate() { | 56 doUpdate() { |
| 57 var node = this.node(); | 57 var node = this.node(); |
| 58 this._treeSubPane.setNode(node); | 58 this._treeSubPane.setNode(node); |
| 59 this._axNodeSubPane.setNode(node); | 59 this._axNodeSubPane.setNode(node); |
| 60 this._ariaSubPane.setNode(node); | 60 this._ariaSubPane.setNode(node); |
| 61 if (!node) | 61 if (!node) |
| 62 return Promise.resolve(); | 62 return Promise.resolve(); |
| 63 var accessibilityModel = WebInspector.AccessibilityModel.fromTarget(node.tar
get()); | 63 var accessibilityModel = Accessibility.AccessibilityModel.fromTarget(node.ta
rget()); |
| 64 accessibilityModel.clear(); | 64 accessibilityModel.clear(); |
| 65 return accessibilityModel.requestPartialAXTree(node) | 65 return accessibilityModel.requestPartialAXTree(node) |
| 66 .then(() => { | 66 .then(() => { |
| 67 this.accessibilityNodeCallback(accessibilityModel.axNodeForDOMNode(nod
e)); | 67 this.accessibilityNodeCallback(accessibilityModel.axNodeForDOMNode(nod
e)); |
| 68 }); | 68 }); |
| 69 } | 69 } |
| 70 | 70 |
| 71 /** | 71 /** |
| 72 * @override | 72 * @override |
| 73 */ | 73 */ |
| 74 wasShown() { | 74 wasShown() { |
| 75 super.wasShown(); | 75 super.wasShown(); |
| 76 | 76 |
| 77 this._treeSubPane.setNode(this.node()); | 77 this._treeSubPane.setNode(this.node()); |
| 78 this._axNodeSubPane.setNode(this.node()); | 78 this._axNodeSubPane.setNode(this.node()); |
| 79 this._ariaSubPane.setNode(this.node()); | 79 this._ariaSubPane.setNode(this.node()); |
| 80 | 80 |
| 81 WebInspector.targetManager.addModelListener( | 81 SDK.targetManager.addModelListener( |
| 82 WebInspector.DOMModel, WebInspector.DOMModel.Events.AttrModified, this._
onAttrChange, this); | 82 SDK.DOMModel, SDK.DOMModel.Events.AttrModified, this._onAttrChange, this
); |
| 83 WebInspector.targetManager.addModelListener( | 83 SDK.targetManager.addModelListener( |
| 84 WebInspector.DOMModel, WebInspector.DOMModel.Events.AttrRemoved, this._o
nAttrChange, this); | 84 SDK.DOMModel, SDK.DOMModel.Events.AttrRemoved, this._onAttrChange, this)
; |
| 85 WebInspector.targetManager.addModelListener( | 85 SDK.targetManager.addModelListener( |
| 86 WebInspector.DOMModel, WebInspector.DOMModel.Events.CharacterDataModifie
d, this._onNodeChange, this); | 86 SDK.DOMModel, SDK.DOMModel.Events.CharacterDataModified, this._onNodeCha
nge, this); |
| 87 WebInspector.targetManager.addModelListener( | 87 SDK.targetManager.addModelListener( |
| 88 WebInspector.DOMModel, WebInspector.DOMModel.Events.ChildNodeCountUpdate
d, this._onNodeChange, this); | 88 SDK.DOMModel, SDK.DOMModel.Events.ChildNodeCountUpdated, this._onNodeCha
nge, this); |
| 89 } | 89 } |
| 90 | 90 |
| 91 /** | 91 /** |
| 92 * @override | 92 * @override |
| 93 */ | 93 */ |
| 94 willHide() { | 94 willHide() { |
| 95 WebInspector.targetManager.removeModelListener( | 95 SDK.targetManager.removeModelListener( |
| 96 WebInspector.DOMModel, WebInspector.DOMModel.Events.AttrModified, this._
onAttrChange, this); | 96 SDK.DOMModel, SDK.DOMModel.Events.AttrModified, this._onAttrChange, this
); |
| 97 WebInspector.targetManager.removeModelListener( | 97 SDK.targetManager.removeModelListener( |
| 98 WebInspector.DOMModel, WebInspector.DOMModel.Events.AttrRemoved, this._o
nAttrChange, this); | 98 SDK.DOMModel, SDK.DOMModel.Events.AttrRemoved, this._onAttrChange, this)
; |
| 99 WebInspector.targetManager.removeModelListener( | 99 SDK.targetManager.removeModelListener( |
| 100 WebInspector.DOMModel, WebInspector.DOMModel.Events.CharacterDataModifie
d, this._onNodeChange, this); | 100 SDK.DOMModel, SDK.DOMModel.Events.CharacterDataModified, this._onNodeCha
nge, this); |
| 101 WebInspector.targetManager.removeModelListener( | 101 SDK.targetManager.removeModelListener( |
| 102 WebInspector.DOMModel, WebInspector.DOMModel.Events.ChildNodeCountUpdate
d, this._onNodeChange, this); | 102 SDK.DOMModel, SDK.DOMModel.Events.ChildNodeCountUpdated, this._onNodeCha
nge, this); |
| 103 } | 103 } |
| 104 | 104 |
| 105 _pullNode() { | 105 _pullNode() { |
| 106 this._node = WebInspector.context.flavor(WebInspector.DOMNode); | 106 this._node = UI.context.flavor(SDK.DOMNode); |
| 107 this.update(); | 107 this.update(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 /** | 110 /** |
| 111 * @param {!WebInspector.Event} event | 111 * @param {!Common.Event} event |
| 112 */ | 112 */ |
| 113 _onAttrChange(event) { | 113 _onAttrChange(event) { |
| 114 if (!this.node()) | 114 if (!this.node()) |
| 115 return; | 115 return; |
| 116 var node = event.data.node; | 116 var node = event.data.node; |
| 117 if (this.node() !== node) | 117 if (this.node() !== node) |
| 118 return; | 118 return; |
| 119 this.update(); | 119 this.update(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 /** | 122 /** |
| 123 * @param {!WebInspector.Event} event | 123 * @param {!Common.Event} event |
| 124 */ | 124 */ |
| 125 _onNodeChange(event) { | 125 _onNodeChange(event) { |
| 126 if (!this.node()) | 126 if (!this.node()) |
| 127 return; | 127 return; |
| 128 var node = event.data; | 128 var node = event.data; |
| 129 if (this.node() !== node) | 129 if (this.node() !== node) |
| 130 return; | 130 return; |
| 131 this.update(); | 131 this.update(); |
| 132 } | 132 } |
| 133 }; | 133 }; |
| 134 | 134 |
| 135 /** | 135 /** |
| 136 * @unrestricted | 136 * @unrestricted |
| 137 */ | 137 */ |
| 138 WebInspector.AccessibilitySubPane = class extends WebInspector.SimpleView { | 138 Accessibility.AccessibilitySubPane = class extends UI.SimpleView { |
| 139 /** | 139 /** |
| 140 * @param {string} name | 140 * @param {string} name |
| 141 */ | 141 */ |
| 142 constructor(name) { | 142 constructor(name) { |
| 143 super(name); | 143 super(name); |
| 144 | 144 |
| 145 this._axNode = null; | 145 this._axNode = null; |
| 146 this.registerRequiredCSS('accessibility/accessibilityNode.css'); | 146 this.registerRequiredCSS('accessibility/accessibilityNode.css'); |
| 147 } | 147 } |
| 148 | 148 |
| 149 /** | 149 /** |
| 150 * @param {?WebInspector.AccessibilityNode} axNode | 150 * @param {?Accessibility.AccessibilityNode} axNode |
| 151 * @protected | 151 * @protected |
| 152 */ | 152 */ |
| 153 setAXNode(axNode) { | 153 setAXNode(axNode) { |
| 154 } | 154 } |
| 155 | 155 |
| 156 /** | 156 /** |
| 157 * @return {?WebInspector.DOMNode} | 157 * @return {?SDK.DOMNode} |
| 158 */ | 158 */ |
| 159 node() { | 159 node() { |
| 160 return this._node; | 160 return this._node; |
| 161 } | 161 } |
| 162 | 162 |
| 163 /** | 163 /** |
| 164 * @param {?WebInspector.DOMNode} node | 164 * @param {?SDK.DOMNode} node |
| 165 */ | 165 */ |
| 166 setNode(node) { | 166 setNode(node) { |
| 167 this._node = node; | 167 this._node = node; |
| 168 } | 168 } |
| 169 | 169 |
| 170 /** | 170 /** |
| 171 * @param {string} textContent | 171 * @param {string} textContent |
| 172 * @param {string=} className | 172 * @param {string=} className |
| 173 * @return {!Element} | 173 * @return {!Element} |
| 174 */ | 174 */ |
| (...skipping 10 matching lines...) Expand all Loading... |
| 185 createTreeOutline() { | 185 createTreeOutline() { |
| 186 var treeOutline = new TreeOutlineInShadow(); | 186 var treeOutline = new TreeOutlineInShadow(); |
| 187 treeOutline.registerRequiredCSS('accessibility/accessibilityNode.css'); | 187 treeOutline.registerRequiredCSS('accessibility/accessibilityNode.css'); |
| 188 treeOutline.registerRequiredCSS('components/objectValue.css'); | 188 treeOutline.registerRequiredCSS('components/objectValue.css'); |
| 189 | 189 |
| 190 treeOutline.element.classList.add('hidden'); | 190 treeOutline.element.classList.add('hidden'); |
| 191 this.element.appendChild(treeOutline.element); | 191 this.element.appendChild(treeOutline.element); |
| 192 return treeOutline; | 192 return treeOutline; |
| 193 } | 193 } |
| 194 }; | 194 }; |
| OLD | NEW |