Diff
Deleted: trunk/LayoutTests/inspector/debugger/source-file-expected.txt (96312 => 96313)
--- trunk/LayoutTests/inspector/debugger/source-file-expected.txt 2011-09-29 08:36:04 UTC (rev 96312)
+++ trunk/LayoutTests/inspector/debugger/source-file-expected.txt 2011-09-29 08:44:57 UTC (rev 96313)
@@ -1,13 +0,0 @@
-Tests mapping between raw locations and ui locations.
-
-
-Running: testPlainConvertLocation
-
-Running: testConcatenatedConvertLocation
-
-Running: testFormattedConvertLocation
-
-Running: testConcatenatedFormattedConvertLocation
-
-Running: testUISourceCodeAdded
-
Modified: trunk/Source/WebCore/ChangeLog (96312 => 96313)
--- trunk/Source/WebCore/ChangeLog 2011-09-29 08:36:04 UTC (rev 96312)
+++ trunk/Source/WebCore/ChangeLog 2011-09-29 08:44:57 UTC (rev 96313)
@@ -1,3 +1,29 @@
+2011-09-29 Pavel Podivilov <podivi...@chromium.org>
+
+ Web Inspector: split SourceFile.js into RawSourceCode.js and UISourceCodeContentProviders.js.
+ https://bugs.webkit.org/show_bug.cgi?id=69068
+
+ Reviewed by Yury Semikhatsky.
+
+ * WebCore.gypi:
+ * WebCore.vcproj/WebCore.vcproj:
+ * inspector/front-end/RawSourceCode.js: Renamed from Source/WebCore/inspector/front-end/SourceFile.js.
+ (WebInspector.RawSourceCode): Moved from SourceFile.js.
+ (WebInspector.UILocation): Moved from SourceFile.js.
+ * inspector/front-end/UISourceCodeContentProviders.js: Added. Moved ContentProvider implementations from SourceFile.js
+ (WebInspector.ScriptContentProvider):
+ (WebInspector.ScriptContentProvider.prototype.requestContent):
+ (WebInspector.ConcatenatedScriptsContentProvider):
+ (WebInspector.ConcatenatedScriptsContentProvider.prototype.requestContent):
+ (WebInspector.ConcatenatedScriptsContentProvider.prototype._concatenateScriptsContent.appendChunk):
+ (WebInspector.ConcatenatedScriptsContentProvider.prototype._concatenateScriptsContent):
+ (WebInspector.ResourceContentProvider):
+ (WebInspector.ResourceContentProvider.prototype.requestContent):
+ (WebInspector.StaticContentProvider):
+ (WebInspector.StaticContentProvider.prototype.requestContent):
+ * inspector/front-end/WebKit.qrc:
+ * inspector/front-end/inspector.html:
+
2011-09-29 Philippe Normand <pnorm...@igalia.com>
[GStreamer] 2 flaky media tests
Modified: trunk/Source/WebCore/WebCore.gypi (96312 => 96313)
--- trunk/Source/WebCore/WebCore.gypi 2011-09-29 08:36:04 UTC (rev 96312)
+++ trunk/Source/WebCore/WebCore.gypi 2011-09-29 08:44:57 UTC (rev 96313)
@@ -6225,6 +6225,7 @@
'inspector/front-end/ConsolePanel.js',
'inspector/front-end/ConsoleView.js',
'inspector/front-end/_javascript_ContextManager.js',
+ 'inspector/front-end/ContentProviders.js',
'inspector/front-end/ContextMenu.js',
'inspector/front-end/CookieItemsView.js',
'inspector/front-end/CookieParser.js',
@@ -6288,6 +6289,7 @@
'inspector/front-end/ProfileView.js',
'inspector/front-end/PropertiesSection.js',
'inspector/front-end/PropertiesSidebarPane.js',
+ 'inspector/front-end/RawSourceCode.js',
'inspector/front-end/RemoteObject.js',
'inspector/front-end/Resource.js',
'inspector/front-end/ResourceCategory.js',
@@ -6316,7 +6318,6 @@
'inspector/front-end/SidebarTreeElement.js',
'inspector/front-end/SoftContextMenu.js',
'inspector/front-end/SourceCSSTokenizer.js',
- 'inspector/front-end/SourceFile.js',
'inspector/front-end/SourceFrame.js',
'inspector/front-end/SourceHTMLTokenizer.js',
'inspector/front-end/SourceJavaScriptTokenizer.js',
Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (96312 => 96313)
--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2011-09-29 08:36:04 UTC (rev 96312)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2011-09-29 08:44:57 UTC (rev 96313)
@@ -69117,6 +69117,10 @@
>
</File>
<File
+ RelativePath="..\inspector\front-end\ContentProviders.js"
+ >
+ </File>
+ <File
RelativePath="..\inspector\front-end\ContextMenu.js"
>
</File>
@@ -69429,6 +69433,10 @@
>
</File>
<File
+ RelativePath="..\inspector\front-end\RawSourceCode.js"
+ >
+ </File>
+ <File
RelativePath="..\inspector\front-end\RemoteObject.js"
>
</File>
@@ -69541,10 +69549,6 @@
>
</File>
<File
- RelativePath="..\inspector\front-end\SourceFile.js"
- >
- </File>
- <File
RelativePath="..\inspector\front-end\SourceFrame.js"
>
</File>
Added: trunk/Source/WebCore/inspector/front-end/ContentProviders.js (0 => 96313)
--- trunk/Source/WebCore/inspector/front-end/ContentProviders.js (rev 0)
+++ trunk/Source/WebCore/inspector/front-end/ContentProviders.js 2011-09-29 08:44:57 UTC (rev 96313)
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @constructor
+ * @implements {WebInspector.ContentProvider}
+ */
+WebInspector.ScriptContentProvider = function(script)
+{
+ this._mimeType = "text/_javascript_";
+ this._script = script;
+};
+
+WebInspector.ScriptContentProvider.prototype = {
+ requestContent: function(callback)
+ {
+ function didRequestSource(source)
+ {
+ callback(this._mimeType, source);
+ }
+ this._script.requestSource(didRequestSource.bind(this));
+ }
+}
+
+WebInspector.ScriptContentProvider.prototype.__proto__ = WebInspector.ContentProvider.prototype;
+
+/**
+ * @constructor
+ * @implements {WebInspector.ContentProvider}
+ */
+WebInspector.ConcatenatedScriptsContentProvider = function(scripts)
+{
+ this._mimeType = "text/html";
+ this._scripts = scripts;
+};
+
+WebInspector.ConcatenatedScriptsContentProvider.prototype = {
+ requestContent: function(callback)
+ {
+ var scripts = this._scripts.slice();
+ scripts.sort(function(x, y) { return x.lineOffset - y.lineOffset || x.columnOffset - y.columnOffset; });
+ var sources = [];
+ function didRequestSource(source)
+ {
+ sources.push(source);
+ if (sources.length == scripts.length)
+ callback(this._mimeType, this._concatenateScriptsContent(scripts, sources));
+ }
+ for (var i = 0; i < scripts.length; ++i)
+ scripts[i].requestSource(didRequestSource.bind(this));
+ },
+
+ _concatenateScriptsContent: function(scripts, sources)
+ {
+ var content = "";
+ var lineNumber = 0;
+ var columnNumber = 0;
+
+ function appendChunk(chunk)
+ {
+ content += chunk;
+ var lineEndings = chunk.lineEndings();
+ var lineCount = lineEndings.length;
+ if (lineCount === 1)
+ columnNumber += chunk.length;
+ else {
+ lineNumber += lineCount - 1;
+ columnNumber = lineEndings[lineCount - 1] - lineEndings[lineCount - 2] - 1;
+ }
+ }
+
+ var scriptOpenTag = "<script>";
+ var scriptCloseTag = "</script>";
+ for (var i = 0; i < scripts.length; ++i) {
+ if (lineNumber > scripts[i].lineOffset || (lineNumber === scripts[i].lineOffset && columnNumber > scripts[i].columnOffset - scriptOpenTag.length))
+ continue;
+
+ // Fill the gap with whitespace characters.
+ while (lineNumber < scripts[i].lineOffset)
+ appendChunk("\n");
+ while (columnNumber < scripts[i].columnOffset - scriptOpenTag.length)
+ appendChunk(" ");
+
+ // Add script tag.
+ appendChunk(scriptOpenTag);
+ appendChunk(sources[i]);
+ appendChunk(scriptCloseTag);
+ }
+
+ return content;
+ }
+}
+
+WebInspector.ConcatenatedScriptsContentProvider.prototype.__proto__ = WebInspector.ContentProvider.prototype;
+
+/**
+ * @constructor
+ * @implements {WebInspector.ContentProvider}
+ */
+WebInspector.ResourceContentProvider = function(resource)
+{
+ this._mimeType = resource.type === WebInspector.Resource.Type.Script ? "text/_javascript_" : "text/html";
+ this._resource = resource;
+};
+
+WebInspector.ResourceContentProvider.prototype = {
+ requestContent: function(callback)
+ {
+ function didRequestContent(content)
+ {
+ callback(this._mimeType, content);
+ }
+ this._resource.requestContent(didRequestContent.bind(this));
+ },
+
+ searchInContent: function(query, callback)
+ {
+ this._resource.searchInContent(query, callback);
+ }
+}
+
+WebInspector.ResourceContentProvider.prototype.__proto__ = WebInspector.ContentProvider.prototype;
+
+
+WebInspector.StaticContentProvider = function(mimeType, content)
+{
+ this._mimeType = mimeType;
+ this._content = content;
+};
+
+WebInspector.StaticContentProvider.prototype = {
+ requestContent: function(callback)
+ {
+ callback(this._mimeType, this._content);
+ }
+}
+
+WebInspector.StaticContentProvider.prototype.__proto__ = WebInspector.ContentProvider.prototype;
Property changes on: trunk/Source/WebCore/inspector/front-end/ContentProviders.js
___________________________________________________________________
Added: svn:eol-style
Copied: trunk/Source/WebCore/inspector/front-end/RawSourceCode.js (from rev 96312, trunk/Source/WebCore/inspector/front-end/SourceFile.js) (0 => 96313)
--- trunk/Source/WebCore/inspector/front-end/RawSourceCode.js (rev 0)
+++ trunk/Source/WebCore/inspector/front-end/RawSourceCode.js 2011-09-29 08:44:57 UTC (rev 96313)
@@ -0,0 +1,247 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// RawSourceCode represents _javascript_ resource or HTML resource with inlined scripts
+// as it came from network.
+
+/**
+ * @constructor
+ * @extends {WebInspector.Object}
+ */
+WebInspector.RawSourceCode = function(id, script, resource, formatter, formatted)
+{
+ this.id = id;
+ this.url = ""
+ this.isContentScript = script.isContentScript;
+ this._scripts = [script];
+ this._formatter = formatter;
+ this._formatted = formatted;
+ this._resource = resource;
+ this.messages = [];
+
+ this._useTemporaryContent = this._resource && !this._resource.finished;
+ this._hasNewScripts = true;
+ if (!this._useTemporaryContent)
+ this._updateSourceMapping();
+ else if (this._resource)
+ this._resource.addEventListener("finished", this._resourceFinished.bind(this));
+}
+
+WebInspector.RawSourceCode.Events = {
+ SourceMappingUpdated: "source-mapping-updated"
+}
+
+WebInspector.RawSourceCode.prototype = {
+ addScript: function(script)
+ {
+ this._scripts.push(script);
+ this._hasNewScripts = true;
+ },
+
+ get sourceMapping()
+ {
+ return this._sourceMapping;
+ },
+
+ setFormatted: function(formatted)
+ {
+ if (this._formatted === formatted)
+ return;
+ this._formatted = formatted;
+ this._updateSourceMapping();
+ },
+
+ contentEdited: function()
+ {
+ this._updateSourceMapping();
+ },
+
+ _resourceFinished: function()
+ {
+ this._useTemporaryContent = false;
+ this._updateSourceMapping();
+ },
+
+ _scriptForRawLocation: function(lineNumber, columnNumber)
+ {
+ var closestScript = this._scripts[0];
+ for (var i = 1; i < this._scripts.length; ++i) {
+ var script = this._scripts[i];
+ if (script.lineOffset > lineNumber || (script.lineOffset === lineNumber && script.columnOffset > columnNumber))
+ continue;
+ if (script.lineOffset > closestScript.lineOffset ||
+ (script.lineOffset === closestScript.lineOffset && script.columnOffset > closestScript.columnOffset))
+ closestScript = script;
+ }
+ return closestScript;
+ },
+
+ forceUpdateSourceMapping: function(script)
+ {
+ if (!this._useTemporaryContent || !this._hasNewScripts)
+ return;
+ this._hasNewScripts = false;
+ this._updateSourceMapping();
+ },
+
+ _updateSourceMapping: function()
+ {
+ if (this._updatingSourceMapping) {
+ this._updateNeeded = true;
+ return;
+ }
+ this._updatingSourceMapping = true;
+ this._updateNeeded = false;
+
+ var originalContentProvider = this._createContentProvider();
+ this._createSourceMapping(originalContentProvider, didCreateSourceMapping.bind(this));
+
+ function didCreateSourceMapping(contentProvider, mapping)
+ {
+ this._updatingSourceMapping = false;
+ if (!this._updateNeeded)
+ this._saveSourceMapping(contentProvider, mapping);
+ else
+ this._updateSourceMapping();
+ }
+ },
+
+ _createContentProvider: function()
+ {
+ if (this._resource && this._resource.finished)
+ return new WebInspector.ResourceContentProvider(this._resource);
+ if (this._scripts.length === 1 && !this._scripts[0].lineOffset && !this._scripts[0].columnOffset)
+ return new WebInspector.ScriptContentProvider(this._scripts[0]);
+ return new WebInspector.ConcatenatedScriptsContentProvider(this._scripts);
+ },
+
+ _createSourceMapping: function(originalContentProvider, callback)
+ {
+ if (!this._formatted) {
+ var uiSourceCode = new WebInspector.UISourceCode(this.id, this.url, this.isContentScript, this, originalContentProvider);
+ var sourceMapping = new WebInspector.RawSourceCode.PlainSourceMapping(this, uiSourceCode);
+ callback(sourceMapping);
+ return;
+ }
+
+ function didRequestContent(mimeType, content)
+ {
+ function didFormatContent(formattedContent, mapping)
+ {
+ var contentProvider = new WebInspector.StaticContentProvider(mimeType, formattedContent)
+ var uiSourceCode = new WebInspector.UISourceCode("deobfuscated:" + this.id, this.url, this.isContentScript, this, contentProvider);
+ var sourceMapping = new WebInspector.RawSourceCode.FormattedSourceMapping(this, uiSourceCode, mapping);
+ callback(sourceMapping);
+ }
+ this._formatter.formatContent(mimeType, content, didFormatContent.bind(this));
+ }
+ originalContentProvider.requestContent(didRequestContent.bind(this));
+ },
+
+ _saveSourceMapping: function(sourceMapping)
+ {
+ var oldUISourceCode;
+ if (this._sourceMapping)
+ oldUISourceCode = this._sourceMapping.uiSourceCode;
+ this._sourceMapping = sourceMapping;
+ this.dispatchEventToListeners(WebInspector.RawSourceCode.Events.SourceMappingUpdated, { oldUISourceCode: oldUISourceCode });
+ }
+}
+
+WebInspector.RawSourceCode.prototype.__proto__ = WebInspector.Object.prototype;
+
+
+/**
+ * @constructor
+ */
+WebInspector.RawSourceCode.PlainSourceMapping = function(rawSourceCode, uiSourceCode)
+{
+ this._rawSourceCode = rawSourceCode;
+ this._uiSourceCode = uiSourceCode;
+}
+
+WebInspector.RawSourceCode.PlainSourceMapping.prototype = {
+ rawLocationToUILocation: function(rawLocation)
+ {
+ return new WebInspector.UILocation(this._uiSourceCode, rawLocation.lineNumber, rawLocation.columnNumber);
+ },
+
+ uiLocationToRawLocation: function(lineNumber, columnNumber)
+ {
+ var rawLocation = { lineNumber: lineNumber, columnNumber: columnNumber };
+ rawLocation.scriptId = this._rawSourceCode._scriptForRawLocation(rawLocation.lineNumber, rawLocation.columnNumber).scriptId;
+ return rawLocation;
+ },
+
+ get uiSourceCode()
+ {
+ return this._uiSourceCode;
+ }
+}
+
+/**
+ * @constructor
+ */
+WebInspector.RawSourceCode.FormattedSourceMapping = function(rawSourceCode, uiSourceCode, mapping)
+{
+ this._rawSourceCode = rawSourceCode;
+ this._uiSourceCode = uiSourceCode;
+ this._mapping = mapping;
+}
+
+WebInspector.RawSourceCode.FormattedSourceMapping.prototype = {
+ rawLocationToUILocation: function(rawLocation)
+ {
+ var location = this._mapping.originalToFormatted(rawLocation);
+ return new WebInspector.UILocation(this._uiSourceCode, location.lineNumber, location.columnNumber);
+ },
+
+ uiLocationToRawLocation: function(lineNumber, columnNumber)
+ {
+ var rawLocation = this._mapping.formattedToOriginal({ lineNumber: lineNumber, columnNumber: columnNumber });
+ rawLocation.scriptId = this._rawSourceCode._scriptForRawLocation(rawLocation.lineNumber, rawLocation.columnNumber).scriptId;
+ return rawLocation;
+ },
+
+ get uiSourceCode()
+ {
+ return this._uiSourceCode;
+ }
+}
+
+/**
+ * @constructor
+ */
+WebInspector.UILocation = function(uiSourceCode, lineNumber, columnNumber)
+{
+ this.uiSourceCode = uiSourceCode;
+ this.lineNumber = lineNumber;
+ this.columnNumber = columnNumber;
+}
Property changes: trunk/Source/WebCore/inspector/front-end/RawSourceCode.js
Added: svn:eol-style
Deleted: trunk/Source/WebCore/inspector/front-end/SourceFile.js (96312 => 96313)
--- trunk/Source/WebCore/inspector/front-end/SourceFile.js 2011-09-29 08:36:04 UTC (rev 96312)
+++ trunk/Source/WebCore/inspector/front-end/SourceFile.js 2011-09-29 08:44:57 UTC (rev 96313)
@@ -1,385 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-// RawSourceCode represents _javascript_ resource or HTML resource with inlined scripts
-// as it came from network.
-
-/**
- * @constructor
- * @extends {WebInspector.Object}
- */
-WebInspector.RawSourceCode = function(id, script, resource, formatter, formatted)
-{
- this.id = id;
- this.url = ""
- this.isContentScript = script.isContentScript;
- this._scripts = [script];
- this._formatter = formatter;
- this._formatted = formatted;
- this._resource = resource;
- this.messages = [];
-
- this._useTemporaryContent = this._resource && !this._resource.finished;
- this._hasNewScripts = true;
- if (!this._useTemporaryContent)
- this._updateSourceMapping();
- else if (this._resource)
- this._resource.addEventListener("finished", this._resourceFinished.bind(this));
-}
-
-WebInspector.RawSourceCode.Events = {
- SourceMappingUpdated: "source-mapping-updated"
-}
-
-WebInspector.RawSourceCode.prototype = {
- addScript: function(script)
- {
- this._scripts.push(script);
- this._hasNewScripts = true;
- },
-
- get sourceMapping()
- {
- return this._sourceMapping;
- },
-
- setFormatted: function(formatted)
- {
- if (this._formatted === formatted)
- return;
- this._formatted = formatted;
- this._updateSourceMapping();
- },
-
- contentEdited: function()
- {
- this._updateSourceMapping();
- },
-
- _resourceFinished: function()
- {
- this._useTemporaryContent = false;
- this._updateSourceMapping();
- },
-
- _scriptForRawLocation: function(lineNumber, columnNumber)
- {
- var closestScript = this._scripts[0];
- for (var i = 1; i < this._scripts.length; ++i) {
- var script = this._scripts[i];
- if (script.lineOffset > lineNumber || (script.lineOffset === lineNumber && script.columnOffset > columnNumber))
- continue;
- if (script.lineOffset > closestScript.lineOffset ||
- (script.lineOffset === closestScript.lineOffset && script.columnOffset > closestScript.columnOffset))
- closestScript = script;
- }
- return closestScript;
- },
-
- forceUpdateSourceMapping: function(script)
- {
- if (!this._useTemporaryContent || !this._hasNewScripts)
- return;
- this._hasNewScripts = false;
- this._updateSourceMapping();
- },
-
- _updateSourceMapping: function()
- {
- if (this._updatingSourceMapping) {
- this._updateNeeded = true;
- return;
- }
- this._updatingSourceMapping = true;
- this._updateNeeded = false;
-
- var originalContentProvider = this._createContentProvider();
- this._createSourceMapping(originalContentProvider, didCreateSourceMapping.bind(this));
-
- function didCreateSourceMapping(contentProvider, mapping)
- {
- this._updatingSourceMapping = false;
- if (!this._updateNeeded)
- this._saveSourceMapping(contentProvider, mapping);
- else
- this._updateSourceMapping();
- }
- },
-
- _createContentProvider: function()
- {
- if (this._resource && this._resource.finished)
- return new WebInspector.ResourceContentProvider(this._resource);
- if (this._scripts.length === 1 && !this._scripts[0].lineOffset && !this._scripts[0].columnOffset)
- return new WebInspector.ScriptContentProvider(this._scripts[0]);
- return new WebInspector.ConcatenatedScriptsContentProvider(this._scripts);
- },
-
- _createSourceMapping: function(originalContentProvider, callback)
- {
- if (!this._formatted) {
- var uiSourceCode = new WebInspector.UISourceCode(this.id, this.url, this.isContentScript, this, originalContentProvider);
- var sourceMapping = new WebInspector.RawSourceCode.PlainSourceMapping(this, uiSourceCode);
- callback(sourceMapping);
- return;
- }
-
- function didRequestContent(mimeType, content)
- {
- function didFormatContent(formattedContent, mapping)
- {
- var contentProvider = new WebInspector.StaticContentProvider(mimeType, formattedContent)
- var uiSourceCode = new WebInspector.UISourceCode("deobfuscated:" + this.id, this.url, this.isContentScript, this, contentProvider);
- var sourceMapping = new WebInspector.RawSourceCode.FormattedSourceMapping(this, uiSourceCode, mapping);
- callback(sourceMapping);
- }
- this._formatter.formatContent(mimeType, content, didFormatContent.bind(this));
- }
- originalContentProvider.requestContent(didRequestContent.bind(this));
- },
-
- _saveSourceMapping: function(sourceMapping)
- {
- var oldUISourceCode;
- if (this._sourceMapping)
- oldUISourceCode = this._sourceMapping.uiSourceCode;
- this._sourceMapping = sourceMapping;
- this.dispatchEventToListeners(WebInspector.RawSourceCode.Events.SourceMappingUpdated, { oldUISourceCode: oldUISourceCode });
- }
-}
-
-WebInspector.RawSourceCode.prototype.__proto__ = WebInspector.Object.prototype;
-
-
-/**
- * @constructor
- */
-WebInspector.RawSourceCode.PlainSourceMapping = function(rawSourceCode, uiSourceCode)
-{
- this._rawSourceCode = rawSourceCode;
- this._uiSourceCode = uiSourceCode;
-}
-
-WebInspector.RawSourceCode.PlainSourceMapping.prototype = {
- rawLocationToUILocation: function(rawLocation)
- {
- return new WebInspector.UILocation(this._uiSourceCode, rawLocation.lineNumber, rawLocation.columnNumber);
- },
-
- uiLocationToRawLocation: function(lineNumber, columnNumber)
- {
- var rawLocation = { lineNumber: lineNumber, columnNumber: columnNumber };
- rawLocation.scriptId = this._rawSourceCode._scriptForRawLocation(rawLocation.lineNumber, rawLocation.columnNumber).scriptId;
- return rawLocation;
- },
-
- get uiSourceCode()
- {
- return this._uiSourceCode;
- }
-}
-
-/**
- * @constructor
- */
-WebInspector.RawSourceCode.FormattedSourceMapping = function(rawSourceCode, uiSourceCode, mapping)
-{
- this._rawSourceCode = rawSourceCode;
- this._uiSourceCode = uiSourceCode;
- this._mapping = mapping;
-}
-
-WebInspector.RawSourceCode.FormattedSourceMapping.prototype = {
- rawLocationToUILocation: function(rawLocation)
- {
- var location = this._mapping.originalToFormatted(rawLocation);
- return new WebInspector.UILocation(this._uiSourceCode, location.lineNumber, location.columnNumber);
- },
-
- uiLocationToRawLocation: function(lineNumber, columnNumber)
- {
- var rawLocation = this._mapping.formattedToOriginal({ lineNumber: lineNumber, columnNumber: columnNumber });
- rawLocation.scriptId = this._rawSourceCode._scriptForRawLocation(rawLocation.lineNumber, rawLocation.columnNumber).scriptId;
- return rawLocation;
- },
-
- get uiSourceCode()
- {
- return this._uiSourceCode;
- }
-}
-
-
-/**
- * @constructor
- */
-WebInspector.UILocation = function(uiSourceCode, lineNumber, columnNumber)
-{
- this.uiSourceCode = uiSourceCode;
- this.lineNumber = lineNumber;
- this.columnNumber = columnNumber;
-}
-
-
-/**
- * @constructor
- * @implements {WebInspector.ContentProvider}
- */
-WebInspector.ScriptContentProvider = function(script)
-{
- this._mimeType = "text/_javascript_";
- this._script = script;
-};
-
-WebInspector.ScriptContentProvider.prototype = {
- requestContent: function(callback)
- {
- function didRequestSource(source)
- {
- callback(this._mimeType, source);
- }
- this._script.requestSource(didRequestSource.bind(this));
- }
-}
-
-WebInspector.ScriptContentProvider.prototype.__proto__ = WebInspector.ContentProvider.prototype;
-
-/**
- * @constructor
- * @implements {WebInspector.ContentProvider}
- */
-WebInspector.ConcatenatedScriptsContentProvider = function(scripts)
-{
- this._mimeType = "text/html";
- this._scripts = scripts;
-};
-
-WebInspector.ConcatenatedScriptsContentProvider.prototype = {
- requestContent: function(callback)
- {
- var scripts = this._scripts.slice();
- scripts.sort(function(x, y) { return x.lineOffset - y.lineOffset || x.columnOffset - y.columnOffset; });
- var sources = [];
- function didRequestSource(source)
- {
- sources.push(source);
- if (sources.length == scripts.length)
- callback(this._mimeType, this._concatenateScriptsContent(scripts, sources));
- }
- for (var i = 0; i < scripts.length; ++i)
- scripts[i].requestSource(didRequestSource.bind(this));
- },
-
- _concatenateScriptsContent: function(scripts, sources)
- {
- var content = "";
- var lineNumber = 0;
- var columnNumber = 0;
-
- function appendChunk(chunk)
- {
- content += chunk;
- var lineEndings = chunk.lineEndings();
- var lineCount = lineEndings.length;
- if (lineCount === 1)
- columnNumber += chunk.length;
- else {
- lineNumber += lineCount - 1;
- columnNumber = lineEndings[lineCount - 1] - lineEndings[lineCount - 2] - 1;
- }
- }
-
- var scriptOpenTag = "<script>";
- var scriptCloseTag = "</script>";
- for (var i = 0; i < scripts.length; ++i) {
- if (lineNumber > scripts[i].lineOffset || (lineNumber === scripts[i].lineOffset && columnNumber > scripts[i].columnOffset - scriptOpenTag.length))
- continue;
-
- // Fill the gap with whitespace characters.
- while (lineNumber < scripts[i].lineOffset)
- appendChunk("\n");
- while (columnNumber < scripts[i].columnOffset - scriptOpenTag.length)
- appendChunk(" ");
-
- // Add script tag.
- appendChunk(scriptOpenTag);
- appendChunk(sources[i]);
- appendChunk(scriptCloseTag);
- }
-
- return content;
- }
-}
-
-WebInspector.ConcatenatedScriptsContentProvider.prototype.__proto__ = WebInspector.ContentProvider.prototype;
-
-/**
- * @constructor
- * @implements {WebInspector.ContentProvider}
- */
-WebInspector.ResourceContentProvider = function(resource)
-{
- this._mimeType = resource.type === WebInspector.Resource.Type.Script ? "text/_javascript_" : "text/html";
- this._resource = resource;
-};
-
-WebInspector.ResourceContentProvider.prototype = {
- requestContent: function(callback)
- {
- function didRequestContent(content)
- {
- callback(this._mimeType, content);
- }
- this._resource.requestContent(didRequestContent.bind(this));
- },
-
- searchInContent: function(query, callback)
- {
- this._resource.searchInContent(query, callback);
- }
-}
-
-WebInspector.ResourceContentProvider.prototype.__proto__ = WebInspector.ContentProvider.prototype;
-
-
-WebInspector.StaticContentProvider = function(mimeType, content)
-{
- this._mimeType = mimeType;
- this._content = content;
-};
-
-WebInspector.StaticContentProvider.prototype = {
- requestContent: function(callback)
- {
- callback(this._mimeType, this._content);
- }
-}
-
-WebInspector.StaticContentProvider.prototype.__proto__ = WebInspector.ContentProvider.prototype;
Modified: trunk/Source/WebCore/inspector/front-end/WebKit.qrc (96312 => 96313)
--- trunk/Source/WebCore/inspector/front-end/WebKit.qrc 2011-09-29 08:36:04 UTC (rev 96312)
+++ trunk/Source/WebCore/inspector/front-end/WebKit.qrc 2011-09-29 08:44:57 UTC (rev 96313)
@@ -20,6 +20,7 @@
<file>ConsoleModel.js</file>
<file>ConsolePanel.js</file>
<file>ConsoleView.js</file>
+ <file>ContentProviders.js</file>
<file>ContextMenu.js</file>
<file>CookieItemsView.js</file>
<file>CookieParser.js</file>
@@ -35,7 +36,6 @@
<file>DataGrid.js</file>
<file>DebuggerModel.js</file>
<file>DebuggerPresentationModel.js</file>
- <file>SourceFile.js</file>
<file>DOMAgent.js</file>
<file>DOMBreakpointsSidebarPane.js</file>
<file>DOMStorage.js</file>
@@ -86,6 +86,7 @@
<file>ProfileView.js</file>
<file>PropertiesSection.js</file>
<file>PropertiesSidebarPane.js</file>
+ <file>RawSourceCode.js</file>
<file>RemoteObject.js</file>
<file>Resource.js</file>
<file>ResourceCategory.js</file>
Modified: trunk/Source/WebCore/inspector/front-end/inspector.html (96312 => 96313)
--- trunk/Source/WebCore/inspector/front-end/inspector.html 2011-09-29 08:36:04 UTC (rev 96312)
+++ trunk/Source/WebCore/inspector/front-end/inspector.html 2011-09-29 08:44:57 UTC (rev 96313)
@@ -160,7 +160,8 @@
<script type="text/_javascript_" src=""
<script type="text/_javascript_" src=""
<script type="text/_javascript_" src=""
- <script type="text/_javascript_" src=""
+ <script type="text/_javascript_" src=""
+ <script type="text/_javascript_" src=""
<script type="text/_javascript_" src=""
<script type="text/_javascript_" src=""
<script type="text/_javascript_" src=""