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

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

Issue 2931773002: DevTools: kill DebuggerWorkspaceBinding.{push,pop,set}SourceMapping (Closed)
Patch Set: address comments Created 3 years, 6 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 /* 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 /** 81 /**
82 * @override 82 * @override
83 * @param {!Workspace.UISourceCode} uiSourceCode 83 * @param {!Workspace.UISourceCode} uiSourceCode
84 * @param {number} lineNumber 84 * @param {number} lineNumber
85 * @param {number} columnNumber 85 * @param {number} columnNumber
86 * @return {?SDK.DebuggerModel.Location} 86 * @return {?SDK.DebuggerModel.Location}
87 */ 87 */
88 uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber) { 88 uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber) {
89 var scripts = this._scriptsForUISourceCode(uiSourceCode); 89 var scripts = this._scriptsForUISourceCode(uiSourceCode);
90 console.assert(scripts.length); 90 if (!scripts.length)
91 return null;
91 var script = scripts[scripts.length - 1]; 92 var script = scripts[scripts.length - 1];
92 if (script.isInlineScriptWithSourceURL()) { 93 if (script.isInlineScriptWithSourceURL()) {
93 return this._debuggerModel.createRawLocationByURL( 94 return this._debuggerModel.createRawLocationByURL(
94 script.sourceURL, lineNumber + script.lineOffset, 95 script.sourceURL, lineNumber + script.lineOffset,
95 lineNumber ? columnNumber : columnNumber + script.columnOffset); 96 lineNumber ? columnNumber : columnNumber + script.columnOffset);
96 } 97 }
97 return this._debuggerModel.createRawLocationByURL(script.sourceURL, lineNumb er, columnNumber); 98 return this._debuggerModel.createRawLocationByURL(script.sourceURL, lineNumb er, columnNumber);
98 } 99 }
99 100
100 /** 101 /**
101 * @param {!SDK.Script} script 102 * @param {!SDK.Script} script
102 */ 103 */
103 addScript(script) { 104 addScript(script) {
104 if (script.isAnonymousScript()) 105 if (script.isAnonymousScript())
105 return; 106 return;
106 this._debuggerWorkspaceBinding.pushSourceMapping(script, this);
107 107
108 var uiSourceCode = this._workspaceUISourceCodeForScript(script); 108 var uiSourceCode = this._workspaceUISourceCodeForScript(script);
109 if (!uiSourceCode) 109 if (!uiSourceCode)
110 return; 110 return;
111 111
112 this._bindUISourceCodeToScripts(uiSourceCode, [script]); 112 this._bindUISourceCodeToScripts(uiSourceCode, [script]);
113 } 113 }
114 114
115 /** 115 /**
116 * @override
117 * @return {boolean}
118 */
119 isIdentity() {
120 return true;
121 }
122
123 /**
124 * @override
125 * @param {!Workspace.UISourceCode} uiSourceCode
126 * @param {number} lineNumber
127 * @return {boolean}
128 */
129 uiLineHasMapping(uiSourceCode, lineNumber) {
130 return true;
131 }
132
133 /**
134 * @param {!Workspace.UISourceCode} uiSourceCode 116 * @param {!Workspace.UISourceCode} uiSourceCode
135 * @return {?Bindings.ResourceScriptFile} 117 * @return {?Bindings.ResourceScriptFile}
136 */ 118 */
137 scriptFile(uiSourceCode) { 119 scriptFile(uiSourceCode) {
138 return this._uiSourceCodeToScriptFile.get(uiSourceCode) || null; 120 return this._uiSourceCodeToScriptFile.get(uiSourceCode) || null;
139 } 121 }
140 122
141 /** 123 /**
142 * @param {!Workspace.UISourceCode} uiSourceCode 124 * @param {!Workspace.UISourceCode} uiSourceCode
143 * @param {?Bindings.ResourceScriptFile} scriptFile 125 * @param {?Bindings.ResourceScriptFile} scriptFile
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 // Due to different listeners order, a script file could be created just bef ore uiSourceCode 197 // Due to different listeners order, a script file could be created just bef ore uiSourceCode
216 // for the corresponding script was created. Check that we don't create scri ptFile twice. 198 // for the corresponding script was created. Check that we don't create scri ptFile twice.
217 var boundScriptFile = this.scriptFile(uiSourceCode); 199 var boundScriptFile = this.scriptFile(uiSourceCode);
218 if (boundScriptFile && boundScriptFile._hasScripts(scripts)) 200 if (boundScriptFile && boundScriptFile._hasScripts(scripts))
219 return; 201 return;
220 202
221 var scriptFile = new Bindings.ResourceScriptFile(this, uiSourceCode, scripts ); 203 var scriptFile = new Bindings.ResourceScriptFile(this, uiSourceCode, scripts );
222 this._setScriptFile(uiSourceCode, scriptFile); 204 this._setScriptFile(uiSourceCode, scriptFile);
223 for (var i = 0; i < scripts.length; ++i) 205 for (var i = 0; i < scripts.length; ++i)
224 this._debuggerWorkspaceBinding.updateLocations(scripts[i]); 206 this._debuggerWorkspaceBinding.updateLocations(scripts[i]);
225 this._debuggerWorkspaceBinding.setSourceMapping(this._debuggerModel, uiSourc eCode, this);
226 this._boundUISourceCodes.add(uiSourceCode); 207 this._boundUISourceCodes.add(uiSourceCode);
227 } 208 }
228 209
229 /** 210 /**
230 * @param {!Workspace.UISourceCode} uiSourceCode 211 * @param {!Workspace.UISourceCode} uiSourceCode
231 */ 212 */
232 _unbindUISourceCode(uiSourceCode) { 213 _unbindUISourceCode(uiSourceCode) {
233 var scriptFile = this.scriptFile(uiSourceCode); 214 var scriptFile = this.scriptFile(uiSourceCode);
234 if (scriptFile) { 215 if (scriptFile) {
235 scriptFile.dispose(); 216 scriptFile.dispose();
236 this._setScriptFile(uiSourceCode, null); 217 this._setScriptFile(uiSourceCode, null);
237 } 218 }
238 this._debuggerWorkspaceBinding.setSourceMapping(this._debuggerModel, uiSourc eCode, null);
239 this._boundUISourceCodes.delete(uiSourceCode); 219 this._boundUISourceCodes.delete(uiSourceCode);
220 if (scriptFile._script)
221 this._debuggerWorkspaceBinding.updateLocations(scriptFile._script);
240 } 222 }
241 223
242 _debuggerReset() { 224 _debuggerReset() {
243 for (var uiSourceCode of this._boundUISourceCodes.valuesArray()) 225 for (var uiSourceCode of this._boundUISourceCodes.valuesArray())
244 this._unbindUISourceCode(uiSourceCode); 226 this._unbindUISourceCode(uiSourceCode);
245 this._boundUISourceCodes.clear(); 227 this._boundUISourceCodes.clear();
246 console.assert(!this._uiSourceCodeToScriptFile.size); 228 console.assert(!this._uiSourceCodeToScriptFile.size);
247 } 229 }
248 230
249 dispose() { 231 dispose() {
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 hasSourceMapURL() { 417 hasSourceMapURL() {
436 return this._script && !!this._script.sourceMapURL; 418 return this._script && !!this._script.sourceMapURL;
437 } 419 }
438 }; 420 };
439 421
440 /** @enum {symbol} */ 422 /** @enum {symbol} */
441 Bindings.ResourceScriptFile.Events = { 423 Bindings.ResourceScriptFile.Events = {
442 DidMergeToVM: Symbol('DidMergeToVM'), 424 DidMergeToVM: Symbol('DidMergeToVM'),
443 DidDivergeFromVM: Symbol('DidDivergeFromVM'), 425 DidDivergeFromVM: Symbol('DidDivergeFromVM'),
444 }; 426 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698