Changeset 127427 in webkit


Ignore:
Timestamp:
Sep 3, 2012 9:34:08 AM (12 years ago)
Author:
vsevik@chromium.org
Message:

Web Inspector: Create JavaScriptSources based on network resources.
https://bugs.webkit.org/show_bug.cgi?id=95352

Reviewed by Pavel Feldman.

Source/WebCore:

Introduced NetworkUISourceCodeProvider that is listening for ResourceTreeModel and creates UISourceCodes for them.
RawSourceCode does not create uiSourceCodes based on resource anymore (this is done by NetworkUISourceCodeProvider instead).
Moved script <-> uiSourceCode binding logic from RawSourceCode to ResourceScriptMapping.
Removed rawSourceCode as it was not needed anymore.

Tests: inspector/debugger/network-uisourcecode-provider.html

inspector/debugger/resource-script-mapping.html

  • WebCore.gypi:
  • WebCore.vcproj/WebCore.vcproj:
  • inspector/compile-front-end.py:
  • inspector/front-end/CompilerScriptMapping.js:
  • inspector/front-end/JavaScriptSource.js:

(WebInspector.JavaScriptSource):

  • inspector/front-end/NetworkUISourceCodeProvider.js: Renamed from Source/WebCore/inspector/front-end/StylesUISourceCodeProvider.js.

(WebInspector.NetworkUISourceCodeProvider):
(WebInspector.NetworkUISourceCodeProvider.prototype._populate):
(WebInspector.NetworkUISourceCodeProvider.prototype._styleResourceAdded):
(WebInspector.NetworkUISourceCodeProvider.prototype._scriptResourceAdded.resourceFinished):
(WebInspector.NetworkUISourceCodeProvider.prototype._scriptResourceAdded):
(WebInspector.NetworkUISourceCodeProvider.prototype._addJavaScriptSource):
(WebInspector.NetworkUISourceCodeProvider.prototype._addUISourceCode):
(WebInspector.NetworkUISourceCodeProvider.prototype._resourceAdded):
(WebInspector.NetworkUISourceCodeProvider.prototype._reset):

  • inspector/front-end/RawSourceCode.js:
  • inspector/front-end/ResourceScriptMapping.js:

(WebInspector.ResourceScriptMapping):
(WebInspector.ResourceScriptMapping.prototype.rawLocationToUILocation):
(WebInspector.ResourceScriptMapping.prototype._bindUISourceCodeToScripts):
(WebInspector.ResourceScriptMapping.prototype._scriptsForSourceURL):
(WebInspector.ResourceScriptMapping.prototype._addOrReplaceTemporaryUISourceCode.get var):
(WebInspector.ResourceScriptMapping.prototype._addOrReplaceTemporaryUISourceCode):
(WebInspector.ResourceScriptMapping.prototype.get _uiSourceCodeReplaced):
(WebInspector.ResourceScriptMapping.prototype._reset):

  • inspector/front-end/ScriptSnippetModel.js:

(WebInspector.ScriptSnippetModel.prototype._addScriptSnippet):
(WebInspector.ScriptSnippetModel.prototype._createUISourceCodeForScript):
(WebInspector.SnippetJavaScriptSource):

  • inspector/front-end/UISourceCode.js:

(WebInspector.UISourceCode):
(WebInspector.UISourceCode.prototype.uiLocationToRawLocation):
(WebInspector.UISourceCode.prototype.setSourceMapping):

  • inspector/front-end/WebKit.qrc:
  • inspector/front-end/inspector.html:
  • inspector/front-end/inspector.js:

LayoutTests:

Removed raw-source-code.html test as RawSourceCode was removed by this patch.
Added resource-script-mapping.html to test script <-> uiSourceCode binding behavior.
Added network-uisourcecode-provider.html to test uiSourceCode creation behavior.
Updated dynamic-script-tag.html to better match expected behavior.

  • http/tests/inspector/network/network-request-revision-content.html:
  • http/tests/inspector/workspace-test.js: Added.

(initialize_WorkspaceTest.InspectorTest.createWorkspace):
(initialize_WorkspaceTest.InspectorTest.waitForWorkspaceUISourceCodeReplacedEvent.uiSourceCodeReplaced):
(initialize_WorkspaceTest.InspectorTest.waitForWorkspaceUISourceCodeReplacedEvent):
(initialize_WorkspaceTest.InspectorTest.waitForWorkspaceUISourceCodeAddedEvent.uiSourceCodeAdded):
(initialize_WorkspaceTest.InspectorTest.waitForWorkspaceUISourceCodeAddedEvent):
(initialize_WorkspaceTest.InspectorTest.addMockUISourceCodeToWorkspace):
(initialize_WorkspaceTest.InspectorTest._defaultUISourceCodeProviderEventHandler):
(initialize_WorkspaceTest.InspectorTest.dumpUISourceCode.didRequestContent):
(initialize_WorkspaceTest.InspectorTest.dumpUISourceCode):
(initialize_WorkspaceTest):

  • inspector/debugger/breakpoint-manager.html:
  • inspector/debugger/dynamic-script-tag-expected.txt:
  • inspector/debugger/dynamic-script-tag.html:
  • inspector/debugger/network-uisourcecode-provider-expected.txt: Added.
  • inspector/debugger/network-uisourcecode-provider.html: Added.
  • inspector/debugger/raw-source-code-expected.txt: Removed.
  • inspector/debugger/raw-source-code.html: Removed.
  • inspector/debugger/resource-script-mapping-expected.txt: Added.
  • inspector/debugger/resource-script-mapping.html: Added.
  • inspector/debugger/scripts-panel.html:
  • inspector/debugger/source-frame-count.html:
Location:
trunk
Files:
5 added
2 deleted
19 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r127425 r127427  
     12012-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
    1372012-09-03  Tommy Widenflycht  <tommyw@google.com>
    238
  • trunk/LayoutTests/http/tests/inspector/network/network-request-revision-content.html

    r125980 r127427  
    1515{
    1616    InspectorTest.addConsoleSniffer(step2, true);
    17     InspectorTest.addSniffer(WebInspector.StylesUISourceCodeProvider.prototype, "_resourceAdded", true);
     17    InspectorTest.addSniffer(WebInspector.NetworkUISourceCodeProvider.prototype, "_resourceAdded", true);
    1818    InspectorTest.evaluateInPage("loadStylesheet()");
    1919
  • trunk/LayoutTests/inspector/debugger/breakpoint-manager.html

    r126999 r127427  
    112112        _addUISourceCode: function(url)
    113113        {
    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);
    115116            uiSourceCodes[url] = uiSourceCode;
    116117            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
     1Tests that inline scripts and document.write scripts get different uiSourceCodes with different URLs. Bug 87119
    32
    43Debugger was enabled.
     4Dumping scripts:
     5script1: file:///usr/local/google/home/vsevik/chromium/src/third_party/WebKit/LayoutTests/inspector/debugger/dynamic-script-tag.html
     6Is anonymous:false
     7Is inline script:true
     8script2: file:///usr/local/google/home/vsevik/chromium/src/third_party/WebKit/LayoutTests/inspector/debugger/dynamic-script-tag.html
    59Is anonymous:false
    610Is inline script:false
    7 dynamic-script-tag.html
    8 UI name: dynamic-script-tag.html
     11script3: file:///usr/local/google/home/vsevik/chromium/src/third_party/WebKit/LayoutTests/inspector/debugger/dynamic-script-tag.html
     12Is anonymous:false
     13Is inline script:false
     14Dumping uiSourceCodes:
     15UISourceCode: file:///usr/local/google/home/vsevik/chromium/src/third_party/WebKit/LayoutTests/inspector/debugger/dynamic-script-tag.html (1)
     16UISourceCode is editable: true
     17UISourceCode is content script: false
     18Mime type: text/javascript
     19UISourceCode content: function bar() { }
    920UI resource: null
    10 UI content: console.log(123)
     21UISourceCode: file:///usr/local/google/home/vsevik/chromium/src/third_party/WebKit/LayoutTests/inspector/debugger/dynamic-script-tag.html (2)
     22UISourceCode is editable: true
     23UISourceCode is content script: false
     24Mime type: text/javascript
     25UISourceCode content: function foo() { }
     26UI resource: null
    1127Debugger was disabled.
    1228
  • trunk/LayoutTests/inspector/debugger/dynamic-script-tag.html

    r117966 r127427  
    33<script src="../../http/tests/inspector/inspector-test.js"></script>
    44<script src="../../http/tests/inspector/debugger-test.js"></script>
     5<script src="../../http/tests/inspector/workspace-test.js"></script>
     6<script>
     7document.write("<scrip" + "t>function foo() { }</sc" + "ript>");
     8var scriptElement = document.createElement("script");
     9scriptElement.textContent = "function bar() { }";
     10document.head.appendChild(scriptElement);
    511
    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()
     12var test = function()
    1613{
    1714    InspectorTest.startDebuggerTest(step1);
     
    1916    function step1()
    2017    {
    21         InspectorTest.evaluateInPage("createScriptTag()");
    22         WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedScriptSource, step2);
    23     }
     18        var model = WebInspector.debuggerModel;
    2419
    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)
    3022        {
    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);
    3339            InspectorTest.addResult("Is anonymous:" + script.isAnonymousScript());
    3440            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);
    3843        }
    39     }
    4044
    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)
    4846        {
    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        {
    5078            InspectorTest.completeDebuggerTest();
    5179        }
     
    5583</head>
    5684<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.
    5986<a href="https://bugs.webkit.org/show_bug.cgi?id=87119">Bug 87119</a>
    60 </p>
    6187</body>
    62 
    6388</html>
  • trunk/LayoutTests/inspector/debugger/scripts-panel.html

    r126999 r127427  
    2525    function createUISouceCode(url)
    2626    {
    27         var uiSourceCode = new WebInspector.JavaScriptSource(url, null, contentProvider, null, false);
     27        var uiSourceCode = new WebInspector.JavaScriptSource(url, null, contentProvider, false);
    2828        uiSourceCode.requestContent = function(callback)
    2929        {
  • trunk/Source/WebCore/ChangeLog

    r127426 r127427  
     12012-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
    1542012-09-03  Andrey Adaikin  <aandrey@chromium.org>
    255
  • trunk/Source/WebCore/WebCore.gypi

    r127425 r127427  
    63586358            'inspector/front-end/NetworkPanelDescriptor.js',
    63596359            'inspector/front-end/NetworkRequest.js',
     6360            'inspector/front-end/NetworkUISourceCodeProvider.js',
    63606361            'inspector/front-end/Object.js',
    63616362            'inspector/front-end/ObjectPopoverHelper.js',
     
    63696370            'inspector/front-end/ProgressBar.js',
    63706371            'inspector/front-end/PropertiesSection.js',
    6371             'inspector/front-end/RawSourceCode.js',
    63726372            'inspector/front-end/RemoteObject.js',
    63736373            'inspector/front-end/Resource.js',
     
    64066406            'inspector/front-end/StyleSource.js',
    64076407            'inspector/front-end/StylesSourceMapping.js',
    6408             'inspector/front-end/StylesUISourceCodeProvider.js',
    64096408            'inspector/front-end/TabbedPane.js',
    64106409            'inspector/front-end/TestController.js',
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r127417 r127427  
    7631976319                                </File>
    7632076320                                <File
     76321                                        RelativePath="..\inspector\front-end\NetworkUISourceCodeProvider.js"
     76322                                        >
     76323                                </File>
     76324                                <File
    7632176325                                        RelativePath="..\inspector\front-end\NetworkRequest.js"
    7632276326                                        >
     
    7639576399                                </File>
    7639676400                                <File
    76397                                         RelativePath="..\inspector\front-end\RawSourceCode.js"
    76398                                         >
    76399                                 </File>
    76400                                 <File
    7640176401                                        RelativePath="..\inspector\front-end\RemoteObject.js"
    7640276402                                        >
     
    7662876628                                <File
    7662976629                                        RelativePath="..\inspector\front-end\StylesSourceMapping.js"
    76630                                         >
    76631                                 </File>
    76632                                 <File
    76633                                         RelativePath="..\inspector\front-end\StylesUISourceCodeProvider.js"
    7663476630                                        >
    7663576631                                </File>
  • trunk/Source/WebCore/inspector/compile-front-end.py

    r127417 r127427  
    8383            "Linkifier.js",
    8484            "NetworkLog.js",
     85            "NetworkUISourceCodeProvider.js",
    8586            "PresentationConsoleMessageHelper.js",
    8687            "SASSSourceMapping.js",
     
    9293            "StyleSource.js",
    9394            "StylesSourceMapping.js",
    94             "StylesUISourceCodeProvider.js",
    9595            "TimelineManager.js",
    96             "RawSourceCode.js",
    9796            "RemoteObject.js",
    9897            "Resource.js",
  • trunk/Source/WebCore/inspector/front-end/CompilerScriptMapping.js

    r126999 r127427  
    121121            else
    122122                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);
    124125            uiSourceCode.isContentScript = script.isContentScript;
    125126            this._uiSourceCodeByURL[sourceURL] = uiSourceCode;
  • trunk/Source/WebCore/inspector/front-end/JavaScriptSource.js

    r123852 r127427  
    3535 * @param {WebInspector.Resource} resource
    3636 * @param {WebInspector.ContentProvider} contentProvider
    37  * @param {WebInspector.SourceMapping} sourceMapping
    3837 */
    39 WebInspector.JavaScriptSource = function(url, resource, contentProvider, sourceMapping, isEditable)
     38WebInspector.JavaScriptSource = function(url, resource, contentProvider, isEditable)
    4039{
    41     WebInspector.UISourceCode.call(this, url, resource, contentProvider, sourceMapping);
     40    WebInspector.UISourceCode.call(this, url, resource, contentProvider);
    4241    this._isEditable = isEditable;
    4342}
  • trunk/Source/WebCore/inspector/front-end/NetworkUISourceCodeProvider.js

    r127426 r127427  
    3333 * @param {WebInspector.Workspace} workspace
    3434 */
    35 WebInspector.StylesUISourceCodeProvider = function(workspace)
     35WebInspector.NetworkUISourceCodeProvider = function(workspace)
    3636{
    3737    this._workspace = workspace;
     
    3939    this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._reset, this);
    4040    this._stylesSourceMapping = new WebInspector.StylesSourceMapping();
     41
     42    this._uiSourceCodeForResource = {};
    4143}
    4244
    43 WebInspector.StylesUISourceCodeProvider.prototype = {
     45WebInspector.NetworkUISourceCodeProvider.prototype = {
    4446    _populate: function()
    4547    {
     
    5860
    5961    /**
     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    /**
    60111     * @param {WebInspector.Event} event
    61112     */
     
    63114    {
    64115        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        }
    70125    },
    71126
    72127    _reset: function()
    73128    {
     129        this._uiSourceCodeForResource = {};
    74130        this._stylesSourceMapping.reset();
    75131        // 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 without
    5  * modification, are permitted provided that the following conditions are
    6  * met:
    7  *
    8  *     * Redistributions of source code must retain the above copyright
    9  * notice, this list of conditions and the following disclaimer.
    10  *     * Redistributions in binary form must reproduce the above
    11  * copyright notice, this list of conditions and the following disclaimer
    12  * in the documentation and/or other materials provided with the
    13  * distribution.
    14  *     * Neither the name of Google Inc. nor the names of its
    15  * contributors may be used to endorse or promote products derived from
    16  * this software without specific prior written permission.
    17  *
    18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    29  */
    30 
    31 // RawSourceCode represents JavaScript resource or HTML resource with inlined scripts
    32 // as it came from network.
    33 
    34 /**
    35  * @constructor
    36  * @extends {WebInspector.Object}
    37  * @param {string} id
    38  * @param {WebInspector.Script} script
    39  * @param {WebInspector.Resource} resource
    40  * @param {WebInspector.NetworkRequest} request
    41  * @param {WebInspector.SourceMapping} sourceMapping
    42  */
    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     else
    57         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} script
    67      */
    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} rawLocation
    80      * @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         else
    106             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} uiSourceCode
    115      * @param {number} lineNumber
    116      * @param {number} columnNumber
    117      * @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  
    3737{
    3838    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();
    4839    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 = {};
    4948}
    5049
     
    5756    {
    5857        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);
    6161    },
    6262
     
    6969    uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber)
    7070    {
    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);
    7374    },
    7475
     
    7879    addScript: function(script)
    7980    {
    80         var resource = null;
    81         var request = null;
     81        console.assert(!this._uiSourceCodeForScriptId[script.scriptId]);
     82
     83        var isDynamicScript = false;
    8284        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);
    121126    },
    122127
    123128    /**
    124129     * @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);
    145160        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))
    156170            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    /**
    163207     * @param {WebInspector.UISourceCode} oldUISourceCode
    164208     * @param {WebInspector.UISourceCode} uiSourceCode
    165209     */
    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);
    175214        this._workspace.project().replaceUISourceCode(oldUISourceCode, uiSourceCode);
    176215    },
    177216
    178     /**
    179      * @param {WebInspector.RawSourceCode} rawSourceCode
    180      * @paran {WebInspector.UISourceCode} uiSourceCode
    181      */
    182     _uiSourceCodeRemoved: function(rawSourceCode, uiSourceCode)
    183     {
    184         if (!uiSourceCode.url)
    185             return;
    186         this._rawSourceCodeForUISourceCode.remove(uiSourceCode);
    187     },
    188 
    189     /**
    190      * @param {WebInspector.Script} script
    191      * @param {WebInspector.RawSourceCode} rawSourceCode
    192      */
    193     _bindScriptToRawSourceCode: function(script, rawSourceCode)
    194     {
    195         this._rawSourceCodeForScriptId[script.scriptId] = rawSourceCode;
    196         this._rawSourceCodeForURL[script.sourceURL] = rawSourceCode;
    197         script.setSourceMapping(this);
    198     },
    199 
    200217    _reset: function()
    201218    {
    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    },
    213224}
  • trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js

    r126999 r127427  
    8282    {
    8383        var snippetJavaScriptSource = new WebInspector.SnippetJavaScriptSource(snippet.id, snippet.name, new WebInspector.SnippetContentProvider(snippet), this);
     84        snippetJavaScriptSource.setSourceMapping(this._snippetScriptMapping);
    8485        this._snippetJavaScriptSourceForSnippetId[snippet.id] = snippetJavaScriptSource;
    8586        this._workspace.project().addUISourceCode(snippetJavaScriptSource);
     
    279280    _createUISourceCodeForScript: function(script)
    280281    {
    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);
    282284        uiSourceCode.isSnippetEvaluation = true;
    283285        this._uiSourceCodeForScriptId[script.scriptId] = uiSourceCode;
     
    373375WebInspector.SnippetJavaScriptSource = function(snippetId, snippetName, contentProvider, scriptSnippetModel)
    374376{
    375     WebInspector.JavaScriptSource.call(this, snippetName, null, contentProvider, scriptSnippetModel.scriptMapping, true);
     377    WebInspector.JavaScriptSource.call(this, snippetName, null, contentProvider, true);
    376378    this._snippetId = snippetId;
    377379    this._scriptSnippetModel = scriptSnippetModel;
  • trunk/Source/WebCore/inspector/front-end/UISourceCode.js

    r125767 r127427  
    3737 * @param {WebInspector.Resource} resource
    3838 * @param {WebInspector.ContentProvider} contentProvider
    39  * @param {WebInspector.SourceMapping=} sourceMapping
    4039 */
    41 WebInspector.UISourceCode = function(url, resource, contentProvider, sourceMapping)
     40WebInspector.UISourceCode = function(url, resource, contentProvider)
    4241{
    4342    this._url = url;
     
    4544    this._parsedURL = new WebInspector.ParsedURL(url);
    4645    this._contentProvider = contentProvider;
    47     this._sourceMapping = sourceMapping;
    4846    this.isContentScript = false;
    4947    /**
     
    385383    uiLocationToRawLocation: function(lineNumber, columnNumber)
    386384    {
     385        if (!this._sourceMapping)
     386            return null;
    387387        var location = this._formatterMapping.formattedToOriginal(lineNumber, columnNumber);
    388388        return this._sourceMapping.uiLocationToRawLocation(this, location[0], location[1]);
     
    538538    },
    539539
     540    /**
     541     * @param {WebInspector.SourceMapping} sourceMapping
     542     */
     543    setSourceMapping: function(sourceMapping)
     544    {
     545        this._sourceMapping = sourceMapping;
     546    },
     547
    540548    formattedChanged: function()
    541549    {
  • trunk/Source/WebCore/inspector/front-end/WebKit.qrc

    r127417 r127427  
    109109    <file>NetworkItemView.js</file>
    110110    <file>NetworkLog.js</file>
     111    <file>NetworkUISourceCodeProvider.js</file>
    111112    <file>NetworkManager.js</file>
    112113    <file>NetworkPanel.js</file>
     
    128129    <file>PropertiesSection.js</file>
    129130    <file>PropertiesSidebarPane.js</file>
    130     <file>RawSourceCode.js</file>
    131131    <file>RemoteObject.js</file>
    132132    <file>Resource.js</file>
     
    182182    <file>StyleSource.js</file>
    183183    <file>StylesSourceMapping.js</file>
    184     <file>StylesUISourceCodeProvider.js</file>
    185184    <file>StylesSidebarPane.js</file>
    186185    <file>TabbedEditorContainer.js</file>
  • trunk/Source/WebCore/inspector/front-end/inspector.html

    r127417 r127427  
    140140    <script type="text/javascript" src="BreakpointManager.js"></script>
    141141    <script type="text/javascript" src="ContentProviders.js"></script>
    142     <script type="text/javascript" src="RawSourceCode.js"></script>
    143142    <script type="text/javascript" src="ResourceScriptMapping.js"></script>
    144143    <script type="text/javascript" src="CompilerScriptMapping.js"></script>
     
    163162    <script type="text/javascript" src="ProgressBar.js"></script>
    164163    <script type="text/javascript" src="StylesSourceMapping.js"></script>
    165     <script type="text/javascript" src="StylesUISourceCodeProvider.js"></script>
    166164    <script type="text/javascript" src="StyleSource.js"></script>
     165    <script type="text/javascript" src="NetworkUISourceCodeProvider.js"></script>
    167166    <script type="text/javascript" src="ElementsPanelDescriptor.js"></script>
    168167    <script type="text/javascript" src="NetworkPanelDescriptor.js"></script>
  • trunk/Source/WebCore/inspector/front-end/inspector.js

    r127417 r127427  
    524524    this.scriptSnippetModel = new WebInspector.ScriptSnippetModel(this.workspace);
    525525    new WebInspector.DebuggerScriptMapping(this.workspace);
    526     new WebInspector.StylesUISourceCodeProvider(this.workspace);
     526    new WebInspector.NetworkUISourceCodeProvider(this.workspace);
    527527    if (WebInspector.experimentsSettings.sass.isEnabled())
    528528        new WebInspector.SASSSourceMapping(this.workspace);
Note: See TracChangeset for help on using the changeset viewer.