Changeset 117600 in webkit


Ignore:
Timestamp:
May 18, 2012 9:10:34 AM (12 years ago)
Author:
vsevik@chromium.org
Message:

Web Inspector: Add resource to UISourceCode constructor.
https://bugs.webkit.org/show_bug.cgi?id=86853

Reviewed by Pavel Feldman.

Source/WebCore:

This is a first step of merging resource revision support into UISourceCode.

  • inspector/front-end/CompilerScriptMapping.js:
  • inspector/front-end/DebuggerResourceBinding.js:

(WebInspector.DebuggerResourceBinding.setScriptSource.didEditScriptSource):
(WebInspector.DebuggerResourceBinding.setScriptSource):

  • inspector/front-end/DebuggerScriptMapping.js:

(WebInspector.DebuggerScriptMapping.prototype._debuggerReset):

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

(WebInspector.RawSourceCode.prototype._createUISourceCode):

  • inspector/front-end/ResourceScriptMapping.js:

(WebInspector.ResourceScriptMapping.prototype.addScript):

  • inspector/front-end/Script.js:

(WebInspector.Script.prototype.isAnonymousScript):

  • inspector/front-end/ScriptSnippetModel.js:

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

  • inspector/front-end/StylesPanel.js:

(WebInspector.StyleSource):
(WebInspector.StyleSourceFrame):
(WebInspector.StyleSourceFrame.prototype.commitEditing):
(WebInspector.StyleSourceFrame.prototype.afterTextChanged):
(WebInspector.StyleSourceFrame.prototype._contentChanged):

  • inspector/front-end/UISourceCode.js:

(WebInspector.UISourceCode):
(WebInspector.UISourceCode.prototype.resource):

LayoutTests:

  • inspector/debugger/breakpoint-manager.html:
  • inspector/debugger/scripts-file-selector.html:
  • inspector/debugger/scripts-panel.html:
  • inspector/debugger/scripts-sorting.html:
  • inspector/debugger/ui-source-code.html:
