Title: [183134] trunk/Source/WebInspectorUI
Revision
183134
Author
[email protected]
Date
2015-04-22 14:12:40 -0700 (Wed, 22 Apr 2015)

Log Message

Web Inspector: clicking Timelines tree view nodes should not change the current content view
https://bugs.webkit.org/show_bug.cgi?id=132202

Patch by Matt Baker <[email protected]> on 2015-04-22
Reviewed by Brian Burg.

TimelineSidebarPanel now prevents timeline views from switching to another content view while the content
browser is showing the TimelineRecordingContentView. Code responsible for creating and updating the tree
element close button, which was duplicated in multiple derived TimelineView classes, has been moved to the
TimelineView base class.

* UserInterface/Views/LayoutTimelineView.js:
Updated name of location column, which was broken in a recent patch.
(WebInspector.LayoutTimelineView.prototype.treeElementDeselected):
(WebInspector.LayoutTimelineView.prototype.treeElementSelected):
Added overrides of new base class methods to handle view-specific highlight logic.
(WebInspector.LayoutTimelineView.prototype._treeElementDeselected): Deleted.
(WebInspector.LayoutTimelineView.prototype._treeElementSelected): Deleted.
(WebInspector.LayoutTimelineView.prototype._updateTreeElementWithCloseButton): Deleted.
(WebInspector.LayoutTimelineView.prototype._closeStatusButtonClicked): Deleted.
Removed tree element close button logic.

* UserInterface/Views/NetworkTimelineView.js:
(WebInspector.NetworkTimelineView.prototype.showContentViewForTreeElement):
(WebInspector.NetworkTimelineView.prototype.treeElementSelected):
Added overrides of new base class methods.
(WebInspector.NetworkTimelineView.prototype._treeElementDeselected): Deleted.
(WebInspector.NetworkTimelineView.prototype._treeElementSelected): Deleted.
Removed tree element close button logic.

* UserInterface/Views/RenderingFrameTimelineView.js:
(WebInspector.RenderingFrameTimelineView.prototype.showContentViewForTreeElement):
(WebInspector.RenderingFrameTimelineView.prototype.treeElementSelected):
Added overrides of new base class methods.

* UserInterface/Views/ResourceTimelineDataGridNode.js:
(WebInspector.ResourceTimelineDataGridNode.prototype.get data):
(WebInspector.ResourceTimelineDataGridNode.prototype.createCellContent):
Removed unused Name column and added "go to" button to the Domain column to show the selected resource.

* UserInterface/Views/ScriptTimelineView.js:
(WebInspector.ScriptTimelineView):
(WebInspector.ScriptTimelineView.prototype.showContentViewForTreeElement):
(WebInspector.ScriptTimelineView.prototype.treeElementSelected):
Added overrides of new base class methods.
(WebInspector.ScriptTimelineView.prototype._dataGridNodeSelected):
(WebInspector.ScriptTimelineView.prototype._treeElementDeselected): Deleted.
(WebInspector.ScriptTimelineView.prototype._treeElementSelected): Deleted.
(WebInspector.ScriptTimelineView.prototype._updateTreeElementWithCloseButton): Deleted.
(WebInspector.ScriptTimelineView.prototype._closeStatusButtonClicked): Deleted.
Removed tree element close button logic.

* UserInterface/Views/TimelineSidebarPanel.js:
(WebInspector.TimelineSidebarPanel.showTimelineViewForTimeline.this._timelineTreeElementMap.get select):
Prevent navigating to a different content view when showing the TimelineRecordingContentView.

* UserInterface/Views/TimelineView.js:
(WebInspector.TimelineView):
(WebInspector.TimelineView.prototype.showContentViewForTreeElement):
(WebInspector.TimelineView.prototype.treeElementDeselected):
(WebInspector.TimelineView.prototype.treeElementSelected):
Tree element selection handlers are now protected methods, which derived classes may override as needed.
(WebInspector.TimelineView.prototype.needsLayout):
(WebInspector.TimelineView.prototype._closeStatusButtonClicked):
(WebInspector.TimelineView.prototype._updateTreeElementWithCloseButton):
Encapsulated logic related to close button creation and behavior.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (183133 => 183134)


