| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 * @param {string} mimeType | 82 * @param {string} mimeType |
| 83 * @param {string} content | 83 * @param {string} content |
| 84 * @param {function(string, !WebInspector.FormatterSourceMapping)} callback | 84 * @param {function(string, !WebInspector.FormatterSourceMapping)} callback |
| 85 */ | 85 */ |
| 86 WebInspector.ScriptFormatter = function(mimeType, content, callback) | 86 WebInspector.ScriptFormatter = function(mimeType, content, callback) |
| 87 { | 87 { |
| 88 content = content.replace(/\r\n?|[\n\u2028\u2029]/g, "\n").replace(/^\uFEFF/
, ''); | 88 content = content.replace(/\r\n?|[\n\u2028\u2029]/g, "\n").replace(/^\uFEFF/
, ''); |
| 89 this._callback = callback; | 89 this._callback = callback; |
| 90 this._originalContent = content; | 90 this._originalContent = content; |
| 91 | 91 |
| 92 this._worker = new WorkerRuntime.Worker("script_formatter_worker"); | 92 this._worker = new WorkerRuntime.Worker("formatter_worker"); |
| 93 this._worker.onmessage = this._didFormatContent.bind(this); | 93 this._worker.onmessage = this._didFormatContent.bind(this); |
| 94 | 94 |
| 95 var parameters = { | 95 var parameters = { |
| 96 mimeType: mimeType, | 96 mimeType: mimeType, |
| 97 content: content, | 97 content: content, |
| 98 indentString: WebInspector.moduleSetting("textEditorIndent").get() | 98 indentString: WebInspector.moduleSetting("textEditorIndent").get() |
| 99 }; | 99 }; |
| 100 this._worker.postMessage({ method: "format", params: parameters }); | 100 this._worker.postMessage({ method: "format", params: parameters }); |
| 101 } | 101 } |
| 102 | 102 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 */ | 236 */ |
| 237 _convertPosition: function(positions1, positions2, position) | 237 _convertPosition: function(positions1, positions2, position) |
| 238 { | 238 { |
| 239 var index = positions1.upperBound(position) - 1; | 239 var index = positions1.upperBound(position) - 1; |
| 240 var convertedPosition = positions2[index] + position - positions1[index]
; | 240 var convertedPosition = positions2[index] + position - positions1[index]
; |
| 241 if (index < positions2.length - 1 && convertedPosition > positions2[inde
x + 1]) | 241 if (index < positions2.length - 1 && convertedPosition > positions2[inde
x + 1]) |
| 242 convertedPosition = positions2[index + 1]; | 242 convertedPosition = positions2[index + 1]; |
| 243 return convertedPosition; | 243 return convertedPosition; |
| 244 } | 244 } |
| 245 } | 245 } |
| OLD | NEW |