Location:
trunk
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r117599 r117600  
     12012-05-18  Vsevolod Vlasov  <vsevik@chromium.org>
     2
     3        Web Inspector: Add resource to UISourceCode constructor.
     4        https://bugs.webkit.org/show_bug.cgi?id=86853
     5
     6        Reviewed by Pavel Feldman.
     7
     8        * inspector/debugger/breakpoint-manager.html:
     9        * inspector/debugger/scripts-file-selector.html:
     10        * inspector/debugger/scripts-panel.html:
     11        * inspector/debugger/scripts-sorting.html:
     12        * inspector/debugger/ui-source-code.html:
     13
    1142012-05-18  Yury Semikhatsky  <yurys@chromium.org>
    215
  • trunk/LayoutTests/inspector/debugger/breakpoint-manager.html

    r117269 r117600  
    137137        breakpointManager._debuggerModel._addScript(url, url);
    138138        InspectorTest.addResult("  Adding UISourceCode: " + url + ")");
    139         var uiSourceCode = new WebInspector.JavaScriptSource(url, null, defaultMapping, false);
     139        var uiSourceCode = new WebInspector.JavaScriptSource(url, null, null, defaultMapping, false);
    140140        uiSourceCodes[url] = uiSourceCode;
    141141        breakpointManager.restoreBreakpoints(uiSourceCode);
  • trunk/LayoutTests/inspector/debugger/scripts-file-selector.html

    r117571 r117600  
    2121    function addUISourceCode(url, isContentScript)
    2222    {
    23         var uiSourceCode = new WebInspector.UISourceCode(url, contentProvider, null);
     23        var uiSourceCode = new WebInspector.UISourceCode(url, null, contentProvider, null);
    2424        uiSourceCode.isContentScript = isContentScript;
    2525        navigatorFileSelector.addUISourceCode(uiSourceCode);
  • trunk/LayoutTests/inspector/debugger/scripts-panel.html

    r117571 r117600  
    5252    function createUISouceCode(url)
    5353    {
    54         var uiSourceCode = new WebInspector.JavaScriptSource(url, contentProvider, null, false);
     54        var uiSourceCode = new WebInspector.JavaScriptSource(url, null, contentProvider, null, false);
    5555        uiSourceCode.requestContent = function(callback)
    5656        {
  • trunk/LayoutTests/inspector/debugger/scripts-sorting.html

    r117571 r117600  
    2121    function addUISourceCode(url, isContentScript)
    2222    {
    23         var uiSourceCode = new WebInspector.UISourceCode(url, contentProvider, null);
     23        var uiSourceCode = new WebInspector.UISourceCode(url, null, contentProvider, null);
    2424        uiSourceCode.isContentScript = isContentScript;
    2525        navigatorFileSelector.addUISourceCode(uiSourceCode);
  • trunk/LayoutTests/inspector/debugger/ui-source-code.html

    r116846 r117600  
    1818        function testUISourceCode(next)
    1919        {
    20             var uiSourceCode = new WebInspector.UISourceCode("url", contentProvider);
     20            var uiSourceCode = new WebInspector.UISourceCode("url", null, contentProvider);
    2121            function didRequestContent(callNumber, content, contentEncoded, mimeType)
    2222            {
  • trunk/Source/WebCore/ChangeLog

    r117599 r117600  
     12012-05-18  Vsevolod Vlasov  <vsevik@chromium.org>
     2
     3        Web Inspector: Add resource to UISourceCode constructor.
     4        https://bugs.webkit.org/show_bug.cgi?id=86853
     5
     6        Reviewed by Pavel Feldman.
     7
     8        This is a first step of merging resource revision support into UISourceCode.
     9
     10        * inspector/front-end/CompilerScriptMapping.js:
     11        * inspector/front-end/DebuggerResourceBinding.js:
     12        (WebInspector.DebuggerResourceBinding.setScriptSource.didEditScriptSource):
     13        (WebInspector.DebuggerResourceBinding.setScriptSource):
     14        * inspector/front-end/DebuggerScriptMapping.js:
     15        (WebInspector.DebuggerScriptMapping.prototype._debuggerReset):
     16        * inspector/front-end/JavaScriptSource.js:
     17        * inspector/front-end/RawSourceCode.js:
     18        (WebInspector.RawSourceCode.prototype._createUISourceCode):
     19        * inspector/front-end/ResourceScriptMapping.js:
     20        (WebInspector.ResourceScriptMapping.prototype.addScript):
     21        * inspector/front-end/Script.js:
     22        (WebInspector.Script.prototype.isAnonymousScript):
     23        * inspector/front-end/ScriptSnippetModel.js:
     24        (WebInspector.ScriptSnippetModel.prototype._createUISourceCodeForScript):
     25        (WebInspector.SnippetJavaScriptSource):
     26        * inspector/front-end/StylesPanel.js:
     27        (WebInspector.StyleSource):
     28        (WebInspector.StyleSourceFrame):
     29        (WebInspector.StyleSourceFrame.prototype.commitEditing):
     30        (WebInspector.StyleSourceFrame.prototype.afterTextChanged):
     31        (WebInspector.StyleSourceFrame.prototype._contentChanged):
     32        * inspector/front-end/UISourceCode.js:
     33        (WebInspector.UISourceCode):
     34        (WebInspector.UISourceCode.prototype.resource):
     35
    1362012-05-18  Yury Semikhatsky  <yurys@chromium.org>
    237
  • trunk/Source/WebCore/inspector/front-end/CompilerScriptMapping.js

    r117571 r117600  
    119119            else
    120120                contentProvider = new WebInspector.CompilerSourceMappingContentProvider(sourceURL);
    121             var uiSourceCode = new WebInspector.JavaScriptSource(sourceURL, contentProvider, this, false);
     121            var uiSourceCode = new WebInspector.JavaScriptSource(sourceURL, null, contentProvider, this, false);
    122122            uiSourceCode.isContentScript = script.isContentScript;
    123123            this._uiSourceCodeByURL[sourceURL] = uiSourceCode;
  • trunk/Source/WebCore/inspector/front-end/DebuggerResourceBinding.js

    r117585 r117600  
    6161        }
    6262
    63         var resource = WebInspector.resourceForURL(script.sourceURL);
     63        var resource = uiSourceCode.resource();
    6464        if (resource)
    6565            resource.addRevision(newSource);
     
    7878    canSetContent: function(resource)
    7979    {
    80         var uiSourceCode = this._uiSourceCodeForResource(resource);
     80        var uiSourceCode = WebInspector.JavaScriptSource.javaScriptSourceForResource.get(resource);
    8181        return !!uiSourceCode && uiSourceCode.isEditable();
    8282    },
     
    9393            return;
    9494
    95         var uiSourceCode = this._uiSourceCodeForResource(resource);
     95        var uiSourceCode = WebInspector.JavaScriptSource.javaScriptSourceForResource.get(resource);
    9696        if (!uiSourceCode) {
    9797            userCallback("Resource is not editable");
     
    100100
    101101        resource.requestContent(this._setContentWithInitialContent.bind(this, uiSourceCode, content, userCallback));
    102     },
    103 
    104     /**
    105      * @param {WebInspector.Resource} resource
    106      * @return {WebInspector.UISourceCode}
    107      */
    108     _uiSourceCodeForResource: function(resource)
    109     {
    110         var uiSourceCodes = this._uiSourceCodeProvider.uiSourceCodes();
    111         for (var i = 0; i < uiSourceCodes.length; ++i) {
    112             if (uiSourceCodes[i].url === resource.url)
    113                 return uiSourceCodes[i];
    114         }
    115         return null;
    116102    },
    117103
  • trunk/Source/WebCore/inspector/front-end/DebuggerScriptMapping.js

    r117302 r117600  
    8888    _debuggerReset: function()
    8989    {
     90        WebInspector.JavaScriptSource.javaScriptSourceForResource.clear();
    9091        for (var i = 0; i < this._mappings.length; ++i)
    9192            this._mappings[i].reset();
  • trunk/Source/WebCore/inspector/front-end/JavaScriptSource.js

    r117299 r117600  
    3333 * @extends {WebInspector.UISourceCode}
    3434 * @param {string} url
     35 * @param {WebInspector.Resource} resource
    3536 * @param {WebInspector.ContentProvider} contentProvider
    3637 * @param {WebInspector.SourceMapping} sourceMapping
    3738 */
    38 WebInspector.JavaScriptSource = function(url, contentProvider, sourceMapping, isEditable)
     39WebInspector.JavaScriptSource = function(url, resource, contentProvider, sourceMapping, isEditable)
    3940{
    40     WebInspector.UISourceCode.call(this, url, contentProvider, sourceMapping);
     41    WebInspector.UISourceCode.call(this, url, resource, contentProvider, sourceMapping);
    4142    this._isEditable = isEditable;
    4243
     
    4748            WebInspector.breakpointManager.restoreBreakpoints(this);
    4849    }.bind(this), 0);
     50    if (resource)
     51        WebInspector.JavaScriptSource.javaScriptSourceForResource.put(resource, this);
    4952}
     53
     54WebInspector.JavaScriptSource.javaScriptSourceForResource = new Map();
    5055
    5156WebInspector.JavaScriptSource.prototype = {
  • trunk/Source/WebCore/inspector/front-end/RawSourceCode.js

    r117269 r117600  
    101101            contentProvider = new WebInspector.ConcatenatedScriptsContentProvider(this._scripts);
    102102
    103         var uiSourceCode = new WebInspector.JavaScriptSource(this.url, contentProvider, this._sourceMapping, isStandaloneScript);
     103        var uiSourceCode = new WebInspector.JavaScriptSource(this.url, this._resource, contentProvider, this._sourceMapping, isStandaloneScript);
    104104        uiSourceCode.isContentScript = this.isContentScript;
    105105        return uiSourceCode;
  • trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js

    r117277 r117600  
    8888        var resource = null;
    8989        var request = null;
    90         var isInlineScript = false;
    91         if (script.isInlineScript()) {
    92             // First lookup the resource that has already been loaded. We are only interested in Document resources.
     90        if (!script.isAnonymousScript()) {
     91            // First lookup the resource that has already been loaded.
    9392            resource = WebInspector.resourceForURL(script.sourceURL);
    94             if (resource && resource.type !== WebInspector.resourceTypes.Document)
    95                 resource = null;
    9693            // Ignore resource in case it has not yet finished loading.
    9794            if (resource && resource.request && !resource.request.finished)
    9895                resource = null;
    9996            if (!resource) {
    100                 // When there is no resource, lookup in-flight requests of type Document.
     97                // When there is no resource, lookup in-flight requests.
    10198                request = WebInspector.networkManager.inflightRequestForURL(script.sourceURL);
    102                 if (request && request.type !== WebInspector.resourceTypes.Document)
    103                     request = null;
    10499            }
    105             // If either of these exists, we bind script to the resource.
    106             if (request || resource) {
    107                 isInlineScript = true;
    108                 var rawSourceCode = this._rawSourceCodeForDocumentURL[script.sourceURL];
    109                 if (rawSourceCode) {
    110                     rawSourceCode.addScript(script);
    111                     this._bindScriptToRawSourceCode(script, rawSourceCode);
    112                     return;
    113                 }
     100        }
     101        console.assert(!resource || !request);
     102
     103        var isInlineScript = script.isInlineScript() && (request || resource);
     104        // If either of these exists, we bind script to the resource.
     105        if (isInlineScript) {
     106            var rawSourceCode = this._rawSourceCodeForDocumentURL[script.sourceURL];
     107            if (rawSourceCode) {
     108                rawSourceCode.addScript(script);
     109                this._bindScriptToRawSourceCode(script, rawSourceCode);
     110                return;
    114111            }
    115112        }
  • trunk/Source/WebCore/inspector/front-end/Script.js

    r117571 r117600  
    160160
    161161    /**
     162     * @return {boolean}
     163     */
     164    isAnonymousScript: function()
     165    {
     166        return !this.sourceURL;
     167    },
     168
     169    /**
    162170     * @param {DebuggerAgent.Location} rawLocation
    163171     * @return {WebInspector.UILocation}
  • trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js

    r117571 r117600  
    216216    _createUISourceCodeForScript: function(script)
    217217    {
    218         var uiSourceCode = new WebInspector.JavaScriptSource(script.sourceURL, script, this._snippetScriptMapping, false);
     218        var uiSourceCode = new WebInspector.JavaScriptSource(script.sourceURL, null, script, this._snippetScriptMapping, false);
    219219        uiSourceCode.isSnippetEvaluation = true;
    220220        this._uiSourceCodeForScriptId[script.scriptId] = uiSourceCode;
     
    302302WebInspector.SnippetJavaScriptSource = function(snippetId, snippetName, contentProvider, scriptSnippetModel)
    303303{
    304     WebInspector.JavaScriptSource.call(this, snippetName, contentProvider, scriptSnippetModel.scriptMapping, true);
     304    WebInspector.JavaScriptSource.call(this, snippetName, null, contentProvider, scriptSnippetModel.scriptMapping, true);
    305305    this._snippetId = snippetId;
    306306    this._scriptSnippetModel = scriptSnippetModel;
  • trunk/Source/WebCore/inspector/front-end/StylesPanel.js

    r117571 r117600  
    9595WebInspector.StyleSource = function(resource)
    9696{
    97     WebInspector.UISourceCode.call(this, resource.url, resource);
    98     this._resource = resource;
     97    WebInspector.UISourceCode.call(this, resource.url, resource, resource);
    9998}
    10099
     
    111110WebInspector.StyleSourceFrame = function(styleSource)
    112111{
    113     this._resource = styleSource._resource;
    114112    this._styleSource = styleSource;
    115113    WebInspector.SourceFrame.call(this, this._styleSource);
    116     this._resource.addEventListener(WebInspector.Resource.Events.RevisionAdded, this._contentChanged, this);
     114    this._styleSource.resource().addEventListener(WebInspector.Resource.Events.RevisionAdded, this._contentChanged, this);
    117115}
    118116
     
    131129    commitEditing: function(text)
    132130    {
    133         this._resource.setContent(text, true, function() {});
     131        this._styleSource.resource().setContent(text, true, function() {});
    134132    },
    135133
     
    140138            var text = this._textModel.text;
    141139            this._styleSource.setWorkingCopy(text);
    142             this._resource.setContent(text, false, function() {});
     140            this._styleSource.resource().setContent(text, false, function() {});
    143141        }
    144142        const updateTimeout = 200;
     
    155153    _contentChanged: function(event)
    156154    {
    157         this._styleSource.contentChanged(this._resource.content || "");
    158         this.setContent(this._resource.content, false, "text/stylesheet");
     155        this._styleSource.contentChanged(this._styleSource.resource().content || "");
     156        this.setContent(this._styleSource.resource().content, false, "text/stylesheet");
    159157    }
    160158}
  • trunk/Source/WebCore/inspector/front-end/UISourceCode.js

    r117571 r117600  
    3535 * @implements {WebInspector.ContentProvider}
    3636 * @param {string} url
     37 * @param {WebInspector.Resource} resource
    3738 * @param {WebInspector.ContentProvider} contentProvider
    3839 * @param {WebInspector.SourceMapping=} sourceMapping
    3940 */
    40 WebInspector.UISourceCode = function(url, contentProvider, sourceMapping)
     41WebInspector.UISourceCode = function(url, resource, contentProvider, sourceMapping)
    4142{
    4243    this._url = url;
     44    this._resource = resource;
    4345    this._parsedURL = new WebInspector.ParsedURL(url);
    4446    this._contentProvider = contentProvider;
     
    8284        this._parsedURL = new WebInspector.ParsedURL(this._url);
    8385        this.dispatchEventToListeners(WebInspector.UISourceCode.Events.TitleChanged, null);
     86    },
     87
     88    /**
     89     * @return {WebInspector.Resource}
     90     */
     91    resource: function()
     92    {
     93        return this._resource;
    8494    },
    8595
Note: See TracChangeset for help on using the changeset viewer.