--- trunk/Source/WebInspectorUI/ChangeLog	2015-04-22 21:01:18 UTC (rev 183133)
+++ trunk/Source/WebInspectorUI/ChangeLog	2015-04-22 21:12:40 UTC (rev 183134)
@@ -1,3 +1,71 @@
+2015-04-22  Matt Baker  <[email protected]>
+
+        Web Inspector: clicking Timelines tree view nodes should not change the current content view
+        https://bugs.webkit.org/show_bug.cgi?id=132202
+
+        Reviewed by Brian Burg.
+
+        TimelineSidebarPanel now prevents timeline views from switching to another content view while the content
+        browser is showing the TimelineRecordingContentView. Code responsible for creating and updating the tree
+        element close button, which was duplicated in multiple derived TimelineView classes, has been moved to the
+        TimelineView base class.
+
+        * UserInterface/Views/LayoutTimelineView.js:
+        Updated name of location column, which was broken in a recent patch.
+        (WebInspector.LayoutTimelineView.prototype.treeElementDeselected):
+        (WebInspector.LayoutTimelineView.prototype.treeElementSelected):
+        Added overrides of new base class methods to handle view-specific highlight logic.
+        (WebInspector.LayoutTimelineView.prototype._treeElementDeselected): Deleted.
+        (WebInspector.LayoutTimelineView.prototype._treeElementSelected): Deleted.
+        (WebInspector.LayoutTimelineView.prototype._updateTreeElementWithCloseButton): Deleted.
+        (WebInspector.LayoutTimelineView.prototype._closeStatusButtonClicked): Deleted.
+        Removed tree element close button logic.
+
+        * UserInterface/Views/NetworkTimelineView.js:
+        (WebInspector.NetworkTimelineView.prototype.showContentViewForTreeElement):
+        (WebInspector.NetworkTimelineView.prototype.treeElementSelected):
+        Added overrides of new base class methods.
+        (WebInspector.NetworkTimelineView.prototype._treeElementDeselected): Deleted.
+        (WebInspector.NetworkTimelineView.prototype._treeElementSelected): Deleted.
+        Removed tree element close button logic.
+
+        * UserInterface/Views/RenderingFrameTimelineView.js:
+        (WebInspector.RenderingFrameTimelineView.prototype.showContentViewForTreeElement):
+        (WebInspector.RenderingFrameTimelineView.prototype.treeElementSelected):
+        Added overrides of new base class methods.
+
+        * UserInterface/Views/ResourceTimelineDataGridNode.js:
+        (WebInspector.ResourceTimelineDataGridNode.prototype.get data):
+        (WebInspector.ResourceTimelineDataGridNode.prototype.createCellContent):
+        Removed unused Name column and added "go to" button to the Domain column to show the selected resource.
+
+        * UserInterface/Views/ScriptTimelineView.js:
+        (WebInspector.ScriptTimelineView):
+        (WebInspector.ScriptTimelineView.prototype.showContentViewForTreeElement):
+        (WebInspector.ScriptTimelineView.prototype.treeElementSelected):
+        Added overrides of new base class methods.
+        (WebInspector.ScriptTimelineView.prototype._dataGridNodeSelected):
+        (WebInspector.ScriptTimelineView.prototype._treeElementDeselected): Deleted.
+        (WebInspector.ScriptTimelineView.prototype._treeElementSelected): Deleted.
+        (WebInspector.ScriptTimelineView.prototype._updateTreeElementWithCloseButton): Deleted.
+        (WebInspector.ScriptTimelineView.prototype._closeStatusButtonClicked): Deleted.
+        Removed tree element close button logic.
+
+        * UserInterface/Views/TimelineSidebarPanel.js:
+        (WebInspector.TimelineSidebarPanel.showTimelineViewForTimeline.this._timelineTreeElementMap.get select):
+        Prevent navigating to a different content view when showing the TimelineRecordingContentView.
+
+        * UserInterface/Views/TimelineView.js:
+        (WebInspector.TimelineView):
+        (WebInspector.TimelineView.prototype.showContentViewForTreeElement):
+        (WebInspector.TimelineView.prototype.treeElementDeselected):
+        (WebInspector.TimelineView.prototype.treeElementSelected):
+        Tree element selection handlers are now protected methods, which derived classes may override as needed.
+        (WebInspector.TimelineView.prototype.needsLayout):
+        (WebInspector.TimelineView.prototype._closeStatusButtonClicked):
+        (WebInspector.TimelineView.prototype._updateTreeElementWithCloseButton):
+        Encapsulated logic related to close button creation and behavior.
+
 2015-04-22  Timothy Hatcher  <[email protected]>
 
         Web Inspector: Remove an unused index argument from Sidebar.removeSidebarPanel

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/LayoutTimelineView.js (183133 => 183134)


