Diff
Modified: trunk/LayoutTests/ChangeLog (94841 => 94842)
--- trunk/LayoutTests/ChangeLog 2011-09-09 09:13:19 UTC (rev 94841)
+++ trunk/LayoutTests/ChangeLog 2011-09-09 10:16:14 UTC (rev 94842)
@@ -1,3 +1,12 @@
+2011-09-08 Alexander Pavlov <apav...@chromium.org>
+
+ Web Inspector: live edit both for JS and CSS is not discoverable.
+ https://bugs.webkit.org/show_bug.cgi?id=65962
+
+ Reviewed by Yury Semikhatsky.
+
+ * inspector/debugger/scripts-panel.html:
+
2011-09-09 Shinya Kawanaka <shin...@google.com>
Crashes in WebCore::AppendNodeCommand::create().
Modified: trunk/LayoutTests/inspector/debugger/scripts-panel.html (94841 => 94842)
--- trunk/LayoutTests/inspector/debugger/scripts-panel.html 2011-09-09 09:13:19 UTC (rev 94841)
+++ trunk/LayoutTests/inspector/debugger/scripts-panel.html 2011-09-09 10:16:14 UTC (rev 94842)
@@ -11,6 +11,7 @@
var model = new WebInspector.Object();
model.breakpointsForUISourceCode = function() { return []; };
model.messagesForUISourceCode = function() { return []; };
+ model.canEditScriptSource = function() { return true; };
return model;
}
function addUISouceCode(model, url)
Modified: trunk/Source/WebCore/ChangeLog (94841 => 94842)
--- trunk/Source/WebCore/ChangeLog 2011-09-09 09:13:19 UTC (rev 94841)
+++ trunk/Source/WebCore/ChangeLog 2011-09-09 10:16:14 UTC (rev 94842)
@@ -1,3 +1,36 @@
+2011-09-08 Alexander Pavlov <apav...@chromium.org>
+
+ Web Inspector: live edit both for JS and CSS is not discoverable.
+ https://bugs.webkit.org/show_bug.cgi?id=65962
+
+ Add the "Edit" button to SourceFrame, so that resources/scripts can be edited both in the
+ Resources and the Scripts panels. The button is grayed out if the resource/script is not editable.
+
+ Reviewed by Yury Semikhatsky.
+
+ * inspector/front-end/Images/statusbarButtonGlyphs.png:
+ * inspector/front-end/ResourceView.js:
+ (WebInspector.EditableResourceSourceFrame.prototype.canEditSource):
+ * inspector/front-end/ScriptsPanel.js:
+ (WebInspector.ScriptsPanel.prototype.get statusBarItems):
+ (WebInspector.ScriptsPanel.prototype.set visibleView):
+ * inspector/front-end/SourceFrame.js:
+ (WebInspector.SourceFrame):
+ (WebInspector.SourceFrame.prototype.get statusBarItems):
+ (WebInspector.SourceFrame.prototype._initializeTextViewer):
+ (WebInspector.SourceFrame.prototype._editButtonClicked):
+ (WebInspector.SourceFrame.prototype.canEditSource):
+ (WebInspector.SourceFrame.prototype.startEditing):
+ (WebInspector.SourceFrame.prototype.commitEditing):
+ (WebInspector.SourceFrame.prototype._setReadOnly):
+ (WebInspector.TextViewerDelegateForSourceFrame.prototype.doubleClick):
+ * inspector/front-end/TextViewer.js:
+ (WebInspector.TextEditorMainPanel.prototype.set readOnly):
+ (WebInspector.TextEditorMainPanel.prototype._updateSelectionOnStartEditing):
+ * inspector/front-end/inspector.css:
+ (button.edit-source-status-bar-item .glyph):
+ (button.edit-source-status-bar-item.toggled-on .glyph):
+
2011-09-09 Shinya Kawanaka <shin...@google.com>
Crashes in WebCore::AppendNodeCommand::create().
Modified: trunk/Source/WebCore/inspector/front-end/Images/statusbarButtonGlyphs.png
(Binary files differ)
Modified: trunk/Source/WebCore/inspector/front-end/ResourceView.js (94841 => 94842)
--- trunk/Source/WebCore/inspector/front-end/ResourceView.js 2011-09-09 09:13:19 UTC (rev 94841)
+++ trunk/Source/WebCore/inspector/front-end/ResourceView.js 2011-09-09 10:16:14 UTC (rev 94842)
@@ -119,16 +119,9 @@
}
WebInspector.EditableResourceSourceFrame.prototype = {
- doubleClick: function(lineNumber)
+ canEditSource: function()
{
- if (!this.resource.isEditable())
- return;
-
- if (this._commitEditingInProgress)
- return;
-
- this._textViewer.readOnly = false;
- WebInspector.markBeingEdited(this._textViewer.element, true);
+ return this.resource.isEditable() && !this._commitEditingInProgress;
},
editContent: function(newText, callback)
Modified: trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js (94841 => 94842)
--- trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js 2011-09-09 09:13:19 UTC (rev 94841)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js 2011-09-09 10:16:14 UTC (rev 94842)
@@ -151,6 +151,9 @@
this._toggleFormatSourceButton.toggled = false;
this._toggleFormatSourceButton.addEventListener("click", this._toggleFormatSource.bind(this), false);
+ this._scriptViewStatusBarItemsContainer = document.createElement("div");
+ this._scriptViewStatusBarItemsContainer.style.display = "inline-block";
+
this._debuggerEnabled = Preferences.debuggerAlwaysEnabled;
this.reset();
@@ -196,7 +199,7 @@
get statusBarItems()
{
- return [this.enableToggleButton.element, this._pauseOnExceptionButton.element, this._toggleFormatSourceButton.element];
+ return [this.enableToggleButton.element, this._pauseOnExceptionButton.element, this._toggleFormatSourceButton.element, this._scriptViewStatusBarItemsContainer];
},
get defaultFocusedElement()
@@ -590,8 +593,13 @@
this._visibleView = x;
- if (x)
+ if (x) {
x.show(this.viewsContainerElement);
+ this._scriptViewStatusBarItemsContainer.removeChildren();
+ var statusBarItems = x.statusBarItems || [];
+ for (var i = 0; i < statusBarItems.length; ++i)
+ this._scriptViewStatusBarItemsContainer.appendChild(statusBarItems[i]);
+ }
},
canShowAnchorLocation: function(anchor)
Modified: trunk/Source/WebCore/inspector/front-end/SourceFrame.js (94841 => 94842)
--- trunk/Source/WebCore/inspector/front-end/SourceFrame.js 2011-09-09 09:13:19 UTC (rev 94841)
+++ trunk/Source/WebCore/inspector/front-end/SourceFrame.js 2011-09-09 10:16:14 UTC (rev 94842)
@@ -43,6 +43,9 @@
this.addChildView(this._textViewer);
this.element.appendChild(this._textViewer.element);
+ this._editButton = new WebInspector.StatusBarButton(WebInspector.UIString("Edit"), "edit-source-status-bar-item");
+ this._editButton.addEventListener("click", this._editButtonClicked.bind(this), this);
+
this._currentSearchResultIndex = -1;
this._searchResults = [];
@@ -96,6 +99,11 @@
this._clearLineHighlight();
},
+ get statusBarItems()
+ {
+ return [this._editButton.element];
+ },
+
get loaded()
{
return !!this._content;
@@ -307,6 +315,9 @@
this.dispatchEventToListeners(WebInspector.SourceFrame.Events.Loaded);
this._textViewer.endUpdates();
+
+ if (!this.canEditSource())
+ this._editButton.disabled = true;
},
_setTextViewerDecorations: function()
@@ -816,15 +827,33 @@
this._textViewer.inheritScrollPositions(sourceFrame._textViewer);
},
- doubleClick: function(lineNumber)
+ _editButtonClicked: function()
{
- if (!this._delegate.canEditScriptSource())
+ if (!this.canEditSource())
return;
+ const shouldStartEditing = !this._editButton.toggled;
+ if (shouldStartEditing)
+ this.startEditing();
+ else
+ this.commitEditing();
+ },
+
+ canEditSource: function()
+ {
+ return this._delegate.canEditScriptSource();
+ },
+
+ startEditing: function(lineNumber)
+ {
+ if (!this.canEditSource())
+ return false;
+
if (this._commitEditingInProgress)
- return;
+ return false;
this._setReadOnly(false);
+ return true;
},
commitEditing: function()
@@ -867,6 +896,7 @@
}
this._commitEditingInProgress = true;
this._textViewer.readOnly = true;
+ this._editButton.toggled = false;
this.editContent(this._textModel.text, didEditContent.bind(this));
},
@@ -887,6 +917,7 @@
this._popoverHelper.hidePopover();
this._textViewer.readOnly = readOnly;
+ this._editButton.toggled = !readOnly;
WebInspector.markBeingEdited(this._textViewer.element, !readOnly);
if (readOnly)
this._delegate.setScriptSourceIsBeingEdited(false);
@@ -904,7 +935,7 @@
WebInspector.TextViewerDelegateForSourceFrame.prototype = {
doubleClick: function(lineNumber)
{
- this._sourceFrame.doubleClick(lineNumber);
+ this._sourceFrame.startEditing(lineNumber);
},
beforeTextChanged: function()
Modified: trunk/Source/WebCore/inspector/front-end/TextViewer.js (94841 => 94842)
--- trunk/Source/WebCore/inspector/front-end/TextViewer.js 2011-09-09 09:13:19 UTC (rev 94841)
+++ trunk/Source/WebCore/inspector/front-end/TextViewer.js 2011-09-09 10:16:14 UTC (rev 94842)
@@ -905,8 +905,10 @@
this._readOnly = readOnly;
if (this._readOnly)
this._container.removeStyleClass("text-editor-editable");
- else
+ else {
this._container.addStyleClass("text-editor-editable");
+ this._updateSelectionOnStartEditing();
+ }
this.endDomUpdates();
},
@@ -915,6 +917,24 @@
return this._readOnly;
},
+ _updateSelectionOnStartEditing: function()
+ {
+ // focust() needs to go first for the case when the last selection was inside the editor and
+ // the "Edit" button was clicked. In this case we bail at the check below, but the
+ // editor does not receive the focus, thus "Esc" does not cancel editing until at least
+ // one change has been made to the editor contents.
+ this._container.focus();
+ var selection = window.getSelection();
+ if (selection.rangeCount && this._container.isAncestor(selection.getRangeAt(0).commonAncestorContainer))
+ return;
+
+ selection.removeAllRanges();
+ var range = document.createRange();
+ range.setStart(this._container, 0);
+ range.setEnd(this._container, 0);
+ selection.addRange(range);
+ },
+
setEditableRange: function(startLine, endLine)
{
this.beginDomUpdates();
Modified: trunk/Source/WebCore/inspector/front-end/inspector.css (94841 => 94842)
--- trunk/Source/WebCore/inspector/front-end/inspector.css 2011-09-09 09:13:19 UTC (rev 94841)
+++ trunk/Source/WebCore/inspector/front-end/inspector.css 2011-09-09 10:16:14 UTC (rev 94842)
@@ -2377,6 +2377,14 @@
-webkit-mask-position: -96px -24px;
}
+button.edit-source-status-bar-item .glyph {
+ -webkit-mask-position: -64px -48px;
+}
+
+button.edit-source-status-bar-item.toggled-on .glyph {
+ background-color: rgb(66, 129, 235);
+}
+
.scripts-pause-on-exceptions-status-bar-item .glyph {
-webkit-mask-position: -256px 0;
}