- Revision
- 121672
- Author
- [email protected]
- Date
- 2012-07-02 05:13:19 -0700 (Mon, 02 Jul 2012)
Log Message
Web Inspector: StyleSource should set content using CSSStyleModelResourceBinding directly.
https://bugs.webkit.org/show_bug.cgi?id=89891
Reviewed by Pavel Feldman.
StyleSource now calls CSS resource binding directly.
CSS resource binding now adds resource revision only after setStyleSheetText call returns from backend.
Resource.revertAndClearHistory is now clearing history asynchronously
since Resource.setContent adds revision that should be removed as well.
* inspector/front-end/CSSStyleModel.js:
(WebInspector.CSSStyleModel.prototype.getViaInspectorResourceForRule):
(WebInspector.CSSStyleModel.prototype.resourceBinding):
(WebInspector.CSSStyleModelResourceBinding.prototype.setStyleContent.innerCallback):
(WebInspector.CSSStyleModelResourceBinding.prototype.setStyleContent):
(WebInspector.CSSStyleModelResourceBinding.prototype.setContent):
* inspector/front-end/Resource.js:
(WebInspector.Resource.prototype.revertAndClearHistory):
(WebInspector.Resource.prototype.revertAndClearHistory.clearHistory):
* inspector/front-end/RevisionHistoryView.js:
(WebInspector.RevisionHistoryView.prototype._createResourceItem):
* inspector/front-end/StylesPanel.js:
(WebInspector.StyleSource.prototype.workingCopyCommitted):
(WebInspector.StyleSource.prototype.workingCopyChanged):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (121671 => 121672)
--- trunk/Source/WebCore/ChangeLog 2012-07-02 12:07:51 UTC (rev 121671)
+++ trunk/Source/WebCore/ChangeLog 2012-07-02 12:13:19 UTC (rev 121672)
@@ -1,3 +1,30 @@
+2012-06-26 Vsevolod Vlasov <[email protected]>
+
+ Web Inspector: StyleSource should set content using CSSStyleModelResourceBinding directly.
+ https://bugs.webkit.org/show_bug.cgi?id=89891
+
+ Reviewed by Pavel Feldman.
+
+ StyleSource now calls CSS resource binding directly.
+ CSS resource binding now adds resource revision only after setStyleSheetText call returns from backend.
+ Resource.revertAndClearHistory is now clearing history asynchronously
+ since Resource.setContent adds revision that should be removed as well.
+
+ * inspector/front-end/CSSStyleModel.js:
+ (WebInspector.CSSStyleModel.prototype.getViaInspectorResourceForRule):
+ (WebInspector.CSSStyleModel.prototype.resourceBinding):
+ (WebInspector.CSSStyleModelResourceBinding.prototype.setStyleContent.innerCallback):
+ (WebInspector.CSSStyleModelResourceBinding.prototype.setStyleContent):
+ (WebInspector.CSSStyleModelResourceBinding.prototype.setContent):
+ * inspector/front-end/Resource.js:
+ (WebInspector.Resource.prototype.revertAndClearHistory):
+ (WebInspector.Resource.prototype.revertAndClearHistory.clearHistory):
+ * inspector/front-end/RevisionHistoryView.js:
+ (WebInspector.RevisionHistoryView.prototype._createResourceItem):
+ * inspector/front-end/StylesPanel.js:
+ (WebInspector.StyleSource.prototype.workingCopyCommitted):
+ (WebInspector.StyleSource.prototype.workingCopyChanged):
+
2012-07-02 Taiju Tsuiki <[email protected]>
Web Inspector: Add DirectoryContentView for FileSystemView
Modified: trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js (121671 => 121672)
--- trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js 2012-07-02 12:07:51 UTC (rev 121671)
+++ trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js 2012-07-02 12:13:19 UTC (rev 121672)
@@ -335,6 +335,14 @@
return;
}
this._resourceBinding._requestViaInspectorResource(rule.id.styleSheetId, callback);
+ },
+
+ /**
+ * @return {WebInspector.CSSStyleModelResourceBinding}
+ */
+ resourceBinding: function()
+ {
+ return this._resourceBinding;
}
}
@@ -940,6 +948,35 @@
WebInspector.CSSStyleModelResourceBinding.prototype = {
/**
+ * @param {WebInspector.StyleSource} styleSource
+ * @param {string} content
+ * @param {boolean} majorChange
+ * @param {function(?string)} userCallback
+ */
+ setStyleContent: function(styleSource, content, majorChange, userCallback)
+ {
+ var resource = styleSource.resource();
+ if (this._styleSheetIdForResource(resource)) {
+ this._innerSetContent(resource, content, majorChange, innerCallback, null);
+ return;
+ }
+ this._loadStyleSheetHeaders(this._innerSetContent.bind(this, resource, content, majorChange, innerCallback));
+
+ function innerCallback(error)
+ {
+ if (error) {
+ userCallback(error);
+ return;
+ }
+
+ if (majorChange)
+ resource.addRevision(content);
+
+ userCallback(null);
+ }
+ },
+
+ /**
* @param {WebInspector.Resource} resource
* @param {string} content
* @param {boolean} majorChange
@@ -947,14 +984,12 @@
*/
setContent: function(resource, content, majorChange, userCallback)
{
- if (majorChange && resource.type === WebInspector.resourceTypes.Stylesheet)
- resource.addRevision(content);
-
- if (this._styleSheetIdForResource(resource)) {
- this._innerSetContent(resource, content, majorChange, userCallback, null);
+ var styleSource = /** @type {WebInspector.StyleSource} */ resource.uiSourceCode();
+ if (!styleSource) {
+ userCallback("Resource is not editable");
return;
}
- this._loadStyleSheetHeaders(this._innerSetContent.bind(this, resource, content, majorChange, userCallback));
+ this.setStyleContent(styleSource, content, majorChange, userCallback);
},
/**
Modified: trunk/Source/WebCore/inspector/front-end/Resource.js (121671 => 121672)
--- trunk/Source/WebCore/inspector/front-end/Resource.js 2012-07-02 12:07:51 UTC (rev 121671)
+++ trunk/Source/WebCore/inspector/front-end/Resource.js 2012-07-02 12:13:19 UTC (rev 121672)
@@ -500,14 +500,20 @@
this.requestContent(revert.bind(this));
},
- revertAndClearHistory: function()
+ revertAndClearHistory: function(callback)
{
function revert(content)
{
- this.setContent(content, true, function() {});
+ this.setContent(content, true, clearHistory.bind(this));
+ }
+
+ function clearHistory()
+ {
WebInspector.Resource._clearResourceHistory(this);
this.history = [];
+ callback();
}
+
this.requestContent(revert.bind(this));
},
Modified: trunk/Source/WebCore/inspector/front-end/RevisionHistoryView.js (121671 => 121672)
--- trunk/Source/WebCore/inspector/front-end/RevisionHistoryView.js 2012-07-02 12:07:51 UTC (rev 121671)
+++ trunk/Source/WebCore/inspector/front-end/RevisionHistoryView.js 2012-07-02 12:13:19 UTC (rev 121672)
@@ -112,17 +112,26 @@
revertToOriginal.textContent = WebInspector.UIString("apply original content");
revertToOriginal.addEventListener("click", resource.revertToOriginal.bind(resource));
- function clearHistory()
+ var clearHistoryElement = resourceItem.listItemElement.createChild("span", "revision-history-link");
+ clearHistoryElement.textContent = WebInspector.UIString("revert");
+ clearHistoryElement.addEventListener("click", this._clearHistory.bind(this, resource));
+ return resourceItem;
+ },
+
+ /**
+ * @param {WebInspector.Resource} resource
+ */
+ _clearHistory: function(resource)
+ {
+ resource.revertAndClearHistory(historyCleared.bind(this));
+
+ function historyCleared()
{
- resource.revertAndClearHistory();
+ var resourceItem = this._resourceItems.get(resource);
this._treeOutline.removeChild(resourceItem);
this._resourceItems.remove(resource);
}
- var clearHistoryElement = resourceItem.listItemElement.createChild("span", "revision-history-link");
- clearHistoryElement.textContent = WebInspector.UIString("revert");
- clearHistoryElement.addEventListener("click", clearHistory.bind(this));
- return resourceItem;
},
_revisionAdded: function(event)
Modified: trunk/Source/WebCore/inspector/front-end/StylesPanel.js (121671 => 121672)
--- trunk/Source/WebCore/inspector/front-end/StylesPanel.js 2012-07-02 12:07:51 UTC (rev 121671)
+++ trunk/Source/WebCore/inspector/front-end/StylesPanel.js 2012-07-02 12:13:19 UTC (rev 121672)
@@ -103,14 +103,14 @@
*/
workingCopyCommitted: function(callback)
{
- this._resource.setContent(this.workingCopy(), true, callback);
+ WebInspector.cssModel.resourceBinding().setStyleContent(this, this.workingCopy(), true, callback);
},
workingCopyChanged: function()
{
function commitIncrementalEdit()
{
- this._resource.setContent(this.workingCopy(), false, function() {});
+ WebInspector.cssModel.resourceBinding().setStyleContent(this, this.workingCopy(), false, function() {});
}
const updateTimeout = 200;
this._incrementalUpdateTimer = setTimeout(commitIncrementalEdit.bind(this), updateTimeout);