Web Inspector: Remove dead code in FrameTreeElement
[WebKit-https.git] / Source / WebInspectorUI / UserInterface / Views / FrameTreeElement.js
index 35af996..9bc6db4 100644 (file)
@@ -38,6 +38,7 @@ WebInspector.FrameTreeElement = class FrameTreeElement extends WebInspector.Reso
         frame.addEventListener(WebInspector.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this);
         frame.addEventListener(WebInspector.Frame.Event.ResourceWasAdded, this._resourceWasAdded, this);
         frame.addEventListener(WebInspector.Frame.Event.ResourceWasRemoved, this._resourceWasRemoved, this);
+        frame.addEventListener(WebInspector.Frame.Event.ExtraScriptAdded, this._extraScriptAdded, this);
         frame.addEventListener(WebInspector.Frame.Event.ChildFrameWasAdded, this._childFrameWasAdded, this);
         frame.addEventListener(WebInspector.Frame.Event.ChildFrameWasRemoved, this._childFrameWasRemoved, this);
 
@@ -45,28 +46,25 @@ WebInspector.FrameTreeElement = class FrameTreeElement extends WebInspector.Reso
         frame.domTree.addEventListener(WebInspector.DOMTree.Event.ContentFlowWasRemoved, this._childContentFlowWasRemoved, this);
         frame.domTree.addEventListener(WebInspector.DOMTree.Event.RootDOMNodeInvalidated, this._rootDOMNodeInvalidated, this);
 
-        if (this._frame.isMainFrame())
-            this._downloadingPage = false;
-
         this.shouldRefreshChildren = true;
         this.folderSettingsKey = this._frame.url.hash;
 
         this.registerFolderizeSettings("frames", WebInspector.UIString("Frames"),
-            function(representedObject) { return representedObject instanceof WebInspector.Frame; },
-            function() { return this.frame.childFrames.length; }.bind(this),
+            (representedObject) => representedObject instanceof WebInspector.Frame,
+            () => this.frame.childFrames.length,
             WebInspector.FrameTreeElement
         );
 
         this.registerFolderizeSettings("flows", WebInspector.UIString("Flows"),
-            function(representedObject) { return representedObject instanceof WebInspector.ContentFlow; },
-            function() { return this.frame.domTree.flowsCount; }.bind(this),
+            (representedObject) => representedObject instanceof WebInspector.ContentFlow,
+            () => this.frame.domTree.flowsCount,
             WebInspector.ContentFlowTreeElement
         );
 
-        this.registerFolderizeSettings("canvases", WebInspector.UIString("Canvases"),
-            function(representedObject) { return representedObject instanceof WebInspector.Canvas; },
-            function() { return WebInspector.canvasManager.canvasesForFrame(this._frame).length; }.bind(this),
-            WebInspector.CanvasTreeElement
+        this.registerFolderizeSettings("extra-scripts", WebInspector.UIString("Extra Scripts"),
+            (representedObject) => representedObject instanceof WebInspector.Script && representedObject.dynamicallyAddedScriptElement,
+            () => this.frame.extraScripts.length,
+            WebInspector.ScriptTreeElement
         );
 
         function makeValidateCallback(resourceType) {
@@ -142,28 +140,7 @@ WebInspector.FrameTreeElement = class FrameTreeElement extends WebInspector.Reso
         // Immediate superclasses are skipped, since Frames handle their own SourceMapResources.
         WebInspector.GeneralTreeElement.prototype.onattach.call(this);
 
-        WebInspector.canvasManager.addEventListener(WebInspector.CanvasManager.Event.CanvasesAvailable, this._canvasesAvailable, this);
-        WebInspector.canvasManager.addEventListener(WebInspector.CanvasManager.Event.CanvasWasAdded, this._canvasWasAdded, this);
-        WebInspector.canvasManager.addEventListener(WebInspector.CanvasManager.Event.CanvasWasRemoved, this._canvasWasRemoved, this);
-
-        if (this._frame.isMainFrame()) {
-            WebInspector.notifications.addEventListener(WebInspector.Notification.PageArchiveStarted, this._pageArchiveStarted, this);
-            WebInspector.notifications.addEventListener(WebInspector.Notification.PageArchiveEnded, this._pageArchiveEnded, this);
-        }
-    }
-
-    ondetach()
-    {
-        WebInspector.ResourceTreeElement.prototype.ondetach.call(this);
-
-        WebInspector.canvasManager.removeEventListener(WebInspector.CanvasManager.Event.CanvasesAvailable, this._canvasesAvailable, this);
-        WebInspector.canvasManager.removeEventListener(WebInspector.CanvasManager.Event.CanvasWasAdded, this._canvasWasAdded, this);
-        WebInspector.canvasManager.removeEventListener(WebInspector.CanvasManager.Event.CanvasWasRemoved, this._canvasWasRemoved, this);
-
-        if (this._frame.isMainFrame()) {
-            WebInspector.notifications.removeEventListener(WebInspector.Notification.PageArchiveStarted, this._pageArchiveStarted, this);
-            WebInspector.notifications.removeEventListener(WebInspector.Notification.PageArchiveEnded, this._pageArchiveEnded, this);
-        }
+        this.element.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this));
     }
 
     // Overrides from FolderizedTreeElement (Protected).
@@ -189,52 +166,6 @@ WebInspector.FrameTreeElement = class FrameTreeElement extends WebInspector.Reso
         return aIsResource ? 1 : -1;
     }
 
