Web Inspector: Allow closing and reopening the Timelines tab
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 May 2015 20:22:55 +0000 (20:22 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 May 2015 20:22:55 +0000 (20:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=144520

Reviewed by Joseph Pecoraro.

* UserInterface/Base/Main.js:
(WebInspector._updateNewTabButtonState):
* UserInterface/Controllers/TimelineManager.js:
(WebInspector.TimelineManager): No need for a delay now. Call reset().
(WebInspector.TimelineManager.prototype.reset):
(WebInspector.TimelineManager.delayedWork): Deleted.
* UserInterface/Views/ContentBrowserTabContentView.js:
(WebInspector.ContentBrowserTabContentView):
(WebInspector.ContentBrowserTabContentView.prototype.closed):
* UserInterface/Views/LayoutTimelineView.js:
(WebInspector.LayoutTimelineView.prototype.closed): Added. Fixed leak.
* UserInterface/Views/NetworkTimelineView.js:
(WebInspector.NetworkTimelineView.prototype.closed): Added. Fixed leak.
* UserInterface/Views/NewTabContentView.js:
(WebInspector.NewTabContentView): Added Timelines.
* UserInterface/Views/OverviewTimelineView.js:
(WebInspector.OverviewTimelineView.prototype.closed): Added. Fixed leak.
* UserInterface/Views/RenderingFrameTimelineView.js:
(WebInspector.RenderingFrameTimelineView.prototype.closed): Added. Fixed leak.
* UserInterface/Views/ScriptTimelineView.js:
(WebInspector.ScriptTimelineView.prototype.closed):
* UserInterface/Views/SearchTabContentView.js:
(WebInspector.SearchTabContentView.prototype.closed): Deleted. Made generic
in ContentBrowserTabContentView.prototype.closed.
* UserInterface/Views/TabBrowser.js:
(WebInspector.TabBrowser.prototype._tabBarItemSelected): Fix a potential exception
when selectedTabBarItem is null.
* UserInterface/Views/TimelineSidebarPanel.js:
(WebInspector.TimelineSidebarPanel):
(WebInspector.TimelineSidebarPanel.prototype.closed):
(WebInspector.TimelineSidebarPanel._recordingCreated): Call _addRecording.
(WebInspector.TimelineSidebarPanel._addRecording): Added.
* UserInterface/Views/TimelineTabContentView.js:
(WebInspector.TimelineTabContentView):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183764 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Base/Main.js
Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js
Source/WebInspectorUI/UserInterface/Views/ContentBrowserTabContentView.js
Source/WebInspectorUI/UserInterface/Views/LayoutTimelineView.js
Source/WebInspectorUI/UserInterface/Views/NetworkTimelineView.js
Source/WebInspectorUI/UserInterface/Views/NewTabContentView.js
Source/WebInspectorUI/UserInterface/Views/OverviewTimelineView.js
Source/WebInspectorUI/UserInterface/Views/RenderingFrameTimelineView.js
Source/WebInspectorUI/UserInterface/Views/ScriptTimelineView.js
Source/WebInspectorUI/UserInterface/Views/SearchTabContentView.js
Source/WebInspectorUI/UserInterface/Views/TabBrowser.js
Source/WebInspectorUI/UserInterface/Views/TimelineSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/TimelineTabContentView.js

index 877c157..75ce0bc 100644 (file)
@@ -1,5 +1,47 @@
 2015-05-04  Timothy Hatcher  <timothy@apple.com>
 
+        Web Inspector: Allow closing and reopening the Timelines tab
+        https://bugs.webkit.org/show_bug.cgi?id=144520
+
+        Reviewed by Joseph Pecoraro.
+
+        * UserInterface/Base/Main.js:
+        (WebInspector._updateNewTabButtonState):
+        * UserInterface/Controllers/TimelineManager.js:
+        (WebInspector.TimelineManager): No need for a delay now. Call reset().
+        (WebInspector.TimelineManager.prototype.reset):
+        (WebInspector.TimelineManager.delayedWork): Deleted.
+        * UserInterface/Views/ContentBrowserTabContentView.js:
+        (WebInspector.ContentBrowserTabContentView):
+        (WebInspector.ContentBrowserTabContentView.prototype.closed):
+        * UserInterface/Views/LayoutTimelineView.js:
+        (WebInspector.LayoutTimelineView.prototype.closed): Added. Fixed leak.
+        * UserInterface/Views/NetworkTimelineView.js:
+        (WebInspector.NetworkTimelineView.prototype.closed): Added. Fixed leak.
+        * UserInterface/Views/NewTabContentView.js:
+        (WebInspector.NewTabContentView): Added Timelines.
+        * UserInterface/Views/OverviewTimelineView.js:
+        (WebInspector.OverviewTimelineView.prototype.closed): Added. Fixed leak.
+        * UserInterface/Views/RenderingFrameTimelineView.js:
+        (WebInspector.RenderingFrameTimelineView.prototype.closed): Added. Fixed leak.
+        * UserInterface/Views/ScriptTimelineView.js:
+        (WebInspector.ScriptTimelineView.prototype.closed):
+        * UserInterface/Views/SearchTabContentView.js:
+        (WebInspector.SearchTabContentView.prototype.closed): Deleted. Made generic
+        in ContentBrowserTabContentView.prototype.closed.
+        * UserInterface/Views/TabBrowser.js:
+        (WebInspector.TabBrowser.prototype._tabBarItemSelected): Fix a potential exception
+        when selectedTabBarItem is null.
+        * UserInterface/Views/TimelineSidebarPanel.js:
+        (WebInspector.TimelineSidebarPanel):
+        (WebInspector.TimelineSidebarPanel.prototype.closed):
+        (WebInspector.TimelineSidebarPanel._recordingCreated): Call _addRecording.
+        (WebInspector.TimelineSidebarPanel._addRecording): Added.
+        * UserInterface/Views/TimelineTabContentView.js:
+        (WebInspector.TimelineTabContentView):
+
+2015-05-04  Timothy Hatcher  <timothy@apple.com>
+
         Web Inspector: Switching recordings in the Timeline navigation bar is broken
         https://bugs.webkit.org/show_bug.cgi?id=144519
 
index 53e97b7..6a40a32 100644 (file)
@@ -430,7 +430,8 @@ WebInspector._rememberOpenTabs = function()
 WebInspector._updateNewTabButtonState = function(event)
 {
     var newTabAllowed = this.isNewTabWithTypeAllowed(WebInspector.ConsoleTabContentView.Type) || this.isNewTabWithTypeAllowed(WebInspector.ElementsTabContentView.Type)
-         || this.isNewTabWithTypeAllowed(WebInspector.ResourcesTabContentView.Type) || this.isNewTabWithTypeAllowed(WebInspector.StorageTabContentView.Type);
+        || this.isNewTabWithTypeAllowed(WebInspector.ResourcesTabContentView.Type) || this.isNewTabWithTypeAllowed(WebInspector.StorageTabContentView.Type)
+        || this.isNewTabWithTypeAllowed(WebInspector.TimelineTabContentView.Type);
     this.tabBar.newTabItem.disabled = !newTabAllowed;
 };
 
index 5b25b9e..cd5201e 100644 (file)
@@ -33,25 +33,26 @@ WebInspector.TimelineManager = class TimelineManager extends WebInspector.Object
         WebInspector.Frame.addEventListener(WebInspector.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this);
         WebInspector.Frame.addEventListener(WebInspector.Frame.Event.ResourceWasAdded, this._resourceWasAdded, this);
 
-        this._recordings = [];
-        this._activeRecording = null;
         this._isCapturing = false;
-
-        this._nextRecordingIdentifier = 1;
-
         this._boundStopCapturing = this.stopCapturing.bind(this);
 
-        function delayedWork()
-        {
-            this._loadNewRecording();
-        }
-
-        // Allow other code to set up listeners before firing the initial RecordingLoaded event.
-        setTimeout(delayedWork.bind(this), 0);
+        this.reset();
     }
 
     // Public
 
+    reset()
+    {
+        if (this._isCapturing)
+            this.stopCapturing();
+
+        this._recordings = [];
+        this._activeRecording = null;
+        this._nextRecordingIdentifier = 1;
+
+        this._loadNewRecording();
+    }
+
     // The current recording that new timeline records will be appended to, if any.
     get activeRecording()
     {
index 46ed767..0cd25ed 100644 (file)
@@ -41,6 +41,10 @@ WebInspector.ContentBrowserTabContentView = function(identifier, styleClassNames
     this._contentBrowser.addEventListener(WebInspector.ContentBrowser.Event.CurrentRepresentedObjectsDidChange, this.showDetailsSidebarPanels, this);
     this._contentBrowser.addEventListener(WebInspector.ContentBrowser.Event.CurrentContentViewDidChange, this._contentBrowserCurrentContentViewDidChange, this);
 
+    // If any content views were shown during sidebar construction, contentBrowserTreeElementForRepresentedObject() would have returned null.
+    // Explicitly update the path for the navigation bar to prevent it from showing up as blank.
+    this._contentBrowser.updateHierarchicalPathForCurrentContentView();
+
     if (navigationSidebarPanel) {
         var showToolTip = WebInspector.UIString("Show the navigation sidebar (%s)").format(WebInspector.navigationSidebarKeyboardShortcut.displayName);
         var hideToolTip = WebInspector.UIString("Hide the navigation sidebar (%s)").format(WebInspector.navigationSidebarKeyboardShortcut.displayName);
@@ -111,6 +115,9 @@ WebInspector.ContentBrowserTabContentView.prototype = {
         WebInspector.navigationSidebar.removeEventListener(null, null, this);
         WebInspector.detailsSidebar.removeEventListener(null, null, this);
 
+        if (this.navigationSidebarPanel && typeof this.navigationSidebarPanel.closed === "function")
+            this.navigationSidebarPanel.closed();
+
         this._contentBrowser.contentViewContainer.closeAllContentViews();
     },
 
index ab7e454..fa2fb78 100644 (file)
@@ -123,6 +123,12 @@ WebInspector.LayoutTimelineView.prototype = {
         WebInspector.ContentView.prototype.hidden.call(this);
     },
 
+    closed: function()
+    {
+        console.assert(this.representedObject instanceof WebInspector.Timeline);
+        this.representedObject.removeEventListener(null, null, this);
+    },
+
     filterDidChange: function()
     {
         WebInspector.TimelineView.prototype.filterDidChange.call(this);
index 2997749..dc48ec1 100644 (file)
@@ -125,6 +125,12 @@ WebInspector.NetworkTimelineView.prototype = {
         WebInspector.ContentView.prototype.hidden.call(this);
     },
 
+    closed: function()
+    {
+        console.assert(this.representedObject instanceof WebInspector.Timeline);
+        this.representedObject.removeEventListener(null, null, this);
+    },
+
     updateLayout: function()
     {
         WebInspector.TimelineView.prototype.updateLayout.call(this);
index ff3e8f8..992731d 100644 (file)
@@ -32,6 +32,7 @@ WebInspector.NewTabContentView = function(identifier)
     var allowedNewTabs = [
         {image: "Images/Elements.svg", title: WebInspector.UIString("Elements"), type: WebInspector.ElementsTabContentView.Type},
         {image: "Images/Resources.svg", title: WebInspector.UIString("Resources"), type: WebInspector.ResourcesTabContentView.Type},
+        {image: "Images/Timeline.svg", title: WebInspector.UIString("Timelines"), type: WebInspector.TimelineTabContentView.Type},
         {image: "Images/Storage.svg", title: WebInspector.UIString("Storage"), type: WebInspector.StorageTabContentView.Type},
         {image: "Images/Console.svg", title: WebInspector.UIString("Console"), type: WebInspector.ConsoleTabContentView.Type}
     ];
index 8b59a6d..d94bcb6 100644 (file)
@@ -88,6 +88,12 @@ WebInspector.OverviewTimelineView.prototype = {
         this._treeOutlineDataGridSynchronizer.synchronize();
     },
 
+    closed: function()
+    {
+        this._networkTimeline.removeEventListener(null, null, this);
+        this._recording.removeEventListener(null, null, this);
+    },
+
     updateLayout: function()
     {
         WebInspector.TimelineView.prototype.updateLayout.call(this);
index 18efe13..b3f9cc7 100644 (file)
@@ -96,6 +96,12 @@ WebInspector.RenderingFrameTimelineView.prototype = {
         WebInspector.ContentView.prototype.hidden.call(this);
     },
 
+    closed: function()
+    {
+        console.assert(this.representedObject instanceof WebInspector.Timeline);
+        this.representedObject.removeEventListener(null, null, this);
+    },
+
     updateLayout: function()
     {
         WebInspector.TimelineView.prototype.updateLayout.call(this);
index 7c8adad..73859d5 100644 (file)
@@ -101,6 +101,12 @@ WebInspector.ScriptTimelineView.prototype = {
         WebInspector.ContentView.prototype.hidden.call(this);
     },
 
+    closed: function()
+    {
+        console.assert(this.representedObject instanceof WebInspector.Timeline);
+        this.representedObject.removeEventListener(null, null, this);
+    },
+
     updateLayout: function()
     {
         WebInspector.TimelineView.prototype.updateLayout.call(this);
index 4835b6a..985ef96 100644 (file)
@@ -54,13 +54,6 @@ WebInspector.SearchTabContentView.prototype = {
         setTimeout(this.focusSearchField.bind(this));
     },
 
-    closed: function()
-    {
-        WebInspector.ContentBrowserTabContentView.prototype.closed.call(this);
-
-        this.navigationSidebarPanel.closed();
-    },
-
     canShowRepresentedObject: function(representedObject)
     {
         return representedObject instanceof WebInspector.Resource || representedObject instanceof WebInspector.DOMTree;
index 16c89f0..058d92b 100644 (file)
@@ -188,7 +188,7 @@ WebInspector.TabBrowser = class TabBrowser extends WebInspector.Object
 
     _tabBarItemSelected(event)
     {
-        var tabContentView = this._tabBar.selectedTabBarItem.representedObject;
+        var tabContentView = this._tabBar.selectedTabBarItem ? this._tabBar.selectedTabBarItem.representedObject : null;
 
         if (tabContentView) {
             this._recentTabContentViews.remove(tabContentView);
index a27ee24..53d2182 100644 (file)
@@ -147,6 +147,14 @@ WebInspector.TimelineSidebarPanel = class TimelineSidebarPanel extends WebInspec
         this.contentBrowser.addEventListener(WebInspector.ContentBrowser.Event.CurrentContentViewDidChange, this._contentBrowserCurrentContentViewDidChange, this);
         WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.Event.CapturingStarted, this._capturingStarted, this);
         WebInspector.timelineManager.addEventListener(WebInspector.TimelineManager.Event.CapturingStopped, this._capturingStopped, this);
+
+        for (var recording of WebInspector.timelineManager.recordings)
+            this._addRecording(recording);
+
+        this._recordingCountChanged();
+
+        if (WebInspector.timelineManager.activeRecording)
+            this._recordingLoaded();
     }
 
     // Public
@@ -162,6 +170,15 @@ WebInspector.TimelineSidebarPanel = class TimelineSidebarPanel extends WebInspec
             this._refreshFrameSelectionChart();
     }
 
+    closed()
+    {
+        WebInspector.showReplayInterfaceSetting.removeEventListener(null, null, this);
+        WebInspector.replayManager.removeEventListener(null, null, this);
+        WebInspector.timelineManager.removeEventListener(null, null, this);
+
+        WebInspector.timelineManager.reset();
+    }
+
     get viewMode()
     {
         return this._viewMode;
@@ -446,14 +463,17 @@ WebInspector.TimelineSidebarPanel = class TimelineSidebarPanel extends WebInspec
 
     _recordingCreated(event)
     {
-        var recording = event.data.recording;
+        this._addRecording(event.data.recording)
+        this._recordingCountChanged();
+    }
+
+    _addRecording(recording)
+    {
         console.assert(recording instanceof WebInspector.TimelineRecording, recording);
 
         var recordingTreeElement = new WebInspector.GeneralTreeElement(WebInspector.TimelineSidebarPanel.StopwatchIconStyleClass, recording.displayName, null, recording);
         this._recordingTreeElementMap.set(recording, recordingTreeElement);
         this._recordingsTreeOutline.appendChild(recordingTreeElement);
-
-        this._recordingCountChanged();
     }
 
     _recordingCountChanged()
index b74304b..c16f139 100644 (file)
@@ -28,9 +28,6 @@ WebInspector.TimelineTabContentView = function(identifier)
     var tabBarItem = new WebInspector.TabBarItem("Images/Timeline.svg", WebInspector.UIString("Timelines"));
     var detailsSidebarPanels = [WebInspector.resourceDetailsSidebarPanel, WebInspector.probeDetailsSidebarPanel];
 
-    // FIME: Until TimelineSidebarPanel supports instantiating after inspector launch, disable closing.
-    tabBarItem.hideCloseButton = true;
-
     WebInspector.ContentBrowserTabContentView.call(this, identifier || "timeline", "timeline", tabBarItem, WebInspector.TimelineSidebarPanel, detailsSidebarPanels);
 };