Changeset 139885 in webkit


Ignore:
Timestamp:
Jan 16, 2013 8:48:30 AM (11 years ago)
Author:
vsevik@chromium.org
Message:

Web Inspector: UISourceCode scriptFile / styleFile should be reset on navigation (debugger or css model reset).
https://bugs.webkit.org/show_bug.cgi?id=107008

Reviewed by Pavel Feldman.

ScriptFiles and styleFiles are now reset and disposed on UISourceCodes on corresponding models reset.
StyleSourceMapping now tries to setup mapping for newly added resource as well as for uiSourceCodes previously.

  • inspector/front-end/CSSStyleModel.js:

(WebInspector.CSSStyleModel):
(WebInspector.CSSStyleModel.prototype._mainFrameCreatedOrNavigated):

  • inspector/front-end/ResourceScriptMapping.js:

(WebInspector.ResourceScriptMapping):
(WebInspector.ResourceScriptMapping.prototype._unbindUISourceCodeFromScripts):
(WebInspector.ResourceScriptMapping.prototype._initialize):
(WebInspector.ResourceScriptMapping.prototype._debuggerReset):
(WebInspector.ResourceScriptFile.prototype.dispose):

  • inspector/front-end/ResourceTreeModel.js:

(WebInspector.ResourceTreeModel.prototype._addFrame):
(WebInspector.ResourceTreeModel.prototype._frameNavigated):

  • inspector/front-end/ScriptSnippetModel.js:

(WebInspector.ScriptSnippetModel):
(WebInspector.ScriptSnippetModel.prototype._debuggerReset):

  • inspector/front-end/StylesSourceMapping.js:

