Title: [181011] trunk/Source/WebInspectorUI
Revision
181011
Author
[email protected]
Date
2015-03-04 12:24:03 -0800 (Wed, 04 Mar 2015)

Log Message

Web Inspector: TimelineViews should be displayed in a ContentViewContainer
https://bugs.webkit.org/show_bug.cgi?id=142290

Reviewed by Timothy Hatcher.

TimelineRecordingContentView has a bunch of logic to manage the currently visible TimelineView.
This could be delegated to a ContentViewContainer to simplify the logic. It also opens the possibility
for other views to be displayed beneath the timeline overview graphs when it makes sense to do so.

In order to be displayable in the container, TimelineView and its subclasses have been upgraded to
be ContentView subclasses. This also reduces some code duplication for basic view management.

* UserInterface/Views/ContentView.js:
(WebInspector.ContentView): Move base class instantiation pattern from TimelineView to here.
(WebInspector.ContentView.isViewable):
* UserInterface/Views/LayoutTimelineView.js: Use ContentView events and base methods.
(WebInspector.LayoutTimelineView.prototype.shown):
(WebInspector.LayoutTimelineView.prototype.hidden):
(WebInspector.LayoutTimelineView.prototype._dataGridNodeSelected):
* UserInterface/Views/NetworkTimelineView.js: Use ContentView events and base methods.
(WebInspector.NetworkTimelineView.prototype.shown):
(WebInspector.NetworkTimelineView.prototype.hidden):
(WebInspector.NetworkTimelineView.prototype._dataGridNodeSelected):
* UserInterface/Views/OverviewTimelineView.js: Use ContentView events and base methods.
(WebInspector.OverviewTimelineView.prototype.shown):
(WebInspector.OverviewTimelineView.prototype._dataGridNodeSelected):
(WebInspector.OverviewTimelineView.prototype._treeElementSelected):
* UserInterface/Views/ScriptTimelineView.js: Use ContentView events and base methods.
(WebInspector.ScriptTimelineView.prototype.shown):
(WebInspector.ScriptTimelineView.prototype.hidden):
(WebInspector.ScriptTimelineView.prototype._dataGridNodeSelected):
* UserInterface/Views/TimelineRecordingContentView.css: Use WebInspector.ContentViewContainer class.
(.content-view.timeline-recording > .content-view-container):
(.content-view.timeline-recording > .content-view-container > .timeline-view > .data-grid td):
(.content-view.timeline-recording > .content-view-container > .timeline-view > .data-grid table.data):
(.content-view.timeline-recording > .view-container): Deleted.
(.content-view.timeline-recording > .view-container > .timeline-view > .data-grid td): Deleted.
(.content-view.timeline-recording > .view-container > .timeline-view > .data-grid table.data): Deleted.

* UserInterface/Views/TimelineRecordingContentView.js:
Many of the changes here mirror the implementation of ClusterContentView. Searching is disabled since
none of the timeline views are currently searchable using ContentViewContainer's full-text search.

In cases where we update the current timeline view, the currentTimelineView accessor returns the
content view if a TimelineView is shown in the content view container, otherwise null.

(WebInspector.TimelineRecordingContentView):
(WebInspector.TimelineRecordingContentView.prototype.showOverviewTimelineView):
(WebInspector.TimelineRecordingContentView.prototype.showTimelineViewForTimeline):
(WebInspector.TimelineRecordingContentView.prototype.get supplementalRepresentedObjects):
(WebInspector.TimelineRecordingContentView.prototype.get handleCopyEvent):
(WebInspector.TimelineRecordingContentView.prototype.get supportsSave):
(WebInspector.TimelineRecordingContentView.prototype.get saveData):
(WebInspector.TimelineRecordingContentView.prototype.get currentTimelineView):
(WebInspector.TimelineRecordingContentView.prototype.shown):
(WebInspector.TimelineRecordingContentView.prototype.hidden):
(WebInspector.TimelineRecordingContentView.prototype.closed):
(WebInspector.TimelineRecordingContentView.prototype.canGoBack):
(WebInspector.TimelineRecordingContentView.prototype.canGoForward):
(WebInspector.TimelineRecordingContentView.prototype.goBack):
(WebInspector.TimelineRecordingContentView.prototype.goForward):
(WebInspector.TimelineRecordingContentView.prototype.updateLayout):
(WebInspector.TimelineRecordingContentView.prototype.saveToCookie):
(WebInspector.TimelineRecordingContentView.prototype.get filterDidChange):
(WebInspector.TimelineRecordingContentView.prototype._currentContentViewDidChange):
(WebInspector.TimelineRecordingContentView.prototype._contentViewSelectionPathComponentDidChange):
(WebInspector.TimelineRecordingContentView.prototype._contentViewSupplementalRepresentedObjectsDidChange):
(WebInspector.TimelineRecordingContentView.prototype._updateTimes):
(WebInspector.TimelineRecordingContentView.prototype._timelineRemoved):
(WebInspector.TimelineRecordingContentView.prototype._timelineCountChanged):
(WebInspector.TimelineRecordingContentView.prototype._timeRangeSelectionChanged):
(WebInspector.TimelineRecordingContentView.prototype.filterDidChange): Deleted.
(WebInspector.TimelineRecordingContentView.prototype._timelineViewSelectionPathComponentsDidChange): Deleted.
(WebInspector.TimelineRecordingContentView.prototype._showTimelineView): Deleted.
* UserInterface/Views/TimelineView.js: Remove duplicated functionality and use ContentView equivalents instead.
(WebInspector.TimelineView):
(WebInspector.TimelineView.prototype.filterUpdated):
(WebInspector.TimelineView.prototype.needsLayout):
(WebInspector.TimelineView.prototype.get representedObject): Deleted.
(WebInspector.TimelineView.prototype.get visible): Deleted.
(WebInspector.TimelineView.prototype.shown): Deleted.
(WebInspector.TimelineView.prototype.hidden): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (181010 => 181011)


