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

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

Issue 2662513003: DevTools: make StylesSourceMapping in charge of creating and removing UISourceCodes (Closed)
Patch Set: pass tests Created 3 years, 9 months 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
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/main/Main.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 *
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 Persistence.persistence.addEventListener( 71 Persistence.persistence.addEventListener(
72 Persistence.Persistence.Events.BindingCreated, this._onBindingCreated, this); 72 Persistence.Persistence.Events.BindingCreated, this._onBindingCreated, this);
73 Persistence.persistence.addEventListener( 73 Persistence.persistence.addEventListener(
74 Persistence.Persistence.Events.BindingRemoved, this._onBindingRemoved, this); 74 Persistence.Persistence.Events.BindingRemoved, this._onBindingRemoved, this);
75 } 75 }
76 SDK.targetManager.addEventListener(SDK.TargetManager.Events.NameChanged, thi s._targetNameChanged, this); 76 SDK.targetManager.addEventListener(SDK.TargetManager.Events.NameChanged, thi s._targetNameChanged, this);
77 77
78 SDK.targetManager.observeTargets(this); 78 SDK.targetManager.observeTargets(this);
79 this._resetWorkspace(Workspace.workspace); 79 this._resetWorkspace(Workspace.workspace);
80 this._workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this)); 80 this._workspace.uiSourceCodes().forEach(this._addUISourceCode.bind(this));
81
82 Bindings.networkProjectManager.on(
83 Bindings.NetworkProjectManager.FrameAttributionChangedEvent, this._frame AttributionChanged, this);
81 } 84 }
82 85
83 /** 86 /**
84 * @param {!UI.TreeElement} treeElement 87 * @param {!UI.TreeElement} treeElement
85 */ 88 */
86 static _treeElementOrder(treeElement) { 89 static _treeElementOrder(treeElement) {
87 if (treeElement._boostOrder) 90 if (treeElement._boostOrder)
88 return 0; 91 return 0;
89 92
90 if (!Sources.NavigatorView._typeOrders) { 93 if (!Sources.NavigatorView._typeOrders) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 _onBindingCreated(event) { 172 _onBindingCreated(event) {
170 var binding = /** @type {!Persistence.PersistenceBinding} */ (event.data); 173 var binding = /** @type {!Persistence.PersistenceBinding} */ (event.data);
171 this._removeUISourceCode(binding.network); 174 this._removeUISourceCode(binding.network);
172 } 175 }
173 176
174 /** 177 /**
175 * @param {!Common.Event} event 178 * @param {!Common.Event} event
176 */ 179 */
177 _onBindingRemoved(event) { 180 _onBindingRemoved(event) {
178 var binding = /** @type {!Persistence.PersistenceBinding} */ (event.data); 181 var binding = /** @type {!Persistence.PersistenceBinding} */ (event.data);
179 this._addUISourceCode(binding.network); 182 if (this._addUISourceCode(binding.network))
183 this.uiSourceCodeAdded(binding.network);
180 } 184 }
181 185
182 /** 186 /**
183 * @param {!Common.Event} event 187 * @param {!Common.Event} event
184 */ 188 */
185 _onBindingChanged(event) { 189 _onBindingChanged(event) {
186 var binding = /** @type {!Persistence.PersistenceBinding} */ (event.data); 190 var binding = /** @type {!Persistence.PersistenceBinding} */ (event.data);
187 191
188 // Update UISourceCode titles. 192 // Update UISourceCode titles.
189 var networkNodes = this._uiSourceCodeNodes.get(binding.network) || []; 193 var networkNodes = this._uiSourceCodeNodes.get(binding.network) || [];
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 /** 244 /**
241 * @param {!Workspace.UISourceCode} uiSourceCode 245 * @param {!Workspace.UISourceCode} uiSourceCode
242 * @return {boolean} 246 * @return {boolean}
243 */ 247 */
244 accept(uiSourceCode) { 248 accept(uiSourceCode) {
245 return !uiSourceCode.project().isServiceProject(); 249 return !uiSourceCode.project().isServiceProject();
246 } 250 }
247 251
248 /** 252 /**
249 * @param {!Workspace.UISourceCode} uiSourceCode 253 * @param {!Workspace.UISourceCode} uiSourceCode
250 * @return {?SDK.ResourceTreeFrame} 254 * @return {!Array<?SDK.ResourceTreeFrame>}
251 */ 255 */
252 _uiSourceCodeFrame(uiSourceCode) { 256 _uiSourceCodeFrames(uiSourceCode) {
253 var frame = Bindings.NetworkProject.frameForProject(uiSourceCode.project()); 257 var frames = Bindings.NetworkProject.framesForUISourceCode(uiSourceCode).sli ce();
254 if (!frame) { 258 if (!frames.length) {
255 var target = Bindings.NetworkProject.targetForProject(uiSourceCode.project ()); 259 var target = Bindings.NetworkProject.targetForProject(uiSourceCode.project ());
256 var resourceTreeModel = target && SDK.ResourceTreeModel.fromTarget(target) ; 260 var resourceTreeModel = target && SDK.ResourceTreeModel.fromTarget(target) ;
257 frame = resourceTreeModel && resourceTreeModel.mainFrame; 261 var frame = resourceTreeModel && resourceTreeModel.mainFrame;
262 frames.push(frame ? frame : null);
258 } 263 }
259 return frame; 264 return frames;
260 } 265 }
261 266
262 /** 267 /**
268 * @param {!Bindings.NetworkProjectManager.FrameAttributionChangedEvent} event
269 */
270 _frameAttributionChanged(event) {
271 var uiSourceCode = event.uiSourceCode;
272 this._removeUISourceCode(uiSourceCode);
273 this._addUISourceCode(uiSourceCode);
274 }
275
276 /**
263 * @param {!Workspace.UISourceCode} uiSourceCode 277 * @param {!Workspace.UISourceCode} uiSourceCode
264 */ 278 */
265 _addUISourceCode(uiSourceCode) { 279 _addUISourceCode(uiSourceCode) {
266 if (!this.accept(uiSourceCode)) 280 if (!this.accept(uiSourceCode))
267 return; 281 return false;
268 282
269 var binding = Persistence.persistence.binding(uiSourceCode); 283 var binding = Persistence.persistence.binding(uiSourceCode);
270 if (!Runtime.experiments.isEnabled('persistence2') && binding && binding.net work === uiSourceCode) 284 if (!Runtime.experiments.isEnabled('persistence2') && binding && binding.net work === uiSourceCode)
271 return; 285 return false;
272 286
273 var isFromSourceMap = uiSourceCode.contentType().isFromSourceMap(); 287 var isFromSourceMap = uiSourceCode.contentType().isFromSourceMap();
274 var path; 288 var path;
275 if (uiSourceCode.project().type() === Workspace.projectTypes.FileSystem) 289 if (uiSourceCode.project().type() === Workspace.projectTypes.FileSystem)
276 path = Persistence.FileSystemWorkspaceBinding.relativePath(uiSourceCode).s lice(0, -1); 290 path = Persistence.FileSystemWorkspaceBinding.relativePath(uiSourceCode).s lice(0, -1);
277 else 291 else
278 path = Common.ParsedURL.extractPath(uiSourceCode.url()).split('/').slice(1 , -1); 292 path = Common.ParsedURL.extractPath(uiSourceCode.url()).split('/').slice(1 , -1);
279 293
280 var project = uiSourceCode.project(); 294 var project = uiSourceCode.project();
281 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode); 295 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode);
282 var frame = this._uiSourceCodeFrame(uiSourceCode); 296 var frames = this._uiSourceCodeFrames(uiSourceCode);
297 var uiSourceCodeNodes = [];
298 for (var frame of frames) {
299 var folderNode =
300 this._folderNode(uiSourceCode, project, target, frame, uiSourceCode.or igin(), path, isFromSourceMap);
301 var uiSourceCodeNode = new Sources.NavigatorUISourceCodeTreeNode(this, uiS ourceCode, frame);
302 folderNode.appendChild(uiSourceCodeNode);
303 uiSourceCodeNodes.push(uiSourceCodeNode);
304 }
283 305
284 var folderNode = 306 this._uiSourceCodeNodes.set(uiSourceCode, uiSourceCodeNodes);
285 this._folderNode(uiSourceCode, project, target, frame, uiSourceCode.orig in(), path, isFromSourceMap);
286 var uiSourceCodeNode = new Sources.NavigatorUISourceCodeTreeNode(this, uiSou rceCode);
287 this._uiSourceCodeNodes.set(uiSourceCode, [uiSourceCodeNode]);
288 folderNode.appendChild(uiSourceCodeNode);
289 this.uiSourceCodeAdded(uiSourceCode); 307 this.uiSourceCodeAdded(uiSourceCode);
dgozman 2017/02/23 02:17:27 Remove.
308 return true;
290 } 309 }
291 310
292 /** 311 /**
293 * @param {!Workspace.UISourceCode} uiSourceCode 312 * @param {!Workspace.UISourceCode} uiSourceCode
294 */ 313 */
295 uiSourceCodeAdded(uiSourceCode) { 314 uiSourceCodeAdded(uiSourceCode) {
296 } 315 }
297 316
298 /** 317 /**
299 * @param {!Common.Event} event 318 * @param {!Common.Event} event
300 */ 319 */
301 _uiSourceCodeAdded(event) { 320 _uiSourceCodeAdded(event) {
302 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (event.data); 321 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (event.data);
303 this._addUISourceCode(uiSourceCode); 322 if (this._addUISourceCode(uiSourceCode))
323 this.uiSourceCodeAdded(uiSourceCode);
304 } 324 }
305 325
306 /** 326 /**
307 * @param {!Common.Event} event 327 * @param {!Common.Event} event
308 */ 328 */
309 _uiSourceCodeRemoved(event) { 329 _uiSourceCodeRemoved(event) {
310 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (event.data); 330 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (event.data);
311 this._removeUISourceCode(uiSourceCode); 331 this._removeUISourceCode(uiSourceCode);
312 } 332 }
313 333
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 /** 545 /**
526 * @param {!Workspace.UISourceCode} uiSourceCode 546 * @param {!Workspace.UISourceCode} uiSourceCode
527 */ 547 */
528 _removeUISourceCode(uiSourceCode) { 548 _removeUISourceCode(uiSourceCode) {
529 var nodes = this._uiSourceCodeNodes.get(uiSourceCode) || []; 549 var nodes = this._uiSourceCodeNodes.get(uiSourceCode) || [];
530 for (var i = 0; i < nodes.length; i++) { 550 for (var i = 0; i < nodes.length; i++) {
531 var node = nodes[i]; 551 var node = nodes[i];
532 552
533 var project = uiSourceCode.project(); 553 var project = uiSourceCode.project();
534 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode); 554 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode);
535 var frame = this._uiSourceCodeFrame(uiSourceCode); 555 var frame = node.frame();
536 556
537 var parentNode = node.parent; 557 var parentNode = node.parent;
538 parentNode.removeChild(node); 558 parentNode.removeChild(node);
539 node = parentNode; 559 node = parentNode;
540 560
541 while (node) { 561 while (node) {
542 parentNode = node.parent; 562 parentNode = node.parent;
543 if (!parentNode || !node.isEmpty()) 563 if (!parentNode || !node.isEmpty())
544 break; 564 break;
545 if (!(node instanceof Sources.NavigatorGroupTreeNode || node instanceof Sources.NavigatorFolderTreeNode)) 565 if (!(node instanceof Sources.NavigatorGroupTreeNode || node instanceof Sources.NavigatorFolderTreeNode))
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 } 1251 }
1232 }; 1252 };
1233 1253
1234 /** 1254 /**
1235 * @unrestricted 1255 * @unrestricted
1236 */ 1256 */
1237 Sources.NavigatorUISourceCodeTreeNode = class extends Sources.NavigatorTreeNode { 1257 Sources.NavigatorUISourceCodeTreeNode = class extends Sources.NavigatorTreeNode {
1238 /** 1258 /**
1239 * @param {!Sources.NavigatorView} navigatorView 1259 * @param {!Sources.NavigatorView} navigatorView
1240 * @param {!Workspace.UISourceCode} uiSourceCode 1260 * @param {!Workspace.UISourceCode} uiSourceCode
1261 * @param {?SDK.ResourceTreeFrame} frame
1241 */ 1262 */
1242 constructor(navigatorView, uiSourceCode) { 1263 constructor(navigatorView, uiSourceCode, frame) {
1243 super(uiSourceCode.project().id() + ':' + uiSourceCode.url(), Sources.Naviga torView.Types.File); 1264 super(uiSourceCode.project().id() + ':' + uiSourceCode.url(), Sources.Naviga torView.Types.File);
1244 this._navigatorView = navigatorView; 1265 this._navigatorView = navigatorView;
1245 this._uiSourceCode = uiSourceCode; 1266 this._uiSourceCode = uiSourceCode;
1246 this._treeElement = null; 1267 this._treeElement = null;
1247 this._eventListeners = []; 1268 this._eventListeners = [];
1269 this._frame = frame;
1248 } 1270 }
1249 1271
1250 /** 1272 /**
1273 * @return {?SDK.ResourceTreeFrame}
1274 */
1275 frame() {
1276 return this._frame;
1277 }
1278
1279 /**
1251 * @return {!Workspace.UISourceCode} 1280 * @return {!Workspace.UISourceCode}
1252 */ 1281 */
1253 uiSourceCode() { 1282 uiSourceCode() {
1254 return this._uiSourceCode; 1283 return this._uiSourceCode;
1255 } 1284 }
1256 1285
1257 /** 1286 /**
1258 * @override 1287 * @override
1259 * @return {!UI.TreeElement} 1288 * @return {!UI.TreeElement}
1260 */ 1289 */
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1610 /** 1639 /**
1611 * @param {string} title 1640 * @param {string} title
1612 * @override 1641 * @override
1613 */ 1642 */
1614 setTitle(title) { 1643 setTitle(title) {
1615 this._title = title; 1644 this._title = title;
1616 if (this._treeElement) 1645 if (this._treeElement)
1617 this._treeElement.title = this._title; 1646 this._treeElement.title = this._title;
1618 } 1647 }
1619 }; 1648 };
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/main/Main.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698