(WebInspector.StylesSourceMapping):
(WebInspector.StylesSourceMapping.prototype._resourceAdded):
(WebInspector.StylesSourceMapping.prototype._uiSourceCodeAddedToWorkspace):
(WebInspector.StylesSourceMapping.prototype._bindUISourceCode):
(WebInspector.StylesSourceMapping.prototype._projectWillReset):
(WebInspector.StylesSourceMapping.prototype._initialize):
(WebInspector.StylesSourceMapping.prototype._mainFrameCreatedOrNavigated):
(WebInspector.StyleFile.prototype.dispose):

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r139884 r139885  
     12013-01-16  Vsevolod Vlasov  <vsevik@chromium.org>
     2
     3        Web Inspector: UISourceCode scriptFile / styleFile should be reset on navigation (debugger or css model reset).
     4        https://bugs.webkit.org/show_bug.cgi?id=107008
     5
     6        Reviewed by Pavel Feldman.
     7
     8        ScriptFiles and styleFiles are now reset and disposed on UISourceCodes on corresponding models reset.
     9        StyleSourceMapping now tries to setup mapping for newly added resource as well as for uiSourceCodes previously.
     10
     11        * inspector/front-end/CSSStyleModel.js:
     12        (WebInspector.CSSStyleModel):
     13        (WebInspector.CSSStyleModel.prototype._mainFrameCreatedOrNavigated):
     14        * inspector/front-end/ResourceScriptMapping.js:
     15        (WebInspector.ResourceScriptMapping):
     16        (WebInspector.ResourceScriptMapping.prototype._unbindUISourceCodeFromScripts):
     17        (WebInspector.ResourceScriptMapping.prototype._initialize):
     18        (WebInspector.ResourceScriptMapping.prototype._debuggerReset):
     19        (WebInspector.ResourceScriptFile.prototype.dispose):
     20        * inspector/front-end/ResourceTreeModel.js:
     21        (WebInspector.ResourceTreeModel.prototype._addFrame):
     22        (WebInspector.ResourceTreeModel.prototype._frameNavigated):
     23        * inspector/front-end/ScriptSnippetModel.js:
     24        (WebInspector.ScriptSnippetModel):
     25        (WebInspector.ScriptSnippetModel.prototype._debuggerReset):
     26        * inspector/front-end/StylesSourceMapping.js:
     27        (WebInspector.StylesSourceMapping):
     28        (WebInspector.StylesSourceMapping.prototype._resourceAdded):
     29        (WebInspector.StylesSourceMapping.prototype._uiSourceCodeAddedToWorkspace):
     30        (WebInspector.StylesSourceMapping.prototype._bindUISourceCode):
     31        (WebInspector.StylesSourceMapping.prototype._projectWillReset):
     32        (WebInspector.StylesSourceMapping.prototype._initialize):
     33        (WebInspector.StylesSourceMapping.prototype._mainFrameCreatedOrNavigated):
     34        (WebInspector.StyleFile.prototype.dispose):
     35
    1362013-01-16  Gustavo Noronha Silva  <gustavo.noronha@collabora.com>
    237
  • trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js

    r139454 r139885  
    4242    WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.UndoRedoCompleted, this._undoRedoCompleted, this);
    4343    this._resourceBinding = new WebInspector.CSSStyleModelResourceBinding();
    44     WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.InspectedURLChanged, this._inspectedURLChanged, this);
     44    WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.MainFrameCreatedOrNavigated, this._mainFrameCreatedOrNavigated, this);
    4545    this._namedFlowCollections = {};
    4646    WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.DocumentUpdated, this._resetNamedFlowCollections, this);
     
    5959    return result;
    6060}
    61 
     61   
    6262/**
    6363 * @param {Array.<CSSAgent.RuleMatch>} matchArray
     
    483483     * @param {WebInspector.Event} event
    484484     */
    485     _inspectedURLChanged: function(event)
     485    _mainFrameCreatedOrNavigated: function(event)
    486486    {
    487487        this._resetSourceMappings();
  • trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js

    r139860 r139885  
    4040
    4141    WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, this._debuggerReset, this);
    42     this._debuggerReset();
     42    this._initialize();
    4343}
    4444
     
    180180    },
    181181
    182     _debuggerReset: function()
     182    /**
     183     * @param {WebInspector.UISourceCode} uiSourceCode
     184     * @param {Array.<WebInspector.Script>} scripts
     185     */
     186    _unbindUISourceCodeFromScripts: function(uiSourceCode, scripts)
     187    {
     188        console.assert(scripts.length);
     189        var scriptFile = /** @type {WebInspector.ResourceScriptFile} */ (uiSourceCode.scriptFile());
     190        scriptFile.dispose();
     191        uiSourceCode.setScriptFile(null);
     192        uiSourceCode.setSourceMapping(null);
     193    },
     194
     195    _initialize: function()
    183196    {
    184197        /** @type {!Object.<string, !Array.<!WebInspector.UISourceCode>>} */
     
    186199        /** @type {!Object.<string, !Array.<!WebInspector.UISourceCode>>} */
    187200        this._nonInlineScriptsForSourceURL = {};
     201    },
     202
     203    _debuggerReset: function()
     204    {
     205        /**
     206         * @param {!Object.<string, !Array.<!WebInspector.UISourceCode>>} scriptsForSourceURL
     207         */
     208        function unbindUISourceCodes(scriptsForSourceURL)
     209        {
     210            for (var sourceURL in scriptsForSourceURL) {
     211                var scripts = scriptsForSourceURL[sourceURL];
     212                if (!scripts.length)
     213                    continue;
     214                var uiSourceCode = this._workspaceUISourceCodeForScript(scripts[0]);
     215                if (!uiSourceCode)
     216                    continue;
     217                this._unbindUISourceCodeFromScripts(uiSourceCode, scripts);
     218            }
     219        }
     220
     221        unbindUISourceCodes.call(this, this._inlineScriptsForSourceURL);
     222        unbindUISourceCodes.call(this, this._nonInlineScriptsForSourceURL);
     223        this._initialize();
    188224    },
    189225}
     
    304340    },
    305341
     342    dispose: function()
     343    {
     344        this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCommitted, this);
     345        this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChanged, this);
     346    },
     347
    306348    __proto__: WebInspector.Object.prototype
    307349}
  • trunk/Source/WebCore/inspector/front-end/ResourceTreeModel.js

    r139853 r139885  
    5858    FrameDetached: "FrameDetached",
    5959    MainFrameNavigated: "MainFrameNavigated",
     60    MainFrameCreatedOrNavigated: "MainFrameCreatedOrNavigated",
    6061    ResourceAdded: "ResourceAdded",
    6162    WillLoadCachedResources: "WillLoadCachedResources",
     
    109110            this.mainFrame = frame;
    110111        this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.FrameAdded, frame);
     112        if (frame.isMainFrame())
     113            this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.MainFrameCreatedOrNavigated, frame);
    111114    },
    112115
     
    138141
    139142        this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.FrameNavigated, frame);
    140         if (frame.isMainFrame())
     143        if (frame.isMainFrame()) {
    141144            this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, frame);
     145            this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.MainFrameCreatedOrNavigated, frame);
     146        }
    142147
    143148        // Fill frame with retained resources (the ones loaded using new loader).
  • trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js

    r139454 r139885  
    3737{
    3838    this._workspace = workspace;
     39    /** {Object.<string, WebInspector.UISourceCode>} */
    3940    this._uiSourceCodeForScriptId = {};
    4041    this._scriptForUISourceCode = new Map();
     42    /** {Object.<string, WebInspector.UISourceCode>} */
    4143    this._uiSourceCodeForSnippetId = {};
    4244    this._snippetIdForUISourceCode = new Map();
     
    4850    workspace.addProject(WebInspector.projectNames.Snippets, this._workspaceProvider);
    4951    this.reset();
     52    WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, this._debuggerReset, this);
    5053}
    5154
     
    341344        uiSourceCode.scriptFile().setIsDivergingFromVM(false);
    342345        return script.rawLocationToUILocation(0, 0).uiSourceCode;
     346    },
     347
     348    _debuggerReset: function()
     349    {
     350        for (var snippetId in this._uiSourceCodeForSnippetId) {
     351            var uiSourceCode = this._uiSourceCodeForSnippetId[snippetId];
     352            this._releaseSnippetScript(uiSourceCode);
     353        }
    343354    },
    344355
  • trunk/Source/WebCore/inspector/front-end/StylesSourceMapping.js

    r139860 r139885  
    4040    this._workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, this._uiSourceCodeAddedToWorkspace, this);
    4141
    42     this._mappedURLs = {};
     42    WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.MainFrameCreatedOrNavigated, this._mainFrameCreatedOrNavigated, this);
     43    WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.ResourceAdded, this._resourceAdded, this);
     44    this._initialize();
    4345}
    4446
     
    6769    },
    6870
     71    _resourceAdded: function(event)
     72    {
     73        var resource = /** @type {WebInspector.UISourceCode} */ (event.data);
     74        if (resource.contentType() !== WebInspector.resourceTypes.Stylesheet)
     75            return;
     76        if (!resource.url)
     77            return;
     78        var uri = WebInspector.fileMapping.uriForURL(resource.url);
     79        var uiSourceCode = this._workspace.uiSourceCodeForURI(uri);
     80        if (!uiSourceCode)
     81            return;
     82        this._bindUISourceCode(uiSourceCode);
     83    },
     84
    6985    _uiSourceCodeAddedToWorkspace: function(event)
    7086    {
     
    7490        if (!uiSourceCode.url || !WebInspector.resourceForURL(uiSourceCode.url))
    7591            return;
     92        this._bindUISourceCode(uiSourceCode);
     93    },
     94
     95    _bindUISourceCode: function(uiSourceCode)
     96    {
    7697        if (this._mappedURLs[uiSourceCode.url])
    7798            return;
     
    89110        for (var i = 0; i < uiSourceCodes; ++i)
    90111            delete this._mappedURLs[uiSourceCodes[i].url];
     112    },
     113
     114    _initialize: function()
     115    {
     116        /** {Object.<string, boolean>} */
     117        this._mappedURLs = {};
     118    },
     119
     120    /**
     121     * @param {WebInspector.Event} event
     122     */
     123    _mainFrameCreatedOrNavigated: function(event)
     124    {
     125        for (var mappedURL in this._mappedURLs) {
     126            var uri = WebInspector.fileMapping.uriForURL(mappedURL);
     127            var uiSourceCode = this._workspace.uiSourceCodeForURI(uri);
     128            if (!uiSourceCode)
     129                continue;
     130            uiSourceCode.styleFile().dispose();
     131            uiSourceCode.setStyleFile(null);
     132            uiSourceCode.setSourceMapping(null);
     133        }
     134        this._initialize();
    91135    }
    92136}
     
    161205        delete this._isAddingRevision;
    162206    },
     207
     208    dispose: function()
     209    {
     210        this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCommitted, this);
     211        this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChanged, this);
     212    }
    163213}
    164214
Note: See TracChangeset for help on using the changeset viewer.