Diff
Modified: trunk/LayoutTests/ChangeLog (117798 => 117799)
--- trunk/LayoutTests/ChangeLog 2012-05-21 17:25:35 UTC (rev 117798)
+++ trunk/LayoutTests/ChangeLog 2012-05-21 17:27:37 UTC (rev 117799)
@@ -1,3 +1,14 @@
+2012-05-21 Pavel Feldman <[email protected]>
+
+ Web Inspector: refactor revision history to not include resource itself.
+ https://bugs.webkit.org/show_bug.cgi?id=87026
+
+ Reviewed by Vsevolod Vlasov.
+
+ * http/tests/inspector/network/network-request-revision-content.html:
+ * inspector/styles/styles-history-expected.txt:
+ * inspector/styles/styles-history.html:
+
2012-05-21 Stephen Chenney <[email protected]>
SVGAnimatedPropertyTearOff does not clear a self pointer on deletion
Modified: trunk/LayoutTests/http/tests/inspector/network/network-request-revision-content.html (117798 => 117799)
--- trunk/LayoutTests/http/tests/inspector/network/network-request-revision-content.html 2012-05-21 17:25:35 UTC (rev 117798)
+++ trunk/LayoutTests/http/tests/inspector/network/network-request-revision-content.html 2012-05-21 17:27:37 UTC (rev 117799)
@@ -23,10 +23,10 @@
resource.history[0].requestContent(step3);
}
- function step3()
+ function step3(content)
{
InspectorTest.addResult(resource.url);
- InspectorTest.addResult(resource.content);
+ InspectorTest.addResult(content);
InspectorTest.completeTest();
}
}
Modified: trunk/LayoutTests/inspector/styles/styles-history-expected.txt (117798 => 117799)
--- trunk/LayoutTests/inspector/styles/styles-history-expected.txt 2012-05-21 17:25:35 UTC (rev 117798)
+++ trunk/LayoutTests/inspector/styles/styles-history-expected.txt 2012-05-21 17:27:37 UTC (rev 117799)
@@ -5,23 +5,11 @@
Running: testSetResourceContentMinor
History length: 0
-Item <tip>:
-body {
- margin: 10px;
- padding: 10px;
-}
-
Running: testSetResourceContentMajor
History length: 1
Item 0:
body {
- margin: 10px;
- padding: 10px;
-}
-
-Item <tip>:
-body {
margin: 20px;
padding: 10px;
}
@@ -30,12 +18,6 @@
History length: 1
Item 0:
body {
- margin: 10px;
- padding: 10px;
-}
-
-Item <tip>:
-body {
margin: 20px;
padding: 10px;
}
@@ -44,17 +26,11 @@
History length: 2
Item 0:
body {
- margin: 10px;
+ margin: 20px;
padding: 10px;
}
-
Item 1:
body {
- margin: 20px;
- padding: 10px;
-}
-Item <tip>:
-body {
margin:30px;
padding: 10px;
}
Modified: trunk/LayoutTests/inspector/styles/styles-history.html (117798 => 117799)
--- trunk/LayoutTests/inspector/styles/styles-history.html 2012-05-21 17:25:35 UTC (rev 117798)
+++ trunk/LayoutTests/inspector/styles/styles-history.html 2012-05-21 17:27:37 UTC (rev 117799)
@@ -96,20 +96,14 @@
function result()
{
InspectorTest.addResult("History length: " + styleResource.history.length);
- for (var i = 0; i < styleResource.history.length; ++i)
- styleResource.history[i].requestContent(dumpRevision.bind(this, i, null));
- styleResource.requestContent(dumpRevision.bind(this, "<tip>", next));
+ for (var i = 0; i < styleResource.history.length; ++i) {
+ InspectorTest.addResult("Item " + i + ":");
+ InspectorTest.addResult(styleResource.history[i].content);
+ }
+ next();
}
return result;
}
-
- function dumpRevision(index, next, content)
- {
- InspectorTest.addResult("Item " + index + ":");
- InspectorTest.addResult(content);
- if (next)
- next();
- }
}
</script>
Modified: trunk/Source/WebCore/ChangeLog (117798 => 117799)
--- trunk/Source/WebCore/ChangeLog 2012-05-21 17:25:35 UTC (rev 117798)
+++ trunk/Source/WebCore/ChangeLog 2012-05-21 17:27:37 UTC (rev 117799)
@@ -1,3 +1,46 @@
+2012-05-21 Pavel Feldman <[email protected]>
+
+ Web Inspector: refactor revision history to not include resource itself.
+ https://bugs.webkit.org/show_bug.cgi?id=87026
+
+ Reviewed by Vsevolod Vlasov.
+
+ This change makes resource contain pure revisions, it stops updating Resources upon free flow editing.
+
+ * inspector/front-end/_javascript_Source.js:
+ (WebInspector._javascript_Source.prototype.setFormatted.didGetContent.didFormatContent):
+ (WebInspector._javascript_Source.prototype.setFormatted.didGetContent):
+ (WebInspector._javascript_Source.prototype.setFormatted):
+ * inspector/front-end/_javascript_SourceFrame.js:
+ (WebInspector._javascript_SourceFrame.prototype.commitEditing):
+ (WebInspector._javascript_SourceFrame.prototype._onContentChanged):
+ (WebInspector._javascript_SourceFrame.prototype._didEditContent):
+ * inspector/front-end/Resource.js:
+ (WebInspector.Resource.prototype.addRevision):
+ (WebInspector.Resource.prototype._innerRequestContent.callback):
+ (WebInspector.Resource.prototype._innerRequestContent):
+ (WebInspector.Resource.prototype.revertToOriginal):
+ (WebInspector.ResourceRevision.prototype.revertToThis):
+ (WebInspector.ResourceRevision.prototype.requestContent):
+ (WebInspector.ResourceRevision.prototype.searchInContent):
+ (WebInspector.ResourceRevision.prototype._persistRevision):
+ * inspector/front-end/RevisionHistoryView.js:
+ (WebInspector.RevisionHistoryView):
+ (WebInspector.RevisionHistoryView.prototype._revisionAdded):
+ (WebInspector.RevisionHistoryTreeElement):
+ * inspector/front-end/ScriptSnippetModel.js:
+ (WebInspector.ScriptSnippetModel.prototype.setScriptSnippetContent):
+ * inspector/front-end/StylesPanel.js:
+ (WebInspector.StyleSourceFrame.prototype.commitEditing):
+ (WebInspector.StyleSourceFrame.prototype._didEditContent):
+ (WebInspector.StyleSourceFrame.prototype._onContentChanged):
+ * inspector/front-end/UISourceCode.js:
+ (WebInspector.UISourceCode.prototype._revisionAdded):
+ (WebInspector.UISourceCode.prototype.contentChanged):
+ (WebInspector.UISourceCode.prototype.commitWorkingCopy):
+ * inspector/front-end/inspector.js:
+ (WebInspector._doLoadedDoneWithCapabilities.get if):
+
2012-05-21 Allan Sandfeld Jensen <[email protected]>
GCC 4.7 and C++11
Modified: trunk/Source/WebCore/inspector/front-end/_javascript_Source.js (117798 => 117799)
--- trunk/Source/WebCore/inspector/front-end/_javascript_Source.js 2012-05-21 17:25:35 UTC (rev 117798)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_Source.js 2012-05-21 17:27:37 UTC (rev 117799)
@@ -102,7 +102,7 @@
{
if (!formatted) {
this._togglingFormatter = true;
- this.contentChanged(content || "");
+ this.contentChanged(content || "", mimeType);
delete this._togglingFormatter;
this._formatterMapping = new WebInspector.IdentityFormatterSourceMapping();
this.updateLiveLocations();
@@ -121,7 +121,7 @@
function didFormatContent(formattedContent, formatterMapping)
{
this._togglingFormatter = true;
- this.contentChanged(formattedContent);
+ this.contentChanged(formattedContent, mimeType);
delete this._togglingFormatter;
this._formatterMapping = formatterMapping;
this.updateLiveLocations();
Modified: trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js (117798 => 117799)
--- trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js 2012-05-21 17:25:35 UTC (rev 117798)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js 2012-05-21 17:27:37 UTC (rev 117799)
@@ -92,7 +92,7 @@
*/
commitEditing: function(text)
{
- this._editingContent = true;
+ this._isCommittingEditing = true;
this._uiSourceCode.commitWorkingCopy(this._didEditContent.bind(this));
},
@@ -101,9 +101,8 @@
*/
_onContentChanged: function(event)
{
- if (this._editingContent)
+ if (this._isCommittingEditing)
return;
- var oldContent = /** @type {string} */ event.data.oldContent;
var content = /** @type {string} */ event.data.content;
if (this._uiSourceCode.togglingFormatter())
@@ -176,7 +175,7 @@
_didEditContent: function(error)
{
- delete this._editingContent;
+ delete this._isCommittingEditing;
if (error) {
WebInspector.log(error, WebInspector.ConsoleMessage.MessageLevel.Error, true);
Modified: trunk/Source/WebCore/inspector/front-end/Resource.js (117798 => 117799)
--- trunk/Source/WebCore/inspector/front-end/Resource.js 2012-05-21 17:25:35 UTC (rev 117798)
+++ trunk/Source/WebCore/inspector/front-end/Resource.js 2012-05-21 17:27:37 UTC (rev 117799)
@@ -114,18 +114,19 @@
}
/**
- * @param {WebInspector.Resource} resource
+ * @param {WebInspector.ResourceRevision} revision
*/
-WebInspector.Resource.persistRevision = function(resource)
+WebInspector.Resource.persistRevision = function(revision)
{
if (!window.localStorage)
return;
+ var resource = revision.resource;
var url = ""
var loaderId = resource.loaderId;
- var timestamp = resource._contentTimestamp.getTime();
+ var timestamp = revision.timestamp.getTime();
var key = "resource-history|" + url + "|" + loaderId + "|" + timestamp;
- var content = resource._content;
+ var content = revision._content;
var registry = WebInspector.Resource._resourceRevisionRegistry();
@@ -301,14 +302,6 @@
},
/**
- * @return {Date}
- */
- get contentTimestamp()
- {
- return this._contentTimestamp;
- },
-
- /**
* @return {boolean}
*/
isEditable: function()
@@ -336,29 +329,26 @@
},
/**
- * @param {string} newContent
+ * @param {string} content
* @param {Date=} timestamp
* @param {boolean=} restoringHistory
*/
- addRevision: function(newContent, timestamp, restoringHistory)
+ addRevision: function(content, timestamp, restoringHistory)
{
- var revision = new WebInspector.ResourceRevision(this, this._content, this._contentTimestamp);
+ if (this.history.length) {
+ var lastRevision = this.history[this.history.length - 1];
+ if (lastRevision._content === content)
+ return;
+ }
+ var revision = new WebInspector.ResourceRevision(this, content, timestamp || new Date());
this.history.push(revision);
- this._content = newContent;
- this._contentTimestamp = timestamp || new Date();
-
this.dispatchEventToListeners(WebInspector.Resource.Events.RevisionAdded, revision);
if (!restoringHistory)
- this._persistRevision();
- WebInspector.resourceTreeModel.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.ResourceContentCommitted, { resource: this, content: newContent });
+ revision._persistRevision();
+ WebInspector.resourceTreeModel.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.ResourceContentCommitted, { resource: this, content: content });
},
- _persistRevision: function()
- {
- WebInspector.Resource.persistRevision(this);
- },
-
/**
* @return {?string}
*/
@@ -458,7 +448,6 @@
{
this._content = error ? null : content;
this._contentEncoded = contentEncoded;
- this._originalContent = content;
var callbacks = this._pendingContentCallbacks.slice();
for (var i = 0; i < callbacks.length; ++i)
callbacks[i](this._content, this._contentEncoded, this.canonicalMimeType());
@@ -466,6 +455,15 @@
delete this._contentRequested;
}
PageAgent.getResourceContent(this.frameId, this.url, callback.bind(this));
+ },
+
+ revertToOriginal: function()
+ {
+ function revert(content)
+ {
+ this.setContent(content, true, function() {});
+ }
+ this.requestContent(revert.bind(this));
}
}
@@ -476,7 +474,7 @@
* @implements {WebInspector.ContentProvider}
* @param {WebInspector.Resource} resource
* @param {?string|undefined} content
- * @param {number} timestamp
+ * @param {Date} timestamp
*/
WebInspector.ResourceRevision = function(resource, content, timestamp)
{
@@ -495,7 +493,7 @@
},
/**
- * @return {number}
+ * @return {Date}
*/
get timestamp()
{
@@ -515,7 +513,7 @@
function revert(content)
{
if (this._resource._content !== content)
- this._resource.setContent(content, true);
+ this._resource.setContent(content, true, function() {});
}
this.requestContent(revert.bind(this));
},
@@ -541,29 +539,7 @@
*/
requestContent: function(callback)
{
- if (typeof this._content === "string") {
- callback(this._content, false, this.resource.mimeType);
- return;
- }
-
- // If we are here, this is initial revision. First, look up content fetched over the wire.
- if (typeof this.resource._originalContent === "string") {
- this._content = this._resource._originalContent;
- callback(this._content, false, this.resource.mimeType);
- return;
- }
-
- /**
- * @param {?Protocol.Error} error
- * @param {string} content
- * @param {boolean} contentEncoded
- */
- function callbackWrapper(error, content, contentEncoded)
- {
- callback(error ? null : content, contentEncoded, this.resource.mimeType);
- }
-
- PageAgent.getResourceContent(this._resource.frameId, this._resource.url, callbackWrapper.bind(this));
+ callback(this._content || "", false, this.resource.mimeType);
},
/**
@@ -575,6 +551,11 @@
searchInContent: function(query, caseSensitive, isRegex, callback)
{
callback([]);
+ },
+
+ _persistRevision: function()
+ {
+ WebInspector.Resource.persistRevision(this);
}
}
Modified: trunk/Source/WebCore/inspector/front-end/RevisionHistoryView.js (117798 => 117799)
--- trunk/Source/WebCore/inspector/front-end/RevisionHistoryView.js 2012-05-21 17:25:35 UTC (rev 117798)
+++ trunk/Source/WebCore/inspector/front-end/RevisionHistoryView.js 2012-05-21 17:27:37 UTC (rev 117799)
@@ -50,19 +50,22 @@
label.textContent = WebInspector.UIString("No revisions");
} else {
var olElement = this.element.createChild("ol");
- var treeOutline = new TreeOutline(olElement);
+ this._treeOutline = new TreeOutline(olElement);
revisionCount = this._resource.history.length;
- var historyItem = new WebInspector.RevisionHistoryTreeElement(this._resource);
- historyItem.selectable = false;
- treeOutline.appendChild(historyItem);
-
for (var i = revisionCount - 1; i >= 0; --i) {
var revision = this._resource.history[i];
- historyItem = new WebInspector.RevisionHistoryTreeElement(this._resource, i);
- historyItem.selectable = false;
- treeOutline.appendChild(historyItem);
+ var historyItem = new WebInspector.RevisionHistoryTreeElement(revision, this._resource.history[i - 1]);
+ this._treeOutline.appendChild(historyItem);
}
+
+ var baseItem = new TreeElement("", null, false);
+ baseItem.selectable = false;
+ this._treeOutline.appendChild(baseItem);
+
+ var revertToOriginal = baseItem.listItemElement.createChild("span", "revision-history-link");
+ revertToOriginal.textContent = WebInspector.UIString("revert to original");
+ revertToOriginal.addEventListener("click", this._resource.revertToOriginal.bind(this._resource));
}
this._statusElement = document.createElement("span");
@@ -97,9 +100,15 @@
}
WebInspector.RevisionHistoryView.prototype = {
- _revisionAdded: function()
+ _revisionAdded: function(event)
{
- WebInspector.RevisionHistoryView.showHistory(this._uiSourceCode);
+ if (this._resource.history.length === 1) {
+ WebInspector.RevisionHistoryView.showHistory(this._uiSourceCode);
+ return;
+ }
+ var historyLength = this._resource.history.length;
+ var historyItem = new WebInspector.RevisionHistoryTreeElement(this._resource.history[historyLength - 1], this._resource.history[historyLength - 2]);
+ this._treeOutline.insertChild(historyItem, 0);
},
_onclose: function()
@@ -115,34 +124,23 @@
/**
* @constructor
* @extends {TreeElement}
- * @param {WebInspector.Resource} resource
- * @param {number=} revisionOrdinal
+ * @param {WebInspector.ResourceRevision} revision
+ * @param {WebInspector.ResourceRevision=} baseRevision
*/
-WebInspector.RevisionHistoryTreeElement = function(resource, revisionOrdinal)
+WebInspector.RevisionHistoryTreeElement = function(revision, baseRevision)
{
- this._resource = resource;
-
var titleElement = document.createElement("span");
- if (isNaN(revisionOrdinal)) {
- this._revision = resource;
- this._baseRevision = resource.history[resource.history.length - 1];
+ titleElement.textContent = revision.timestamp.toLocaleTimeString();
- titleElement.textContent = resource.contentTimestamp.toLocaleTimeString();
- } else {
- this._revision = resource.history[revisionOrdinal];
- this._baseRevision = resource.history[revisionOrdinal - 1];
+ TreeElement.call(this, titleElement, null, true);
+ this.selectable = false;
- titleElement.textContent = revisionOrdinal ? resource.history[revisionOrdinal].timestamp.toLocaleTimeString() : WebInspector.UIString("(original)");
- function revert()
- {
- this._revision.revertToThis();
- }
+ this._revision = revision;
+ this._baseRevision = baseRevision;
- var revertElement = titleElement.createChild("span", "revision-history-link");
- revertElement.textContent = WebInspector.UIString("revert to this");
- revertElement.addEventListener("click", revert.bind(this), false);
- }
- TreeElement.call(this, titleElement, null, revisionOrdinal !== 0);
+ var revertElement = titleElement.createChild("span", "revision-history-link");
+ revertElement.textContent = WebInspector.UIString("revert to this");
+ revertElement.addEventListener("click", this._revision.revertToThis.bind(this._revision), false);
}
WebInspector.RevisionHistoryTreeElement.prototype = {
@@ -153,7 +151,10 @@
this._wasExpandedOnce = true;
this.childrenListElement.addStyleClass("source-code");
- this._baseRevision.requestContent(step1.bind(this));
+ if (this._baseRevision)
+ this._baseRevision.requestContent(step1.bind(this));
+ else
+ this._revision.resource.requestContent(step1.bind(this));
function step1(baseContent)
{
Modified: trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js (117798 => 117799)
--- trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js 2012-05-21 17:25:35 UTC (rev 117798)
+++ trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js 2012-05-21 17:27:37 UTC (rev 117799)
@@ -113,7 +113,7 @@
{
var snippet = this._snippetStorage.snippetForId(snippetJavaScriptSource.snippetId);
snippet.content = newContent;
- snippetJavaScriptSource.contentChanged(newContent);
+ snippetJavaScriptSource.contentChanged(newContent, "text/_javascript_");
},
/**
Modified: trunk/Source/WebCore/inspector/front-end/StylesPanel.js (117798 => 117799)
--- trunk/Source/WebCore/inspector/front-end/StylesPanel.js 2012-05-21 17:25:35 UTC (rev 117798)
+++ trunk/Source/WebCore/inspector/front-end/StylesPanel.js 2012-05-21 17:27:37 UTC (rev 117799)
@@ -145,6 +145,7 @@
*/
commitEditing: function(text)
{
+ this._isCommittingEditing = true;
this._styleSource.commitWorkingCopy(this._didEditContent.bind(this));
},
@@ -159,6 +160,7 @@
WebInspector.log(error, WebInspector.ConsoleMessage.MessageLevel.Error, true);
return;
}
+ delete this._isCommittingEditing;
},
_clearIncrementalUpdateTimer: function()
@@ -173,7 +175,8 @@
*/
_onContentChanged: function(event)
{
- this.setContent(this._styleSource.resource().content, false, "text/stylesheet");
+ if (!this._isCommittingEditing)
+ this.setContent(this._styleSource.content() || "", false, "text/css");
},
populateTextAreaContextMenu: function(contextMenu, lineNumber)
Modified: trunk/Source/WebCore/inspector/front-end/UISourceCode.js (117798 => 117799)
--- trunk/Source/WebCore/inspector/front-end/UISourceCode.js 2012-05-21 17:25:35 UTC (rev 117798)
+++ trunk/Source/WebCore/inspector/front-end/UISourceCode.js 2012-05-21 17:27:37 UTC (rev 117799)
@@ -136,21 +136,24 @@
_revisionAdded: function(event)
{
- this.contentChanged(this.resource().content || "");
+ var revision = /** @type {WebInspector.ResourceRevision} */ event.data;
+ this.contentChanged(revision.content || "", this._resource.canonicalMimeType());
},
/**
* @param {string} newContent
+ * @param {string} mimeType
*/
- contentChanged: function(newContent)
+ contentChanged: function(newContent, mimeType)
{
if (this._committingWorkingCopy)
return;
- var oldContent = this._contentLoaded ? this._content : undefined;
this._content = newContent;
+ this._mimeType = mimeType;
+ this._contentLoaded = true;
delete this._workingCopy;
- this.dispatchEventToListeners(WebInspector.UISourceCode.Events.ContentChanged, {oldContent: oldContent, content: newContent});
+ this.dispatchEventToListeners(WebInspector.UISourceCode.Events.ContentChanged, {content: newContent});
},
/**
@@ -204,7 +207,7 @@
{
delete this._committingWorkingCopy;
if (!error)
- this.contentChanged(newContent);
+ this.contentChanged(newContent, this._mimeType);
callback(error);
}
Modified: trunk/Source/WebCore/inspector/front-end/inspector.js (117798 => 117799)
--- trunk/Source/WebCore/inspector/front-end/inspector.js 2012-05-21 17:25:35 UTC (rev 117798)
+++ trunk/Source/WebCore/inspector/front-end/inspector.js 2012-05-21 17:27:37 UTC (rev 117799)
@@ -416,6 +416,8 @@
this.scriptSnippetModel = new WebInspector.ScriptSnippetModel();
this.breakpointManager = new WebInspector.BreakpointManager(WebInspector.settings.breakpoints, this.debuggerModel);
+ WebInspector.CSSCompletions.requestCSSNameCompletions();
+
this.drawer = new WebInspector.Drawer();
this.consoleView = new WebInspector.ConsoleView(WebInspector.WorkerManager.isWorkerFrontend());
@@ -444,7 +446,6 @@
if (this._zoomLevel)
this._requestZoom();
- WebInspector.CSSCompletions.requestCSSNameCompletions();
this._createPanels();
this._createGlobalStatusBarItems();