Title: [241302] trunk/Source/WebInspectorUI
Revision
241302
Author
[email protected]
Date
2019-02-12 10:22:40 -0800 (Tue, 12 Feb 2019)

Log Message

Web Inspector: Timelines: clicking on an empty space in the overview should deselect any selected record bar
https://bugs.webkit.org/show_bug.cgi?id=194365
<rdar://problem/47868426>

Reviewed by Joseph Pecoraro.

* UserInterface/Views/TimelineRecordBar.js:
(WI.TimelineRecordBar.prototype._handleClick):
Mark the "click" event so that later listeners know it was handled by `WI.TimelineRecordBar`.

* UserInterface/Views/TimelineOverview.js:
(WI.TimelineOverview):
(WI.TimelineOverview.prototype._instrumentAdded):
(WI.TimelineOverview.prototype._instrumentRemoved):
(WI.TimelineOverview.prototype._handleGraphsContainerClick): Added.
(WI.TimelineOverview.prototype._handleOverviewGraphRecordSelected): Added.
(WI.TimelineOverview.prototype._recordSelected):
Listen for "click" on the graph container and deselect all records when fired, unless the
click was marked by a `WI.TimelineRecordBar`.

* UserInterface/Views/TimelineRecordingContentView.js:
(WI.TimelineRecordingContentView.prototype._recordSelected):
Ensure that all `WI.TimelineView` update their selected record whenever it changes for any
other `WI.TimelineView` (or if there is no selected record).

* UserInterface/Views/TimelineOverviewGraph.js:
(WI.TimelineOverviewGraph.prototype.didLayoutSubtree): Added.
Drive-by: since `WI.TimelineRecordBar` are reused when combining, we need to re-determine
which one holds the currently selected record.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (241301 => 241302)


--- trunk/Source/WebInspectorUI/ChangeLog	2019-02-12 18:21:58 UTC (rev 241301)
+++ trunk/Source/WebInspectorUI/ChangeLog	2019-02-12 18:22:40 UTC (rev 241302)
@@ -1,3 +1,35 @@
+2019-02-12  Devin Rousso  <[email protected]>
+
+        Web Inspector: Timelines: clicking on an empty space in the overview should deselect any selected record bar
+        https://bugs.webkit.org/show_bug.cgi?id=194365
+        <rdar://problem/47868426>
+
+        Reviewed by Joseph Pecoraro.
+
+        * UserInterface/Views/TimelineRecordBar.js:
+        (WI.TimelineRecordBar.prototype._handleClick):
+        Mark the "click" event so that later listeners know it was handled by `WI.TimelineRecordBar`.
+
+        * UserInterface/Views/TimelineOverview.js:
+        (WI.TimelineOverview):
+        (WI.TimelineOverview.prototype._instrumentAdded):
+        (WI.TimelineOverview.prototype._instrumentRemoved):
+        (WI.TimelineOverview.prototype._handleGraphsContainerClick): Added.
+        (WI.TimelineOverview.prototype._handleOverviewGraphRecordSelected): Added.
+        (WI.TimelineOverview.prototype._recordSelected):
+        Listen for "click" on the graph container and deselect all records when fired, unless the
+        click was marked by a `WI.TimelineRecordBar`.
+
+        * UserInterface/Views/TimelineRecordingContentView.js:
+        (WI.TimelineRecordingContentView.prototype._recordSelected):
+        Ensure that all `WI.TimelineView` update their selected record whenever it changes for any
+        other `WI.TimelineView` (or if there is no selected record).
+
+        * UserInterface/Views/TimelineOverviewGraph.js:
+        (WI.TimelineOverviewGraph.prototype.didLayoutSubtree): Added.
+        Drive-by: since `WI.TimelineRecordBar` are reused when combining, we need to re-determine
+        which one holds the currently selected record.
+
 2019-02-12  Joseph Pecoraro  <[email protected]>
 
         Web Inspector: Remove unused maxUsage in CPUTimelineView

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineOverview.js (241301 => 241302)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineOverview.js	2019-02-12 18:21:58 UTC (rev 241301)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineOverview.js	2019-02-12 18:22:40 UTC (rev 241302)
@@ -53,6 +53,7 @@
 
         this._graphsContainerView = new WI.View;
         this._graphsContainerView.element.classList.add("graphs-container");
+        this._graphsContainerView.element.addEventListener("click", this._handleGraphsContainerClick.bind(this));
         this.addSubview(this._graphsContainerView);
 
         this._selectedTimelineRecord = null;
@@ -636,7 +637,7 @@
         this._treeElementsByTypeMap.set(timeline.type, treeElement);
 
         let overviewGraph = WI.TimelineOverviewGraph.createForTimeline(timeline, this);
-        overviewGraph.addEventListener(WI.TimelineOverviewGraph.Event.RecordSelected, this._recordSelected, this);
+        overviewGraph.addEventListener(WI.TimelineOverviewGraph.Event.RecordSelected, this._handleOverviewGraphRecordSelected, this);
         this._overviewGraphsByTypeMap.set(timeline.type, overviewGraph);
         this._graphsContainerView.insertSubviewBefore(overviewGraph, this._graphsContainerView.subviews[insertionIndex]);
 
@@ -662,7 +663,7 @@
         let shouldSuppressSelectSibling = true;
         this._timelinesTreeOutline.removeChild(treeElement, shouldSuppressOnDeselect, shouldSuppressSelectSibling);
 
