Diff
Modified: trunk/Source/WebCore/ChangeLog (131168 => 131169)
--- trunk/Source/WebCore/ChangeLog 2012-10-12 11:14:43 UTC (rev 131168)
+++ trunk/Source/WebCore/ChangeLog 2012-10-12 11:19:41 UTC (rev 131169)
@@ -1,3 +1,54 @@
+2012-10-10 Vsevolod Vlasov <[email protected]>
+
+ Web Inspector: Refactor UISourceCode, make it possible to distinguish working copy changes/commits from formatting.
+ https://bugs.webkit.org/show_bug.cgi?id=98911
+
+ Reviewed by Pavel Feldman.
+
+ ContentChanged was dispatched both when working copy was committed and UISourceCode was formatted before.
+ WorkingCopyChanged event was dispatched when working copy was set.
+ Now there are three explicit events: WorkingCopyChanged, WorkingCopyCommitted, FormattedChanged.
+ No events are dispatched now during revisions restoring.
+ Reverting to revisions is now implemented based on the working copy editing.
+
+ * inspector/front-end/_javascript_SourceFrame.js:
+ (WebInspector._javascript_SourceFrame):
+ (WebInspector._javascript_SourceFrame.prototype._onFormattedChanged):
+ (WebInspector._javascript_SourceFrame.prototype._onWorkingCopyChanged):
+ (WebInspector._javascript_SourceFrame.prototype._onWorkingCopyCommitted):
+ (WebInspector._javascript_SourceFrame.prototype._innerSetContent):
+ (WebInspector._javascript_SourceFrame.prototype.onTextChanged):
+ * inspector/front-end/NavigatorView.js:
+ (WebInspector.NavigatorView.prototype._uiSourceCodeWorkingCopyCommitted):
+ (WebInspector.NavigatorView.prototype._uiSourceCodeFormattedChanged):
+ (WebInspector.NavigatorView.prototype._addUISourceCodeListeners):
+ (WebInspector.NavigatorView.prototype._removeUISourceCodeListeners):
+ * inspector/front-end/TabbedEditorContainer.js:
+ (WebInspector.TabbedEditorContainer.prototype._addUISourceCodeListeners):
+ (WebInspector.TabbedEditorContainer.prototype._removeUISourceCodeListeners):
+ (WebInspector.TabbedEditorContainer.prototype._uiSourceCodeWorkingCopyCommitted):
+ (WebInspector.TabbedEditorContainer.prototype._uiSourceCodeFormattedChanged):
+ * inspector/front-end/UISourceCode.js:
+ (WebInspector.UISourceCode):
+ (WebInspector.UISourceCode.prototype._commitContent):
+ (WebInspector.UISourceCode.prototype.addRevision):
+ (WebInspector.UISourceCode.prototype._restoreRevisionHistory):
+ (WebInspector.UISourceCode.prototype.revertToOriginal):
+ (WebInspector.UISourceCode.prototype.revertAndClearHistory):
+ (WebInspector.UISourceCode.prototype.setWorkingCopy):
+ (WebInspector.UISourceCode.prototype.commitWorkingCopy):
+ (WebInspector.UISourceCode.prototype.setFormatted.didGetContent.formattedChanged):
+ (WebInspector.UISourceCode.prototype.setFormatted.didGetContent):
+ (WebInspector.UISourceCode.prototype.setFormatted):
+ (WebInspector.Revision.prototype.revertToThis):
+ * inspector/front-end/UISourceCodeFrame.js:
+ (WebInspector.UISourceCodeFrame):
+ (WebInspector.UISourceCodeFrame.prototype.onTextChanged):
+ (WebInspector.UISourceCodeFrame.prototype._onFormattedChanged):
+ (WebInspector.UISourceCodeFrame.prototype._onWorkingCopyChanged):
+ (WebInspector.UISourceCodeFrame.prototype._onWorkingCopyCommitted):
+ (WebInspector.UISourceCodeFrame.prototype._innerSetContent):
+
2012-10-12 Balazs Kelemen <[email protected]>
[WK2] Serialization of Resource[Request,Response,Error] should be shared across ports
Modified: trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js (131168 => 131169)
--- trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js 2012-10-12 11:14:43 UTC (rev 131168)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js 2012-10-12 11:19:41 UTC (rev 131169)
@@ -57,7 +57,9 @@
this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.BreakpointAdded, this._breakpointAdded, this);
this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.BreakpointRemoved, this._breakpointRemoved, this);
- this._javaScriptSource.addEventListener(WebInspector.UISourceCode.Events.ContentChanged, this._onContentChanged, this);
+ this._javaScriptSource.addEventListener(WebInspector.UISourceCode.Events.FormattedChanged, this._onFormattedChanged, this);
+ this._javaScriptSource.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._onWorkingCopyChanged, this);
+ this._javaScriptSource.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._onWorkingCopyCommitted, this);
this._javaScriptSource.addEventListener(WebInspector.UISourceCode.Events.ConsoleMessageAdded, this._consoleMessageAdded, this);
this._javaScriptSource.addEventListener(WebInspector.UISourceCode.Events.ConsoleMessageRemoved, this._consoleMessageRemoved, this);
this._javaScriptSource.addEventListener(WebInspector.UISourceCode.Events.ConsoleMessagesCleared, this._consoleMessagesCleared, this);
@@ -101,12 +103,33 @@
/**
* @param {WebInspector.Event} event
*/
- _onContentChanged: function(event)
+ _onFormattedChanged: function(event)
{
- if (this._isCommittingEditing)
- return;
var content = /** @type {string} */ event.data.content;
+ this._innerSetContent(content);
+ },
+ /**
+ * @param {WebInspector.Event} event
+ */
+ _onWorkingCopyChanged: function(event)
+ {
+ this._innerSetContent(this._javaScriptSource.workingCopy());
+ },
+
+ /**
+ * @param {WebInspector.Event} event
+ */
+ _onWorkingCopyCommitted: function(event)
+ {
+ this._innerSetContent(this._javaScriptSource.workingCopy());
+ },
+
+ _innerSetContent: function(content)
+ {
+ if (this._isSettingWorkingCopy || this._isCommittingEditing)
+ return;
+
if (this._javaScriptSource.togglingFormatter())
this.setContent(content, false, this._javaScriptSource.mimeType());
else {
@@ -158,7 +181,9 @@
var wasDiverged = this._scriptFile && this._scriptFile.hasDivergedFromVM();
this._preserveDecorations = true;
+ this._isSettingWorkingCopy = true;
this._javaScriptSource.setWorkingCopy(this._textEditor.text());
+ delete this._isSettingWorkingCopy;
delete this._preserveDecorations;
if (this._supportsEnabledBreakpointsWhileEditing())
Modified: trunk/Source/WebCore/inspector/front-end/NavigatorView.js (131168 => 131169)
--- trunk/Source/WebCore/inspector/front-end/NavigatorView.js 2012-10-12 11:14:43 UTC (rev 131168)
+++ trunk/Source/WebCore/inspector/front-end/NavigatorView.js 2012-10-12 11:19:41 UTC (rev 131169)
@@ -94,9 +94,15 @@
this._updateScriptTitle(uiSourceCode)
},
- _uiSourceCodeContentChanged: function(event)
+ _uiSourceCodeWorkingCopyCommitted: function(event)
{
var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.target;
+ this._updateScriptTitle(uiSourceCode)
+ },
+
+ _uiSourceCodeFormattedChanged: function(event)
+ {
+ var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.target;
this._updateScriptTitle(uiSourceCode);
},
@@ -187,7 +193,8 @@
{
uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.TitleChanged, this._uiSourceCodeTitleChanged, this);
uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._uiSourceCodeWorkingCopyChanged, this);
- uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.ContentChanged, this._uiSourceCodeContentChanged, this);
+ uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._uiSourceCodeWorkingCopyCommitted, this);
+ uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.FormattedChanged, this._uiSourceCodeFormattedChanged, this);
},
/**
@@ -197,7 +204,8 @@
{
uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.TitleChanged, this._uiSourceCodeTitleChanged, this);
uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._uiSourceCodeWorkingCopyChanged, this);
- uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.ContentChanged, this._uiSourceCodeContentChanged, this);
+ uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._uiSourceCodeWorkingCopyCommitted, this);
+ uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.FormattedChanged, this._uiSourceCodeFormattedChanged, this);
},
_showScriptFoldersSettingChanged: function()
Modified: trunk/Source/WebCore/inspector/front-end/TabbedEditorContainer.js (131168 => 131169)
--- trunk/Source/WebCore/inspector/front-end/TabbedEditorContainer.js 2012-10-12 11:14:43 UTC (rev 131168)
+++ trunk/Source/WebCore/inspector/front-end/TabbedEditorContainer.js 2012-10-12 11:19:41 UTC (rev 131169)
@@ -333,7 +333,8 @@
{
uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.TitleChanged, this._uiSourceCodeTitleChanged, this);
uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._uiSourceCodeWorkingCopyChanged, this);
- uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.ContentChanged, this._uiSourceCodeContentChanged, this);
+ uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._uiSourceCodeWorkingCopyCommitted, this);
+ uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.FormattedChanged, this._uiSourceCodeFormattedChanged, this);
},
/**
@@ -343,7 +344,8 @@
{
uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.TitleChanged, this._uiSourceCodeTitleChanged, this);
uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._uiSourceCodeWorkingCopyChanged, this);
- uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.ContentChanged, this._uiSourceCodeContentChanged, this);
+ uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._uiSourceCodeWorkingCopyCommitted, this);
+ uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.FormattedChanged, this._uiSourceCodeFormattedChanged, this);
},
/**
@@ -370,12 +372,18 @@
this._updateFileTitle(uiSourceCode);
},
- _uiSourceCodeContentChanged: function(event)
+ _uiSourceCodeWorkingCopyCommitted: function(event)
{
var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.target;
this._updateFileTitle(uiSourceCode);
},
+ _uiSourceCodeFormattedChanged: function(event)
+ {
+ var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.target;
+ this._updateFileTitle(uiSourceCode);
+ },
+
reset: function()
{
this._tabbedPane.closeAllTabs();
Modified: trunk/Source/WebCore/inspector/front-end/UISourceCode.js (131168 => 131169)
--- trunk/Source/WebCore/inspector/front-end/UISourceCode.js 2012-10-12 11:14:43 UTC (rev 131168)
+++ trunk/Source/WebCore/inspector/front-end/UISourceCode.js 2012-10-12 11:19:41 UTC (rev 131169)
@@ -61,13 +61,15 @@
* @type {Array.<WebInspector.Revision>}
*/
this.history = [];
- this._restoreRevisionHistory();
+ if (this.isEditable())
+ this._restoreRevisionHistory();
this._formatterMapping = new WebInspector.IdentityFormatterSourceMapping();
}
WebInspector.UISourceCode.Events = {
- ContentChanged: "ContentChanged",
+ FormattedChanged: "FormattedChanged",
WorkingCopyChanged: "WorkingCopyChanged",
+ WorkingCopyCommitted: "WorkingCopyCommitted",
TitleChanged: "TitleChanged",
ConsoleMessageAdded: "ConsoleMessageAdded",
ConsoleMessageRemoved: "ConsoleMessageRemoved",
@@ -172,33 +174,32 @@
},
/**
- * @param {string} newContent
+ * @param {string} content
*/
- _setContent: function(newContent)
+ _commitContent: function(content)
{
- this.setWorkingCopy(newContent);
- this.commitWorkingCopy(function() {});
+ this._content = content;
+ this._contentLoaded = true;
+
+ var lastRevision = this.history.length ? this.history[this.history.length - 1] : null;
+ if (!lastRevision || lastRevision._content !== this._content) {
+ var revision = new WebInspector.Revision(this, this._content, new Date());
+ this.history.push(revision);
+ revision._persist();
+ }
+
+ var oldWorkingCopy = this._workingCopy;
+ delete this._workingCopy;
+ this.dispatchEventToListeners(WebInspector.UISourceCode.Events.WorkingCopyCommitted, {oldWorkingCopy: oldWorkingCopy, workingCopy: this.workingCopy()});
+ WebInspector.workspace.dispatchEventToListeners(WebInspector.Workspace.Events.UISourceCodeContentCommitted, { uiSourceCode: this, content: this._content });
},
/**
* @param {string} content
- * @param {Date=} timestamp
- * @param {boolean=} restoringHistory
*/
- addRevision: function(content, timestamp, restoringHistory)
+ addRevision: function(content)
{
- if (this.history.length) {
- var lastRevision = this.history[this.history.length - 1];
- if (lastRevision._content === content)
- return;
- }
- var revision = new WebInspector.Revision(this, content, timestamp || new Date());
- this.history.push(revision);
-
- this.contentChanged(revision.content || "", this.canonicalMimeType());
- if (!restoringHistory)
- revision._persist();
- WebInspector.workspace.dispatchEventToListeners(WebInspector.Workspace.Events.UISourceCodeContentCommitted, { uiSourceCode: this, content: content });
+ this._commitContent(content);
},
_restoreRevisionHistory: function()
@@ -208,8 +209,17 @@
var registry = WebInspector.Revision._revisionHistoryRegistry();
var historyItems = registry[this.url];
- for (var i = 0; historyItems && i < historyItems.length; ++i)
- this.addRevision(window.localStorage[historyItems[i].key], new Date(historyItems[i].timestamp), true);
+ if (!historyItems || !historyItems.length)
+ return;
+ for (var i = 0; i < historyItems.length; ++i) {
+ var content = window.localStorage[historyItems[i].key];
+ var timestamp = new Date(historyItems[i].timestamp);
+ var revision = new WebInspector.Revision(this, content, timestamp);
+ this.history.push(revision);
+ }
+ this._content = this.history[this.history.length - 1].content;
+ this._contentLoaded = true;
+ this._mimeType = this.canonicalMimeType();
},
_clearRevisionHistory: function()
@@ -238,7 +248,7 @@
if (typeof content !== "string")
return;
- this._setContent(content);
+ this.addRevision(content);
}
this.requestOriginalContent(callback.bind(this));
@@ -260,7 +270,7 @@
if (typeof content !== "string")
return;
- this._setContent(content);
+ this.addRevision(content);
this._clearRevisionHistory();
this.history = [];
callback(this);
@@ -270,19 +280,6 @@
},
/**
- * @param {string} newContent
- * @param {string} mimeType
- */
- contentChanged: function(newContent, mimeType)
- {
- this._content = newContent;
- this._mimeType = mimeType;
- this._contentLoaded = true;
- delete this._workingCopy;
- this.dispatchEventToListeners(WebInspector.UISourceCode.Events.ContentChanged, {content: newContent});
- },
-
- /**
* @return {boolean}
*/
isEditable: function()
@@ -305,6 +302,7 @@
*/
setWorkingCopy: function(newWorkingCopy)
{
+ this._mimeType = this.canonicalMimeType();
var oldWorkingCopy = this._workingCopy;
if (this._content === newWorkingCopy)
delete this._workingCopy;
@@ -314,7 +312,7 @@
this.scriptFile().workingCopyChanged();
else if (this.styleFile())
this.styleFile().workingCopyChanged();
- this.dispatchEventToListeners(WebInspector.UISourceCode.Events.WorkingCopyChanged, {oldWorkingCopy: oldWorkingCopy, workingCopy: newWorkingCopy});
+ this.dispatchEventToListeners(WebInspector.UISourceCode.Events.WorkingCopyChanged, {oldWorkingCopy: oldWorkingCopy, workingCopy: this.workingCopy()});
},
/**
@@ -327,12 +325,11 @@
return;
}
- var newContent = this._workingCopy;
if (this.scriptFile())
this.scriptFile().workingCopyCommitted(callback);
else if (this.styleFile())
this.styleFile().workingCopyCommitted(callback);
- this.addRevision(newContent);
+ this._commitContent(this._workingCopy);
},
/**
@@ -563,7 +560,9 @@
function formattedChanged(content, formatterMapping)
{
this._togglingFormatter = true;
- this.contentChanged(content, mimeType);
+ this._content = content;
+ delete this._workingCopy;
+ this.dispatchEventToListeners(WebInspector.UISourceCode.Events.FormattedChanged, {content: content});
delete this._togglingFormatter;
this._formatterMapping = formatterMapping;
this.updateLiveLocations();
@@ -807,7 +806,7 @@
function revert(content)
{
if (this._uiSourceCode._content !== content)
- this._uiSourceCode._setContent(content);
+ this._uiSourceCode.addRevision(content);
}
this.requestContent(revert.bind(this));
},
Modified: trunk/Source/WebCore/inspector/front-end/UISourceCodeFrame.js (131168 => 131169)
--- trunk/Source/WebCore/inspector/front-end/UISourceCodeFrame.js 2012-10-12 11:14:43 UTC (rev 131168)
+++ trunk/Source/WebCore/inspector/front-end/UISourceCodeFrame.js 2012-10-12 11:19:41 UTC (rev 131169)
@@ -35,7 +35,9 @@
{
this._uiSourceCode = uiSourceCode;
WebInspector.SourceFrame.call(this, this._uiSourceCode);
- this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.ContentChanged, this._onContentChanged, this);
+ this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.FormattedChanged, this._onFormattedChanged, this);
+ this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._onWorkingCopyChanged, this);
+ this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._onWorkingCopyCommitted, this);
}
WebInspector.UISourceCodeFrame.prototype = {
@@ -62,7 +64,9 @@
onTextChanged: function(oldRange, newRange)
{
+ this._isSettingWorkingCopy = true;
this._uiSourceCode.setWorkingCopy(this._textEditor.text());
+ delete this._isSettingWorkingCopy;
},
_didEditContent: function(error)
@@ -76,12 +80,36 @@
/**
* @param {WebInspector.Event} event
*/
- _onContentChanged: function(event)
+ _onFormattedChanged: function(event)
{
- if (!this._isCommittingEditing)
- this.setContent(this._uiSourceCode.content() || "", false, this._uiSourceCode.contentType().canonicalMimeType());
+ var content = /** @type {string} */ event.data.content;
+ this._innerSetContent(content);
},
+ /**
+ * @param {WebInspector.Event} event
+ */
+ _onWorkingCopyChanged: function(event)
+ {
+ this._innerSetContent(this._uiSourceCode.workingCopy());
+ },
+
+ /**
+ * @param {WebInspector.Event} event
+ */
+ _onWorkingCopyCommitted: function(event)
+ {
+ this._innerSetContent(this._uiSourceCode.workingCopy());
+ },
+
+ _innerSetContent: function(content)
+ {
+ if (this._isSettingWorkingCopy || this._isCommittingEditing)
+ return;
+
+ this.setContent(this._uiSourceCode.content() || "", false, this._uiSourceCode.contentType().canonicalMimeType());
+ },
+
populateTextAreaContextMenu: function(contextMenu, lineNumber)
{
WebInspector.SourceFrame.prototype.populateTextAreaContextMenu.call(this, contextMenu, lineNumber);