--- trunk/Source/WebInspectorUI/ChangeLog	2015-03-04 20:00:00 UTC (rev 181010)
+++ trunk/Source/WebInspectorUI/ChangeLog	2015-03-04 20:24:03 UTC (rev 181011)
@@ -1,3 +1,88 @@
+2015-03-04  Brian J. Burg  <[email protected]>
+
+        Web Inspector: TimelineViews should be displayed in a ContentViewContainer
+        https://bugs.webkit.org/show_bug.cgi?id=142290
+
+        Reviewed by Timothy Hatcher.
+
+        TimelineRecordingContentView has a bunch of logic to manage the currently visible TimelineView.
+        This could be delegated to a ContentViewContainer to simplify the logic. It also opens the possibility
+        for other views to be displayed beneath the timeline overview graphs when it makes sense to do so.
+
+        In order to be displayable in the container, TimelineView and its subclasses have been upgraded to
+        be ContentView subclasses. This also reduces some code duplication for basic view management.
+
+        * UserInterface/Views/ContentView.js:
+        (WebInspector.ContentView): Move base class instantiation pattern from TimelineView to here.
+        (WebInspector.ContentView.isViewable):
+        * UserInterface/Views/LayoutTimelineView.js: Use ContentView events and base methods.
+        (WebInspector.LayoutTimelineView.prototype.shown):
+        (WebInspector.LayoutTimelineView.prototype.hidden):
+        (WebInspector.LayoutTimelineView.prototype._dataGridNodeSelected):
+        * UserInterface/Views/NetworkTimelineView.js: Use ContentView events and base methods.
+        (WebInspector.NetworkTimelineView.prototype.shown):
+        (WebInspector.NetworkTimelineView.prototype.hidden):
+        (WebInspector.NetworkTimelineView.prototype._dataGridNodeSelected):
+        * UserInterface/Views/OverviewTimelineView.js: Use ContentView events and base methods.
+        (WebInspector.OverviewTimelineView.prototype.shown):
+        (WebInspector.OverviewTimelineView.prototype._dataGridNodeSelected):
+        (WebInspector.OverviewTimelineView.prototype._treeElementSelected):
+        * UserInterface/Views/ScriptTimelineView.js: Use ContentView events and base methods.
+        (WebInspector.ScriptTimelineView.prototype.shown):
+        (WebInspector.ScriptTimelineView.prototype.hidden):
+        (WebInspector.ScriptTimelineView.prototype._dataGridNodeSelected):
+        * UserInterface/Views/TimelineRecordingContentView.css: Use WebInspector.ContentViewContainer class.
+        (.content-view.timeline-recording > .content-view-container):
+        (.content-view.timeline-recording > .content-view-container > .timeline-view > .data-grid td):
+        (.content-view.timeline-recording > .content-view-container > .timeline-view > .data-grid table.data):
+        (.content-view.timeline-recording > .view-container): Deleted.
+        (.content-view.timeline-recording > .view-container > .timeline-view > .data-grid td): Deleted.
+        (.content-view.timeline-recording > .view-container > .timeline-view > .data-grid table.data): Deleted.
+
+        * UserInterface/Views/TimelineRecordingContentView.js:
+        Many of the changes here mirror the implementation of ClusterContentView. Searching is disabled since
+        none of the timeline views are currently searchable using ContentViewContainer's full-text search.
+
+        In cases where we update the current timeline view, the currentTimelineView accessor returns the
+        content view if a TimelineView is shown in the content view container, otherwise null.
+
+        (WebInspector.TimelineRecordingContentView):
+        (WebInspector.TimelineRecordingContentView.prototype.showOverviewTimelineView):
+        (WebInspector.TimelineRecordingContentView.prototype.showTimelineViewForTimeline):
+        (WebInspector.TimelineRecordingContentView.prototype.get supplementalRepresentedObjects):
+        (WebInspector.TimelineRecordingContentView.prototype.get handleCopyEvent):
+        (WebInspector.TimelineRecordingContentView.prototype.get supportsSave):
+        (WebInspector.TimelineRecordingContentView.prototype.get saveData):
+        (WebInspector.TimelineRecordingContentView.prototype.get currentTimelineView):
+        (WebInspector.TimelineRecordingContentView.prototype.shown):
+        (WebInspector.TimelineRecordingContentView.prototype.hidden):
+        (WebInspector.TimelineRecordingContentView.prototype.closed):
+        (WebInspector.TimelineRecordingContentView.prototype.canGoBack):
+        (WebInspector.TimelineRecordingContentView.prototype.canGoForward):
+        (WebInspector.TimelineRecordingContentView.prototype.goBack):
+        (WebInspector.TimelineRecordingContentView.prototype.goForward):
+        (WebInspector.TimelineRecordingContentView.prototype.updateLayout):
+        (WebInspector.TimelineRecordingContentView.prototype.saveToCookie):
+        (WebInspector.TimelineRecordingContentView.prototype.get filterDidChange):
+        (WebInspector.TimelineRecordingContentView.prototype._currentContentViewDidChange):
+        (WebInspector.TimelineRecordingContentView.prototype._contentViewSelectionPathComponentDidChange):
+        (WebInspector.TimelineRecordingContentView.prototype._contentViewSupplementalRepresentedObjectsDidChange):
+        (WebInspector.TimelineRecordingContentView.prototype._updateTimes):
+        (WebInspector.TimelineRecordingContentView.prototype._timelineRemoved):
+        (WebInspector.TimelineRecordingContentView.prototype._timelineCountChanged):
+        (WebInspector.TimelineRecordingContentView.prototype._timeRangeSelectionChanged):
+        (WebInspector.TimelineRecordingContentView.prototype.filterDidChange): Deleted.
+        (WebInspector.TimelineRecordingContentView.prototype._timelineViewSelectionPathComponentsDidChange): Deleted.
+        (WebInspector.TimelineRecordingContentView.prototype._showTimelineView): Deleted.
+        * UserInterface/Views/TimelineView.js: Remove duplicated functionality and use ContentView equivalents instead.
+        (WebInspector.TimelineView):
+        (WebInspector.TimelineView.prototype.filterUpdated):
+        (WebInspector.TimelineView.prototype.needsLayout):
+        (WebInspector.TimelineView.prototype.get representedObject): Deleted.
+        (WebInspector.TimelineView.prototype.get visible): Deleted.
+        (WebInspector.TimelineView.prototype.shown): Deleted.
+        (WebInspector.TimelineView.prototype.hidden): Deleted.
+
 2015-03-03  Brian J. Burg  <[email protected]>
 
         Web Inspector: selecting overview timeline tree elements without source locations doesn't update selection components

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ContentView.js (181010 => 181011)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ContentView.js	2015-03-04 20:00:00 UTC (rev 181010)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ContentView.js	2015-03-04 20:24:03 UTC (rev 181011)
@@ -42,6 +42,18 @@
         if (representedObject instanceof WebInspector.TimelineRecording)
             return new WebInspector.TimelineRecordingContentView(representedObject);
 
