Diff
Modified: trunk/LayoutTests/ChangeLog (116842 => 116843)
--- trunk/LayoutTests/ChangeLog 2012-05-12 08:31:30 UTC (rev 116842)
+++ trunk/LayoutTests/ChangeLog 2012-05-12 08:33:31 UTC (rev 116843)
@@ -1,3 +1,13 @@
+2012-05-12 Pavel Feldman <[email protected]>
+
+ Web Inspector: merge MainScriptMapping into DebuggerPresentationModel; move other classes into their own files.
+ https://bugs.webkit.org/show_bug.cgi?id=86285
+
+ Reviewed by Yury Semikhatsky.
+
+ * http/tests/inspector/compiler-script-mapping-expected.txt:
+ * http/tests/inspector/compiler-script-mapping.html:
+
2012-05-12 Kent Tamura <[email protected]>
[Chromium] Rebaseline for some tests.
Modified: trunk/LayoutTests/http/tests/inspector/compiler-script-mapping-expected.txt (116842 => 116843)
--- trunk/LayoutTests/http/tests/inspector/compiler-script-mapping-expected.txt 2012-05-12 08:31:30 UTC (rev 116842)
+++ trunk/LayoutTests/http/tests/inspector/compiler-script-mapping-expected.txt 2012-05-12 08:33:31 UTC (rev 116843)
@@ -16,4 +16,5 @@
Running: testInlinedSourceMap
Running: testSourceMapCouldNotBeLoaded
+compiled.js
Modified: trunk/LayoutTests/http/tests/inspector/compiler-script-mapping.html (116842 => 116843)
--- trunk/LayoutTests/http/tests/inspector/compiler-script-mapping.html 2012-05-12 08:31:30 UTC (rev 116842)
+++ trunk/LayoutTests/http/tests/inspector/compiler-script-mapping.html 2012-05-12 08:33:31 UTC (rev 116843)
@@ -192,18 +192,17 @@
{
WebInspector.settings.sourceMapsEnabled.set(true);
WebInspector.debuggerModel._reset();
- var mainScriptMapping = new WebInspector.MainScriptMapping();
- mainScriptMapping.addEventListener(WebInspector.MainScriptMapping.Events.UISourceCodeListChanged, uiSourceCodeListChanged);
+ var debuggerPresentationModel = new WebInspector.DebuggerPresentationModel();
+ debuggerPresentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.UISourceCodeAdded, uiSourceCodeAdded);
var script = InspectorTest.createScriptMock("compiled.js", 0, 0, true, "");
script.sourceMapURL = "http://localhost:8000/inspector/resources/source-map.json_";
console.error = function() {}; // Error message is platform dependent.
- mainScriptMapping.addScript(script);
+ debuggerPresentationModel._parsedScriptSource({data:script});
- function uiSourceCodeListChanged(event)
+ function uiSourceCodeAdded(event)
{
- InspectorTest.assertEquals(1, event.data.addedItems.length);
- InspectorTest.assertEquals("compiled.js", event.data.addedItems[0].url);
+ InspectorTest.addResult(event.data.url);
next();
}
}
Modified: trunk/Source/WebCore/ChangeLog (116842 => 116843)
--- trunk/Source/WebCore/ChangeLog 2012-05-12 08:31:30 UTC (rev 116842)
+++ trunk/Source/WebCore/ChangeLog 2012-05-12 08:33:31 UTC (rev 116843)
@@ -1,3 +1,48 @@
+2012-05-12 Pavel Feldman <[email protected]>
+
+ Web Inspector: merge MainScriptMapping into DebuggerPresentationModel; move other classes into their own files.
+ https://bugs.webkit.org/show_bug.cgi?id=86285
+
+ Reviewed by Yury Semikhatsky.
+
+ The only purpose of the debugger presentation model now is to manage mappings. Merging main script mapping back into it.
+ Other classes defined in that class are moved out into their own files.
+
+ * WebCore.gypi:
+ * WebCore.vcproj/WebCore.vcproj:
+ * inspector/compile-front-end.py:
+ * inspector/front-end/DebuggerPresentationModel.js:
+ (WebInspector.DebuggerPresentationModel):
+ (WebInspector.DebuggerPresentationModel.prototype._parsedScriptSource):
+ (WebInspector.DebuggerPresentationModel.prototype.uiSourceCodes):
+ (WebInspector.DebuggerPresentationModel.prototype._debuggerReset):
+ * inspector/front-end/DebuggerResourceBinding.js: Added.
+ (WebInspector.DebuggerResourceBinding):
+ (WebInspector.DebuggerResourceBinding.canEditScriptSource):
+ (WebInspector.DebuggerResourceBinding.setScriptSource.didEditScriptSource):
+ (WebInspector.DebuggerResourceBinding.setScriptSource):
+ (WebInspector.DebuggerResourceBinding.prototype.canSetContent):
+ (WebInspector.DebuggerResourceBinding.prototype.setContent):
+ (WebInspector.DebuggerResourceBinding.prototype._uiSourceCodeForResource):
+ (WebInspector.DebuggerResourceBinding.prototype._setContentWithInitialContent):
+ * inspector/front-end/PresentationConsoleMessageHelper.js: Added.
+ (WebInspector.PresentationConsoleMessageHelper):
+ (WebInspector.PresentationConsoleMessageHelper.prototype._consoleMessageAdded):
+ (WebInspector.PresentationConsoleMessageHelper.prototype._addConsoleMessageToScript):
+ (WebInspector.PresentationConsoleMessageHelper.prototype._addPendingConsoleMessage):
+ (WebInspector.PresentationConsoleMessageHelper.prototype._parsedScriptSource):
+ (WebInspector.PresentationConsoleMessageHelper.prototype._consoleCleared):
+ (WebInspector.PresentationConsoleMessageHelper.prototype._debuggerReset):
+ (WebInspector.PresentationConsoleMessage):
+ (WebInspector.PresentationConsoleMessage.prototype._updateLocation):
+ (WebInspector.PresentationConsoleMessage.prototype.get lineNumber):
+ (WebInspector.PresentationConsoleMessage.prototype.dispose):
+ * inspector/front-end/ScriptMapping.js:
+ * inspector/front-end/ScriptsPanel.js:
+ * inspector/front-end/WebKit.qrc:
+ * inspector/front-end/inspector.html:
+ * inspector/front-end/inspector.js:
+
2012-05-12 Mike West <[email protected]>
Cleanup ContentSecurityPolicy naming conventions.
Modified: trunk/Source/WebCore/WebCore.gypi (116842 => 116843)
--- trunk/Source/WebCore/WebCore.gypi 2012-05-12 08:31:30 UTC (rev 116842)
+++ trunk/Source/WebCore/WebCore.gypi 2012-05-12 08:33:31 UTC (rev 116843)
@@ -6361,6 +6361,7 @@
'inspector/front-end/DataGrid.js',
'inspector/front-end/DebuggerModel.js',
'inspector/front-end/DebuggerPresentationModel.js',
+ 'inspector/front-end/DebuggerResourceBinding.js',
'inspector/front-end/Dialog.js',
'inspector/front-end/DOMAgent.js',
'inspector/front-end/DOMBreakpointsSidebarPane.js',
@@ -6425,6 +6426,7 @@
'inspector/front-end/PanelEnablerView.js',
'inspector/front-end/Placard.js',
'inspector/front-end/Popover.js',
+ 'inspector/front-end/PresentationConsoleMessageHelper.js',
'inspector/front-end/ProfileDataGridTree.js',
'inspector/front-end/ProfileLauncherView.js',
'inspector/front-end/ProfilesPanel.js',
Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (116842 => 116843)
--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2012-05-12 08:31:30 UTC (rev 116842)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2012-05-12 08:33:31 UTC (rev 116843)
@@ -74229,6 +74229,10 @@
>
</File>
<File
+ RelativePath="..\inspector\front-end\DebuggerResourceBinding.js"
+ >
+ </File>
+ <File
RelativePath="..\inspector\front-end\dialog.css"
>
</File>
@@ -74549,6 +74553,10 @@
>
</File>
<File
+ RelativePath="..\inspector\front-end\PresentationConsoleMessageHelper.js"
+ >
+ </File>
+ <File
RelativePath="..\inspector\front-end\ProfileDataGridTree.js"
>
</File>
Modified: trunk/Source/WebCore/inspector/compile-front-end.py (116842 => 116843)
--- trunk/Source/WebCore/inspector/compile-front-end.py 2012-05-12 08:31:30 UTC (rev 116842)
+++ trunk/Source/WebCore/inspector/compile-front-end.py 2012-05-12 08:33:31 UTC (rev 116843)
@@ -74,6 +74,7 @@
"DOMStorage.js",
"DebuggerModel.js",
"DebuggerPresentationModel.js",
+ "DebuggerResourceBinding.js",
"FileManager.js",
"HAREntry.js",
"IndexedDBModel.js",
@@ -213,6 +214,7 @@
"CallStackSidebarPane.js",
"ScopeChainSidebarPane.js",
"_javascript_SourceFrame.js",
+ "PresentationConsoleMessageHelper.js",
"TabbedEditorContainer.js",
"ScriptsNavigator.js",
"ScriptsPanel.js",
Modified: trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js (116842 => 116843)
--- trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js 2012-05-12 08:31:30 UTC (rev 116842)
+++ trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js 2012-05-12 08:33:31 UTC (rev 116843)
@@ -34,15 +34,21 @@
*/
WebInspector.DebuggerPresentationModel = function()
{
- this._scriptMapping = new WebInspector.MainScriptMapping();
- this._scriptMapping.addEventListener(WebInspector.MainScriptMapping.Events.UISourceCodeListChanged, this._handleUISourceCodeListChanged, this);
+ this._mappings = [];
+
+ this._resourceMapping = new WebInspector.ResourceScriptMapping();
+ this._mappings.push(this._resourceMapping);
+ this._compilerMapping = new WebInspector.CompilerScriptMapping();
+ this._mappings.push(this._compilerMapping);
+ this._snippetsMapping = new WebInspector.SnippetsScriptMapping();
+ this._mappings.push(this._snippetsMapping);
+
+ for (var i = 0; i < this._mappings.length; ++i)
+ this._mappings[i].addEventListener(WebInspector.ScriptMapping.Events.UISourceCodeListChanged, this._handleUISourceCodeListChanged, this);
WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedScriptSource, this._parsedScriptSource, this);
WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.FailedToParseScriptSource, this._parsedScriptSource, this);
WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, this._debuggerReset, this);
-
- new WebInspector.DebuggerResourceBinding();
- new WebInspector.PresentationConsoleMessageHelper();
}
WebInspector.DebuggerPresentationModel.Events = {
@@ -58,7 +64,8 @@
_parsedScriptSource: function(event)
{
var script = /** @type {WebInspector.Script} */ event.data;
- this._scriptMapping.addScript(script);
+ var mapping = this._mappingForScript(script);
+ mapping.addScript(script);
},
/**
@@ -66,7 +73,13 @@
*/
uiSourceCodes: function()
{
- return this._scriptMapping.uiSourceCodeList();
+ var result = [];
+ for (var i = 0; i < this._mappings.length; ++i) {
+ var uiSourceCodeList = this._mappings[i].uiSourceCodeList();
+ for (var j = 0; j < uiSourceCodeList.length; ++j)
+ result.push(uiSourceCodeList[j]);
+ }
+ return result;
},
/**
@@ -89,264 +102,35 @@
}
},
- _debuggerReset: function()
- {
- this._scriptMapping.reset();
- }
-}
-
-WebInspector.DebuggerPresentationModel.prototype.__proto__ = WebInspector.Object.prototype;
-
-/**
- * @constructor
- */
-WebInspector.PresentationConsoleMessageHelper = function()
-{
- this._pendingConsoleMessages = {};
- this._presentationConsoleMessages = [];
-
- WebInspector.console.addEventListener(WebInspector.ConsoleModel.Events.MessageAdded, this._consoleMessageAdded, this);
- WebInspector.console.addEventListener(WebInspector.ConsoleModel.Events.ConsoleCleared, this._consoleCleared, this);
-
- WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedScriptSource, this._parsedScriptSource, this);
- WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.FailedToParseScriptSource, this._parsedScriptSource, this);
- WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, this._debuggerReset, this);
-}
-
-WebInspector.PresentationConsoleMessageHelper.prototype = {
/**
- * @param {WebInspector.Event} event
+ * @param {WebInspector.Script} script
+ * @return {WebInspector.ScriptMapping}
*/
- _consoleMessageAdded: function(event)
+ _mappingForScript: function(script)
{
- var message = /** @type {WebInspector.ConsoleMessage} */ event.data;
- if (!message.url || !message.isErrorOrWarning())
- return;
+ if (WebInspector.experimentsSettings.snippetsSupport.isEnabled()) {
+ if (WebInspector.snippetsModel.snippetIdForSourceURL(script.sourceURL))
+ return this._snippetsMapping;
+ }
- var rawLocation = message.location();
- if (rawLocation)
- this._addConsoleMessageToScript(message, rawLocation);
- else
- this._addPendingConsoleMessage(message);
- },
-
- /**
- * @param {WebInspector.ConsoleMessage} message
- * @param {DebuggerAgent.Location} rawLocation
- */
- _addConsoleMessageToScript: function(message, rawLocation)
- {
- this._presentationConsoleMessages.push(new WebInspector.PresentationConsoleMessage(message, rawLocation));
- },
-
- /**
- * @param {WebInspector.ConsoleMessage} message
- */
- _addPendingConsoleMessage: function(message)
- {
- if (!this._pendingConsoleMessages[message.url])
- this._pendingConsoleMessages[message.url] = [];
- this._pendingConsoleMessages[message.url].push(message);
- },
-
- /**
- * @param {WebInspector.Event} event
- */
- _parsedScriptSource: function(event)
- {
- var script = /** @type {WebInspector.Script} */ event.data;
-
- var messages = this._pendingConsoleMessages[script.sourceURL];
- if (!messages)
- return;
-
- var pendingMessages = [];
- for (var i = 0; i < messages.length; i++) {
- var message = messages[i];
- var rawLocation = message.location();
- if (script.scriptId === rawLocation.scriptId)
- this._addConsoleMessageToScript(messages, rawLocation);
- else
- pendingMessages.push(message);
+ if (WebInspector.settings.sourceMapsEnabled.get() && script.sourceMapURL) {
+ if (this._compilerMapping.loadSourceMapForScript(script))
+ return this._compilerMapping;
}
- if (pendingMessages.length)
- this._pendingConsoleMessages[script.sourceURL] = pendingMessages;
- else
- delete this._pendingConsoleMessages[script.sourceURL];
+ return this._resourceMapping;
},
- _consoleCleared: function()
- {
- this._pendingConsoleMessages = {};
- for (var i = 0; i < this._presentationConsoleMessages.length; ++i)
- this._presentationConsoleMessages[i].dispose();
- this._presentationConsoleMessages = [];
- var uiSourceCodes = WebInspector.debuggerPresentationModel.uiSourceCodes();
- for (var i = 0; i < uiSourceCodes.length; ++i)
- uiSourceCodes[i].consoleMessagesCleared();
- },
-
_debuggerReset: function()
{
- this._pendingConsoleMessages = {};
- this._presentationConsoleMessages = [];
+ for (var i = 0; i < this._mappings.length; ++i)
+ this._mappings[i].reset();
}
}
-/**
- * @constructor
- * @param {WebInspector.ConsoleMessage} message
- * @param {DebuggerAgent.Location} rawLocation
- */
-WebInspector.PresentationConsoleMessage = function(message, rawLocation)
-{
- this.originalMessage = message;
- this._liveLocation = WebInspector.debuggerModel.createLiveLocation(rawLocation, this._updateLocation.bind(this));
-}
+WebInspector.DebuggerPresentationModel.prototype.__proto__ = WebInspector.Object.prototype;
-WebInspector.PresentationConsoleMessage.prototype = {
- /**
- * @param {WebInspector.UILocation} uiLocation
- */
- _updateLocation: function(uiLocation)
- {
- if (this._uiLocation)
- this._uiLocation.uiSourceCode.consoleMessageRemoved(this);
- this._uiLocation = uiLocation;
- this._uiLocation.uiSourceCode.consoleMessageAdded(this);
- },
-
- get lineNumber()
- {
- return this._uiLocation.lineNumber;
- },
-
- dispose: function()
- {
- this._liveLocation.dispose();
- }
-}
-
/**
- * @constructor
- * @implements {WebInspector.ResourceDomainModelBinding}
- */
-WebInspector.DebuggerResourceBinding = function()
-{
- WebInspector.Resource.registerDomainModelBinding(WebInspector.resourceTypes.Script, this);
-}
-
-
-/**
- * @param {WebInspector.UISourceCode} uiSourceCode
- * @return {boolean}
- */
-WebInspector.DebuggerResourceBinding.canEditScriptSource = function(uiSourceCode)
-{
- return WebInspector.debuggerModel.canSetScriptSource() && uiSourceCode.isEditable;
-}
-
-/**
- * @param {WebInspector.UISourceCode} uiSourceCode
- * @param {string} newSource
- * @param {function(?Protocol.Error)} callback
- */
-WebInspector.DebuggerResourceBinding.setScriptSource = function(uiSourceCode, newSource, callback)
-{
- var rawLocation = uiSourceCode.uiLocationToRawLocation(0, 0);
- var script = WebInspector.debuggerModel.scriptForId(rawLocation.scriptId);
-
- /**
- * @this {WebInspector.DebuggerPresentationModel}
- * @param {?Protocol.Error} error
- */
- function didEditScriptSource(error)
- {
- callback(error);
- if (error)
- return;
-
- var resource = WebInspector.resourceForURL(script.sourceURL);
- if (resource)
- resource.addRevision(newSource);
-
- uiSourceCode.contentChanged(newSource);
- }
- WebInspector.debuggerModel.setScriptSource(script.scriptId, newSource, didEditScriptSource.bind(this));
-}
-
-WebInspector.DebuggerResourceBinding.prototype = {
- /**
- * @param {WebInspector.Resource} resource
- * @return {boolean}
- */
- canSetContent: function(resource)
- {
- var uiSourceCode = this._uiSourceCodeForResource(resource);
- return !!uiSourceCode && WebInspector.DebuggerResourceBinding.canEditScriptSource(uiSourceCode);
- },
-
- /**
- * @param {WebInspector.Resource} resource
- * @param {string} content
- * @param {boolean} majorChange
- * @param {function(?string)} userCallback
- */
- setContent: function(resource, content, majorChange, userCallback)
- {
- if (!majorChange)
- return;
-
- var uiSourceCode = this._uiSourceCodeForResource(resource);
- if (!uiSourceCode) {
- userCallback("Resource is not editable");
- return;
- }
-
- resource.requestContent(this._setContentWithInitialContent.bind(this, uiSourceCode, content, userCallback));
- },
-
- /**
- * @param {WebInspector.Resource} resource
- * @return {WebInspector.UISourceCode}
- */
- _uiSourceCodeForResource: function(resource)
- {
- var uiSourceCodes = WebInspector.debuggerPresentationModel.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
- * @param {?string} oldContent
- * @param {boolean} oldContentEncoded
- * @param {string} mimeType
- */
- _setContentWithInitialContent: function(uiSourceCode, content, userCallback, oldContent, oldContentEncoded, mimeType)
- {
- /**
- * @this {WebInspector.DebuggerResourceBinding}
- * @param {?string} error
- */
- function callback(error)
- {
- if (userCallback)
- userCallback(error);
- }
- WebInspector.DebuggerResourceBinding.setScriptSource(uiSourceCode, content, callback.bind(this));
- }
-}
-
-WebInspector.DebuggerResourceBinding.prototype.__proto__ = WebInspector.ResourceDomainModelBinding.prototype;
-
-/**
* @type {?WebInspector.DebuggerPresentationModel}
*/
WebInspector.debuggerPresentationModel = null;
Added: trunk/Source/WebCore/inspector/front-end/DebuggerResourceBinding.js (0 => 116843)
--- trunk/Source/WebCore/inspector/front-end/DebuggerResourceBinding.js (rev 0)
+++ trunk/Source/WebCore/inspector/front-end/DebuggerResourceBinding.js 2012-05-12 08:33:31 UTC (rev 116843)
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2012 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.ResourceDomainModelBinding}
+ */
+WebInspector.DebuggerResourceBinding = function()
+{
+ WebInspector.Resource.registerDomainModelBinding(WebInspector.resourceTypes.Script, this);
+}
+
+
+/**
+ * @param {WebInspector.UISourceCode} uiSourceCode
+ * @return {boolean}
+ */
+WebInspector.DebuggerResourceBinding.canEditScriptSource = function(uiSourceCode)
+{
+ return WebInspector.debuggerModel.canSetScriptSource() && uiSourceCode.isEditable;
+}
+
+/**
+ * @param {WebInspector.UISourceCode} uiSourceCode
+ * @param {string} newSource
+ * @param {function(?Protocol.Error)} callback
+ */
+WebInspector.DebuggerResourceBinding.setScriptSource = function(uiSourceCode, newSource, callback)
+{
+ var rawLocation = uiSourceCode.uiLocationToRawLocation(0, 0);
+ var script = WebInspector.debuggerModel.scriptForId(rawLocation.scriptId);
+
+ /**
+ * @this {WebInspector.DebuggerPresentationModel}
+ * @param {?Protocol.Error} error
+ */
+ function didEditScriptSource(error)
+ {
+ callback(error);
+ if (error)
+ return;
+
+ var resource = WebInspector.resourceForURL(script.sourceURL);
+ if (resource)
+ resource.addRevision(newSource);
+
+ uiSourceCode.contentChanged(newSource);
+ }
+ WebInspector.debuggerModel.setScriptSource(script.scriptId, newSource, didEditScriptSource.bind(this));
+}
+
+WebInspector.DebuggerResourceBinding.prototype = {
+ /**
+ * @param {WebInspector.Resource} resource
+ * @return {boolean}
+ */
+ canSetContent: function(resource)
+ {
+ var uiSourceCode = this._uiSourceCodeForResource(resource);
+ return !!uiSourceCode && WebInspector.DebuggerResourceBinding.canEditScriptSource(uiSourceCode);
+ },
+
+ /**
+ * @param {WebInspector.Resource} resource
+ * @param {string} content
+ * @param {boolean} majorChange
+ * @param {function(?string)} userCallback
+ */
+ setContent: function(resource, content, majorChange, userCallback)
+ {
+ if (!majorChange)
+ return;
+
+ var uiSourceCode = this._uiSourceCodeForResource(resource);
+ if (!uiSourceCode) {
+ userCallback("Resource is not editable");
+ return;
+ }
+
+ resource.requestContent(this._setContentWithInitialContent.bind(this, uiSourceCode, content, userCallback));
+ },
+
+ /**
+ * @param {WebInspector.Resource} resource
+ * @return {WebInspector.UISourceCode}
+ */
+ _uiSourceCodeForResource: function(resource)
+ {
+ var uiSourceCodes = WebInspector.debuggerPresentationModel.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
+ * @param {?string} oldContent
+ * @param {boolean} oldContentEncoded
+ * @param {string} mimeType
+ */
+ _setContentWithInitialContent: function(uiSourceCode, content, userCallback, oldContent, oldContentEncoded, mimeType)
+ {
+ /**
+ * @this {WebInspector.DebuggerResourceBinding}
+ * @param {?string} error
+ */
+ function callback(error)
+ {
+ if (userCallback)
+ userCallback(error);
+ }
+ WebInspector.DebuggerResourceBinding.setScriptSource(uiSourceCode, content, callback.bind(this));
+ }
+}
+
+WebInspector.DebuggerResourceBinding.prototype.__proto__ = WebInspector.ResourceDomainModelBinding.prototype;
Property changes on: trunk/Source/WebCore/inspector/front-end/DebuggerResourceBinding.js
___________________________________________________________________
Added: svn:eol-style
Added: trunk/Source/WebCore/inspector/front-end/PresentationConsoleMessageHelper.js (0 => 116843)
--- trunk/Source/WebCore/inspector/front-end/PresentationConsoleMessageHelper.js (rev 0)
+++ trunk/Source/WebCore/inspector/front-end/PresentationConsoleMessageHelper.js 2012-05-12 08:33:31 UTC (rev 116843)
@@ -0,0 +1,160 @@
+/*
+ * Copyright (C) 2012 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
+ */
+WebInspector.PresentationConsoleMessageHelper = function()
+{
+ this._pendingConsoleMessages = {};
+ this._presentationConsoleMessages = [];
+
+ WebInspector.console.addEventListener(WebInspector.ConsoleModel.Events.MessageAdded, this._consoleMessageAdded, this);
+ WebInspector.console.addEventListener(WebInspector.ConsoleModel.Events.ConsoleCleared, this._consoleCleared, this);
+
+ WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedScriptSource, this._parsedScriptSource, this);
+ WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.FailedToParseScriptSource, this._parsedScriptSource, this);
+ WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, this._debuggerReset, this);
+}
+
+WebInspector.PresentationConsoleMessageHelper.prototype = {
+ /**
+ * @param {WebInspector.Event} event
+ */
+ _consoleMessageAdded: function(event)
+ {
+ var message = /** @type {WebInspector.ConsoleMessage} */ event.data;
+ if (!message.url || !message.isErrorOrWarning())
+ return;
+
+ var rawLocation = message.location();
+ if (rawLocation)
+ this._addConsoleMessageToScript(message, rawLocation);
+ else
+ this._addPendingConsoleMessage(message);
+ },
+
+ /**
+ * @param {WebInspector.ConsoleMessage} message
+ * @param {DebuggerAgent.Location} rawLocation
+ */
+ _addConsoleMessageToScript: function(message, rawLocation)
+ {
+ this._presentationConsoleMessages.push(new WebInspector.PresentationConsoleMessage(message, rawLocation));
+ },
+
+ /**
+ * @param {WebInspector.ConsoleMessage} message
+ */
+ _addPendingConsoleMessage: function(message)
+ {
+ if (!this._pendingConsoleMessages[message.url])
+ this._pendingConsoleMessages[message.url] = [];
+ this._pendingConsoleMessages[message.url].push(message);
+ },
+
+ /**
+ * @param {WebInspector.Event} event
+ */
+ _parsedScriptSource: function(event)
+ {
+ var script = /** @type {WebInspector.Script} */ event.data;
+
+ var messages = this._pendingConsoleMessages[script.sourceURL];
+ if (!messages)
+ return;
+
+ var pendingMessages = [];
+ for (var i = 0; i < messages.length; i++) {
+ var message = messages[i];
+ var rawLocation = message.location();
+ if (script.scriptId === rawLocation.scriptId)
+ this._addConsoleMessageToScript(messages, rawLocation);
+ else
+ pendingMessages.push(message);
+ }
+
+ if (pendingMessages.length)
+ this._pendingConsoleMessages[script.sourceURL] = pendingMessages;
+ else
+ delete this._pendingConsoleMessages[script.sourceURL];
+ },
+
+ _consoleCleared: function()
+ {
+ this._pendingConsoleMessages = {};
+ for (var i = 0; i < this._presentationConsoleMessages.length; ++i)
+ this._presentationConsoleMessages[i].dispose();
+ this._presentationConsoleMessages = [];
+ var uiSourceCodes = WebInspector.debuggerPresentationModel.uiSourceCodes();
+ for (var i = 0; i < uiSourceCodes.length; ++i)
+ uiSourceCodes[i].consoleMessagesCleared();
+ },
+
+ _debuggerReset: function()
+ {
+ this._pendingConsoleMessages = {};
+ this._presentationConsoleMessages = [];
+ }
+}
+
+/**
+ * @constructor
+ * @param {WebInspector.ConsoleMessage} message
+ * @param {DebuggerAgent.Location} rawLocation
+ */
+WebInspector.PresentationConsoleMessage = function(message, rawLocation)
+{
+ this.originalMessage = message;
+ this._liveLocation = WebInspector.debuggerModel.createLiveLocation(rawLocation, this._updateLocation.bind(this));
+}
+
+WebInspector.PresentationConsoleMessage.prototype = {
+ /**
+ * @param {WebInspector.UILocation} uiLocation
+ */
+ _updateLocation: function(uiLocation)
+ {
+ if (this._uiLocation)
+ this._uiLocation.uiSourceCode.consoleMessageRemoved(this);
+ this._uiLocation = uiLocation;
+ this._uiLocation.uiSourceCode.consoleMessageAdded(this);
+ },
+
+ get lineNumber()
+ {
+ return this._uiLocation.lineNumber;
+ },
+
+ dispose: function()
+ {
+ this._liveLocation.dispose();
+ }
+}
Property changes on: trunk/Source/WebCore/inspector/front-end/PresentationConsoleMessageHelper.js
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/Source/WebCore/inspector/front-end/ScriptMapping.js (116842 => 116843)
--- trunk/Source/WebCore/inspector/front-end/ScriptMapping.js 2012-05-12 08:31:30 UTC (rev 116842)
+++ trunk/Source/WebCore/inspector/front-end/ScriptMapping.js 2012-05-12 08:33:31 UTC (rev 116843)
@@ -122,90 +122,3 @@
}
WebInspector.ScriptMapping.prototype.__proto__ = WebInspector.Object.prototype;
-
-/**
- * @constructor
- * @extends {WebInspector.Object}
- */
-WebInspector.MainScriptMapping = function()
-{
- this._mappings = [];
-
- this._resourceMapping = new WebInspector.ResourceScriptMapping();
- this._mappings.push(this._resourceMapping);
- this._compilerMapping = new WebInspector.CompilerScriptMapping();
- this._mappings.push(this._compilerMapping);
- this._snippetsMapping = new WebInspector.SnippetsScriptMapping();
- this._mappings.push(this._snippetsMapping);
-
- for (var i = 0; i < this._mappings.length; ++i)
- this._mappings[i].addEventListener(WebInspector.ScriptMapping.Events.UISourceCodeListChanged, this._handleUISourceCodeListChanged, this);
-
- this._mappingForScriptId = {};
-}
-
-WebInspector.MainScriptMapping.Events = {
- UISourceCodeListChanged: "ui-source-code-list-changed"
-}
-
-WebInspector.MainScriptMapping.prototype = {
- /**
- * @return {Array.<WebInspector.UISourceCode>}
- */
- uiSourceCodeList: function()
- {
- var result = [];
- for (var i = 0; i < this._mappings.length; ++i) {
- var uiSourceCodeList = this._mappings[i].uiSourceCodeList();
- for (var j = 0; j < uiSourceCodeList.length; ++j)
- result.push(uiSourceCodeList[j]);
- }
- return result;
- },
-
- /**
- * @param {WebInspector.Script} script
- */
- addScript: function(script)
- {
- var mapping = this._mappingForScript(script);
- this._mappingForScriptId[script.scriptId] = mapping;
- mapping.addScript(script);
- },
-
- /**
- * @param {WebInspector.Script} script
- * @return {WebInspector.ScriptMapping}
- */
- _mappingForScript: function(script)
- {
- if (WebInspector.experimentsSettings.snippetsSupport.isEnabled()) {
- if (WebInspector.snippetsModel.snippetIdForSourceURL(script.sourceURL))
- return this._snippetsMapping;
- }
-
- if (WebInspector.settings.sourceMapsEnabled.get() && script.sourceMapURL) {
- if (this._compilerMapping.loadSourceMapForScript(script))
- return this._compilerMapping;
- }
-
- return this._resourceMapping;
- },
-
- /**
- * @param {WebInspector.Event} event
- */
- _handleUISourceCodeListChanged: function(event)
- {
- this.dispatchEventToListeners(WebInspector.MainScriptMapping.Events.UISourceCodeListChanged, event.data);
- },
-
- reset: function()
- {
- for (var i = 0; i < this._mappings.length; ++i)
- this._mappings[i].reset();
- this._mappingForScriptId = {};
- }
-}
-
-WebInspector.MainScriptMapping.prototype.__proto__ = WebInspector.Object.prototype;
Modified: trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js (116842 => 116843)
--- trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js 2012-05-12 08:31:30 UTC (rev 116842)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js 2012-05-12 08:33:31 UTC (rev 116843)
@@ -38,6 +38,7 @@
WebInspector.settings.navigatorWasOnceHidden = WebInspector.settings.createSetting("navigatorWasOnceHidden", false);
this._presentationModel = presentationModel;
+ new WebInspector.PresentationConsoleMessageHelper();
function viewGetter()
{
Modified: trunk/Source/WebCore/inspector/front-end/WebKit.qrc (116842 => 116843)
--- trunk/Source/WebCore/inspector/front-end/WebKit.qrc 2012-05-12 08:31:30 UTC (rev 116842)
+++ trunk/Source/WebCore/inspector/front-end/WebKit.qrc 2012-05-12 08:33:31 UTC (rev 116843)
@@ -37,6 +37,7 @@
<file>DataGrid.js</file>
<file>DebuggerModel.js</file>
<file>DebuggerPresentationModel.js</file>
+ <file>DebuggerResourceBinding.js</file>
<file>Dialog.js</file>
<file>DOMAgent.js</file>
<file>DOMBreakpointsSidebarPane.js</file>
@@ -101,6 +102,7 @@
<file>PanelEnablerView.js</file>
<file>Placard.js</file>
<file>Popover.js</file>
+ <file>PresentationConsoleMessageHelper.js</file>
<file>ProfileDataGridTree.js</file>
<file>ProfileLauncherView.js</file>
<file>ProfilesPanel.js</file>
Modified: trunk/Source/WebCore/inspector/front-end/inspector.html (116842 => 116843)
--- trunk/Source/WebCore/inspector/front-end/inspector.html 2012-05-12 08:31:30 UTC (rev 116842)
+++ trunk/Source/WebCore/inspector/front-end/inspector.html 2012-05-12 08:33:31 UTC (rev 116843)
@@ -182,6 +182,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=""
Modified: trunk/Source/WebCore/inspector/front-end/inspector.js (116842 => 116843)
--- trunk/Source/WebCore/inspector/front-end/inspector.js 2012-05-12 08:31:30 UTC (rev 116842)
+++ trunk/Source/WebCore/inspector/front-end/inspector.js 2012-05-12 08:33:31 UTC (rev 116843)
@@ -415,6 +415,7 @@
this.snippetsModel = new WebInspector.SnippetsModel();
this.breakpointManager = new WebInspector.BreakpointManager(WebInspector.settings.breakpoints, this.debuggerModel);
this.debuggerPresentationModel = new WebInspector.DebuggerPresentationModel();
+ new WebInspector.DebuggerResourceBinding();
this.drawer = new WebInspector.Drawer();
this.consoleView = new WebInspector.ConsoleView(WebInspector.WorkerManager.isWorkerFrontend());