Title: [199972] trunk/Source/WebInspectorUI
Revision
199972
Author
mattba...@apple.com
Date
2016-04-24 18:03:22 -0700 (Sun, 24 Apr 2016)

Log Message

Web Inspector: Error when selecting a bar in the Frames timeline
https://bugs.webkit.org/show_bug.cgi?id=156960
<rdar://problem/25897955>

Reviewed by Timothy Hatcher.

Fixes timeline grid node selection when record selected in the overview.
Adds general purpose `findNode` method to DataGrid.

* UserInterface/Views/DataGrid.js:
(WebInspector.DataGrid.prototype.findNode):
Basic find function for locating a grid node in linear time.

* UserInterface/Views/TimelineRecordingContentView.js:
(WebInspector.TimelineRecordingContentView.prototype._recordSelected):
Remove tree outline references, call generic select method.

* UserInterface/Views/TimelineView.js:
(WebInspector.TimelineView.prototype.selectRecord):
If a data grid was set, deselect current selection and select the node
associated with the timeline record.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (199971 => 199972)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-04-25 00:59:48 UTC (rev 199971)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-04-25 01:03:22 UTC (rev 199972)
@@ -1,5 +1,29 @@
 2016-04-24  Matt Baker  <mattba...@apple.com>
 
+        Web Inspector: Error when selecting a bar in the Frames timeline
+        https://bugs.webkit.org/show_bug.cgi?id=156960
+        <rdar://problem/25897955>
+
+        Reviewed by Timothy Hatcher.
+
+        Fixes timeline grid node selection when record selected in the overview.
+        Adds general purpose `findNode` method to DataGrid.
+
+        * UserInterface/Views/DataGrid.js:
+        (WebInspector.DataGrid.prototype.findNode):
+        Basic find function for locating a grid node in linear time.
+
+        * UserInterface/Views/TimelineRecordingContentView.js:
+        (WebInspector.TimelineRecordingContentView.prototype._recordSelected):
+        Remove tree outline references, call generic select method.
+
+        * UserInterface/Views/TimelineView.js:
+        (WebInspector.TimelineView.prototype.selectRecord):
+        If a data grid was set, deselect current selection and select the node
+        associated with the timeline record.
+
+2016-04-24  Matt Baker  <mattba...@apple.com>
+
         Web Inspector: Events in _javascript_ & Events timeline have no profile children
         https://bugs.webkit.org/show_bug.cgi?id=156627
         <rdar://problem/25749740>

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js (199971 => 199972)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js	2016-04-25 00:59:48 UTC (rev 199971)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js	2016-04-25 01:03:22 UTC (rev 199972)
@@ -1042,6 +1042,23 @@
         this.children = [];
     }
 
+    findNode(comparator, skipHidden, stayWithin, dontPopulate)
+    {
+        console.assert(typeof comparator === "function");
+
+        let currentNode = this._rows[0];
+        while (currentNode && !currentNode.root) {
+            if (!currentNode.isPlaceholderNode && !(skipHidden && currentNode.hidden)) {
+                if (comparator(currentNode))
+                    return currentNode;
+            }
+
+            currentNode = currentNode.traverseNextNode(skipHidden, stayWithin, dontPopulate);
+        }
+
+        return null;
+    }
+
     sortNodes(comparator)
     {
         if (this._sortNodesRequestId)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js (199971 => 199972)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js	2016-04-25 00:59:48 UTC (rev 199971)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js	2016-04-25 01:03:22 UTC (rev 199972)
@@ -715,28 +715,12 @@
 
     _recordSelected(event)
     {
-        var timelineView = this._timelineViewMap.get(event.data.timeline);
+        let timelineView = this._timelineViewMap.get(event.data.timeline);
         console.assert(timelineView === this.currentTimelineView, timelineView);
         if (timelineView !== this.currentTimelineView)
             return;
 
-        var selectedTreeElement = this.currentTimelineView.navigationSidebarTreeOutline.selectedTreeElement;
-        if (!event.data.record) {
-            if (selectedTreeElement)
-                selectedTreeElement.deselect();
-            return;
-        }
-
-        var treeElement = this.currentTimelineView.navigationSidebarTreeOutline.findTreeElement(event.data.record);
-        console.assert(treeElement, "Timeline view has no tree element for record selected in timeline overview.", timelineView, event.data.record);
-        if (!treeElement || treeElement.selected)
-            return;
-
-        // Don't select the record's tree element if one of it's children is already selected.
-        if (selectedTreeElement && selectedTreeElement.hasAncestor(treeElement))
-            return;
-
-        treeElement.revealAndSelect(false, false, false, true);
+        timelineView.selectRecord(event.data.record);
     }
 
     _timelineSelected()

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineView.js (199971 => 199972)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineView.js	2016-04-25 00:59:48 UTC (rev 199971)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineView.js	2016-04-25 01:03:22 UTC (rev 199972)
@@ -142,6 +142,30 @@
         // Implemented by sub-classes if needed.
     }
 
+    selectRecord(record)
+    {
+        if (!this._timelineDataGrid)
+            return;
+
+        let selectedDataGridNode = this._timelineDataGrid.selectedNode;
+        if (!record) {
+            if (selectedDataGridNode)
+                selectedDataGridNode.deselect();
+            return;
+        }
+
+        let dataGridNode = this._timelineDataGrid.findNode((node) => node.record === record);
+        console.assert(dataGridNode, "Timeline view has no grid node for record selected in timeline overview.", this, record);
+        if (!dataGridNode || dataGridNode.selected)
+            return;
+
+        // Don't select the record's grid node if one of it's children is already selected.
+        if (selectedDataGridNode && selectedDataGridNode.hasAncestor(dataGridNode))
+            return;
+
+        dataGridNode.revealAndSelect();
+    }
+
     matchTreeElementAgainstCustomFilters(treeElement)
     {
         // Implemented by sub-classes if needed.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to