Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 * |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 236 /** | 236 /** |
| 237 * @param {!Workspace.UISourceCode} uiSourceCode | 237 * @param {!Workspace.UISourceCode} uiSourceCode |
| 238 * @return {boolean} | 238 * @return {boolean} |
| 239 */ | 239 */ |
| 240 accept(uiSourceCode) { | 240 accept(uiSourceCode) { |
| 241 return !uiSourceCode.project().isServiceProject(); | 241 return !uiSourceCode.project().isServiceProject(); |
| 242 } | 242 } |
| 243 | 243 |
| 244 /** | 244 /** |
| 245 * @param {!Workspace.UISourceCode} uiSourceCode | 245 * @param {!Workspace.UISourceCode} uiSourceCode |
| 246 * @return {?SDK.ResourceTreeFrame} | 246 * @return {?Array<!SDK.ResourceTreeFrame>} |
| 247 */ | 247 */ |
| 248 _uiSourceCodeFrame(uiSourceCode) { | 248 _uiSourceCodeFrames(uiSourceCode) { |
| 249 var frame = Bindings.NetworkProject.frameForProject(uiSourceCode.project()); | 249 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode); |
| 250 if (!frame) { | 250 var resourceTreeModel = target && target.model(SDK.ResourceTreeModel); |
| 251 var target = Bindings.NetworkProject.targetForProject(uiSourceCode.project ()); | 251 if (!resourceTreeModel) |
| 252 var resourceTreeModel = target && target.model(SDK.ResourceTreeModel); | 252 return null; |
| 253 frame = resourceTreeModel && resourceTreeModel.mainFrame; | 253 var frames = null; |
| 254 var frameIds = Bindings.NetworkProject.frameAttribution(uiSourceCode); | |
| 255 if (frameIds && frameIds.size) { | |
| 256 frames = Array.from(frameIds).map(frameId => resourceTreeModel.frameForId( frameId)); | |
|
dgozman
2017/04/20 17:12:07
Let's make NetworkProject do the mapping and retur
lushnikov
2017/04/21 01:21:51
Done.
| |
| 257 } else { | |
| 258 // This is to overcome compilation cache which doesn't get reset. | |
| 259 frames = [resourceTreeModel.mainFrame]; | |
| 254 } | 260 } |
| 255 return frame; | 261 frames = frames.filter(frame => !!frame); |
| 262 return frames.length ? frames : null; | |
| 256 } | 263 } |
| 257 | 264 |
| 258 /** | 265 /** |
| 259 * @param {!Workspace.UISourceCode} uiSourceCode | 266 * @param {!Workspace.UISourceCode} uiSourceCode |
| 260 */ | 267 */ |
| 261 _addUISourceCode(uiSourceCode) { | 268 _addUISourceCode(uiSourceCode) { |
| 262 if (!this.accept(uiSourceCode)) | 269 if (!this.accept(uiSourceCode)) |
| 263 return; | 270 return; |
| 264 | 271 |
| 265 var binding = Persistence.persistence.binding(uiSourceCode); | 272 var binding = Persistence.persistence.binding(uiSourceCode); |
| 266 if (!Runtime.experiments.isEnabled('persistence2') && binding && binding.net work === uiSourceCode) | 273 if (!Runtime.experiments.isEnabled('persistence2') && binding && binding.net work === uiSourceCode) |
| 267 return; | 274 return; |
| 268 | 275 |
| 269 var isFromSourceMap = uiSourceCode.contentType().isFromSourceMap(); | 276 var isFromSourceMap = uiSourceCode.contentType().isFromSourceMap(); |
| 270 var path; | 277 var path; |
| 271 if (uiSourceCode.project().type() === Workspace.projectTypes.FileSystem) | 278 if (uiSourceCode.project().type() === Workspace.projectTypes.FileSystem) |
| 272 path = Persistence.FileSystemWorkspaceBinding.relativePath(uiSourceCode).s lice(0, -1); | 279 path = Persistence.FileSystemWorkspaceBinding.relativePath(uiSourceCode).s lice(0, -1); |
| 273 else | 280 else |
| 274 path = Common.ParsedURL.extractPath(uiSourceCode.url()).split('/').slice(1 , -1); | 281 path = Common.ParsedURL.extractPath(uiSourceCode.url()).split('/').slice(1 , -1); |
| 275 | 282 |
| 276 var project = uiSourceCode.project(); | 283 var project = uiSourceCode.project(); |
| 277 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode); | 284 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode); |
| 278 var frame = this._uiSourceCodeFrame(uiSourceCode); | 285 var frames = this._uiSourceCodeFrames(uiSourceCode); |
| 279 | 286 var uiSourceCodeNodes = []; |
| 280 var folderNode = | 287 if (frames && frames.length) { |
|
dgozman
2017/04/20 17:12:07
frames are never empty.
lushnikov
2017/04/21 01:21:51
Done.
| |
| 281 this._folderNode(uiSourceCode, project, target, frame, uiSourceCode.orig in(), path, isFromSourceMap); | 288 for (var frame of frames) { |
| 282 var uiSourceCodeNode = new Sources.NavigatorUISourceCodeTreeNode(this, uiSou rceCode); | 289 var folderNode = |
| 283 this._uiSourceCodeNodes.set(uiSourceCode, [uiSourceCodeNode]); | 290 this._folderNode(uiSourceCode, project, target, frame, uiSourceCode. origin(), path, isFromSourceMap); |
| 284 folderNode.appendChild(uiSourceCodeNode); | 291 var uiSourceCodeNode = new Sources.NavigatorUISourceCodeTreeNode(this, u iSourceCode, frame); |
| 292 folderNode.appendChild(uiSourceCodeNode); | |
| 293 uiSourceCodeNodes.push(uiSourceCodeNode); | |
| 294 } | |
| 295 } else { | |
| 296 var folderNode = | |
| 297 this._folderNode(uiSourceCode, project, target, null, uiSourceCode.ori gin(), path, isFromSourceMap); | |
| 298 var uiSourceCodeNode = new Sources.NavigatorUISourceCodeTreeNode(this, uiS ourceCode, null); | |
| 299 folderNode.appendChild(uiSourceCodeNode); | |
| 300 uiSourceCodeNodes.push(uiSourceCodeNode); | |
| 301 } | |
| 302 this._uiSourceCodeNodes.set(uiSourceCode, uiSourceCodeNodes); | |
| 285 this.uiSourceCodeAdded(uiSourceCode); | 303 this.uiSourceCodeAdded(uiSourceCode); |
| 286 } | 304 } |
| 287 | 305 |
| 288 /** | 306 /** |
| 289 * @param {!Workspace.UISourceCode} uiSourceCode | 307 * @param {!Workspace.UISourceCode} uiSourceCode |
| 290 */ | 308 */ |
| 291 uiSourceCodeAdded(uiSourceCode) { | 309 uiSourceCodeAdded(uiSourceCode) { |
| 292 } | 310 } |
| 293 | 311 |
| 294 /** | 312 /** |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 523 /** | 541 /** |
| 524 * @param {!Workspace.UISourceCode} uiSourceCode | 542 * @param {!Workspace.UISourceCode} uiSourceCode |
| 525 */ | 543 */ |
| 526 _removeUISourceCode(uiSourceCode) { | 544 _removeUISourceCode(uiSourceCode) { |
| 527 var nodes = this._uiSourceCodeNodes.get(uiSourceCode) || []; | 545 var nodes = this._uiSourceCodeNodes.get(uiSourceCode) || []; |
| 528 for (var i = 0; i < nodes.length; i++) { | 546 for (var i = 0; i < nodes.length; i++) { |
| 529 var node = nodes[i]; | 547 var node = nodes[i]; |
| 530 | 548 |
| 531 var project = uiSourceCode.project(); | 549 var project = uiSourceCode.project(); |
| 532 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode); | 550 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode); |
| 533 var frame = this._uiSourceCodeFrame(uiSourceCode); | 551 var frame = node.frame(); |
| 534 | 552 |
| 535 var parentNode = node.parent; | 553 var parentNode = node.parent; |
| 536 parentNode.removeChild(node); | 554 parentNode.removeChild(node); |
| 537 node = parentNode; | 555 node = parentNode; |
| 538 | 556 |
| 539 while (node) { | 557 while (node) { |
| 540 parentNode = node.parent; | 558 parentNode = node.parent; |
| 541 if (!parentNode || !node.isEmpty()) | 559 if (!parentNode || !node.isEmpty()) |
| 542 break; | 560 break; |
| 543 if (!(node instanceof Sources.NavigatorGroupTreeNode || node instanceof Sources.NavigatorFolderTreeNode)) | 561 if (!(node instanceof Sources.NavigatorGroupTreeNode || node instanceof Sources.NavigatorFolderTreeNode)) |
| (...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1207 } | 1225 } |
| 1208 }; | 1226 }; |
| 1209 | 1227 |
| 1210 /** | 1228 /** |
| 1211 * @unrestricted | 1229 * @unrestricted |
| 1212 */ | 1230 */ |
| 1213 Sources.NavigatorUISourceCodeTreeNode = class extends Sources.NavigatorTreeNode { | 1231 Sources.NavigatorUISourceCodeTreeNode = class extends Sources.NavigatorTreeNode { |
| 1214 /** | 1232 /** |
| 1215 * @param {!Sources.NavigatorView} navigatorView | 1233 * @param {!Sources.NavigatorView} navigatorView |
| 1216 * @param {!Workspace.UISourceCode} uiSourceCode | 1234 * @param {!Workspace.UISourceCode} uiSourceCode |
| 1235 * @param {?SDK.ResourceTreeFrame} frame | |
| 1217 */ | 1236 */ |
| 1218 constructor(navigatorView, uiSourceCode) { | 1237 constructor(navigatorView, uiSourceCode, frame) { |
| 1219 super(uiSourceCode.project().id() + ':' + uiSourceCode.url(), Sources.Naviga torView.Types.File); | 1238 super(uiSourceCode.project().id() + ':' + uiSourceCode.url(), Sources.Naviga torView.Types.File); |
| 1220 this._navigatorView = navigatorView; | 1239 this._navigatorView = navigatorView; |
| 1221 this._uiSourceCode = uiSourceCode; | 1240 this._uiSourceCode = uiSourceCode; |
| 1222 this._treeElement = null; | 1241 this._treeElement = null; |
| 1223 this._eventListeners = []; | 1242 this._eventListeners = []; |
| 1243 this._frame = frame; | |
| 1224 } | 1244 } |
| 1225 | 1245 |
| 1226 /** | 1246 /** |
| 1247 * @return {?SDK.ResourceTreeFrame} | |
| 1248 */ | |
| 1249 frame() { | |
| 1250 return this._frame; | |
| 1251 } | |
| 1252 | |
| 1253 /** | |
| 1227 * @return {!Workspace.UISourceCode} | 1254 * @return {!Workspace.UISourceCode} |
| 1228 */ | 1255 */ |
| 1229 uiSourceCode() { | 1256 uiSourceCode() { |
| 1230 return this._uiSourceCode; | 1257 return this._uiSourceCode; |
| 1231 } | 1258 } |
| 1232 | 1259 |
| 1233 /** | 1260 /** |
| 1234 * @override | 1261 * @override |
| 1235 * @return {!UI.TreeElement} | 1262 * @return {!UI.TreeElement} |
| 1236 */ | 1263 */ |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1586 /** | 1613 /** |
| 1587 * @param {string} title | 1614 * @param {string} title |
| 1588 * @override | 1615 * @override |
| 1589 */ | 1616 */ |
| 1590 setTitle(title) { | 1617 setTitle(title) { |
| 1591 this._title = title; | 1618 this._title = title; |
| 1592 if (this._treeElement) | 1619 if (this._treeElement) |
| 1593 this._treeElement.title = this._title; | 1620 this._treeElement.title = this._title; |
| 1594 } | 1621 } |
| 1595 }; | 1622 }; |
| OLD | NEW |