| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 { | 140 { |
| 141 var lines = []; | 141 var lines = []; |
| 142 var textModel = this.sourceFrame.textModel; | 142 var textModel = this.sourceFrame.textModel; |
| 143 for (var i = 0; i < textModel.linesCount; ++i) { | 143 for (var i = 0; i < textModel.linesCount; ++i) { |
| 144 if (i === line) | 144 if (i === line) |
| 145 lines.push(newContent); | 145 lines.push(newContent); |
| 146 else | 146 else |
| 147 lines.push(textModel.line(i)); | 147 lines.push(textModel.line(i)); |
| 148 } | 148 } |
| 149 | 149 |
| 150 var linesCountToShift = newContent.split("\n").length - 1; | 150 var editData = {}; |
| 151 var newContent = lines.join("\n"); | 151 editData.sourceID = this._sourceIDForLine(line); |
| 152 WebInspector.panels.scripts.editScriptSource(this._sourceIDForLine(line)
, newContent, line, linesCountToShift, this._editLineComplete.bind(this, newCont
ent), cancelEditingCallback); | 152 editData.content = lines.join("\n"); |
| 153 editData.line = line; |
| 154 editData.linesCountToShift = newContent.split("\n").length - 1; |
| 155 |
| 156 WebInspector.panels.scripts.editScriptSource(editData, this._editLineCom
plete.bind(this, editData), cancelEditingCallback); |
| 153 }, | 157 }, |
| 154 | 158 |
| 155 _editLineComplete: function(newContent) | 159 _editLineComplete: function(editData, newContent) |
| 156 { | 160 { |
| 157 this.resource.content = newContent; | 161 this.resource.setContent(newContent, this._revertEditLine.bind(this, edi
tData)); |
| 162 }, |
| 163 |
| 164 _revertEditLine: function(editData, contentToRevertTo) |
| 165 { |
| 166 var newEditData = {}; |
| 167 newEditData.sourceID = editData.sourceID; |
| 168 newEditData.content = editData.content; |
| 169 newEditData.line = editData.line; |
| 170 newEditData.linesCountToShift = -editData.linesCountToShift; |
| 171 WebInspector.panels.scripts.editScriptSource(newEditData, this._editLine
Complete.bind(this, newEditData)); |
| 158 }, | 172 }, |
| 159 | 173 |
| 160 _sourceIDForLine: function(line) | 174 _sourceIDForLine: function(line) |
| 161 { | 175 { |
| 162 var sourceID = null; | 176 var sourceID = null; |
| 163 var closestStartingLine = 0; | 177 var closestStartingLine = 0; |
| 164 var scripts = this.resource.scripts; | 178 var scripts = this.resource.scripts; |
| 165 for (var i = 0; i < scripts.length; ++i) { | 179 for (var i = 0; i < scripts.length; ++i) { |
| 166 var script = scripts[i]; | 180 var script = scripts[i]; |
| 167 if (script.startingLine <= line && script.startingLine >= closestSta
rtingLine) { | 181 if (script.startingLine <= line && script.startingLine >= closestSta
rtingLine) { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 this._sourceFrameSetup = true; | 301 this._sourceFrameSetup = true; |
| 288 this.resize(); | 302 this.resize(); |
| 289 if (this._delayedFindSearchMatches) { | 303 if (this._delayedFindSearchMatches) { |
| 290 this._delayedFindSearchMatches(); | 304 this._delayedFindSearchMatches(); |
| 291 delete this._delayedFindSearchMatches; | 305 delete this._delayedFindSearchMatches; |
| 292 } | 306 } |
| 293 } | 307 } |
| 294 } | 308 } |
| 295 | 309 |
| 296 WebInspector.SourceView.prototype.__proto__ = WebInspector.ResourceView.prototyp
e; | 310 WebInspector.SourceView.prototype.__proto__ = WebInspector.ResourceView.prototyp
e; |
| OLD | NEW |