Changeset 86552 in webkit
- Timestamp:
- May 16, 2011 2:53:57 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r86551 r86552 1 2011-05-05 Pavel Podivilov <podivilov@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: move double click handling from TextEditor to SourceFrame. 6 https://bugs.webkit.org/show_bug.cgi?id=60271 7 8 It is SourceFrame's responsibility to check if content is editable and 9 to configure TextEditor component (e.g. set editable range) when user 10 tries to initiate editing. 11 12 * inspector/front-end/ResourceView.js: 13 (WebInspector.ResourceSourceFrame.prototype.doubleClick): 14 (WebInspector.RevisionSourceFrame.prototype.doubleClick): 15 * inspector/front-end/SourceFrame.js: 16 (WebInspector.SourceFrame.prototype.beforeTextChanged): 17 (WebInspector.SourceFrame.prototype.afterTextChanged): 18 (WebInspector.SourceFrame.prototype.doubleClick): 19 (WebInspector.SourceFrame.prototype.commitEditing.didEditContent): 20 (WebInspector.SourceFrame.prototype.commitEditing): 21 (WebInspector.SourceFrame.prototype.cancelEditing): 22 (WebInspector.SourceFrame.prototype._setReadOnly): 23 * inspector/front-end/TextViewer.js: 24 (WebInspector.TextViewer.prototype.set readOnly): 25 (WebInspector.TextViewer.prototype._enterInternalTextChangeMode): 26 (WebInspector.TextViewer.prototype._exitInternalTextChangeMode): 27 (WebInspector.TextViewer.prototype._doubleClick): 28 (WebInspector.TextViewer.prototype._commitEditing): 29 (WebInspector.TextViewer.prototype._cancelEditing): 30 (WebInspector.TextViewerDelegate.prototype.doubleClick): 31 (WebInspector.TextViewerDelegate.prototype.beforeTextChanged): 32 (WebInspector.TextViewerDelegate.prototype.afterTextChanged): 33 1 34 2011-05-15 Robert Hogan <robert@webkit.org> 2 35 -
trunk/Source/WebCore/inspector/front-end/ResourceView.js
r85943 r86552 137 137 }, 138 138 139 isContentEditable: function() 140 { 141 return this._resource.isEditable(); 139 doubleClick: function(lineNumber) 140 { 141 if (!this._resource.isEditable()) 142 return; 143 144 if (this._commitEditingInProgress) 145 return; 146 147 this._textViewer.readOnly = false; 148 WebInspector.markBeingEdited(this._textViewer.element, true); 142 149 }, 143 150 … … 157 164 }, 158 165 159 endEditing: function(oldRange, newRange)166 afterTextChanged: function(oldRange, newRange) 160 167 { 161 168 function commitIncrementalEdit() … … 205 212 }, 206 213 207 isContentEditable: function() 208 { 209 return false; 214 doubleClick: function(lineNumber) 215 { 210 216 }, 211 217 -
trunk/Source/WebCore/inspector/front-end/SourceFrame.js
r85319 r86552 234 234 }, 235 235 236 isContentEditable: function() 237 { 238 return this._delegate.canEditScriptSource(); 239 }, 240 241 readOnlyStateChanged: function(readOnly) 242 { 243 WebInspector.markBeingEdited(this._textViewer.element, !readOnly); 244 }, 245 246 startEditing: function() 236 beforeTextChanged: function() 247 237 { 248 238 if (!this._viewerState) { … … 255 245 }, 256 246 257 endEditing: function(oldRange, newRange)247 afterTextChanged: function(oldRange, newRange) 258 248 { 259 249 if (!oldRange || !newRange) … … 884 874 }, 885 875 876 doubleClick: function(lineNumber) 877 { 878 if (!this._delegate.canEditScriptSource()) 879 return; 880 881 if (this._commitEditingInProgress) 882 return; 883 884 this._setReadOnly(false); 885 }, 886 886 887 commitEditing: function(callback) 887 888 { 888 889 if (!this._viewerState) { 889 890 // No editing was actually done. 890 this._ delegate.setScriptSourceIsBeingEdited(false);891 this._setReadOnly(true); 891 892 callback(); 892 893 return; … … 895 896 function didEditContent(error) 896 897 { 898 this._commitEditingInProgress = false; 897 899 if (error) { 898 900 if (error.data && error.data[0]) { … … 900 902 WebInspector.showConsole(); 901 903 } 902 callback(error);904 this._textViewer.readOnly = false; 903 905 return; 904 906 } … … 919 921 920 922 delete this._viewerState; 923 this._setReadOnly(true); 924 } 925 this._commitEditingInProgress = true; 926 this._textViewer.readOnly = true; 927 this.editContent(this._textModel.text, didEditContent.bind(this)); 928 }, 929 930 editContent: function(newContent, callback) 931 { 932 this._delegate.editScriptSource(newContent, callback); 933 }, 934 935 cancelEditing: function() 936 { 937 this._restoreViewerState(); 938 this._setReadOnly(true); 939 }, 940 941 _setReadOnly: function(readOnly) 942 { 943 this._textViewer.readOnly = readOnly; 944 WebInspector.markBeingEdited(this._textViewer.element, !readOnly); 945 if (readOnly) 921 946 this._delegate.setScriptSourceIsBeingEdited(false); 922 923 callback();924 }925 this.editContent(this._textModel.text, didEditContent.bind(this));926 },927 928 editContent: function(newContent, callback)929 {930 this._delegate.editScriptSource(newContent, callback);931 },932 933 cancelEditing: function()934 {935 this._restoreViewerState();936 this._delegate.setScriptSourceIsBeingEdited(false);937 947 } 938 948 } -
trunk/Source/WebCore/inspector/front-end/TextViewer.js
r86446 r86552 73 73 return; 74 74 this._mainPanel.readOnly = readOnly; 75 this._delegate.readOnlyStateChanged(readOnly);76 75 }, 77 76 … … 178 177 { 179 178 this._internalTextChangeMode = true; 180 this._delegate. startEditing();179 this._delegate.beforeTextChanged(); 181 180 }, 182 181 … … 184 183 { 185 184 this._internalTextChangeMode = false; 186 this._delegate. endEditing(oldRange, newRange);185 this._delegate.afterTextChanged(oldRange, newRange); 187 186 }, 188 187 … … 230 229 _doubleClick: function(event) 231 230 { 232 if (!this.readOnly || this._commitEditingInProgress)231 if (!this.readOnly) 233 232 return; 234 233 … … 237 236 return; // Do not trigger editing from line numbers. 238 237 239 if (!this._delegate.isContentEditable()) 240 return; 241 242 this.readOnly = false; 238 this._delegate.doubleClick(lineRow.lineNumber); 243 239 window.getSelection().collapseToStart(); 244 240 }, … … 302 298 return false; 303 299 304 this.readOnly = true; 305 function didCommitEditing(error) 306 { 307 this._commitEditingInProgress = false; 308 if (error) 309 this.readOnly = false; 310 } 311 this._commitEditingInProgress = true; 312 this._delegate.commitEditing(didCommitEditing.bind(this)); 300 this._delegate.commitEditing(); 313 301 return true; 314 302 }, … … 319 307 return false; 320 308 321 this.readOnly = true;322 309 this._delegate.cancelEditing(); 323 310 return true; … … 332 319 333 320 WebInspector.TextViewerDelegate.prototype = { 334 isContentEditable: function()321 doubleClick: function(lineNumber) 335 322 { 336 323 // Should be implemented by subclasses. 337 324 }, 338 325 339 readOnlyStateChanged: function(readOnly)326 beforeTextChanged: function() 340 327 { 341 328 // Should be implemented by subclasses. 342 329 }, 343 330 344 startEditing: function() 345 { 346 // Should be implemented by subclasses. 347 }, 348 349 endEditing: function(oldRange, newRange) 331 afterTextChanged: function(oldRange, newRange) 350 332 { 351 333 // Should be implemented by subclasses.
Note: See TracChangeset
for help on using the changeset viewer.