+        if (representedObject instanceof WebInspector.Timeline) {
+            var timelineType = representedObject.type;
+            if (timelineType === WebInspector.TimelineRecord.Type.Network)
+                return new WebInspector.NetworkTimelineView(representedObject);
+
+            if (timelineType === WebInspector.TimelineRecord.Type.Layout)
+                return new WebInspector.LayoutTimelineView(representedObject);
+
+            if (timelineType === WebInspector.TimelineRecord.Type.Script)
+                return new WebInspector.ScriptTimelineView(representedObject);
+        }
+
         if (representedObject instanceof WebInspector.DOMStorageObject)
             return new WebInspector.DOMStorageContentView(representedObject);
 
@@ -106,6 +118,8 @@
         return true;
     if (representedObject instanceof WebInspector.TimelineRecording)
         return true;
+    if (representedObject instanceof WebInspector.Timeline)
+        return true;
     if (representedObject instanceof WebInspector.DOMStorageObject)
         return true;
     if (representedObject instanceof WebInspector.CookieStorageObject)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/LayoutTimelineView.js (181010 => 181011)


--- trunk/Source/WebInspectorUI/UserInterface/Views/LayoutTimelineView.js	2015-03-04 20:00:00 UTC (rev 181010)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/LayoutTimelineView.js	2015-03-04 20:24:03 UTC (rev 181011)
@@ -109,7 +109,7 @@
 
     shown: function()
     {
-        WebInspector.TimelineView.prototype.shown.call(this);
+        WebInspector.ContentView.prototype.shown.call(this);
 
         this._updateHighlight();
 
@@ -122,7 +122,7 @@
 
         this._dataGrid.hidden();
 
-        WebInspector.TimelineView.prototype.hidden.call(this);
+        WebInspector.ContentView.prototype.hidden.call(this);
     },
 
     filterDidChange: function()
