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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sources/SourcesNavigator.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 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 10 *
11 * 2. Redistributions in binary form must reproduce the above 11 * 2. Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer 12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the 13 * in the documentation and/or other materials provided with the
14 * distribution. 14 * distribution.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. AND ITS CONTRIBUTORS 16 * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. AND ITS CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC.
20 * OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 * OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28 /**
29 /** 29 * @unrestricted
30 * @constructor 30 */
31 * @extends {WebInspector.NavigatorView} 31 WebInspector.SourcesNavigatorView = class extends WebInspector.NavigatorView {
32 */ 32 constructor() {
33 WebInspector.SourcesNavigatorView = function() 33 super();
34 { 34 WebInspector.targetManager.addEventListener(
35 WebInspector.NavigatorView.call(this); 35 WebInspector.TargetManager.Events.InspectedURLChanged, this._inspectedUR LChanged, this);
36 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Event s.InspectedURLChanged, this._inspectedURLChanged, this); 36 }
37 }; 37
38 38 /**
39 WebInspector.SourcesNavigatorView.prototype = { 39 * @override
40 /** 40 * @param {!WebInspector.UISourceCode} uiSourceCode
41 * @override 41 * @return {boolean}
42 * @param {!WebInspector.UISourceCode} uiSourceCode 42 */
43 * @return {boolean} 43 accept(uiSourceCode) {
44 */ 44 if (!super.accept(uiSourceCode))
45 accept: function(uiSourceCode) 45 return false;
46 { 46 return uiSourceCode.project().type() !== WebInspector.projectTypes.ContentSc ripts &&
47 if (!WebInspector.NavigatorView.prototype.accept(uiSourceCode)) 47 uiSourceCode.project().type() !== WebInspector.projectTypes.Snippets;
48 return false; 48 }
49 return uiSourceCode.project().type() !== WebInspector.projectTypes.Conte ntScripts && uiSourceCode.project().type() !== WebInspector.projectTypes.Snippet s; 49
50 }, 50 /**
51 51 * @param {!WebInspector.Event} event
52 /** 52 */
53 * @param {!WebInspector.Event} event 53 _inspectedURLChanged(event) {
54 */ 54 var mainTarget = WebInspector.targetManager.mainTarget();
55 _inspectedURLChanged: function(event) 55 if (event.data !== mainTarget)
56 { 56 return;
57 var mainTarget = WebInspector.targetManager.mainTarget(); 57 var inspectedURL = mainTarget && mainTarget.inspectedURL();
58 if (event.data !== mainTarget) 58 if (!inspectedURL)
59 return; 59 return;
60 var inspectedURL = mainTarget && mainTarget.inspectedURL(); 60 for (var node of this._uiSourceCodeNodes.valuesArray()) {
61 if (!inspectedURL) 61 var uiSourceCode = node.uiSourceCode();
62 return; 62 if (uiSourceCode.url() === inspectedURL)
63 for (var node of this._uiSourceCodeNodes.valuesArray()) { 63 this.revealUISourceCode(uiSourceCode, true);
64 var uiSourceCode = node.uiSourceCode(); 64 }
65 if (uiSourceCode.url() === inspectedURL) 65 }
66 this.revealUISourceCode(uiSourceCode, true); 66
67 } 67 /**
68 }, 68 * @override
69 69 * @param {!WebInspector.UISourceCode} uiSourceCode
70 /** 70 */
71 * @override 71 uiSourceCodeAdded(uiSourceCode) {
72 * @param {!WebInspector.UISourceCode} uiSourceCode 72 var mainTarget = WebInspector.targetManager.mainTarget();
73 */ 73 var inspectedURL = mainTarget && mainTarget.inspectedURL();
74 uiSourceCodeAdded: function(uiSourceCode) 74 if (!inspectedURL)
75 { 75 return;
76 var mainTarget = WebInspector.targetManager.mainTarget(); 76 if (uiSourceCode.url() === inspectedURL)
77 var inspectedURL = mainTarget && mainTarget.inspectedURL(); 77 this.revealUISourceCode(uiSourceCode, true);
78 if (!inspectedURL) 78 }
79 return; 79
80 if (uiSourceCode.url() === inspectedURL) 80 /**
81 this.revealUISourceCode(uiSourceCode, true); 81 * @override
82 }, 82 * @param {!Event} event
83 83 */
84 /** 84 handleContextMenu(event) {
85 * @override 85 var contextMenu = new WebInspector.ContextMenu(event);
86 * @param {!Event} event 86 WebInspector.NavigatorView.appendAddFolderItem(contextMenu);
87 */ 87 contextMenu.show();
88 handleContextMenu: function(event) 88 }
89 { 89 };
90 var contextMenu = new WebInspector.ContextMenu(event); 90
91 WebInspector.NavigatorView.appendAddFolderItem(contextMenu); 91 /**
92 contextMenu.show(); 92 * @unrestricted
93 }, 93 */
94 94 WebInspector.NetworkNavigatorView = class extends WebInspector.NavigatorView {
95 __proto__: WebInspector.NavigatorView.prototype 95 constructor() {
96 }; 96 super();
97 97 WebInspector.targetManager.addEventListener(
98 /** 98 WebInspector.TargetManager.Events.InspectedURLChanged, this._inspectedUR LChanged, this);
99 * @constructor 99 }
100 * @extends {WebInspector.NavigatorView} 100
101 */ 101 /**
102 WebInspector.NetworkNavigatorView = function() 102 * @override
103 { 103 * @param {!WebInspector.UISourceCode} uiSourceCode
104 WebInspector.NavigatorView.call(this); 104 * @return {boolean}
105 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Event s.InspectedURLChanged, this._inspectedURLChanged, this); 105 */
106 }; 106 accept(uiSourceCode) {
107 107 return uiSourceCode.project().type() === WebInspector.projectTypes.Network;
108 WebInspector.NetworkNavigatorView.prototype = { 108 }
109 /** 109
110 * @override 110 /**
111 * @param {!WebInspector.UISourceCode} uiSourceCode 111 * @param {!WebInspector.Event} event
112 * @return {boolean} 112 */
113 */ 113 _inspectedURLChanged(event) {
114 accept: function(uiSourceCode) 114 var mainTarget = WebInspector.targetManager.mainTarget();
115 { 115 if (event.data !== mainTarget)
116 return uiSourceCode.project().type() === WebInspector.projectTypes.Netwo rk; 116 return;
117 }, 117 var inspectedURL = mainTarget && mainTarget.inspectedURL();
118 118 if (!inspectedURL)
119 /** 119 return;
120 * @param {!WebInspector.Event} event 120 for (var node of this._uiSourceCodeNodes.valuesArray()) {
121 */ 121 var uiSourceCode = node.uiSourceCode();
122 _inspectedURLChanged: function(event) 122 if (uiSourceCode.url() === inspectedURL)
123 { 123 this.revealUISourceCode(uiSourceCode, true);
124 var mainTarget = WebInspector.targetManager.mainTarget(); 124 }
125 if (event.data !== mainTarget) 125 }
126 return; 126
127 var inspectedURL = mainTarget && mainTarget.inspectedURL(); 127 /**
128 if (!inspectedURL) 128 * @override
129 return; 129 * @param {!WebInspector.UISourceCode} uiSourceCode
130 for (var node of this._uiSourceCodeNodes.valuesArray()) { 130 */
131 var uiSourceCode = node.uiSourceCode(); 131 uiSourceCodeAdded(uiSourceCode) {
132 if (uiSourceCode.url() === inspectedURL) 132 var mainTarget = WebInspector.targetManager.mainTarget();
133 this.revealUISourceCode(uiSourceCode, true); 133 var inspectedURL = mainTarget && mainTarget.inspectedURL();
134 } 134 if (!inspectedURL)
135 }, 135 return;
136 136 if (uiSourceCode.url() === inspectedURL)
137 /** 137 this.revealUISourceCode(uiSourceCode, true);
138 * @override 138 }
139 * @param {!WebInspector.UISourceCode} uiSourceCode 139 };
140 */ 140
141 uiSourceCodeAdded: function(uiSourceCode) 141 /**
142 { 142 * @unrestricted
143 var mainTarget = WebInspector.targetManager.mainTarget(); 143 */
144 var inspectedURL = mainTarget && mainTarget.inspectedURL(); 144 WebInspector.FilesNavigatorView = class extends WebInspector.NavigatorView {
145 if (!inspectedURL) 145 constructor() {
146 return; 146 super();
147 if (uiSourceCode.url() === inspectedURL) 147 }
148 this.revealUISourceCode(uiSourceCode, true); 148
149 }, 149 /**
150 150 * @override
151 __proto__: WebInspector.NavigatorView.prototype 151 * @param {!WebInspector.UISourceCode} uiSourceCode
152 }; 152 * @return {boolean}
153 153 */
154 /** 154 accept(uiSourceCode) {
155 * @constructor 155 return uiSourceCode.project().type() === WebInspector.projectTypes.FileSyste m;
156 * @extends {WebInspector.NavigatorView} 156 }
157 */ 157
158 WebInspector.FilesNavigatorView = function() 158 /**
159 { 159 * @override
160 WebInspector.NavigatorView.call(this); 160 * @param {!Event} event
161 }; 161 */
162 162 handleContextMenu(event) {
163 WebInspector.FilesNavigatorView.prototype = { 163 var contextMenu = new WebInspector.ContextMenu(event);
164 /** 164 WebInspector.NavigatorView.appendAddFolderItem(contextMenu);
165 * @override 165 contextMenu.show();
166 * @param {!WebInspector.UISourceCode} uiSourceCode 166 }
167 * @return {boolean} 167 };
168 */ 168
169 accept: function(uiSourceCode) 169 /**
170 { 170 * @unrestricted
171 return uiSourceCode.project().type() === WebInspector.projectTypes.FileS ystem; 171 */
172 }, 172 WebInspector.ContentScriptsNavigatorView = class extends WebInspector.NavigatorV iew {
173 173 constructor() {
174 /** 174 super();
175 * @override 175 }
176 * @param {!Event} event 176
177 */ 177 /**
178 handleContextMenu: function(event) 178 * @override
179 { 179 * @param {!WebInspector.UISourceCode} uiSourceCode
180 var contextMenu = new WebInspector.ContextMenu(event); 180 * @return {boolean}
181 WebInspector.NavigatorView.appendAddFolderItem(contextMenu); 181 */
182 contextMenu.show(); 182 accept(uiSourceCode) {
183 }, 183 return uiSourceCode.project().type() === WebInspector.projectTypes.ContentSc ripts;
184 184 }
185 __proto__: WebInspector.NavigatorView.prototype 185 };
186 }; 186
187 187 /**
188 /** 188 * @unrestricted
189 * @constructor 189 */
190 * @extends {WebInspector.NavigatorView} 190 WebInspector.SnippetsNavigatorView = class extends WebInspector.NavigatorView {
191 */ 191 constructor() {
192 WebInspector.ContentScriptsNavigatorView = function() 192 super();
193 { 193 var toolbar = new WebInspector.Toolbar('snippets-navigator-toolbar');
194 WebInspector.NavigatorView.call(this); 194 var newButton = new WebInspector.ToolbarButton(WebInspector.UIString('New'), 'add-toolbar-item');
195 }; 195 newButton.addEventListener('click', this._handleCreateSnippet.bind(this));
196
197 WebInspector.ContentScriptsNavigatorView.prototype = {
198 /**
199 * @override
200 * @param {!WebInspector.UISourceCode} uiSourceCode
201 * @return {boolean}
202 */
203 accept: function(uiSourceCode)
204 {
205 return uiSourceCode.project().type() === WebInspector.projectTypes.Conte ntScripts;
206 },
207
208 __proto__: WebInspector.NavigatorView.prototype
209 };
210
211 /**
212 * @constructor
213 * @extends {WebInspector.NavigatorView}
214 */
215 WebInspector.SnippetsNavigatorView = function()
216 {
217 WebInspector.NavigatorView.call(this);
218 var toolbar = new WebInspector.Toolbar("snippets-navigator-toolbar");
219 var newButton = new WebInspector.ToolbarButton(WebInspector.UIString("New"), "add-toolbar-item");
220 newButton.addEventListener("click", this._handleCreateSnippet.bind(this));
221 toolbar.appendToolbarItem(newButton); 196 toolbar.appendToolbarItem(newButton);
222 this.element.insertBefore(toolbar.element, this.element.firstChild); 197 this.element.insertBefore(toolbar.element, this.element.firstChild);
223 }; 198 }
224 199
225 WebInspector.SnippetsNavigatorView.prototype = { 200 /**
226 /** 201 * @override
227 * @override 202 * @param {!WebInspector.UISourceCode} uiSourceCode
228 * @param {!WebInspector.UISourceCode} uiSourceCode 203 * @return {boolean}
229 * @return {boolean} 204 */
230 */ 205 accept(uiSourceCode) {
231 accept: function(uiSourceCode) 206 return uiSourceCode.project().type() === WebInspector.projectTypes.Snippets;
232 { 207 }
233 return uiSourceCode.project().type() === WebInspector.projectTypes.Snipp ets; 208
234 }, 209 /**
235 210 * @override
236 /** 211 * @param {!Event} event
237 * @override 212 */
238 * @param {!Event} event 213 handleContextMenu(event) {
239 */ 214 var contextMenu = new WebInspector.ContextMenu(event);
240 handleContextMenu: function(event) 215 contextMenu.appendItem(WebInspector.UIString('New'), this._handleCreateSnipp et.bind(this));
241 { 216 contextMenu.show();
242 var contextMenu = new WebInspector.ContextMenu(event); 217 }
243 contextMenu.appendItem(WebInspector.UIString("New"), this._handleCreateS nippet.bind(this)); 218
244 contextMenu.show(); 219 /**
245 }, 220 * @override
246 221 * @param {!Event} event
247 /** 222 * @param {!WebInspector.UISourceCode} uiSourceCode
248 * @override 223 */
249 * @param {!Event} event 224 handleFileContextMenu(event, uiSourceCode) {
250 * @param {!WebInspector.UISourceCode} uiSourceCode 225 var contextMenu = new WebInspector.ContextMenu(event);
251 */ 226 contextMenu.appendItem(WebInspector.UIString('Run'), this._handleEvaluateSni ppet.bind(this, uiSourceCode));
252 handleFileContextMenu: function(event, uiSourceCode) 227 contextMenu.appendItem(WebInspector.UIString('Rename'), this.rename.bind(thi s, uiSourceCode));
253 { 228 contextMenu.appendItem(WebInspector.UIString('Remove'), this._handleRemoveSn ippet.bind(this, uiSourceCode));
254 var contextMenu = new WebInspector.ContextMenu(event); 229 contextMenu.appendSeparator();
255 contextMenu.appendItem(WebInspector.UIString("Run"), this._handleEvaluat eSnippet.bind(this, uiSourceCode)); 230 contextMenu.appendItem(WebInspector.UIString('New'), this._handleCreateSnipp et.bind(this));
256 contextMenu.appendItem(WebInspector.UIString("Rename"), this.rename.bind (this, uiSourceCode)); 231 contextMenu.appendSeparator();
257 contextMenu.appendItem(WebInspector.UIString("Remove"), this._handleRemo veSnippet.bind(this, uiSourceCode)); 232 contextMenu.appendItem(WebInspector.UIString('Save as...'), this._handleSave As.bind(this, uiSourceCode));
258 contextMenu.appendSeparator(); 233 contextMenu.show();
259 contextMenu.appendItem(WebInspector.UIString("New"), this._handleCreateS nippet.bind(this)); 234 }
260 contextMenu.appendSeparator(); 235
261 contextMenu.appendItem(WebInspector.UIString("Save as..."), this._handle SaveAs.bind(this, uiSourceCode)); 236 /**
262 contextMenu.show(); 237 * @param {!WebInspector.UISourceCode} uiSourceCode
263 }, 238 */
264 239 _handleEvaluateSnippet(uiSourceCode) {
265 /** 240 var executionContext = WebInspector.context.flavor(WebInspector.ExecutionCon text);
266 * @param {!WebInspector.UISourceCode} uiSourceCode 241 if (uiSourceCode.project().type() !== WebInspector.projectTypes.Snippets || !executionContext)
267 */ 242 return;
268 _handleEvaluateSnippet: function(uiSourceCode) 243 WebInspector.scriptSnippetModel.evaluateScriptSnippet(executionContext, uiSo urceCode);
269 { 244 }
270 var executionContext = WebInspector.context.flavor(WebInspector.Executio nContext); 245
271 if (uiSourceCode.project().type() !== WebInspector.projectTypes.Snippets || !executionContext) 246 /**
272 return; 247 * @param {!WebInspector.UISourceCode} uiSourceCode
273 WebInspector.scriptSnippetModel.evaluateScriptSnippet(executionContext, uiSourceCode); 248 */
274 }, 249 _handleSaveAs(uiSourceCode) {
275 250 if (uiSourceCode.project().type() !== WebInspector.projectTypes.Snippets)
276 /** 251 return;
277 * @param {!WebInspector.UISourceCode} uiSourceCode 252 uiSourceCode.saveAs();
278 */ 253 }
279 _handleSaveAs: function(uiSourceCode) 254
280 { 255 /**
281 if (uiSourceCode.project().type() !== WebInspector.projectTypes.Snippets ) 256 * @param {!WebInspector.UISourceCode} uiSourceCode
282 return; 257 */
283 uiSourceCode.saveAs(); 258 _handleRemoveSnippet(uiSourceCode) {
284 }, 259 if (uiSourceCode.project().type() !== WebInspector.projectTypes.Snippets)
285 260 return;
286 /** 261 uiSourceCode.remove();
287 * @param {!WebInspector.UISourceCode} uiSourceCode 262 }
288 */ 263
289 _handleRemoveSnippet: function(uiSourceCode) 264 _handleCreateSnippet() {
290 { 265 this.create(WebInspector.scriptSnippetModel.project(), '');
291 if (uiSourceCode.project().type() !== WebInspector.projectTypes.Snippets ) 266 }
292 return; 267
293 uiSourceCode.remove(); 268 /**
294 }, 269 * @override
295 270 */
296 _handleCreateSnippet: function() 271 sourceDeleted(uiSourceCode) {
297 { 272 this._handleRemoveSnippet(uiSourceCode);
298 this.create(WebInspector.scriptSnippetModel.project(), ""); 273 }
299 }, 274 };
300
301 /**
302 * @override
303 */
304 sourceDeleted: function(uiSourceCode)
305 {
306 this._handleRemoveSnippet(uiSourceCode);
307 },
308
309 __proto__: WebInspector.NavigatorView.prototype
310 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698