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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/bindings/NetworkProject.js

Issue 2736393002: DevTools: split network project into buckets (Closed)
Patch Set: fix 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/LayoutTests/inspector/sources/debugger/navigator-view.html ('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 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 cssModel.addEventListener(SDK.CSSModel.Events.StyleSheetAdded, this._s tyleSheetAdded, this), 100 cssModel.addEventListener(SDK.CSSModel.Events.StyleSheetAdded, this._s tyleSheetAdded, this),
101 cssModel.addEventListener(SDK.CSSModel.Events.StyleSheetRemoved, this. _styleSheetRemoved, this)); 101 cssModel.addEventListener(SDK.CSSModel.Events.StyleSheetRemoved, this. _styleSheetRemoved, this));
102 } 102 }
103 this._eventListeners.push(target.targetManager().addEventListener( 103 this._eventListeners.push(target.targetManager().addEventListener(
104 SDK.TargetManager.Events.SuspendStateChanged, this._suspendStateChanged, this)); 104 SDK.TargetManager.Events.SuspendStateChanged, this._suspendStateChanged, this));
105 } 105 }
106 106
107 /** 107 /**
108 * @param {!SDK.Target} target 108 * @param {!SDK.Target} target
109 * @param {?SDK.ResourceTreeFrame} frame 109 * @param {?SDK.ResourceTreeFrame} frame
110 * @param {boolean} isContentScripts 110 * @param {string} bucketType
111 * @return {string} 111 * @return {string}
112 */ 112 */
113 static projectId(target, frame, isContentScripts) { 113 static projectId(target, frame, bucketType) {
114 return target.id() + ':' + (frame ? frame.id : '') + ':' + (isContentScripts ? 'contentscripts' : ''); 114 return target.id() + ':' + (frame ? frame.id : '') + ':' + bucketType;
115 } 115 }
116 116
117 /** 117 /**
118 * @param {!SDK.Target} target 118 * @param {!SDK.Target} target
119 * @return {!Bindings.NetworkProject} 119 * @return {!Bindings.NetworkProject}
120 */ 120 */
121 static forTarget(target) { 121 static forTarget(target) {
122 return target[Bindings.NetworkProject._networkProjectSymbol]; 122 return target[Bindings.NetworkProject._networkProjectSymbol];
123 } 123 }
124 124
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 156
157 var resource = uiSourceCode[Bindings.NetworkProject._resourceSymbol]; 157 var resource = uiSourceCode[Bindings.NetworkProject._resourceSymbol];
158 if (resource) 158 if (resource)
159 return resource.mimeType; 159 return resource.mimeType;
160 var mimeType = Common.ResourceType.mimeFromURL(uiSourceCode.url()); 160 var mimeType = Common.ResourceType.mimeFromURL(uiSourceCode.url());
161 return mimeType || uiSourceCode.contentType().canonicalMimeType(); 161 return mimeType || uiSourceCode.contentType().canonicalMimeType();
162 } 162 }
163 163
164 /** 164 /**
165 * @param {?SDK.ResourceTreeFrame} frame 165 * @param {?SDK.ResourceTreeFrame} frame
166 * @param {boolean} isContentScripts 166 * @param {string} bucketType
167 * @return {!Bindings.ContentProviderBasedProject} 167 * @return {!Bindings.ContentProviderBasedProject}
168 */ 168 */
169 _workspaceProject(frame, isContentScripts) { 169 _workspaceProject(frame, bucketType) {
170 var projectId = Bindings.NetworkProject.projectId(this.target(), frame, isCo ntentScripts); 170 var projectId = Bindings.NetworkProject.projectId(this.target(), frame, buck etType);
171 var projectType = isContentScripts ? Workspace.projectTypes.ContentScripts : Workspace.projectTypes.Network; 171 var isContentScriptBucket = bucketType === Bindings.ProjectBuckets.ContentSc riptsBucket ||
172 bucketType === Bindings.ProjectBuckets.SourceMapContentScriptsBucket;
173 var projectType = isContentScriptBucket ? Workspace.projectTypes.ContentScri pts : Workspace.projectTypes.Network;
172 174
173 var project = this._workspaceProjects.get(projectId); 175 var project = this._workspaceProjects.get(projectId);
174 if (project) 176 if (project)
175 return project; 177 return project;
176 178
177 project = new Bindings.ContentProviderBasedProject( 179 project = new Bindings.ContentProviderBasedProject(
178 this._workspace, projectId, projectType, '', false /* isServiceProject * /); 180 this._workspace, projectId, projectType, '', false /* isServiceProject * /);
179 project[Bindings.NetworkProject._targetSymbol] = this.target(); 181 project[Bindings.NetworkProject._targetSymbol] = this.target();
180 project[Bindings.NetworkProject._frameSymbol] = frame; 182 project[Bindings.NetworkProject._frameSymbol] = frame;
183 project[Bindings.NetworkProject._bucketSymbol] = bucketType;
181 this._workspaceProjects.set(projectId, project); 184 this._workspaceProjects.set(projectId, project);
182 return project; 185 return project;
183 } 186 }
184 187
185 /** 188 /**
186 * @param {!Common.ContentProvider} contentProvider 189 * @param {!Common.ContentProvider} contentProvider
187 * @param {?SDK.ResourceTreeFrame} frame 190 * @param {?SDK.ResourceTreeFrame} frame
188 * @param {boolean} isContentScript 191 * @param {boolean} isContentScript
189 * @param {?number} contentSize 192 * @param {?number} contentSize
190 * @return {!Workspace.UISourceCode} 193 * @return {!Workspace.UISourceCode}
191 */ 194 */
192 addFile(contentProvider, frame, isContentScript, contentSize) { 195 addFile(contentProvider, frame, isContentScript, contentSize) {
193 var uiSourceCode = this._createFile(contentProvider, frame, isContentScript || false); 196 var bucketType = isContentScript ? Bindings.ProjectBuckets.SourceMapContentS criptsBucket :
197 Bindings.ProjectBuckets.SourceMapBucket;
198 var uiSourceCode = this._createFile(contentProvider, frame, bucketType);
194 var metadata = typeof contentSize === 'number' ? new Workspace.UISourceCodeM etadata(null, contentSize) : null; 199 var metadata = typeof contentSize === 'number' ? new Workspace.UISourceCodeM etadata(null, contentSize) : null;
195 this._addUISourceCodeWithProvider(uiSourceCode, contentProvider, metadata); 200 this._addUISourceCodeWithProvider(uiSourceCode, contentProvider, metadata);
196 return uiSourceCode; 201 return uiSourceCode;
197 } 202 }
198 203
199 /** 204 /**
200 * @param {?SDK.ResourceTreeFrame} frame 205 * @param {?SDK.ResourceTreeFrame} frame
201 * @param {string} url 206 * @param {string} url
207 * @param {string} bucketType
202 */ 208 */
203 _removeFileForURL(frame, url) { 209 _removeFileForURL(frame, url, bucketType) {
204 var project = this._workspaceProjects.get(Bindings.NetworkProject.projectId( this.target(), frame, false)); 210 var project = this._workspaceProjects.get(Bindings.NetworkProject.projectId( this.target(), frame, bucketType));
205 if (!project) 211 if (!project)
206 return; 212 return;
207 project.removeFile(url); 213 project.removeFile(url);
208 } 214 }
209 215
210 _populate() { 216 _populateResources() {
211 /** 217 /**
212 * @param {!SDK.ResourceTreeFrame} frame 218 * @param {!SDK.ResourceTreeFrame} frame
213 * @this {Bindings.NetworkProject} 219 * @this {Bindings.NetworkProject}
214 */ 220 */
215 function populateFrame(frame) { 221 function populateFrame(frame) {
216 for (var i = 0; i < frame.childFrames.length; ++i) 222 for (var i = 0; i < frame.childFrames.length; ++i)
217 populateFrame.call(this, frame.childFrames[i]); 223 populateFrame.call(this, frame.childFrames[i]);
218 224
219 var resources = frame.resources(); 225 var resources = frame.resources();
220 for (var i = 0; i < resources.length; ++i) 226 for (var i = 0; i < resources.length; ++i)
(...skipping 23 matching lines...) Expand all
244 var script = /** @type {!SDK.Script} */ (event.data); 250 var script = /** @type {!SDK.Script} */ (event.data);
245 if (!script.sourceURL || script.isLiveEdit() || (script.isInlineScript() && !script.hasSourceURL)) 251 if (!script.sourceURL || script.isLiveEdit() || (script.isInlineScript() && !script.hasSourceURL))
246 return; 252 return;
247 // Filter out embedder injected content scripts. 253 // Filter out embedder injected content scripts.
248 if (script.isContentScript() && !script.hasSourceURL) { 254 if (script.isContentScript() && !script.hasSourceURL) {
249 var parsedURL = new Common.ParsedURL(script.sourceURL); 255 var parsedURL = new Common.ParsedURL(script.sourceURL);
250 if (!parsedURL.isValid) 256 if (!parsedURL.isValid)
251 return; 257 return;
252 } 258 }
253 var originalContentProvider = script.originalContentProvider(); 259 var originalContentProvider = script.originalContentProvider();
254 var uiSourceCode = 260 var bucketType = script.isContentScript() ? Bindings.ProjectBuckets.ContentS criptsBucket :
255 this._createFile(originalContentProvider, SDK.ResourceTreeFrame.fromScri pt(script), script.isContentScript()); 261 Bindings.ProjectBuckets.RegularS criptsBucket;
262 var uiSourceCode = this._createFile(originalContentProvider, SDK.ResourceTre eFrame.fromScript(script), bucketType);
256 uiSourceCode[Bindings.NetworkProject._scriptSymbol] = script; 263 uiSourceCode[Bindings.NetworkProject._scriptSymbol] = script;
257 var resource = SDK.ResourceTreeModel.resourceForURL(uiSourceCode.url()); 264 var resource = SDK.ResourceTreeModel.resourceForURL(uiSourceCode.url());
258 this._addUISourceCodeWithProvider(uiSourceCode, originalContentProvider, thi s._resourceMetadata(resource)); 265 this._addUISourceCodeWithProvider(uiSourceCode, originalContentProvider, thi s._resourceMetadata(resource));
259 } 266 }
260 267
261 /** 268 /**
262 * @param {!Common.Event} event 269 * @param {!Common.Event} event
263 */ 270 */
264 _styleSheetAdded(event) { 271 _styleSheetAdded(event) {
265 var header = /** @type {!SDK.CSSStyleSheetHeader} */ (event.data); 272 var header = /** @type {!SDK.CSSStyleSheetHeader} */ (event.data);
266 if (header.isInline && !header.hasSourceURL && header.origin !== 'inspector' ) 273 if (header.isInline && !header.hasSourceURL && header.origin !== 'inspector' )
267 return; 274 return;
268 if (!header.resourceURL()) 275 if (!header.resourceURL())
269 return; 276 return;
270 277
271 var originalContentProvider = header.originalContentProvider(); 278 var originalContentProvider = header.originalContentProvider();
272 var uiSourceCode = this._createFile(originalContentProvider, SDK.ResourceTre eFrame.fromStyleSheet(header), false); 279 var uiSourceCode = this._createFile(
280 originalContentProvider, SDK.ResourceTreeFrame.fromStyleSheet(header),
281 Bindings.ProjectBuckets.StyleSheetsBucket);
273 uiSourceCode[Bindings.NetworkProject._styleSheetSymbol] = header; 282 uiSourceCode[Bindings.NetworkProject._styleSheetSymbol] = header;
274 var resource = SDK.ResourceTreeModel.resourceForURL(uiSourceCode.url()); 283 var resource = SDK.ResourceTreeModel.resourceForURL(uiSourceCode.url());
275 this._addUISourceCodeWithProvider(uiSourceCode, originalContentProvider, thi s._resourceMetadata(resource)); 284 this._addUISourceCodeWithProvider(uiSourceCode, originalContentProvider, thi s._resourceMetadata(resource));
276 } 285 }
277 286
278 /** 287 /**
279 * @param {!Common.Event} event 288 * @param {!Common.Event} event
280 */ 289 */
281 _styleSheetRemoved(event) { 290 _styleSheetRemoved(event) {
282 var header = /** @type {!SDK.CSSStyleSheetHeader} */ (event.data); 291 var header = /** @type {!SDK.CSSStyleSheetHeader} */ (event.data);
283 if (header.isInline && !header.hasSourceURL && header.origin !== 'inspector' ) 292 if (header.isInline && !header.hasSourceURL && header.origin !== 'inspector' )
284 return; 293 return;
285 294
286 this._removeFileForURL(SDK.ResourceTreeFrame.fromStyleSheet(header), header. resourceURL()); 295 this._removeFileForURL(
296 SDK.ResourceTreeFrame.fromStyleSheet(header), header.resourceURL(), Bind ings.ProjectBuckets.StyleSheetsBucket);
287 } 297 }
288 298
289 /** 299 /**
290 * @param {!Common.Event} event 300 * @param {!Common.Event} event
291 */ 301 */
292 _resourceAdded(event) { 302 _resourceAdded(event) {
293 var resource = /** @type {!SDK.Resource} */ (event.data); 303 var resource = /** @type {!SDK.Resource} */ (event.data);
294 this._addResource(resource); 304 this._addResource(resource);
295 } 305 }
296 306
(...skipping 12 matching lines...) Expand all
309 if (resourceType === Common.resourceTypes.Image && resource.mimeType && !res ource.mimeType.startsWith('image')) 319 if (resourceType === Common.resourceTypes.Image && resource.mimeType && !res ource.mimeType.startsWith('image'))
310 return; 320 return;
311 if (resourceType === Common.resourceTypes.Font && resource.mimeType && !reso urce.mimeType.includes('font')) 321 if (resourceType === Common.resourceTypes.Font && resource.mimeType && !reso urce.mimeType.includes('font'))
312 return; 322 return;
313 if ((resourceType === Common.resourceTypes.Image || resourceType === Common. resourceTypes.Font) && 323 if ((resourceType === Common.resourceTypes.Image || resourceType === Common. resourceTypes.Font) &&
314 resource.contentURL().startsWith('data:')) 324 resource.contentURL().startsWith('data:'))
315 return; 325 return;
316 326
317 var frame = SDK.ResourceTreeFrame.fromResource(resource); 327 var frame = SDK.ResourceTreeFrame.fromResource(resource);
318 // Never load document twice. 328 // Never load document twice.
319 var projectId = Bindings.NetworkProject.projectId(this.target(), frame, fals e); 329 var projectId = Bindings.NetworkProject.projectId(this.target(), frame, Bind ings.ProjectBuckets.ResourcesBucket);
320 var project = this._workspaceProjects.get(projectId); 330 var project = this._workspaceProjects.get(projectId);
321 if (project && project.uiSourceCodeForURL(resource.url)) 331 if (project && project.uiSourceCodeForURL(resource.url))
322 return; 332 return;
323 333
324 var uiSourceCode = this._createFile(resource, frame, false); 334 var uiSourceCode = this._createFile(resource, frame, Bindings.ProjectBuckets .ResourcesBucket);
325 uiSourceCode[Bindings.NetworkProject._resourceSymbol] = resource; 335 uiSourceCode[Bindings.NetworkProject._resourceSymbol] = resource;
326 this._addUISourceCodeWithProvider(uiSourceCode, resource, this._resourceMeta data(resource)); 336 this._addUISourceCodeWithProvider(uiSourceCode, resource, this._resourceMeta data(resource));
327 } 337 }
328 338
329 /** 339 /**
330 * @param {!SDK.ResourceTreeFrame} frame 340 * @param {!SDK.ResourceTreeFrame} frame
331 */ 341 */
332 _removeFrameResources(frame) { 342 _removeFrameResources(frame) {
333 var project = this._workspaceProject(frame, false); 343 // TODO(lushnikov): this method should clean up only ResourcesBucket.
334 for (var resource of frame.resources()) 344 var projects = [
335 project.removeUISourceCode(resource.url); 345 this._workspaceProject(frame, Bindings.ProjectBuckets.ResourcesBucket),
336 project = this._workspaceProject(frame, true); 346 this._workspaceProject(frame, Bindings.ProjectBuckets.ContentScriptsBucket ),
337 for (var resource of frame.resources()) 347 this._workspaceProject(frame, Bindings.ProjectBuckets.RegularScriptsBucket ),
338 project.removeUISourceCode(resource.url); 348 this._workspaceProject(frame, Bindings.ProjectBuckets.StyleSheetsBucket),
349 ];
350 for (var resource of frame.resources()) {
351 for (var project of projects)
352 project.removeUISourceCode(resource.url);
353 }
339 } 354 }
340 355
341 /** 356 /**
342 * @param {!Common.Event} event 357 * @param {!Common.Event} event
343 */ 358 */
344 _frameWillNavigate(event) { 359 _frameWillNavigate(event) {
345 var frame = /** @type {!SDK.ResourceTreeFrame} */ (event.data); 360 var frame = /** @type {!SDK.ResourceTreeFrame} */ (event.data);
346 this._removeFrameResources(frame); 361 this._removeFrameResources(frame);
347 } 362 }
348 363
349 /** 364 /**
350 * @param {!Common.Event} event 365 * @param {!Common.Event} event
351 */ 366 */
352 _frameDetached(event) { 367 _frameDetached(event) {
353 var frame = /** @type {!SDK.ResourceTreeFrame} */ (event.data); 368 var frame = /** @type {!SDK.ResourceTreeFrame} */ (event.data);
354 this._removeFrameResources(frame); 369 this._removeFrameResources(frame);
355 } 370 }
356 371
357 /** 372 /**
358 * @param {!Common.Event} event 373 * @param {!Common.Event} event
359 */ 374 */
360 _mainFrameNavigated(event) { 375 _mainFrameNavigated(event) {
361 this._reset(); 376 this._resetResources();
362 } 377 }
363 378
364 _suspendStateChanged() { 379 _suspendStateChanged() {
365 if (this.target().targetManager().allTargetsSuspended()) 380 if (this.target().targetManager().allTargetsSuspended())
366 this._reset(); 381 this._resetResources();
367 else 382 else
368 this._populate(); 383 this._populateResources();
369 } 384 }
370 385
371 /** 386 /**
372 * @param {!Common.ContentProvider} contentProvider 387 * @param {!Common.ContentProvider} contentProvider
373 * @param {?SDK.ResourceTreeFrame} frame 388 * @param {?SDK.ResourceTreeFrame} frame
374 * @param {boolean} isContentScript 389 * @param {string} bucketType
375 * @return {!Workspace.UISourceCode} 390 * @return {!Workspace.UISourceCode}
376 */ 391 */
377 _createFile(contentProvider, frame, isContentScript) { 392 _createFile(contentProvider, frame, bucketType) {
378 var url = contentProvider.contentURL(); 393 var url = contentProvider.contentURL();
379 var project = this._workspaceProject(frame, isContentScript); 394 var project = this._workspaceProject(frame, bucketType);
380 var uiSourceCode = project.createUISourceCode(url, contentProvider.contentTy pe()); 395 var uiSourceCode = project.createUISourceCode(url, contentProvider.contentTy pe());
381 uiSourceCode[Bindings.NetworkProject._targetSymbol] = this.target(); 396 uiSourceCode[Bindings.NetworkProject._targetSymbol] = this.target();
382 return uiSourceCode; 397 return uiSourceCode;
383 } 398 }
384 399
385 /** 400 /**
386 * @param {?SDK.Resource} resource 401 * @param {?SDK.Resource} resource
387 * @return {?Workspace.UISourceCodeMetadata} 402 * @return {?Workspace.UISourceCodeMetadata}
388 */ 403 */
389 _resourceMetadata(resource) { 404 _resourceMetadata(resource) {
390 if (!resource || (typeof resource.contentSize() !== 'number' && !resource.la stModified())) 405 if (!resource || (typeof resource.contentSize() !== 'number' && !resource.la stModified()))
391 return null; 406 return null;
392 return new Workspace.UISourceCodeMetadata(resource.lastModified(), resource. contentSize()); 407 return new Workspace.UISourceCodeMetadata(resource.lastModified(), resource. contentSize());
393 } 408 }
394 409
395 _dispose() { 410 _dispose() {
396 this._reset(); 411 for (var project of this._workspaceProjects.values())
412 project.removeProject();
397 Common.EventTarget.removeEventListeners(this._eventListeners); 413 Common.EventTarget.removeEventListeners(this._eventListeners);
398 delete this.target()[Bindings.NetworkProject._networkProjectSymbol]; 414 delete this.target()[Bindings.NetworkProject._networkProjectSymbol];
399 } 415 }
400 416
401 _reset() { 417 _resetResources() {
402 for (var project of this._workspaceProjects.values()) 418 // TODO(lushnikov): this method should clean up only ResourcesBucket.
403 project.removeProject(); 419 for (var projectId of this._workspaceProjects.keys()) {
404 this._workspaceProjects.clear(); 420 var project = this._workspaceProjects.get(projectId);
421 switch (project[Bindings.NetworkProject._bucketSymbol]) {
422 case Bindings.ProjectBuckets.ResourcesBucket:
423 case Bindings.ProjectBuckets.ContentScriptsBucket:
424 case Bindings.ProjectBuckets.RegularScriptsBucket:
425 case Bindings.ProjectBuckets.StyleSheetsBucket:
426 case Bindings.ProjectBuckets.SourceMapBucket:
427 case Bindings.ProjectBuckets.SourceMapContentScriptsBucket:
428 project.removeProject();
429 this._workspaceProjects.delete(projectId);
430 break;
431 }
432 }
405 } 433 }
406 434
407 /** 435 /**
408 * @param {!Workspace.Workspace} workspace 436 * @param {!Workspace.Workspace} workspace
409 * @param {string} url 437 * @param {string} url
410 * @param {!SDK.Script} script 438 * @param {!SDK.Script} script
411 * @return {?Workspace.UISourceCode} 439 * @return {?Workspace.UISourceCode}
412 */ 440 */
413 static uiSourceCodeForScriptURL(workspace, url, script) { 441 static uiSourceCodeForScriptURL(workspace, url, script) {
442 var buckets = [];
443 if (script.isContentScript()) {
444 buckets = [Bindings.ProjectBuckets.SourceMapContentScriptsBucket, Bindings .ProjectBuckets.ContentScriptsBucket];
445 } else {
446 buckets = [
447 Bindings.ProjectBuckets.SourceMapBucket, Bindings.ProjectBuckets.Regular ScriptsBucket,
448 Bindings.ProjectBuckets.ResourcesBucket
449 ];
450 }
414 var target = script.debuggerModel.target(); 451 var target = script.debuggerModel.target();
415 var frame = SDK.ResourceTreeFrame.fromScript(script); 452 var frame = SDK.ResourceTreeFrame.fromScript(script);
416 return workspace.uiSourceCode(Bindings.NetworkProject.projectId(target, fram e, false), url) || 453 var projectIds = buckets.map(bucket => Bindings.NetworkProject.projectId(tar get, frame, bucket));
417 workspace.uiSourceCode(Bindings.NetworkProject.projectId(target, frame, true), url); 454 for (var projectId of projectIds) {
455 var uiSourceCode = workspace.uiSourceCode(projectId, url);
456 if (uiSourceCode)
457 return uiSourceCode;
458 }
459 return null;
418 } 460 }
419 461
420 /** 462 /**
421 * @param {!Workspace.Workspace} workspace 463 * @param {!Workspace.Workspace} workspace
422 * @param {string} url 464 * @param {string} url
423 * @param {!SDK.CSSStyleSheetHeader} header 465 * @param {!SDK.CSSStyleSheetHeader} header
424 * @return {?Workspace.UISourceCode} 466 * @return {?Workspace.UISourceCode}
425 */ 467 */
426 static uiSourceCodeForStyleURL(workspace, url, header) { 468 static uiSourceCodeForStyleURL(workspace, url, header) {
469 var buckets = [
470 Bindings.ProjectBuckets.SourceMapBucket, Bindings.ProjectBuckets.StyleShee tsBucket,
471 Bindings.ProjectBuckets.ResourcesBucket
472 ];
427 var frame = SDK.ResourceTreeFrame.fromStyleSheet(header); 473 var frame = SDK.ResourceTreeFrame.fromStyleSheet(header);
428 return workspace.uiSourceCode(Bindings.NetworkProject.projectId(header.targe t(), frame, false), url); 474 var target = header.target();
475 var projectIds = buckets.map(bucket => Bindings.NetworkProject.projectId(tar get, frame, bucket));
476 for (var projectId of projectIds) {
477 var uiSourceCode = workspace.uiSourceCode(projectId, url);
478 if (uiSourceCode)
479 return uiSourceCode;
480 }
481 return null;
429 } 482 }
430 }; 483 };
431 484
485 /** @enum {string} */
486 Bindings.ProjectBuckets = {
487 ResourcesBucket: 'ResourcesBucket',
488 ContentScriptsBucket: 'ContentScriptsBucket',
489 RegularScriptsBucket: 'RegularScriptsBucket',
490 StyleSheetsBucket: 'StyleSheetsBucket',
491 SourceMapBucket: 'SourceMapBucket',
492 SourceMapContentScriptsBucket: 'SourceMapContentScriptsBucket',
493 };
494
432 Bindings.NetworkProject._networkProjectSymbol = Symbol('networkProject'); 495 Bindings.NetworkProject._networkProjectSymbol = Symbol('networkProject');
433 Bindings.NetworkProject._resourceSymbol = Symbol('resource'); 496 Bindings.NetworkProject._resourceSymbol = Symbol('resource');
434 Bindings.NetworkProject._scriptSymbol = Symbol('script'); 497 Bindings.NetworkProject._scriptSymbol = Symbol('script');
435 Bindings.NetworkProject._styleSheetSymbol = Symbol('styleSheet'); 498 Bindings.NetworkProject._styleSheetSymbol = Symbol('styleSheet');
436 Bindings.NetworkProject._targetSymbol = Symbol('target'); 499 Bindings.NetworkProject._targetSymbol = Symbol('target');
437 Bindings.NetworkProject._frameSymbol = Symbol('frame'); 500 Bindings.NetworkProject._frameSymbol = Symbol('frame');
501 Bindings.NetworkProject._bucketSymbol = Symbol('bucket');
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/sources/debugger/navigator-view.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698