Diff
Modified: trunk/LayoutTests/ChangeLog (117599 => 117600)
--- trunk/LayoutTests/ChangeLog 2012-05-18 15:57:26 UTC (rev 117599)
+++ trunk/LayoutTests/ChangeLog 2012-05-18 16:10:34 UTC (rev 117600)
@@ -1,3 +1,16 @@
+2012-05-18 Vsevolod Vlasov <[email protected]>
+
+ Web Inspector: Add resource to UISourceCode constructor.
+ https://bugs.webkit.org/show_bug.cgi?id=86853
+
+ Reviewed by Pavel Feldman.
+
+ * inspector/debugger/breakpoint-manager.html:
+ * inspector/debugger/scripts-file-selector.html:
+ * inspector/debugger/scripts-panel.html:
+ * inspector/debugger/scripts-sorting.html:
+ * inspector/debugger/ui-source-code.html:
+
2012-05-18 Yury Semikhatsky <[email protected]>
Web Inspector: error when expanding an HTMLAllCollection object in the console
Modified: trunk/LayoutTests/inspector/debugger/breakpoint-manager.html (117599 => 117600)
--- trunk/LayoutTests/inspector/debugger/breakpoint-manager.html 2012-05-18 15:57:26 UTC (rev 117599)
+++ trunk/LayoutTests/inspector/debugger/breakpoint-manager.html 2012-05-18 16:10:34 UTC (rev 117600)
@@ -136,7 +136,7 @@
{
breakpointManager._debuggerModel._addScript(url, url);
InspectorTest.addResult(" Adding UISourceCode: " + url + ")");
- var uiSourceCode = new WebInspector._javascript_Source(url, null, defaultMapping, false);
+ var uiSourceCode = new WebInspector._javascript_Source(url, null, null, defaultMapping, false);
uiSourceCodes[url] = uiSourceCode;
breakpointManager.restoreBreakpoints(uiSourceCode);
return uiSourceCode;
Modified: trunk/LayoutTests/inspector/debugger/scripts-file-selector.html (117599 => 117600)
--- trunk/LayoutTests/inspector/debugger/scripts-file-selector.html 2012-05-18 15:57:26 UTC (rev 117599)
+++ trunk/LayoutTests/inspector/debugger/scripts-file-selector.html 2012-05-18 16:10:34 UTC (rev 117600)
@@ -20,7 +20,7 @@
function addUISourceCode(url, isContentScript)
{
- var uiSourceCode = new WebInspector.UISourceCode(url, contentProvider, null);
+ var uiSourceCode = new WebInspector.UISourceCode(url, null, contentProvider, null);
uiSourceCode.isContentScript = isContentScript;
navigatorFileSelector.addUISourceCode(uiSourceCode);
}
Modified: trunk/LayoutTests/inspector/debugger/scripts-panel.html (117599 => 117600)
--- trunk/LayoutTests/inspector/debugger/scripts-panel.html 2012-05-18 15:57:26 UTC (rev 117599)
+++ trunk/LayoutTests/inspector/debugger/scripts-panel.html 2012-05-18 16:10:34 UTC (rev 117600)
@@ -51,7 +51,7 @@
}
function createUISouceCode(url)
{
- var uiSourceCode = new WebInspector._javascript_Source(url, contentProvider, null, false);
+ var uiSourceCode = new WebInspector._javascript_Source(url, null, contentProvider, null, false);
uiSourceCode.requestContent = function(callback)
{
InspectorTest.addResult("Source requested for " + url);
Modified: trunk/LayoutTests/inspector/debugger/scripts-sorting.html (117599 => 117600)
--- trunk/LayoutTests/inspector/debugger/scripts-sorting.html 2012-05-18 15:57:26 UTC (rev 117599)
+++ trunk/LayoutTests/inspector/debugger/scripts-sorting.html 2012-05-18 16:10:34 UTC (rev 117600)
@@ -20,7 +20,7 @@
function addUISourceCode(url, isContentScript)
{
- var uiSourceCode = new WebInspector.UISourceCode(url, contentProvider, null);
+ var uiSourceCode = new WebInspector.UISourceCode(url, null, contentProvider, null);
uiSourceCode.isContentScript = isContentScript;
navigatorFileSelector.addUISourceCode(uiSourceCode);
}
Modified: trunk/LayoutTests/inspector/debugger/ui-source-code.html (117599 => 117600)
--- trunk/LayoutTests/inspector/debugger/ui-source-code.html 2012-05-18 15:57:26 UTC (rev 117599)
+++ trunk/LayoutTests/inspector/debugger/ui-source-code.html 2012-05-18 16:10:34 UTC (rev 117600)
@@ -17,7 +17,7 @@
InspectorTest.runTestSuite([
function testUISourceCode(next)
{
- var uiSourceCode = new WebInspector.UISourceCode("url", contentProvider);
+ var uiSourceCode = new WebInspector.UISourceCode("url", null, contentProvider);
function didRequestContent(callNumber, content, contentEncoded, mimeType)
{
InspectorTest.addResult("Callback " + callNumber + " is invoked.");
Modified: trunk/Source/WebCore/ChangeLog (117599 => 117600)
--- trunk/Source/WebCore/ChangeLog 2012-05-18 15:57:26 UTC (rev 117599)
+++ trunk/Source/WebCore/ChangeLog 2012-05-18 16:10:34 UTC (rev 117600)
@@ -1,3 +1,38 @@
+2012-05-18 Vsevolod Vlasov <[email protected]>
+
+ Web Inspector: Add resource to UISourceCode constructor.
+ https://bugs.webkit.org/show_bug.cgi?id=86853
+
+ Reviewed by Pavel Feldman.
+
+ This is a first step of merging resource revision support into UISourceCode.
+
+ * inspector/front-end/CompilerScriptMapping.js:
+ * inspector/front-end/DebuggerResourceBinding.js:
+ (WebInspector.DebuggerResourceBinding.setScriptSource.didEditScriptSource):
+ (WebInspector.DebuggerResourceBinding.setScriptSource):
+ * inspector/front-end/DebuggerScriptMapping.js:
+ (WebInspector.DebuggerScriptMapping.prototype._debuggerReset):
+ * inspector/front-end/_javascript_Source.js:
+ * inspector/front-end/RawSourceCode.js:
+ (WebInspector.RawSourceCode.prototype._createUISourceCode):
+ * inspector/front-end/ResourceScriptMapping.js:
+ (WebInspector.ResourceScriptMapping.prototype.addScript):
+ * inspector/front-end/Script.js:
+ (WebInspector.Script.prototype.isAnonymousScript):
+ * inspector/front-end/ScriptSnippetModel.js:
+ (WebInspector.ScriptSnippetModel.prototype._createUISourceCodeForScript):
+ (WebInspector.SnippetJavaScriptSource):
+ * inspector/front-end/StylesPanel.js:
+ (WebInspector.StyleSource):
+ (WebInspector.StyleSourceFrame):
+ (WebInspector.StyleSourceFrame.prototype.commitEditing):
+ (WebInspector.StyleSourceFrame.prototype.afterTextChanged):
+ (WebInspector.StyleSourceFrame.prototype._contentChanged):
+ * inspector/front-end/UISourceCode.js:
+ (WebInspector.UISourceCode):
+ (WebInspector.UISourceCode.prototype.resource):
+
2012-05-18 Yury Semikhatsky <[email protected]>
Web Inspector: error when expanding an HTMLAllCollection object in the console
Modified: trunk/Source/WebCore/inspector/front-end/CompilerScriptMapping.js (117599 => 117600)
--- trunk/Source/WebCore/inspector/front-end/CompilerScriptMapping.js 2012-05-18 15:57:26 UTC (rev 117599)
+++ trunk/Source/WebCore/inspector/front-end/CompilerScriptMapping.js 2012-05-18 16:10:34 UTC (rev 117600)
@@ -118,7 +118,7 @@
contentProvider = new WebInspector.StaticContentProvider(WebInspector.resourceTypes.Script, sourceContent);
else
contentProvider = new WebInspector.CompilerSourceMappingContentProvider(sourceURL);
- var uiSourceCode = new WebInspector._javascript_Source(sourceURL, contentProvider, this, false);
+ var uiSourceCode = new WebInspector._javascript_Source(sourceURL, null, contentProvider, this, false);
uiSourceCode.isContentScript = script.isContentScript;
this._uiSourceCodeByURL[sourceURL] = uiSourceCode;
this._sourceMapForUISourceCode.put(uiSourceCode, sourceMap);
Modified: trunk/Source/WebCore/inspector/front-end/DebuggerResourceBinding.js (117599 => 117600)
--- trunk/Source/WebCore/inspector/front-end/DebuggerResourceBinding.js 2012-05-18 15:57:26 UTC (rev 117599)
+++ trunk/Source/WebCore/inspector/front-end/DebuggerResourceBinding.js 2012-05-18 16:10:34 UTC (rev 117600)
@@ -60,7 +60,7 @@
return;
}
- var resource = WebInspector.resourceForURL(script.sourceURL);
+ var resource = uiSourceCode.resource();
if (resource)
resource.addRevision(newSource);
@@ -77,7 +77,7 @@
*/
canSetContent: function(resource)
{
- var uiSourceCode = this._uiSourceCodeForResource(resource);
+ var uiSourceCode = WebInspector._javascript_Source._javascript_SourceForResource.get(resource);
return !!uiSourceCode && uiSourceCode.isEditable();
},
@@ -92,7 +92,7 @@
if (!majorChange)
return;
- var uiSourceCode = this._uiSourceCodeForResource(resource);
+ var uiSourceCode = WebInspector._javascript_Source._javascript_SourceForResource.get(resource);
if (!uiSourceCode) {
userCallback("Resource is not editable");
return;
@@ -102,20 +102,6 @@
},
/**
- * @param {WebInspector.Resource} resource
- * @return {WebInspector.UISourceCode}
- */
- _uiSourceCodeForResource: function(resource)
- {
- var uiSourceCodes = this._uiSourceCodeProvider.uiSourceCodes();
- for (var i = 0; i < uiSourceCodes.length; ++i) {
- if (uiSourceCodes[i].url ="" resource.url)
- return uiSourceCodes[i];
- }
- return null;
- },
-
- /**
* @param {WebInspector.UISourceCode} uiSourceCode
* @param {string} content
* @param {function(?string)} userCallback
Modified: trunk/Source/WebCore/inspector/front-end/DebuggerScriptMapping.js (117599 => 117600)
--- trunk/Source/WebCore/inspector/front-end/DebuggerScriptMapping.js 2012-05-18 15:57:26 UTC (rev 117599)
+++ trunk/Source/WebCore/inspector/front-end/DebuggerScriptMapping.js 2012-05-18 16:10:34 UTC (rev 117600)
@@ -87,6 +87,7 @@
_debuggerReset: function()
{
+ WebInspector._javascript_Source._javascript_SourceForResource.clear();
for (var i = 0; i < this._mappings.length; ++i)
this._mappings[i].reset();
}
Modified: trunk/Source/WebCore/inspector/front-end/_javascript_Source.js (117599 => 117600)
--- trunk/Source/WebCore/inspector/front-end/_javascript_Source.js 2012-05-18 15:57:26 UTC (rev 117599)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_Source.js 2012-05-18 16:10:34 UTC (rev 117600)
@@ -32,12 +32,13 @@
* @constructor
* @extends {WebInspector.UISourceCode}
* @param {string} url
+ * @param {WebInspector.Resource} resource
* @param {WebInspector.ContentProvider} contentProvider
* @param {WebInspector.SourceMapping} sourceMapping
*/
-WebInspector._javascript_Source = function(url, contentProvider, sourceMapping, isEditable)
+WebInspector._javascript_Source = function(url, resource, contentProvider, sourceMapping, isEditable)
{
- WebInspector.UISourceCode.call(this, url, contentProvider, sourceMapping);
+ WebInspector.UISourceCode.call(this, url, resource, contentProvider, sourceMapping);
this._isEditable = isEditable;
this._formatterMapping = new WebInspector.IdentityFormatterSourceMapping();
@@ -46,8 +47,12 @@
if (!this._formatted)
WebInspector.breakpointManager.restoreBreakpoints(this);
}.bind(this), 0);
+ if (resource)
+ WebInspector._javascript_Source._javascript_SourceForResource.put(resource, this);
}
+WebInspector._javascript_Source._javascript_SourceForResource = new Map();
+
WebInspector._javascript_Source.prototype = {
/**
* @param {?string} content
Modified: trunk/Source/WebCore/inspector/front-end/RawSourceCode.js (117599 => 117600)
--- trunk/Source/WebCore/inspector/front-end/RawSourceCode.js 2012-05-18 15:57:26 UTC (rev 117599)
+++ trunk/Source/WebCore/inspector/front-end/RawSourceCode.js 2012-05-18 16:10:34 UTC (rev 117600)
@@ -100,7 +100,7 @@
else
contentProvider = new WebInspector.ConcatenatedScriptsContentProvider(this._scripts);
- var uiSourceCode = new WebInspector._javascript_Source(this.url, contentProvider, this._sourceMapping, isStandaloneScript);
+ var uiSourceCode = new WebInspector._javascript_Source(this.url, this._resource, contentProvider, this._sourceMapping, isStandaloneScript);
uiSourceCode.isContentScript = this.isContentScript;
return uiSourceCode;
},
Modified: trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js (117599 => 117600)
--- trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js 2012-05-18 15:57:26 UTC (rev 117599)
+++ trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js 2012-05-18 16:10:34 UTC (rev 117600)
@@ -87,30 +87,27 @@
{
var resource = null;
var request = null;
- var isInlineScript = false;
- if (script.isInlineScript()) {
- // First lookup the resource that has already been loaded. We are only interested in Document resources.
+ if (!script.isAnonymousScript()) {
+ // First lookup the resource that has already been loaded.
resource = WebInspector.resourceForURL(script.sourceURL);
- if (resource && resource.type !== WebInspector.resourceTypes.Document)
- resource = null;
// Ignore resource in case it has not yet finished loading.
if (resource && resource.request && !resource.request.finished)
resource = null;
if (!resource) {
- // When there is no resource, lookup in-flight requests of type Document.
+ // When there is no resource, lookup in-flight requests.
request = WebInspector.networkManager.inflightRequestForURL(script.sourceURL);
- if (request && request.type !== WebInspector.resourceTypes.Document)
- request = null;
}
- // If either of these exists, we bind script to the resource.
- if (request || resource) {
- isInlineScript = true;
- var rawSourceCode = this._rawSourceCodeForDocumentURL[script.sourceURL];
- if (rawSourceCode) {
- rawSourceCode.addScript(script);
- this._bindScriptToRawSourceCode(script, rawSourceCode);
- return;
- }
+ }
+ console.assert(!resource || !request);
+
+ var isInlineScript = script.isInlineScript() && (request || resource);
+ // If either of these exists, we bind script to the resource.
+ if (isInlineScript) {
+ var rawSourceCode = this._rawSourceCodeForDocumentURL[script.sourceURL];
+ if (rawSourceCode) {
+ rawSourceCode.addScript(script);
+ this._bindScriptToRawSourceCode(script, rawSourceCode);
+ return;
}
}
Modified: trunk/Source/WebCore/inspector/front-end/Script.js (117599 => 117600)
--- trunk/Source/WebCore/inspector/front-end/Script.js 2012-05-18 15:57:26 UTC (rev 117599)
+++ trunk/Source/WebCore/inspector/front-end/Script.js 2012-05-18 16:10:34 UTC (rev 117600)
@@ -159,6 +159,14 @@
},
/**
+ * @return {boolean}
+ */
+ isAnonymousScript: function()
+ {
+ return !this.sourceURL;
+ },
+
+ /**
* @param {DebuggerAgent.Location} rawLocation
* @return {WebInspector.UILocation}
*/
Modified: trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js (117599 => 117600)
--- trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js 2012-05-18 15:57:26 UTC (rev 117599)
+++ trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js 2012-05-18 16:10:34 UTC (rev 117600)
@@ -215,7 +215,7 @@
*/
_createUISourceCodeForScript: function(script)
{
- var uiSourceCode = new WebInspector._javascript_Source(script.sourceURL, script, this._snippetScriptMapping, false);
+ var uiSourceCode = new WebInspector._javascript_Source(script.sourceURL, null, script, this._snippetScriptMapping, false);
uiSourceCode.isSnippetEvaluation = true;
this._uiSourceCodeForScriptId[script.scriptId] = uiSourceCode;
this._scriptForUISourceCode.put(uiSourceCode, script);
@@ -301,7 +301,7 @@
*/
WebInspector.SnippetJavaScriptSource = function(snippetId, snippetName, contentProvider, scriptSnippetModel)
{
- WebInspector._javascript_Source.call(this, snippetName, contentProvider, scriptSnippetModel.scriptMapping, true);
+ WebInspector._javascript_Source.call(this, snippetName, null, contentProvider, scriptSnippetModel.scriptMapping, true);
this._snippetId = snippetId;
this._scriptSnippetModel = scriptSnippetModel;
this.isSnippet = true;
Modified: trunk/Source/WebCore/inspector/front-end/StylesPanel.js (117599 => 117600)
--- trunk/Source/WebCore/inspector/front-end/StylesPanel.js 2012-05-18 15:57:26 UTC (rev 117599)
+++ trunk/Source/WebCore/inspector/front-end/StylesPanel.js 2012-05-18 16:10:34 UTC (rev 117600)
@@ -94,8 +94,7 @@
*/
WebInspector.StyleSource = function(resource)
{
- WebInspector.UISourceCode.call(this, resource.url, resource);
- this._resource = resource;
+ WebInspector.UISourceCode.call(this, resource.url, resource, resource);
}
WebInspector.StyleSource.prototype = {
@@ -110,10 +109,9 @@
*/
WebInspector.StyleSourceFrame = function(styleSource)
{
- this._resource = styleSource._resource;
this._styleSource = styleSource;
WebInspector.SourceFrame.call(this, this._styleSource);
- this._resource.addEventListener(WebInspector.Resource.Events.RevisionAdded, this._contentChanged, this);
+ this._styleSource.resource().addEventListener(WebInspector.Resource.Events.RevisionAdded, this._contentChanged, this);
}
WebInspector.StyleSourceFrame.prototype = {
@@ -130,7 +128,7 @@
*/
commitEditing: function(text)
{
- this._resource.setContent(text, true, function() {});
+ this._styleSource.resource().setContent(text, true, function() {});
},
afterTextChanged: function(oldRange, newRange)
@@ -139,7 +137,7 @@
{
var text = this._textModel.text;
this._styleSource.setWorkingCopy(text);
- this._resource.setContent(text, false, function() {});
+ this._styleSource.resource().setContent(text, false, function() {});
}
const updateTimeout = 200;
this._incrementalUpdateTimer = setTimeout(commitIncrementalEdit.bind(this), updateTimeout);
@@ -154,8 +152,8 @@
_contentChanged: function(event)
{
- this._styleSource.contentChanged(this._resource.content || "");
- this.setContent(this._resource.content, false, "text/stylesheet");
+ this._styleSource.contentChanged(this._styleSource.resource().content || "");
+ this.setContent(this._styleSource.resource().content, false, "text/stylesheet");
}
}
Modified: trunk/Source/WebCore/inspector/front-end/UISourceCode.js (117599 => 117600)
--- trunk/Source/WebCore/inspector/front-end/UISourceCode.js 2012-05-18 15:57:26 UTC (rev 117599)
+++ trunk/Source/WebCore/inspector/front-end/UISourceCode.js 2012-05-18 16:10:34 UTC (rev 117600)
@@ -34,12 +34,14 @@
* @extends {WebInspector.Object}
* @implements {WebInspector.ContentProvider}
* @param {string} url
+ * @param {WebInspector.Resource} resource
* @param {WebInspector.ContentProvider} contentProvider
* @param {WebInspector.SourceMapping=} sourceMapping
*/
-WebInspector.UISourceCode = function(url, contentProvider, sourceMapping)
+WebInspector.UISourceCode = function(url, resource, contentProvider, sourceMapping)
{
this._url = url;
+ this._resource = resource;
this._parsedURL = new WebInspector.ParsedURL(url);
this._contentProvider = contentProvider;
this._sourceMapping = sourceMapping;
@@ -84,6 +86,14 @@
},
/**
+ * @return {WebInspector.Resource}
+ */
+ resource: function()
+ {
+ return this._resource;
+ },
+
+ /**
* @return {WebInspector.ParsedURL}
*/
get parsedURL()