OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 } | 83 } |
84 return result; | 84 return result; |
85 } | 85 } |
86 | 86 |
87 DebuggerScript._formatScript = function(script) | 87 DebuggerScript._formatScript = function(script) |
88 { | 88 { |
89 var lineEnds = script.line_ends; | 89 var lineEnds = script.line_ends; |
90 var lineCount = lineEnds.length; | 90 var lineCount = lineEnds.length; |
91 var endLine = script.line_offset + lineCount - 1; | 91 var endLine = script.line_offset + lineCount - 1; |
92 var endColumn; | 92 var endColumn; |
93 if (lineCount === 1) | 93 // V8 will not count last line if script source ends with \n. |
94 endColumn = script.source.length + script.column_offset; | 94 if (script.source[script.source.length - 1] === '\n') { |
95 else | 95 endLine += 1; |
96 endColumn = script.source.length - (script.line_ends[lineCount - 2] + 1)
; | 96 endColumn = 0; |
| 97 } else { |
| 98 if (lineCount === 1) |
| 99 endColumn = script.source.length + script.column_offset; |
| 100 else |
| 101 endColumn = script.source.length - (lineEnds[lineCount - 2] + 1); |
| 102 } |
97 | 103 |
98 return { | 104 return { |
99 id: script.id, | 105 id: script.id, |
100 name: script.nameOrSourceURL(), | 106 name: script.nameOrSourceURL(), |
101 source: script.source, | 107 source: script.source, |
102 startLine: script.line_offset, | 108 startLine: script.line_offset, |
103 startColumn: script.column_offset, | 109 startColumn: script.column_offset, |
104 endLine: endLine, | 110 endLine: endLine, |
105 endColumn: endColumn, | 111 endColumn: endColumn, |
106 isContentScript: !!script.context_data && script.context_data.indexOf("i
njected") == 0 | 112 isContentScript: !!script.context_data && script.context_data.indexOf("i
njected") == 0 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 "thisObject": thisObject, | 276 "thisObject": thisObject, |
271 "scopeChain": scopeChain, | 277 "scopeChain": scopeChain, |
272 "scopeType": scopeType, | 278 "scopeType": scopeType, |
273 "evaluate": evaluate, | 279 "evaluate": evaluate, |
274 "caller": callerFrame | 280 "caller": callerFrame |
275 }; | 281 }; |
276 } | 282 } |
277 | 283 |
278 return DebuggerScript; | 284 return DebuggerScript; |
279 })(); | 285 })(); |
OLD | NEW |