Changeset 94842 in webkit
- Timestamp:
- Sep 9, 2011 3:16:14 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r94841 r94842 1 2011-09-08 Alexander Pavlov <apavlov@chromium.org> 2 3 Web Inspector: live edit both for JS and CSS is not discoverable. 4 https://bugs.webkit.org/show_bug.cgi?id=65962 5 6 Reviewed by Yury Semikhatsky. 7 8 * inspector/debugger/scripts-panel.html: 9 1 10 2011-09-09 Shinya Kawanaka <shinyak@google.com> 2 11 -
trunk/LayoutTests/inspector/debugger/scripts-panel.html
r94571 r94842 12 12 model.breakpointsForUISourceCode = function() { return []; }; 13 13 model.messagesForUISourceCode = function() { return []; }; 14 model.canEditScriptSource = function() { return true; }; 14 15 return model; 15 16 } -
trunk/Source/WebCore/ChangeLog
r94841 r94842 1 2011-09-08 Alexander Pavlov <apavlov@chromium.org> 2 3 Web Inspector: live edit both for JS and CSS is not discoverable. 4 https://bugs.webkit.org/show_bug.cgi?id=65962 5 6 Add the "Edit" button to SourceFrame, so that resources/scripts can be edited both in the 7 Resources and the Scripts panels. The button is grayed out if the resource/script is not editable. 8 9 Reviewed by Yury Semikhatsky. 10 11 * inspector/front-end/Images/statusbarButtonGlyphs.png: 12 * inspector/front-end/ResourceView.js: 13 (WebInspector.EditableResourceSourceFrame.prototype.canEditSource): 14 * inspector/front-end/ScriptsPanel.js: 15 (WebInspector.ScriptsPanel.prototype.get statusBarItems): 16 (WebInspector.ScriptsPanel.prototype.set visibleView): 17 * inspector/front-end/SourceFrame.js: 18 (WebInspector.SourceFrame): 19 (WebInspector.SourceFrame.prototype.get statusBarItems): 20 (WebInspector.SourceFrame.prototype._initializeTextViewer): 21 (WebInspector.SourceFrame.prototype._editButtonClicked): 22 (WebInspector.SourceFrame.prototype.canEditSource): 23 (WebInspector.SourceFrame.prototype.startEditing): 24 (WebInspector.SourceFrame.prototype.commitEditing): 25 (WebInspector.SourceFrame.prototype._setReadOnly): 26 (WebInspector.TextViewerDelegateForSourceFrame.prototype.doubleClick): 27 * inspector/front-end/TextViewer.js: 28 (WebInspector.TextEditorMainPanel.prototype.set readOnly): 29 (WebInspector.TextEditorMainPanel.prototype._updateSelectionOnStartEditing): 30 * inspector/front-end/inspector.css: 31 (button.edit-source-status-bar-item .glyph): 32 (button.edit-source-status-bar-item.toggled-on .glyph): 33 1 34 2011-09-09 Shinya Kawanaka <shinyak@google.com> 2 35 -
trunk/Source/WebCore/inspector/front-end/ResourceView.js
r94754 r94842 120 120 121 121 WebInspector.EditableResourceSourceFrame.prototype = { 122 doubleClick: function(lineNumber)122 canEditSource: function() 123 123 { 124 if (!this.resource.isEditable()) 125 return; 126 127 if (this._commitEditingInProgress) 128 return; 129 130 this._textViewer.readOnly = false; 131 WebInspector.markBeingEdited(this._textViewer.element, true); 124 return this.resource.isEditable() && !this._commitEditingInProgress; 132 125 }, 133 126 -
trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js
r94760 r94842 152 152 this._toggleFormatSourceButton.addEventListener("click", this._toggleFormatSource.bind(this), false); 153 153 154 this._scriptViewStatusBarItemsContainer = document.createElement("div"); 155 this._scriptViewStatusBarItemsContainer.style.display = "inline-block"; 156 154 157 this._debuggerEnabled = Preferences.debuggerAlwaysEnabled; 155 158 … … 197 200 get statusBarItems() 198 201 { 199 return [this.enableToggleButton.element, this._pauseOnExceptionButton.element, this._toggleFormatSourceButton.element ];202 return [this.enableToggleButton.element, this._pauseOnExceptionButton.element, this._toggleFormatSourceButton.element, this._scriptViewStatusBarItemsContainer]; 200 203 }, 201 204 … … 591 594 this._visibleView = x; 592 595 593 if (x) 596 if (x) { 594 597 x.show(this.viewsContainerElement); 598 this._scriptViewStatusBarItemsContainer.removeChildren(); 599 var statusBarItems = x.statusBarItems || []; 600 for (var i = 0; i < statusBarItems.length; ++i) 601 this._scriptViewStatusBarItemsContainer.appendChild(statusBarItems[i]); 602 } 595 603 }, 596 604 -
trunk/Source/WebCore/inspector/front-end/SourceFrame.js
r94665 r94842 44 44 this.element.appendChild(this._textViewer.element); 45 45 46 this._editButton = new WebInspector.StatusBarButton(WebInspector.UIString("Edit"), "edit-source-status-bar-item"); 47 this._editButton.addEventListener("click", this._editButtonClicked.bind(this), this); 48 46 49 this._currentSearchResultIndex = -1; 47 50 this._searchResults = []; … … 95 98 this._popoverHelper.hidePopover(); 96 99 this._clearLineHighlight(); 100 }, 101 102 get statusBarItems() 103 { 104 return [this._editButton.element]; 97 105 }, 98 106 … … 308 316 309 317 this._textViewer.endUpdates(); 318 319 if (!this.canEditSource()) 320 this._editButton.disabled = true; 310 321 }, 311 322 … … 817 828 }, 818 829 819 doubleClick: function(lineNumber) 820 { 821 if (!this._delegate.canEditScriptSource()) 822 return; 830 _editButtonClicked: function() 831 { 832 if (!this.canEditSource()) 833 return; 834 835 const shouldStartEditing = !this._editButton.toggled; 836 if (shouldStartEditing) 837 this.startEditing(); 838 else 839 this.commitEditing(); 840 }, 841 842 canEditSource: function() 843 { 844 return this._delegate.canEditScriptSource(); 845 }, 846 847 startEditing: function(lineNumber) 848 { 849 if (!this.canEditSource()) 850 return false; 823 851 824 852 if (this._commitEditingInProgress) 825 return ;853 return false; 826 854 827 855 this._setReadOnly(false); 856 return true; 828 857 }, 829 858 … … 868 897 this._commitEditingInProgress = true; 869 898 this._textViewer.readOnly = true; 899 this._editButton.toggled = false; 870 900 this.editContent(this._textModel.text, didEditContent.bind(this)); 871 901 }, … … 888 918 889 919 this._textViewer.readOnly = readOnly; 920 this._editButton.toggled = !readOnly; 890 921 WebInspector.markBeingEdited(this._textViewer.element, !readOnly); 891 922 if (readOnly) … … 905 936 doubleClick: function(lineNumber) 906 937 { 907 this._sourceFrame. doubleClick(lineNumber);938 this._sourceFrame.startEditing(lineNumber); 908 939 }, 909 940 -
trunk/Source/WebCore/inspector/front-end/TextViewer.js
r94749 r94842 906 906 if (this._readOnly) 907 907 this._container.removeStyleClass("text-editor-editable"); 908 else 908 else { 909 909 this._container.addStyleClass("text-editor-editable"); 910 this._updateSelectionOnStartEditing(); 911 } 910 912 this.endDomUpdates(); 911 913 }, … … 914 916 { 915 917 return this._readOnly; 918 }, 919 920 _updateSelectionOnStartEditing: function() 921 { 922 // focust() needs to go first for the case when the last selection was inside the editor and 923 // the "Edit" button was clicked. In this case we bail at the check below, but the 924 // editor does not receive the focus, thus "Esc" does not cancel editing until at least 925 // one change has been made to the editor contents. 926 this._container.focus(); 927 var selection = window.getSelection(); 928 if (selection.rangeCount && this._container.isAncestor(selection.getRangeAt(0).commonAncestorContainer)) 929 return; 930 931 selection.removeAllRanges(); 932 var range = document.createRange(); 933 range.setStart(this._container, 0); 934 range.setEnd(this._container, 0); 935 selection.addRange(range); 916 936 }, 917 937 -
trunk/Source/WebCore/inspector/front-end/inspector.css
r94754 r94842 2378 2378 } 2379 2379 2380 button.edit-source-status-bar-item .glyph { 2381 -webkit-mask-position: -64px -48px; 2382 } 2383 2384 button.edit-source-status-bar-item.toggled-on .glyph { 2385 background-color: rgb(66, 129, 235); 2386 } 2387 2380 2388 .scripts-pause-on-exceptions-status-bar-item .glyph { 2381 2389 -webkit-mask-position: -256px 0;
Note: See TracChangeset
for help on using the changeset viewer.