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

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

Issue 2889013002: DevTools: introduce uiSourceCode.mimeType() method (Closed)
Patch Set: address comments Created 3 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 /** 4 /**
5 * @implements {Sources.TabbedEditorContainerDelegate} 5 * @implements {Sources.TabbedEditorContainerDelegate}
6 * @implements {UI.Searchable} 6 * @implements {UI.Searchable}
7 * @implements {UI.Replaceable} 7 * @implements {UI.Replaceable}
8 * @unrestricted 8 * @unrestricted
9 */ 9 */
10 Sources.SourcesView = class extends UI.VBox { 10 Sources.SourcesView = class extends UI.VBox {
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 _createSourceView(uiSourceCode) { 349 _createSourceView(uiSourceCode) {
350 var sourceFrame; 350 var sourceFrame;
351 var sourceView; 351 var sourceView;
352 var contentType = uiSourceCode.contentType(); 352 var contentType = uiSourceCode.contentType();
353 353
354 if (contentType.hasScripts()) 354 if (contentType.hasScripts())
355 sourceFrame = new Sources.JavaScriptSourceFrame(uiSourceCode); 355 sourceFrame = new Sources.JavaScriptSourceFrame(uiSourceCode);
356 else if (contentType.isStyleSheet()) 356 else if (contentType.isStyleSheet())
357 sourceFrame = new Sources.CSSSourceFrame(uiSourceCode); 357 sourceFrame = new Sources.CSSSourceFrame(uiSourceCode);
358 else if (contentType === Common.resourceTypes.Image) 358 else if (contentType === Common.resourceTypes.Image)
359 sourceView = new SourceFrame.ImageView(Bindings.NetworkProject.uiSourceCod eMimeType(uiSourceCode), uiSourceCode); 359 sourceView = new SourceFrame.ImageView(uiSourceCode.mimeType(), uiSourceCo de);
360 else if (contentType === Common.resourceTypes.Font) 360 else if (contentType === Common.resourceTypes.Font)
361 sourceView = new SourceFrame.FontView(Bindings.NetworkProject.uiSourceCode MimeType(uiSourceCode), uiSourceCode); 361 sourceView = new SourceFrame.FontView(uiSourceCode.mimeType(), uiSourceCod e);
362 else 362 else
363 sourceFrame = new SourceFrame.UISourceCodeFrame(uiSourceCode); 363 sourceFrame = new SourceFrame.UISourceCodeFrame(uiSourceCode);
364 364
365 if (sourceFrame) { 365 if (sourceFrame) {
366 sourceFrame.setHighlighterType(Bindings.NetworkProject.uiSourceCodeMimeTyp e(uiSourceCode)); 366 sourceFrame.setHighlighterType(uiSourceCode.mimeType());
367 this._historyManager.trackSourceFrameCursorJumps(sourceFrame); 367 this._historyManager.trackSourceFrameCursorJumps(sourceFrame);
368 } 368 }
369 var widget = /** @type {!UI.Widget} */ (sourceFrame || sourceView); 369 var widget = /** @type {!UI.Widget} */ (sourceFrame || sourceView);
370 this._sourceViewByUISourceCode.set(uiSourceCode, widget); 370 this._sourceViewByUISourceCode.set(uiSourceCode, widget);
371 uiSourceCode.addEventListener(Workspace.UISourceCode.Events.TitleChanged, th is._uiSourceCodeTitleChanged, this); 371 uiSourceCode.addEventListener(Workspace.UISourceCode.Events.TitleChanged, th is._uiSourceCodeTitleChanged, this);
372 return widget; 372 return widget;
373 } 373 }
374 374
375 /** 375 /**
376 * @param {!Workspace.UISourceCode} uiSourceCode 376 * @param {!Workspace.UISourceCode} uiSourceCode
(...skipping 18 matching lines...) Expand all
395 395
396 /** 396 /**
397 * @param {!Workspace.UISourceCode} uiSourceCode 397 * @param {!Workspace.UISourceCode} uiSourceCode
398 */ 398 */
399 _recreateSourceFrameIfNeeded(uiSourceCode) { 399 _recreateSourceFrameIfNeeded(uiSourceCode) {
400 var oldSourceView = this._sourceViewByUISourceCode.get(uiSourceCode); 400 var oldSourceView = this._sourceViewByUISourceCode.get(uiSourceCode);
401 if (!oldSourceView || !(oldSourceView instanceof SourceFrame.UISourceCodeFra me)) 401 if (!oldSourceView || !(oldSourceView instanceof SourceFrame.UISourceCodeFra me))
402 return; 402 return;
403 var oldSourceFrame = /** @type {!SourceFrame.UISourceCodeFrame} */ (oldSourc eView); 403 var oldSourceFrame = /** @type {!SourceFrame.UISourceCodeFrame} */ (oldSourc eView);
404 if (this._sourceFrameMatchesUISourceCode(oldSourceFrame, uiSourceCode)) { 404 if (this._sourceFrameMatchesUISourceCode(oldSourceFrame, uiSourceCode)) {
405 oldSourceFrame.setHighlighterType(Bindings.NetworkProject.uiSourceCodeMime Type(uiSourceCode)); 405 oldSourceFrame.setHighlighterType(uiSourceCode.mimeType());
406 } else { 406 } else {
407 this._editorContainer.removeUISourceCode(uiSourceCode); 407 this._editorContainer.removeUISourceCode(uiSourceCode);
408 this._removeSourceFrame(uiSourceCode); 408 this._removeSourceFrame(uiSourceCode);
409 } 409 }
410 } 410 }
411 411
412 /** 412 /**
413 * @override 413 * @override
414 * @param {!Workspace.UISourceCode} uiSourceCode 414 * @param {!Workspace.UISourceCode} uiSourceCode
415 * @return {!UI.Widget} 415 * @return {!UI.Widget}
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 * @return {boolean} 773 * @return {boolean}
774 */ 774 */
775 handleAction(context, actionId) { 775 handleAction(context, actionId) {
776 var sourcesView = UI.context.flavor(Sources.SourcesView); 776 var sourcesView = UI.context.flavor(Sources.SourcesView);
777 if (!sourcesView) 777 if (!sourcesView)
778 return false; 778 return false;
779 sourcesView._editorContainer.closeAllFiles(); 779 sourcesView._editorContainer.closeAllFiles();
780 return true; 780 return true;
781 } 781 }
782 }; 782 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698