@@ -199,7 +199,7 @@
 
     _dataGridNodeSelected: function(event)
     {
-        this.dispatchEventToListeners(WebInspector.TimelineView.Event.SelectionPathComponentsDidChange);
+        this.dispatchEventToListeners(WebInspector.ContentView.Event.SelectionPathComponentsDidChange);
     },
 
     _treeElementDeselected: function(treeElement)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTimelineView.js (181010 => 181011)


--- trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTimelineView.js	2015-03-04 20:00:00 UTC (rev 181010)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTimelineView.js	2015-03-04 20:24:03 UTC (rev 181011)
@@ -115,7 +115,7 @@
 
     shown: function()
     {
-        WebInspector.TimelineView.prototype.shown.call(this);
+        WebInspector.ContentView.prototype.shown.call(this);
 
         this._dataGrid.shown();
     },
@@ -124,7 +124,7 @@
     {
         this._dataGrid.hidden();
 
-        WebInspector.TimelineView.prototype.hidden.call(this);
+        WebInspector.ContentView.prototype.hidden.call(this);
     },
 
     updateLayout: function()
@@ -197,7 +197,7 @@
 
     _dataGridNodeSelected: function(event)
     {
-        this.dispatchEventToListeners(WebInspector.TimelineView.Event.SelectionPathComponentsDidChange);
+        this.dispatchEventToListeners(WebInspector.ContentView.Event.SelectionPathComponentsDidChange);
     },
 
     _treeElementDeselected: function(treeElement)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/OverviewTimelineView.js (181010 => 181011)


--- trunk/Source/WebInspectorUI/UserInterface/Views/OverviewTimelineView.js	2015-03-04 20:00:00 UTC (rev 181010)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/OverviewTimelineView.js	2015-03-04 20:24:03 UTC (rev 181011)
@@ -83,7 +83,7 @@
 
     shown: function()
     {
-        WebInspector.TimelineView.prototype.shown.call(this);
+        WebInspector.ContentView.prototype.shown.call(this);
 
         this._treeOutlineDataGridSynchronizer.synchronize();
     },
@@ -322,7 +322,7 @@
 
     _dataGridNodeSelected: function(event)
     {
-        this.dispatchEventToListeners(WebInspector.TimelineView.Event.SelectionPathComponentsDidChange);
+        this.dispatchEventToListeners(WebInspector.ContentView.Event.SelectionPathComponentsDidChange);
     },
 
     _treeElementDeselected: function(treeElement)
@@ -352,7 +352,7 @@
 
         if (!treeElement.sourceCodeTimeline.sourceCodeLocation) {
             WebInspector.timelineSidebarPanel.showTimelineOverview();
-            this.dispatchEventToListeners(WebInspector.TimelineView.Event.SelectionPathComponentsDidChange);
+            this.dispatchEventToListeners(WebInspector.ContentView.Event.SelectionPathComponentsDidChange);
             return;
         }
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ScriptTimelineView.js (181010 => 181011)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ScriptTimelineView.js	2015-03-04 20:00:00 UTC (rev 181010)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ScriptTimelineView.js	2015-03-04 20:24:03 UTC (rev 181011)
@@ -91,7 +91,7 @@
 
     shown: function()
     {
-        WebInspector.TimelineView.prototype.shown.call(this);
+        WebInspector.ContentView.prototype.shown.call(this);
 
         this._dataGrid.shown();
     },
@@ -100,7 +100,7 @@
     {
         this._dataGrid.hidden();
 
-        WebInspector.TimelineView.prototype.hidden.call(this);
+        WebInspector.ContentView.prototype.hidden.call(this);
     },
 
     updateLayout: function()
@@ -243,7 +243,7 @@
 
     _dataGridNodeSelected: function(event)
     {
-        this.dispatchEventToListeners(WebInspector.TimelineView.Event.SelectionPathComponentsDidChange);
+        this.dispatchEventToListeners(WebInspector.ContentView.Event.SelectionPathComponentsDidChange);
     },
 
     _treeElementDeselected: function(treeElement)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.css (181010 => 181011)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.css	2015-03-04 20:00:00 UTC (rev 181010)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.css	2015-03-04 20:24:03 UTC (rev 181011)
@@ -30,7 +30,7 @@
     right: 0;
 }
 
