Bug 1171614 - Remove the special path for data-URI images from the server inspector actor r=jdescottes draft
authorIan Moody <moz-ian@perix.co.uk>
Fri, 01 Jul 2016 18:28:36 +0100
changeset 384590 1b84682e679dc4e853c63fc373b94f6f41847d2e
parent 384476 95ffbc4ff63584631c408e8d9912961fcf68bb09
child 384591 d3679bcd16984518f07f2cb90919eb884ce41807
push id22315
push usermoz-ian@perix.co.uk
push dateWed, 06 Jul 2016 18:00:26 +0000
reviewersjdescottes
bugs1171614
milestone50.0a1
Bug 1171614 - Remove the special path for data-URI images from the server inspector actor r=jdescottes MozReview-Commit-ID: 2tWleM1wH1G
devtools/server/actors/inspector.js
--- a/devtools/server/actors/inspector.js
+++ b/devtools/server/actors/inspector.js
@@ -3023,32 +3023,25 @@ var imageToImageData = Task.async(functi
   let imgWidth = node.naturalWidth || node.width;
   let imgHeight = node.naturalHeight || node.height;
   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:")) {
-    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");
-
-    // Copy the rawNode image or canvas in the new canvas and extract data
-    ctx.drawImage(node, 0, 0, canvas.width, canvas.height);
-    imageData = canvas.toDataURL("image/png");
-  }
+  // 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");
+
+  // Copy the rawNode image or canvas in the new canvas and extract data
+  ctx.drawImage(node, 0, 0, canvas.width, canvas.height);
+  let imageData = canvas.toDataURL("image/png");
 
   return {
     data: imageData,
     size: {
       naturalWidth: imgWidth,
       naturalHeight: imgHeight,
       resized: resizeRatio !== 1
     }