 Chromium Code Reviews
 Chromium Code Reviews Issue 1663723002:
  [DevTools] Add sourceMap support for blackboxing  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@call-set-blackboxed-ranges-on-script-parsed
    
  
    Issue 1663723002:
  [DevTools] Add sourceMap support for blackboxing  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@call-set-blackboxed-ranges-on-script-parsed| OLD | NEW | 
|---|---|
| 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 /** | 5 /** | 
| 6 * @constructor | 6 * @constructor | 
| 7 */ | 7 */ | 
| 8 WebInspector.BlackboxManager = function() | 8 WebInspector.BlackboxManager = function() | 
| 9 { | 9 { | 
| 10 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI nspector.DebuggerModel.Events.ParsedScriptSource, this._parsedScriptSource, this ); | 10 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI nspector.DebuggerModel.Events.ParsedScriptSource, this._parsedScriptSource, this ); | 
| 11 WebInspector.moduleSetting("skipStackFramesPattern").addChangeListener(this. _patternChanged.bind(this)); | 11 WebInspector.moduleSetting("skipStackFramesPattern").addChangeListener(this. _patternChanged.bind(this)); | 
| 12 WebInspector.moduleSetting("skipContentScripts").addChangeListener(this._pat ternChanged.bind(this)); | 12 WebInspector.moduleSetting("skipContentScripts").addChangeListener(this._pat ternChanged.bind(this)); | 
| 13 | |
| 14 /** @type {!Map<string, !WebInspector.SourceMap>} */ | |
| 15 this._sourceMapForScriptId = new Map(); | |
| 
dgozman
2016/02/03 18:24:10
Ask CompilerScriptMapping instead of keeping a sep
 
kozy
2016/02/09 23:10:09
Done.
 | |
