-- cgit v1.2.1 From 5d8c7de3956e5686549f4d086738b6a59a285890 Mon Sep 17 00:00:00 2001 From: pankajp Date: Thu, 24 May 2018 12:43:32 +0000 Subject: Prevent expensive relayout in loop in html report js Faster html report loading in browser by avoiding unneeded expensive layouts in the loop to generate markers. --- coverage/htmlfiles/coverage_html.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/coverage/htmlfiles/coverage_html.js b/coverage/htmlfiles/coverage_html.js index f6f5de2..b7fbd9c 100644 --- a/coverage/htmlfiles/coverage_html.js +++ b/coverage/htmlfiles/coverage_html.js @@ -555,11 +555,14 @@ coverage.resize_scroll_markers = function () { var previous_line = -99, last_mark, - last_top; + last_top, + offsets = {}; + // Calculate line offsets outside loop to prevent relayouts + c.missed_lines.each(function(){offsets[this.id] = $(this).offset().top}); c.missed_lines.each(function () { - var line_top = Math.round($(this).offset().top * marker_scale), - id_name = $(this).attr('id'), + var id_name = $(this).attr('id'), + line_top = Math.round(offsets[id_name] * marker_scale), line_number = parseInt(id_name.substring(1, id_name.length)); if (line_number === previous_line + 1) { -- cgit v1.2.1 From 1ea419731992fbfa03aed3d92e420965a1eed0c5 Mon Sep 17 00:00:00 2001 From: pankajp Date: Thu, 24 May 2018 12:45:36 +0000 Subject: Html report marker div style in its own css layer. This gives faster scrolling in Chrome, comparable to firefox --- coverage/htmlfiles/style.css | 1 + 1 file changed, 1 insertion(+) diff --git a/coverage/htmlfiles/style.css b/coverage/htmlfiles/style.css index 86b8209..12e9064 100644 --- a/coverage/htmlfiles/style.css +++ b/coverage/htmlfiles/style.css @@ -365,6 +365,7 @@ td.text { height: 100%; background: white; border-left: 1px solid #eee; + will-change: transform; /* for faster scrolling of fixed element in Chrome */ } #scroll_marker .marker { -- cgit v1.2.1