start.js (1166B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 const { 8 setupDraw, 9 } = require("resource://devtools/client/memory/components/tree-map/draw.js"); 10 const DragZoom = require("resource://devtools/client/memory/components/tree-map/drag-zoom.js"); 11 const CanvasUtils = require("resource://devtools/client/memory/components/tree-map/canvas-utils.js"); 12 13 /** 14 * Start the tree map visualization 15 * 16 * @param {HTMLDivElement} container 17 * @param {object} report 18 * the report from a census 19 * @param {number} debounceRate 20 */ 21 module.exports = function startVisualization( 22 parentEl, 23 report, 24 debounceRate = 60 25 ) { 26 const window = parentEl.ownerDocument.defaultView; 27 const canvases = new CanvasUtils(parentEl, debounceRate); 28 const dragZoom = new DragZoom( 29 canvases.container, 30 debounceRate, 31 window.requestAnimationFrame 32 ); 33 34 setupDraw(report, canvases, dragZoom); 35 36 return function stopVisualization() { 37 canvases.destroy(); 38 dragZoom.destroy(); 39 }; 40 };