Commit 54fd0626 authored by Zeynep Cankara's avatar Zeynep Cankara Committed by Commit Bot

[tools][system-analyzer] Sync Timeline Track Scrolling

This CL sync the timeline-tracks positions
upon receiving a horizontal scrolling event.

Bug: v8:10644

Change-Id: I69bc1066a3f5da6ddc978ad71fe77820df8066bd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2336806
Commit-Queue: Zeynep Cankara <zcankara@google.com>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69263}
parent febd37b1
...@@ -10,9 +10,11 @@ defineCustomElement('timeline-panel', (templateText) => ...@@ -10,9 +10,11 @@ defineCustomElement('timeline-panel', (templateText) =>
constructor() { constructor() {
super(templateText); super(templateText);
this.timelineOverview.addEventListener( this.timelineOverview.addEventListener(
'mousemove', e => this.handleTimelineIndicatorMove(e)); 'mousemove', e => this.handleTimelineIndicatorMove(e));
this.addEventListener( this.addEventListener(
'overviewupdate', e => this.handleOverviewBackgroundUpdate(e)); 'overviewupdate', e => this.handleOverviewBackgroundUpdate(e));
this.addEventListener(
'scrolltrack', e => this.handleTrackScroll(e));
this.backgroundCanvas = document.createElement('canvas'); this.backgroundCanvas = document.createElement('canvas');
this.isLocked = false; this.isLocked = false;
} }
...@@ -44,13 +46,18 @@ defineCustomElement('timeline-panel', (templateText) => ...@@ -44,13 +46,18 @@ defineCustomElement('timeline-panel', (templateText) =>
return this.$("slot").assignedNodes().filter( return this.$("slot").assignedNodes().filter(
track => track.nodeType === Node.ELEMENT_NODE); track => track.nodeType === Node.ELEMENT_NODE);
} }
handleTrackScroll(event){
//TODO(zcankara) add forEachTrack helper method
for (const track of this.timelineTracks) {
track.scrollLeft = event.detail;
}
}
handleTimelineIndicatorMove(event) { handleTimelineIndicatorMove(event) {
if (event.buttons == 0) return; if (event.buttons == 0) return;
let timelineTotalWidth = this.timelineCanvas.offsetWidth; let timelineTotalWidth = this.timelineCanvas.offsetWidth;
let factor = this.timelineOverview.offsetWidth / timelineTotalWidth; let factor = this.timelineOverview.offsetWidth / timelineTotalWidth;
for (const track of this.timelineTracks) { for (const track of this.timelineTracks) {
track.handleTimelineIndicatorMove(event.movementX / factor); track.timelineIndicatorMove(event.movementX / factor);
} }
} }
......
...@@ -14,6 +14,8 @@ defineCustomElement('./timeline/timeline-track', (templateText) => ...@@ -14,6 +14,8 @@ defineCustomElement('./timeline/timeline-track', (templateText) =>
#selectedEntry; #selectedEntry;
constructor() { constructor() {
super(templateText); super(templateText);
this.timeline.addEventListener("scroll",
e => this.handleTimelineScroll(e));
this.backgroundCanvas = document.createElement('canvas'); this.backgroundCanvas = document.createElement('canvas');
this.isLocked = false; this.isLocked = false;
} }
...@@ -67,6 +69,10 @@ defineCustomElement('./timeline/timeline-track', (templateText) => ...@@ -67,6 +69,10 @@ defineCustomElement('./timeline/timeline-track', (templateText) =>
return this.#selectedEntry; return this.#selectedEntry;
} }
set scrollLeft(offset){
this.timeline.scrollLeft = offset;
}
updateStats(){ updateStats(){
let unique = new Map(); let unique = new Map();
for (const entry of this.data.all) { for (const entry of this.data.all) {
...@@ -109,11 +115,17 @@ defineCustomElement('./timeline/timeline-track', (templateText) => ...@@ -109,11 +115,17 @@ defineCustomElement('./timeline/timeline-track', (templateText) =>
detail: selectedEvent})); detail: selectedEvent}));
} }
// TODO(zcankara) Emit event and handle data in timeline track timelineIndicatorMove(offset) {
handleTimelineIndicatorMove(offset) {
this.timeline.scrollLeft += offset; this.timeline.scrollLeft += offset;
} }
handleTimelineScroll(e){
let horizontal = e.currentTarget.scrollLeft;
this.dispatchEvent(new CustomEvent(
'scrolltrack', {bubbles: true, composed: true,
detail: horizontal}));
}
asyncSetTimelineChunkBackground(backgroundTodo) { asyncSetTimelineChunkBackground(backgroundTodo) {
const kIncrement = 100; const kIncrement = 100;
let start = 0; let start = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment