2011-03-28 Andrey Adaikin <aandrey@google.com>

        Reviewed by Yury Semikhatsky.

        Web Inspector: source frame should show the error to user when live edit is failed
        https://bugs.webkit.org/show_bug.cgi?id=57002

        * inspector/front-end/ScriptsPanel.js:
        (WebInspector.SourceFrameDelegateForScriptsPanel.prototype.editScriptSource):
        * inspector/front-end/SourceFrame.js:
        (WebInspector.SourceFrame.prototype._handleSave.didSaveScriptSource):
        (WebInspector.SourceFrame.prototype._handleSave):
        (WebInspector.SourceFrameDelegate.prototype.editScriptSource):

git-svn-id: svn://svn.chromium.org/blink/trunk@82099 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent eb7ffef4
2011-03-28 Andrey Adaikin <aandrey@google.com>
Reviewed by Yury Semikhatsky.
Web Inspector: source frame should show the error to user when live edit is failed
https://bugs.webkit.org/show_bug.cgi?id=57002
* inspector/front-end/ScriptsPanel.js:
(WebInspector.SourceFrameDelegateForScriptsPanel.prototype.editScriptSource):
* inspector/front-end/SourceFrame.js:
(WebInspector.SourceFrame.prototype._handleSave.didSaveScriptSource):
(WebInspector.SourceFrame.prototype._handleSave):
(WebInspector.SourceFrameDelegate.prototype.editScriptSource):
2011-03-26 Mario Sanchez Prada <msanchez@igalia.com> 2011-03-26 Mario Sanchez Prada <msanchez@igalia.com>
Reviewed by Martin Robinson. Reviewed by Martin Robinson.
...@@ -1058,14 +1058,7 @@ WebInspector.SourceFrameDelegateForScriptsPanel.prototype = { ...@@ -1058,14 +1058,7 @@ WebInspector.SourceFrameDelegateForScriptsPanel.prototype = {
editScriptSource: function(text, callback) editScriptSource: function(text, callback)
{ {
function didEditScriptSource(success, newBodyOrErrorMessage) this._model.editScriptSource(this._sourceFileId, text, callback);
{
if (!success) {
WebInspector.log(newBodyOrErrorMessage, WebInspector.ConsoleMessage.MessageLevel.Warning);
return;
}
}
this._model.editScriptSource(this._sourceFileId, text, didEditScriptSource.bind(this));
}, },
setScriptSourceIsBeingEdited: function(inEditMode) setScriptSourceIsBeingEdited: function(inEditMode)
......
...@@ -795,12 +795,31 @@ WebInspector.SourceFrame.prototype = { ...@@ -795,12 +795,31 @@ WebInspector.SourceFrame.prototype = {
if (this._textViewer.readOnly || !this._delegate.canEditScriptSource()) if (this._textViewer.readOnly || !this._delegate.canEditScriptSource())
return false; return false;
if (this._originalTextModelContent === undefined) {
// No editing was actually done.
this._textViewer.readOnly = true;
this._delegate.setScriptSourceIsBeingEdited(false);
return true;
}
var originalTextModelContent = this._originalTextModelContent;
var newSource = this._textModel.text; var newSource = this._textModel.text;
if (this._originalTextModelContent !== newSource)
this._delegate.editScriptSource(newSource);
delete this._originalTextModelContent; delete this._originalTextModelContent;
this._textViewer.readOnly = true; this._textViewer.readOnly = true;
this._delegate.setScriptSourceIsBeingEdited(false); this._delegate.setScriptSourceIsBeingEdited(false);
function didEditScriptSource(success, newBodyOrErrorMessage)
{
if (!success && this._originalTextModelContent === undefined && this._textModel.text === newSource) {
this._originalTextModelContent = originalTextModelContent;
this._textViewer.readOnly = false;
this._delegate.setScriptSourceIsBeingEdited(true);
WebInspector.log(newBodyOrErrorMessage, WebInspector.ConsoleMessage.MessageLevel.Error);
WebInspector.showConsole();
}
}
this._delegate.editScriptSource(newSource, didEditScriptSource.bind(this));
return true; return true;
}, },
...@@ -881,7 +900,7 @@ WebInspector.SourceFrameDelegate.prototype = { ...@@ -881,7 +900,7 @@ WebInspector.SourceFrameDelegate.prototype = {
return false; return false;
}, },
editScriptSource: function(text) editScriptSource: function(text, callback)
{ {
// Should be implemented by subclasses. // Should be implemented by subclasses.
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment