Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(949)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/accessibility/AccessibilitySidebarView.js

Issue 2466123002: DevTools: reformat front-end code to match chromium style. (Closed)
Patch Set: all done Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
5 /** 4 /**
6 * @constructor 5 * @unrestricted
7 * @extends {WebInspector.ThrottledWidget}
8 */ 6 */
9 WebInspector.AccessibilitySidebarView = function() 7 WebInspector.AccessibilitySidebarView = class extends WebInspector.ThrottledWidg et {
10 { 8 constructor() {
11 WebInspector.ThrottledWidget.call(this); 9 super();
12 this._node = null; 10 this._node = null;
13 this._axNode = null; 11 this._axNode = null;
14 this._sidebarPaneStack = WebInspector.viewManager.createStackLocation(); 12 this._sidebarPaneStack = WebInspector.viewManager.createStackLocation();
15 this._treeSubPane = new WebInspector.AXTreePane(); 13 this._treeSubPane = new WebInspector.AXTreePane();
16 this._sidebarPaneStack.showView(this._treeSubPane); 14 this._sidebarPaneStack.showView(this._treeSubPane);
17 this._ariaSubPane = new WebInspector.ARIAAttributesPane(); 15 this._ariaSubPane = new WebInspector.ARIAAttributesPane();
18 this._sidebarPaneStack.showView(this._ariaSubPane); 16 this._sidebarPaneStack.showView(this._ariaSubPane);
19 this._axNodeSubPane = new WebInspector.AXNodeSubPane(); 17 this._axNodeSubPane = new WebInspector.AXNodeSubPane();
20 this._sidebarPaneStack.showView(this._axNodeSubPane); 18 this._sidebarPaneStack.showView(this._axNodeSubPane);
21 this._sidebarPaneStack.widget().show(this.element); 19 this._sidebarPaneStack.widget().show(this.element);
22 WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, this._pul lNode, this); 20 WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, this._pul lNode, this);
23 this._pullNode(); 21 this._pullNode();
24 }; 22 }
25 23
26 WebInspector.AccessibilitySidebarView.prototype = { 24 /**
27 /** 25 * @return {?WebInspector.DOMNode}
28 * @return {?WebInspector.DOMNode} 26 */
29 */ 27 node() {
30 node: function() 28 return this._node;
31 { 29 }
32 return this._node;
33 },
34 30
35 /** 31 /**
36 * @param {?Array<!WebInspector.AccessibilityNode>} nodes 32 * @param {?Array<!WebInspector.AccessibilityNode>} nodes
37 */ 33 */
38 accessibilityNodeCallback: function(nodes) 34 accessibilityNodeCallback(nodes) {
39 { 35 if (!nodes)
40 if (!nodes) 36 return;
41 return;
42 37
43 var currentAXNode = nodes[0]; 38 var currentAXNode = nodes[0];
44 if (currentAXNode.ignored) 39 if (currentAXNode.ignored)
45 this._sidebarPaneStack.removeView(this._ariaSubPane); 40 this._sidebarPaneStack.removeView(this._ariaSubPane);
46 else 41 else
47 this._sidebarPaneStack.showView(this._ariaSubPane, this._axNodeSubPa ne); 42 this._sidebarPaneStack.showView(this._ariaSubPane, this._axNodeSubPane);
48 43
49 if (this._axNodeSubPane) 44 if (this._axNodeSubPane)
50 this._axNodeSubPane.setAXNode(currentAXNode); 45 this._axNodeSubPane.setAXNode(currentAXNode);
51 if (this._treeSubPane) 46 if (this._treeSubPane)
52 this._treeSubPane.setAXNodeAndAncestors(nodes); 47 this._treeSubPane.setAXNodeAndAncestors(nodes);
53 }, 48 }
54 49
55 /** 50 /**
56 * @override 51 * @override
57 * @protected 52 * @protected
58 * @return {!Promise.<?>} 53 * @return {!Promise.<?>}
59 */ 54 */
60 doUpdate: function() 55 doUpdate() {
61 { 56 var node = this.node();
62 var node = this.node(); 57 this._treeSubPane.setNode(node);
63 this._treeSubPane.setNode(node); 58 this._axNodeSubPane.setNode(node);
64 this._axNodeSubPane.setNode(node); 59 this._ariaSubPane.setNode(node);
65 this._ariaSubPane.setNode(node); 60 return WebInspector.AccessibilityModel.fromTarget(node.target()).getAXNodeCh ain(node).then((nodes) => {
66 return WebInspector.AccessibilityModel.fromTarget(node.target()).getAXNo deChain(node) 61 this.accessibilityNodeCallback(nodes);
67 .then((nodes) => { this.accessibilityNodeCallback(nodes); }); 62 });
68 }, 63 }
69 64
70 /** 65 /**
71 * @override 66 * @override
72 */ 67 */
73 wasShown: function() 68 wasShown() {
74 { 69 super.wasShown();
75 WebInspector.ThrottledWidget.prototype.wasShown.call(this);
76 70
77 this._treeSubPane.setNode(this.node()); 71 this._treeSubPane.setNode(this.node());
78 this._axNodeSubPane.setNode(this.node()); 72 this._axNodeSubPane.setNode(this.node());
79 this._ariaSubPane.setNode(this.node()); 73 this._ariaSubPane.setNode(this.node());
80 74
81 WebInspector.targetManager.addModelListener(WebInspector.DOMModel, WebIn spector.DOMModel.Events.AttrModified, this._onAttrChange, this); 75 WebInspector.targetManager.addModelListener(
82 WebInspector.targetManager.addModelListener(WebInspector.DOMModel, WebIn spector.DOMModel.Events.AttrRemoved, this._onAttrChange, this); 76 WebInspector.DOMModel, WebInspector.DOMModel.Events.AttrModified, this._ onAttrChange, this);
83 WebInspector.targetManager.addModelListener(WebInspector.DOMModel, WebIn spector.DOMModel.Events.CharacterDataModified, this._onNodeChange, this); 77 WebInspector.targetManager.addModelListener(
84 WebInspector.targetManager.addModelListener(WebInspector.DOMModel, WebIn spector.DOMModel.Events.ChildNodeCountUpdated, this._onNodeChange, this); 78 WebInspector.DOMModel, WebInspector.DOMModel.Events.AttrRemoved, this._o nAttrChange, this);
85 }, 79 WebInspector.targetManager.addModelListener(
80 WebInspector.DOMModel, WebInspector.DOMModel.Events.CharacterDataModifie d, this._onNodeChange, this);
81 WebInspector.targetManager.addModelListener(
82 WebInspector.DOMModel, WebInspector.DOMModel.Events.ChildNodeCountUpdate d, this._onNodeChange, this);
83 }
86 84
87 /** 85 /**
88 * @override 86 * @override
89 */ 87 */
90 willHide: function() 88 willHide() {
91 { 89 WebInspector.targetManager.removeModelListener(
92 WebInspector.targetManager.removeModelListener(WebInspector.DOMModel, We bInspector.DOMModel.Events.AttrModified, this._onAttrChange, this); 90 WebInspector.DOMModel, WebInspector.DOMModel.Events.AttrModified, this._ onAttrChange, this);
93 WebInspector.targetManager.removeModelListener(WebInspector.DOMModel, We bInspector.DOMModel.Events.AttrRemoved, this._onAttrChange, this); 91 WebInspector.targetManager.removeModelListener(
94 WebInspector.targetManager.removeModelListener(WebInspector.DOMModel, We bInspector.DOMModel.Events.CharacterDataModified, this._onNodeChange, this); 92 WebInspector.DOMModel, WebInspector.DOMModel.Events.AttrRemoved, this._o nAttrChange, this);
95 WebInspector.targetManager.removeModelListener(WebInspector.DOMModel, We bInspector.DOMModel.Events.ChildNodeCountUpdated, this._onNodeChange, this); 93 WebInspector.targetManager.removeModelListener(
96 }, 94 WebInspector.DOMModel, WebInspector.DOMModel.Events.CharacterDataModifie d, this._onNodeChange, this);
95 WebInspector.targetManager.removeModelListener(
96 WebInspector.DOMModel, WebInspector.DOMModel.Events.ChildNodeCountUpdate d, this._onNodeChange, this);
97 }
97 98
98 _pullNode: function() 99 _pullNode() {
99 { 100 this._node = WebInspector.context.flavor(WebInspector.DOMNode);
100 this._node = WebInspector.context.flavor(WebInspector.DOMNode); 101 this.update();
101 this.update(); 102 }
102 },
103 103
104 /** 104 /**
105 * @param {!WebInspector.Event} event 105 * @param {!WebInspector.Event} event
106 */ 106 */
107 _onAttrChange: function(event) 107 _onAttrChange(event) {
108 { 108 if (!this.node())
109 if (!this.node()) 109 return;
110 return; 110 var node = event.data.node;
111 var node = event.data.node; 111 if (this.node() !== node)
112 if (this.node() !== node) 112 return;
113 return; 113 this.update();
114 this.update(); 114 }
115 },
116 115
117 /** 116 /**
118 * @param {!WebInspector.Event} event 117 * @param {!WebInspector.Event} event
119 */ 118 */
120 _onNodeChange: function(event) 119 _onNodeChange(event) {
121 { 120 if (!this.node())
122 if (!this.node()) 121 return;
123 return; 122 var node = event.data;
124 var node = event.data; 123 if (this.node() !== node)
125 if (this.node() !== node) 124 return;
126 return; 125 this.update();
127 this.update(); 126 }
128 },
129
130
131 __proto__: WebInspector.ThrottledWidget.prototype
132 }; 127 };
133 128
134 /** 129 /**
135 * @constructor 130 * @unrestricted
136 * @extends {WebInspector.SimpleView}
137 * @param {string} name
138 */ 131 */
139 WebInspector.AccessibilitySubPane = function(name) 132 WebInspector.AccessibilitySubPane = class extends WebInspector.SimpleView {
140 { 133 /**
141 WebInspector.SimpleView.call(this, name); 134 * @param {string} name
135 */
136 constructor(name) {
137 super(name);
142 138
143 this._axNode = null; 139 this._axNode = null;
144 this.registerRequiredCSS("accessibility/accessibilityNode.css"); 140 this.registerRequiredCSS('accessibility/accessibilityNode.css');
141 }
142
143 /**
144 * @param {?WebInspector.AccessibilityNode} axNode
145 * @protected
146 */
147 setAXNode(axNode) {
148 }
149
150 /**
151 * @return {?WebInspector.DOMNode}
152 */
153 node() {
154 return this._node;
155 }
156
157 /**
158 * @param {?WebInspector.DOMNode} node
159 */
160 setNode(node) {
161 this._node = node;
162 }
163
164 /**
165 * @param {string} textContent
166 * @param {string=} className
167 * @return {!Element}
168 */
169 createInfo(textContent, className) {
170 var classNameOrDefault = className || 'gray-info-message';
171 var info = this.element.createChild('div', classNameOrDefault);
172 info.textContent = textContent;
173 return info;
174 }
175
176 /**
177 * @return {!TreeOutline}
178 */
179 createTreeOutline() {
180 var treeOutline = new TreeOutlineInShadow();
181 treeOutline.registerRequiredCSS('accessibility/accessibilityNode.css');
182 treeOutline.registerRequiredCSS('components/objectValue.css');
183
184 treeOutline.element.classList.add('hidden');
185 this.element.appendChild(treeOutline.element);
186 return treeOutline;
187 }
145 }; 188 };
146
147 WebInspector.AccessibilitySubPane.prototype = {
148 /**
149 * @param {?WebInspector.AccessibilityNode} axNode
150 * @protected
151 */
152 setAXNode: function(axNode)
153 {
154 },
155
156 /**
157 * @return {?WebInspector.DOMNode}
158 */
159 node: function()
160 {
161 return this._node;
162 },
163
164 /**
165 * @param {?WebInspector.DOMNode} node
166 */
167 setNode: function(node)
168 {
169 this._node = node;
170 },
171
172 /**
173 * @param {string} textContent
174 * @param {string=} className
175 * @return {!Element}
176 */
177 createInfo: function(textContent, className)
178 {
179 var classNameOrDefault = className || "gray-info-message";
180 var info = this.element.createChild("div", classNameOrDefault);
181 info.textContent = textContent;
182 return info;
183 },
184
185 /**
186 * @return {!TreeOutline}
187 */
188 createTreeOutline: function()
189 {
190 var treeOutline = new TreeOutlineInShadow();
191 treeOutline.registerRequiredCSS("accessibility/accessibilityNode.css");
192 treeOutline.registerRequiredCSS("components/objectValue.css");
193
194 treeOutline.element.classList.add("hidden");
195 this.element.appendChild(treeOutline.element);
196 return treeOutline;
197 },
198
199 __proto__: WebInspector.SimpleView.prototype
200 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698