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

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: 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 if (!scripts.length)
91 return null;
90 console.assert(scripts.length); 92 console.assert(scripts.length);
dgozman 2017/06/08 19:12:00 Remove assert.
lushnikov 2017/06/08 21:14:34 Done.
91 var script = scripts[scripts.length - 1]; 93 var script = scripts[scripts.length - 1];
92 if (script.isInlineScriptWithSourceURL()) { 94 if (script.isInlineScriptWithSourceURL()) {
93 return this._debuggerModel.createRawLocationByURL( 95 return this._debuggerModel.createRawLocationByURL(
94 script.sourceURL, lineNumber + script.lineOffset, 96 script.sourceURL, lineNumber + script.lineOffset,
95 lineNumber ? columnNumber : columnNumber + script.columnOffset); 97 lineNumber ? columnNumber : columnNumber + script.columnOffset);
96 } 98 }
97 return this._debuggerModel.createRawLocationByURL(script.sourceURL, lineNumb er, columnNumber); 99 return this._debuggerModel.createRawLocationByURL(script.sourceURL, lineNumb er, columnNumber);
98 } 100 }
99 101
100 /** 102 /**
101 * @param {!SDK.Script} script 103 * @param {!SDK.Script} script
102 */ 104 */
103 addScript(script) { 105 addScript(script) {
104 if (script.isAnonymousScript()) 106 if (script.isAnonymousScript())
105 return; 107 return;
106 this._debuggerWorkspaceBinding.pushSourceMapping(script, this);
107 108
108 var uiSourceCode = this._workspaceUISourceCodeForScript(script); 109 var uiSourceCode = this._workspaceUISourceCodeForScript(script);
109 if (!uiSourceCode) 110 if (!uiSourceCode)
110 return; 111 return;
111 112
112 this._bindUISourceCodeToScripts(uiSourceCode, [script]); 113 this._bindUISourceCodeToScripts(uiSourceCode, [script]);
113 } 114 }
114 115
115 /** 116 /**
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 117 * @param {!Workspace.UISourceCode} uiSourceCode
135 * @return {?Bindings.ResourceScriptFile} 118 * @return {?Bindings.ResourceScriptFile}
136 */ 119 */
137 scriptFile(uiSourceCode) { 120 scriptFile(uiSourceCode) {
138 return this._uiSourceCodeToScriptFile.get(uiSourceCode) || null; 121 return this._uiSourceCodeToScriptFile.get(uiSourceCode) || null;
139 } 122 }
140 123
141 /** 124 /**
142 * @param {!Workspace.UISourceCode} uiSourceCode 125 * @param {!Workspace.UISourceCode} uiSourceCode
143 * @param {?Bindings.ResourceScriptFile} scriptFile 126 * @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 198 // 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. 199 // for the corresponding script was created. Check that we don't create scri ptFile twice.
217 var boundScriptFile = this.scriptFile(uiSourceCode); 200 var boundScriptFile = this.scriptFile(uiSourceCode);
218 if (boundScriptFile && boundScriptFile._hasScripts(scripts)) 201 if (boundScriptFile && boundScriptFile._hasScripts(scripts))
219 return; 202 return;
220 203
221 var scriptFile = new Bindings.ResourceScriptFile(this, uiSourceCode, scripts ); 204 var scriptFile = new Bindings.ResourceScriptFile(this, uiSourceCode, scripts );
222 this._setScriptFile(uiSourceCode, scriptFile); 205 this._setScriptFile(uiSourceCode, scriptFile);
223 for (var i = 0; i < scripts.length; ++i) 206 for (var i = 0; i < scripts.length; ++i)
224 this._debuggerWorkspaceBinding.updateLocations(scripts[i]); 207 this._debuggerWorkspaceBinding.updateLocations(scripts[i]);
225 this._debuggerWorkspaceBinding.setSourceMapping(this._debuggerModel, uiSourc eCode, this);
226 this._boundUISourceCodes.add(uiSourceCode); 208 this._boundUISourceCodes.add(uiSourceCode);
227 } 209 }
228 210
229 /** 211 /**
230 * @param {!Workspace.UISourceCode} uiSourceCode 212 * @param {!Workspace.UISourceCode} uiSourceCode
231 */ 213 */
232 _unbindUISourceCode(uiSourceCode) { 214 _unbindUISourceCode(uiSourceCode) {
233 var scriptFile = this.scriptFile(uiSourceCode); 215 var scriptFile = this.scriptFile(uiSourceCode);
234 if (scriptFile) { 216 if (scriptFile) {
235 scriptFile.dispose(); 217 scriptFile.dispose();
236 this._setScriptFile(uiSourceCode, null); 218 this._setScriptFile(uiSourceCode, null);
237 } 219 }
238 this._debuggerWorkspaceBinding.setSourceMapping(this._debuggerModel, uiSourc eCode, null);
239 this._boundUISourceCodes.delete(uiSourceCode); 220 this._boundUISourceCodes.delete(uiSourceCode);
dgozman 2017/06/08 19:12:00 updateLocations here
lushnikov 2017/06/08 21:14:34 Done.
240 } 221 }
241 222
242 _debuggerReset() { 223 _debuggerReset() {
243 for (var uiSourceCode of this._boundUISourceCodes.valuesArray()) 224 for (var uiSourceCode of this._boundUISourceCodes.valuesArray())
244 this._unbindUISourceCode(uiSourceCode); 225 this._unbindUISourceCode(uiSourceCode);
245 this._boundUISourceCodes.clear(); 226 this._boundUISourceCodes.clear();
246 console.assert(!this._uiSourceCodeToScriptFile.size); 227 console.assert(!this._uiSourceCodeToScriptFile.size);
247 } 228 }
248 229
249 dispose() { 230 dispose() {
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 hasSourceMapURL() { 416 hasSourceMapURL() {
436 return this._script && !!this._script.sourceMapURL; 417 return this._script && !!this._script.sourceMapURL;
437 } 418 }
438 }; 419 };
439 420
440 /** @enum {symbol} */ 421 /** @enum {symbol} */
441 Bindings.ResourceScriptFile.Events = { 422 Bindings.ResourceScriptFile.Events = {
442 DidMergeToVM: Symbol('DidMergeToVM'), 423 DidMergeToVM: Symbol('DidMergeToVM'),
443 DidDivergeFromVM: Symbol('DidDivergeFromVM'), 424 DidDivergeFromVM: Symbol('DidDivergeFromVM'),
444 }; 425 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698