perfetto-ui: Fix canvas limit px
Even though the canvas was not drawing behind the scroll bar,
the TimeScale calculations were still based on a width that
included the scrollbar. This caused the final px to not be
visible. This CL fixes this bug.
Change-Id: I95dcd7068f831bdbb0dc47c1fbc3e6aefa281d24
diff --git a/ui/src/frontend/panel_container.ts b/ui/src/frontend/panel_container.ts
index 3c2e31f..8698422 100644
--- a/ui/src/frontend/panel_container.ts
+++ b/ui/src/frontend/panel_container.ts
@@ -245,12 +245,7 @@
}
const dpr = window.devicePixelRatio;
- // On non-MacOS if there is a solid scroll bar it can cover important
- // pixels, reduce the size of the canvas so it doesn't overlap with
- // the scroll bar.
- ctx.canvas.width =
- (this.parentWidth - globals.frontendLocalState.getScrollbarWidth()) *
- dpr;
+ ctx.canvas.width = this.parentWidth * dpr;
ctx.canvas.height = this.canvasHeight * dpr;
ctx.scale(dpr, dpr);
}
@@ -270,7 +265,11 @@
const oldWidth = this.parentWidth;
const oldHeight = this.parentHeight;
const clientRect = assertExists(dom.parentElement).getBoundingClientRect();
- this.parentWidth = clientRect.width;
+ // On non-MacOS if there is a solid scroll bar it can cover important
+ // pixels, reduce the size of the canvas so it doesn't overlap with
+ // the scroll bar.
+ this.parentWidth =
+ clientRect.width - globals.frontendLocalState.getScrollbarWidth();
this.parentHeight = clientRect.height;
return this.parentHeight !== oldHeight || this.parentWidth !== oldWidth;
}