[Pkg-javascript-commits] [pdf.js] 05/174: Remove TryCatch in canvas fill

David Prévot taffit at moszumanska.debian.org
Thu Nov 19 18:44:58 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit 063ca95f5fb829d930733926c65c0fbeedaffe11
Author: Fabian Lange <lange.fabian at gmail.com>
Date:   Sun Nov 9 13:53:50 2014 +0100

    Remove TryCatch in canvas fill
    
    As verified by @Rob--W, the evenodd fill rule works correctly in all supported browsers. This now allows optimization by JS engines.
    
    This fixes #5458
---
 src/display/canvas.js | 14 ++------------
 web/compatibility.js  |  6 ++++--
 2 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/src/display/canvas.js b/src/display/canvas.js
index 8e8deda..cdcf849 100644
--- a/src/display/canvas.js
+++ b/src/display/canvas.js
@@ -1096,12 +1096,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
           ctx.fill();
           ctx.mozFillRule = 'nonzero';
         } else {
-          try {
-            ctx.fill('evenodd');
-          } catch (ex) {
-            // shouldn't really happen, but browsers might think differently
-            ctx.fill();
-          }
+          ctx.fill('evenodd');
         }
         this.pendingEOFill = false;
       } else {
@@ -2110,12 +2105,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
             ctx.clip();
             ctx.mozFillRule = 'nonzero';
           } else {
-            try {
-              ctx.clip('evenodd');
-            } catch (ex) {
-              // shouldn't really happen, but browsers might think differently
-              ctx.clip();
-            }
+            ctx.clip('evenodd');
           }
         } else {
           ctx.clip();
diff --git a/web/compatibility.js b/web/compatibility.js
index 06f54bf..6d91057 100644
--- a/web/compatibility.js
+++ b/web/compatibility.js
@@ -522,9 +522,9 @@ if (typeof PDFJS === 'undefined') {
 
     if (polyfill) {
       var contextPrototype = window.CanvasRenderingContext2D.prototype;
-      contextPrototype._createImageData = contextPrototype.createImageData;
+      var createImageData = contextPrototype.createImageData;
       contextPrototype.createImageData = function(w, h) {
-        var imageData = this._createImageData(w, h);
+        var imageData = createImageData.call(this, w, h);
         imageData.data.set = function(arr) {
           for (var i = 0, ii = this.length; i < ii; i++) {
             this[i] = arr[i];
@@ -532,6 +532,8 @@ if (typeof PDFJS === 'undefined') {
         };
         return imageData;
       };
+      // this closure will be kept referenced, so clear its vars
+      contextPrototype = null;
     }
   }
 })();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list