-.content-view.timeline-recording > .view-container {
+.content-view.timeline-recording > .content-view-container {
     position: absolute;
     left: 0;
     right: 0;
@@ -38,12 +38,12 @@
     overflow: hidden;
 }
 
-.content-view.timeline-recording > .view-container > .timeline-view > .data-grid td {
+.content-view.timeline-recording > .content-view-container > .timeline-view > .data-grid td {
     height: 16px;
     line-height: 16px;
 }
 
-.content-view.timeline-recording > .view-container > .timeline-view > .data-grid table.data {
+.content-view.timeline-recording > .content-view-container > .timeline-view > .data-grid table.data {
     background-image: linear-gradient(to bottom, white, white 50%, rgb(243, 243, 243) 50%, rgb(243, 243, 243));
     background-size: 100% 40px;
 }

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js (181010 => 181011)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js	2015-03-04 20:00:00 UTC (rev 181010)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js	2015-03-04 20:24:03 UTC (rev 181011)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2015 University of Washington.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -35,9 +36,9 @@
     this._timelineOverview.addEventListener(WebInspector.TimelineOverview.Event.TimeRangeSelectionChanged, this._timeRangeSelectionChanged, this);
     this.element.appendChild(this._timelineOverview.element);
 
-    this._viewContainerElement = document.createElement("div");
-    this._viewContainerElement.classList.add(WebInspector.TimelineRecordingContentView.ViewContainerStyleClassName);
-    this.element.appendChild(this._viewContainerElement);
+    this._contentViewContainer = new WebInspector.ContentViewContainer();
+    this._contentViewContainer.addEventListener(WebInspector.ContentViewContainer.Event.CurrentContentViewDidChange, this._currentContentViewDidChange, this);
+    this.element.appendChild(this._contentViewContainer.element);
 
     var trashImage;
     if (WebInspector.Platform.isLegacyMacOS)
@@ -54,9 +55,6 @@
     this._timelineViewMap = new Map;
     this._pathComponentMap = new Map;
 
-    this._currentTimelineView = null;
-    this._currentTimelineViewIdentifier = null;
-
     this._updating = false;
     this._currentTime = NaN;
     this._lastUpdateTimestamp = NaN;
@@ -73,6 +71,9 @@
     WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.Paused, this._debuggerPaused, this);
     WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.Resumed, this._debuggerResumed, this);
 
+    WebInspector.ContentView.addEventListener(WebInspector.ContentView.Event.SelectionPathComponentsDidChange, this._contentViewSelectionPathComponentDidChange, this);
+    WebInspector.ContentView.addEventListener(WebInspector.ContentView.Event.SupplementalRepresentedObjectsDidChange, this._contentViewSupplementalRepresentedObjectsDidChange, this);
+
     for (var timeline of this._recording.timelines.values())
         this._timelineAdded(timeline);
 
@@ -80,7 +81,6 @@
 };
 
 WebInspector.TimelineRecordingContentView.StyleClassName = "timeline-recording";
-WebInspector.TimelineRecordingContentView.ViewContainerStyleClassName = "view-container";
 
 WebInspector.TimelineRecordingContentView.SelectedTimelineTypeCookieKey = "timeline-recording-content-view-selected-timeline-type";
 WebInspector.TimelineRecordingContentView.OverviewTimelineViewCookieValue = "timeline-recording-content-view-overview-timeline-view";
@@ -93,7 +93,7 @@
 
     showOverviewTimelineView: function()
     {
-        this._showTimelineView(this._overviewTimelineView);
+        this._contentViewContainer.showContentView(this._overviewTimelineView);
     },
 
     showTimelineViewForTimeline: function(timeline)
@@ -103,7 +103,7 @@
         if (!this._timelineViewMap.has(timeline))
             return;
 
-        this._showTimelineView(this._timelineViewMap.get(timeline));
+        this._contentViewContainer.showContentView(this._timelineViewMap.get(timeline));
     },
 
     get allowedNavigationSidebarPanels()
@@ -119,30 +119,56 @@
 
     get selectionPathComponents()
     {
-        var pathComponents = [];
-        if (this._currentTimelineView.representedObject instanceof WebInspector.Timeline)
-            pathComponents.push(this._pathComponentMap.get(this._currentTimelineView.representedObject));
-        pathComponents = pathComponents.concat(this._currentTimelineView.selectionPathComponents || []);
+        if (!this._contentViewContainer.currentContentView)
+            return [];
+
+        var pathComponents = this._contentViewContainer.currentContentView.selectionPathComponents || [];
+        var representedObject = this._contentViewContainer.currentContentView.representedObject;
+        if (representedObject instanceof WebInspector.Timeline)
+            pathComponents.unshift(this._pathComponentMap.get(representedObject));
         return pathComponents;
     },
 
+    get supplementalRepresentedObjects()
+    {
+        if (!this._contentViewContainer.currentContentView)
+            return [];
+        return this._contentViewContainer.currentContentView.supplementalRepresentedObjects;
+    },
+
     get navigationItems()
     {
         return [this._clearTimelineNavigationItem];
     },
 
