Changeset 95524 in webkit
- Timestamp:
- Sep 20, 2011 3:22:59 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r95520 r95524 1 2011-09-09 Pavel Podivilov <podivilov@chromium.org> 2 3 Web Inspector: implement reverse mapping for compiler source maps. 4 https://bugs.webkit.org/show_bug.cgi?id=67850 5 6 Reviewed by Pavel Feldman. 7 8 * inspector/debugger/compiler-source-mapping.html: 9 1 10 2011-09-20 Renata Hodovan <reni@webkit.org> 2 11 -
trunk/LayoutTests/inspector/debugger/compiler-source-mapping.html
r94577 r95524 15 15 } 16 16 17 function checkReverseMapping(compiledLineNumber, compiledColumnNumber, sourceURL, sourceLineNumber, mapping) 18 { 19 var compiledLocation = mapping.sourceLocationToCompiledLocation(sourceURL, sourceLineNumber); 20 InspectorTest.assertEquals(compiledLineNumber, compiledLocation.lineNumber); 21 InspectorTest.assertEquals(compiledColumnNumber, compiledLocation.columnNumber); 22 } 23 17 24 InspectorTest.runTestSuite([ 18 25 function testSimpleMapping(next) 19 26 { 20 // example.js: 21 // 0 1 2 3 22 // 012345678901234567890123456789012345 23 // function add(variable_x, variable_y) 24 // { 25 // return variable_x + variable_y; 26 // } 27 // example-compiled.js: 28 // 0 1 2 3 29 // 012345678901234567890123456789012345 30 // function add(a,b){return a+b}; 27 /* 28 example.js: 29 0 1 2 3 30 012345678901234567890123456789012345 31 function add(variable_x, variable_y) 32 { 33 return variable_x + variable_y; 34 } 35 36 var global = "foo"; 37 ---------------------------------------- 38 example-compiled.js: 39 0 1 2 3 40 012345678901234567890123456789012345 41 function add(a,b){return a+b}var global="foo"; 42 */ 31 43 var mappingPayload = { 32 "mappings":"AAASA,QAAAA,IAAG,CAACC,CAAD,CAAaC,CAAb,CACZ,CACI,MAAOD,EAAP,CAAoBC,CADxB ;",44 "mappings":"AAASA,QAAAA,IAAG,CAACC,CAAD,CAAaC,CAAb,CACZ,CACI,MAAOD,EAAP,CAAoBC,CADxB,CAIA,IAAIC,OAAS;", 33 45 "sources":["example.js"] 34 46 }; 35 47 var mapping = new WebInspector.ClosureCompilerSourceMapping(mappingPayload); 48 36 49 checkMapping(0, 9, "example.js", 0, 9, mapping); 37 50 checkMapping(0, 13, "example.js", 0, 13, mapping); … … 40 53 checkMapping(0, 25, "example.js", 2, 11, mapping); 41 54 checkMapping(0, 27, "example.js", 2, 24, mapping); 55 56 checkReverseMapping(0, 0, "example.js", 0, mapping); 57 checkReverseMapping(0, 17, "example.js", 1, mapping); 58 checkReverseMapping(0, 18, "example.js", 2, mapping); 59 checkReverseMapping(0, 29, "example.js", 4, mapping); 60 checkReverseMapping(0, 29, "example.js", 5, mapping); 61 InspectorTest.assertTrue(!mapping.sourceLocationToCompiledLocation("example.js", 6)); 62 42 63 next(); 43 64 } -
trunk/Source/WebCore/ChangeLog
r95522 r95524 1 2011-09-09 Pavel Podivilov <podivilov@chromium.org> 2 3 Web Inspector: implement reverse mapping for compiler source maps. 4 https://bugs.webkit.org/show_bug.cgi?id=67850 5 6 Implement the mapping from source code to compiled code. It will be used for 7 setting breakpoints on source code. 8 9 Reviewed by Pavel Feldman. 10 11 * inspector/front-end/CompilerSourceMapping.js: 12 (WebInspector.ClosureCompilerSourceMapping): 13 (WebInspector.ClosureCompilerSourceMapping.prototype.compiledLocationToSourceLocation): 14 (WebInspector.ClosureCompilerSourceMapping.prototype.sourceLocationToCompiledLocation): 15 (WebInspector.ClosureCompilerSourceMapping.prototype._parseMappings): 16 1 17 2011-09-08 Pavel Podivilov <podivilov@chromium.org> 2 18 -
trunk/Source/WebCore/inspector/front-end/CompilerSourceMapping.js
r94577 r95524 69 69 70 70 this._sources = payload.sources; 71 this._mappings = this._parsePayload(payload); 71 this._mappings = []; 72 this._reverseMappingsBySourceURL = {}; 73 for (var i = 0; i < this._sources.length; ++i) 74 this._reverseMappingsBySourceURL[this._sources[i]] = []; 75 this._parseMappings(payload.mappings); 72 76 } 73 77 … … 76 80 { 77 81 var mapping = this._findMapping(lineNumber, columnNumber); 78 var sourceURL = this._sources[mapping[2]]; 79 return { sourceURL: sourceURL, lineNumber: mapping[3], columnNumber: mapping[4] }; 80 }, 81 82 sourceLocationToCompiledLocation: function(sourceURL, lineNumber, columnNumber) 83 { 82 return { sourceURL: mapping[2], lineNumber: mapping[3], columnNumber: mapping[4] }; 83 }, 84 85 sourceLocationToCompiledLocation: function(sourceURL, lineNumber) 86 { 87 var mappings = this._reverseMappingsBySourceURL[sourceURL]; 88 for ( ; lineNumber < mappings.length; ++lineNumber) { 89 var mapping = mappings[lineNumber]; 90 if (mapping) 91 return { lineNumber: mapping[0], columnNumber: mapping[1] }; 92 } 84 93 }, 85 94 … … 107 116 }, 108 117 109 _parsePayload: function(payload) 110 { 111 var mappings = []; 112 var stringCharIterator = new WebInspector.ClosureCompilerSourceMapping.StringCharIterator(payload.mappings); 118 _parseMappings: function(mappingsPayload) 119 { 120 var stringCharIterator = new WebInspector.ClosureCompilerSourceMapping.StringCharIterator(mappingsPayload); 113 121 114 122 var lineNumber = 0; … … 118 126 var sourceColumnNumber = 0; 119 127 var nameIndex = 0; 128 129 var sourceURL = this._sources[0]; 130 var reverseMappings = this._reverseMappingsBySourceURL[sourceURL]; 131 120 132 do { 121 133 columnNumber += this._decodeVLQ(stringCharIterator); 122 134 if (this._isSeparator(stringCharIterator.peek())) 123 135 continue; 124 sourceIndex += this._decodeVLQ(stringCharIterator); 136 var sourceIndexDelta = this._decodeVLQ(stringCharIterator); 137 if (sourceIndexDelta) { 138 sourceIndex += sourceIndexDelta; 139 sourceURL = this._sources[sourceIndex]; 140 reverseMappings = this._reverseMappingsBySourceURL[sourceURL]; 141 } 125 142 sourceLineNumber += this._decodeVLQ(stringCharIterator); 126 143 sourceColumnNumber += this._decodeVLQ(stringCharIterator); 127 var mapping = [lineNumber, columnNumber, sourceIndex, sourceLineNumber, sourceColumnNumber]; 128 if (!this._isSeparator(stringCharIterator.peek())) { 144 if (!this._isSeparator(stringCharIterator.peek())) 129 145 nameIndex += this._decodeVLQ(stringCharIterator); 130 mapping.push(nameIndex); 131 } 132 mappings.push(mapping); 146 147 this._mappings.push([lineNumber, columnNumber, sourceURL, sourceLineNumber, sourceColumnNumber]); 148 if (!reverseMappings[sourceLineNumber]) 149 reverseMappings[sourceLineNumber] = [lineNumber, columnNumber]; 150 133 151 if (stringCharIterator.next() === ";") { 134 152 lineNumber += 1; … … 136 154 } 137 155 } while(stringCharIterator.hasNext()); 138 return mappings;139 156 }, 140 157 -
trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js
r94762 r95524 174 174 var rawSourceCode = uiSourceCode.rawSourceCode; 175 175 var script = this._scriptForRawSourceCode(rawSourceCode); 176 return !script.lineOffset && !script.columnOffset;176 return script && !script.lineOffset && !script.columnOffset; 177 177 }, 178 178
Note: See TracChangeset
for help on using the changeset viewer.