Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js b/third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js |
| index 0979e6e0b301302803df054450025f58d676a19e..76aedc8c4e49b386b8f243f53209c42f59cd33c4 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js |
| @@ -68,6 +68,12 @@ Workspace.UISourceCode = class extends Common.Object { |
| /** @type {!Array<!Workspace.UISourceCode.Message>} */ |
| this._messages = []; |
| + |
| + this._contentLoaded = false; |
| + /** @type {?string} */ |
| + this._originalContent = null; |
| + /** @type {?string} */ |
| + this._content = null; |
| } |
| /** |
| @@ -273,10 +279,9 @@ Workspace.UISourceCode = class extends Common.Object { |
| * @return {!Promise<?string>} |
| */ |
| requestOriginalContent() { |
| - var callback; |
| - var promise = new Promise(fulfill => callback = fulfill); |
| - this._project.requestFileContent(this, callback); |
| - return promise; |
| + if (this._contentLoaded) |
| + return Promise.resolve(this._originalContent); |
| + return this.requestContent(); |
| } |
| /** |
| @@ -298,8 +303,7 @@ Workspace.UISourceCode = class extends Common.Object { |
| */ |
| _contentCommitted(content, committedByUser) { |
| delete this._lastAcceptedContent; |
| - this._content = content; |
| - this._contentLoaded = true; |
| + this._setContent(content); |
|
lushnikov
2016/12/17 00:10:51
why do you want to link original content to the co
einbinder
2016/12/20 00:56:55
Yep. Done.
|
| var lastRevision = this.history.length ? this.history[this.history.length - 1] : null; |
| if (!lastRevision || lastRevision._content !== this._content) { |
| @@ -389,7 +393,7 @@ Workspace.UISourceCode = class extends Common.Object { |
| } |
| if (this.isDirty()) |
| return this._workingCopy; |
| - return this._content; |
| + return this._content || ''; |
|
einbinder
2016/12/16 23:43:00
This could have returned null before.
|
| } |
| resetWorkingCopy() { |
| @@ -485,8 +489,7 @@ Workspace.UISourceCode = class extends Common.Object { |
| * @param {?string} content |
| */ |
| _fireContentAvailable(content) { |
| - this._contentLoaded = true; |
| - this._content = content; |
| + this._setContent(content); |
| var callback = this._requestContentCallback; |
| this._requestContentCallback = null; |
| @@ -496,6 +499,16 @@ Workspace.UISourceCode = class extends Common.Object { |
| } |
| /** |
| + * @param {?string} content |
| + */ |
| + _setContent(content) { |
| + if (!this._contentLoaded) |
| + this._originalContent = content; |
| + this._contentLoaded = true; |
| + this._content = content; |
| + } |
| + |
| + /** |
| * @return {boolean} |
| */ |
| contentLoaded() { |