+    get handleCopyEvent()
+    {
+        var currentContentView = this._contentViewContainer.currentContentView;
+        return currentContentView && typeof currentContentView.handleCopyEvent === "function" ? currentContentView.handleCopyEvent.bind(currentContentView) : null;
+    },
+
+    get supportsSave()
+    {
+        var currentContentView = this._contentViewContainer.currentContentView;
+        return currentContentView && currentContentView.supportsSave;
+    },
+
+    get saveData()
+    {
+        var currentContentView = this._contentViewContainer.currentContentView;
+        return currentContentView && currentContentView.saveData || null;
+    },
+
     get currentTimelineView()
     {
-        return this._currentTimelineView;
+        var contentView = this._contentViewContainer.currentContentView;
+        return (contentView instanceof WebInspector.TimelineView) ? contentView : null;
     },
 
     shown: function()
     {
-        if (!this._currentTimelineView)
-            return;
-
         this._timelineOverview.shown();
-        this._currentTimelineView.shown();
+        this._contentViewContainer.shown();
         this._clearTimelineNavigationItem.enabled = this._recording.isWritable();
 
         if (!this._updating && WebInspector.timelineManager.activeRecording === this._recording && WebInspector.timelineManager.isCapturing())
@@ -151,42 +177,59 @@
 
     hidden: function()
     {
-        if (!this._currentTimelineView)
-            return;
-
         this._timelineOverview.hidden();
-        this._currentTimelineView.hidden();
+        this._contentViewContainer.hidden();
 
         if (this._updating)
             this._stopUpdatingCurrentTime();
     },
 
-    filterDidChange: function()
+    closed: function()
     {
-        if (!this._currentTimelineView)
-            return;
+        this._contentViewContainer.closeAllContentViews();
 
-        this._currentTimelineView.filterDidChange();
+        WebInspector.ContentView.removeEventListener(WebInspector.ContentView.Event.SelectionPathComponentsDidChange, this._contentViewSelectionPathComponentDidChange, this);
+        WebInspector.ContentView.removeEventListener(WebInspector.ContentView.Event.SupplementalRepresentedObjectsDidChange, this._contentViewSupplementalRepresentedObjectsDidChange, this);
     },
 
+    canGoBack: function()
+    {
+        return this._contentViewContainer.canGoBack();
+    },
+
+    canGoForward: function()
+    {
+        return this._contentViewContainer.canGoForward();
+    },
+
+    goBack: function()
+    {
+        this._contentViewContainer.goBack();
+    },
+
+    goForward: function()
+    {
+        this._contentViewContainer.goForward();
+    },
+
     updateLayout: function()
     {
         this._timelineOverview.updateLayoutForResize();
 
-        if (!this._currentTimelineView)
-            return;
-
-        this._currentTimelineView.updateLayout();
+        var currentContentView = this._contentViewContainer.currentContentView;
+        if (currentContentView)
+            currentContentView.updateLayout();
     },
 
     saveToCookie: function(cookie)
     {
         cookie.type = WebInspector.ContentViewCookieType.Timelines;
 
-        if (!this._currentTimelineView || this._currentTimelineView === this._overviewTimelineView)
+        var currentContentView = this._contentViewContainer.currentContentView;
+        if (!currentContentView || currentContentView === this._overviewTimelineView)
             cookie[WebInspector.TimelineRecordingContentView.SelectedTimelineTypeCookieKey] = WebInspector.TimelineRecordingContentView.OverviewTimelineViewCookieValue;
-        else
-            cookie[WebInspector.TimelineRecordingContentView.SelectedTimelineTypeCookieKey] = this._currentTimelineView.representedObject.type;
+        else if (currentContentView.representedObject instanceof WebInspector.Timeline)
+            cookie[WebInspector.TimelineRecordingContentView.SelectedTimelineTypeCookieKey] = this.currentTimelineView.representedObject.type;
     },
 
     restoreFromCookie: function(cookie)
@@ -199,9 +242,17 @@
             this.showTimelineViewForTimeline(this.representedObject.timelines.get(timelineType));
     },
 
