third_party/js/mozmill/shared-modules/screenshot.js
function create(controller, boxes) {
  var doc = controller.window.document;
  var maxWidth = doc.documentElement.boxObject.width;
  var maxHeight = doc.documentElement.boxObject.height;
  var rect = [];
  for (var i = 0, j = boxes.length; i < j; ++i) {
    rect = boxes[i];
    if (rect[0] + rect[2] > maxWidth) maxWidth = rect[0] + rect[2];
    if (rect[1] + rect[3] > maxHeight) maxHeight = rect[1] + rect[3];
  }
  var canvas = doc.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
  var width = doc.documentElement.boxObject.width;
  var height = doc.documentElement.boxObject.height;
  canvas.width = maxWidth;
  canvas.height = maxHeight;
  var ctx = canvas.getContext("2d");
  ctx.clearRect(0,0, canvas.width, canvas.height);
  ctx.save();
  ctx.drawWindow(controller.window, 0, 0, width, height, "rgb(0,0,0)");
  ctx.restore();
  ctx.save();
  ctx.fillStyle = "rgba(255,0,0,0.4)";
  for (var i = 0, j = boxes.length; i < j; ++i) {
    rect = boxes[i];
    ctx.fillRect(rect[0], rect[1], rect[2], rect[3]);
  }
  ctx.restore();

  _saveCanvas(canvas);
}
function create(controller, boxes) {
  var doc = controller.window.document;
  var maxWidth = doc.documentElement.boxObject.width;
  var maxHeight = doc.documentElement.boxObject.height;
  var rect = [];
  for (var i = 0, j = boxes.length; i < j; ++i) {
    rect = boxes[i];
    if (rect[0] + rect[2] > maxWidth) maxWidth = rect[0] + rect[2];
    if (rect[1] + rect[3] > maxHeight) maxHeight = rect[1] + rect[3];
  }
  var canvas = doc.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
  var width = doc.documentElement.boxObject.width;
  var height = doc.documentElement.boxObject.height;
  canvas.width = maxWidth;
  canvas.height = maxHeight;
  var ctx = canvas.getContext("2d");
  ctx.clearRect(0,0, canvas.width, canvas.height);
  ctx.save();
  ctx.drawWindow(controller.window, 0, 0, width, height, "rgb(0,0,0)");
  ctx.restore();
  ctx.save();
  ctx.fillStyle = "rgba(255,0,0,0.4)";
  for (var i = 0, j = boxes.length; i < j; ++i) {
    rect = boxes[i];
    ctx.fillRect(rect[0], rect[1], rect[2], rect[3]);
  }
  ctx.restore();

  _saveCanvas(canvas);
}
function create ( controller , boxes ) { var doc = controller . window . document ; var maxWidth = doc . documentElement . boxObject . width ; var maxHeight = doc . documentElement . boxObject . height ; var rect = [ ] ; for ( var i = 0 , j = boxes . length ; i < j ; ++ i ) { rect = boxes [ i ] ; if ( rect [ 0 ] + rect [ 2 ] > maxWidth ) maxWidth = rect [ 0 ] + rect [ 2 ] ; if ( rect [ 1 ] + rect [ 3 ] > maxHeight ) maxHeight = rect [ 1 ] + rect [ 3 ] ; } var canvas = doc . createElementNS ( "http://www.w3.org/1999/xhtml" , "canvas" ) ; var width = doc . documentElement . boxObject . width ; var height = doc . documentElement . boxObject . height ; canvas . width = maxWidth ; canvas . height = maxHeight ; var ctx = canvas . getContext ( "2d" ) ; ctx . clearRect ( 0 , 0 , canvas . width , canvas . height ) ; ctx . save ( ) ; ctx . drawWindow ( controller . window , 0 , 0 , width , height , "rgb(0,0,0)" ) ; ctx . restore ( ) ; ctx . save ( ) ; ctx . fillStyle = "rgba(255,0,0,0.4)" ; for ( var i = 0 , j = boxes . length ; i < j ; ++ i ) { rect = boxes [ i ] ; ctx . fillRect ( rect [ 0 ] , rect [ 1 ] , rect [ 2 ] , rect [ 3 ] ) ; } ctx . restore ( ) ; _saveCanvas ( canvas ) ; }
This function creates a screenshot of the window provided in the given
controller and highlights elements from the coordinates provided in the
given boxes-array.

@param {array of array of int} boxes
@param {MozmillController} controller
This function creates a screenshot of the window provided in the given controller and highlights elements from the coordinates provided in the given boxes - array .