-    // Called from ResourceTreeElement.
-
-    updateStatusForMainFrame()
-    {
-        function loadedImages()
-        {
-            if (!this._reloadButton || !this._downloadButton)
-                return;
-
-            var fragment = document.createDocumentFragment("div");
-            fragment.appendChild(this._downloadButton.element);
-            fragment.appendChild(this._reloadButton.element);
-            this.status = fragment;
-
-            delete this._loadingMainFrameButtons;
-        }
-
-        if (this._reloadButton && this._downloadButton) {
-            loadedImages.call(this);
-            return;
-        }
-
-        if (!this._loadingMainFrameButtons) {
-            this._loadingMainFrameButtons = true;
-
-            var tooltip;
-            if (WebInspector.debuggableType === WebInspector.DebuggableType.JavaScript)
-                tooltip = WebInspector.UIString("Restart (%s)").format(WebInspector._reloadPageKeyboardShortcut.displayName);
-            else
-                tooltip = WebInspector.UIString("Reload page (%s)\nReload ignoring cache (%s)").format(WebInspector._reloadPageKeyboardShortcut.displayName, WebInspector._reloadPageIgnoringCacheKeyboardShortcut.displayName);
-
-            wrappedSVGDocument(platformImagePath("Reload.svg"), null, tooltip, function(element) {
-                this._reloadButton = new WebInspector.TreeElementStatusButton(element);
-                this._reloadButton.addEventListener(WebInspector.TreeElementStatusButton.Event.Clicked, this._reloadPageClicked, this);
-                loadedImages.call(this);
-            }.bind(this));
-
-            wrappedSVGDocument(platformImagePath("DownloadArrow.svg"), null, WebInspector.UIString("Download Web Archive"), function(element) {
-                this._downloadButton = new WebInspector.TreeElementStatusButton(element);
-                this._downloadButton.addEventListener(WebInspector.TreeElementStatusButton.Event.Clicked, this._downloadButtonClicked, this);
-                this._updateDownloadButton();
-                loadedImages.call(this);
-            }.bind(this));
-        }
-    }
-
     // Overrides from TreeElement (Private).
 
     onpopulate()
@@ -264,11 +195,12 @@ WebInspector.FrameTreeElement = class FrameTreeElement extends WebInspector.Reso
         for (var flowKey in flowMap)
             this.addChildForRepresentedObject(flowMap[flowKey]);
 
-        var canvases = WebInspector.canvasManager.canvasesForFrame(this._frame);
-        for (var canvas of canvases)
-            this.addChildForRepresentedObject(canvas);
+        for (let extraScript of this._frame.extraScripts) {
+            if (extraScript.sourceURL || extraScript.sourceMappingURL)
+                this.addChildForRepresentedObject(extraScript);
+        }
     }
-        
+
     onexpand()
     {
         this._expandedSetting.value = true;
@@ -305,9 +237,6 @@ WebInspector.FrameTreeElement = class FrameTreeElement extends WebInspector.Reso
         // shouldRefreshChildren will call onpopulate if expanded is true.
         this._updateExpandedSetting();
 
-        if (this._frame.isMainFrame())
-            this._updateDownloadButton();
-
         this.shouldRefreshChildren = true;
     }
 
@@ -321,6 +250,13 @@ WebInspector.FrameTreeElement = class FrameTreeElement extends WebInspector.Reso
         this.removeChildForRepresentedObject(event.data.resource);
     }
 
+    _extraScriptAdded(event)
+    {
+        let extraScript = event.data.script;
+        if (extraScript.sourceURL || extraScript.sourceMappingURL)
+            this.addRepresentedObjectToNewChildQueue(extraScript);
+    }
+
     _childFrameWasAdded(event)
     {
         this.addRepresentedObjectToNewChildQueue(event.data.childFrame);
@@ -341,73 +277,9 @@ WebInspector.FrameTreeElement = class FrameTreeElement extends WebInspector.Reso
         this.removeChildForRepresentedObject(event.data.flow);
     }
 
-    _canvasesAvailable(event)
-    {
-        this.updateParentStatus();
-        this.removeChildren();
-
-        this.shouldRefreshChildren = true;
-    }
-
-    _canvasWasAdded(event)
-    {
-        var canvas = event.data.canvas;
-        if (canvas.parentFrame == this._frame)
-            this.addRepresentedObjectToNewChildQueue(canvas);
-    }
-
-    _canvasWasRemoved(event)
-    {
-        var canvas = event.data.canvas;
-        if (canvas.parentFrame == this._frame)
-            this.removeChildForRepresentedObject(canvas);
-    }
-
     _rootDOMNodeInvalidated()
     {
         if (this.expanded)
             this._frame.domTree.requestContentFlowList();
     }
-
-    _reloadPageClicked(event)
-    {
-        // Ignore cache when the shift key is pressed.
-        PageAgent.reload(event.data.shiftKey);
-    }
-
-    _downloadButtonClicked(event)
-    {
-        WebInspector.archiveMainFrame();
-    }
-
-    _updateDownloadButton()
-    {
-        console.assert(this._frame.isMainFrame());
-        if (!this._downloadButton)
-            return;
-
-        if (!PageAgent.archive || WebInspector.debuggableType !== WebInspector.DebuggableType.Web) {
-            this._downloadButton.hidden = true;
-            return;
-        }
-
-        if (this._downloadingPage) {
-            this._downloadButton.enabled = false;
-            return;
-        }
-
-        this._downloadButton.enabled = WebInspector.canArchiveMainFrame();
-    }
-
-    _pageArchiveStarted(event)
-    {
-        this._downloadingPage = true;
-        this._updateDownloadButton();
-    }
-
-    _pageArchiveEnded(event)
-    {
-        this._downloadingPage = false;
-        this._updateDownloadButton();
-    }
 };