| 13 } | 16 } | 
| 14 | 17 | 
| 15 WebInspector.BlackboxManager.prototype = { | 18 WebInspector.BlackboxManager.prototype = { | 
| 16 /** | 19 /** | 
| 17 * @param {!WebInspector.Event} event | 20 * @param {!WebInspector.Event} event | 
| 18 */ | 21 */ | 
| 19 _parsedScriptSource: function(event) | 22 _parsedScriptSource: function(event) | 
| 20 { | 23 { | 
| 21 var script = /** @type {!WebInspector.Script} */ (event.data); | 24 var script = /** @type {!WebInspector.Script} */ (event.data); | 
| 25 script.addEventListener(WebInspector.Script.Events.SourceMapLoaded, this ._sourceMapLoaded.bind(this, script)); | |
| 22 this._blackboxScriptIfNeeded(script); | 26 this._blackboxScriptIfNeeded(script); | 
| 23 }, | 27 }, | 
| 24 | 28 | 
| 25 _patternChanged: function() | 29 _patternChanged: function() | 
| 26 { | 30 { | 
| 27 for (var debuggerModel of WebInspector.DebuggerModel.instances()) { | 31 for (var debuggerModel of WebInspector.DebuggerModel.instances()) { | 
| 28 for (var scriptId in debuggerModel.scripts) | 32 for (var scriptId in debuggerModel.scripts) | 
| 29 this._blackboxScriptIfNeeded(debuggerModel.scripts[scriptId]); | 33 this._blackboxScriptIfNeeded(debuggerModel.scripts[scriptId]); | 
| 30 } | 34 } | 
| 31 }, | 35 }, | 
| 32 | 36 | 
| 33 /** | 37 /** | 
| 34 * @param {!WebInspector.Script} script | 38 * @param {!WebInspector.Script} script | 
| 35 */ | 39 */ | 
| 36 _blackboxScriptIfNeeded: function(script) | 40 _blackboxScriptIfNeeded: function(script) | 
| 37 { | 41 { | 
| 38 if (WebInspector.BlackboxSupport.isBlackboxed(script.sourceURL, script.i sContentScript())) | 42 if (WebInspector.BlackboxSupport.isBlackboxed(script.sourceURL, script.i sContentScript())) { | 
| 39 script.setBlackboxedRanges([ { line: 0, column: 0 } ]); | 43 script.setBlackboxedRanges([ { line: 0, column: 0 } ]); | 
| 40 else | 44 return; | 
| 45 } | |
| 46 | |
| 47 if (!this._sourceMapForScriptId.has(script.scriptId)) { | |
| 41 script.setBlackboxedRanges([]); | 48 script.setBlackboxedRanges([]); | 
| 49 return; | |
| 50 } | |
| 51 | |
| 52 var sourceMap = this._sourceMapForScriptId.get(script.scriptId); | |
| 53 var mappings = sourceMap.mappings().slice(); | |
| 54 mappings.sort(mappingComparator); | |
| 55 | |
| 56 if (!mappings.length) { | |
| 57 script.setBlackboxedRanges([]); | |
| 58 return; | |
| 59 } | |
| 60 | |
| 61 var currentBlackboxed = false; | |
| 62 var positions = []; | |
| 63 if (mappings[0].lineNumber !== 0 || mappings[0].columnNumber !== 0) { | |
| 64 positions.push({ line: 0, column: 0}); | |
| 65 currentBlackboxed = true; | |
| 66 } | |
| 67 for (var mapping of sourceMap.mappings()) { | |
| 68 if (currentBlackboxed !== WebInspector.BlackboxSupport.isBlackboxedU RL(mapping.sourceURL)) { | |
| 
dgozman
2016/02/03 18:24:10
Ain't this slow? Should we cache instead of regexp
 
kozy
2016/02/09 23:10:09
Done.
 | |
| 69 positions.push({ line: mapping.lineNumber, column: mapping.colum nNumber }); | |
| 70 currentBlackboxed = !currentBlackboxed; | |
| 71 } | |
| 72 } | |
| 73 | |
| 74 script.setBlackboxedRanges(positions); | |
| 75 | |
| 76 /** | |
| 77 * @param {!WebInspector.SourceMap.Entry} a | |
| 78 * @param {!WebInspector.SourceMap.Entry} b | |
| 79 */ | |
| 80 function mappingComparator(a, b) | |
| 81 { | |
| 82 if (a.lineNumber !== b.lineNumber) | |
| 83 return a.lineNumber - b.lineNumber; | |
| 84 return a.columnNumber - b.columnNumber; | |
| 85 } | |
| 86 }, | |
| 87 | |
| 88 /** | |
| 89 * @param {!WebInspector.Script} script | |
| 90 * @param {!WebInspector.Event} event | |
| 91 */ | |
| 92 _sourceMapLoaded: function(script, event) | |
| 93 { | |
| 94 var sourceMap = /** @type {?WebInspector.SourceMap} */ (event.data); | |
| 95 if (!sourceMap) | |
| 96 return; | |
| 97 | |
| 98 this._sourceMapForScriptId.set(script.scriptId, sourceMap); | |
| 99 this._blackboxScriptIfNeeded(script); | |
| 42 } | 100 } | 
| 43 } | 101 } | 
| 44 | 102 | 
| 45 WebInspector.BlackboxSupport = {} | 103 WebInspector.BlackboxSupport = {} | 
| 46 | 104 | 
| 47 /** | 105 /** | 
| 48 * @param {string} url | 106 * @param {string} url | 
| 49 * @return {string} | 107 * @return {string} | 
| 50 */ | 108 */ | 
| 51 WebInspector.BlackboxSupport._urlToRegExpString = function(url) | 109 WebInspector.BlackboxSupport._urlToRegExpString = function(url) | 
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 } | 227 } | 
| 170 | 228 | 
| 171 /** | 229 /** | 
| 172 * @param {function(!WebInspector.Event)} listener | 230 * @param {function(!WebInspector.Event)} listener | 
| 173 * @param {!Object=} thisObject | 231 * @param {!Object=} thisObject | 
| 174 */ | 232 */ | 
| 175 WebInspector.BlackboxSupport.removeChangeListener = function(listener, thisObjec t) | 233 WebInspector.BlackboxSupport.removeChangeListener = function(listener, thisObjec t) | 
| 176 { | 234 { | 
| 177 WebInspector.moduleSetting("skipStackFramesPattern").removeChangeListener(li stener, thisObject); | 235 WebInspector.moduleSetting("skipStackFramesPattern").removeChangeListener(li stener, thisObject); | 
| 178 } | 236 } | 
| OLD | NEW |