diff --git a/src/cargo/core/compiler/timings.js b/src/cargo/core/compiler/timings.js index 1b7e29e01..d9a0b53bd 100644 --- a/src/cargo/core/compiler/timings.js +++ b/src/cargo/core/compiler/timings.js @@ -22,6 +22,21 @@ let UNIT_COORDS = {}; // Map of unit index to the index it was unlocked by. let REVERSE_UNIT_DEPS = {}; let REVERSE_UNIT_RMETA_DEPS = {}; + +// Colors from css +const getCssColor = name => getComputedStyle(document.body).getPropertyValue(name); +const TEXT_COLOR = getCssColor('--text'); +const BG_COLOR = getCssColor('--background'); +const CANVAS_BG = getCssColor('--canvas-background'); +const AXES_COLOR = getCssColor('--canvas-axes'); +const GRID_COLOR = getCssColor('--canvas-grid'); +const BLOCK_COLOR = getCssColor('--canvas-block'); +const CUSTOM_BUILD_COLOR = getCssColor('--canvas-custom-build'); +const NOT_CUSTOM_BUILD_COLOR = getCssColor('--canvas-not-custom-build'); +const DEP_LINE_COLOR = getCssColor('--canvas-dep-line'); +const DEP_LINE_HIGHLIGHTED_COLOR = getCssColor('--canvas-dep-line-highlighted'); +const CPU_COLOR = getCssColor('--canvas-cpu'); + for (let n=0; n 1) { ctx.beginPath(); ctx.fillStyle = cpuFillStyle; @@ -245,8 +261,8 @@ function render_timing_graph() { ctx.save(); ctx.translate(canvas_width-200, MARGIN); // background - ctx.fillStyle = '#fff'; - ctx.strokeStyle = '#000'; + ctx.fillStyle = BG_COLOR; + ctx.strokeStyle = TEXT_COLOR; ctx.lineWidth = 1; ctx.textBaseline = 'middle' ctx.textAlign = 'start'; @@ -255,7 +271,7 @@ function render_timing_graph() { ctx.stroke(); ctx.fill(); - ctx.fillStyle = '#000' + ctx.fillStyle = TEXT_COLOR; ctx.beginPath(); ctx.lineWidth = 2; ctx.strokeStyle = 'red'; @@ -282,7 +298,7 @@ function render_timing_graph() { ctx.fillStyle = cpuFillStyle ctx.fillRect(15, 60, 30, 15); ctx.fill(); - ctx.fillStyle = 'black'; + ctx.fillStyle = TEXT_COLOR; ctx.fillText('CPU Usage', 54, 71); ctx.restore(); @@ -311,12 +327,13 @@ function draw_graph_axes(id, graph_height) { const canvas_width = Math.max(graph_width + X_LINE + 30, X_LINE + 250); const canvas_height = graph_height + MARGIN + Y_LINE; let ctx = setup_canvas(id, canvas_width, canvas_height); - ctx.fillStyle = '#f7f7f7'; + ctx.fillStyle = CANVAS_BG; ctx.fillRect(0, 0, canvas_width, canvas_height); ctx.lineWidth = 2; ctx.font = '16px sans-serif'; ctx.textAlign = 'center'; + ctx.strokeStyle = AXES_COLOR; // Draw main axes. ctx.beginPath(); @@ -327,7 +344,7 @@ function draw_graph_axes(id, graph_height) { // Draw X tick marks. const {step, tick_dist, num_ticks} = split_ticks(DURATION, px_per_sec, graph_width); - ctx.fillStyle = '#303030'; + ctx.fillStyle = AXES_COLOR; for (let n=0; nCargo Build Timings — {ROOTS}