From 30e00bc5737bec7396505b54125c167f5a365fde Mon Sep 17 00:00:00 2001
From: "Manas (prometheansacrifice)" <harlequinsguitar@gmail.com>
Date: Tue, 11 Mar 2014 08:48:37 +0530
Subject: [PATCH] Removing set-presence-in-ImageData check from canvas.js

---
 src/display/canvas.js | 13 ++++---------
 web/compatibility.js  | 12 ++++++++++++
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/src/display/canvas.js b/src/display/canvas.js
index f9ca1721b..00153986a 100644
--- a/src/display/canvas.js
+++ b/src/display/canvas.js
@@ -507,20 +507,15 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
 
     } else if (imgData.kind === ImageKind.RGBA_32BPP) {
       // RGBA, 32-bits per pixel.
-      var haveSetAndSubarray = 'set' in dest && 'subarray' in src;
 
       for (var i = 0; i < totalChunks; i++) {
         var thisChunkHeight =
           (i < fullChunks) ? fullChunkHeight : partialChunkHeight;
         var elemsInThisChunk = imgData.width * thisChunkHeight * 4;
-        if (haveSetAndSubarray) {
-          dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
-          srcPos += elemsInThisChunk;
-        } else {
-          for (var j = 0; j < elemsInThisChunk; j++) {
-            dest[j] = src[srcPos++];
-          }
-        }
+
+        dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
+        srcPos += elemsInThisChunk;
+
         ctx.putImageData(chunkImgData, 0, i * fullChunkHeight);
       }
 
diff --git a/web/compatibility.js b/web/compatibility.js
index 64ce745bd..aceca91fa 100644
--- a/web/compatibility.js
+++ b/web/compatibility.js
@@ -493,3 +493,15 @@ if (typeof PDFJS === 'undefined') {
     PDFJS.disableHistory = true;
   }
 })();
+
+(function checkSetPresenceInImageData() {
+  if (window.CanvasPixelArray) {
+    if (typeof window.CanvasPixelArray.prototype.set !== 'function') {
+      window.CanvasPixelArray.prototype.set = function(arr) {
+        for (var i = 0, ii = this.length; i < ii; i++) {
+          this[i] = arr[i];
+        }
+      };
+    }
+  }
+})();