Diff
Modified: trunk/Source/WebCore/ChangeLog (120085 => 120086)
--- trunk/Source/WebCore/ChangeLog 2012-06-12 16:44:28 UTC (rev 120085)
+++ trunk/Source/WebCore/ChangeLog 2012-06-12 16:57:12 UTC (rev 120086)
@@ -1,5 +1,28 @@
2012-06-12 Pavel Feldman <pfeld...@chromium.org>
+ Web Inspector: allow clearing revision history.
+ https://bugs.webkit.org/show_bug.cgi?id=88847
+
+ Reviewed by Vsevolod Vlasov.
+
+ This change also renames "Revision history" to "Local modifications".
+ I intend to list modifications to all files in that view in the subsequent change.
+
+ * English.lproj/localizedStrings.js:
+ * inspector/front-end/Resource.js:
+ (WebInspector.Resource._clearResourceHistory):
+ * inspector/front-end/RevisionHistoryView.js:
+ (WebInspector.RevisionHistoryView.else.clearHistory):
+ (WebInspector.RevisionHistoryView):
+ (WebInspector.RevisionHistoryView.prototype._revisionAdded):
+ (WebInspector.RevisionHistoryTreeElement):
+ (WebInspector.RevisionHistoryTreeElement.prototype._createLine):
+ (WebInspector.RevisionHistoryTreeElement.prototype.allowRevert):
+ * inspector/front-end/ScriptsPanel.js:
+ (WebInspector.ScriptsPanel.prototype.appendApplicableItems):
+
+2012-06-12 Pavel Feldman <pfeld...@chromium.org>
+
Web Inspector: use jsdifflib for revision diff calculation.
https://bugs.webkit.org/show_bug.cgi?id=88791
@@ -44,6 +67,52 @@
* inspector/front-end/revisionHistory.css:
(.revision-history-line-separator .webkit-line-number):
+2012-06-12 Pavel Feldman <pfeld...@chromium.org>
+
+ Web Inspector: use jsdifflib for revision diff calculation.
+ https://bugs.webkit.org/show_bug.cgi?id=88791
+
+ Reviewed by Vsevolod Vlasov.
+
+ Present diff calculation is incomplete, it does not properly handle the following case:
+ [a, b, c, d, e, f, g, h] => [c, d, e, f, g, h, a, b]
+ We should not be implementing diff by ourselves. I imported jsdifflib from
+ https://github.com/cemerick/jsdifflib. It has BSD license that is compatible with WebKit.
+
+ * WebCore.gypi:
+ * WebCore.vcproj/WebCore.vcproj:
+ * inspector/front-end/RevisionHistoryView.js:
+ (WebInspector.RevisionHistoryTreeElement.prototype.onexpand.step2):
+ (WebInspector.RevisionHistoryTreeElement.prototype.onexpand):
+ (WebInspector.RevisionHistoryTreeElement.prototype._createLine.appendLineNumber):
+ (WebInspector.RevisionHistoryTreeElement.prototype._createLine):
+ * inspector/front-end/WebKit.qrc:
+ * inspector/front-end/externs.js:
+ (difflib.stringAsLines):
+ (difflib.SequenceMatcher):
+ (difflib.SequenceMatcher.prototype.get_opcodes):
+ * inspector/front-end/inspector.html:
+ * inspector/front-end/jsdifflib.js: Added.
+ (difflib.defaultJunkFunction):
+ (difflib.stripLinebreaks):
+ (difflib.stringAsLines):
+ (difflib.__reduce):
+ (difflib.__ntuplecomp):
+ (difflib.__calculate_ratio):
+ (difflib.__dictget):
+ (difflib.SequenceMatcher.this.set_seqs):
+ (difflib.SequenceMatcher.this.set_seq1):
+ (difflib.SequenceMatcher.this.set_seq2):
+ (difflib.SequenceMatcher.this.__chain_b):
+ (difflib.SequenceMatcher.this.find_longest_match):
+ (difflib.SequenceMatcher.this.get_matching_blocks):
+ (difflib.SequenceMatcher.this.get_opcodes):
+ (difflib.SequenceMatcher.this.get_grouped_opcodes):
+ (difflib.SequenceMatcher.this.quick_ratio):
+ (difflib.SequenceMatcher.this.real_quick_ratio):
+ * inspector/front-end/revisionHistory.css:
+ (.revision-history-line-separator .webkit-line-number):
+
2012-06-12 Christophe Dumez <christophe.du...@intel.com>
[GStreamer] http/tests/media/video-buffered-range-contains-currentTime.html is failing
Modified: trunk/Source/WebCore/English.lproj/localizedStrings.js (120085 => 120086)
--- trunk/Source/WebCore/English.lproj/localizedStrings.js 2012-06-12 16:44:28 UTC (rev 120085)
+++ trunk/Source/WebCore/English.lproj/localizedStrings.js 2012-06-12 16:57:12 UTC (rev 120086)
@@ -506,7 +506,6 @@
localizedStrings["This request has no cookies."] = "This request has no cookies.";
localizedStrings["(original)"] = "(original)";
localizedStrings["(%d, %d)"] = "(%d, %d)";
-localizedStrings["Revert to this revision"] = "Revert to this revision";
localizedStrings["WebSockets"] = "WebSockets";
localizedStrings["Frames"] = "Frames";
localizedStrings["Text"] = "Text";
@@ -699,3 +698,6 @@
localizedStrings["Clipboard access is denied"] = "Clipboard access is denied";
localizedStrings["Go to source"] = "Go to source";
localizedStrings["Delete profile"] = "Delete profile";
+localizedStrings["Local modifications..."] = "Local modifications...";
+localizedStrings["revert to original"] = "revert to original";
+localizedStrings["revert and clear history"] = "revert and clear history";
Modified: trunk/Source/WebCore/inspector/front-end/Resource.js (120085 => 120086)
--- trunk/Source/WebCore/inspector/front-end/Resource.js 2012-06-12 16:44:28 UTC (rev 120085)
+++ trunk/Source/WebCore/inspector/front-end/Resource.js 2012-06-12 16:57:12 UTC (rev 120086)
@@ -152,6 +152,25 @@
setTimeout(persist, 0);
}
+/**
+ * @param {WebInspector.Resource} resource
+ */
+WebInspector.Resource._clearResourceHistory = function(resource)
+{
+ if (!window.localStorage)
+ return;
+
+ if (resource.url.startsWith("inspector://"))
+ return;
+
+ var registry = WebInspector.Resource._resourceRevisionRegistry();
+ var historyItems = registry[resource.url];
+ for (var i = 0; historyItems && i < historyItems.length; ++i)
+ delete window.localStorage[historyItems[i].key];
+ delete registry[resource.url];
+ window.localStorage["resource-history"] = JSON.stringify(registry);
+}
+
WebInspector.Resource.Events = {
RevisionAdded: "revision-added",
MessageAdded: "message-added",
@@ -471,6 +490,17 @@
this.requestContent(revert.bind(this));
},
+ revertAndClearHistory: function()
+ {
+ function revert(content)
+ {
+ this.setContent(content, true, function() {});
+ WebInspector.Resource._clearResourceHistory(this);
+ this.history = [];
+ }
+ this.requestContent(revert.bind(this));
+ },
+
/**
* @return {boolean}
*/
Modified: trunk/Source/WebCore/inspector/front-end/RevisionHistoryView.js (120085 => 120086)
--- trunk/Source/WebCore/inspector/front-end/RevisionHistoryView.js 2012-06-12 16:44:28 UTC (rev 120085)
+++ trunk/Source/WebCore/inspector/front-end/RevisionHistoryView.js 2012-06-12 16:57:12 UTC (rev 120086)
@@ -55,7 +55,7 @@
for (var i = revisionCount - 1; i >= 0; --i) {
var revision = this._resource.history[i];
- var historyItem = new WebInspector.RevisionHistoryTreeElement(revision, this._resource.history[i - 1]);
+ var historyItem = new WebInspector.RevisionHistoryTreeElement(revision, this._resource.history[i - 1], i !== revisionCount - 1);
this._treeOutline.appendChild(historyItem);
}
@@ -66,6 +66,16 @@
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));
+
+ function clearHistory()
+ {
+ this._resource.revertAndClearHistory();
+ WebInspector.RevisionHistoryView.showHistory(uiSourceCode);
+ }
+
+ var clearHistoryElement = baseItem.listItemElement.createChild("span", "revision-history-link");
+ clearHistoryElement.textContent = WebInspector.UIString("revert and clear history");
+ clearHistoryElement.addEventListener("click", clearHistory.bind(this));
}
this._statusElement = document.createElement("span");
@@ -107,7 +117,9 @@
return;
}
var historyLength = this._resource.history.length;
- var historyItem = new WebInspector.RevisionHistoryTreeElement(this._resource.history[historyLength - 1], this._resource.history[historyLength - 2]);
+ var historyItem = new WebInspector.RevisionHistoryTreeElement(this._resource.history[historyLength - 1], this._resource.history[historyLength - 2], false);
+ if (this._treeOutline.children.length)
+ this._treeOutline.children[0].allowRevert();
this._treeOutline.insertChild(historyItem, 0);
},
@@ -125,9 +137,10 @@
* @constructor
* @extends {TreeElement}
* @param {WebInspector.ResourceRevision} revision
- * @param {WebInspector.ResourceRevision=} baseRevision
+ * @param {WebInspector.ResourceRevision} baseRevision
+ * @param {boolean} allowRevert
*/
-WebInspector.RevisionHistoryTreeElement = function(revision, baseRevision)
+WebInspector.RevisionHistoryTreeElement = function(revision, baseRevision, allowRevert)
{
var titleElement = document.createElement("span");
titleElement.textContent = revision.timestamp.toLocaleTimeString();
@@ -138,9 +151,11 @@
this._revision = revision;
this._baseRevision = baseRevision;
- 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);
+ this._revertElement = titleElement.createChild("span", "revision-history-link");
+ this._revertElement.textContent = WebInspector.UIString("revert to this");
+ this._revertElement.addEventListener("click", this._revision.revertToThis.bind(this._revision), false);
+ if (!allowRevert)
+ this._revertElement.addStyleClass("hidden");
}
WebInspector.RevisionHistoryTreeElement.prototype = {
@@ -234,6 +249,11 @@
child.listItemElement.appendChild(contentSpan);
child.listItemElement.addStyleClass("revision-history-line");
child.listItemElement.addStyleClass("revision-history-line-" + changeType);
+ },
+
+ allowRevert: function()
+ {
+ this._revertElement.removeStyleClass("hidden");
}
}
Modified: trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js (120085 => 120086)
--- trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js 2012-06-12 16:44:28 UTC (rev 120085)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js 2012-06-12 16:57:12 UTC (rev 120086)
@@ -1066,7 +1066,7 @@
return;
var uiSourceCode = /** @type {WebInspector.UISourceCode} */ target;
- contextMenu.appendItem(WebInspector.UIString("Revision history..."), this._showLocalHistory.bind(this, uiSourceCode));
+ contextMenu.appendItem(WebInspector.UIString("Local modifications..."), this._showLocalHistory.bind(this, uiSourceCode));
if (uiSourceCode.resource() && uiSourceCode.resource().request)
contextMenu.appendApplicableItems(uiSourceCode.resource().request);
},