+    filterDidChange: function()
+    {
+        if (!this.currentTimelineView)
+            return;
+
+        this.currentTimelineView.filterDidChange();
+    },
+
     matchTreeElementAgainstCustomFilters: function(treeElement)
     {
-        if (this._currentTimelineView && !this._currentTimelineView.matchTreeElementAgainstCustomFilters(treeElement))
+        if (this.currentTimelineView && !this.currentTimelineView.matchTreeElementAgainstCustomFilters(treeElement))
             return false;
 
         var startTime = this._timelineOverview.selectionStartTime;
@@ -257,51 +308,39 @@
 
     // Private
 
+    _currentContentViewDidChange: function(event)
+    {
+        var timelineView = this.currentTimelineView;
+        if (timelineView) {
+            WebInspector.timelineSidebarPanel.contentTreeOutline = timelineView.navigationSidebarTreeOutline;
+            WebInspector.timelineSidebarPanel.contentTreeOutlineLabel = timelineView.navigationSidebarTreeOutlineLabel;
+
+            timelineView.startTime = this._timelineOverview.selectionStartTime;
+            timelineView.endTime = this._timelineOverview.selectionStartTime + this._timelineOverview.selectionDuration;
+            timelineView.currentTime = this._currentTime;
+        }
+
+        this.dispatchEventToListeners(WebInspector.ContentView.Event.SelectionPathComponentsDidChange);
+        this.dispatchEventToListeners(WebInspector.ContentView.Event.NavigationItemsDidChange);
+    },
+
     _pathComponentSelected: function(event)
     {
         WebInspector.timelineSidebarPanel.showTimelineViewForTimeline(event.data.pathComponent.representedObject);
     },
 
-    _timelineViewSelectionPathComponentsDidChange: function()
+    _contentViewSelectionPathComponentDidChange: function(event)
     {
+        if (event.target !== this._contentViewContainer.currentContentView)
+            return;
         this.dispatchEventToListeners(WebInspector.ContentView.Event.SelectionPathComponentsDidChange);
     },
 
-    _showTimelineView: function(timelineView)
+    _contentViewSupplementalRepresentedObjectsDidChange: function(event)
     {
-        console.assert(timelineView instanceof WebInspector.TimelineView);
-        console.assert(timelineView.representedObject === this._recording || this._recording.timelines.has(timelineView.representedObject.type));
-
-        // If the content view is shown and then hidden, we must reattach the content tree outline and timeline view.
-        if (timelineView.visible && timelineView === this._currentTimelineView)
+        if (event.target !== this._contentViewContainer.currentContentView)
             return;
-
-        if (this._currentTimelineView) {
-            this._currentTimelineView.removeEventListener(WebInspector.TimelineView.Event.SelectionPathComponentsDidChange, this._timelineViewSelectionPathComponentsDidChange, this);
-
-            this._currentTimelineView.hidden();
-            this._currentTimelineView.element.remove();
-        }
-
-        this._currentTimelineView = timelineView;
-
-        WebInspector.timelineSidebarPanel.contentTreeOutline = timelineView && timelineView.navigationSidebarTreeOutline;
-        WebInspector.timelineSidebarPanel.contentTreeOutlineLabel = timelineView && timelineView.navigationSidebarTreeOutlineLabel;
-
-        if (this._currentTimelineView) {
-            this._currentTimelineView.addEventListener(WebInspector.TimelineView.Event.SelectionPathComponentsDidChange, this._timelineViewSelectionPathComponentsDidChange, this);
-
-            this._viewContainerElement.appendChild(this._currentTimelineView.element);
-
-            this._currentTimelineView.startTime = this._timelineOverview.selectionStartTime;
-            this._currentTimelineView.endTime = this._timelineOverview.selectionStartTime + this._timelineOverview.selectionDuration;
-            this._currentTimelineView.currentTime = this._currentTime;
-
-            this._currentTimelineView.shown();
-            this._currentTimelineView.updateLayout();
-        }
-
-        this.dispatchEventToListeners(WebInspector.ContentView.Event.SelectionPathComponentsDidChange);
+        this.dispatchEventToListeners(WebInspector.ContentView.Event.SupplementalRepresentedObjectsDidChange);
     },
 
     _update: function(timestamp)
@@ -350,13 +389,15 @@
 
         this._currentTime = currentTime;
         this._timelineOverview.currentTime = currentTime;
-        this._currentTimelineView.currentTime = currentTime;
+        if (this.currentTimelineView)
+            this.currentTimelineView.currentTime = currentTime;
 
         WebInspector.timelineSidebarPanel.updateFilter();
 
         // Force a layout now since we are already in an animation frame and don't need to delay it until the next.
         this._timelineOverview.updateLayoutIfNeeded();
-        this._currentTimelineView.updateLayoutIfNeeded();
+        if (this.currentTimelineView)
+            this.currentTimelineView.updateLayoutIfNeeded();
     },
 
     _startUpdatingCurrentTime: function()
@@ -455,7 +496,7 @@
         console.assert(timeline instanceof WebInspector.Timeline, timeline);
         console.assert(!this._timelineViewMap.has(timeline), timeline);
 
-        this._timelineViewMap.set(timeline, new WebInspector.TimelineView(timeline));
+        this._timelineViewMap.set(timeline, new WebInspector.ContentView(timeline));
 
         var pathComponent = new WebInspector.HierarchicalPathComponent(timeline.displayName, timeline.iconClassName, timeline);
         pathComponent.addEventListener(WebInspector.HierarchicalPathComponent.Event.SiblingWasSelected, this._pathComponentSelected, this);
@@ -471,7 +512,7 @@
         console.assert(this._timelineViewMap.has(timeline), timeline);
 
         var timelineView = this._timelineViewMap.take(timeline);
-        if (this._currentTimelineView === timelineView)
+        if (this.currentTimelineView === timelineView)
             this.showOverviewTimelineView();
 
         this._pathComponentMap.delete(timeline);
@@ -495,7 +536,7 @@
         const timelineHeight = 36;
         const extraOffset = 22;
         this._timelineOverview.element.style.height = (timelineCount * timelineHeight + extraOffset) + "px";
-        this._viewContainerElement.style.top = (timelineCount * timelineHeight + extraOffset) + "px";
+        this._contentViewContainer.element.style.top = (timelineCount * timelineHeight + extraOffset) + "px";
     },
 
     _recordingReset: function(event)
