Changeset 80728 in webkit
- Timestamp:
- Mar 10, 2011 8:46:02 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r80723 r80728 1 2011-03-10 Andrey Adaikin <aandrey@google.com> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: [Text editor] Substitute live-edit mode activation by double-click 6 https://bugs.webkit.org/show_bug.cgi?id=56084 7 8 Also fixed a regression: console was not opening/closing on ESC key press because tabIndex="0" attribute was preserved for a readOnly viewer. 9 10 * inspector/front-end/SourceFrame.js: 11 (WebInspector.SourceFrame): 12 (WebInspector.SourceFrame.prototype._startEditing): 13 (WebInspector.SourceFrame.prototype._registerShortcuts): 14 (WebInspector.SourceFrame.prototype._handleKeyDown): 15 (WebInspector.SourceFrame.prototype._handleSave): 16 (WebInspector.SourceFrame.prototype._handleRevertEditing): 17 (WebInspector.SourceFrame.prototype._doubleClick): 18 * inspector/front-end/TextEditorModel.js: 19 (WebInspector.TextEditorModel.prototype.get text): 20 * inspector/front-end/TextViewer.js: 21 (WebInspector.TextViewer.prototype.get readOnly): 22 (WebInspector.TextEditorMainPanel): 23 (WebInspector.TextEditorMainPanel.prototype.set readOnly): 24 (WebInspector.TextEditorMainPanel.prototype.get readOnly): 25 1 26 2011-03-10 Greg Simon <gregsimon@chromium.org> 2 27 -
trunk/Source/WebCore/inspector/front-end/SourceFrame.js
r80709 r80728 47 47 this._rowMessages = {}; 48 48 this._messageBubbles = {}; 49 50 if (Preferences.sourceEditorEnabled) { 51 this._registerShortcuts(); 52 this.element.addEventListener("keydown", this._handleKeyDown.bind(this), false); 53 } 49 54 } 50 55 … … 174 179 _startEditing: function() 175 180 { 181 if (this._originalTextModelContent === undefined) 182 this._originalTextModelContent = this._textModel.text; 183 176 184 WebInspector.searchController.cancelSearch(); 177 185 this.clearMessages(); … … 764 772 }, 765 773 774 _registerShortcuts: function() 775 { 776 this._shortcuts = {}; 777 this._shortcuts[WebInspector.KeyboardShortcut.makeKey("s", WebInspector.KeyboardShortcut.Modifiers.CtrlOrMeta)] = this._handleSave.bind(this); 778 this._shortcuts[WebInspector.KeyboardShortcut.makeKey(WebInspector.KeyboardShortcut.Keys.Esc.code)] = this._handleRevertEditing.bind(this); 779 }, 780 781 _handleKeyDown: function(e) 782 { 783 var shortcutKey = WebInspector.KeyboardShortcut.makeKeyFromEvent(e); 784 var handler = this._shortcuts[shortcutKey]; 785 if (handler) { 786 handler.call(this); 787 e.preventDefault(); 788 e.stopPropagation(); 789 } 790 }, 791 792 _handleSave: function() 793 { 794 if (!this._delegate.canEditScriptSource()) 795 return; 796 797 var newSource = this._textModel.text; 798 if (this._originalTextModelContent !== newSource) 799 this._delegate.editScriptSource(newSource); 800 delete this._originalTextModelContent; 801 this._textViewer.readOnly = true; 802 }, 803 804 _handleRevertEditing: function() 805 { 806 if (this._originalTextModelContent !== undefined) 807 this._textModel.setText(null, this._originalTextModelContent); 808 delete this._originalTextModelContent; 809 this._textViewer.readOnly = true; 810 }, 811 766 812 _doubleClick: function(event) 767 813 { … … 772 818 if (!lineRow) 773 819 return; // Do not trigger editing from line numbers. 820 821 if (Preferences.sourceEditorEnabled) { 822 if (this._textViewer.readOnly) { 823 this._textViewer.readOnly = false; 824 window.getSelection().collapseToStart(); 825 } 826 return; 827 } 774 828 775 829 this._textViewer.editLine(lineRow, this._didEditLine.bind(this, lineRow.lineNumber)); -
trunk/Source/WebCore/inspector/front-end/TextEditorModel.js
r57909 r80728 73 73 }, 74 74 75 get text() 76 { 77 return this._lines.join("\n"); 78 }, 79 75 80 line: function(lineNumber) 76 81 { -
trunk/Source/WebCore/inspector/front-end/TextViewer.js
r80704 r80728 59 59 }, 60 60 61 get readOnly() 62 { 63 return this._mainPanel.readOnly; 64 }, 65 61 66 set startEditingListener(startEditingListener) 62 67 { … … 681 686 this.element = document.createElement("div"); 682 687 this.element.className = "text-editor-contents"; 683 this.element.tabIndex = 0;684 688 685 689 this._container = document.createElement("div"); 686 690 this._container.className = "inner-container"; 687 this._container.tabIndex = 0;688 691 this.element.appendChild(this._container); 689 692 … … 721 724 this.beginDomUpdates(); 722 725 this._readOnly = readOnly; 723 if (this._readOnly) 726 if (this._readOnly) { 727 this.element.removeAttribute("tabIndex"); 728 this._container.removeAttribute("tabIndex"); 724 729 this._container.removeStyleClass("text-editor-editable"); 725 else 730 // Remove the focus from the editable area. 731 this._container.blur(); 732 this.element.blur(); 733 } else { 734 this.element.setAttribute("tabIndex", "0"); 735 this._container.setAttribute("tabIndex", "0"); 726 736 this._container.addStyleClass("text-editor-editable"); 737 } 727 738 this.endDomUpdates(); 739 }, 740 741 get readOnly() 742 { 743 return this._readOnly; 728 744 }, 729 745
Note: See TracChangeset
for help on using the changeset viewer.