OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 | 324 |
325 /** | 325 /** |
326 * @constructor | 326 * @constructor |
327 * @param {!WebInspector.UISourceCode} uiSourceCode | 327 * @param {!WebInspector.UISourceCode} uiSourceCode |
328 * @param {!WebInspector.StylesSourceMapping} mapping | 328 * @param {!WebInspector.StylesSourceMapping} mapping |
329 */ | 329 */ |
330 WebInspector.StyleFile = function(uiSourceCode, mapping) | 330 WebInspector.StyleFile = function(uiSourceCode, mapping) |
331 { | 331 { |
332 this._uiSourceCode = uiSourceCode; | 332 this._uiSourceCode = uiSourceCode; |
333 this._mapping = mapping; | 333 this._mapping = mapping; |
334 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working
CopyChanged, this._workingCopyChanged, this); | 334 this._eventListeners = [ |
335 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working
CopyCommitted, this._workingCopyCommitted, this); | 335 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Wor
kingCopyChanged, this._workingCopyChanged, this), |
| 336 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Wor
kingCopyCommitted, this._workingCopyCommitted, this) |
| 337 ]; |
336 this._uiSourceCode.forceLoadOnCheckContent(); | 338 this._uiSourceCode.forceLoadOnCheckContent(); |
337 this._commitThrottler = new WebInspector.Throttler(WebInspector.StyleFile.up
dateTimeout); | 339 this._commitThrottler = new WebInspector.Throttler(WebInspector.StyleFile.up
dateTimeout); |
| 340 this._terminated = false; |
338 } | 341 } |
339 | 342 |
340 WebInspector.StyleFile.updateTimeout = 200; | 343 WebInspector.StyleFile.updateTimeout = 200; |
341 | 344 |
342 WebInspector.StyleFile.prototype = { | 345 WebInspector.StyleFile.prototype = { |
343 /** | 346 /** |
344 * @param {!WebInspector.Event} event | 347 * @param {!WebInspector.Event} event |
345 */ | 348 */ |
346 _workingCopyCommitted: function(event) | 349 _workingCopyCommitted: function(event) |
347 { | 350 { |
(...skipping 10 matching lines...) Expand all Loading... |
358 _workingCopyChanged: function(event) | 361 _workingCopyChanged: function(event) |
359 { | 362 { |
360 if (this._isAddingRevision) | 363 if (this._isAddingRevision) |
361 return; | 364 return; |
362 | 365 |
363 this._commitThrottler.schedule(this._commitIncrementalEdit.bind(this), f
alse); | 366 this._commitThrottler.schedule(this._commitIncrementalEdit.bind(this), f
alse); |
364 }, | 367 }, |
365 | 368 |
366 _commitIncrementalEdit: function() | 369 _commitIncrementalEdit: function() |
367 { | 370 { |
| 371 if (this._terminated) |
| 372 return; |
368 var promise = this._mapping._setStyleContent(this._uiSourceCode, this._u
iSourceCode.workingCopy(), this._isMajorChangePending) | 373 var promise = this._mapping._setStyleContent(this._uiSourceCode, this._u
iSourceCode.workingCopy(), this._isMajorChangePending) |
369 .then(this._styleContentSet.bind(this)) | 374 .then(this._styleContentSet.bind(this)) |
370 this._isMajorChangePending = false; | 375 this._isMajorChangePending = false; |
371 return promise; | 376 return promise; |
372 }, | 377 }, |
373 | 378 |
374 /** | 379 /** |
375 * @param {?string} error | 380 * @param {?string} error |
376 */ | 381 */ |
377 _styleContentSet: function(error) | 382 _styleContentSet: function(error) |
378 { | 383 { |
379 if (error) | 384 if (error) |
380 console.error(error); | 385 console.error(error); |
381 }, | 386 }, |
382 | 387 |
383 /** | 388 /** |
384 * @param {string} content | 389 * @param {string} content |
385 */ | 390 */ |
386 addRevision: function(content) | 391 addRevision: function(content) |
387 { | 392 { |
388 this._isAddingRevision = true; | 393 this._isAddingRevision = true; |
389 this._uiSourceCode.addRevision(content); | 394 this._uiSourceCode.addRevision(content); |
390 delete this._isAddingRevision; | 395 delete this._isAddingRevision; |
391 }, | 396 }, |
392 | 397 |
393 dispose: function() | 398 dispose: function() |
394 { | 399 { |
395 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.
WorkingCopyCommitted, this._workingCopyCommitted, this); | 400 if (this._terminated) |
396 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.
WorkingCopyChanged, this._workingCopyChanged, this); | 401 return; |
| 402 this._terminated = true; |
| 403 WebInspector.EventTarget.removeEventListeners(this._eventListeners); |
397 } | 404 } |
398 } | 405 } |
OLD | NEW |