https://bugs.webkit.org/show_bug.cgi?id=86742
Reviewed by Vsevolod Vlasov.
Simple refactoring.
* inspector/front-end/JavaScriptSourceFrame.js:
(WebInspector.JavaScriptSourceFrame):
(WebInspector.JavaScriptSourceFrame.prototype.commitEditing):
(WebInspector.JavaScriptSourceFrame.prototype.afterTextChanged):
(WebInspector.JavaScriptSourceFrame.prototype._didEditContent):
* inspector/front-end/ResourceView.js:
(WebInspector.ResourceSourceFrame):
(WebInspector.ResourceSourceFrame.prototype.get resource):
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel.prototype._createSourceFrame):
* inspector/front-end/SourceFrame.js:
(WebInspector.SourceFrame):
(WebInspector.SourceFrame.prototype._ensureContentLoaded):
* inspector/front-end/StylesPanel.js:
(WebInspector.StyleSourceFrame):
* inspector/front-end/UISourceCode.js:
(WebInspector.UISourceCode.prototype.contentURL):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@117455
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-05-17 Pavel Feldman <pfeldman@chromium.org>
+
+ Web Inspector: create SourceFrames with content providers.
+ https://bugs.webkit.org/show_bug.cgi?id=86742
+
+ Reviewed by Vsevolod Vlasov.
+
+ Simple refactoring.
+
+ * inspector/front-end/JavaScriptSourceFrame.js:
+ (WebInspector.JavaScriptSourceFrame):
+ (WebInspector.JavaScriptSourceFrame.prototype.commitEditing):
+ (WebInspector.JavaScriptSourceFrame.prototype.afterTextChanged):
+ (WebInspector.JavaScriptSourceFrame.prototype._didEditContent):
+ * inspector/front-end/ResourceView.js:
+ (WebInspector.ResourceSourceFrame):
+ (WebInspector.ResourceSourceFrame.prototype.get resource):
+ * inspector/front-end/ScriptsPanel.js:
+ (WebInspector.ScriptsPanel.prototype._createSourceFrame):
+ * inspector/front-end/SourceFrame.js:
+ (WebInspector.SourceFrame):
+ (WebInspector.SourceFrame.prototype._ensureContentLoaded):
+ * inspector/front-end/StylesPanel.js:
+ (WebInspector.StyleSourceFrame):
+ * inspector/front-end/UISourceCode.js:
+ (WebInspector.UISourceCode.prototype.contentURL):
+
2012-05-17 Yury Semikhatsky <yurys@chromium.org>
Web Inspector: error when expanding an HTMLAllCollection object in the console
for (var i = 0; i < locations.length; ++i)
this._breakpointAdded({data:locations[i]});
- WebInspector.SourceFrame.call(this, uiSourceCode.url);
+ WebInspector.SourceFrame.call(this, uiSourceCode);
this._popoverHelper = new WebInspector.ObjectPopoverHelper(this.textViewer.element,
this._getPopoverAnchor.bind(this), this._resolveObjectForPopover.bind(this), this._onHidePopover.bind(this), true);
},
/**
- * @param {function(?string, boolean, string)} callback
- */
- requestContent: function(callback)
- {
- /**
- * @param {?string} content
- * @param {boolean} contentEncoded
- * @param {string} mimeType
- */
- function mycallback(content, contentEncoded, mimeType)
- {
- this._originalContent = content;
- callback(content, contentEncoded, mimeType);
- }
- this._uiSourceCode.requestContent(mycallback.bind(this));
- },
-
- /**
* @return {boolean}
*/
canEditSource: function()
this._editingContent = true;
if (!this._uiSourceCode.isDirty())
return;
- this._uiSourceCode.commitWorkingCopy(this._didEditContent.bind(this, text));
+ this._uiSourceCode.commitWorkingCopy(this._didEditContent.bind(this));
},
/**
{
this._uiSourceCode.setWorkingCopy(this.textModel.text);
if (!this._uiSourceCode.isDirty())
- this._didEditContent(this._originalContent, null);
+ this._didEditContent(null);
},
beforeTextChanged: function()
WebInspector.SourceFrame.prototype.beforeTextChanged.call(this);
},
- _didEditContent: function(content, error)
+ _didEditContent: function(error)
{
delete this._editingContent;
return;
}
- this._originalContent = content;
-
// Restore all muted breakpoints.
for (var lineNumber = 0; lineNumber < this.textModel.linesCount; ++lineNumber) {
var breakpointDecoration = this.textModel.getAttribute(lineNumber, "breakpoint");
WebInspector.ResourceSourceFrame = function(resource)
{
this._resource = resource;
- WebInspector.SourceFrame.call(this, resource.url);
+ WebInspector.SourceFrame.call(this, resource);
this._resource.addEventListener(WebInspector.Resource.Events.RevisionAdded, this._contentChanged, this);
}
return this._resource;
},
- /**
- * @param {function(?string,boolean,string)} callback
- */
- requestContent: function(callback)
- {
- /**
- * @param {?string} content
- * @param {boolean} contentEncoded
- * @param {string} mimeType
- */
- function callbackWrapper(content, contentEncoded, mimeType)
- {
- callback(content, contentEncoded, mimeType);
- }
- this.resource.requestContent(callbackWrapper.bind(this));
- },
-
_contentChanged: function(event)
{
this.setContent(this._resource.content, false, this._resource.canonicalMimeType());
sourceFrame = new WebInspector.StyleSourceFrame(uiSourceCode);
else {
console.assert(false, "Unknown UISourceCode type");
- sourceFrame = new WebInspector.SourceFrame(uiSourceCode.url);
+ sourceFrame = new WebInspector.SourceFrame(uiSourceCode);
}
this._sourceFramesByUISourceCode.put(uiSourceCode, sourceFrame);
/**
* @extends {WebInspector.View}
* @constructor
+ * @param {WebInspector.ContentProvider} contentProvider
*/
-WebInspector.SourceFrame = function(url)
+WebInspector.SourceFrame = function(contentProvider)
{
WebInspector.View.call(this);
this.element.addStyleClass("script-view");
- this._url = url;
+ this._url = contentProvider.contentURL();
+ this._contentProvider = contentProvider;
this._textModel = new WebInspector.TextEditorModel();
{
if (!this._contentRequested) {
this._contentRequested = true;
- this.requestContent(this.setContent.bind(this));
+ this._contentProvider.requestContent(this.setContent.bind(this));
}
},
/**
- * @param {function(?string, boolean, string)} callback
- */
- requestContent: function(callback)
- {
- },
-
- /**
* @param {TextDiff} diffData
*/
markDiff: function(diffData)
{
this._resource = styleSource._resource;
this._styleSource = styleSource;
- WebInspector.SourceFrame.call(this, this._resource.url);
+ WebInspector.SourceFrame.call(this, this._styleSource);
this._resource.addEventListener(WebInspector.Resource.Events.RevisionAdded, this._contentChanged, this);
}
},
/**
- * @param {function(?string,boolean,string)} callback
- */
- requestContent: function(callback)
- {
- this._styleSource.requestContent(callback);
- },
-
- /**
* @param {string} text
*/
commitEditing: function(text)
/**
* @constructor
* @extends {WebInspector.Object}
+ * @implements {WebInspector.ContentProvider}
* @param {string} url
* @param {WebInspector.ContentProvider} contentProvider
* @param {WebInspector.SourceMapping=} sourceMapping
},
/**
+ * @return {?string}
+ */
+ contentURL: function()
+ {
+ return this._url;
+ },
+
+ /**
* @param {function(?string,boolean,string)} callback
*/
requestContent: function(callback)