Bug 1171614 - Make server inspector actor only return data-URIs as-is if they are smaller than maxDim. r=jdescottes draft
authorIan Moody <moz-ian@perix.co.uk>
Thu, 07 Jul 2016 12:13:49 +0100
changeset 385022 caf1540023f9fca662bbd7e3e8e9262af32e0212
parent 384476 95ffbc4ff63584631c408e8d9912961fcf68bb09
child 385023 26e6febbfe2acc47e0273b3d594b2b50e79dc7c9
push id22395
push usermoz-ian@perix.co.uk
push dateThu, 07 Jul 2016 13:58:51 +0000
reviewersjdescottes
bugs1171614
milestone50.0a1
Bug 1171614 - Make server inspector actor only return data-URIs as-is if they are smaller than maxDim. r=jdescottes MozReview-Commit-ID: Hw0K8ZA79eG
devtools/server/actors/inspector.js
--- a/devtools/server/actors/inspector.js
+++ b/devtools/server/actors/inspector.js
@@ -3025,18 +3025,19 @@ var imageToImageData = Task.async(functi
   let imgMax = Math.max(imgWidth, imgHeight);
   if (maxDim && imgMax > maxDim) {
     resizeRatio = maxDim / imgMax;
   }
 
   // Extract the image data
   let imageData;
   // The image may already be a data-uri, in which case, save ourselves the
-  // trouble of converting via the canvas.drawImage.toDataURL method
-  if (isImg && node.src.startsWith("data:")) {
+  // trouble of converting via the canvas.drawImage.toDataURL method, but only
+  // if the image doesn't need resizing
+  if (isImg && node.src.startsWith("data:") && resizeRatio === 1) {
     imageData = node.src;
   } else {
     // Create a canvas to copy the rawNode into and get the imageData from
     let canvas = node.ownerDocument.createElementNS(XHTML_NS, "canvas");
     canvas.width = imgWidth * resizeRatio;
     canvas.height = imgHeight * resizeRatio;
     let ctx = canvas.getContext("2d");