Changeset 117781 in webkit
- Timestamp:
- May 21, 2012 8:09:56 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r117778 r117781 1 2012-05-21 Vsevolod Vlasov <vsevik@chromium.org> 2 3 Web Inspector: Move working copy support to UISourceCode and use it for both styles and scripts. 4 https://bugs.webkit.org/show_bug.cgi?id=87021 5 6 Reviewed by Pavel Feldman. 7 8 UISourceCode now listens for RevisionAdded event. 9 Virtual methods workingCopyChanged and workingCopyCommitted added to UISourceCode and implemented in descendants. 10 DebuggerResourceBinding does not call contentChanged on UISourceCode explicitly anymore. 11 12 * inspector/front-end/DebuggerResourceBinding.js: 13 (WebInspector.DebuggerResourceBinding.setScriptSource.didEditScriptSource): 14 (WebInspector.DebuggerResourceBinding.setScriptSource): 15 * inspector/front-end/JavaScriptSource.js: 16 (WebInspector.JavaScriptSource.prototype.workingCopyCommitted): 17 * inspector/front-end/JavaScriptSourceFrame.js: 18 (WebInspector.JavaScriptSourceFrame.prototype.commitEditing): 19 * inspector/front-end/ScriptSnippetModel.js: 20 (WebInspector.SnippetJavaScriptSource.prototype.workingCopyCommitted): 21 * inspector/front-end/StylesPanel.js: 22 (WebInspector.StyleSource.prototype.workingCopyCommitted): 23 (WebInspector.StyleSource.prototype.workingCopyChanged): 24 (WebInspector.StyleSourceFrame): 25 (WebInspector.StyleSourceFrame.prototype.commitEditing): 26 (WebInspector.StyleSourceFrame.prototype.afterTextChanged): 27 (WebInspector.StyleSourceFrame.prototype._didEditContent): 28 (WebInspector.StyleSourceFrame.prototype._onContentChanged): 29 * inspector/front-end/UISourceCode.js: 30 (WebInspector.UISourceCode): 31 (WebInspector.UISourceCode.prototype._revisionAdded): 32 (WebInspector.UISourceCode.prototype.contentChanged): 33 (WebInspector.UISourceCode.prototype.workingCopy): 34 (WebInspector.UISourceCode.prototype.setWorkingCopy): 35 (WebInspector.UISourceCode.prototype.workingCopyChanged): 36 (WebInspector.UISourceCode.prototype.commitWorkingCopy): 37 (WebInspector.UISourceCode.prototype.workingCopyCommitted): 38 1 39 2012-05-21 Andrey Kosyakov <caseq@chromium.org> 2 40 -
trunk/Source/WebCore/inspector/front-end/DebuggerResourceBinding.js
r117746 r117781 65 65 resource.addRevision(newSource); 66 66 67 uiSourceCode.contentChanged(newSource);68 67 callback(null); 69 68 } -
trunk/Source/WebCore/inspector/front-end/JavaScriptSource.js
r117600 r117781 178 178 }, 179 179 180 commitWorkingCopy: function(callback) 180 /** 181 * @param {function(?string)} callback 182 */ 183 workingCopyCommitted: function(callback) 181 184 { 182 185 WebInspector.DebuggerResourceBinding.setScriptSource(this, this.workingCopy(), callback); -
trunk/Source/WebCore/inspector/front-end/JavaScriptSourceFrame.js
r117751 r117781 94 94 { 95 95 this._editingContent = true; 96 if (!this._uiSourceCode.isDirty())97 return;98 96 this._uiSourceCode.commitWorkingCopy(this._didEditContent.bind(this)); 99 97 }, -
trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js
r117600 r117781 317 317 }, 318 318 319 commitWorkingCopy: function(callback) 320 { 319 /** 320 * @param {function(?string)} callback 321 */ 322 workingCopyCommitted: function(callback) 323 { 321 324 this._scriptSnippetModel.setScriptSnippetContent(this, this.workingCopy()); 322 callback( );325 callback(null); 323 326 }, 324 327 -
trunk/Source/WebCore/inspector/front-end/StylesPanel.js
r117750 r117781 99 99 100 100 WebInspector.StyleSource.prototype = { 101 /** 102 * @param {function(?string)} callback 103 */ 104 workingCopyCommitted: function(callback) 105 { 106 this._resource.setContent(this.workingCopy(), true, callback); 107 }, 108 109 workingCopyChanged: function() 110 { 111 function commitIncrementalEdit() 112 { 113 this._resource.setContent(this.workingCopy(), false, function() {}); 114 } 115 const updateTimeout = 200; 116 this._incrementalUpdateTimer = setTimeout(commitIncrementalEdit.bind(this), updateTimeout); 117 } 101 118 } 102 119 … … 112 129 this._styleSource = styleSource; 113 130 WebInspector.SourceFrame.call(this, this._styleSource); 114 this._styleSource. resource().addEventListener(WebInspector.Resource.Events.RevisionAdded, this._contentChanged, this);131 this._styleSource.addEventListener(WebInspector.UISourceCode.Events.ContentChanged, this._onContentChanged, this); 115 132 } 116 133 … … 129 146 commitEditing: function(text) 130 147 { 131 this._styleSource. resource().setContent(text, true, function() {});148 this._styleSource.commitWorkingCopy(this._didEditContent.bind(this)); 132 149 }, 133 150 134 151 afterTextChanged: function(oldRange, newRange) 135 152 { 136 function commitIncrementalEdit() 137 { 138 var text = this._textModel.text; 139 this._styleSource.setWorkingCopy(text); 140 this._styleSource.resource().setContent(text, false, function() {}); 141 } 142 const updateTimeout = 200; 143 this._incrementalUpdateTimer = setTimeout(commitIncrementalEdit.bind(this), updateTimeout); 153 this._styleSource.setWorkingCopy(this.textModel.text); 154 }, 155 156 _didEditContent: function(error) 157 { 158 if (error) { 159 WebInspector.log(error, WebInspector.ConsoleMessage.MessageLevel.Error, true); 160 return; 161 } 144 162 }, 145 163 … … 151 169 }, 152 170 153 _contentChanged: function(event) 154 { 155 this._styleSource.contentChanged(this._styleSource.resource().content || ""); 171 /** 172 * @param {WebInspector.Event} event 173 */ 174 _onContentChanged: function(event) 175 { 156 176 this.setContent(this._styleSource.resource().content, false, "text/stylesheet"); 157 177 }, -
trunk/Source/WebCore/inspector/front-end/UISourceCode.js
r117774 r117781 56 56 */ 57 57 this._consoleMessages = []; 58 59 if (this.resource()) 60 this.resource().addEventListener(WebInspector.Resource.Events.RevisionAdded, this._revisionAdded, this); 58 61 } 59 62 … … 132 135 }, 133 136 137 _revisionAdded: function(event) 138 { 139 this.contentChanged(this.resource().content || ""); 140 }, 141 134 142 /** 135 143 * @param {string} newContent … … 137 145 contentChanged: function(newContent) 138 146 { 139 console.assert(this._contentLoaded); 140 var oldContent = this._content; 147 if (this._committingWorkingCopy) 148 return; 149 150 var oldContent = this._contentLoaded ? this._content : undefined; 141 151 this._content = newContent; 142 152 delete this._workingCopy; … … 158 168 { 159 169 console.assert(this._contentLoaded); 160 return this._workingCopy; 170 if (this.isDirty()) 171 return this._workingCopy; 172 return this._content; 161 173 }, 162 174 … … 172 184 else 173 185 this._workingCopy = newWorkingCopy; 186 this.workingCopyChanged(); 174 187 this.dispatchEventToListeners(WebInspector.UISourceCode.Events.WorkingCopyChanged, {oldWorkingCopy: oldWorkingCopy, workingCopy: newWorkingCopy}); 188 }, 189 190 workingCopyChanged: function() 191 { 192 // Overridden. 193 }, 194 195 /** 196 * @param {function(?string)} callback 197 */ 198 commitWorkingCopy: function(callback) 199 { 200 /** 201 * @param {?string} error 202 */ 203 function innerCallback(error) 204 { 205 delete this._committingWorkingCopy; 206 if (!error) 207 this.contentChanged(newContent); 208 callback(error); 209 } 210 211 if (!this.isDirty()) { 212 callback(null); 213 return; 214 } 215 216 var newContent = this._workingCopy; 217 this._committingWorkingCopy = true; 218 this.workingCopyCommitted(innerCallback.bind(this)); 219 }, 220 221 /** 222 * @param {function(?string)} callback 223 */ 224 workingCopyCommitted: function(callback) 225 { 226 // Overridden. 175 227 }, 176 228
Note: See TracChangeset
for help on using the changeset viewer.