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):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@121672
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-06-26 Vsevolod Vlasov <vsevik@chromium.org>
+
+ 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 <tzik@chromium.org>
Web Inspector: Add DirectoryContentView for FileSystemView
return;
}
this._resourceBinding._requestViaInspectorResource(rule.id.styleSheetId, callback);
+ },
+
+ /**
+ * @return {WebInspector.CSSStyleModelResourceBinding}
+ */
+ resourceBinding: function()
+ {
+ return this._resourceBinding;
}
}
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
*/
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);
},
/**
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));
},
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)
*/
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);