Changeset 83288 in webkit
- Timestamp:
- Apr 8, 2011 5:31:41 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/inspector/debugger/live-edit.html
r82590 r83288 69 69 { 70 70 sourceFrame._textViewer.readOnly = false; 71 sourceFrame. _startEditing();71 sourceFrame.startEditing(); 72 72 var newText = sourceFrame._textModel.text.replace(string, replacement); 73 73 sourceFrame._textModel.setText(null, newText); -
trunk/Source/WebCore/ChangeLog
r83287 r83288 1 2011-04-07 Pavel Podivilov <podivilov@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: make SourceFrame TextViewer's delegate for editing operations. 6 https://bugs.webkit.org/show_bug.cgi?id=58026 7 8 This is the first step of decoupling TextViewer from SourceFrame. 9 10 * inspector/front-end/SourceFrame.js: 11 (WebInspector.SourceFrame): 12 (WebInspector.SourceFrame.prototype.show): 13 (WebInspector.SourceFrame.prototype.hide): 14 (WebInspector.SourceFrame.prototype._ensureContentLoaded): 15 (WebInspector.SourceFrame.prototype.contentEditable): 16 (WebInspector.SourceFrame.prototype.startEditing): 17 (WebInspector.SourceFrame.prototype.endEditing): 18 (WebInspector.SourceFrame.prototype._createTextViewer): 19 (WebInspector.SourceFrame.prototype._handleSave): 20 (WebInspector.SourceFrame.prototype._handleRevertEditing): 21 * inspector/front-end/TextViewer.js: 22 (WebInspector.TextViewer.prototype._enterInternalTextChangeMode): 23 (WebInspector.TextViewer.prototype._exitInternalTextChangeMode): 24 (WebInspector.TextViewer.prototype._syncDecorationsForLine): 25 (WebInspector.TextViewer.prototype._doubleClick): 26 (WebInspector.TextViewerDelegate): 27 (WebInspector.TextViewerDelegate.prototype.contentEditable): 28 (WebInspector.TextViewerDelegate.prototype.startEditing): 29 (WebInspector.TextViewerDelegate.prototype.endEditing): 30 (WebInspector.TextEditorMainPanel.prototype._paintScheduledLines): 31 (WebInspector.TextEditorMainPanel.prototype._handleDOMUpdates): 32 * inspector/front-end/inspector.html: 33 1 34 2011-04-08 Leandro Gracia Gil <leandrogracia@chromium.org> 2 35 -
trunk/Source/WebCore/inspector/front-end/SourceFrame.js
r82932 r83288 31 31 WebInspector.SourceFrame = function(delegate, url) 32 32 { 33 WebInspector.View.call(this); 34 35 this.element.addStyleClass("script-view"); 33 WebInspector.TextViewerDelegate.call(this); 36 34 37 35 this._delegate = delegate; … … 51 49 52 50 this._registerShortcuts(); 53 this.element.addEventListener("keydown", this._handleKeyDown.bind(this), false);54 51 } 55 52 … … 62 59 show: function(parentElement) 63 60 { 64 WebInspector.View.prototype.show.call(this, parentElement);61 this._parentElement = parentElement; 65 62 66 63 this._ensureContentLoaded(); … … 71 68 if (this._scrollLeft) 72 69 this._textViewer.scrollLeft = this._scrollLeft; 70 this._textViewer.show(parentElement); 73 71 this._textViewer.resize(); 74 72 } … … 77 75 hide: function() 78 76 { 77 delete this._parentElement; 78 79 79 if (this._textViewer) { 80 80 this._scrollTop = this._textViewer.scrollTop; 81 81 this._scrollLeft = this._textViewer.scrollLeft; 82 82 this._textViewer.freeCachedElements(); 83 } 84 85 WebInspector.View.prototype.hide.call(this); 83 this._textViewer.hide(); 84 } 86 85 87 86 this._hidePopup(); 88 87 this._clearLineHighlight(); 88 }, 89 90 detach: function() 91 { 92 delete this._parentElement; 93 94 if (this._textViewer) 95 this._textViewer.detach(); 96 }, 97 98 get element() 99 { 100 return this._textViewer.element; 89 101 }, 90 102 … … 212 224 }, 213 225 214 _startEditing: function() 226 isContentEditable: function() 227 { 228 return this._delegate.canEditScriptSource(); 229 }, 230 231 startEditing: function() 215 232 { 216 233 if (!this._viewerState) { … … 223 240 }, 224 241 225 _endEditing: function(oldRange, newRange)242 endEditing: function(oldRange, newRange) 226 243 { 227 244 // Adjust execution line number. … … 267 284 this._textModel.setText(null, content); 268 285 269 this._textViewer = new WebInspector.TextViewer(this._textModel, WebInspector.platform, this._url); 270 this._textViewer.startEditingListener = this._startEditing.bind(this); 271 this._textViewer.endEditingListener = this._endEditing.bind(this); 286 this._textViewer = new WebInspector.TextViewer(this._textModel, WebInspector.platform, this._url, this); 272 287 273 288 var element = this._textViewer.element; 289 element.addStyleClass("script-view"); 274 290 if (this._delegate.debuggingSupported()) { 275 291 element.addEventListener("contextmenu", this._contextMenu.bind(this), true); … … 278 294 element.addEventListener("scroll", this._scroll.bind(this), true); 279 295 } 280 281 if (this._delegate.canEditScriptSource()) 282 element.addEventListener("dblclick", this._doubleClick.bind(this), true); 283 284 this.element.appendChild(element); 296 element.addEventListener("keydown", this._handleKeyDown.bind(this), false); 285 297 286 298 this._textViewer.beginUpdates(); … … 305 317 306 318 this._textViewer.endUpdates(); 319 320 if (this._parentElement) 321 this.show(this._parentElement) 307 322 }, 308 323 … … 892 907 this._textViewer.readOnly = false; 893 908 this._delegate.setScriptSourceIsBeingEdited(true); 894 WebInspector.log(error , WebInspector.ConsoleMessage.MessageLevel.Error);909 WebInspector.log(error.data[0], WebInspector.ConsoleMessage.MessageLevel.Error); 895 910 WebInspector.showConsole(); 896 911 } … … 909 924 this._delegate.setScriptSourceIsBeingEdited(false); 910 925 return true; 911 },912 913 _doubleClick: function(event)914 {915 if (!this._delegate.canEditScriptSource())916 return;917 918 var lineRow = event.target.enclosingNodeOrSelfWithClass("webkit-line-content");919 if (!lineRow)920 return; // Do not trigger editing from line numbers.921 922 if (this._textViewer.readOnly) {923 this._textViewer.readOnly = false;924 window.getSelection().collapseToStart();925 }926 926 } 927 927 } 928 928 929 WebInspector.SourceFrame.prototype.__proto__ = WebInspector. View.prototype;929 WebInspector.SourceFrame.prototype.__proto__ = WebInspector.TextViewerDelegate.prototype; 930 930 931 931 -
trunk/Source/WebCore/inspector/front-end/TextViewer.js
r83285 r83288 30 30 */ 31 31 32 WebInspector.TextViewer = function(textModel, platform, url )32 WebInspector.TextViewer = function(textModel, platform, url, delegate) 33 33 { 34 WebInspector.View.call(this); 35 34 36 this._textModel = textModel; 35 37 this._textModel.changeListener = this._textChanged.bind(this); 36 37 this.element = document.createElement("div"); 38 this._delegate = delegate; 39 38 40 this.element.className = "text-editor monospace"; 39 41 … … 50 52 this._gutterPanel.element.addEventListener("mousewheel", function(e) { 51 53 this._mainPanel.element.dispatchEvent(e); 52 }.bind(this), false) 54 }.bind(this), false); 55 56 this.element.addEventListener("dblclick", this._doubleClick.bind(this), true); 53 57 } 54 58 … … 67 71 { 68 72 return this._mainPanel.readOnly; 69 },70 71 set startEditingListener(startEditingListener)72 {73 this._startEditingListener = startEditingListener;74 },75 76 set endEditingListener(endEditingListener)77 {78 this._endEditingListener = endEditingListener;79 73 }, 80 74 … … 176 170 this._internalTextChangeMode = true; 177 171 178 if (this._startEditingListener) 179 this._startEditingListener(); 172 this._delegate.startEditing(); 180 173 }, 181 174 … … 188 181 this._updatePanelOffsets(); 189 182 190 if (this._endEditingListener) 191 this._endEditingListener(oldRange, newRange); 183 this._delegate.endEditing(oldRange, newRange); 192 184 }, 193 185 … … 231 223 gutterChunk.element.style.removeProperty("height"); 232 224 } 225 }, 226 227 _doubleClick: function(event) 228 { 229 if (!this._delegate.isContentEditable()) 230 return; 231 232 var lineRow = event.target.enclosingNodeOrSelfWithClass("webkit-line-content"); 233 if (!lineRow) 234 return; // Do not trigger editing from line numbers. 235 236 if (this.readOnly) { 237 this.readOnly = false; 238 window.getSelection().collapseToStart(); 239 } 233 240 } 234 241 } 242 243 WebInspector.TextViewer.prototype.__proto__ = WebInspector.View.prototype; 244 245 WebInspector.TextViewerDelegate = function() 246 { 247 } 248 249 WebInspector.TextViewerDelegate.prototype = { 250 isContentEditable: function() 251 { 252 // Should be implemented by subclasses. 253 }, 254 255 startEditing: function() 256 { 257 // Should be implemented by subclasses. 258 }, 259 260 endEditing: function(oldRange, newRange) 261 { 262 // Should be implemented by subclasses. 263 } 264 } 265 266 WebInspector.TextViewerDelegate.prototype.__proto__ = WebInspector.Object.prototype; 235 267 236 268 WebInspector.TextEditorChunkedPanel = function(textModel) … … 1270 1302 delete lineRow.lineNumber; 1271 1303 } 1272 1304 1273 1305 if (this._dirtyLines) { 1274 1306 this._dirtyLines.start = Math.min(this._dirtyLines.start, startLine); -
trunk/Source/WebCore/inspector/front-end/inspector.html
r83176 r83288 101 101 <script type="text/javascript" src="NetworkPanel.js"></script> 102 102 <script type="text/javascript" src="InjectedFakeWorker.js"></script> 103 <script type="text/javascript" src="TextViewer.js"></script> 103 104 <script type="text/javascript" src="SourceFrame.js"></script> 104 105 <script type="text/javascript" src="ResourceView.js"></script> … … 127 128 <script type="text/javascript" src="TextEditorModel.js"></script> 128 129 <script type="text/javascript" src="TextEditorHighlighter.js"></script> 129 <script type="text/javascript" src="TextViewer.js"></script>130 130 <script type="text/javascript" src="SourceTokenizer.js"></script> 131 131 <script type="text/javascript" src="SourceCSSTokenizer.js"></script>
Note: See TracChangeset
for help on using the changeset viewer.