Title: [139885] trunk/Source/WebCore
Revision
139885
Author
[email protected]
Date
2013-01-16 08:48:30 -0800 (Wed, 16 Jan 2013)

Log 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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (139884 => 139885)


--- trunk/Source/WebCore/ChangeLog	2013-01-16 16:26:10 UTC (rev 139884)
+++ trunk/Source/WebCore/ChangeLog	2013-01-16 16:48:30 UTC (rev 139885)
@@ -1,3 +1,38 @@
+2013-01-16  Vsevolod Vlasov  <[email protected]>
+
+        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):
+
 2013-01-16  Gustavo Noronha Silva  <[email protected]>
 
         [GStreamer][Soup] Let GStreamer provide the buffer data is downloaded to, to avoid copying

Modified: trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js (139884 => 139885)


--- trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js	2013-01-16 16:26:10 UTC (rev 139884)
+++ trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js	2013-01-16 16:48:30 UTC (rev 139885)
@@ -41,7 +41,7 @@
     WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.UndoRedoRequested, this._undoRedoRequested, this);
     WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.UndoRedoCompleted, this._undoRedoCompleted, this);
     this._resourceBinding = new WebInspector.CSSStyleModelResourceBinding();
-    WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.InspectedURLChanged, this._inspectedURLChanged, this);
+    WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.MainFrameCreatedOrNavigated, this._mainFrameCreatedOrNavigated, this);
     this._namedFlowCollections = {};
     WebInspector.domAgent.addEventListener(WebInspector.DOMAgent.Events.DocumentUpdated, this._resetNamedFlowCollections, this);
     InspectorBackend.registerCSSDispatcher(new WebInspector.CSSDispatcher(this));
@@ -58,7 +58,7 @@
         result.push(WebInspector.CSSRule.parsePayload(ruleArray[i]));
     return result;
 }
-
+    
 /**
  * @param {Array.<CSSAgent.RuleMatch>} matchArray
  */
@@ -482,7 +482,7 @@
     /**
      * @param {WebInspector.Event} event
      */
-    _inspectedURLChanged: function(event)
+    _mainFrameCreatedOrNavigated: function(event)
     {
         this._resetSourceMappings();
         this._resourceBinding._reset();

Modified: trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js (139884 => 139885)


--- trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js	2013-01-16 16:26:10 UTC (rev 139884)
+++ trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js	2013-01-16 16:48:30 UTC (rev 139885)
@@ -39,7 +39,7 @@
     this._workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, this._uiSourceCodeAddedToWorkspace, this);
 
     WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, this._debuggerReset, this);
-    this._debuggerReset();
+    this._initialize();
 }
 
 WebInspector.ResourceScriptMapping.prototype = {
@@ -179,13 +179,49 @@
         uiSourceCode.setSourceMapping(this);
     },
 
-    _debuggerReset: function()
+    /**
+     * @param {WebInspector.UISourceCode} uiSourceCode
+     * @param {Array.<WebInspector.Script>} scripts
+     */
+    _unbindUISourceCodeFromScripts: function(uiSourceCode, scripts)
     {
+        console.assert(scripts.length);
+        var scriptFile = /** @type {WebInspector.ResourceScriptFile} */ (uiSourceCode.scriptFile());
+        scriptFile.dispose();
+        uiSourceCode.setScriptFile(null);
+        uiSourceCode.setSourceMapping(null);
+    },
+
+    _initialize: function()
+    {
         /** @type {!Object.<string, !Array.<!WebInspector.UISourceCode>>} */
         this._inlineScriptsForSourceURL = {};
         /** @type {!Object.<string, !Array.<!WebInspector.UISourceCode>>} */
         this._nonInlineScriptsForSourceURL = {};
     },
+
+    _debuggerReset: function()
+    {
+        /**
+         * @param {!Object.<string, !Array.<!WebInspector.UISourceCode>>} scriptsForSourceURL
+         */
+        function unbindUISourceCodes(scriptsForSourceURL)
+        {
+            for (var sourceURL in scriptsForSourceURL) {
+                var scripts = scriptsForSourceURL[sourceURL];
+                if (!scripts.length)
+                    continue;
+                var uiSourceCode = this._workspaceUISourceCodeForScript(scripts[0]);
+                if (!uiSourceCode)
+                    continue;
+                this._unbindUISourceCodeFromScripts(uiSourceCode, scripts);
+            }
+        }
+
+        unbindUISourceCodes.call(this, this._inlineScriptsForSourceURL);
+        unbindUISourceCodes.call(this, this._nonInlineScriptsForSourceURL);
+        this._initialize();
+    },
 }
 
 /**
@@ -303,5 +339,11 @@
         return this._isDivergingFromVM;
     },
 
+    dispose: function()
+    {
+        this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCommitted, this);
+        this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChanged, this);
+    },
+
     __proto__: WebInspector.Object.prototype
 }

Modified: trunk/Source/WebCore/inspector/front-end/ResourceTreeModel.js (139884 => 139885)


--- trunk/Source/WebCore/inspector/front-end/ResourceTreeModel.js	2013-01-16 16:26:10 UTC (rev 139884)
+++ trunk/Source/WebCore/inspector/front-end/ResourceTreeModel.js	2013-01-16 16:48:30 UTC (rev 139885)
@@ -57,6 +57,7 @@
     FrameNavigated: "FrameNavigated",
     FrameDetached: "FrameDetached",
     MainFrameNavigated: "MainFrameNavigated",
+    MainFrameCreatedOrNavigated: "MainFrameCreatedOrNavigated",
     ResourceAdded: "ResourceAdded",
     WillLoadCachedResources: "WillLoadCachedResources",
     CachedResourcesLoaded: "CachedResourcesLoaded",
@@ -108,6 +109,8 @@
         if (frame.isMainFrame())
             this.mainFrame = frame;
         this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.FrameAdded, frame);
+        if (frame.isMainFrame())
+            this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.MainFrameCreatedOrNavigated, frame);
     },
 
     /**
@@ -137,8 +140,10 @@
             WebInspector.inspectedPageURL = frame.url;
 
         this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.FrameNavigated, frame);
-        if (frame.isMainFrame())
+        if (frame.isMainFrame()) {
             this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, frame);
+            this.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.MainFrameCreatedOrNavigated, frame);
+        }
 
         // Fill frame with retained resources (the ones loaded using new loader).
         var resources = frame.resources();

Modified: trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js (139884 => 139885)


--- trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js	2013-01-16 16:26:10 UTC (rev 139884)
+++ trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js	2013-01-16 16:48:30 UTC (rev 139885)
@@ -36,8 +36,10 @@
 WebInspector.ScriptSnippetModel = function(workspace)
 {
     this._workspace = workspace;
+    /** {Object.<string, WebInspector.UISourceCode>} */
     this._uiSourceCodeForScriptId = {};
     this._scriptForUISourceCode = new Map();