--- trunk/Source/WebInspectorUI/UserInterface/Views/LayoutTimelineView.js	2015-04-22 21:01:18 UTC (rev 183133)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/LayoutTimelineView.js	2015-04-22 21:12:40 UTC (rev 183134)
@@ -29,12 +29,10 @@
 
     console.assert(timeline.type === WebInspector.TimelineRecord.Type.Layout);
 
-    this.navigationSidebarTreeOutline._onselect_ = this._treeElementSelected.bind(this);
-    this.navigationSidebarTreeOutline._ondeselect_ = this._treeElementDeselected.bind(this);
     this.navigationSidebarTreeOutline.element.classList.add(WebInspector.NavigationSidebarPanel.HideDisclosureButtonsStyleClassName);
     this.navigationSidebarTreeOutline.element.classList.add(WebInspector.LayoutTimelineView.TreeOutlineStyleClassName);
 
-    var columns = {eventType: {}, initiatorCallFrame: {}, width: {}, height: {}, startTime: {}, totalTime: {}};
+    var columns = {eventType: {}, location: {}, width: {}, height: {}, startTime: {}, totalTime: {}};
 
     columns.eventType.title = WebInspector.UIString("Type");
     columns.eventType.width = "15%";
@@ -48,8 +46,8 @@
     columns.eventType.scopeBar = WebInspector.TimelineDataGrid.createColumnScopeBar("layout", typeToLabelMap);
     columns.eventType.hidden = true;
 
-    columns.initiatorCallFrame.title = WebInspector.UIString("Initiator");
-    columns.initiatorCallFrame.width = "25%";
+    columns.location.title = WebInspector.UIString("Initiator");
+    columns.location.width = "25%";
 
     columns.width.title = WebInspector.UIString("Width");
     columns.width.width = "8%";
@@ -165,6 +163,23 @@
         dataGridNode.revealAndSelect();
     },
 
+    treeElementDeselected: function(treeElement)
+    {
+        WebInspector.TimelineView.prototype.treeElementDeselected.call(this, treeElement);
+
+        this._updateHighlight();
+    },
+
+    treeElementSelected: function(treeElement, selectedByUser)
+    {
+        if (this._dataGrid.shouldIgnoreSelectionEvent())
+            return;
+
+        WebInspector.TimelineView.prototype.treeElementSelected.call(this, treeElement, selectedByUser);
+
+        this._updateHighlight();
+    },
+
     // Private
 
     _processPendingRecords: function()
@@ -202,62 +217,6 @@
         this.dispatchEventToListeners(WebInspector.ContentView.Event.SelectionPathComponentsDidChange);
     },
 
