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

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

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month 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 {WebInspector.TargetManager.Observer} 5 * @implements {SDK.TargetManager.Observer}
6 * @unrestricted 6 * @unrestricted
7 */ 7 */
8 WebInspector.BlackboxManager = class { 8 Bindings.BlackboxManager = class {
9 /** 9 /**
10 * @param {!WebInspector.DebuggerWorkspaceBinding} debuggerWorkspaceBinding 10 * @param {!Bindings.DebuggerWorkspaceBinding} debuggerWorkspaceBinding
11 */ 11 */
12 constructor(debuggerWorkspaceBinding) { 12 constructor(debuggerWorkspaceBinding) {
13 this._debuggerWorkspaceBinding = debuggerWorkspaceBinding; 13 this._debuggerWorkspaceBinding = debuggerWorkspaceBinding;
14 14
15 WebInspector.targetManager.addModelListener( 15 SDK.targetManager.addModelListener(
16 WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.ParsedScri ptSource, this._parsedScriptSource, 16 SDK.DebuggerModel, SDK.DebuggerModel.Events.ParsedScriptSource, this._pa rsedScriptSource,
17 this); 17 this);
18 WebInspector.targetManager.addModelListener( 18 SDK.targetManager.addModelListener(
19 WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.GlobalObje ctCleared, this._globalObjectCleared, 19 SDK.DebuggerModel, SDK.DebuggerModel.Events.GlobalObjectCleared, this._g lobalObjectCleared,
20 this); 20 this);
21 WebInspector.moduleSetting('skipStackFramesPattern').addChangeListener(this. _patternChanged.bind(this)); 21 Common.moduleSetting('skipStackFramesPattern').addChangeListener(this._patte rnChanged.bind(this));
22 WebInspector.moduleSetting('skipContentScripts').addChangeListener(this._pat ternChanged.bind(this)); 22 Common.moduleSetting('skipContentScripts').addChangeListener(this._patternCh anged.bind(this));
23 23
24 /** @type {!Map<!WebInspector.DebuggerModel, !Map<string, !Array<!Protocol.D ebugger.ScriptPosition>>>} */ 24 /** @type {!Map<!SDK.DebuggerModel, !Map<string, !Array<!Protocol.Debugger.S criptPosition>>>} */
25 this._debuggerModelData = new Map(); 25 this._debuggerModelData = new Map();
26 /** @type {!Map<string, boolean>} */ 26 /** @type {!Map<string, boolean>} */
27 this._isBlackboxedURLCache = new Map(); 27 this._isBlackboxedURLCache = new Map();
28 28
29 WebInspector.targetManager.observeTargets(this); 29 SDK.targetManager.observeTargets(this);
30 } 30 }
31 31
32 /** 32 /**
33 * @param {function(!WebInspector.Event)} listener 33 * @param {function(!Common.Event)} listener
34 * @param {!Object=} thisObject 34 * @param {!Object=} thisObject
35 */ 35 */
36 addChangeListener(listener, thisObject) { 36 addChangeListener(listener, thisObject) {
37 WebInspector.moduleSetting('skipStackFramesPattern').addChangeListener(liste ner, thisObject); 37 Common.moduleSetting('skipStackFramesPattern').addChangeListener(listener, t hisObject);
38 } 38 }
39 39
40 /** 40 /**
41 * @param {function(!WebInspector.Event)} listener 41 * @param {function(!Common.Event)} listener
42 * @param {!Object=} thisObject 42 * @param {!Object=} thisObject
43 */ 43 */
44 removeChangeListener(listener, thisObject) { 44 removeChangeListener(listener, thisObject) {
45 WebInspector.moduleSetting('skipStackFramesPattern').removeChangeListener(li stener, thisObject); 45 Common.moduleSetting('skipStackFramesPattern').removeChangeListener(listener , thisObject);
46 } 46 }
47 47
48 /** 48 /**
49 * @override 49 * @override
50 * @param {!WebInspector.Target} target 50 * @param {!SDK.Target} target
51 */ 51 */
52 targetAdded(target) { 52 targetAdded(target) {
53 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); 53 var debuggerModel = SDK.DebuggerModel.fromTarget(target);
54 if (debuggerModel) 54 if (debuggerModel)
55 this._setBlackboxPatterns(debuggerModel); 55 this._setBlackboxPatterns(debuggerModel);
56 } 56 }
57 57
58 /** 58 /**
59 * @override 59 * @override
60 * @param {!WebInspector.Target} target 60 * @param {!SDK.Target} target
61 */ 61 */
62 targetRemoved(target) { 62 targetRemoved(target) {
63 } 63 }
64 64
65 /** 65 /**
66 * @param {!WebInspector.DebuggerModel} debuggerModel 66 * @param {!SDK.DebuggerModel} debuggerModel
67 * @return {!Promise<boolean>} 67 * @return {!Promise<boolean>}
68 */ 68 */
69 _setBlackboxPatterns(debuggerModel) { 69 _setBlackboxPatterns(debuggerModel) {
70 var regexPatterns = WebInspector.moduleSetting('skipStackFramesPattern').get AsArray(); 70 var regexPatterns = Common.moduleSetting('skipStackFramesPattern').getAsArra y();
71 var patterns = /** @type {!Array<string>} */ ([]); 71 var patterns = /** @type {!Array<string>} */ ([]);
72 for (var item of regexPatterns) { 72 for (var item of regexPatterns) {
73 if (!item.disabled && item.pattern) 73 if (!item.disabled && item.pattern)
74 patterns.push(item.pattern); 74 patterns.push(item.pattern);
75 } 75 }
76 return debuggerModel.setBlackboxPatterns(patterns); 76 return debuggerModel.setBlackboxPatterns(patterns);
77 } 77 }
78 78
79 /** 79 /**
80 * @param {!WebInspector.DebuggerModel.Location} location 80 * @param {!SDK.DebuggerModel.Location} location
81 * @return {boolean} 81 * @return {boolean}
82 */ 82 */
83 isBlackboxedRawLocation(location) { 83 isBlackboxedRawLocation(location) {
84 var script = location.script(); 84 var script = location.script();
85 if (!script) 85 if (!script)
86 return false; 86 return false;
87 var positions = this._scriptPositions(script); 87 var positions = this._scriptPositions(script);
88 if (!positions) 88 if (!positions)
89 return this._isBlackboxedScript(script); 89 return this._isBlackboxedScript(script);
90 var index = positions.lowerBound(location, comparator); 90 var index = positions.lowerBound(location, comparator);
91 return !!(index % 2); 91 return !!(index % 2);
92 92
93 /** 93 /**
94 * @param {!WebInspector.DebuggerModel.Location} a 94 * @param {!SDK.DebuggerModel.Location} a
95 * @param {!Protocol.Debugger.ScriptPosition} b 95 * @param {!Protocol.Debugger.ScriptPosition} b
96 * @return {number} 96 * @return {number}
97 */ 97 */
98 function comparator(a, b) { 98 function comparator(a, b) {
99 if (a.lineNumber !== b.lineNumber) 99 if (a.lineNumber !== b.lineNumber)
100 return a.lineNumber - b.lineNumber; 100 return a.lineNumber - b.lineNumber;
101 return a.columnNumber - b.columnNumber; 101 return a.columnNumber - b.columnNumber;
102 } 102 }
103 } 103 }
104 104
105 /** 105 /**
106 * @param {!WebInspector.UISourceCode} uiSourceCode 106 * @param {!Workspace.UISourceCode} uiSourceCode
107 * @return {boolean} 107 * @return {boolean}
108 */ 108 */
109 isBlackboxedUISourceCode(uiSourceCode) { 109 isBlackboxedUISourceCode(uiSourceCode) {
110 var projectType = uiSourceCode.project().type(); 110 var projectType = uiSourceCode.project().type();
111 var isContentScript = projectType === WebInspector.projectTypes.ContentScrip ts; 111 var isContentScript = projectType === Workspace.projectTypes.ContentScripts;
112 if (isContentScript && WebInspector.moduleSetting('skipContentScripts').get( )) 112 if (isContentScript && Common.moduleSetting('skipContentScripts').get())
113 return true; 113 return true;
114 var url = this._uiSourceCodeURL(uiSourceCode); 114 var url = this._uiSourceCodeURL(uiSourceCode);
115 return url ? this.isBlackboxedURL(url) : false; 115 return url ? this.isBlackboxedURL(url) : false;
116 } 116 }
117 117
118 /** 118 /**
119 * @param {string} url 119 * @param {string} url
120 * @param {boolean=} isContentScript 120 * @param {boolean=} isContentScript
121 * @return {boolean} 121 * @return {boolean}
122 */ 122 */
123 isBlackboxedURL(url, isContentScript) { 123 isBlackboxedURL(url, isContentScript) {
124 if (this._isBlackboxedURLCache.has(url)) 124 if (this._isBlackboxedURLCache.has(url))
125 return !!this._isBlackboxedURLCache.get(url); 125 return !!this._isBlackboxedURLCache.get(url);
126 if (isContentScript && WebInspector.moduleSetting('skipContentScripts').get( )) 126 if (isContentScript && Common.moduleSetting('skipContentScripts').get())
127 return true; 127 return true;
128 var regex = WebInspector.moduleSetting('skipStackFramesPattern').asRegExp(); 128 var regex = Common.moduleSetting('skipStackFramesPattern').asRegExp();
129 var isBlackboxed = regex && regex.test(url); 129 var isBlackboxed = regex && regex.test(url);
130 this._isBlackboxedURLCache.set(url, isBlackboxed); 130 this._isBlackboxedURLCache.set(url, isBlackboxed);
131 return isBlackboxed; 131 return isBlackboxed;
132 } 132 }
133 133
134 /** 134 /**
135 * @param {!WebInspector.Script} script 135 * @param {!SDK.Script} script
136 * @param {?WebInspector.TextSourceMap} sourceMap 136 * @param {?SDK.TextSourceMap} sourceMap
137 * @return {!Promise<undefined>} 137 * @return {!Promise<undefined>}
138 */ 138 */
139 sourceMapLoaded(script, sourceMap) { 139 sourceMapLoaded(script, sourceMap) {
140 if (!sourceMap) 140 if (!sourceMap)
141 return Promise.resolve(); 141 return Promise.resolve();
142 var previousScriptState = this._scriptPositions(script); 142 var previousScriptState = this._scriptPositions(script);
143 if (!previousScriptState) 143 if (!previousScriptState)
144 return Promise.resolve(); 144 return Promise.resolve();
145 145
146 var hasBlackboxedMappings = sourceMap.sourceURLs().some((url) => this.isBlac kboxedURL(url)); 146 var hasBlackboxedMappings = sourceMap.sourceURLs().some((url) => this.isBlac kboxedURL(url));
(...skipping 15 matching lines...) Expand all
162 } 162 }
163 for (var mapping of mappings) { 163 for (var mapping of mappings) {
164 if (mapping.sourceURL && currentBlackboxed !== this.isBlackboxedURL(mappin g.sourceURL)) { 164 if (mapping.sourceURL && currentBlackboxed !== this.isBlackboxedURL(mappin g.sourceURL)) {
165 positions.push({lineNumber: mapping.lineNumber, columnNumber: mapping.co lumnNumber}); 165 positions.push({lineNumber: mapping.lineNumber, columnNumber: mapping.co lumnNumber});
166 currentBlackboxed = !currentBlackboxed; 166 currentBlackboxed = !currentBlackboxed;
167 } 167 }
168 isBlackboxed = currentBlackboxed || isBlackboxed; 168 isBlackboxed = currentBlackboxed || isBlackboxed;
169 } 169 }
170 return this._setScriptState(script, !isBlackboxed ? [] : positions); 170 return this._setScriptState(script, !isBlackboxed ? [] : positions);
171 /** 171 /**
172 * @param {!WebInspector.SourceMapEntry} a 172 * @param {!SDK.SourceMapEntry} a
173 * @param {!WebInspector.SourceMapEntry} b 173 * @param {!SDK.SourceMapEntry} b
174 * @return {number} 174 * @return {number}
175 */ 175 */
176 function mappingComparator(a, b) { 176 function mappingComparator(a, b) {
177 if (a.lineNumber !== b.lineNumber) 177 if (a.lineNumber !== b.lineNumber)
178 return a.lineNumber - b.lineNumber; 178 return a.lineNumber - b.lineNumber;
179 return a.columnNumber - b.columnNumber; 179 return a.columnNumber - b.columnNumber;
180 } 180 }
181 } 181 }
182 182
183 /** 183 /**
184 * @param {!WebInspector.UISourceCode} uiSourceCode 184 * @param {!Workspace.UISourceCode} uiSourceCode
185 * @return {?string} 185 * @return {?string}
186 */ 186 */
187 _uiSourceCodeURL(uiSourceCode) { 187 _uiSourceCodeURL(uiSourceCode) {
188 return uiSourceCode.project().type() === WebInspector.projectTypes.Debugger ? null : uiSourceCode.url(); 188 return uiSourceCode.project().type() === Workspace.projectTypes.Debugger ? n ull : uiSourceCode.url();
189 } 189 }
190 190
191 /** 191 /**
192 * @param {!WebInspector.UISourceCode} uiSourceCode 192 * @param {!Workspace.UISourceCode} uiSourceCode
193 * @return {boolean} 193 * @return {boolean}
194 */ 194 */
195 canBlackboxUISourceCode(uiSourceCode) { 195 canBlackboxUISourceCode(uiSourceCode) {
196 var url = this._uiSourceCodeURL(uiSourceCode); 196 var url = this._uiSourceCodeURL(uiSourceCode);
197 return url ? !!this._urlToRegExpString(url) : false; 197 return url ? !!this._urlToRegExpString(url) : false;
198 } 198 }
199 199
200 /** 200 /**
201 * @param {!WebInspector.UISourceCode} uiSourceCode 201 * @param {!Workspace.UISourceCode} uiSourceCode
202 */ 202 */
203 blackboxUISourceCode(uiSourceCode) { 203 blackboxUISourceCode(uiSourceCode) {
204 var url = this._uiSourceCodeURL(uiSourceCode); 204 var url = this._uiSourceCodeURL(uiSourceCode);
205 if (url) 205 if (url)
206 this._blackboxURL(url); 206 this._blackboxURL(url);
207 } 207 }
208 208
209 /** 209 /**
210 * @param {!WebInspector.UISourceCode} uiSourceCode 210 * @param {!Workspace.UISourceCode} uiSourceCode
211 */ 211 */
212 unblackboxUISourceCode(uiSourceCode) { 212 unblackboxUISourceCode(uiSourceCode) {
213 var url = this._uiSourceCodeURL(uiSourceCode); 213 var url = this._uiSourceCodeURL(uiSourceCode);
214 if (url) 214 if (url)
215 this._unblackboxURL(url); 215 this._unblackboxURL(url);
216 } 216 }
217 217
218 blackboxContentScripts() { 218 blackboxContentScripts() {
219 WebInspector.moduleSetting('skipContentScripts').set(true); 219 Common.moduleSetting('skipContentScripts').set(true);
220 } 220 }
221 221
222 unblackboxContentScripts() { 222 unblackboxContentScripts() {
223 WebInspector.moduleSetting('skipContentScripts').set(false); 223 Common.moduleSetting('skipContentScripts').set(false);
224 } 224 }
225 225
226 /** 226 /**
227 * @param {string} url 227 * @param {string} url
228 */ 228 */
229 _blackboxURL(url) { 229 _blackboxURL(url) {
230 var regexPatterns = WebInspector.moduleSetting('skipStackFramesPattern').get AsArray(); 230 var regexPatterns = Common.moduleSetting('skipStackFramesPattern').getAsArra y();
231 var regexValue = this._urlToRegExpString(url); 231 var regexValue = this._urlToRegExpString(url);
232 if (!regexValue) 232 if (!regexValue)
233 return; 233 return;
234 var found = false; 234 var found = false;
235 for (var i = 0; i < regexPatterns.length; ++i) { 235 for (var i = 0; i < regexPatterns.length; ++i) {
236 var item = regexPatterns[i]; 236 var item = regexPatterns[i];
237 if (item.pattern === regexValue) { 237 if (item.pattern === regexValue) {
238 item.disabled = false; 238 item.disabled = false;
239 found = true; 239 found = true;
240 break; 240 break;
241 } 241 }
242 } 242 }
243 if (!found) 243 if (!found)
244 regexPatterns.push({pattern: regexValue}); 244 regexPatterns.push({pattern: regexValue});
245 WebInspector.moduleSetting('skipStackFramesPattern').setAsArray(regexPattern s); 245 Common.moduleSetting('skipStackFramesPattern').setAsArray(regexPatterns);
246 } 246 }
247 247
248 /** 248 /**
249 * @param {string} url 249 * @param {string} url
250 */ 250 */
251 _unblackboxURL(url) { 251 _unblackboxURL(url) {
252 var regexPatterns = WebInspector.moduleSetting('skipStackFramesPattern').get AsArray(); 252 var regexPatterns = Common.moduleSetting('skipStackFramesPattern').getAsArra y();
253 var regexValue = WebInspector.blackboxManager._urlToRegExpString(url); 253 var regexValue = Bindings.blackboxManager._urlToRegExpString(url);
254 if (!regexValue) 254 if (!regexValue)
255 return; 255 return;
256 regexPatterns = regexPatterns.filter(function(item) { 256 regexPatterns = regexPatterns.filter(function(item) {
257 return item.pattern !== regexValue; 257 return item.pattern !== regexValue;
258 }); 258 });
259 for (var i = 0; i < regexPatterns.length; ++i) { 259 for (var i = 0; i < regexPatterns.length; ++i) {
260 var item = regexPatterns[i]; 260 var item = regexPatterns[i];
261 if (item.disabled) 261 if (item.disabled)
262 continue; 262 continue;
263 try { 263 try {
264 var regex = new RegExp(item.pattern); 264 var regex = new RegExp(item.pattern);
265 if (regex.test(url)) 265 if (regex.test(url))
266 item.disabled = true; 266 item.disabled = true;
267 } catch (e) { 267 } catch (e) {
268 } 268 }
269 } 269 }
270 WebInspector.moduleSetting('skipStackFramesPattern').setAsArray(regexPattern s); 270 Common.moduleSetting('skipStackFramesPattern').setAsArray(regexPatterns);
271 } 271 }
272 272
273 _patternChanged() { 273 _patternChanged() {
274 this._isBlackboxedURLCache.clear(); 274 this._isBlackboxedURLCache.clear();
275 275
276 var promises = []; 276 var promises = [];
277 for (var debuggerModel of WebInspector.DebuggerModel.instances()) { 277 for (var debuggerModel of SDK.DebuggerModel.instances()) {
278 promises.push(this._setBlackboxPatterns.bind(this, debuggerModel)); 278 promises.push(this._setBlackboxPatterns.bind(this, debuggerModel));
279 for (var scriptId in debuggerModel.scripts) { 279 for (var scriptId in debuggerModel.scripts) {
280 var script = debuggerModel.scripts[scriptId]; 280 var script = debuggerModel.scripts[scriptId];
281 promises.push(this._addScript(script).then(loadSourceMap.bind(this, scri pt))); 281 promises.push(this._addScript(script).then(loadSourceMap.bind(this, scri pt)));
282 } 282 }
283 } 283 }
284 Promise.all(promises).then(this._patternChangeFinishedForTests.bind(this)); 284 Promise.all(promises).then(this._patternChangeFinishedForTests.bind(this));
285 285
286 /** 286 /**
287 * @param {!WebInspector.Script} script 287 * @param {!SDK.Script} script
288 * @return {!Promise<undefined>} 288 * @return {!Promise<undefined>}
289 * @this {WebInspector.BlackboxManager} 289 * @this {Bindings.BlackboxManager}
290 */ 290 */
291 function loadSourceMap(script) { 291 function loadSourceMap(script) {
292 return this.sourceMapLoaded(script, this._debuggerWorkspaceBinding.sourceM apForScript(script)); 292 return this.sourceMapLoaded(script, this._debuggerWorkspaceBinding.sourceM apForScript(script));
293 } 293 }
294 } 294 }
295 295
296 _patternChangeFinishedForTests() { 296 _patternChangeFinishedForTests() {
297 // This method is sniffed in tests. 297 // This method is sniffed in tests.
298 } 298 }
299 299
300 /** 300 /**
301 * @param {!WebInspector.Event} event 301 * @param {!Common.Event} event
302 */ 302 */
303 _globalObjectCleared(event) { 303 _globalObjectCleared(event) {
304 var debuggerModel = /** @type {!WebInspector.DebuggerModel} */ (event.target ); 304 var debuggerModel = /** @type {!SDK.DebuggerModel} */ (event.target);
305 this._debuggerModelData.delete(debuggerModel); 305 this._debuggerModelData.delete(debuggerModel);
306 this._isBlackboxedURLCache.clear(); 306 this._isBlackboxedURLCache.clear();
307 } 307 }
308 308
309 /** 309 /**
310 * @param {!WebInspector.Event} event 310 * @param {!Common.Event} event
311 */ 311 */
312 _parsedScriptSource(event) { 312 _parsedScriptSource(event) {
313 var script = /** @type {!WebInspector.Script} */ (event.data); 313 var script = /** @type {!SDK.Script} */ (event.data);
314 this._addScript(script); 314 this._addScript(script);
315 } 315 }
316 316
317 /** 317 /**
318 * @param {!WebInspector.Script} script 318 * @param {!SDK.Script} script
319 * @return {!Promise<undefined>} 319 * @return {!Promise<undefined>}
320 */ 320 */
321 _addScript(script) { 321 _addScript(script) {
322 var blackboxed = this._isBlackboxedScript(script); 322 var blackboxed = this._isBlackboxedScript(script);
323 return this._setScriptState(script, blackboxed ? [{lineNumber: 0, columnNumb er: 0}] : []); 323 return this._setScriptState(script, blackboxed ? [{lineNumber: 0, columnNumb er: 0}] : []);
324 } 324 }
325 325
326 /** 326 /**
327 * @param {!WebInspector.Script} script 327 * @param {!SDK.Script} script
328 * @return {boolean} 328 * @return {boolean}
329 */ 329 */
330 _isBlackboxedScript(script) { 330 _isBlackboxedScript(script) {
331 return this.isBlackboxedURL(script.sourceURL, script.isContentScript()); 331 return this.isBlackboxedURL(script.sourceURL, script.isContentScript());
332 } 332 }
333 333
334 /** 334 /**
335 * @param {!WebInspector.Script} script 335 * @param {!SDK.Script} script
336 * @return {?Array<!Protocol.Debugger.ScriptPosition>} 336 * @return {?Array<!Protocol.Debugger.ScriptPosition>}
337 */ 337 */
338 _scriptPositions(script) { 338 _scriptPositions(script) {
339 if (this._debuggerModelData.has(script.debuggerModel)) 339 if (this._debuggerModelData.has(script.debuggerModel))
340 return this._debuggerModelData.get(script.debuggerModel).get(script.script Id) || null; 340 return this._debuggerModelData.get(script.debuggerModel).get(script.script Id) || null;
341 return null; 341 return null;
342 } 342 }
343 343
344 /** 344 /**
345 * @param {!WebInspector.Script} script 345 * @param {!SDK.Script} script
346 * @param {!Array<!Protocol.Debugger.ScriptPosition>} positions 346 * @param {!Array<!Protocol.Debugger.ScriptPosition>} positions
347 */ 347 */
348 _setScriptPositions(script, positions) { 348 _setScriptPositions(script, positions) {
349 var debuggerModel = script.debuggerModel; 349 var debuggerModel = script.debuggerModel;
350 if (!this._debuggerModelData.has(debuggerModel)) 350 if (!this._debuggerModelData.has(debuggerModel))
351 this._debuggerModelData.set(debuggerModel, new Map()); 351 this._debuggerModelData.set(debuggerModel, new Map());
352 this._debuggerModelData.get(debuggerModel).set(script.scriptId, positions); 352 this._debuggerModelData.get(debuggerModel).set(script.scriptId, positions);
353 } 353 }
354 354
355 /** 355 /**
356 * @param {!WebInspector.Script} script 356 * @param {!SDK.Script} script
357 * @param {!Array<!Protocol.Debugger.ScriptPosition>} positions 357 * @param {!Array<!Protocol.Debugger.ScriptPosition>} positions
358 * @return {!Promise<undefined>} 358 * @return {!Promise<undefined>}
359 */ 359 */
360 _setScriptState(script, positions) { 360 _setScriptState(script, positions) {
361 var previousScriptState = this._scriptPositions(script); 361 var previousScriptState = this._scriptPositions(script);
362 if (previousScriptState) { 362 if (previousScriptState) {
363 var hasChanged = false; 363 var hasChanged = false;
364 hasChanged = previousScriptState.length !== positions.length; 364 hasChanged = previousScriptState.length !== positions.length;
365 for (var i = 0; !hasChanged && i < positions.length; ++i) 365 for (var i = 0; !hasChanged && i < positions.length; ++i)
366 hasChanged = positions[i].lineNumber !== previousScriptState[i].lineNumb er || 366 hasChanged = positions[i].lineNumber !== previousScriptState[i].lineNumb er ||
367 positions[i].columnNumber !== previousScriptState[i].columnNumber; 367 positions[i].columnNumber !== previousScriptState[i].columnNumber;
368 if (!hasChanged) 368 if (!hasChanged)
369 return Promise.resolve(); 369 return Promise.resolve();
370 } else { 370 } else {
371 if (positions.length === 0) 371 if (positions.length === 0)
372 return Promise.resolve().then(updateState.bind(this, false)); 372 return Promise.resolve().then(updateState.bind(this, false));
373 } 373 }
374 374
375 return script.setBlackboxedRanges(positions).then(updateState.bind(this)); 375 return script.setBlackboxedRanges(positions).then(updateState.bind(this));
376 376
377 /** 377 /**
378 * @param {boolean} success 378 * @param {boolean} success
379 * @this {WebInspector.BlackboxManager} 379 * @this {Bindings.BlackboxManager}
380 */ 380 */
381 function updateState(success) { 381 function updateState(success) {
382 if (success) { 382 if (success) {
383 this._setScriptPositions(script, positions); 383 this._setScriptPositions(script, positions);
384 this._debuggerWorkspaceBinding.updateLocations(script); 384 this._debuggerWorkspaceBinding.updateLocations(script);
385 var isBlackboxed = positions.length !== 0; 385 var isBlackboxed = positions.length !== 0;
386 if (!isBlackboxed && script.sourceMapURL) 386 if (!isBlackboxed && script.sourceMapURL)
387 this._debuggerWorkspaceBinding.maybeLoadSourceMap(script); 387 this._debuggerWorkspaceBinding.maybeLoadSourceMap(script);
388 } else { 388 } else {
389 var hasPositions = !!this._scriptPositions(script); 389 var hasPositions = !!this._scriptPositions(script);
390 if (!hasPositions) 390 if (!hasPositions)
391 this._setScriptPositions(script, []); 391 this._setScriptPositions(script, []);
392 } 392 }
393 } 393 }
394 } 394 }
395 395
396 /** 396 /**
397 * @param {string} url 397 * @param {string} url
398 * @return {string} 398 * @return {string}
399 */ 399 */
400 _urlToRegExpString(url) { 400 _urlToRegExpString(url) {
401 var parsedURL = new WebInspector.ParsedURL(url); 401 var parsedURL = new Common.ParsedURL(url);
402 if (parsedURL.isAboutBlank() || parsedURL.isDataURL()) 402 if (parsedURL.isAboutBlank() || parsedURL.isDataURL())
403 return ''; 403 return '';
404 if (!parsedURL.isValid) 404 if (!parsedURL.isValid)
405 return '^' + url.escapeForRegExp() + '$'; 405 return '^' + url.escapeForRegExp() + '$';
406 var name = parsedURL.lastPathComponent; 406 var name = parsedURL.lastPathComponent;
407 if (name) 407 if (name)
408 name = '/' + name; 408 name = '/' + name;
409 else if (parsedURL.folderPathComponents) 409 else if (parsedURL.folderPathComponents)
410 name = parsedURL.folderPathComponents + '/'; 410 name = parsedURL.folderPathComponents + '/';
411 if (!name) 411 if (!name)
412 name = parsedURL.host; 412 name = parsedURL.host;
413 if (!name) 413 if (!name)
414 return ''; 414 return '';
415 var scheme = parsedURL.scheme; 415 var scheme = parsedURL.scheme;
416 var prefix = ''; 416 var prefix = '';
417 if (scheme && scheme !== 'http' && scheme !== 'https') { 417 if (scheme && scheme !== 'http' && scheme !== 'https') {
418 prefix = '^' + scheme + '://'; 418 prefix = '^' + scheme + '://';
419 if (scheme === 'chrome-extension') 419 if (scheme === 'chrome-extension')
420 prefix += parsedURL.host + '\\b'; 420 prefix += parsedURL.host + '\\b';
421 prefix += '.*'; 421 prefix += '.*';
422 } 422 }
423 return prefix + name.escapeForRegExp() + (url.endsWith(name) ? '$' : '\\b'); 423 return prefix + name.escapeForRegExp() + (url.endsWith(name) ? '$' : '\\b');
424 } 424 }
425 }; 425 };
426 426
427 /** @type {!WebInspector.BlackboxManager} */ 427 /** @type {!Bindings.BlackboxManager} */
428 WebInspector.blackboxManager; 428 Bindings.blackboxManager;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698