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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sources/NavigatorView.js

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 * @implements {WebInspector.TargetManager.Observer} 29 * @implements {SDK.TargetManager.Observer}
30 * @unrestricted 30 * @unrestricted
31 */ 31 */
32 WebInspector.NavigatorView = class extends WebInspector.VBox { 32 Sources.NavigatorView = class extends UI.VBox {
33 constructor() { 33 constructor() {
34 super(); 34 super();
35 this.registerRequiredCSS('sources/navigatorView.css'); 35 this.registerRequiredCSS('sources/navigatorView.css');
36 36
37 this._scriptsTree = new TreeOutlineInShadow(); 37 this._scriptsTree = new TreeOutlineInShadow();
38 this._scriptsTree.registerRequiredCSS('sources/navigatorTree.css'); 38 this._scriptsTree.registerRequiredCSS('sources/navigatorTree.css');
39 this._scriptsTree.setComparator(WebInspector.NavigatorView._treeElementsComp are); 39 this._scriptsTree.setComparator(Sources.NavigatorView._treeElementsCompare);
40 this.element.appendChild(this._scriptsTree.element); 40 this.element.appendChild(this._scriptsTree.element);
41 this.setDefaultFocusedElement(this._scriptsTree.element); 41 this.setDefaultFocusedElement(this._scriptsTree.element);
42 42
43 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.NavigatorUISource CodeTreeNode>} */ 43 /** @type {!Map.<!Workspace.UISourceCode, !Sources.NavigatorUISourceCodeTree Node>} */
44 this._uiSourceCodeNodes = new Map(); 44 this._uiSourceCodeNodes = new Map();
45 /** @type {!Map.<string, !WebInspector.NavigatorFolderTreeNode>} */ 45 /** @type {!Map.<string, !Sources.NavigatorFolderTreeNode>} */
46 this._subfolderNodes = new Map(); 46 this._subfolderNodes = new Map();
47 47
48 this._rootNode = new WebInspector.NavigatorRootTreeNode(this); 48 this._rootNode = new Sources.NavigatorRootTreeNode(this);
49 this._rootNode.populate(); 49 this._rootNode.populate();
50 50
51 /** @type {!Map.<!WebInspector.ResourceTreeFrame, !WebInspector.NavigatorGro upTreeNode>} */ 51 /** @type {!Map.<!SDK.ResourceTreeFrame, !Sources.NavigatorGroupTreeNode>} * /
52 this._frameNodes = new Map(); 52 this._frameNodes = new Map();
53 53
54 this.element.addEventListener('contextmenu', this.handleContextMenu.bind(thi s), false); 54 this.element.addEventListener('contextmenu', this.handleContextMenu.bind(thi s), false);
55 55
56 this._navigatorGroupByFolderSetting = WebInspector.moduleSetting('navigatorG roupByFolder'); 56 this._navigatorGroupByFolderSetting = Common.moduleSetting('navigatorGroupBy Folder');
57 this._navigatorGroupByFolderSetting.addChangeListener(this._groupingChanged. bind(this)); 57 this._navigatorGroupByFolderSetting.addChangeListener(this._groupingChanged. bind(this));
58 58
59 this._initGrouping(); 59 this._initGrouping();
60 WebInspector.targetManager.addModelListener( 60 SDK.targetManager.addModelListener(
61 WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.Events.Fr ameNavigated, this._frameNavigated, 61 SDK.ResourceTreeModel, SDK.ResourceTreeModel.Events.FrameNavigated, this ._frameNavigated,
62 this); 62 this);
63 WebInspector.targetManager.addModelListener( 63 SDK.targetManager.addModelListener(
64 WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.Events.Fr ameDetached, this._frameDetached, this); 64 SDK.ResourceTreeModel, SDK.ResourceTreeModel.Events.FrameDetached, this. _frameDetached, this);
65 65
66 if (Runtime.experiments.isEnabled('persistence2')) { 66 if (Runtime.experiments.isEnabled('persistence2')) {
67 WebInspector.persistence.addEventListener( 67 Persistence.persistence.addEventListener(
68 WebInspector.Persistence.Events.BindingCreated, this._onBindingChanged , this); 68 Persistence.Persistence.Events.BindingCreated, this._onBindingChanged, this);
69 WebInspector.persistence.addEventListener( 69 Persistence.persistence.addEventListener(
70 WebInspector.Persistence.Events.BindingRemoved, this._onBindingChanged , this); 70 Persistence.Persistence.Events.BindingRemoved, this._onBindingChanged, this);
71 } else { 71 } else {
72 WebInspector.persistence.addEventListener( 72 Persistence.persistence.addEventListener(
73 WebInspector.Persistence.Events.BindingCreated, this._onBindingCreated , this); 73 Persistence.Persistence.Events.BindingCreated, this._onBindingCreated, this);
74 WebInspector.persistence.addEventListener( 74 Persistence.persistence.addEventListener(
75 WebInspector.Persistence.Events.BindingRemoved, this._onBindingRemoved , this); 75 Persistence.Persistence.Events.BindingRemoved, this._onBindingRemoved, this);
76 } 76 }
77 WebInspector.targetManager.addEventListener( 77 SDK.targetManager.addEventListener(
78 WebInspector.TargetManager.Events.NameChanged, this._targetNameChanged, this); 78 SDK.TargetManager.Events.NameChanged, this._targetNameChanged, this);
79 79
80 WebInspector.targetManager.observeTargets(this); 80 SDK.targetManager.observeTargets(this);
81 this._resetWorkspace(WebInspector.workspace); 81 this._resetWorkspace(Workspace.workspace);
82 this._workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this)); 82 this._workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this));
83 } 83 }
84 84
85 /** 85 /**
86 * @param {!TreeElement} treeElement 86 * @param {!TreeElement} treeElement
87 */ 87 */
88 static _treeElementOrder(treeElement) { 88 static _treeElementOrder(treeElement) {
89 if (treeElement._boostOrder) 89 if (treeElement._boostOrder)
90 return 0; 90 return 0;
91 91
92 if (!WebInspector.NavigatorView._typeOrders) { 92 if (!Sources.NavigatorView._typeOrders) {
93 var weights = {}; 93 var weights = {};
94 var types = WebInspector.NavigatorView.Types; 94 var types = Sources.NavigatorView.Types;
95 weights[types.Root] = 1; 95 weights[types.Root] = 1;
96 weights[types.Category] = 1; 96 weights[types.Category] = 1;
97 weights[types.Domain] = 10; 97 weights[types.Domain] = 10;
98 weights[types.FileSystemFolder] = 1; 98 weights[types.FileSystemFolder] = 1;
99 weights[types.NetworkFolder] = 1; 99 weights[types.NetworkFolder] = 1;
100 weights[types.SourceMapFolder] = 2; 100 weights[types.SourceMapFolder] = 2;
101 weights[types.File] = 10; 101 weights[types.File] = 10;
102 weights[types.Frame] = 70; 102 weights[types.Frame] = 70;
103 weights[types.Worker] = 90; 103 weights[types.Worker] = 90;
104 weights[types.FileSystem] = 100; 104 weights[types.FileSystem] = 100;
105 WebInspector.NavigatorView._typeOrders = weights; 105 Sources.NavigatorView._typeOrders = weights;
106 } 106 }
107 107
108 var order = WebInspector.NavigatorView._typeOrders[treeElement._nodeType]; 108 var order = Sources.NavigatorView._typeOrders[treeElement._nodeType];
109 if (treeElement._uiSourceCode) { 109 if (treeElement._uiSourceCode) {
110 var contentType = treeElement._uiSourceCode.contentType(); 110 var contentType = treeElement._uiSourceCode.contentType();
111 if (contentType.isDocument()) 111 if (contentType.isDocument())
112 order += 3; 112 order += 3;
113 else if (contentType.isScript()) 113 else if (contentType.isScript())
114 order += 5; 114 order += 5;
115 else if (contentType.isStyleSheet()) 115 else if (contentType.isStyleSheet())
116 order += 10; 116 order += 10;
117 else 117 else
118 order += 15; 118 order += 15;
119 } 119 }
120 120
121 return order; 121 return order;
122 } 122 }
123 123
124 /** 124 /**
125 * @param {!WebInspector.ContextMenu} contextMenu 125 * @param {!UI.ContextMenu} contextMenu
126 */ 126 */
127 static appendAddFolderItem(contextMenu) { 127 static appendAddFolderItem(contextMenu) {
128 function addFolder() { 128 function addFolder() {
129 WebInspector.isolatedFileSystemManager.addFileSystem(); 129 Workspace.isolatedFileSystemManager.addFileSystem();
130 } 130 }
131 131
132 var addFolderLabel = WebInspector.UIString('Add folder to workspace'); 132 var addFolderLabel = Common.UIString('Add folder to workspace');
133 contextMenu.appendItem(addFolderLabel, addFolder); 133 contextMenu.appendItem(addFolderLabel, addFolder);
134 } 134 }
135 135
136 /** 136 /**
137 * @param {!WebInspector.ContextMenu} contextMenu 137 * @param {!UI.ContextMenu} contextMenu
138 * @param {string=} path 138 * @param {string=} path
139 */ 139 */
140 static appendSearchItem(contextMenu, path) { 140 static appendSearchItem(contextMenu, path) {
141 function searchPath() { 141 function searchPath() {
142 WebInspector.AdvancedSearchView.openSearch('', path.trim()); 142 Sources.AdvancedSearchView.openSearch('', path.trim());
143 } 143 }
144 144
145 var searchLabel = WebInspector.UIString('Search in folder'); 145 var searchLabel = Common.UIString('Search in folder');
146 if (!path || !path.trim()) { 146 if (!path || !path.trim()) {
147 path = '*'; 147 path = '*';
148 searchLabel = WebInspector.UIString('Search in all files'); 148 searchLabel = Common.UIString('Search in all files');
149 } 149 }
150 contextMenu.appendItem(searchLabel, searchPath); 150 contextMenu.appendItem(searchLabel, searchPath);
151 } 151 }
152 152
153 /** 153 /**
154 * @param {!TreeElement} treeElement1 154 * @param {!TreeElement} treeElement1
155 * @param {!TreeElement} treeElement2 155 * @param {!TreeElement} treeElement2
156 * @return {number} 156 * @return {number}
157 */ 157 */
158 static _treeElementsCompare(treeElement1, treeElement2) { 158 static _treeElementsCompare(treeElement1, treeElement2) {
159 var typeWeight1 = WebInspector.NavigatorView._treeElementOrder(treeElement1) ; 159 var typeWeight1 = Sources.NavigatorView._treeElementOrder(treeElement1);
160 var typeWeight2 = WebInspector.NavigatorView._treeElementOrder(treeElement2) ; 160 var typeWeight2 = Sources.NavigatorView._treeElementOrder(treeElement2);
161 161
162 var result; 162 var result;
163 if (typeWeight1 > typeWeight2) 163 if (typeWeight1 > typeWeight2)
164 return 1; 164 return 1;
165 if (typeWeight1 < typeWeight2) 165 if (typeWeight1 < typeWeight2)
166 return -1; 166 return -1;
167 return treeElement1.titleAsText().compareTo(treeElement2.titleAsText()); 167 return treeElement1.titleAsText().compareTo(treeElement2.titleAsText());
168 } 168 }
169 169
170 /** 170 /**
171 * @param {!WebInspector.Event} event 171 * @param {!Common.Event} event
172 */ 172 */
173 _onBindingCreated(event) { 173 _onBindingCreated(event) {
174 var binding = /** @type {!WebInspector.PersistenceBinding} */ (event.data); 174 var binding = /** @type {!Persistence.PersistenceBinding} */ (event.data);
175 this._removeUISourceCode(binding.network); 175 this._removeUISourceCode(binding.network);
176 } 176 }
177 177
178 /** 178 /**
179 * @param {!WebInspector.Event} event 179 * @param {!Common.Event} event
180 */ 180 */
181 _onBindingRemoved(event) { 181 _onBindingRemoved(event) {
182 var binding = /** @type {!WebInspector.PersistenceBinding} */ (event.data); 182 var binding = /** @type {!Persistence.PersistenceBinding} */ (event.data);
183 this._addUISourceCode(binding.network); 183 this._addUISourceCode(binding.network);
184 } 184 }
185 185
186 /** 186 /**
187 * @param {!WebInspector.Event} event 187 * @param {!Common.Event} event
188 */ 188 */
189 _onBindingChanged(event) { 189 _onBindingChanged(event) {
190 var binding = /** @type {!WebInspector.PersistenceBinding} */ (event.data); 190 var binding = /** @type {!Persistence.PersistenceBinding} */ (event.data);
191 191
192 // Update UISourceCode titles. 192 // Update UISourceCode titles.
193 var networkNode = this._uiSourceCodeNodes.get(binding.network); 193 var networkNode = this._uiSourceCodeNodes.get(binding.network);
194 if (networkNode) 194 if (networkNode)
195 networkNode.updateTitle(); 195 networkNode.updateTitle();
196 var fileSystemNode = this._uiSourceCodeNodes.get(binding.fileSystem); 196 var fileSystemNode = this._uiSourceCodeNodes.get(binding.fileSystem);
197 if (fileSystemNode) 197 if (fileSystemNode)
198 fileSystemNode.updateTitle(); 198 fileSystemNode.updateTitle();
199 199
200 // Update folder titles. 200 // Update folder titles.
201 var pathTokens = WebInspector.FileSystemWorkspaceBinding.relativePath(bindin g.fileSystem); 201 var pathTokens = Bindings.FileSystemWorkspaceBinding.relativePath(binding.fi leSystem);
202 var folderPath = ''; 202 var folderPath = '';
203 for (var i = 0; i < pathTokens.length - 1; ++i) { 203 for (var i = 0; i < pathTokens.length - 1; ++i) {
204 folderPath += pathTokens[i]; 204 folderPath += pathTokens[i];
205 var folderId = 205 var folderId =
206 this._folderNodeId(binding.fileSystem.project(), null, null, binding.f ileSystem.origin(), folderPath); 206 this._folderNodeId(binding.fileSystem.project(), null, null, binding.f ileSystem.origin(), folderPath);
207 var folderNode = this._subfolderNodes.get(folderId); 207 var folderNode = this._subfolderNodes.get(folderId);
208 if (folderNode) 208 if (folderNode)
209 folderNode.updateTitle(); 209 folderNode.updateTitle();
210 folderPath += '/'; 210 folderPath += '/';
211 } 211 }
212 212
213 // Update fileSystem root title. 213 // Update fileSystem root title.
214 var fileSystemRoot = this._rootNode.child(binding.fileSystem.project().id()) ; 214 var fileSystemRoot = this._rootNode.child(binding.fileSystem.project().id()) ;
215 if (fileSystemRoot) 215 if (fileSystemRoot)
216 fileSystemRoot.updateTitle(); 216 fileSystemRoot.updateTitle();
217 } 217 }
218 218
219 /** 219 /**
220 * @override 220 * @override
221 */ 221 */
222 focus() { 222 focus() {
223 this._scriptsTree.focus(); 223 this._scriptsTree.focus();
224 } 224 }
225 225
226 /** 226 /**
227 * @param {!WebInspector.Workspace} workspace 227 * @param {!Workspace.Workspace} workspace
228 */ 228 */
229 _resetWorkspace(workspace) { 229 _resetWorkspace(workspace) {
230 this._workspace = workspace; 230 this._workspace = workspace;
231 this._workspace.addEventListener(WebInspector.Workspace.Events.UISourceCodeA dded, this._uiSourceCodeAdded, this); 231 this._workspace.addEventListener(Workspace.Workspace.Events.UISourceCodeAdde d, this._uiSourceCodeAdded, this);
232 this._workspace.addEventListener( 232 this._workspace.addEventListener(
233 WebInspector.Workspace.Events.UISourceCodeRemoved, this._uiSourceCodeRem oved, this); 233 Workspace.Workspace.Events.UISourceCodeRemoved, this._uiSourceCodeRemove d, this);
234 this._workspace.addEventListener( 234 this._workspace.addEventListener(
235 WebInspector.Workspace.Events.ProjectRemoved, this._projectRemoved.bind( this), this); 235 Workspace.Workspace.Events.ProjectRemoved, this._projectRemoved.bind(thi s), this);
236 } 236 }
237 237
238 /** 238 /**
239 * @param {!WebInspector.UISourceCode} uiSourceCode 239 * @param {!Workspace.UISourceCode} uiSourceCode
240 * @return {boolean} 240 * @return {boolean}
241 */ 241 */
242 accept(uiSourceCode) { 242 accept(uiSourceCode) {
243 return !uiSourceCode.isFromServiceProject(); 243 return !uiSourceCode.isFromServiceProject();
244 } 244 }
245 245
246 /** 246 /**
247 * @param {!WebInspector.UISourceCode} uiSourceCode 247 * @param {!Workspace.UISourceCode} uiSourceCode
248 * @return {?WebInspector.ResourceTreeFrame} 248 * @return {?SDK.ResourceTreeFrame}
249 */ 249 */
250 _uiSourceCodeFrame(uiSourceCode) { 250 _uiSourceCodeFrame(uiSourceCode) {
251 var frame = WebInspector.NetworkProject.frameForProject(uiSourceCode.project ()); 251 var frame = Bindings.NetworkProject.frameForProject(uiSourceCode.project());
252 if (!frame) { 252 if (!frame) {
253 var target = WebInspector.NetworkProject.targetForProject(uiSourceCode.pro ject()); 253 var target = Bindings.NetworkProject.targetForProject(uiSourceCode.project ());
254 var resourceTreeModel = target && WebInspector.ResourceTreeModel.fromTarge t(target); 254 var resourceTreeModel = target && SDK.ResourceTreeModel.fromTarget(target) ;
255 frame = resourceTreeModel && resourceTreeModel.mainFrame; 255 frame = resourceTreeModel && resourceTreeModel.mainFrame;
256 } 256 }
257 return frame; 257 return frame;
258 } 258 }
259 259
260 /** 260 /**
261 * @param {!WebInspector.UISourceCode} uiSourceCode 261 * @param {!Workspace.UISourceCode} uiSourceCode
262 */ 262 */
263 _addUISourceCode(uiSourceCode) { 263 _addUISourceCode(uiSourceCode) {
264 if (!this.accept(uiSourceCode)) 264 if (!this.accept(uiSourceCode))
265 return; 265 return;
266 266
267 var binding = WebInspector.persistence.binding(uiSourceCode); 267 var binding = Persistence.persistence.binding(uiSourceCode);
268 if (!Runtime.experiments.isEnabled('persistence2') && binding && binding.net work === uiSourceCode) 268 if (!Runtime.experiments.isEnabled('persistence2') && binding && binding.net work === uiSourceCode)
269 return; 269 return;
270 270
271 var isFromSourceMap = uiSourceCode.contentType().isFromSourceMap(); 271 var isFromSourceMap = uiSourceCode.contentType().isFromSourceMap();
272 var path; 272 var path;
273 if (uiSourceCode.project().type() === WebInspector.projectTypes.FileSystem) 273 if (uiSourceCode.project().type() === Workspace.projectTypes.FileSystem)
274 path = WebInspector.FileSystemWorkspaceBinding.relativePath(uiSourceCode). slice(0, -1); 274 path = Bindings.FileSystemWorkspaceBinding.relativePath(uiSourceCode).slic e(0, -1);
275 else 275 else
276 path = WebInspector.ParsedURL.extractPath(uiSourceCode.url()).split('/').s lice(1, -1); 276 path = Common.ParsedURL.extractPath(uiSourceCode.url()).split('/').slice(1 , -1);
277 277
278 var project = uiSourceCode.project(); 278 var project = uiSourceCode.project();
279 var target = WebInspector.NetworkProject.targetForUISourceCode(uiSourceCode) ; 279 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode);
280 var frame = this._uiSourceCodeFrame(uiSourceCode); 280 var frame = this._uiSourceCodeFrame(uiSourceCode);
281 281
282 var folderNode = 282 var folderNode =
283 this._folderNode(uiSourceCode, project, target, frame, uiSourceCode.orig in(), path, isFromSourceMap); 283 this._folderNode(uiSourceCode, project, target, frame, uiSourceCode.orig in(), path, isFromSourceMap);
284 var uiSourceCodeNode = new WebInspector.NavigatorUISourceCodeTreeNode(this, uiSourceCode); 284 var uiSourceCodeNode = new Sources.NavigatorUISourceCodeTreeNode(this, uiSou rceCode);
285 this._uiSourceCodeNodes.set(uiSourceCode, uiSourceCodeNode); 285 this._uiSourceCodeNodes.set(uiSourceCode, uiSourceCodeNode);
286 folderNode.appendChild(uiSourceCodeNode); 286 folderNode.appendChild(uiSourceCodeNode);
287 this.uiSourceCodeAdded(uiSourceCode); 287 this.uiSourceCodeAdded(uiSourceCode);
288 } 288 }
289 289
290 /** 290 /**
291 * @param {!WebInspector.UISourceCode} uiSourceCode 291 * @param {!Workspace.UISourceCode} uiSourceCode
292 */ 292 */
293 uiSourceCodeAdded(uiSourceCode) { 293 uiSourceCodeAdded(uiSourceCode) {
294 } 294 }
295 295
296 /** 296 /**
297 * @param {!WebInspector.Event} event 297 * @param {!Common.Event} event
298 */ 298 */
299 _uiSourceCodeAdded(event) { 299 _uiSourceCodeAdded(event) {
300 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data); 300 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (event.data);
301 this._addUISourceCode(uiSourceCode); 301 this._addUISourceCode(uiSourceCode);
302 } 302 }
303 303
304 /** 304 /**
305 * @param {!WebInspector.Event} event 305 * @param {!Common.Event} event
306 */ 306 */
307 _uiSourceCodeRemoved(event) { 307 _uiSourceCodeRemoved(event) {
308 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data); 308 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (event.data);
309 this._removeUISourceCode(uiSourceCode); 309 this._removeUISourceCode(uiSourceCode);
310 } 310 }
311 311
312 /** 312 /**
313 * @param {!WebInspector.Event} event 313 * @param {!Common.Event} event
314 */ 314 */
315 _projectRemoved(event) { 315 _projectRemoved(event) {
316 var project = /** @type {!WebInspector.Project} */ (event.data); 316 var project = /** @type {!Workspace.Project} */ (event.data);
317 317
318 var frame = WebInspector.NetworkProject.frameForProject(project); 318 var frame = Bindings.NetworkProject.frameForProject(project);
319 if (frame) 319 if (frame)
320 this._discardFrame(frame); 320 this._discardFrame(frame);
321 321
322 var uiSourceCodes = project.uiSourceCodes(); 322 var uiSourceCodes = project.uiSourceCodes();
323 for (var i = 0; i < uiSourceCodes.length; ++i) 323 for (var i = 0; i < uiSourceCodes.length; ++i)
324 this._removeUISourceCode(uiSourceCodes[i]); 324 this._removeUISourceCode(uiSourceCodes[i]);
325 } 325 }
326 326
327 /** 327 /**
328 * @param {!WebInspector.Project} project 328 * @param {!Workspace.Project} project
329 * @param {?WebInspector.Target} target 329 * @param {?SDK.Target} target
330 * @param {?WebInspector.ResourceTreeFrame} frame 330 * @param {?SDK.ResourceTreeFrame} frame
331 * @param {string} projectOrigin 331 * @param {string} projectOrigin
332 * @param {string} path 332 * @param {string} path
333 * @return {string} 333 * @return {string}
334 */ 334 */
335 _folderNodeId(project, target, frame, projectOrigin, path) { 335 _folderNodeId(project, target, frame, projectOrigin, path) {
336 var targetId = target ? target.id() : ''; 336 var targetId = target ? target.id() : '';
337 var projectId = project.type() === WebInspector.projectTypes.FileSystem ? pr oject.id() : ''; 337 var projectId = project.type() === Workspace.projectTypes.FileSystem ? proje ct.id() : '';
338 var frameId = this._groupByFrame && frame ? frame.id : ''; 338 var frameId = this._groupByFrame && frame ? frame.id : '';
339 return targetId + ':' + projectId + ':' + frameId + ':' + projectOrigin + ': ' + path; 339 return targetId + ':' + projectId + ':' + frameId + ':' + projectOrigin + ': ' + path;
340 } 340 }
341 341
342 /** 342 /**
343 * @param {!WebInspector.UISourceCode} uiSourceCode 343 * @param {!Workspace.UISourceCode} uiSourceCode
344 * @param {!WebInspector.Project} project 344 * @param {!Workspace.Project} project
345 * @param {?WebInspector.Target} target 345 * @param {?SDK.Target} target
346 * @param {?WebInspector.ResourceTreeFrame} frame 346 * @param {?SDK.ResourceTreeFrame} frame
347 * @param {string} projectOrigin 347 * @param {string} projectOrigin
348 * @param {!Array<string>} path 348 * @param {!Array<string>} path
349 * @param {boolean} fromSourceMap 349 * @param {boolean} fromSourceMap
350 * @return {!WebInspector.NavigatorTreeNode} 350 * @return {!Sources.NavigatorTreeNode}
351 */ 351 */
352 _folderNode(uiSourceCode, project, target, frame, projectOrigin, path, fromSou rceMap) { 352 _folderNode(uiSourceCode, project, target, frame, projectOrigin, path, fromSou rceMap) {
353 if (project.type() === WebInspector.projectTypes.Snippets) 353 if (project.type() === Workspace.projectTypes.Snippets)
354 return this._rootNode; 354 return this._rootNode;
355 355
356 if (target && !this._groupByFolder && !fromSourceMap) 356 if (target && !this._groupByFolder && !fromSourceMap)
357 return this._domainNode(uiSourceCode, project, target, frame, projectOrigi n); 357 return this._domainNode(uiSourceCode, project, target, frame, projectOrigi n);
358 358
359 var folderPath = path.join('/'); 359 var folderPath = path.join('/');
360 var folderId = this._folderNodeId(project, target, frame, projectOrigin, fol derPath); 360 var folderId = this._folderNodeId(project, target, frame, projectOrigin, fol derPath);
361 var folderNode = this._subfolderNodes.get(folderId); 361 var folderNode = this._subfolderNodes.get(folderId);
362 if (folderNode) 362 if (folderNode)
363 return folderNode; 363 return folderNode;
364 364
365 if (!path.length) { 365 if (!path.length) {
366 if (target) 366 if (target)
367 return this._domainNode(uiSourceCode, project, target, frame, projectOri gin); 367 return this._domainNode(uiSourceCode, project, target, frame, projectOri gin);
368 var fileSystemNode = this._rootNode.child(project.id()); 368 var fileSystemNode = this._rootNode.child(project.id());
369 if (!fileSystemNode) { 369 if (!fileSystemNode) {
370 fileSystemNode = new WebInspector.NavigatorGroupTreeNode( 370 fileSystemNode = new Sources.NavigatorGroupTreeNode(
371 this, project, project.id(), WebInspector.NavigatorView.Types.FileSy stem, project.displayName()); 371 this, project, project.id(), Sources.NavigatorView.Types.FileSystem, project.displayName());
372 this._rootNode.appendChild(fileSystemNode); 372 this._rootNode.appendChild(fileSystemNode);
373 } 373 }
374 return fileSystemNode; 374 return fileSystemNode;
375 } 375 }
376 376
377 var parentNode = 377 var parentNode =
378 this._folderNode(uiSourceCode, project, target, frame, projectOrigin, pa th.slice(0, -1), fromSourceMap); 378 this._folderNode(uiSourceCode, project, target, frame, projectOrigin, pa th.slice(0, -1), fromSourceMap);
379 var type = fromSourceMap ? WebInspector.NavigatorView.Types.SourceMapFolder : 379 var type = fromSourceMap ? Sources.NavigatorView.Types.SourceMapFolder :
380 WebInspector.NavigatorView.Types.NetworkFolder; 380 Sources.NavigatorView.Types.NetworkFolder;
381 if (project.type() === WebInspector.projectTypes.FileSystem) 381 if (project.type() === Workspace.projectTypes.FileSystem)
382 type = WebInspector.NavigatorView.Types.FileSystemFolder; 382 type = Sources.NavigatorView.Types.FileSystemFolder;
383 var name = path[path.length - 1]; 383 var name = path[path.length - 1];
384 384
385 folderNode = new WebInspector.NavigatorFolderTreeNode(this, project, folderI d, type, folderPath, name); 385 folderNode = new Sources.NavigatorFolderTreeNode(this, project, folderId, ty pe, folderPath, name);
386 this._subfolderNodes.set(folderId, folderNode); 386 this._subfolderNodes.set(folderId, folderNode);
387 parentNode.appendChild(folderNode); 387 parentNode.appendChild(folderNode);
388 return folderNode; 388 return folderNode;
389 } 389 }
390 390
391 /** 391 /**
392 * @param {!WebInspector.UISourceCode} uiSourceCode 392 * @param {!Workspace.UISourceCode} uiSourceCode
393 * @param {!WebInspector.Project} project 393 * @param {!Workspace.Project} project
394 * @param {!WebInspector.Target} target 394 * @param {!SDK.Target} target
395 * @param {?WebInspector.ResourceTreeFrame} frame 395 * @param {?SDK.ResourceTreeFrame} frame
396 * @param {string} projectOrigin 396 * @param {string} projectOrigin
397 * @return {!WebInspector.NavigatorTreeNode} 397 * @return {!Sources.NavigatorTreeNode}
398 */ 398 */
399 _domainNode(uiSourceCode, project, target, frame, projectOrigin) { 399 _domainNode(uiSourceCode, project, target, frame, projectOrigin) {
400 var frameNode = this._frameNode(project, target, frame); 400 var frameNode = this._frameNode(project, target, frame);
401 if (!this._groupByDomain) 401 if (!this._groupByDomain)
402 return frameNode; 402 return frameNode;
403 var domainNode = frameNode.child(projectOrigin); 403 var domainNode = frameNode.child(projectOrigin);
404 if (domainNode) 404 if (domainNode)
405 return domainNode; 405 return domainNode;
406 406
407 domainNode = new WebInspector.NavigatorGroupTreeNode( 407 domainNode = new Sources.NavigatorGroupTreeNode(
408 this, project, projectOrigin, WebInspector.NavigatorView.Types.Domain, 408 this, project, projectOrigin, Sources.NavigatorView.Types.Domain,
409 this._computeProjectDisplayName(target, projectOrigin)); 409 this._computeProjectDisplayName(target, projectOrigin));
410 if (frame && projectOrigin === WebInspector.ParsedURL.extractOrigin(frame.ur l)) 410 if (frame && projectOrigin === Common.ParsedURL.extractOrigin(frame.url))
411 domainNode.treeNode()._boostOrder = true; 411 domainNode.treeNode()._boostOrder = true;
412 frameNode.appendChild(domainNode); 412 frameNode.appendChild(domainNode);
413 return domainNode; 413 return domainNode;
414 } 414 }
415 415
416 /** 416 /**
417 * @param {!WebInspector.Project} project 417 * @param {!Workspace.Project} project
418 * @param {!WebInspector.Target} target 418 * @param {!SDK.Target} target
419 * @param {?WebInspector.ResourceTreeFrame} frame 419 * @param {?SDK.ResourceTreeFrame} frame
420 * @return {!WebInspector.NavigatorTreeNode} 420 * @return {!Sources.NavigatorTreeNode}
421 */ 421 */
422 _frameNode(project, target, frame) { 422 _frameNode(project, target, frame) {
423 if (!this._groupByFrame || !frame) 423 if (!this._groupByFrame || !frame)
424 return this._targetNode(project, target); 424 return this._targetNode(project, target);
425 425
426 var frameNode = this._frameNodes.get(frame); 426 var frameNode = this._frameNodes.get(frame);
427 if (frameNode) 427 if (frameNode)
428 return frameNode; 428 return frameNode;
429 429
430 frameNode = new WebInspector.NavigatorGroupTreeNode( 430 frameNode = new Sources.NavigatorGroupTreeNode(
431 this, project, target.id() + ':' + frame.id, WebInspector.NavigatorView. Types.Frame, frame.displayName()); 431 this, project, target.id() + ':' + frame.id, Sources.NavigatorView.Types .Frame, frame.displayName());
432 frameNode.setHoverCallback(hoverCallback); 432 frameNode.setHoverCallback(hoverCallback);
433 this._frameNodes.set(frame, frameNode); 433 this._frameNodes.set(frame, frameNode);
434 this._frameNode(project, target, frame.parentFrame).appendChild(frameNode); 434 this._frameNode(project, target, frame.parentFrame).appendChild(frameNode);
435 if (!frame.parentFrame) 435 if (!frame.parentFrame)
436 frameNode.treeNode()._boostOrder = true; 436 frameNode.treeNode()._boostOrder = true;
437 437
438 /** 438 /**
439 * @param {boolean} hovered 439 * @param {boolean} hovered
440 */ 440 */
441 function hoverCallback(hovered) { 441 function hoverCallback(hovered) {
442 if (hovered) { 442 if (hovered) {
443 var domModel = WebInspector.DOMModel.fromTarget(target); 443 var domModel = SDK.DOMModel.fromTarget(target);
444 if (domModel) 444 if (domModel)
445 domModel.highlightFrame(frame.id); 445 domModel.highlightFrame(frame.id);
446 } else { 446 } else {
447 WebInspector.DOMModel.hideDOMNodeHighlight(); 447 SDK.DOMModel.hideDOMNodeHighlight();
448 } 448 }
449 } 449 }
450 return frameNode; 450 return frameNode;
451 } 451 }
452 452
453 /** 453 /**
454 * @param {!WebInspector.Project} project 454 * @param {!Workspace.Project} project
455 * @param {!WebInspector.Target} target 455 * @param {!SDK.Target} target
456 * @return {!WebInspector.NavigatorTreeNode} 456 * @return {!Sources.NavigatorTreeNode}
457 */ 457 */
458 _targetNode(project, target) { 458 _targetNode(project, target) {
459 if (target === WebInspector.targetManager.mainTarget()) 459 if (target === SDK.targetManager.mainTarget())
460 return this._rootNode; 460 return this._rootNode;
461 461
462 var targetNode = this._rootNode.child('target:' + target.id()); 462 var targetNode = this._rootNode.child('target:' + target.id());
463 if (!targetNode) { 463 if (!targetNode) {
464 targetNode = new WebInspector.NavigatorGroupTreeNode( 464 targetNode = new Sources.NavigatorGroupTreeNode(
465 this, project, 'target:' + target.id(), 465 this, project, 'target:' + target.id(),
466 !target.hasBrowserCapability() ? WebInspector.NavigatorView.Types.Work er : 466 !target.hasBrowserCapability() ? Sources.NavigatorView.Types.Worker :
467 WebInspector.NavigatorView.Types.Netw orkFolder, 467 Sources.NavigatorView.Types.NetworkFo lder,
468 target.name()); 468 target.name());
469 this._rootNode.appendChild(targetNode); 469 this._rootNode.appendChild(targetNode);
470 } 470 }
471 return targetNode; 471 return targetNode;
472 } 472 }
473 473
474 /** 474 /**
475 * @param {!WebInspector.Target} target 475 * @param {!SDK.Target} target
476 * @param {string} projectOrigin 476 * @param {string} projectOrigin
477 * @return {string} 477 * @return {string}
478 */ 478 */
479 _computeProjectDisplayName(target, projectOrigin) { 479 _computeProjectDisplayName(target, projectOrigin) {
480 for (var context of target.runtimeModel.executionContexts()) { 480 for (var context of target.runtimeModel.executionContexts()) {
481 if (context.name && context.origin && projectOrigin.startsWith(context.ori gin)) 481 if (context.name && context.origin && projectOrigin.startsWith(context.ori gin))
482 return context.name; 482 return context.name;
483 } 483 }
484 484
485 if (!projectOrigin) 485 if (!projectOrigin)
486 return WebInspector.UIString('(no domain)'); 486 return Common.UIString('(no domain)');
487 487
488 var parsedURL = new WebInspector.ParsedURL(projectOrigin); 488 var parsedURL = new Common.ParsedURL(projectOrigin);
489 var prettyURL = parsedURL.isValid ? parsedURL.host + (parsedURL.port ? (':' + parsedURL.port) : '') : ''; 489 var prettyURL = parsedURL.isValid ? parsedURL.host + (parsedURL.port ? (':' + parsedURL.port) : '') : '';
490 490
491 return (prettyURL || projectOrigin); 491 return (prettyURL || projectOrigin);
492 } 492 }
493 493
494 /** 494 /**
495 * @param {!WebInspector.UISourceCode} uiSourceCode 495 * @param {!Workspace.UISourceCode} uiSourceCode
496 * @param {boolean=} select 496 * @param {boolean=} select
497 */ 497 */
498 revealUISourceCode(uiSourceCode, select) { 498 revealUISourceCode(uiSourceCode, select) {
499 var node = this._uiSourceCodeNodes.get(uiSourceCode); 499 var node = this._uiSourceCodeNodes.get(uiSourceCode);
500 if (!node) 500 if (!node)
501 return; 501 return;
502 if (this._scriptsTree.selectedTreeElement) 502 if (this._scriptsTree.selectedTreeElement)
503 this._scriptsTree.selectedTreeElement.deselect(); 503 this._scriptsTree.selectedTreeElement.deselect();
504 this._lastSelectedUISourceCode = uiSourceCode; 504 this._lastSelectedUISourceCode = uiSourceCode;
505 node.reveal(select); 505 node.reveal(select);
506 } 506 }
507 507
508 /** 508 /**
509 * @param {!WebInspector.UISourceCode} uiSourceCode 509 * @param {!Workspace.UISourceCode} uiSourceCode
510 * @param {boolean} focusSource 510 * @param {boolean} focusSource
511 */ 511 */
512 _sourceSelected(uiSourceCode, focusSource) { 512 _sourceSelected(uiSourceCode, focusSource) {
513 this._lastSelectedUISourceCode = uiSourceCode; 513 this._lastSelectedUISourceCode = uiSourceCode;
514 WebInspector.Revealer.reveal(uiSourceCode, !focusSource); 514 Common.Revealer.reveal(uiSourceCode, !focusSource);
515 } 515 }
516 516
517 /** 517 /**
518 * @param {!WebInspector.UISourceCode} uiSourceCode 518 * @param {!Workspace.UISourceCode} uiSourceCode
519 */ 519 */
520 sourceDeleted(uiSourceCode) { 520 sourceDeleted(uiSourceCode) {
521 } 521 }
522 522
523 /** 523 /**
524 * @param {!WebInspector.UISourceCode} uiSourceCode 524 * @param {!Workspace.UISourceCode} uiSourceCode
525 */ 525 */
526 _removeUISourceCode(uiSourceCode) { 526 _removeUISourceCode(uiSourceCode) {
527 var node = this._uiSourceCodeNodes.get(uiSourceCode); 527 var node = this._uiSourceCodeNodes.get(uiSourceCode);
528 if (!node) 528 if (!node)
529 return; 529 return;
530 530
531 var project = uiSourceCode.project(); 531 var project = uiSourceCode.project();
532 var target = WebInspector.NetworkProject.targetForUISourceCode(uiSourceCode) ; 532 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode);
533 var frame = this._uiSourceCodeFrame(uiSourceCode); 533 var frame = this._uiSourceCodeFrame(uiSourceCode);
534 534
535 var parentNode = node.parent; 535 var parentNode = node.parent;
536 this._uiSourceCodeNodes.delete(uiSourceCode); 536 this._uiSourceCodeNodes.delete(uiSourceCode);
537 parentNode.removeChild(node); 537 parentNode.removeChild(node);
538 node = parentNode; 538 node = parentNode;
539 539
540 while (node) { 540 while (node) {
541 parentNode = node.parent; 541 parentNode = node.parent;
542 if (!parentNode || !node.isEmpty()) 542 if (!parentNode || !node.isEmpty())
543 break; 543 break;
544 if (!(node instanceof WebInspector.NavigatorGroupTreeNode || 544 if (!(node instanceof Sources.NavigatorGroupTreeNode ||
545 node instanceof WebInspector.NavigatorFolderTreeNode)) 545 node instanceof Sources.NavigatorFolderTreeNode))
546 break; 546 break;
547 if (node._type === WebInspector.NavigatorView.Types.Frame) 547 if (node._type === Sources.NavigatorView.Types.Frame)
548 break; 548 break;
549 549
550 var folderId = this._folderNodeId(project, target, frame, uiSourceCode.ori gin(), node._folderPath); 550 var folderId = this._folderNodeId(project, target, frame, uiSourceCode.ori gin(), node._folderPath);
551 this._subfolderNodes.delete(folderId); 551 this._subfolderNodes.delete(folderId);
552 parentNode.removeChild(node); 552 parentNode.removeChild(node);
553 node = parentNode; 553 node = parentNode;
554 } 554 }
555 } 555 }
556 556
557 reset() { 557 reset() {
558 var nodes = this._uiSourceCodeNodes.valuesArray(); 558 var nodes = this._uiSourceCodeNodes.valuesArray();
559 for (var i = 0; i < nodes.length; ++i) 559 for (var i = 0; i < nodes.length; ++i)
560 nodes[i].dispose(); 560 nodes[i].dispose();
561 561
562 this._scriptsTree.removeChildren(); 562 this._scriptsTree.removeChildren();
563 this._uiSourceCodeNodes.clear(); 563 this._uiSourceCodeNodes.clear();
564 this._subfolderNodes.clear(); 564 this._subfolderNodes.clear();
565 this._frameNodes.clear(); 565 this._frameNodes.clear();
566 this._rootNode.reset(); 566 this._rootNode.reset();
567 } 567 }
568 568
569 /** 569 /**
570 * @param {!Event} event 570 * @param {!Event} event
571 */ 571 */
572 handleContextMenu(event) { 572 handleContextMenu(event) {
573 } 573 }
574 574
575 /** 575 /**
576 * @param {!WebInspector.Project} project 576 * @param {!Workspace.Project} project
577 * @param {string} path 577 * @param {string} path
578 * @param {!WebInspector.UISourceCode=} uiSourceCode 578 * @param {!Workspace.UISourceCode=} uiSourceCode
579 */ 579 */
580 _handleContextMenuCreate(project, path, uiSourceCode) { 580 _handleContextMenuCreate(project, path, uiSourceCode) {
581 this.create(project, path, uiSourceCode); 581 this.create(project, path, uiSourceCode);
582 } 582 }
583 583
584 /** 584 /**
585 * @param {!WebInspector.UISourceCode} uiSourceCode 585 * @param {!Workspace.UISourceCode} uiSourceCode
586 */ 586 */
587 _handleContextMenuRename(uiSourceCode) { 587 _handleContextMenuRename(uiSourceCode) {
588 this.rename(uiSourceCode, false); 588 this.rename(uiSourceCode, false);
589 } 589 }
590 590
591 /** 591 /**
592 * @param {!WebInspector.Project} project 592 * @param {!Workspace.Project} project
593 * @param {string} path 593 * @param {string} path
594 */ 594 */
595 _handleContextMenuExclude(project, path) { 595 _handleContextMenuExclude(project, path) {
596 var shouldExclude = window.confirm(WebInspector.UIString('Are you sure you w ant to exclude this folder?')); 596 var shouldExclude = window.confirm(Common.UIString('Are you sure you want to exclude this folder?'));
597 if (shouldExclude) { 597 if (shouldExclude) {
598 WebInspector.startBatchUpdate(); 598 UI.startBatchUpdate();
599 project.excludeFolder(WebInspector.FileSystemWorkspaceBinding.completeURL( project, path)); 599 project.excludeFolder(Bindings.FileSystemWorkspaceBinding.completeURL(proj ect, path));
600 WebInspector.endBatchUpdate(); 600 UI.endBatchUpdate();
601 } 601 }
602 } 602 }
603 603
604 /** 604 /**
605 * @param {!WebInspector.UISourceCode} uiSourceCode 605 * @param {!Workspace.UISourceCode} uiSourceCode
606 */ 606 */
607 _handleContextMenuDelete(uiSourceCode) { 607 _handleContextMenuDelete(uiSourceCode) {
608 var shouldDelete = window.confirm(WebInspector.UIString('Are you sure you wa nt to delete this file?')); 608 var shouldDelete = window.confirm(Common.UIString('Are you sure you want to delete this file?'));
609 if (shouldDelete) 609 if (shouldDelete)
610 uiSourceCode.project().deleteFile(uiSourceCode.url()); 610 uiSourceCode.project().deleteFile(uiSourceCode.url());
611 } 611 }
612 612
613 /** 613 /**
614 * @param {!Event} event 614 * @param {!Event} event
615 * @param {!WebInspector.UISourceCode} uiSourceCode 615 * @param {!Workspace.UISourceCode} uiSourceCode
616 */ 616 */
617 handleFileContextMenu(event, uiSourceCode) { 617 handleFileContextMenu(event, uiSourceCode) {
618 var contextMenu = new WebInspector.ContextMenu(event); 618 var contextMenu = new UI.ContextMenu(event);
619 contextMenu.appendApplicableItems(uiSourceCode); 619 contextMenu.appendApplicableItems(uiSourceCode);
620 contextMenu.appendSeparator(); 620 contextMenu.appendSeparator();
621 621
622 var project = uiSourceCode.project(); 622 var project = uiSourceCode.project();
623 if (project.type() === WebInspector.projectTypes.FileSystem) { 623 if (project.type() === Workspace.projectTypes.FileSystem) {
624 var parentURL = uiSourceCode.parentURL(); 624 var parentURL = uiSourceCode.parentURL();
625 contextMenu.appendItem( 625 contextMenu.appendItem(
626 WebInspector.UIString('Rename\u2026'), this._handleContextMenuRename.b ind(this, uiSourceCode)); 626 Common.UIString('Rename\u2026'), this._handleContextMenuRename.bind(th is, uiSourceCode));
627 contextMenu.appendItem( 627 contextMenu.appendItem(
628 WebInspector.UIString('Make a copy\u2026'), 628 Common.UIString('Make a copy\u2026'),
629 this._handleContextMenuCreate.bind(this, project, parentURL, uiSourceC ode)); 629 this._handleContextMenuCreate.bind(this, project, parentURL, uiSourceC ode));
630 contextMenu.appendItem(WebInspector.UIString('Delete'), this._handleContex tMenuDelete.bind(this, uiSourceCode)); 630 contextMenu.appendItem(Common.UIString('Delete'), this._handleContextMenuD elete.bind(this, uiSourceCode));
631 contextMenu.appendSeparator(); 631 contextMenu.appendSeparator();
632 } 632 }
633 633
634 contextMenu.show(); 634 contextMenu.show();
635 } 635 }
636 636
637 /** 637 /**
638 * @param {!Event} event 638 * @param {!Event} event
639 * @param {!WebInspector.NavigatorFolderTreeNode} node 639 * @param {!Sources.NavigatorFolderTreeNode} node
640 */ 640 */
641 handleFolderContextMenu(event, node) { 641 handleFolderContextMenu(event, node) {
642 var path = node._folderPath; 642 var path = node._folderPath;
643 var project = node._project; 643 var project = node._project;
644 644
645 var contextMenu = new WebInspector.ContextMenu(event); 645 var contextMenu = new UI.ContextMenu(event);
646 646
647 WebInspector.NavigatorView.appendSearchItem(contextMenu, path); 647 Sources.NavigatorView.appendSearchItem(contextMenu, path);
648 contextMenu.appendSeparator(); 648 contextMenu.appendSeparator();
649 649
650 if (project.type() !== WebInspector.projectTypes.FileSystem) 650 if (project.type() !== Workspace.projectTypes.FileSystem)
651 return; 651 return;
652 652
653 contextMenu.appendItem(WebInspector.UIString('New file'), this._handleContex tMenuCreate.bind(this, project, path)); 653 contextMenu.appendItem(Common.UIString('New file'), this._handleContextMenuC reate.bind(this, project, path));
654 contextMenu.appendItem( 654 contextMenu.appendItem(
655 WebInspector.UIString('Exclude folder'), this._handleContextMenuExclude. bind(this, project, path)); 655 Common.UIString('Exclude folder'), this._handleContextMenuExclude.bind(t his, project, path));
656 656
657 function removeFolder() { 657 function removeFolder() {
658 var shouldRemove = window.confirm(WebInspector.UIString('Are you sure you want to remove this folder?')); 658 var shouldRemove = window.confirm(Common.UIString('Are you sure you want t o remove this folder?'));
659 if (shouldRemove) 659 if (shouldRemove)
660 project.remove(); 660 project.remove();
661 } 661 }
662 662
663 contextMenu.appendSeparator(); 663 contextMenu.appendSeparator();
664 WebInspector.NavigatorView.appendAddFolderItem(contextMenu); 664 Sources.NavigatorView.appendAddFolderItem(contextMenu);
665 if (node instanceof WebInspector.NavigatorGroupTreeNode) 665 if (node instanceof Sources.NavigatorGroupTreeNode)
666 contextMenu.appendItem(WebInspector.UIString('Remove folder from workspace '), removeFolder); 666 contextMenu.appendItem(Common.UIString('Remove folder from workspace'), re moveFolder);
667 667
668 contextMenu.show(); 668 contextMenu.show();
669 } 669 }
670 670
671 /** 671 /**
672 * @param {!WebInspector.UISourceCode} uiSourceCode 672 * @param {!Workspace.UISourceCode} uiSourceCode
673 * @param {boolean} deleteIfCanceled 673 * @param {boolean} deleteIfCanceled
674 */ 674 */
675 rename(uiSourceCode, deleteIfCanceled) { 675 rename(uiSourceCode, deleteIfCanceled) {
676 var node = this._uiSourceCodeNodes.get(uiSourceCode); 676 var node = this._uiSourceCodeNodes.get(uiSourceCode);
677 console.assert(node); 677 console.assert(node);
678 node.rename(callback.bind(this)); 678 node.rename(callback.bind(this));
679 679
680 /** 680 /**
681 * @this {WebInspector.NavigatorView} 681 * @this {Sources.NavigatorView}
682 * @param {boolean} committed 682 * @param {boolean} committed
683 */ 683 */
684 function callback(committed) { 684 function callback(committed) {
685 if (!committed) { 685 if (!committed) {
686 if (deleteIfCanceled) 686 if (deleteIfCanceled)
687 uiSourceCode.remove(); 687 uiSourceCode.remove();
688 return; 688 return;
689 } 689 }
690 690
691 this._sourceSelected(uiSourceCode, true); 691 this._sourceSelected(uiSourceCode, true);
692 } 692 }
693 } 693 }
694 694
695 /** 695 /**
696 * @param {!WebInspector.Project} project 696 * @param {!Workspace.Project} project
697 * @param {string} path 697 * @param {string} path
698 * @param {!WebInspector.UISourceCode=} uiSourceCodeToCopy 698 * @param {!Workspace.UISourceCode=} uiSourceCodeToCopy
699 */ 699 */
700 create(project, path, uiSourceCodeToCopy) { 700 create(project, path, uiSourceCodeToCopy) {
701 var filePath; 701 var filePath;
702 var uiSourceCode; 702 var uiSourceCode;
703 703
704 /** 704 /**
705 * @this {WebInspector.NavigatorView} 705 * @this {Sources.NavigatorView}
706 * @param {?string} content 706 * @param {?string} content
707 */ 707 */
708 function contentLoaded(content) { 708 function contentLoaded(content) {
709 createFile.call(this, content || ''); 709 createFile.call(this, content || '');
710 } 710 }
711 711
712 if (uiSourceCodeToCopy) 712 if (uiSourceCodeToCopy)
713 uiSourceCodeToCopy.requestContent().then(contentLoaded.bind(this)); 713 uiSourceCodeToCopy.requestContent().then(contentLoaded.bind(this));
714 else 714 else
715 createFile.call(this); 715 createFile.call(this);
716 716
717 /** 717 /**
718 * @this {WebInspector.NavigatorView} 718 * @this {Sources.NavigatorView}
719 * @param {string=} content 719 * @param {string=} content
720 */ 720 */
721 function createFile(content) { 721 function createFile(content) {
722 project.createFile(path, null, content || '', fileCreated.bind(this)); 722 project.createFile(path, null, content || '', fileCreated.bind(this));
723 } 723 }
724 724
725 /** 725 /**
726 * @this {WebInspector.NavigatorView} 726 * @this {Sources.NavigatorView}
727 * @param {?WebInspector.UISourceCode} uiSourceCode 727 * @param {?Workspace.UISourceCode} uiSourceCode
728 */ 728 */
729 function fileCreated(uiSourceCode) { 729 function fileCreated(uiSourceCode) {
730 if (!uiSourceCode) 730 if (!uiSourceCode)
731 return; 731 return;
732 this._sourceSelected(uiSourceCode, false); 732 this._sourceSelected(uiSourceCode, false);
733 this.revealUISourceCode(uiSourceCode, true); 733 this.revealUISourceCode(uiSourceCode, true);
734 this.rename(uiSourceCode, true); 734 this.rename(uiSourceCode, true);
735 } 735 }
736 } 736 }
737 737
738 _groupingChanged() { 738 _groupingChanged() {
739 this.reset(); 739 this.reset();
740 this._initGrouping(); 740 this._initGrouping();
741 this._workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this)); 741 this._workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this));
742 } 742 }
743 743
744 _initGrouping() { 744 _initGrouping() {
745 this._groupByFrame = true; 745 this._groupByFrame = true;
746 this._groupByDomain = this._navigatorGroupByFolderSetting.get(); 746 this._groupByDomain = this._navigatorGroupByFolderSetting.get();
747 this._groupByFolder = this._groupByDomain; 747 this._groupByFolder = this._groupByDomain;
748 } 748 }
749 749
750 _resetForTest() { 750 _resetForTest() {
751 this.reset(); 751 this.reset();
752 this._workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this)); 752 this._workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this));
753 } 753 }
754 754
755 /** 755 /**
756 * @param {!WebInspector.Event} event 756 * @param {!Common.Event} event
757 */ 757 */
758 _frameNavigated(event) { 758 _frameNavigated(event) {
759 var frame = /** @type {!WebInspector.ResourceTreeFrame} */ (event.data); 759 var frame = /** @type {!SDK.ResourceTreeFrame} */ (event.data);
760 var node = this._frameNodes.get(frame); 760 var node = this._frameNodes.get(frame);
761 if (!node) 761 if (!node)
762 return; 762 return;
763 763
764 node.treeNode().title = frame.displayName(); 764 node.treeNode().title = frame.displayName();
765 for (var child of frame.childFrames) 765 for (var child of frame.childFrames)
766 this._discardFrame(child); 766 this._discardFrame(child);
767 } 767 }
768 768
769 /** 769 /**
770 * @param {!WebInspector.Event} event 770 * @param {!Common.Event} event
771 */ 771 */
772 _frameDetached(event) { 772 _frameDetached(event) {
773 var frame = /** @type {!WebInspector.ResourceTreeFrame} */ (event.data); 773 var frame = /** @type {!SDK.ResourceTreeFrame} */ (event.data);
774 this._discardFrame(frame); 774 this._discardFrame(frame);
775 } 775 }
776 776
777 /** 777 /**
778 * @param {!WebInspector.ResourceTreeFrame} frame 778 * @param {!SDK.ResourceTreeFrame} frame
779 */ 779 */
780 _discardFrame(frame) { 780 _discardFrame(frame) {
781 var node = this._frameNodes.get(frame); 781 var node = this._frameNodes.get(frame);
782 if (!node) 782 if (!node)
783 return; 783 return;
784 784
785 if (node.parent) 785 if (node.parent)
786 node.parent.removeChild(node); 786 node.parent.removeChild(node);
787 this._frameNodes.delete(frame); 787 this._frameNodes.delete(frame);
788 for (var child of frame.childFrames) 788 for (var child of frame.childFrames)
789 this._discardFrame(child); 789 this._discardFrame(child);
790 } 790 }
791 791
792 /** 792 /**
793 * @override 793 * @override
794 * @param {!WebInspector.Target} target 794 * @param {!SDK.Target} target
795 */ 795 */
796 targetAdded(target) { 796 targetAdded(target) {
797 } 797 }
798 798
799 /** 799 /**
800 * @override 800 * @override
801 * @param {!WebInspector.Target} target 801 * @param {!SDK.Target} target
802 */ 802 */
803 targetRemoved(target) { 803 targetRemoved(target) {
804 var targetNode = this._rootNode.child('target:' + target.id()); 804 var targetNode = this._rootNode.child('target:' + target.id());
805 if (targetNode) 805 if (targetNode)
806 this._rootNode.removeChild(targetNode); 806 this._rootNode.removeChild(targetNode);
807 } 807 }
808 808
809 /** 809 /**
810 * @param {!WebInspector.Event} event 810 * @param {!Common.Event} event
811 */ 811 */
812 _targetNameChanged(event) { 812 _targetNameChanged(event) {
813 var target = /** @type {!WebInspector.Target} */ (event.data); 813 var target = /** @type {!SDK.Target} */ (event.data);
814 var targetNode = this._rootNode.child('target:' + target.id()); 814 var targetNode = this._rootNode.child('target:' + target.id());
815 if (targetNode) 815 if (targetNode)
816 targetNode.setTitle(target.name()); 816 targetNode.setTitle(target.name());
817 } 817 }
818 }; 818 };
819 819
820 WebInspector.NavigatorView.Types = { 820 Sources.NavigatorView.Types = {
821 Category: 'category', 821 Category: 'category',
822 Domain: 'domain', 822 Domain: 'domain',
823 File: 'file', 823 File: 'file',
824 FileSystem: 'fs', 824 FileSystem: 'fs',
825 FileSystemFolder: 'fs-folder', 825 FileSystemFolder: 'fs-folder',
826 Frame: 'frame', 826 Frame: 'frame',
827 NetworkFolder: 'nw-folder', 827 NetworkFolder: 'nw-folder',
828 Root: 'root', 828 Root: 'root',
829 SourceMapFolder: 'sm-folder', 829 SourceMapFolder: 'sm-folder',
830 Worker: 'worker' 830 Worker: 'worker'
831 }; 831 };
832 832
833 833
834 /** 834 /**
835 * @unrestricted 835 * @unrestricted
836 */ 836 */
837 WebInspector.NavigatorFolderTreeElement = class extends TreeElement { 837 Sources.NavigatorFolderTreeElement = class extends TreeElement {
838 /** 838 /**
839 * @param {!WebInspector.NavigatorView} navigatorView 839 * @param {!Sources.NavigatorView} navigatorView
840 * @param {string} type 840 * @param {string} type
841 * @param {string} title 841 * @param {string} title
842 * @param {function(boolean)=} hoverCallback 842 * @param {function(boolean)=} hoverCallback
843 */ 843 */
844 constructor(navigatorView, type, title, hoverCallback) { 844 constructor(navigatorView, type, title, hoverCallback) {
845 super('', true); 845 super('', true);
846 this.listItemElement.classList.add('navigator-' + type + '-tree-item', 'navi gator-folder-tree-item'); 846 this.listItemElement.classList.add('navigator-' + type + '-tree-item', 'navi gator-folder-tree-item');
847 this._nodeType = type; 847 this._nodeType = type;
848 this.title = title; 848 this.title = title;
849 this.tooltip = title; 849 this.tooltip = title;
(...skipping 14 matching lines...) Expand all
864 */ 864 */
865 onattach() { 865 onattach() {
866 this.collapse(); 866 this.collapse();
867 this._node.onattach(); 867 this._node.onattach();
868 this.listItemElement.addEventListener('contextmenu', this._handleContextMenu Event.bind(this), false); 868 this.listItemElement.addEventListener('contextmenu', this._handleContextMenu Event.bind(this), false);
869 this.listItemElement.addEventListener('mousemove', this._mouseMove.bind(this ), false); 869 this.listItemElement.addEventListener('mousemove', this._mouseMove.bind(this ), false);
870 this.listItemElement.addEventListener('mouseleave', this._mouseLeave.bind(th is), false); 870 this.listItemElement.addEventListener('mouseleave', this._mouseLeave.bind(th is), false);
871 } 871 }
872 872
873 /** 873 /**
874 * @param {!WebInspector.NavigatorTreeNode} node 874 * @param {!Sources.NavigatorTreeNode} node
875 */ 875 */
876 setNode(node) { 876 setNode(node) {
877 this._node = node; 877 this._node = node;
878 var paths = []; 878 var paths = [];
879 while (node && !node.isRoot()) { 879 while (node && !node.isRoot()) {
880 paths.push(node._title); 880 paths.push(node._title);
881 node = node.parent; 881 node = node.parent;
882 } 882 }
883 paths.reverse(); 883 paths.reverse();
884 this.tooltip = paths.join('/'); 884 this.tooltip = paths.join('/');
(...skipping 26 matching lines...) Expand all
911 if (!this._hoverCallback) 911 if (!this._hoverCallback)
912 return; 912 return;
913 this._hovered = false; 913 this._hovered = false;
914 this._hoverCallback(false); 914 this._hoverCallback(false);
915 } 915 }
916 }; 916 };
917 917
918 /** 918 /**
919 * @unrestricted 919 * @unrestricted
920 */ 920 */
921 WebInspector.NavigatorSourceTreeElement = class extends TreeElement { 921 Sources.NavigatorSourceTreeElement = class extends TreeElement {
922 /** 922 /**
923 * @param {!WebInspector.NavigatorView} navigatorView 923 * @param {!Sources.NavigatorView} navigatorView
924 * @param {!WebInspector.UISourceCode} uiSourceCode 924 * @param {!Workspace.UISourceCode} uiSourceCode
925 * @param {string} title 925 * @param {string} title
926 */ 926 */
927 constructor(navigatorView, uiSourceCode, title) { 927 constructor(navigatorView, uiSourceCode, title) {
928 super('', false); 928 super('', false);
929 this._nodeType = WebInspector.NavigatorView.Types.File; 929 this._nodeType = Sources.NavigatorView.Types.File;
930 this.title = title; 930 this.title = title;
931 this.listItemElement.classList.add( 931 this.listItemElement.classList.add(
932 'navigator-' + uiSourceCode.contentType().name() + '-tree-item', 'naviga tor-file-tree-item'); 932 'navigator-' + uiSourceCode.contentType().name() + '-tree-item', 'naviga tor-file-tree-item');
933 this.tooltip = uiSourceCode.url(); 933 this.tooltip = uiSourceCode.url();
934 this.createIcon(); 934 this.createIcon();
935 935
936 this._navigatorView = navigatorView; 936 this._navigatorView = navigatorView;
937 this._uiSourceCode = uiSourceCode; 937 this._uiSourceCode = uiSourceCode;
938 } 938 }
939 939
940 /** 940 /**
941 * @return {!WebInspector.UISourceCode} 941 * @return {!Workspace.UISourceCode}
942 */ 942 */
943 get uiSourceCode() { 943 get uiSourceCode() {
944 return this._uiSourceCode; 944 return this._uiSourceCode;
945 } 945 }
946 946
947 /** 947 /**
948 * @override 948 * @override
949 */ 949 */
950 onattach() { 950 onattach() {
951 this.listItemElement.draggable = true; 951 this.listItemElement.draggable = true;
952 this.listItemElement.addEventListener('click', this._onclick.bind(this), fal se); 952 this.listItemElement.addEventListener('click', this._onclick.bind(this), fal se);
953 this.listItemElement.addEventListener('contextmenu', this._handleContextMenu Event.bind(this), false); 953 this.listItemElement.addEventListener('contextmenu', this._handleContextMenu Event.bind(this), false);
954 this.listItemElement.addEventListener('mousedown', this._onmousedown.bind(th is), false); 954 this.listItemElement.addEventListener('mousedown', this._onmousedown.bind(th is), false);
955 this.listItemElement.addEventListener('dragstart', this._ondragstart.bind(th is), false); 955 this.listItemElement.addEventListener('dragstart', this._ondragstart.bind(th is), false);
956 } 956 }
957 957
958 _onmousedown(event) { 958 _onmousedown(event) {
959 if (event.which === 1) // Warm-up data for drag'n'drop 959 if (event.which === 1) // Warm-up data for drag'n'drop
960 this._uiSourceCode.requestContent().then(callback.bind(this)); 960 this._uiSourceCode.requestContent().then(callback.bind(this));
961 /** 961 /**
962 * @param {?string} content 962 * @param {?string} content
963 * @this {WebInspector.NavigatorSourceTreeElement} 963 * @this {Sources.NavigatorSourceTreeElement}
964 */ 964 */
965 function callback(content) { 965 function callback(content) {
966 this._warmedUpContent = content; 966 this._warmedUpContent = content;
967 } 967 }
968 } 968 }
969 969
970 _shouldRenameOnMouseDown() { 970 _shouldRenameOnMouseDown() {
971 if (!this._uiSourceCode.canRename()) 971 if (!this._uiSourceCode.canRename())
972 return false; 972 return false;
973 var isSelected = this === this.treeOutline.selectedTreeElement; 973 var isSelected = this === this.treeOutline.selectedTreeElement;
974 return isSelected && this.treeOutline.element.hasFocus() && !WebInspector.is BeingEdited(this.treeOutline.element); 974 return isSelected && this.treeOutline.element.hasFocus() && !UI.isBeingEdite d(this.treeOutline.element);
975 } 975 }
976 976
977 /** 977 /**
978 * @override 978 * @override
979 */ 979 */
980 selectOnMouseDown(event) { 980 selectOnMouseDown(event) {
981 if (event.which !== 1 || !this._shouldRenameOnMouseDown()) { 981 if (event.which !== 1 || !this._shouldRenameOnMouseDown()) {
982 super.selectOnMouseDown(event); 982 super.selectOnMouseDown(event);
983 return; 983 return;
984 } 984 }
985 setTimeout(rename.bind(this), 300); 985 setTimeout(rename.bind(this), 300);
986 986
987 /** 987 /**
988 * @this {WebInspector.NavigatorSourceTreeElement} 988 * @this {Sources.NavigatorSourceTreeElement}
989 */ 989 */
990 function rename() { 990 function rename() {
991 if (this._shouldRenameOnMouseDown()) 991 if (this._shouldRenameOnMouseDown())
992 this._navigatorView.rename(this.uiSourceCode, false); 992 this._navigatorView.rename(this.uiSourceCode, false);
993 } 993 }
994 } 994 }
995 995
996 _ondragstart(event) { 996 _ondragstart(event) {
997 event.dataTransfer.setData('text/plain', this._warmedUpContent); 997 event.dataTransfer.setData('text/plain', this._warmedUpContent);
998 event.dataTransfer.effectAllowed = 'copy'; 998 event.dataTransfer.effectAllowed = 'copy';
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 */ 1048 */
1049 _handleContextMenuEvent(event) { 1049 _handleContextMenuEvent(event) {
1050 this.select(); 1050 this.select();
1051 this._navigatorView.handleFileContextMenu(event, this._uiSourceCode); 1051 this._navigatorView.handleFileContextMenu(event, this._uiSourceCode);
1052 } 1052 }
1053 }; 1053 };
1054 1054
1055 /** 1055 /**
1056 * @unrestricted 1056 * @unrestricted
1057 */ 1057 */
1058 WebInspector.NavigatorTreeNode = class { 1058 Sources.NavigatorTreeNode = class {
1059 /** 1059 /**
1060 * @param {string} id 1060 * @param {string} id
1061 * @param {string} type 1061 * @param {string} type
1062 */ 1062 */
1063 constructor(id, type) { 1063 constructor(id, type) {
1064 this.id = id; 1064 this.id = id;
1065 this._type = type; 1065 this._type = type;
1066 /** @type {!Map.<string, !WebInspector.NavigatorTreeNode>} */ 1066 /** @type {!Map.<string, !Sources.NavigatorTreeNode>} */
1067 this._children = new Map(); 1067 this._children = new Map();
1068 } 1068 }
1069 1069
1070 /** 1070 /**
1071 * @return {!TreeElement} 1071 * @return {!TreeElement}
1072 */ 1072 */
1073 treeNode() { 1073 treeNode() {
1074 throw 'Not implemented'; 1074 throw 'Not implemented';
1075 } 1075 }
1076 1076
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 this.wasPopulated(); 1110 this.wasPopulated();
1111 } 1111 }
1112 1112
1113 wasPopulated() { 1113 wasPopulated() {
1114 var children = this.children(); 1114 var children = this.children();
1115 for (var i = 0; i < children.length; ++i) 1115 for (var i = 0; i < children.length; ++i)
1116 this.treeNode().appendChild(/** @type {!TreeElement} */ (children[i].treeN ode())); 1116 this.treeNode().appendChild(/** @type {!TreeElement} */ (children[i].treeN ode()));
1117 } 1117 }
1118 1118
1119 /** 1119 /**
1120 * @param {!WebInspector.NavigatorTreeNode} node 1120 * @param {!Sources.NavigatorTreeNode} node
1121 */ 1121 */
1122 didAddChild(node) { 1122 didAddChild(node) {
1123 if (this.isPopulated()) 1123 if (this.isPopulated())
1124 this.treeNode().appendChild(/** @type {!TreeElement} */ (node.treeNode())) ; 1124 this.treeNode().appendChild(/** @type {!TreeElement} */ (node.treeNode())) ;
1125 } 1125 }
1126 1126
1127 /** 1127 /**
1128 * @param {!WebInspector.NavigatorTreeNode} node 1128 * @param {!Sources.NavigatorTreeNode} node
1129 */ 1129 */
1130 willRemoveChild(node) { 1130 willRemoveChild(node) {
1131 if (this.isPopulated()) 1131 if (this.isPopulated())
1132 this.treeNode().removeChild(/** @type {!TreeElement} */ (node.treeNode())) ; 1132 this.treeNode().removeChild(/** @type {!TreeElement} */ (node.treeNode())) ;
1133 } 1133 }
1134 1134
1135 /** 1135 /**
1136 * @return {boolean} 1136 * @return {boolean}
1137 */ 1137 */
1138 isPopulated() { 1138 isPopulated() {
1139 return this._populated; 1139 return this._populated;
1140 } 1140 }
1141 1141
1142 /** 1142 /**
1143 * @return {boolean} 1143 * @return {boolean}
1144 */ 1144 */
1145 isEmpty() { 1145 isEmpty() {
1146 return !this._children.size; 1146 return !this._children.size;
1147 } 1147 }
1148 1148
1149 /** 1149 /**
1150 * @return {!Array.<!WebInspector.NavigatorTreeNode>} 1150 * @return {!Array.<!Sources.NavigatorTreeNode>}
1151 */ 1151 */
1152 children() { 1152 children() {
1153 return this._children.valuesArray(); 1153 return this._children.valuesArray();
1154 } 1154 }
1155 1155
1156 /** 1156 /**
1157 * @param {string} id 1157 * @param {string} id
1158 * @return {?WebInspector.NavigatorTreeNode} 1158 * @return {?Sources.NavigatorTreeNode}
1159 */ 1159 */
1160 child(id) { 1160 child(id) {
1161 return this._children.get(id) || null; 1161 return this._children.get(id) || null;
1162 } 1162 }
1163 1163
1164 /** 1164 /**
1165 * @param {!WebInspector.NavigatorTreeNode} node 1165 * @param {!Sources.NavigatorTreeNode} node
1166 */ 1166 */
1167 appendChild(node) { 1167 appendChild(node) {
1168 this._children.set(node.id, node); 1168 this._children.set(node.id, node);
1169 node.parent = this; 1169 node.parent = this;
1170 this.didAddChild(node); 1170 this.didAddChild(node);
1171 } 1171 }
1172 1172
1173 /** 1173 /**
1174 * @param {!WebInspector.NavigatorTreeNode} node 1174 * @param {!Sources.NavigatorTreeNode} node
1175 */ 1175 */
1176 removeChild(node) { 1176 removeChild(node) {
1177 this.willRemoveChild(node); 1177 this.willRemoveChild(node);
1178 this._children.remove(node.id); 1178 this._children.remove(node.id);
1179 delete node.parent; 1179 delete node.parent;
1180 node.dispose(); 1180 node.dispose();
1181 } 1181 }
1182 1182
1183 reset() { 1183 reset() {
1184 this._children.clear(); 1184 this._children.clear();
1185 } 1185 }
1186 }; 1186 };
1187 1187
1188 /** 1188 /**
1189 * @unrestricted 1189 * @unrestricted
1190 */ 1190 */
1191 WebInspector.NavigatorRootTreeNode = class extends WebInspector.NavigatorTreeNod e { 1191 Sources.NavigatorRootTreeNode = class extends Sources.NavigatorTreeNode {
1192 /** 1192 /**
1193 * @param {!WebInspector.NavigatorView} navigatorView 1193 * @param {!Sources.NavigatorView} navigatorView
1194 */ 1194 */
1195 constructor(navigatorView) { 1195 constructor(navigatorView) {
1196 super('', WebInspector.NavigatorView.Types.Root); 1196 super('', Sources.NavigatorView.Types.Root);
1197 this._navigatorView = navigatorView; 1197 this._navigatorView = navigatorView;
1198 } 1198 }
1199 1199
1200 /** 1200 /**
1201 * @override 1201 * @override
1202 * @return {boolean} 1202 * @return {boolean}
1203 */ 1203 */
1204 isRoot() { 1204 isRoot() {
1205 return true; 1205 return true;
1206 } 1206 }
1207 1207
1208 /** 1208 /**
1209 * @override 1209 * @override
1210 * @return {!TreeElement} 1210 * @return {!TreeElement}
1211 */ 1211 */
1212 treeNode() { 1212 treeNode() {
1213 return this._navigatorView._scriptsTree.rootElement(); 1213 return this._navigatorView._scriptsTree.rootElement();
1214 } 1214 }
1215 }; 1215 };
1216 1216
1217 /** 1217 /**
1218 * @unrestricted 1218 * @unrestricted
1219 */ 1219 */
1220 WebInspector.NavigatorUISourceCodeTreeNode = class extends WebInspector.Navigato rTreeNode { 1220 Sources.NavigatorUISourceCodeTreeNode = class extends Sources.NavigatorTreeNode {
1221 /** 1221 /**
1222 * @param {!WebInspector.NavigatorView} navigatorView 1222 * @param {!Sources.NavigatorView} navigatorView
1223 * @param {!WebInspector.UISourceCode} uiSourceCode 1223 * @param {!Workspace.UISourceCode} uiSourceCode
1224 */ 1224 */
1225 constructor(navigatorView, uiSourceCode) { 1225 constructor(navigatorView, uiSourceCode) {
1226 super(uiSourceCode.project().id() + ':' + uiSourceCode.url(), WebInspector.N avigatorView.Types.File); 1226 super(uiSourceCode.project().id() + ':' + uiSourceCode.url(), Sources.Naviga torView.Types.File);
1227 this._navigatorView = navigatorView; 1227 this._navigatorView = navigatorView;
1228 this._uiSourceCode = uiSourceCode; 1228 this._uiSourceCode = uiSourceCode;
1229 this._treeElement = null; 1229 this._treeElement = null;
1230 this._eventListeners = []; 1230 this._eventListeners = [];
1231 } 1231 }
1232 1232
1233 /** 1233 /**
1234 * @return {!WebInspector.UISourceCode} 1234 * @return {!Workspace.UISourceCode}
1235 */ 1235 */
1236 uiSourceCode() { 1236 uiSourceCode() {
1237 return this._uiSourceCode; 1237 return this._uiSourceCode;
1238 } 1238 }
1239 1239
1240 /** 1240 /**
1241 * @override 1241 * @override
1242 * @return {!TreeElement} 1242 * @return {!TreeElement}
1243 */ 1243 */
1244 treeNode() { 1244 treeNode() {
1245 if (this._treeElement) 1245 if (this._treeElement)
1246 return this._treeElement; 1246 return this._treeElement;
1247 1247
1248 this._treeElement = new WebInspector.NavigatorSourceTreeElement(this._naviga torView, this._uiSourceCode, ''); 1248 this._treeElement = new Sources.NavigatorSourceTreeElement(this._navigatorVi ew, this._uiSourceCode, '');
1249 this.updateTitle(); 1249 this.updateTitle();
1250 1250
1251 var updateTitleBound = this.updateTitle.bind(this, undefined); 1251 var updateTitleBound = this.updateTitle.bind(this, undefined);
1252 this._eventListeners = [ 1252 this._eventListeners = [
1253 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Title Changed, updateTitleBound), 1253 this._uiSourceCode.addEventListener(Workspace.UISourceCode.Events.TitleCha nged, updateTitleBound),
1254 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Worki ngCopyChanged, updateTitleBound), 1254 this._uiSourceCode.addEventListener(Workspace.UISourceCode.Events.WorkingC opyChanged, updateTitleBound),
1255 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Worki ngCopyCommitted, updateTitleBound) 1255 this._uiSourceCode.addEventListener(Workspace.UISourceCode.Events.WorkingC opyCommitted, updateTitleBound)
1256 ]; 1256 ];
1257 return this._treeElement; 1257 return this._treeElement;
1258 } 1258 }
1259 1259
1260 /** 1260 /**
1261 * @param {boolean=} ignoreIsDirty 1261 * @param {boolean=} ignoreIsDirty
1262 */ 1262 */
1263 updateTitle(ignoreIsDirty) { 1263 updateTitle(ignoreIsDirty) {
1264 if (!this._treeElement) 1264 if (!this._treeElement)
1265 return; 1265 return;
1266 1266
1267 var titleText = this._uiSourceCode.displayName(); 1267 var titleText = this._uiSourceCode.displayName();
1268 if (!ignoreIsDirty && 1268 if (!ignoreIsDirty &&
1269 (this._uiSourceCode.isDirty() || WebInspector.persistence.hasUnsavedComm ittedChanges(this._uiSourceCode))) 1269 (this._uiSourceCode.isDirty() || Persistence.persistence.hasUnsavedCommi ttedChanges(this._uiSourceCode)))
1270 titleText = '*' + titleText; 1270 titleText = '*' + titleText;
1271 1271
1272 var binding = WebInspector.persistence.binding(this._uiSourceCode); 1272 var binding = Persistence.persistence.binding(this._uiSourceCode);
1273 if (binding && Runtime.experiments.isEnabled('persistence2')) { 1273 if (binding && Runtime.experiments.isEnabled('persistence2')) {
1274 var titleElement = createElement('span'); 1274 var titleElement = createElement('span');
1275 titleElement.textContent = titleText; 1275 titleElement.textContent = titleText;
1276 var icon = WebInspector.Icon.create('smallicon-checkmark', 'mapped-file-ch eckmark'); 1276 var icon = UI.Icon.create('smallicon-checkmark', 'mapped-file-checkmark');
1277 icon.title = WebInspector.PersistenceUtils.tooltipForUISourceCode(this._ui SourceCode); 1277 icon.title = Persistence.PersistenceUtils.tooltipForUISourceCode(this._uiS ourceCode);
1278 titleElement.appendChild(icon); 1278 titleElement.appendChild(icon);
1279 this._treeElement.title = titleElement; 1279 this._treeElement.title = titleElement;
1280 } else { 1280 } else {
1281 this._treeElement.title = titleText; 1281 this._treeElement.title = titleText;
1282 } 1282 }
1283 1283
1284 var tooltip = this._uiSourceCode.url(); 1284 var tooltip = this._uiSourceCode.url();
1285 if (this._uiSourceCode.contentType().isFromSourceMap()) 1285 if (this._uiSourceCode.contentType().isFromSourceMap())
1286 tooltip = WebInspector.UIString('%s (from source map)', this._uiSourceCode .displayName()); 1286 tooltip = Common.UIString('%s (from source map)', this._uiSourceCode.displ ayName());
1287 this._treeElement.tooltip = tooltip; 1287 this._treeElement.tooltip = tooltip;
1288 } 1288 }
1289 1289
1290 /** 1290 /**
1291 * @override 1291 * @override
1292 * @return {boolean} 1292 * @return {boolean}
1293 */ 1293 */
1294 hasChildren() { 1294 hasChildren() {
1295 return false; 1295 return false;
1296 } 1296 }
1297 1297
1298 /** 1298 /**
1299 * @override 1299 * @override
1300 */ 1300 */
1301 dispose() { 1301 dispose() {
1302 WebInspector.EventTarget.removeEventListeners(this._eventListeners); 1302 Common.EventTarget.removeEventListeners(this._eventListeners);
1303 } 1303 }
1304 1304
1305 /** 1305 /**
1306 * @param {boolean=} select 1306 * @param {boolean=} select
1307 */ 1307 */
1308 reveal(select) { 1308 reveal(select) {
1309 this.parent.populate(); 1309 this.parent.populate();
1310 this.parent.treeNode().expand(); 1310 this.parent.treeNode().expand();
1311 this._treeElement.reveal(true); 1311 this._treeElement.reveal(true);
1312 if (select) 1312 if (select)
1313 this._treeElement.select(true); 1313 this._treeElement.select(true);
1314 } 1314 }
1315 1315
1316 /** 1316 /**
1317 * @param {function(boolean)=} callback 1317 * @param {function(boolean)=} callback
1318 */ 1318 */
1319 rename(callback) { 1319 rename(callback) {
1320 if (!this._treeElement) 1320 if (!this._treeElement)
1321 return; 1321 return;
1322 1322
1323 // Tree outline should be marked as edited as well as the tree element to pr event search from starting. 1323 // Tree outline should be marked as edited as well as the tree element to pr event search from starting.
1324 var treeOutlineElement = this._treeElement.treeOutline.element; 1324 var treeOutlineElement = this._treeElement.treeOutline.element;
1325 WebInspector.markBeingEdited(treeOutlineElement, true); 1325 UI.markBeingEdited(treeOutlineElement, true);
1326 1326
1327 /** 1327 /**
1328 * @param {!Element} element 1328 * @param {!Element} element
1329 * @param {string} newTitle 1329 * @param {string} newTitle
1330 * @param {string} oldTitle 1330 * @param {string} oldTitle
1331 * @this {WebInspector.NavigatorUISourceCodeTreeNode} 1331 * @this {Sources.NavigatorUISourceCodeTreeNode}
1332 */ 1332 */
1333 function commitHandler(element, newTitle, oldTitle) { 1333 function commitHandler(element, newTitle, oldTitle) {
1334 if (newTitle !== oldTitle) { 1334 if (newTitle !== oldTitle) {
1335 this._treeElement.title = newTitle; 1335 this._treeElement.title = newTitle;
1336 this._uiSourceCode.rename(newTitle, renameCallback.bind(this)); 1336 this._uiSourceCode.rename(newTitle, renameCallback.bind(this));
1337 return; 1337 return;
1338 } 1338 }
1339 afterEditing.call(this, true); 1339 afterEditing.call(this, true);
1340 } 1340 }
1341 1341
1342 /** 1342 /**
1343 * @param {boolean} success 1343 * @param {boolean} success
1344 * @this {WebInspector.NavigatorUISourceCodeTreeNode} 1344 * @this {Sources.NavigatorUISourceCodeTreeNode}
1345 */ 1345 */
1346 function renameCallback(success) { 1346 function renameCallback(success) {
1347 if (!success) { 1347 if (!success) {
1348 WebInspector.markBeingEdited(treeOutlineElement, false); 1348 UI.markBeingEdited(treeOutlineElement, false);
1349 this.updateTitle(); 1349 this.updateTitle();
1350 this.rename(callback); 1350 this.rename(callback);
1351 return; 1351 return;
1352 } 1352 }
1353 afterEditing.call(this, true); 1353 afterEditing.call(this, true);
1354 } 1354 }
1355 1355
1356 /** 1356 /**
1357 * @param {boolean} committed 1357 * @param {boolean} committed
1358 * @this {WebInspector.NavigatorUISourceCodeTreeNode} 1358 * @this {Sources.NavigatorUISourceCodeTreeNode}
1359 */ 1359 */
1360 function afterEditing(committed) { 1360 function afterEditing(committed) {
1361 WebInspector.markBeingEdited(treeOutlineElement, false); 1361 UI.markBeingEdited(treeOutlineElement, false);
1362 this.updateTitle(); 1362 this.updateTitle();
1363 this._treeElement.treeOutline.focus(); 1363 this._treeElement.treeOutline.focus();
1364 if (callback) 1364 if (callback)
1365 callback(committed); 1365 callback(committed);
1366 } 1366 }
1367 1367
1368 this.updateTitle(true); 1368 this.updateTitle(true);
1369 this._treeElement.startEditingTitle( 1369 this._treeElement.startEditingTitle(
1370 new WebInspector.InplaceEditor.Config(commitHandler.bind(this), afterEdi ting.bind(this, false))); 1370 new UI.InplaceEditor.Config(commitHandler.bind(this), afterEditing.bind( this, false)));
1371 } 1371 }
1372 }; 1372 };
1373 1373
1374 /** 1374 /**
1375 * @unrestricted 1375 * @unrestricted
1376 */ 1376 */
1377 WebInspector.NavigatorFolderTreeNode = class extends WebInspector.NavigatorTreeN ode { 1377 Sources.NavigatorFolderTreeNode = class extends Sources.NavigatorTreeNode {
1378 /** 1378 /**
1379 * @param {!WebInspector.NavigatorView} navigatorView 1379 * @param {!Sources.NavigatorView} navigatorView
1380 * @param {?WebInspector.Project} project 1380 * @param {?Workspace.Project} project
1381 * @param {string} id 1381 * @param {string} id
1382 * @param {string} type 1382 * @param {string} type
1383 * @param {string} folderPath 1383 * @param {string} folderPath
1384 * @param {string} title 1384 * @param {string} title
1385 */ 1385 */
1386 constructor(navigatorView, project, id, type, folderPath, title) { 1386 constructor(navigatorView, project, id, type, folderPath, title) {
1387 super(id, type); 1387 super(id, type);
1388 this._navigatorView = navigatorView; 1388 this._navigatorView = navigatorView;
1389 this._project = project; 1389 this._project = project;
1390 this._folderPath = folderPath; 1390 this._folderPath = folderPath;
1391 this._title = title; 1391 this._title = title;
1392 } 1392 }
1393 1393
1394 /** 1394 /**
1395 * @override 1395 * @override
1396 * @return {!TreeElement} 1396 * @return {!TreeElement}
1397 */ 1397 */
1398 treeNode() { 1398 treeNode() {
1399 if (this._treeElement) 1399 if (this._treeElement)
1400 return this._treeElement; 1400 return this._treeElement;
1401 this._treeElement = this._createTreeElement(this._title, this); 1401 this._treeElement = this._createTreeElement(this._title, this);
1402 this.updateTitle(); 1402 this.updateTitle();
1403 return this._treeElement; 1403 return this._treeElement;
1404 } 1404 }
1405 1405
1406 updateTitle() { 1406 updateTitle() {
1407 if (!this._treeElement || this._project.type() !== WebInspector.projectTypes .FileSystem) 1407 if (!this._treeElement || this._project.type() !== Workspace.projectTypes.Fi leSystem)
1408 return; 1408 return;
1409 var absoluteFileSystemPath = 1409 var absoluteFileSystemPath =
1410 WebInspector.FileSystemWorkspaceBinding.fileSystemPath(this._project.id( )) + '/' + this._folderPath; 1410 Bindings.FileSystemWorkspaceBinding.fileSystemPath(this._project.id()) + '/' + this._folderPath;
1411 var hasMappedFiles = Runtime.experiments.isEnabled('persistence2') ? 1411 var hasMappedFiles = Runtime.experiments.isEnabled('persistence2') ?
1412 WebInspector.persistence.filePathHasBindings(absoluteFileSystemPath) : 1412 Persistence.persistence.filePathHasBindings(absoluteFileSystemPath) :
1413 true; 1413 true;
1414 this._treeElement.listItemElement.classList.toggle('has-mapped-files', hasMa ppedFiles); 1414 this._treeElement.listItemElement.classList.toggle('has-mapped-files', hasMa ppedFiles);
1415 } 1415 }
1416 1416
1417 /** 1417 /**
1418 * @return {!TreeElement} 1418 * @return {!TreeElement}
1419 */ 1419 */
1420 _createTreeElement(title, node) { 1420 _createTreeElement(title, node) {
1421 if (this._project.type() !== WebInspector.projectTypes.FileSystem) { 1421 if (this._project.type() !== Workspace.projectTypes.FileSystem) {
1422 try { 1422 try {
1423 title = decodeURI(title); 1423 title = decodeURI(title);
1424 } catch (e) { 1424 } catch (e) {
1425 } 1425 }
1426 } 1426 }
1427 var treeElement = new WebInspector.NavigatorFolderTreeElement(this._navigato rView, this._type, title); 1427 var treeElement = new Sources.NavigatorFolderTreeElement(this._navigatorView , this._type, title);
1428 treeElement.setNode(node); 1428 treeElement.setNode(node);
1429 return treeElement; 1429 return treeElement;
1430 } 1430 }
1431 1431
1432 /** 1432 /**
1433 * @override 1433 * @override
1434 */ 1434 */
1435 wasPopulated() { 1435 wasPopulated() {
1436 if (!this._treeElement || this._treeElement._node !== this) 1436 if (!this._treeElement || this._treeElement._node !== this)
1437 return; 1437 return;
1438 this._addChildrenRecursive(); 1438 this._addChildrenRecursive();
1439 } 1439 }
1440 1440
1441 _addChildrenRecursive() { 1441 _addChildrenRecursive() {
1442 var children = this.children(); 1442 var children = this.children();
1443 for (var i = 0; i < children.length; ++i) { 1443 for (var i = 0; i < children.length; ++i) {
1444 var child = children[i]; 1444 var child = children[i];
1445 this.didAddChild(child); 1445 this.didAddChild(child);
1446 if (child instanceof WebInspector.NavigatorFolderTreeNode) 1446 if (child instanceof Sources.NavigatorFolderTreeNode)
1447 child._addChildrenRecursive(); 1447 child._addChildrenRecursive();
1448 } 1448 }
1449 } 1449 }
1450 1450
1451 _shouldMerge(node) { 1451 _shouldMerge(node) {
1452 return this._type !== WebInspector.NavigatorView.Types.Domain && 1452 return this._type !== Sources.NavigatorView.Types.Domain &&
1453 node instanceof WebInspector.NavigatorFolderTreeNode; 1453 node instanceof Sources.NavigatorFolderTreeNode;
1454 } 1454 }
1455 1455
1456 /** 1456 /**
1457 * @param {!WebInspector.NavigatorTreeNode} node 1457 * @param {!Sources.NavigatorTreeNode} node
1458 * @override 1458 * @override
1459 */ 1459 */
1460 didAddChild(node) { 1460 didAddChild(node) {
1461 function titleForNode(node) { 1461 function titleForNode(node) {
1462 return node._title; 1462 return node._title;
1463 } 1463 }
1464 1464
1465 if (!this._treeElement) 1465 if (!this._treeElement)
1466 return; 1466 return;
1467 1467
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1519 this._treeElement.appendChild(oldTreeElement); 1519 this._treeElement.appendChild(oldTreeElement);
1520 if (oldTreeElement.expanded) 1520 if (oldTreeElement.expanded)
1521 treeElement.expand(); 1521 treeElement.expand();
1522 } 1522 }
1523 if (this.isPopulated()) 1523 if (this.isPopulated())
1524 this._treeElement.appendChild(node.treeNode()); 1524 this._treeElement.appendChild(node.treeNode());
1525 } 1525 }
1526 1526
1527 /** 1527 /**
1528 * @override 1528 * @override
1529 * @param {!WebInspector.NavigatorTreeNode} node 1529 * @param {!Sources.NavigatorTreeNode} node
1530 */ 1530 */
1531 willRemoveChild(node) { 1531 willRemoveChild(node) {
1532 if (node._isMerged || !this.isPopulated()) 1532 if (node._isMerged || !this.isPopulated())
1533 return; 1533 return;
1534 this._treeElement.removeChild(node._treeElement); 1534 this._treeElement.removeChild(node._treeElement);
1535 } 1535 }
1536 }; 1536 };
1537 1537
1538 /** 1538 /**
1539 * @unrestricted 1539 * @unrestricted
1540 */ 1540 */
1541 WebInspector.NavigatorGroupTreeNode = class extends WebInspector.NavigatorTreeNo de { 1541 Sources.NavigatorGroupTreeNode = class extends Sources.NavigatorTreeNode {
1542 /** 1542 /**
1543 * @param {!WebInspector.NavigatorView} navigatorView 1543 * @param {!Sources.NavigatorView} navigatorView
1544 * @param {!WebInspector.Project} project 1544 * @param {!Workspace.Project} project
1545 * @param {string} id 1545 * @param {string} id
1546 * @param {string} type 1546 * @param {string} type
1547 * @param {string} title 1547 * @param {string} title
1548 */ 1548 */
1549 constructor(navigatorView, project, id, type, title) { 1549 constructor(navigatorView, project, id, type, title) {
1550 super(id, type); 1550 super(id, type);
1551 this._project = project; 1551 this._project = project;
1552 this._navigatorView = navigatorView; 1552 this._navigatorView = navigatorView;
1553 this._title = title; 1553 this._title = title;
1554 this.populate(); 1554 this.populate();
1555 } 1555 }
1556 1556
1557 /** 1557 /**
1558 * @param {function(boolean)} hoverCallback 1558 * @param {function(boolean)} hoverCallback
1559 */ 1559 */
1560 setHoverCallback(hoverCallback) { 1560 setHoverCallback(hoverCallback) {
1561 this._hoverCallback = hoverCallback; 1561 this._hoverCallback = hoverCallback;
1562 } 1562 }
1563 1563
1564 /** 1564 /**
1565 * @override 1565 * @override
1566 * @return {!TreeElement} 1566 * @return {!TreeElement}
1567 */ 1567 */
1568 treeNode() { 1568 treeNode() {
1569 if (this._treeElement) 1569 if (this._treeElement)
1570 return this._treeElement; 1570 return this._treeElement;
1571 this._treeElement = 1571 this._treeElement =
1572 new WebInspector.NavigatorFolderTreeElement(this._navigatorView, this._t ype, this._title, this._hoverCallback); 1572 new Sources.NavigatorFolderTreeElement(this._navigatorView, this._type, this._title, this._hoverCallback);
1573 this._treeElement.setNode(this); 1573 this._treeElement.setNode(this);
1574 return this._treeElement; 1574 return this._treeElement;
1575 } 1575 }
1576 1576
1577 /** 1577 /**
1578 * @override 1578 * @override
1579 */ 1579 */
1580 onattach() { 1580 onattach() {
1581 this.updateTitle(); 1581 this.updateTitle();
1582 } 1582 }
1583 1583
1584 updateTitle() { 1584 updateTitle() {
1585 if (!this._treeElement || this._project.type() !== WebInspector.projectTypes .FileSystem) 1585 if (!this._treeElement || this._project.type() !== Workspace.projectTypes.Fi leSystem)
1586 return; 1586 return;
1587 if (!Runtime.experiments.isEnabled('persistence2')) { 1587 if (!Runtime.experiments.isEnabled('persistence2')) {
1588 this._treeElement.listItemElement.classList.add('has-mapped-files'); 1588 this._treeElement.listItemElement.classList.add('has-mapped-files');
1589 return; 1589 return;
1590 } 1590 }
1591 var fileSystemPath = WebInspector.FileSystemWorkspaceBinding.fileSystemPath( this._project.id()); 1591 var fileSystemPath = Bindings.FileSystemWorkspaceBinding.fileSystemPath(this ._project.id());
1592 var wasActive = this._treeElement.listItemElement.classList.contains('has-ma pped-files'); 1592 var wasActive = this._treeElement.listItemElement.classList.contains('has-ma pped-files');
1593 var isActive = WebInspector.persistence.filePathHasBindings(fileSystemPath); 1593 var isActive = Persistence.persistence.filePathHasBindings(fileSystemPath);
1594 if (wasActive === isActive) 1594 if (wasActive === isActive)
1595 return; 1595 return;
1596 this._treeElement.listItemElement.classList.toggle('has-mapped-files', isAct ive); 1596 this._treeElement.listItemElement.classList.toggle('has-mapped-files', isAct ive);
1597 if (isActive) 1597 if (isActive)
1598 this._treeElement.expand(); 1598 this._treeElement.expand();
1599 else 1599 else
1600 this._treeElement.collapse(); 1600 this._treeElement.collapse();
1601 } 1601 }
1602 1602
1603 /** 1603 /**
1604 * @param {string} title 1604 * @param {string} title
1605 * @override 1605 * @override
1606 */ 1606 */
1607 setTitle(title) { 1607 setTitle(title) {
1608 this._title = title; 1608 this._title = title;
1609 if (this._treeElement) 1609 if (this._treeElement)
1610 this._treeElement.title = this._title; 1610 this._treeElement.title = this._title;
1611 } 1611 }
1612 }; 1612 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698