-    _treeElementDeselected: function(treeElement)
-    {
-        if (treeElement.status)
-            treeElement.status = "";
-
-        this._updateHighlight();
-    },
-
-    _treeElementSelected: function(treeElement, selectedByUser)
-    {
-        if (this._dataGrid.shouldIgnoreSelectionEvent())
-            return;
-
-        if (!WebInspector.timelineSidebarPanel.canShowDifferentContentView())
-            return;
-
-        if (treeElement instanceof WebInspector.FolderTreeElement)
-            return;
-
-        if (!(treeElement instanceof WebInspector.TimelineRecordTreeElement)) {
-            console.error("Unknown tree element selected.");
-            return;
-        }
-
-        this._updateHighlight();
-
-        if (!treeElement.record.sourceCodeLocation) {
-            WebInspector.timelineSidebarPanel.showTimelineViewForTimeline(this.representedObject);
-            return;
-        }
-
-        WebInspector.resourceSidebarPanel.showOriginalOrFormattedSourceCodeLocation(treeElement.record.sourceCodeLocation);
-        this._updateTreeElementWithCloseButton(treeElement);
-    },
-
-    _updateTreeElementWithCloseButton: function(treeElement)
-    {
-        if (this._closeStatusButton) {
-            treeElement.status = this._closeStatusButton.element;
-            return;
-        }
-
-        wrappedSVGDocument(platformImagePath("Close.svg"), null, WebInspector.UIString("Close resource view"), function(element) {
-            this._closeStatusButton = new WebInspector.TreeElementStatusButton(element);
-            this._closeStatusButton.addEventListener(WebInspector.TreeElementStatusButton.Event.Clicked, this._closeStatusButtonClicked, this);
-            if (treeElement === this.navigationSidebarTreeOutline.selectedTreeElement)
-                this._updateTreeElementWithCloseButton(treeElement);
-        }.bind(this));
-    },
-
-    _closeStatusButtonClicked: function(event)
-    {
-        this.navigationSidebarTreeOutline.selectedTreeElement.deselect();
-        WebInspector.timelineSidebarPanel.showTimelineViewForTimeline(this.representedObject);
-    },
-
     _updateHighlight: function()
     {
         var record = this._hoveredOrSelectedRecord();

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTimelineView.js (183133 => 183134)


--- trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTimelineView.js	2015-04-22 21:01:18 UTC (rev 183133)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTimelineView.js	2015-04-22 21:12:40 UTC (rev 183134)
@@ -29,8 +29,6 @@
 
     console.assert(timeline.type === WebInspector.TimelineRecord.Type.Network);
 
-    this.navigationSidebarTreeOutline._onselect_ = this._treeElementSelected.bind(this);
-    this.navigationSidebarTreeOutline._ondeselect_ = this._treeElementDeselected.bind(this);    
     this.navigationSidebarTreeOutline.element.classList.add(WebInspector.NavigationSidebarPanel.HideDisclosureButtonsStyleClassName);
     this.navigationSidebarTreeOutline.element.classList.add(WebInspector.NetworkTimelineView.TreeOutlineStyleClassName);
 
@@ -150,6 +148,17 @@
 
     // Protected
 
+    showContentViewForTreeElement: function(treeElement)
+    {
+        if (treeElement instanceof WebInspector.ResourceTreeElement || treeElement instanceof WebInspector.ScriptTreeElement) {
+            WebInspector.resourceSidebarPanel.showSourceCode(treeElement.representedObject);
+            return true;
+        }
+
+        console.error("Unknown tree element selected.", treeElement);
+        return false;
+    },
+
     treeElementPathComponentSelected: function(event)
     {
         var dataGridNode = this._dataGrid.dataGridNodeForTreeElement(event.data.pathComponent.generalTreeElement);
@@ -158,6 +167,14 @@
         dataGridNode.revealAndSelect();
     },
 
+    treeElementSelected: function(treeElement, selectedByUser)
+    {
+        if (this._dataGrid.shouldIgnoreSelectionEvent())
+            return false;
+
+        WebInspector.TimelineView.prototype.treeElementSelected.call(this, treeElement, selectedByUser);
+    },
+
     // Private
 
     _processPendingRecords: function()
@@ -200,32 +217,6 @@
         this.dispatchEventToListeners(WebInspector.ContentView.Event.SelectionPathComponentsDidChange);
     },
 