+    /** {Object.<string, WebInspector.UISourceCode>} */
     this._uiSourceCodeForSnippetId = {};
     this._snippetIdForUISourceCode = new Map();
     
@@ -47,6 +49,7 @@
     this._workspaceProvider = new WebInspector.SimpleWorkspaceProvider(this._workspace);
     workspace.addProject(WebInspector.projectNames.Snippets, this._workspaceProvider);
     this.reset();
+    WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, this._debuggerReset, this);
 }
 
 WebInspector.ScriptSnippetModel.prototype = {
@@ -342,6 +345,14 @@
         return script.rawLocationToUILocation(0, 0).uiSourceCode;
     },
 
+    _debuggerReset: function()
+    {
+        for (var snippetId in this._uiSourceCodeForSnippetId) {
+            var uiSourceCode = this._uiSourceCodeForSnippetId[snippetId];
+            this._releaseSnippetScript(uiSourceCode);
+        }
+    },
+
     /**
      * @param {WebInspector.UISourceCode} uiSourceCode
      * @return {string}

Modified: trunk/Source/WebCore/inspector/front-end/StylesSourceMapping.js (139884 => 139885)


--- trunk/Source/WebCore/inspector/front-end/StylesSourceMapping.js	2013-01-16 16:26:10 UTC (rev 139884)
+++ trunk/Source/WebCore/inspector/front-end/StylesSourceMapping.js	2013-01-16 16:48:30 UTC (rev 139885)
@@ -39,7 +39,9 @@
     this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._projectWillReset, this);
     this._workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, this._uiSourceCodeAddedToWorkspace, this);
 
-    this._mappedURLs = {};
+    WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.MainFrameCreatedOrNavigated, this._mainFrameCreatedOrNavigated, this);
+    WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.ResourceAdded, this._resourceAdded, this);
+    this._initialize();
 }
 
 WebInspector.StylesSourceMapping.prototype = {
@@ -66,6 +68,20 @@
         return new WebInspector.CSSLocation(uiSourceCode.url || "", lineNumber);
     },
 
+    _resourceAdded: function(event)
+    {
+        var resource = /** @type {WebInspector.UISourceCode} */ (event.data);
+        if (resource.contentType() !== WebInspector.resourceTypes.Stylesheet)
+            return;
+        if (!resource.url)
+            return;
+        var uri = WebInspector.fileMapping.uriForURL(resource.url);
+        var uiSourceCode = this._workspace.uiSourceCodeForURI(uri);
+        if (!uiSourceCode)
+            return;
+        this._bindUISourceCode(uiSourceCode);
+    },
+
     _uiSourceCodeAddedToWorkspace: function(event)
     {
         var uiSourceCode = /** @type {WebInspector.UISourceCode} */ (event.data);
@@ -73,6 +89,11 @@
             return;
         if (!uiSourceCode.url || !WebInspector.resourceForURL(uiSourceCode.url))
             return;
+        this._bindUISourceCode(uiSourceCode);
+    },
+
+    _bindUISourceCode: function(uiSourceCode)
+    {
         if (this._mappedURLs[uiSourceCode.url])
             return;
         this._mappedURLs[uiSourceCode.url] = true;
@@ -88,6 +109,29 @@
         var uiSourceCodes = project.uiSourceCodes();
         for (var i = 0; i < uiSourceCodes; ++i)
             delete this._mappedURLs[uiSourceCodes[i].url];
+    },
+
+    _initialize: function()
+    {
+        /** {Object.<string, boolean>} */
+        this._mappedURLs = {};
+    },
+
+    /**
+     * @param {WebInspector.Event} event
+     */
+    _mainFrameCreatedOrNavigated: function(event)
+    {
+        for (var mappedURL in this._mappedURLs) {
+            var uri = WebInspector.fileMapping.uriForURL(mappedURL);
+            var uiSourceCode = this._workspace.uiSourceCodeForURI(uri);
+            if (!uiSourceCode)
+                continue;
+            uiSourceCode.styleFile().dispose();
+            uiSourceCode.setStyleFile(null);
+            uiSourceCode.setSourceMapping(null);
+        }
+        this._initialize();
     }
 }
 
@@ -160,6 +204,12 @@
         this._uiSourceCode.addRevision(content);
         delete this._isAddingRevision;
     },
+
+    dispose: function()
+    {
+        this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCommitted, this);
+        this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._workingCopyChanged, this);
+    }
 }
 
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to