-        overviewGraph.removeEventListener(WI.TimelineOverviewGraph.Event.RecordSelected, this._recordSelected, this);
+        overviewGraph.removeEventListener(WI.TimelineOverviewGraph.Event.RecordSelected, this._handleOverviewGraphRecordSelected, this);
         this._graphsContainerView.removeSubview(overviewGraph);
 
         this._overviewGraphsByTypeMap.delete(timeline.type);
@@ -674,6 +675,15 @@
         this._timelineRuler.addMarker(event.data.marker);
     }
 
+    _handleGraphsContainerClick(event)
+    {
+        // Set when a WI.TimelineRecordBar receives the "click" first and is about to be selected.
+        if (event.__timelineRecordBarClick)
+            return;
+
+        this._recordSelected(null, null);
+    }
+
     _timelineRulerMouseDown(event)
     {
         this._timelineRulerSelectionChanged = false;
@@ -710,13 +720,23 @@
         this.dispatchEventToListeners(WI.TimelineOverview.Event.TimeRangeSelectionChanged);
     }
 
-    _recordSelected(event)
+    _handleOverviewGraphRecordSelected(event)
     {
         let {record, recordBar} = event.data;
-        if (!record || record === this._selectedTimelineRecord)
+
+        // Ignore deselection events, as they are handled by the newly selected record's timeline.
+        if (!record)
             return;
 
-        if (this._selectedTimelineRecord && this._selectedTimelineRecord.type !== record.type) {
+        this._recordSelected(record, recordBar);
+    }
+
+    _recordSelected(record, recordBar)
+    {
+        if (record === this._selectedTimelineRecord)
+            return;
+
+        if (this._selectedTimelineRecord && (!record || this._selectedTimelineRecord.type !== record.type)) {
             let timelineOverviewGraph = this._overviewGraphsByTypeMap.get(this._selectedTimelineRecord.type);
             console.assert(timelineOverviewGraph);
             if (timelineOverviewGraph)
@@ -734,7 +754,7 @@
             }
 
             let startTime = firstRecord instanceof WI.RenderingFrameTimelineRecord ? firstRecord.frameIndex : firstRecord.startTime;
-            let endTime = lastRecord instanceof WI.RenderingFrameTimelineRecord ? lastRecord.frameIndex : lastRecord.startTime;
+            let endTime = lastRecord instanceof WI.RenderingFrameTimelineRecord ? lastRecord.frameIndex : lastRecord.endTime;
 
             if (startTime < this.selectionStartTime || endTime > this.selectionStartTime + this.selectionDuration) {
                 let selectionPadding = this.secondsPerPixel * 10;
@@ -743,15 +763,7 @@
             }
         }
 
-        for (let [type, overviewGraph] of this._overviewGraphsByTypeMap) {
-            if (overviewGraph !== event.target)
-                continue;
-
-            let timeline = this._recording.timelines.get(type);
-            console.assert(timeline, "Timeline recording missing timeline type", type);
-            this.dispatchEventToListeners(WI.TimelineOverview.Event.RecordSelected, {timeline, record: this._selectedTimelineRecord});
-            return;
-        }
+        this.dispatchEventToListeners(WI.TimelineOverview.Event.RecordSelected, {record: this._selectedTimelineRecord});
     }
 
     _resetSelection()

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineOverviewGraph.js (241301 => 241302)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineOverviewGraph.js	2019-02-12 18:21:58 UTC (rev 241301)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineOverviewGraph.js	2019-02-12 18:22:40 UTC (rev 241302)
@@ -253,6 +253,13 @@
         super.needsLayout();
     }
 
+    didLayoutSubtree()
+    {
+        super.didLayoutSubtree();
+
+        this.updateSelectedRecord();
+    }
+
     // TimelineRecordBar delegate
 
     timelineRecordBarClicked(timelineRecordBar)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordBar.js (241301 => 241302)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordBar.js	2019-02-12 18:21:58 UTC (rev 241301)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordBar.js	2019-02-12 18:22:40 UTC (rev 241302)
@@ -388,6 +388,9 @@
 
     _handleClick(event)
     {
+        // Ensure that the container "click" listener added by `WI.TimelineOverview` isn't called.
+        event.__timelineRecordBarClick = true;
+
         if (this._delegate.timelineRecordBarClicked)
             this._delegate.timelineRecordBarClicked(this);
     }

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js (241301 => 241302)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js	2019-02-12 18:21:58 UTC (rev 241301)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js	2019-02-12 18:22:40 UTC (rev 241302)
@@ -697,13 +697,17 @@
 
     _recordSelected(event)
     {
-        let {record, timeline} = event.data;
-        let timelineView = this._timelineViewMap.get(timeline);
+        let {record} = event.data;
 
-        if (record && timelineView !== this.currentTimelineView)
-            this.showTimelineViewForTimeline(timeline);
+        for (let timelineView of this._timelineViewMap.values()) {
+            let recordMatchesTimeline = record && timelineView.representedObject.type === record.type;
 
-        timelineView.selectRecord(record);
+            if (recordMatchesTimeline && timelineView !== this.currentTimelineView)
+                this.showTimelineViewForTimeline(timelineView.representedObject);
+
+            if (!record || recordMatchesTimeline)
+                timelineView.selectRecord(record);
+        }
     }
 
     _timelineSelected()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to