Changeset 127427 in webkit
- Timestamp:
- Sep 3, 2012 9:34:08 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 2 deleted
- 19 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r127425 r127427 1 2012-09-03 Vsevolod Vlasov <vsevik@chromium.org> 2 3 Web Inspector: Create JavaScriptSources based on network resources. 4 https://bugs.webkit.org/show_bug.cgi?id=95352 5 6 Reviewed by Pavel Feldman. 7 8 Removed raw-source-code.html test as RawSourceCode was removed by this patch. 9 Added resource-script-mapping.html to test script <-> uiSourceCode binding behavior. 10 Added network-uisourcecode-provider.html to test uiSourceCode creation behavior. 11 Updated dynamic-script-tag.html to better match expected behavior. 12 13 * http/tests/inspector/network/network-request-revision-content.html: 14 * http/tests/inspector/workspace-test.js: Added. 15 (initialize_WorkspaceTest.InspectorTest.createWorkspace): 16 (initialize_WorkspaceTest.InspectorTest.waitForWorkspaceUISourceCodeReplacedEvent.uiSourceCodeReplaced): 17 (initialize_WorkspaceTest.InspectorTest.waitForWorkspaceUISourceCodeReplacedEvent): 18 (initialize_WorkspaceTest.InspectorTest.waitForWorkspaceUISourceCodeAddedEvent.uiSourceCodeAdded): 19 (initialize_WorkspaceTest.InspectorTest.waitForWorkspaceUISourceCodeAddedEvent): 20 (initialize_WorkspaceTest.InspectorTest.addMockUISourceCodeToWorkspace): 21 (initialize_WorkspaceTest.InspectorTest._defaultUISourceCodeProviderEventHandler): 22 (initialize_WorkspaceTest.InspectorTest.dumpUISourceCode.didRequestContent): 23 (initialize_WorkspaceTest.InspectorTest.dumpUISourceCode): 24 (initialize_WorkspaceTest): 25 * inspector/debugger/breakpoint-manager.html: 26 * inspector/debugger/dynamic-script-tag-expected.txt: 27 * inspector/debugger/dynamic-script-tag.html: 28 * inspector/debugger/network-uisourcecode-provider-expected.txt: Added. 29 * inspector/debugger/network-uisourcecode-provider.html: Added. 30 * inspector/debugger/raw-source-code-expected.txt: Removed. 31 * inspector/debugger/raw-source-code.html: Removed. 32 * inspector/debugger/resource-script-mapping-expected.txt: Added. 33 * inspector/debugger/resource-script-mapping.html: Added. 34 * inspector/debugger/scripts-panel.html: 35 * inspector/debugger/source-frame-count.html: 36 1 37 2012-09-03 Tommy Widenflycht <tommyw@google.com> 2 38 -
trunk/LayoutTests/http/tests/inspector/network/network-request-revision-content.html
r125980 r127427 15 15 { 16 16 InspectorTest.addConsoleSniffer(step2, true); 17 InspectorTest.addSniffer(WebInspector. StylesUISourceCodeProvider.prototype, "_resourceAdded", true);17 InspectorTest.addSniffer(WebInspector.NetworkUISourceCodeProvider.prototype, "_resourceAdded", true); 18 18 InspectorTest.evaluateInPage("loadStylesheet()"); 19 19 -
trunk/LayoutTests/inspector/debugger/breakpoint-manager.html
r126999 r127427 112 112 _addUISourceCode: function(url) 113 113 { 114 var uiSourceCode = new WebInspector.JavaScriptSource(url, null, null, defaultMapping, false); 114 var uiSourceCode = new WebInspector.JavaScriptSource(url, null, null, false); 115 uiSourceCode.setSourceMapping(defaultMapping); 115 116 uiSourceCodes[url] = uiSourceCode; 116 117 this.dispatchEventToListeners(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, uiSourceCode); -
trunk/LayoutTests/inspector/debugger/dynamic-script-tag-expected.txt
r117966 r127427 1 CONSOLE MESSAGE: line 1: 123 2 Tests that dynamically added script tag gets its own JavaScriptSource and is not bound to the resource. Bug 87119 1 Tests that inline scripts and document.write scripts get different uiSourceCodes with different URLs. Bug 87119 3 2 4 3 Debugger was enabled. 4 Dumping scripts: 5 script1: file:///usr/local/google/home/vsevik/chromium/src/third_party/WebKit/LayoutTests/inspector/debugger/dynamic-script-tag.html 6 Is anonymous:false 7 Is inline script:true 8 script2: file:///usr/local/google/home/vsevik/chromium/src/third_party/WebKit/LayoutTests/inspector/debugger/dynamic-script-tag.html 5 9 Is anonymous:false 6 10 Is inline script:false 7 dynamic-script-tag.html 8 UI name: dynamic-script-tag.html 11 script3: file:///usr/local/google/home/vsevik/chromium/src/third_party/WebKit/LayoutTests/inspector/debugger/dynamic-script-tag.html 12 Is anonymous:false 13 Is inline script:false 14 Dumping uiSourceCodes: 15 UISourceCode: file:///usr/local/google/home/vsevik/chromium/src/third_party/WebKit/LayoutTests/inspector/debugger/dynamic-script-tag.html (1) 16 UISourceCode is editable: true 17 UISourceCode is content script: false 18 Mime type: text/javascript 19 UISourceCode content: function bar() { } 9 20 UI resource: null 10 UI content: console.log(123) 21 UISourceCode: file:///usr/local/google/home/vsevik/chromium/src/third_party/WebKit/LayoutTests/inspector/debugger/dynamic-script-tag.html (2) 22 UISourceCode is editable: true 23 UISourceCode is content script: false 24 Mime type: text/javascript 25 UISourceCode content: function foo() { } 26 UI resource: null 11 27 Debugger was disabled. 12 28 -
trunk/LayoutTests/inspector/debugger/dynamic-script-tag.html
r117966 r127427 3 3 <script src="../../http/tests/inspector/inspector-test.js"></script> 4 4 <script src="../../http/tests/inspector/debugger-test.js"></script> 5 <script src="../../http/tests/inspector/workspace-test.js"></script> 6 <script> 7 document.write("<scrip" + "t>function foo() { }</sc" + "ript>"); 8 var scriptElement = document.createElement("script"); 9 scriptElement.textContent = "function bar() { }"; 10 document.head.appendChild(scriptElement); 5 11 6 <script> 7 8 function createScriptTag() 9 { 10 var script = document.createElement("script"); 11 script.innerHTML = "console.log(123)"; 12 document.head.appendChild(script); 13 } 14 15 function test() 12 var test = function() 16 13 { 17 14 InspectorTest.startDebuggerTest(step1); … … 19 16 function step1() 20 17 { 21 InspectorTest.evaluateInPage("createScriptTag()"); 22 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedScriptSource, step2); 23 } 18 var model = WebInspector.debuggerModel; 24 19 25 function step2(event) 26 { 27 var script = event.data; 28 script.requestContent(callback); 29 function callback(content) 20 var scripts = Object.values(WebInspector.debuggerModel.scripts); 21 function filterOutStandaloneScripts(script) 30 22 { 31 if (content !== "console.log(123)") 32 return; 23 return script.sourceURL.indexOf("dynamic-script-tag.html") !== -1; 24 } 25 scripts = scripts.filter(filterOutStandaloneScripts); 26 27 function compareScriptFunction(script1, script2) 28 { 29 return script1.sourceURL.localeCompare(script2.sourceURL); 30 } 31 scripts.sort(compareScriptFunction); 32 InspectorTest.assertEquals(3, scripts.length, "Wrong scripts count."); 33 34 var uiSourceCodes = []; 35 InspectorTest.addResult("Dumping scripts:"); 36 for (var i = 0; i < scripts.length; ++i) { 37 var script = scripts[i]; 38 InspectorTest.addResult("script" + (i+1) + ": " + script.sourceURL); 33 39 InspectorTest.addResult("Is anonymous:" + script.isAnonymousScript()); 34 40 InspectorTest.addResult("Is inline script:" + script.isInlineScript()); 35 InspectorTest.addResult(new WebInspector.ParsedURL(script.sourceURL).displayName); 36 // Invoke post source map install. 37 setTimeout(step3.bind(this, script), 0); 41 if (!script.isInlineScript()) 42 uiSourceCodes.push(script.rawLocationToUILocation(0, 0).uiSourceCode); 38 43 } 39 }40 44 41 function step3(script) 42 { 43 var uiLocation = script.rawLocationToUILocation(0, 0); 44 InspectorTest.addResult("UI name: " + uiLocation.uiSourceCode.parsedURL.displayName); 45 InspectorTest.addResult("UI resource: " + uiLocation.uiSourceCode.resource()); 46 uiLocation.uiSourceCode.requestContent(callback); 47 function callback(content) 45 function compareUISourceCodeFunction(uiSourceCode1, uiSourceCode2) 48 46 { 49 InspectorTest.addResult("UI content: " + content); 47 return uiSourceCode1.url.localeCompare(uiSourceCode2.url); 48 } 49 uiSourceCodes.sort(compareUISourceCodeFunction); 50 51 var seenUISourceCodes = new Map(); 52 InspectorTest.assertEquals(2, uiSourceCodes.length, "Wrong uiSourceCodes count."); 53 InspectorTest.addResult("Dumping uiSourceCodes:"); 54 55 var index = 0; 56 dumpNextUISourceCode(); 57 function dumpNextUISourceCode() 58 { 59 if (index >= uiSourceCodes.length) { 60 uiSourceCodesDumped(); 61 return; 62 } 63 var uiSourceCode = uiSourceCodes[index]; 64 InspectorTest.dumpUISourceCode(uiSourceCode, uiSourceCodeDumped); 65 66 function uiSourceCodeDumped() 67 { 68 InspectorTest.addResult("UI resource: " + uiSourceCode.resource()); 69 InspectorTest.assertTrue(!seenUISourceCodes.get(uiSourceCode), "UISourceCode matches two scripts: " + uiSourceCode.url); 70 seenUISourceCodes.put(uiSourceCode, uiSourceCode); 71 ++index; 72 dumpNextUISourceCode(); 73 } 74 } 75 76 function uiSourceCodesDumped() 77 { 50 78 InspectorTest.completeDebuggerTest(); 51 79 } … … 55 83 </head> 56 84 <body onload="runTest()"> 57 <p> 58 Tests that dynamically added script tag gets its own JavaScriptSource and is not bound to the resource. 85 <p>Tests that inline scripts and document.write scripts get different uiSourceCodes with different URLs. 59 86 <a href="https://bugs.webkit.org/show_bug.cgi?id=87119">Bug 87119</a> 60 </p>61 87 </body> 62 63 88 </html> -
trunk/LayoutTests/inspector/debugger/scripts-panel.html
r126999 r127427 25 25 function createUISouceCode(url) 26 26 { 27 var uiSourceCode = new WebInspector.JavaScriptSource(url, null, contentProvider, null,false);27 var uiSourceCode = new WebInspector.JavaScriptSource(url, null, contentProvider, false); 28 28 uiSourceCode.requestContent = function(callback) 29 29 { -
trunk/Source/WebCore/ChangeLog
r127426 r127427 1 2012-09-03 Vsevolod Vlasov <vsevik@chromium.org> 2 3 Web Inspector: Create JavaScriptSources based on network resources. 4 https://bugs.webkit.org/show_bug.cgi?id=95352 5 6 Reviewed by Pavel Feldman. 7 8 Introduced NetworkUISourceCodeProvider that is listening for ResourceTreeModel and creates UISourceCodes for them. 9 RawSourceCode does not create uiSourceCodes based on resource anymore (this is done by NetworkUISourceCodeProvider instead). 10 Moved script <-> uiSourceCode binding logic from RawSourceCode to ResourceScriptMapping. 11 Removed rawSourceCode as it was not needed anymore. 12 13 Tests: inspector/debugger/network-uisourcecode-provider.html 14 inspector/debugger/resource-script-mapping.html 15 16 * WebCore.gypi: 17 * WebCore.vcproj/WebCore.vcproj: 18 * inspector/compile-front-end.py: 19 * inspector/front-end/CompilerScriptMapping.js: 20 * inspector/front-end/JavaScriptSource.js: 21 (WebInspector.JavaScriptSource): 22 * inspector/front-end/NetworkUISourceCodeProvider.js: Renamed from Source/WebCore/inspector/front-end/StylesUISourceCodeProvider.js. 23 (WebInspector.NetworkUISourceCodeProvider): 24 (WebInspector.NetworkUISourceCodeProvider.prototype._populate): 25 (WebInspector.NetworkUISourceCodeProvider.prototype._styleResourceAdded): 26 (WebInspector.NetworkUISourceCodeProvider.prototype._scriptResourceAdded.resourceFinished): 27 (WebInspector.NetworkUISourceCodeProvider.prototype._scriptResourceAdded): 28 (WebInspector.NetworkUISourceCodeProvider.prototype._addJavaScriptSource): 29 (WebInspector.NetworkUISourceCodeProvider.prototype._addUISourceCode): 30 (WebInspector.NetworkUISourceCodeProvider.prototype._resourceAdded): 31 (WebInspector.NetworkUISourceCodeProvider.prototype._reset): 32 * inspector/front-end/RawSourceCode.js: 33 * inspector/front-end/ResourceScriptMapping.js: 34 (WebInspector.ResourceScriptMapping): 35 (WebInspector.ResourceScriptMapping.prototype.rawLocationToUILocation): 36 (WebInspector.ResourceScriptMapping.prototype._bindUISourceCodeToScripts): 37 (WebInspector.ResourceScriptMapping.prototype._scriptsForSourceURL): 38 (WebInspector.ResourceScriptMapping.prototype._addOrReplaceTemporaryUISourceCode.get var): 39 (WebInspector.ResourceScriptMapping.prototype._addOrReplaceTemporaryUISourceCode): 40 (WebInspector.ResourceScriptMapping.prototype.get _uiSourceCodeReplaced): 41 (WebInspector.ResourceScriptMapping.prototype._reset): 42 * inspector/front-end/ScriptSnippetModel.js: 43 (WebInspector.ScriptSnippetModel.prototype._addScriptSnippet): 44 (WebInspector.ScriptSnippetModel.prototype._createUISourceCodeForScript): 45 (WebInspector.SnippetJavaScriptSource): 46 * inspector/front-end/UISourceCode.js: 47 (WebInspector.UISourceCode): 48 (WebInspector.UISourceCode.prototype.uiLocationToRawLocation): 49 (WebInspector.UISourceCode.prototype.setSourceMapping): 50 * inspector/front-end/WebKit.qrc: 51 * inspector/front-end/inspector.html: 52 * inspector/front-end/inspector.js: 53 1 54 2012-09-03 Andrey Adaikin <aandrey@chromium.org> 2 55 -
trunk/Source/WebCore/WebCore.gypi
r127425 r127427 6358 6358 'inspector/front-end/NetworkPanelDescriptor.js', 6359 6359 'inspector/front-end/NetworkRequest.js', 6360 'inspector/front-end/NetworkUISourceCodeProvider.js', 6360 6361 'inspector/front-end/Object.js', 6361 6362 'inspector/front-end/ObjectPopoverHelper.js', … … 6369 6370 'inspector/front-end/ProgressBar.js', 6370 6371 'inspector/front-end/PropertiesSection.js', 6371 'inspector/front-end/RawSourceCode.js',6372 6372 'inspector/front-end/RemoteObject.js', 6373 6373 'inspector/front-end/Resource.js', … … 6406 6406 'inspector/front-end/StyleSource.js', 6407 6407 'inspector/front-end/StylesSourceMapping.js', 6408 'inspector/front-end/StylesUISourceCodeProvider.js',6409 6408 'inspector/front-end/TabbedPane.js', 6410 6409 'inspector/front-end/TestController.js', -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r127417 r127427 76319 76319 </File> 76320 76320 <File 76321 RelativePath="..\inspector\front-end\NetworkUISourceCodeProvider.js" 76322 > 76323 </File> 76324 <File 76321 76325 RelativePath="..\inspector\front-end\NetworkRequest.js" 76322 76326 > … … 76395 76399 </File> 76396 76400 <File 76397 RelativePath="..\inspector\front-end\RawSourceCode.js"76398 >76399 </File>76400 <File76401 76401 RelativePath="..\inspector\front-end\RemoteObject.js" 76402 76402 > … … 76628 76628 <File 76629 76629 RelativePath="..\inspector\front-end\StylesSourceMapping.js" 76630 >76631 </File>76632 <File76633 RelativePath="..\inspector\front-end\StylesUISourceCodeProvider.js"76634 76630 > 76635 76631 </File> -
trunk/Source/WebCore/inspector/compile-front-end.py
r127417 r127427 83 83 "Linkifier.js", 84 84 "NetworkLog.js", 85 "NetworkUISourceCodeProvider.js", 85 86 "PresentationConsoleMessageHelper.js", 86 87 "SASSSourceMapping.js", … … 92 93 "StyleSource.js", 93 94 "StylesSourceMapping.js", 94 "StylesUISourceCodeProvider.js",95 95 "TimelineManager.js", 96 "RawSourceCode.js",97 96 "RemoteObject.js", 98 97 "Resource.js", -
trunk/Source/WebCore/inspector/front-end/CompilerScriptMapping.js
r126999 r127427 121 121 else 122 122 contentProvider = new WebInspector.CompilerSourceMappingContentProvider(sourceURL); 123 var uiSourceCode = new WebInspector.JavaScriptSource(sourceURL, null, contentProvider, this, false); 123 var uiSourceCode = new WebInspector.JavaScriptSource(sourceURL, null, contentProvider, false); 124 uiSourceCode.setSourceMapping(this); 124 125 uiSourceCode.isContentScript = script.isContentScript; 125 126 this._uiSourceCodeByURL[sourceURL] = uiSourceCode; -
trunk/Source/WebCore/inspector/front-end/JavaScriptSource.js
r123852 r127427 35 35 * @param {WebInspector.Resource} resource 36 36 * @param {WebInspector.ContentProvider} contentProvider 37 * @param {WebInspector.SourceMapping} sourceMapping38 37 */ 39 WebInspector.JavaScriptSource = function(url, resource, contentProvider, sourceMapping,isEditable)38 WebInspector.JavaScriptSource = function(url, resource, contentProvider, isEditable) 40 39 { 41 WebInspector.UISourceCode.call(this, url, resource, contentProvider , sourceMapping);40 WebInspector.UISourceCode.call(this, url, resource, contentProvider); 42 41 this._isEditable = isEditable; 43 42 } -
trunk/Source/WebCore/inspector/front-end/NetworkUISourceCodeProvider.js
r127426 r127427 33 33 * @param {WebInspector.Workspace} workspace 34 34 */ 35 WebInspector. StylesUISourceCodeProvider = function(workspace)35 WebInspector.NetworkUISourceCodeProvider = function(workspace) 36 36 { 37 37 this._workspace = workspace; … … 39 39 this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._reset, this); 40 40 this._stylesSourceMapping = new WebInspector.StylesSourceMapping(); 41 42 this._uiSourceCodeForResource = {}; 41 43 } 42 44 43 WebInspector. StylesUISourceCodeProvider.prototype = {45 WebInspector.NetworkUISourceCodeProvider.prototype = { 44 46 _populate: function() 45 47 { … … 58 60 59 61 /** 62 * @param {WebInspector.Resource} resource 63 */ 64 _styleResourceAdded: function(resource) 65 { 66 var uiSourceCode = new WebInspector.StyleSource(resource); 67 this._stylesSourceMapping.addUISourceCode(uiSourceCode); 68 this._addUISourceCode(uiSourceCode); 69 }, 70 71 /** 72 * @param {WebInspector.Resource} resource 73 */ 74 _scriptResourceAdded: function(resource) 75 { 76 if (resource.request && !resource.request.finished) { 77 resource.request.addEventListener(WebInspector.NetworkRequest.Events.FinishedLoading, resourceFinished, this); 78 return; 79 } 80 this._addJavaScriptSource(resource); 81 82 function resourceFinished() 83 { 84 resource.request.removeEventListener(WebInspector.NetworkRequest.Events.FinishedLoading, resourceFinished, this); 85 this._addJavaScriptSource(resource); 86 } 87 }, 88 89 /** 90 * @param {WebInspector.Resource} resource 91 */ 92 _addJavaScriptSource: function(resource) 93 { 94 if (this._uiSourceCodeForResource[resource.url]) 95 return; 96 var isDocument = resource.type === WebInspector.resourceTypes.Document; 97 var uiSourceCode = new WebInspector.JavaScriptSource(resource.url, resource, resource, !isDocument); 98 this._uiSourceCodeForResource[resource.url] = uiSourceCode; 99 this._addUISourceCode(uiSourceCode); 100 }, 101 102 /** 103 * @param {WebInspector.UISourceCode} uiSourceCode 104 */ 105 _addUISourceCode: function(uiSourceCode) 106 { 107 this._workspace.project().addUISourceCode(uiSourceCode); 108 }, 109 110 /** 60 111 * @param {WebInspector.Event} event 61 112 */ … … 63 114 { 64 115 var resource = /** @type {WebInspector.Resource} */ event.data; 65 if (resource.type !== WebInspector.resourceTypes.Stylesheet) 66 return; 67 var uiSourceCode = new WebInspector.StyleSource(resource); 68 this._stylesSourceMapping.addUISourceCode(uiSourceCode); 69 this._workspace.project().addUISourceCode(uiSourceCode); 116 switch (resource.type) { 117 case WebInspector.resourceTypes.Stylesheet: 118 this._styleResourceAdded(resource); 119 break; 120 case WebInspector.resourceTypes.Document: 121 case WebInspector.resourceTypes.Script: 122 this._scriptResourceAdded(resource); 123 break; 124 } 70 125 }, 71 126 72 127 _reset: function() 73 128 { 129 this._uiSourceCodeForResource = {}; 74 130 this._stylesSourceMapping.reset(); 75 131 // FIXME: We should not populate until the ProjectWillReset event was handled by all listeners. Introduce ProjectDidReset event for that matter. -
trunk/Source/WebCore/inspector/front-end/RawSourceCode.js
r119898 r127427 1 /*2 * Copyright (C) 2011 Google Inc. All rights reserved.3 *4 * Redistribution and use in source and binary forms, with or without5 * modification, are permitted provided that the following conditions are6 * met:7 *8 * * Redistributions of source code must retain the above copyright9 * notice, this list of conditions and the following disclaimer.10 * * Redistributions in binary form must reproduce the above11 * copyright notice, this list of conditions and the following disclaimer12 * in the documentation and/or other materials provided with the13 * distribution.14 * * Neither the name of Google Inc. nor the names of its15 * contributors may be used to endorse or promote products derived from16 * this software without specific prior written permission.17 *18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.29 */30 31 // RawSourceCode represents JavaScript resource or HTML resource with inlined scripts32 // as it came from network.33 34 /**35 * @constructor36 * @extends {WebInspector.Object}37 * @param {string} id38 * @param {WebInspector.Script} script39 * @param {WebInspector.Resource} resource40 * @param {WebInspector.NetworkRequest} request41 * @param {WebInspector.SourceMapping} sourceMapping42 */43 WebInspector.RawSourceCode = function(id, script, resource, request, sourceMapping)44 {45 this.id = id;46 this.url = script.sourceURL;47 this.isContentScript = script.isContentScript;48 this._scripts = [script];49 this._resource = resource;50 this._pendingRequest = request;51 this._sourceMapping = sourceMapping;52 53 this._uiSourceCode = null;54 if (this._pendingRequest)55 this._pendingRequest.addEventListener(WebInspector.NetworkRequest.Events.FinishedLoading, this._finishedLoading, this);56 else57 this._uiSourceCode = this._createUISourceCode();58 }59 60 WebInspector.RawSourceCode.Events = {61 UISourceCodeChanged: "us-source-code-changed"62 }63 64 WebInspector.RawSourceCode.prototype = {65 /**66 * @param {WebInspector.Script} script67 */68 addScript: function(script)69 {70 this._scripts.push(script);71 if (this._temporaryUISourceCode) {72 var oldUISourceCode = this._temporaryUISourceCode;73 this._temporaryUISourceCode = this._createUISourceCode();74 this.dispatchEventToListeners(WebInspector.RawSourceCode.Events.UISourceCodeChanged, { uiSourceCode: this._temporaryUISourceCode, oldUISourceCode: oldUISourceCode });75 }76 },77 78 /**79 * @param {WebInspector.DebuggerModel.Location} rawLocation80 * @return {WebInspector.UILocation}81 */82 rawLocationToUILocation: function(rawLocation)83 {84 var uiSourceCode = this._uiSourceCode || this._temporaryUISourceCode;85 if (!uiSourceCode) {86 this._temporaryUISourceCode = this._createUISourceCode();87 uiSourceCode = this._temporaryUISourceCode;88 this.dispatchEventToListeners(WebInspector.RawSourceCode.Events.UISourceCodeChanged, { uiSourceCode: uiSourceCode });89 }90 return new WebInspector.UILocation(uiSourceCode, rawLocation.lineNumber, rawLocation.columnNumber || 0);91 },92 93 /**94 * @return {WebInspector.UISourceCode}95 */96 _createUISourceCode: function()97 {98 var isStandaloneScript = this._scripts.length === 1 && !this._scripts[0].isInlineScript();99 100 var contentProvider;101 if (this._resource)102 contentProvider = this._resource;103 else if (isStandaloneScript)104 contentProvider = this._scripts[0];105 else106 contentProvider = new WebInspector.ConcatenatedScriptsContentProvider(this._scripts);107 108 var uiSourceCode = new WebInspector.JavaScriptSource(this.url, this._resource, contentProvider, this._sourceMapping, isStandaloneScript);109 uiSourceCode.isContentScript = this.isContentScript;110 return uiSourceCode;111 },112 113 /**114 * @param {WebInspector.UISourceCode} uiSourceCode115 * @param {number} lineNumber116 * @param {number} columnNumber117 * @return {WebInspector.RawLocation}118 */119 uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber)120 {121 if (this.url)122 return WebInspector.debuggerModel.createRawLocationByURL(this.url, lineNumber, columnNumber);123 return WebInspector.debuggerModel.createRawLocation(this._scripts[0], lineNumber, columnNumber);124 },125 126 /**127 * @return {WebInspector.UISourceCode|null}128 */129 uiSourceCode: function()130 {131 return this._uiSourceCode || this._temporaryUISourceCode;132 },133 134 _finishedLoading: function(event)135 {136 this._resource = WebInspector.resourceForURL(this._pendingRequest.url);137 delete this._pendingRequest;138 var oldUISourceCode = this._uiSourceCode || this._temporaryUISourceCode;139 delete this._temporaryUISourceCode;140 this._uiSourceCode = this._createUISourceCode();141 this.dispatchEventToListeners(WebInspector.RawSourceCode.Events.UISourceCodeChanged, { uiSourceCode: this._uiSourceCode, oldUISourceCode: oldUISourceCode });142 }143 }144 145 WebInspector.RawSourceCode.prototype.__proto__ = WebInspector.Object.prototype; -
trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js
r127005 r127427 37 37 { 38 38 this._workspace = workspace; 39 /** @type {Array.<WebInspector.RawSourceCode>} */40 this._rawSourceCodes = [];41 /** @type {Object.<string, WebInspector.RawSourceCode>} */42 this._rawSourceCodeForScriptId = {};43 /** @type {Object.<string, WebInspector.RawSourceCode>} */44 this._rawSourceCodeForURL = {};45 /** @type {Object.<string, WebInspector.RawSourceCode>} */46 this._rawSourceCodeForDocumentURL = {};47 this._rawSourceCodeForUISourceCode = new Map();48 39 this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._reset, this); 40 this._workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, this._uiSourceCodeAddedToWorkspace, this); 41 42 /** @type {Object.<string, WebInspector.UISourceCode>} */ 43 this._uiSourceCodeForScriptId = {}; 44 this._scriptIdForUISourceCode = new Map(); 45 this._temporaryUISourceCodes = new Map(); 46 /** @type {Object.<string, number>} */ 47 this._nextDynamicScriptIndexForURL = {}; 49 48 } 50 49 … … 57 56 { 58 57 var debuggerModelLocation = /** @type {WebInspector.DebuggerModel.Location} */ rawLocation; 59 var rawSourceCode = this._rawSourceCodeForScriptId[debuggerModelLocation.scriptId]; 60 return rawSourceCode.rawLocationToUILocation(debuggerModelLocation); 58 var script = WebInspector.debuggerModel.scriptForId(debuggerModelLocation.scriptId); 59 var uiSourceCode = this._uiSourceCodeForScriptId[debuggerModelLocation.scriptId]; 60 return new WebInspector.UILocation(uiSourceCode, debuggerModelLocation.lineNumber, debuggerModelLocation.columnNumber || 0); 61 61 }, 62 62 … … 69 69 uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber) 70 70 { 71 var rawSourceCode = this._rawSourceCodeForUISourceCode.get(uiSourceCode); 72 return rawSourceCode.uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber); 71 var scriptId = this._scriptIdForUISourceCode.get(uiSourceCode); 72 var script = WebInspector.debuggerModel.scriptForId(scriptId); 73 return WebInspector.debuggerModel.createRawLocation(script, lineNumber, columnNumber); 73 74 }, 74 75 … … 78 79 addScript: function(script) 79 80 { 80 var resource = null; 81 var request = null; 81 console.assert(!this._uiSourceCodeForScriptId[script.scriptId]); 82 83 var isDynamicScript = false; 82 84 if (!script.isAnonymousScript()) { 83 // First lookup the resource that has already been loaded. 84 resource = WebInspector.resourceForURL(script.sourceURL); 85 // Ignore resource in case it has not yet finished loading. 86 if (resource && resource.request && !resource.request.finished) 87 resource = null; 88 // Only bind inline and standalone scripts. 89 if (resource && !this._shouldBindScriptToContentProvider(script, resource)) 90 resource = null; 91 if (!resource) { 92 // When there is no resource, lookup in-flight requests. 93 request = WebInspector.networkManager.inflightRequestForURL(script.sourceURL); 94 // Only bind inline and standalone scripts. 95 if (request && !this._shouldBindScriptToContentProvider(script, request)) 96 request = null; 97 } 98 } 99 console.assert(!resource || !request); 100 101 var isInlineScript = script.isInlineScript() && (request || resource); 102 // If either of these exists, we bind script to the resource. 103 if (isInlineScript) { 104 var rawSourceCode = this._rawSourceCodeForDocumentURL[script.sourceURL]; 105 if (rawSourceCode) { 106 rawSourceCode.addScript(script); 107 this._bindScriptToRawSourceCode(script, rawSourceCode); 108 return; 109 } 110 } 111 112 var rawSourceCode = new WebInspector.RawSourceCode(script.scriptId, script, resource, request, this); 113 this._rawSourceCodes.push(rawSourceCode); 114 this._bindScriptToRawSourceCode(script, rawSourceCode); 115 if (isInlineScript) 116 this._rawSourceCodeForDocumentURL[script.sourceURL] = rawSourceCode; 117 118 if (rawSourceCode.uiSourceCode()) 119 this._uiSourceCodeAdded(rawSourceCode, rawSourceCode.uiSourceCode()); 120 rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeChanged, this._handleUISourceCodeChanged, this); 85 var uiSourceCode = this._workspace.uiSourceCodeForURL(script.sourceURL); 86 isDynamicScript = !!uiSourceCode && uiSourceCode.contentType() === WebInspector.resourceTypes.Document && !script.isInlineScript(); 87 if (uiSourceCode && !isDynamicScript && !this._temporaryUISourceCodes.get(uiSourceCode)) 88 this._bindUISourceCodeToScripts(uiSourceCode, [script]); 89 } 90 if (!this._uiSourceCodeForScriptId[script.scriptId]) 91 this._addOrReplaceTemporaryUISourceCode(script, isDynamicScript); 92 93 console.assert(this._uiSourceCodeForScriptId[script.scriptId]); 94 }, 95 96 /** 97 * @param {WebInspector.UISourceCode} uiSourceCode 98 * @param {Array.<WebInspector.Script>} scripts 99 */ 100 _bindUISourceCodeToScripts: function(uiSourceCode, scripts) 101 { 102 console.assert(scripts.length); 103 104 for (var i = 0; i < scripts.length; ++i) { 105 this._uiSourceCodeForScriptId[scripts[i].scriptId] = uiSourceCode; 106 scripts[i].setSourceMapping(this); 107 } 108 uiSourceCode.isContentScript = scripts[0].isContentScript; 109 uiSourceCode.setSourceMapping(this); 110 this._scriptIdForUISourceCode.put(uiSourceCode, scripts[0].scriptId); 111 }, 112 113 /** 114 * @param {string} sourceURL 115 * @param {boolean} isInlineScript 116 * @return {Array.<WebInspector.Script>} 117 */ 118 _scriptsForSourceURL: function(sourceURL, isInlineScript) 119 { 120 function filter(script) 121 { 122 return script.sourceURL === sourceURL && script.isInlineScript() === isInlineScript; 123 } 124 125 return Object.values(WebInspector.debuggerModel.scripts).filter(filter); 121 126 }, 122 127 123 128 /** 124 129 * @param {WebInspector.Script} script 125 * @param {WebInspector.ContentProvider} contentProvider 126 * @return {boolean} 127 */ 128 _shouldBindScriptToContentProvider: function(script, contentProvider) 129 { 130 if (script.isInlineScript()) 131 return contentProvider.contentType() === WebInspector.resourceTypes.Document; 132 return contentProvider.contentType() === WebInspector.resourceTypes.Script; 133 }, 134 135 /** 136 * @param {WebInspector.Event} event 137 */ 138 _handleUISourceCodeChanged: function(event) 139 { 140 var rawSourceCode = /** @type {WebInspector.RawSourceCode} */ event.target; 141 var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.data.uiSourceCode; 142 var oldUISourceCode = /** @type {WebInspector.UISourceCode} */ event.data.oldUISourceCode; 143 if (!oldUISourceCode) 144 this._uiSourceCodeAdded(rawSourceCode, uiSourceCode); 130 * @param {boolean} isDynamicScript 131 */ 132 _addOrReplaceTemporaryUISourceCode: function(script, isDynamicScript) 133 { 134 var scripts = script.isInlineScript() ? this._scriptsForSourceURL(script.sourceURL, true) : [script]; 135 136 var oldUISourceCode; 137 for (var i = 0; i < scripts.length; ++i) { 138 oldUISourceCode = this._uiSourceCodeForScriptId[scripts[i].scriptId]; 139 if (oldUISourceCode) 140 break; 141 } 142 console.assert(!oldUISourceCode || this._temporaryUISourceCodes.get(oldUISourceCode)); 143 144 var contentProvider = script.isInlineScript() ? new WebInspector.ConcatenatedScriptsContentProvider(scripts) : script; 145 var url = script.sourceURL; 146 if (isDynamicScript) { 147 var nextIndex = this._nextDynamicScriptIndexForURL[script.sourceURL] || 1; 148 url += " (" + nextIndex + ")"; 149 this._nextDynamicScriptIndexForURL[script.sourceURL] = nextIndex + 1; 150 } 151 var uiSourceCode = new WebInspector.JavaScriptSource(url, null, contentProvider, !script.isInlineScript()); 152 this._temporaryUISourceCodes.put(uiSourceCode, uiSourceCode); 153 this._bindUISourceCodeToScripts(uiSourceCode, scripts); 154 155 if (!script.sourceURL) 156 return uiSourceCode; 157 158 if (oldUISourceCode) 159 this._uiSourceCodeReplaced(oldUISourceCode, uiSourceCode); 145 160 else 146 this._uiSourceCodeReplaced(rawSourceCode, oldUISourceCode, uiSourceCode); 147 }, 148 149 /** 150 * @param {WebInspector.RawSourceCode} rawSourceCode 151 * @paran {WebInspector.UISourceCode} uiSourceCode 152 */ 153 _uiSourceCodeAdded: function(rawSourceCode, uiSourceCode) 154 { 155 if (!uiSourceCode.url) 161 this._workspace.project().addUISourceCode(uiSourceCode); 162 return uiSourceCode; 163 }, 164 165 _uiSourceCodeAddedToWorkspace: function(event) 166 { 167 var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.data; 168 console.assert(!this._scriptIdForUISourceCode.get(uiSourceCode) || this._temporaryUISourceCodes.get(uiSourceCode)); 169 if (!uiSourceCode.url || this._temporaryUISourceCodes.get(uiSourceCode)) 156 170 return; 157 this._rawSourceCodeForUISourceCode.put(uiSourceCode, rawSourceCode); 158 this._workspace.project().addUISourceCode(uiSourceCode); 159 }, 160 161 /** 162 * @param {WebInspector.RawSourceCode} rawSourceCode 171 this._addUISourceCode(uiSourceCode); 172 }, 173 174 /** 175 * @param {WebInspector.UISourceCode} uiSourceCode 176 */ 177 _addUISourceCode: function(uiSourceCode) 178 { 179 var isInlineScript; 180 switch (uiSourceCode.contentType()) { 181 case WebInspector.resourceTypes.Document: 182 isInlineScript = true; 183 break; 184 case WebInspector.resourceTypes.Script: 185 isInlineScript = false; 186 break; 187 default: 188 return; 189 } 190 191 var scripts = this._scriptsForSourceURL(uiSourceCode.url, isInlineScript); 192 if (!scripts.length) 193 return; 194 195 var oldUISourceCode = this._uiSourceCodeForScriptId[scripts[0].scriptId]; 196 this._bindUISourceCodeToScripts(uiSourceCode, scripts); 197 198 if (oldUISourceCode) { 199 console.assert(this._temporaryUISourceCodes.get(oldUISourceCode)); 200 this._uiSourceCodeReplaced(oldUISourceCode, uiSourceCode); 201 } 202 203 console.assert(this._scriptIdForUISourceCode.get(uiSourceCode) && !this._temporaryUISourceCodes.get(uiSourceCode)); 204 }, 205 206 /** 163 207 * @param {WebInspector.UISourceCode} oldUISourceCode 164 208 * @param {WebInspector.UISourceCode} uiSourceCode 165 209 */ 166 _uiSourceCodeReplaced: function(rawSourceCode, oldUISourceCode, uiSourceCode) 167 { 168 if (!uiSourceCode.url) 169 return; 170 this._rawSourceCodeForUISourceCode.remove(oldUISourceCode); 171 this._rawSourceCodeForUISourceCode.put(uiSourceCode, rawSourceCode); 172 173 for (var i = 0; i < rawSourceCode._scripts.length; ++i) 174 rawSourceCode._scripts[i].setSourceMapping(this); 210 _uiSourceCodeReplaced: function(oldUISourceCode, uiSourceCode) 211 { 212 this._temporaryUISourceCodes.remove(oldUISourceCode); 213 this._scriptIdForUISourceCode.remove(oldUISourceCode); 175 214 this._workspace.project().replaceUISourceCode(oldUISourceCode, uiSourceCode); 176 215 }, 177 216 178 /**179 * @param {WebInspector.RawSourceCode} rawSourceCode180 * @paran {WebInspector.UISourceCode} uiSourceCode181 */182 _uiSourceCodeRemoved: function(rawSourceCode, uiSourceCode)183 {184 if (!uiSourceCode.url)185 return;186 this._rawSourceCodeForUISourceCode.remove(uiSourceCode);187 },188 189 /**190 * @param {WebInspector.Script} script191 * @param {WebInspector.RawSourceCode} rawSourceCode192 */193 _bindScriptToRawSourceCode: function(script, rawSourceCode)194 {195 this._rawSourceCodeForScriptId[script.scriptId] = rawSourceCode;196 this._rawSourceCodeForURL[script.sourceURL] = rawSourceCode;197 script.setSourceMapping(this);198 },199 200 217 _reset: function() 201 218 { 202 for (var i = 0; i < this._rawSourceCodes.length; ++i) { 203 var rawSourceCode = this._rawSourceCodes[i]; 204 this._uiSourceCodeRemoved(rawSourceCode, rawSourceCode.uiSourceCode()); 205 rawSourceCode.removeAllListeners(); 206 } 207 this._rawSourceCodes = []; 208 this._rawSourceCodeForScriptId = {}; 209 this._rawSourceCodeForURL = {}; 210 this._rawSourceCodeForDocumentURL = {}; 211 this._rawSourceCodeForUISourceCode.clear(); 212 } 219 this._uiSourceCodeForScriptId = {}; 220 this._scriptIdForUISourceCode.clear(); 221 this._temporaryUISourceCodes.clear(); 222 this._nextDynamicScriptIndexForURL = {}; 223 }, 213 224 } -
trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js
r126999 r127427 82 82 { 83 83 var snippetJavaScriptSource = new WebInspector.SnippetJavaScriptSource(snippet.id, snippet.name, new WebInspector.SnippetContentProvider(snippet), this); 84 snippetJavaScriptSource.setSourceMapping(this._snippetScriptMapping); 84 85 this._snippetJavaScriptSourceForSnippetId[snippet.id] = snippetJavaScriptSource; 85 86 this._workspace.project().addUISourceCode(snippetJavaScriptSource); … … 279 280 _createUISourceCodeForScript: function(script) 280 281 { 281 var uiSourceCode = new WebInspector.JavaScriptSource(script.sourceURL, null, script, this._snippetScriptMapping, false); 282 var uiSourceCode = new WebInspector.JavaScriptSource(script.sourceURL, null, script, false); 283 uiSourceCode.setSourceMapping(this._snippetScriptMapping); 282 284 uiSourceCode.isSnippetEvaluation = true; 283 285 this._uiSourceCodeForScriptId[script.scriptId] = uiSourceCode; … … 373 375 WebInspector.SnippetJavaScriptSource = function(snippetId, snippetName, contentProvider, scriptSnippetModel) 374 376 { 375 WebInspector.JavaScriptSource.call(this, snippetName, null, contentProvider, scriptSnippetModel.scriptMapping,true);377 WebInspector.JavaScriptSource.call(this, snippetName, null, contentProvider, true); 376 378 this._snippetId = snippetId; 377 379 this._scriptSnippetModel = scriptSnippetModel; -
trunk/Source/WebCore/inspector/front-end/UISourceCode.js
r125767 r127427 37 37 * @param {WebInspector.Resource} resource 38 38 * @param {WebInspector.ContentProvider} contentProvider 39 * @param {WebInspector.SourceMapping=} sourceMapping40 39 */ 41 WebInspector.UISourceCode = function(url, resource, contentProvider , sourceMapping)40 WebInspector.UISourceCode = function(url, resource, contentProvider) 42 41 { 43 42 this._url = url; … … 45 44 this._parsedURL = new WebInspector.ParsedURL(url); 46 45 this._contentProvider = contentProvider; 47 this._sourceMapping = sourceMapping;48 46 this.isContentScript = false; 49 47 /** … … 385 383 uiLocationToRawLocation: function(lineNumber, columnNumber) 386 384 { 385 if (!this._sourceMapping) 386 return null; 387 387 var location = this._formatterMapping.formattedToOriginal(lineNumber, columnNumber); 388 388 return this._sourceMapping.uiLocationToRawLocation(this, location[0], location[1]); … … 538 538 }, 539 539 540 /** 541 * @param {WebInspector.SourceMapping} sourceMapping 542 */ 543 setSourceMapping: function(sourceMapping) 544 { 545 this._sourceMapping = sourceMapping; 546 }, 547 540 548 formattedChanged: function() 541 549 { -
trunk/Source/WebCore/inspector/front-end/WebKit.qrc
r127417 r127427 109 109 <file>NetworkItemView.js</file> 110 110 <file>NetworkLog.js</file> 111 <file>NetworkUISourceCodeProvider.js</file> 111 112 <file>NetworkManager.js</file> 112 113 <file>NetworkPanel.js</file> … … 128 129 <file>PropertiesSection.js</file> 129 130 <file>PropertiesSidebarPane.js</file> 130 <file>RawSourceCode.js</file>131 131 <file>RemoteObject.js</file> 132 132 <file>Resource.js</file> … … 182 182 <file>StyleSource.js</file> 183 183 <file>StylesSourceMapping.js</file> 184 <file>StylesUISourceCodeProvider.js</file>185 184 <file>StylesSidebarPane.js</file> 186 185 <file>TabbedEditorContainer.js</file> -
trunk/Source/WebCore/inspector/front-end/inspector.html
r127417 r127427 140 140 <script type="text/javascript" src="BreakpointManager.js"></script> 141 141 <script type="text/javascript" src="ContentProviders.js"></script> 142 <script type="text/javascript" src="RawSourceCode.js"></script>143 142 <script type="text/javascript" src="ResourceScriptMapping.js"></script> 144 143 <script type="text/javascript" src="CompilerScriptMapping.js"></script> … … 163 162 <script type="text/javascript" src="ProgressBar.js"></script> 164 163 <script type="text/javascript" src="StylesSourceMapping.js"></script> 165 <script type="text/javascript" src="StylesUISourceCodeProvider.js"></script>166 164 <script type="text/javascript" src="StyleSource.js"></script> 165 <script type="text/javascript" src="NetworkUISourceCodeProvider.js"></script> 167 166 <script type="text/javascript" src="ElementsPanelDescriptor.js"></script> 168 167 <script type="text/javascript" src="NetworkPanelDescriptor.js"></script> -
trunk/Source/WebCore/inspector/front-end/inspector.js
r127417 r127427 524 524 this.scriptSnippetModel = new WebInspector.ScriptSnippetModel(this.workspace); 525 525 new WebInspector.DebuggerScriptMapping(this.workspace); 526 new WebInspector. StylesUISourceCodeProvider(this.workspace);526 new WebInspector.NetworkUISourceCodeProvider(this.workspace); 527 527 if (WebInspector.experimentsSettings.sass.isEnabled()) 528 528 new WebInspector.SASSSourceMapping(this.workspace);
Note: See TracChangeset
for help on using the changeset viewer.