@@ -530,12 +571,14 @@
 
     _timeRangeSelectionChanged: function(event)
     {
-        this._currentTimelineView.startTime = this._timelineOverview.selectionStartTime;
-        this._currentTimelineView.endTime = this._timelineOverview.selectionStartTime + this._timelineOverview.selectionDuration;
+        if (this.currentTimelineView) {
+            this.currentTimelineView.startTime = this._timelineOverview.selectionStartTime;
+            this.currentTimelineView.endTime = this._timelineOverview.selectionStartTime + this._timelineOverview.selectionDuration;
+        }
 
         // Delay until the next frame to stay in sync with the current timeline view's time-based layout changes.
         requestAnimationFrame(function() {
-            var selectedTreeElement = this._currentTimelineView && this._currentTimelineView.navigationSidebarTreeOutline ? this._currentTimelineView.navigationSidebarTreeOutline.selectedTreeElement : null;
+            var selectedTreeElement = this.currentTimelineView && this.currentTimelineView.navigationSidebarTreeOutline ? this.currentTimelineView.navigationSidebarTreeOutline.selectedTreeElement : null;
             var selectionWasHidden = selectedTreeElement && selectedTreeElement.hidden;
 
             WebInspector.timelineSidebarPanel.updateFilter();

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineView.js (181010 => 181011)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineView.js	2015-03-04 20:00:00 UTC (rev 181010)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineView.js	2015-03-04 20:24:03 UTC (rev 181011)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2015 University of Washington.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -25,35 +26,12 @@
 
 WebInspector.TimelineView = function(representedObject)
 {
-    if (this.constructor === WebInspector.TimelineView) {
-        // When instantiated directly return an instance of a type-based concrete subclass.
-
-        console.assert(representedObject && representedObject instanceof WebInspector.Timeline);
-
-        var timelineType = representedObject.type;
-        if (timelineType === WebInspector.TimelineRecord.Type.Network)
-            return new WebInspector.NetworkTimelineView(representedObject);
-
-        if (timelineType === WebInspector.TimelineRecord.Type.Layout)
-            return new WebInspector.LayoutTimelineView(representedObject);
-
-        if (timelineType === WebInspector.TimelineRecord.Type.Script)
-            return new WebInspector.ScriptTimelineView(representedObject);
-
-        throw Error("Can't make a Timeline for an unknown representedObject.");
-    }
-
-    // Concrete object instantiation.
+    // This class should not be instantiated directly. Create a concrete subclass instead.
     console.assert(this.constructor !== WebInspector.TimelineView && this instanceof WebInspector.TimelineView);
 
-    WebInspector.Object.call(this);
+    WebInspector.ContentView.call(this, representedObject);
 
-    console.assert(representedObject instanceof WebInspector.Timeline || representedObject instanceof WebInspector.TimelineRecording);
-    this._representedObject = representedObject;
-
     this._contentTreeOutline = WebInspector.timelineSidebarPanel.createContentTreeOutline();
-
-    this.element = document.createElement("div");
     this.element.classList.add(WebInspector.TimelineView.StyleClassName);
 
     this._zeroTime = 0;
@@ -64,21 +42,12 @@
 
 WebInspector.TimelineView.StyleClassName = "timeline-view";
 
-WebInspector.TimelineView.Event = {
-    SelectionPathComponentsDidChange: "timeline-view-selection-path-components-did-change"
-};
-
 WebInspector.TimelineView.prototype = {
     constructor: WebInspector.TimelineView,
-    __proto__: WebInspector.Object.prototype,
+    __proto__: WebInspector.ContentView.prototype,
 
     // Public
 
-    get representedObject()
-    {
-        return this._representedObject;
-    },
-
     get navigationSidebarTreeOutline()
     {
         return this._contentTreeOutline;
@@ -170,30 +139,12 @@
             this.needsLayout();
     },
 
-    get visible()
-    {
-        return this._visible;
-    },
-
     reset: function()
     {
         this._contentTreeOutline.removeChildren();
     },
 
-    shown: function()
-    {
-        this._visible = true;
 
-        // Implemented by sub-classes if needed.
-    },
-
-    hidden: function()
-    {
-        // Implemented by sub-classes if needed.
-
-        this._visible = false;
-    },
-
     filterDidChange: function()
     {
         // Implemented by sub-classes if needed.
@@ -224,7 +175,7 @@
 
     filterUpdated: function()
     {
-        this.dispatchEventToListeners(WebInspector.TimelineView.Event.SelectionPathComponentsDidChange);
+        this.dispatchEventToListeners(WebInspector.ContentView.Event.SelectionPathComponentsDidChange);
     },
 
     // Protected
@@ -236,7 +187,7 @@
 
     needsLayout: function()
     {
-        if (!this._visible)
+        if (!this.visible)
             return;
 
         if (this._scheduledLayoutUpdateIdentifier)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to