summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/inspector/front-end/ResourceView.js
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/inspector/front-end/ResourceView.js')
-rw-r--r--Source/WebCore/inspector/front-end/ResourceView.js68
1 files changed, 63 insertions, 5 deletions
diff --git a/Source/WebCore/inspector/front-end/ResourceView.js b/Source/WebCore/inspector/front-end/ResourceView.js
index 83cf99d5..ffd9062 100644
--- a/Source/WebCore/inspector/front-end/ResourceView.js
+++ b/Source/WebCore/inspector/front-end/ResourceView.js
@@ -45,15 +45,20 @@ WebInspector.ResourceView.prototype.__proto__ = WebInspector.View.prototype;
WebInspector.ResourceView.createResourceView = function(resource)
{
+ function sourceFrameForDelegateAndURL(delegate, url)
+ {
+ var view = new WebInspector.SourceFrame(delegate, url);
+ view.resource = resource;
+ return view;
+ }
+
switch (resource.category) {
case WebInspector.resourceCategories.documents:
- case WebInspector.resourceCategories.stylesheets:
case WebInspector.resourceCategories.scripts:
case WebInspector.resourceCategories.xhr:
- var delegate = new WebInspector.SourceFrameDelegateForResourcesPanel(resource);
- var view = new WebInspector.SourceFrame(delegate, resource.url);
- view.resource = resource;
- return view;
+ return sourceFrameForDelegateAndURL(new WebInspector.SourceFrameDelegateForResourcesPanel(resource), resource.url);
+ case WebInspector.resourceCategories.stylesheets:
+ return sourceFrameForDelegateAndURL(new WebInspector.CSSSourceFrameDelegateForResourcesPanel(resource), resource.url);
case WebInspector.resourceCategories.images:
return new WebInspector.ImageView(resource);
case WebInspector.resourceCategories.fonts:
@@ -147,3 +152,56 @@ WebInspector.SourceFrameDelegateForResourcesPanel.prototype = {
}
WebInspector.SourceFrameDelegateForResourcesPanel.prototype.__proto__ = WebInspector.SourceFrameDelegate.prototype;
+
+
+WebInspector.CSSSourceFrameDelegateForResourcesPanel = function(resource)
+{
+ WebInspector.SourceFrameDelegateForResourcesPanel.call(this, resource);
+}
+
+WebInspector.CSSSourceFrameDelegateForResourcesPanel.prototype = {
+ canEditScriptSource: function()
+ {
+ return true;
+ },
+
+ editScriptSource: function(newText)
+ {
+ function handleStyleSheet(newText, styleSheet)
+ {
+ this._styleSheet = styleSheet;
+ this._saveStyleSheet(newText);
+ }
+
+ function handleInfos(newText, error, infos)
+ {
+ if (error)
+ return;
+ for (var i = 0; i < infos.length; ++i) {
+ var info = infos[i];
+ if (info.sourceURL === this._resource.url) {
+ WebInspector.CSSStyleSheet.createForId(info.styleSheetId, handleStyleSheet.bind(this, newText));
+ break;
+ }
+ }
+ }
+
+ if (this._styleSheet)
+ this._saveStyleSheet(newText);
+ else
+ CSSAgent.getAllStyleSheets(handleInfos.bind(this, newText));
+ },
+
+ _saveStyleSheet: function(newText)
+ {
+ function callback(success)
+ {
+ if (!success)
+ console.error("Failed to save modified stylesheet %s", this._resource.url);
+ }
+
+ this._styleSheet.setText(newText, callback.bind(this));
+ }
+}
+
+WebInspector.CSSSourceFrameDelegateForResourcesPanel.prototype.__proto__ = WebInspector.SourceFrameDelegateForResourcesPanel.prototype;