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

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

Issue 2536273003: [DevTools] Remove Workspace.projectTypes enum part1. (Closed)
Patch Set: Created 4 years 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 22 matching lines...) Expand all
33 */ 33 */
34 Sources.JavaScriptSourceFrame = class extends Sources.UISourceCodeFrame { 34 Sources.JavaScriptSourceFrame = class extends Sources.UISourceCodeFrame {
35 /** 35 /**
36 * @param {!Workspace.UISourceCode} uiSourceCode 36 * @param {!Workspace.UISourceCode} uiSourceCode
37 */ 37 */
38 constructor(uiSourceCode) { 38 constructor(uiSourceCode) {
39 super(uiSourceCode); 39 super(uiSourceCode);
40 40
41 this._scriptsPanel = Sources.SourcesPanel.instance(); 41 this._scriptsPanel = Sources.SourcesPanel.instance();
42 this._breakpointManager = Bindings.breakpointManager; 42 this._breakpointManager = Bindings.breakpointManager;
43 if (uiSourceCode.project().type() === Workspace.projectTypes.Debugger) 43 if (Bindings.DefaultScriptMapping.isDebuggerUISourceCode(uiSourceCode))
44 this.element.classList.add('source-frame-debugger-script'); 44 this.element.classList.add('source-frame-debugger-script');
45 45
46 this._popoverHelper = new Components.ObjectPopoverHelper( 46 this._popoverHelper = new Components.ObjectPopoverHelper(
47 this._scriptsPanel.element, this._getPopoverAnchor.bind(this), this._res olveObjectForPopover.bind(this), 47 this._scriptsPanel.element, this._getPopoverAnchor.bind(this), this._res olveObjectForPopover.bind(this),
48 this._onHidePopover.bind(this), true); 48 this._onHidePopover.bind(this), true);
49 this._popoverHelper.setTimeout(250, 250); 49 this._popoverHelper.setTimeout(250, 250);
50 50
51 this.textEditor.element.addEventListener('keydown', this._onKeyDown.bind(thi s), true); 51 this.textEditor.element.addEventListener('keydown', this._onKeyDown.bind(thi s), true);
52 52
53 this.textEditor.addEventListener( 53 this.textEditor.addEventListener(
(...skipping 19 matching lines...) Expand all
73 /** @type {!Map.<!SDK.Target, !Bindings.ResourceScriptFile>}*/ 73 /** @type {!Map.<!SDK.Target, !Bindings.ResourceScriptFile>}*/
74 this._scriptFileForTarget = new Map(); 74 this._scriptFileForTarget = new Map();
75 var targets = SDK.targetManager.targets(); 75 var targets = SDK.targetManager.targets();
76 for (var i = 0; i < targets.length; ++i) { 76 for (var i = 0; i < targets.length; ++i) {
77 var scriptFile = Bindings.debuggerWorkspaceBinding.scriptFile(uiSourceCode , targets[i]); 77 var scriptFile = Bindings.debuggerWorkspaceBinding.scriptFile(uiSourceCode , targets[i]);
78 if (scriptFile) 78 if (scriptFile)
79 this._updateScriptFile(targets[i]); 79 this._updateScriptFile(targets[i]);
80 } 80 }
81 81
82 if (this._scriptFileForTarget.size || uiSourceCode.extension() === 'js' || 82 if (this._scriptFileForTarget.size || uiSourceCode.extension() === 'js' ||
83 uiSourceCode.project().type() === Workspace.projectTypes.Snippets) 83 Snippets.ScriptSnippetModel.isSnippetUISourceCode(uiSourceCode))
84 this._compiler = new Sources.JavaScriptCompiler(this); 84 this._compiler = new Sources.JavaScriptCompiler(this);
85 85
86 Common.moduleSetting('skipStackFramesPattern').addChangeListener(this._showB lackboxInfobarIfNeeded, this); 86 Common.moduleSetting('skipStackFramesPattern').addChangeListener(this._showB lackboxInfobarIfNeeded, this);
87 Common.moduleSetting('skipContentScripts').addChangeListener(this._showBlack boxInfobarIfNeeded, this); 87 Common.moduleSetting('skipContentScripts').addChangeListener(this._showBlack boxInfobarIfNeeded, this);
88 this._showBlackboxInfobarIfNeeded(); 88 this._showBlackboxInfobarIfNeeded();
89 /** @type {!Map.<number, !Element>} */ 89 /** @type {!Map.<number, !Element>} */
90 this._valueWidgets = new Map(); 90 this._valueWidgets = new Map();
91 } 91 }
92 92
93 /** 93 /**
94 * @override 94 * @override
95 * @return {!Array<!UI.ToolbarItem>} 95 * @return {!Array<!UI.ToolbarItem>}
96 */ 96 */
97 syncToolbarItems() { 97 syncToolbarItems() {
98 var result = super.syncToolbarItems(); 98 var result = super.syncToolbarItems();
99 var originURL = Bindings.CompilerScriptMapping.uiSourceCodeOrigin(this.uiSou rceCode()); 99 var originURL = Bindings.CompilerScriptMapping.uiSourceCodeOrigin(this.uiSou rceCode());
100 if (originURL) { 100 if (originURL) {
101 var parsedURL = originURL.asParsedURL(); 101 var parsedURL = originURL.asParsedURL();
102 if (parsedURL) 102 if (parsedURL)
103 result.push(new UI.ToolbarText(Common.UIString('(source mapped from %s)' , parsedURL.displayName))); 103 result.push(new UI.ToolbarText(Common.UIString('(source mapped from %s)' , parsedURL.displayName)));
104 } 104 }
105 105
106 if (this.uiSourceCode().project().type() === Workspace.projectTypes.Snippets ) { 106 if (Snippets.ScriptSnippetModel.isSnippetUISourceCode(this.uiSourceCode())) {
107 result.push(new UI.ToolbarSeparator(true)); 107 result.push(new UI.ToolbarSeparator(true));
108 var runSnippet = UI.Toolbar.createActionButtonForId('debugger.run-snippet' ); 108 var runSnippet = UI.Toolbar.createActionButtonForId('debugger.run-snippet' );
109 runSnippet.setText(Host.isMac() ? Common.UIString('\u2318+Enter') : Common .UIString('Ctrl+Enter')); 109 runSnippet.setText(Host.isMac() ? Common.UIString('\u2318+Enter') : Common .UIString('Ctrl+Enter'));
110 result.push(runSnippet); 110 result.push(runSnippet);
111 } 111 }
112 112
113 return result; 113 return result;
114 } 114 }
115 115
116 _showBlackboxInfobarIfNeeded() { 116 _showBlackboxInfobarIfNeeded() {
117 var uiSourceCode = this.uiSourceCode(); 117 var uiSourceCode = this.uiSourceCode();
118 if (!uiSourceCode.contentType().hasScripts()) 118 if (!uiSourceCode.contentType().hasScripts())
119 return; 119 return;
120 var projectType = uiSourceCode.project().type(); 120 if (Snippets.ScriptSnippetModel.isSnippetUISourceCode(uiSourceCode))
121 if (projectType === Workspace.projectTypes.Snippets)
122 return; 121 return;
123 if (!Bindings.blackboxManager.isBlackboxedUISourceCode(uiSourceCode)) { 122 if (!Bindings.blackboxManager.isBlackboxedUISourceCode(uiSourceCode)) {
124 this._hideBlackboxInfobar(); 123 this._hideBlackboxInfobar();
125 return; 124 return;
126 } 125 }
127 126
128 if (this._blackboxInfobar) 127 if (this._blackboxInfobar)
129 this._blackboxInfobar.dispose(); 128 this._blackboxInfobar.dispose();
130 129
131 var infobar = new UI.Infobar(UI.Infobar.Type.Warning, Common.UIString('This script is blackboxed in debugger')); 130 var infobar = new UI.Infobar(UI.Infobar.Type.Warning, Common.UIString('This script is blackboxed in debugger'));
132 this._blackboxInfobar = infobar; 131 this._blackboxInfobar = infobar;
133 132
134 infobar.createDetailsRowMessage( 133 infobar.createDetailsRowMessage(
135 Common.UIString('Debugger will skip stepping through this script, and wi ll not stop on exceptions')); 134 Common.UIString('Debugger will skip stepping through this script, and wi ll not stop on exceptions'));
136 135
137 var scriptFile = this._scriptFileForTarget.size ? this._scriptFileForTarget. valuesArray()[0] : null; 136 var scriptFile = this._scriptFileForTarget.size ? this._scriptFileForTarget. valuesArray()[0] : null;
138 if (scriptFile && scriptFile.hasSourceMapURL()) 137 if (scriptFile && scriptFile.hasSourceMapURL())
139 infobar.createDetailsRowMessage(Common.UIString('Source map found, but ign ored for blackboxed file.')); 138 infobar.createDetailsRowMessage(Common.UIString('Source map found, but ign ored for blackboxed file.'));
140 infobar.createDetailsRowMessage(); 139 infobar.createDetailsRowMessage();
141 infobar.createDetailsRowMessage(Common.UIString('Possible ways to cancel thi s behavior are:')); 140 infobar.createDetailsRowMessage(Common.UIString('Possible ways to cancel thi s behavior are:'));
142 141
143 infobar.createDetailsRowMessage(' - ').createTextChild( 142 infobar.createDetailsRowMessage(' - ').createTextChild(
144 Common.UIString('Go to "%s" tab in settings', Common.UIString('Blackboxi ng'))); 143 Common.UIString('Go to "%s" tab in settings', Common.UIString('Blackboxi ng')));
145 var unblackboxLink = infobar.createDetailsRowMessage(' - ').createChild('spa n', 'link'); 144 var unblackboxLink = infobar.createDetailsRowMessage(' - ').createChild('spa n', 'link');
146 unblackboxLink.textContent = Common.UIString('Unblackbox this script'); 145 unblackboxLink.textContent = Common.UIString('Unblackbox this script');
147 unblackboxLink.addEventListener('click', unblackbox, false); 146 unblackboxLink.addEventListener('click', unblackbox, false);
148 147
149 function unblackbox() { 148 function unblackbox() {
150 Bindings.blackboxManager.unblackboxUISourceCode(uiSourceCode); 149 Bindings.blackboxManager.unblackboxUISourceCode(uiSourceCode);
151 if (projectType === Workspace.projectTypes.ContentScripts) 150 if (Bindings.NetworkProject.isContentScriptUISourceCode(uiSourceCode))
152 Bindings.blackboxManager.unblackboxContentScripts(); 151 Bindings.blackboxManager.unblackboxContentScripts();
153 } 152 }
154 153
155 this.attachInfobars([this._blackboxInfobar]); 154 this.attachInfobars([this._blackboxInfobar]);
156 } 155 }
157 156
158 _hideBlackboxInfobar() { 157 _hideBlackboxInfobar() {
159 if (!this._blackboxInfobar) 158 if (!this._blackboxInfobar)
160 return; 159 return;
161 this._blackboxInfobar.dispose(); 160 this._blackboxInfobar.dispose();
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 function addSourceMapURLDialogCallback(scriptFile, url) { 266 function addSourceMapURLDialogCallback(scriptFile, url) {
268 if (!url) 267 if (!url)
269 return; 268 return;
270 scriptFile.addSourceMapURL(url); 269 scriptFile.addSourceMapURL(url);
271 } 270 }
272 271
273 /** 272 /**
274 * @this {Sources.JavaScriptSourceFrame} 273 * @this {Sources.JavaScriptSourceFrame}
275 */ 274 */
276 function populateSourceMapMembers() { 275 function populateSourceMapMembers() {
277 if (this.uiSourceCode().project().type() === Workspace.projectTypes.Networ k && 276 if (Bindings.NetworkProject.isNetworkUISourceCode(this.uiSourceCode()) &&
278 Common.moduleSetting('jsSourceMapsEnabled').get() && 277 Common.moduleSetting('jsSourceMapsEnabled').get() &&
279 !Bindings.blackboxManager.isBlackboxedUISourceCode(this.uiSourceCode() )) { 278 !Bindings.blackboxManager.isBlackboxedUISourceCode(this.uiSourceCode() )) {
280 if (this._scriptFileForTarget.size) { 279 if (this._scriptFileForTarget.size) {
281 var scriptFile = this._scriptFileForTarget.valuesArray()[0]; 280 var scriptFile = this._scriptFileForTarget.valuesArray()[0];
282 var addSourceMapURLLabel = Common.UIString.capitalize('Add ^source ^ma p\u2026'); 281 var addSourceMapURLLabel = Common.UIString.capitalize('Add ^source ^ma p\u2026');
283 contextMenu.appendItem(addSourceMapURLLabel, addSourceMapURL.bind(null , scriptFile)); 282 contextMenu.appendItem(addSourceMapURLLabel, addSourceMapURL.bind(null , scriptFile));
284 contextMenu.appendSeparator(); 283 contextMenu.appendSeparator();
285 } 284 }
286 } 285 }
287 } 286 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 322
324 _muteBreakpointsWhileEditing() { 323 _muteBreakpointsWhileEditing() {
325 if (this._muted) 324 if (this._muted)
326 return; 325 return;
327 for (var decoration of this._breakpointDecorations) 326 for (var decoration of this._breakpointDecorations)
328 this._updateBreakpointDecoration(decoration); 327 this._updateBreakpointDecoration(decoration);
329 this._muted = true; 328 this._muted = true;
330 } 329 }
331 330
332 _supportsEnabledBreakpointsWhileEditing() { 331 _supportsEnabledBreakpointsWhileEditing() {
333 return this.uiSourceCode().project().type() === Workspace.projectTypes.Snipp ets; 332 return Snippets.ScriptSnippetModel.isSnippetUISourceCode(this.uiSourceCode() );
334 } 333 }
335 334
336 _restoreBreakpointsIfConsistentScripts() { 335 _restoreBreakpointsIfConsistentScripts() {
337 var scriptFiles = this._scriptFileForTarget.valuesArray(); 336 var scriptFiles = this._scriptFileForTarget.valuesArray();
338 for (var i = 0; i < scriptFiles.length; ++i) { 337 for (var i = 0; i < scriptFiles.length; ++i) {
339 if (scriptFiles[i].hasDivergedFromVM() || scriptFiles[i].isMergingToVM()) 338 if (scriptFiles[i].hasDivergedFromVM() || scriptFiles[i].isMergingToVM())
340 return; 339 return;
341 } 340 }
342 341
343 this._restoreBreakpointsAfterEditing(); 342 this._restoreBreakpointsAfterEditing();
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 static mostSpecificFirst(decoration1, decoration2) { 1114 static mostSpecificFirst(decoration1, decoration2) {
1116 if (!!decoration1.condition !== !!decoration2.condition) 1115 if (!!decoration1.condition !== !!decoration2.condition)
1117 return !!decoration1.condition ? -1 : 1; 1116 return !!decoration1.condition ? -1 : 1;
1118 if (decoration1.enabled !== decoration2.enabled) 1117 if (decoration1.enabled !== decoration2.enabled)
1119 return decoration1.enabled ? -1 : 1; 1118 return decoration1.enabled ? -1 : 1;
1120 return 0; 1119 return 0;
1121 } 1120 }
1122 }; 1121 };
1123 1122
1124 Sources.JavaScriptSourceFrame.BreakpointDecoration._decorationSymbol = Symbol('d ecoration'); 1123 Sources.JavaScriptSourceFrame.BreakpointDecoration._decorationSymbol = Symbol('d ecoration');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698