-    _treeElementDeselected: function(treeElement)
-    {
-        if (treeElement.status)
-            treeElement.status = "";
-    },
-
-    _treeElementSelected: function(treeElement, selectedByUser)
-    {
-        if (this._dataGrid.shouldIgnoreSelectionEvent())
-            return;
-
-        if (!WebInspector.timelineSidebarPanel.canShowDifferentContentView())
-            return;
-
-        if (treeElement instanceof WebInspector.FolderTreeElement)
-            return;
-
-        if (treeElement instanceof WebInspector.ResourceTreeElement || treeElement instanceof WebInspector.ScriptTreeElement) {
-            WebInspector.resourceSidebarPanel.showSourceCode(treeElement.representedObject);
-            this._updateTreeElementWithCloseButton(treeElement);
-            return;
-        }
-
-        console.error("Unknown tree element selected.");
-    },
-
     _updateTreeElementWithCloseButton: function(treeElement)
     {
         if (this._closeStatusButton) {

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/RenderingFrameTimelineView.js (183133 => 183134)


--- trunk/Source/WebInspectorUI/UserInterface/Views/RenderingFrameTimelineView.js	2015-04-22 21:01:18 UTC (rev 183133)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/RenderingFrameTimelineView.js	2015-04-22 21:12:40 UTC (rev 183134)
@@ -154,6 +154,24 @@
 
     // Protected
 
+    showContentViewForTreeElement: function(treeElement)
+    {
+        if (treeElement instanceof WebInspector.ProfileNodeTreeElement && treeElement.profileNode.sourceCodeLocation) {
+            WebInspector.resourceSidebarPanel.showOriginalOrFormattedSourceCodeLocation(treeElement.profileNode.sourceCodeLocation);
+            return true;
+        }
+
+        return WebInspector.TimelineView.prototype.showContentViewForTreeElement.call(this, treeElement);
+    },
+
+    treeElementSelected: function(treeElement, selectedByUser)
+    {
+        if (this._dataGrid.shouldIgnoreSelectionEvent())
+            return;
+
+        WebInspector.TimelineView.prototype.treeElementSelected.call(this, treeElement, selectedByUser);
+    },
+
     treeElementPathComponentSelected: function(event)
     {
         var dataGridNode = this._dataGrid.dataGridNodeForTreeElement(event.data.pathComponent.generalTreeElement);

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ResourceTimelineDataGridNode.js (183133 => 183134)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ResourceTimelineDataGridNode.js	2015-04-22 21:01:18 UTC (rev 183133)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ResourceTimelineDataGridNode.js	2015-04-22 21:12:40 UTC (rev 183134)
@@ -75,7 +75,6 @@
         if (!this._graphOnly) {
             var zeroTime = this.graphDataSource ? this.graphDataSource.zeroTime : 0;
 
-            data.name = WebInspector.displayNameForURL(resource.url, resource.urlComponents);
             data.domain = WebInspector.displayNameForHost(resource.urlComponents.host);
             data.scheme = resource.urlComponents.scheme ? resource.urlComponents.scheme.toUpperCase() : "";
             data.method = resource.requestMethod;
@@ -106,26 +105,6 @@
         var value = this.data[columnIdentifier];
 
         switch (columnIdentifier) {
-        case "name":
-            cell.classList.add(resource.type, WebInspector.ResourceTreeElement.ResourceIconStyleClassName);
-
-            var fragment = document.createDocumentFragment();
-
-            var goToButton = WebInspector.createGoToArrowButton();
-            goToButton.addEventListener("click", this._goToResource.bind(this));
-            fragment.appendChild(goToButton);
-
-            var icon = document.createElement("div");
-            icon.className = WebInspector.ResourceTimelineDataGridNode.IconStyleClassName;
-            fragment.appendChild(icon);
-
-            var text = document.createTextNode(value);
-            fragment.appendChild(text);
-
-            cell.title = resource.url;
-
-            return fragment;
-
         case "type":
             return WebInspector.Resource.displayNameForType(value);
 
@@ -137,8 +116,17 @@
             return value ? WebInspector.UIString("Yes") : WebInspector.UIString("No");
 
         case "domain":
-            return value || emptyValuePlaceholderString;
+            var fragment = document.createDocumentFragment();
 
+            var goToButton = WebInspector.createGoToArrowButton();
+            goToButton.addEventListener("click", this._goToResource.bind(this));
+            fragment.appendChild(goToButton);
+
+            var text = document.createTextNode(value || emptyValuePlaceholderString);
+            fragment.appendChild(text);
+
+            return fragment;
+
         case "size":
         case "transferSize":
             return isNaN(value) ? emptyValuePlaceholderString : Number.bytesToString(value, true);

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ScriptTimelineView.js (183133 => 183134)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ScriptTimelineView.js	2015-04-22 21:01:18 UTC (rev 183133)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ScriptTimelineView.js	2015-04-22 21:12:40 UTC (rev 183134)
@@ -29,8 +29,6 @@
 
     console.assert(timeline.type === WebInspector.TimelineRecord.Type.Script);
 
-    this.navigationSidebarTreeOutline._onselect_ = this._treeElementSelected.bind(this);
-    this.navigationSidebarTreeOutline._ondeselect_ = this._treeElementDeselected.bind(this);
     this.navigationSidebarTreeOutline.element.classList.add(WebInspector.ScriptTimelineView.TreeOutlineStyleClassName);
 
     var columns = {location: {}, callCount: {}, startTime: {}, totalTime: {}, selfTime: {}, averageTime: {}};
@@ -165,6 +163,16 @@
 
     // Protected
 
+    showContentViewForTreeElement: function(treeElement)
+    {
+        if (treeElement instanceof WebInspector.ProfileNodeTreeElement && treeElement.profileNode.sourceCodeLocation) {
+            WebInspector.resourceSidebarPanel.showOriginalOrFormattedSourceCodeLocation(treeElement.profileNode.sourceCodeLocation);
+            return true;
+        }
+
+        return WebInspector.TimelineView.prototype.showContentViewForTreeElement.call(this, treeElement);
+    },
+
     treeElementPathComponentSelected: function(event)
     {
         var dataGridNode = this._dataGrid.dataGridNodeForTreeElement(event.data.pathComponent.generalTreeElement);
@@ -173,6 +181,14 @@
         dataGridNode.revealAndSelect();
     },
 
+    treeElementSelected: function(treeElement, selectedByUser)
+    {
+        if (this._dataGrid.shouldIgnoreSelectionEvent())
+            return false;
+
+        WebInspector.TimelineView.prototype.treeElementSelected.call(this, treeElement, selectedByUser);
+    },
+
     dataGridNodeForTreeElement: function(treeElement)
     {
         if (treeElement instanceof WebInspector.ProfileNodeTreeElement)
@@ -244,60 +260,5 @@
     _dataGridNodeSelected: function(event)
     {
         this.dispatchEventToListeners(WebInspector.ContentView.Event.SelectionPathComponentsDidChange);
-    },
-
-    _treeElementDeselected: function(treeElement)
-    {
-        if (treeElement.status)
-            treeElement.status = "";
-    },
-
-    _treeElementSelected: function(treeElement, selectedByUser)
-    {
-        if (this._dataGrid.shouldIgnoreSelectionEvent())
-            return;
-
-        if (!WebInspector.timelineSidebarPanel.canShowDifferentContentView())
-            return;
-
-        if (treeElement instanceof WebInspector.FolderTreeElement)
-            return;
-
-        var sourceCodeLocation = null;
-        if (treeElement instanceof WebInspector.TimelineRecordTreeElement)
-            sourceCodeLocation = treeElement.record.sourceCodeLocation;
-        else if (treeElement instanceof WebInspector.ProfileNodeTreeElement)
-            sourceCodeLocation = treeElement.profileNode.sourceCodeLocation;
-        else
-            console.error("Unknown tree element selected.");
-
-        if (!sourceCodeLocation) {
-            WebInspector.timelineSidebarPanel.showTimelineViewForTimeline(this.representedObject);
-            return;
-        }
-
-        WebInspector.resourceSidebarPanel.showOriginalOrFormattedSourceCodeLocation(sourceCodeLocation);
-        this._updateTreeElementWithCloseButton(treeElement);
-    },
-
-    _updateTreeElementWithCloseButton: function(treeElement)
-    {
-        if (this._closeStatusButton) {
-            treeElement.status = this._closeStatusButton.element;
-            return;
-        }
-
-        wrappedSVGDocument(platformImagePath("Close.svg"), null, WebInspector.UIString("Close resource view"), function(element) {
-            this._closeStatusButton = new WebInspector.TreeElementStatusButton(element);
-            this._closeStatusButton.addEventListener(WebInspector.TreeElementStatusButton.Event.Clicked, this._closeStatusButtonClicked, this);
-            if (treeElement === this.navigationSidebarTreeOutline.selectedTreeElement)
-                this._updateTreeElementWithCloseButton(treeElement);
-        }.bind(this));
-    },
-
-    _closeStatusButtonClicked: function(event)
-    {
-        this.navigationSidebarTreeOutline.selectedTreeElement.deselect();
-        WebInspector.timelineSidebarPanel.showTimelineViewForTimeline(this.representedObject);
     }
 };

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineSidebarPanel.js (183133 => 183134)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineSidebarPanel.js	2015-04-22 21:01:18 UTC (rev 183133)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineSidebarPanel.js	2015-04-22 21:12:40 UTC (rev 183134)
@@ -274,6 +274,9 @@
 
     canShowDifferentContentView()
     {
+        if (WebInspector.contentBrowser.currentContentView instanceof WebInspector.TimelineRecordingContentView)
+            return false;
+
         return !this.restoringState || !this._restoredShowingTimelineRecordingContentView;
     }
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineView.js (183133 => 183134)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineView.js	2015-04-22 21:01:18 UTC (rev 183133)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineView.js	2015-04-22 21:12:40 UTC (rev 183134)
@@ -32,6 +32,9 @@
     WebInspector.ContentView.call(this, representedObject);
 
     this._contentTreeOutline = WebInspector.timelineSidebarPanel.createContentTreeOutline();
+    this._contentTreeOutline._onselect_ = this.treeElementSelected.bind(this);
+    this._contentTreeOutline._ondeselect_ = this.treeElementDeselected.bind(this);
+
     this.element.classList.add(WebInspector.TimelineView.StyleClassName);
 
     this._zeroTime = 0;
@@ -180,11 +183,54 @@
 
     // Protected
 
+    showContentViewForTreeElement: function(treeElement)
+    {
+        // Implemented by sub-classes if needed.
+
+        if (!(treeElement instanceof WebInspector.TimelineRecordTreeElement)) {
+            console.error("Unknown tree element selected.", treeElement);
+            return false;
+        }
+
+        var sourceCodeLocation = treeElement.record.sourceCodeLocation;
+        if (!sourceCodeLocation) {
+            WebInspector.timelineSidebarPanel.showTimelineViewForTimeline(this.representedObject);
+            return true;
+        }
+
+        WebInspector.resourceSidebarPanel.showOriginalOrFormattedSourceCodeLocation(sourceCodeLocation);
+        return true;
+    },
+
     treeElementPathComponentSelected: function(event)
     {
         // Implemented by sub-classes if needed.
     },
 
+    treeElementDeselected: function(treeElement)
+    {
+        // Implemented by sub-classes if needed.
+
+        if (this._closeStatusButton && treeElement.status === this._closeStatusButton.element)
+            treeElement.status = "";
+    },
+
+    treeElementSelected: function(treeElement, selectedByUser)
+    {
+        // Implemented by sub-classes if needed.
+
+        if (!WebInspector.timelineSidebarPanel.canShowDifferentContentView())
+            return;
+
+        if (treeElement instanceof WebInspector.FolderTreeElement)
+            return;
+
+        if (!this.showContentViewForTreeElement(treeElement))
+            return;
+
+        this._updateTreeElementWithCloseButton(treeElement);
+    },
+
     needsLayout: function()
     {
         if (!this.visible)
@@ -194,5 +240,30 @@
             return;
 
         this._scheduledLayoutUpdateIdentifier = requestAnimationFrame(this.updateLayout.bind(this));
+    },
+
+    // Private
+
+    _closeStatusButtonClicked: function(event)
+    {
+        if (this.navigationSidebarTreeOutline.selectedTreeElement)
+            this.navigationSidebarTreeOutline.selectedTreeElement.deselect();
+
+        WebInspector.timelineSidebarPanel.showTimelineViewForTimeline(this.representedObject);
+    },
+
+    _updateTreeElementWithCloseButton: function(treeElement)
+    {
+        if (this._closeStatusButton) {
+            treeElement.status = this._closeStatusButton.element;
+            return;
+        }
+
+        wrappedSVGDocument(platformImagePath("Close.svg"), null, WebInspector.UIString("Close resource view"), function(element) {
+            this._closeStatusButton = new WebInspector.TreeElementStatusButton(element);
+            this._closeStatusButton.addEventListener(WebInspector.TreeElementStatusButton.Event.Clicked, this._closeStatusButtonClicked, this);
+            if (treeElement === this.navigationSidebarTreeOutline.selectedTreeElement)
+                this._updateTreeElementWithCloseButton(treeElement);
+        }.bind(this));
     }
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to