Diff
Modified: trunk/Source/WebCore/ChangeLog (117780 => 117781)
--- trunk/Source/WebCore/ChangeLog 2012-05-21 14:49:25 UTC (rev 117780)
+++ trunk/Source/WebCore/ChangeLog 2012-05-21 15:09:56 UTC (rev 117781)
@@ -1,3 +1,41 @@
+2012-05-21 Vsevolod Vlasov <[email protected]>
+
+ Web Inspector: Move working copy support to UISourceCode and use it for both styles and scripts.
+ https://bugs.webkit.org/show_bug.cgi?id=87021
+
+ Reviewed by Pavel Feldman.
+
+ UISourceCode now listens for RevisionAdded event.
+ Virtual methods workingCopyChanged and workingCopyCommitted added to UISourceCode and implemented in descendants.
+ DebuggerResourceBinding does not call contentChanged on UISourceCode explicitly anymore.
+
+ * inspector/front-end/DebuggerResourceBinding.js:
+ (WebInspector.DebuggerResourceBinding.setScriptSource.didEditScriptSource):
+ (WebInspector.DebuggerResourceBinding.setScriptSource):
+ * inspector/front-end/_javascript_Source.js:
+ (WebInspector._javascript_Source.prototype.workingCopyCommitted):
+ * inspector/front-end/_javascript_SourceFrame.js:
+ (WebInspector._javascript_SourceFrame.prototype.commitEditing):
+ * inspector/front-end/ScriptSnippetModel.js:
+ (WebInspector.SnippetJavaScriptSource.prototype.workingCopyCommitted):
+ * inspector/front-end/StylesPanel.js:
+ (WebInspector.StyleSource.prototype.workingCopyCommitted):
+ (WebInspector.StyleSource.prototype.workingCopyChanged):
+ (WebInspector.StyleSourceFrame):
+ (WebInspector.StyleSourceFrame.prototype.commitEditing):
+ (WebInspector.StyleSourceFrame.prototype.afterTextChanged):
+ (WebInspector.StyleSourceFrame.prototype._didEditContent):
+ (WebInspector.StyleSourceFrame.prototype._onContentChanged):
+ * inspector/front-end/UISourceCode.js:
+ (WebInspector.UISourceCode):
+ (WebInspector.UISourceCode.prototype._revisionAdded):
+ (WebInspector.UISourceCode.prototype.contentChanged):
+ (WebInspector.UISourceCode.prototype.workingCopy):
+ (WebInspector.UISourceCode.prototype.setWorkingCopy):
+ (WebInspector.UISourceCode.prototype.workingCopyChanged):
+ (WebInspector.UISourceCode.prototype.commitWorkingCopy):
+ (WebInspector.UISourceCode.prototype.workingCopyCommitted):
+
2012-05-21 Andrey Kosyakov <[email protected]>
Web Inspector: [refactoring] promote fill/border colors used by timeline's frame overview to TimelineCategory
Modified: trunk/Source/WebCore/inspector/front-end/DebuggerResourceBinding.js (117780 => 117781)
--- trunk/Source/WebCore/inspector/front-end/DebuggerResourceBinding.js 2012-05-21 14:49:25 UTC (rev 117780)
+++ trunk/Source/WebCore/inspector/front-end/DebuggerResourceBinding.js 2012-05-21 15:09:56 UTC (rev 117781)
@@ -64,7 +64,6 @@
if (resource)
resource.addRevision(newSource);
- uiSourceCode.contentChanged(newSource);
callback(null);
}
WebInspector.debuggerModel.setScriptSource(script.scriptId, newSource, didEditScriptSource.bind(this));
Modified: trunk/Source/WebCore/inspector/front-end/_javascript_Source.js (117780 => 117781)
--- trunk/Source/WebCore/inspector/front-end/_javascript_Source.js 2012-05-21 14:49:25 UTC (rev 117780)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_Source.js 2012-05-21 15:09:56 UTC (rev 117781)
@@ -177,7 +177,10 @@
return this._isEditable && WebInspector.debuggerModel.canSetScriptSource();
},
- commitWorkingCopy: function(callback)
+ /**
+ * @param {function(?string)} callback
+ */
+ workingCopyCommitted: function(callback)
{
WebInspector.DebuggerResourceBinding.setScriptSource(this, this.workingCopy(), callback);
}
Modified: trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js (117780 => 117781)
--- trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js 2012-05-21 14:49:25 UTC (rev 117780)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js 2012-05-21 15:09:56 UTC (rev 117781)
@@ -93,8 +93,6 @@
commitEditing: function(text)
{
this._editingContent = true;
- if (!this._uiSourceCode.isDirty())
- return;
this._uiSourceCode.commitWorkingCopy(this._didEditContent.bind(this));
},
Modified: trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js (117780 => 117781)
--- trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js 2012-05-21 14:49:25 UTC (rev 117780)
+++ trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js 2012-05-21 15:09:56 UTC (rev 117781)
@@ -316,10 +316,13 @@
return true;
},
- commitWorkingCopy: function(callback)
- {
+ /**
+ * @param {function(?string)} callback
+ */
+ workingCopyCommitted: function(callback)
+ {
this._scriptSnippetModel.setScriptSnippetContent(this, this.workingCopy());
- callback();
+ callback(null);
},
/**
Modified: trunk/Source/WebCore/inspector/front-end/StylesPanel.js (117780 => 117781)
--- trunk/Source/WebCore/inspector/front-end/StylesPanel.js 2012-05-21 14:49:25 UTC (rev 117780)
+++ trunk/Source/WebCore/inspector/front-end/StylesPanel.js 2012-05-21 15:09:56 UTC (rev 117781)
@@ -98,6 +98,23 @@
}
WebInspector.StyleSource.prototype = {
+ /**
+ * @param {function(?string)} callback
+ */
+ workingCopyCommitted: function(callback)
+ {
+ this._resource.setContent(this.workingCopy(), true, callback);
+ },
+
+ workingCopyChanged: function()
+ {
+ function commitIncrementalEdit()
+ {
+ this._resource.setContent(this.workingCopy(), false, function() {});
+ }
+ const updateTimeout = 200;
+ this._incrementalUpdateTimer = setTimeout(commitIncrementalEdit.bind(this), updateTimeout);
+ }
}
WebInspector.StyleSource.prototype.__proto__ = WebInspector.UISourceCode.prototype;
@@ -111,7 +128,7 @@
{
this._styleSource = styleSource;
WebInspector.SourceFrame.call(this, this._styleSource);
- this._styleSource.resource().addEventListener(WebInspector.Resource.Events.RevisionAdded, this._contentChanged, this);
+ this._styleSource.addEventListener(WebInspector.UISourceCode.Events.ContentChanged, this._onContentChanged, this);
}
WebInspector.StyleSourceFrame.prototype = {
@@ -128,19 +145,20 @@
*/
commitEditing: function(text)
{
- this._styleSource.resource().setContent(text, true, function() {});
+ this._styleSource.commitWorkingCopy(this._didEditContent.bind(this));
},
afterTextChanged: function(oldRange, newRange)
{
- function commitIncrementalEdit()
- {
- var text = this._textModel.text;
- this._styleSource.setWorkingCopy(text);
- this._styleSource.resource().setContent(text, false, function() {});
+ this._styleSource.setWorkingCopy(this.textModel.text);
+ },
+
+ _didEditContent: function(error)
+ {
+ if (error) {
+ WebInspector.log(error, WebInspector.ConsoleMessage.MessageLevel.Error, true);
+ return;
}
- const updateTimeout = 200;
- this._incrementalUpdateTimer = setTimeout(commitIncrementalEdit.bind(this), updateTimeout);
},
_clearIncrementalUpdateTimer: function()
@@ -150,9 +168,11 @@
delete this._incrementalUpdateTimer;
},
- _contentChanged: function(event)
+ /**
+ * @param {WebInspector.Event} event
+ */
+ _onContentChanged: function(event)
{
- this._styleSource.contentChanged(this._styleSource.resource().content || "");
this.setContent(this._styleSource.resource().content, false, "text/stylesheet");
},
Modified: trunk/Source/WebCore/inspector/front-end/UISourceCode.js (117780 => 117781)
--- trunk/Source/WebCore/inspector/front-end/UISourceCode.js 2012-05-21 14:49:25 UTC (rev 117780)
+++ trunk/Source/WebCore/inspector/front-end/UISourceCode.js 2012-05-21 15:09:56 UTC (rev 117781)
@@ -55,6 +55,9 @@
* @type {Array.<WebInspector.PresentationConsoleMessage>}
*/
this._consoleMessages = [];
+
+ if (this.resource())
+ this.resource().addEventListener(WebInspector.Resource.Events.RevisionAdded, this._revisionAdded, this);
}
WebInspector.UISourceCode.Events = {
@@ -131,13 +134,20 @@
this._contentProvider.requestContent(this.fireContentAvailable.bind(this));
},
+ _revisionAdded: function(event)
+ {
+ this.contentChanged(this.resource().content || "");
+ },
+
/**
* @param {string} newContent
*/
contentChanged: function(newContent)
{
- console.assert(this._contentLoaded);
- var oldContent = this._content;
+ if (this._committingWorkingCopy)
+ return;
+
+ var oldContent = this._contentLoaded ? this._content : undefined;
this._content = newContent;
delete this._workingCopy;
this.dispatchEventToListeners(WebInspector.UISourceCode.Events.ContentChanged, {oldContent: oldContent, content: newContent});
@@ -157,7 +167,9 @@
workingCopy: function()
{
console.assert(this._contentLoaded);
- return this._workingCopy;
+ if (this.isDirty())
+ return this._workingCopy;
+ return this._content;
},
/**
@@ -171,10 +183,50 @@
delete this._workingCopy;
else
this._workingCopy = newWorkingCopy;
+ this.workingCopyChanged();
this.dispatchEventToListeners(WebInspector.UISourceCode.Events.WorkingCopyChanged, {oldWorkingCopy: oldWorkingCopy, workingCopy: newWorkingCopy});
},
+ workingCopyChanged: function()
+ {
+ // Overridden.
+ },
+
/**
+ * @param {function(?string)} callback
+ */
+ commitWorkingCopy: function(callback)
+ {
+ /**
+ * @param {?string} error
+ */
+ function innerCallback(error)
+ {
+ delete this._committingWorkingCopy;
+ if (!error)
+ this.contentChanged(newContent);
+ callback(error);
+ }
+
+ if (!this.isDirty()) {
+ callback(null);
+ return;
+ }
+
+ var newContent = this._workingCopy;
+ this._committingWorkingCopy = true;
+ this.workingCopyCommitted(innerCallback.bind(this));
+ },
+
+ /**
+ * @param {function(?string)} callback
+ */
+ workingCopyCommitted: function(callback)
+ {
+ // Overridden.
+ },
+
+ /**
* @return {boolean}
*/
isDirty: function()