| 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 var historyItems = registry[this.url]; | 197 var historyItems = registry[this.url]; |
| 198 for (var i = 0; historyItems && i < historyItems.length; ++i) | 198 for (var i = 0; historyItems && i < historyItems.length; ++i) |
| 199 delete window.localStorage[historyItems[i].key]; | 199 delete window.localStorage[historyItems[i].key]; |
| 200 delete registry[this.url]; | 200 delete registry[this.url]; |
| 201 window.localStorage["revision-history"] = JSON.stringify(registry); | 201 window.localStorage["revision-history"] = JSON.stringify(registry); |
| 202 }, | 202 }, |
| 203 | 203 |
| 204 revertToOriginal: function() | 204 revertToOriginal: function() |
| 205 { | 205 { |
| 206 /** | 206 /** |
| 207 * @this {WebInspector.UISourceCode} |
| 207 * @param {?string} content | 208 * @param {?string} content |
| 208 * @param {boolean} contentEncoded | 209 * @param {boolean} contentEncoded |
| 209 * @param {string} mimeType | 210 * @param {string} mimeType |
| 210 */ | 211 */ |
| 211 function callback(content, contentEncoded, mimeType) | 212 function callback(content, contentEncoded, mimeType) |
| 212 { | 213 { |
| 213 this._setContent(); | 214 if (typeof content === "undefined") |
| 215 return; |
| 216 |
| 217 this._setContent(/** @type {string} */ content); |
| 214 } | 218 } |
| 215 | 219 |
| 216 this.requestOriginalContent(callback.bind(this)); | 220 this.requestOriginalContent(callback.bind(this)); |
| 217 }, | 221 }, |
| 218 | 222 |
| 223 /** |
| 224 * @param {function(WebInspector.UISourceCode)} callback |
| 225 */ |
| 219 revertAndClearHistory: function(callback) | 226 revertAndClearHistory: function(callback) |
| 220 { | 227 { |
| 221 function revert(content) | 228 /** |
| 229 * @this {WebInspector.UISourceCode} |
| 230 * @param {?string} content |
| 231 * @param {boolean} contentEncoded |
| 232 * @param {string} mimeType |
| 233 */ |
| 234 function revert(content, contentEncoded, mimeType) |
| 222 { | 235 { |
| 223 this._setContent(content); | 236 if (typeof content === "undefined") |
| 237 return; |
| 238 |
| 239 this._setContent(/** @type {string} */ content); |
| 224 this._clearRevisionHistory(); | 240 this._clearRevisionHistory(); |
| 225 this.history = []; | 241 this.history = []; |
| 226 callback(); | 242 callback(this); |
| 227 } | 243 } |
| 228 | 244 |
| 229 this.requestOriginalContent(revert.bind(this)); | 245 this.requestOriginalContent(revert.bind(this)); |
| 230 }, | 246 }, |
| 231 | 247 |
| 232 /** | 248 /** |
| 233 * @param {string} newContent | 249 * @param {string} newContent |
| 234 * @param {string} mimeType | 250 * @param {string} mimeType |
| 235 */ | 251 */ |
| 236 contentChanged: function(newContent, mimeType) | 252 contentChanged: function(newContent, mimeType) |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 function persist() | 847 function persist() |
| 832 { | 848 { |
| 833 window.localStorage[key] = this._content; | 849 window.localStorage[key] = this._content; |
| 834 window.localStorage["revision-history"] = JSON.stringify(registry); | 850 window.localStorage["revision-history"] = JSON.stringify(registry); |
| 835 } | 851 } |
| 836 | 852 |
| 837 // Schedule async storage. | 853 // Schedule async storage. |
| 838 setTimeout(persist.bind(this), 0); | 854 setTimeout(persist.bind(this), 0); |
| 839 } | 855 } |
| 840 } | 856 } |
| OLD | NEW |