From 65bc78d8709884edcc6f6bbfb128864e3240c28a Mon Sep 17 00:00:00 2001 From: Yury Delendik Date: Thu, 9 Aug 2012 10:41:18 -0500 Subject: [PATCH 1/4] Using fast pixels copy in putBinaryImageData --- src/canvas.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/canvas.js b/src/canvas.js index 122dd5e59..97ff8f8d4 100644 --- a/src/canvas.js +++ b/src/canvas.js @@ -1281,12 +1281,14 @@ function checkPutBinaryImageDataCompatibility() { function CanvasGraphicsPutBinaryImageDataShim(ctx, imgData, w, h) { var tmpImgData = ctx.getImageData(0, 0, w, h); - // Copy over the imageData pixel by pixel. var tmpImgDataPixels = tmpImgData.data; - var len = tmpImgDataPixels.length; - - while (len--) { - tmpImgDataPixels[len] = imgData.data[len]; + var data = imgData.data; + if ('set' in tmpImgDataPixels) + tmpImgDataPixels.set(data); + else { + // Copy over the imageData pixel by pixel. + for (var i = 0, ii = tmpImgDataPixels.length; i < ii; i++) + tmpImgDataPixels[i] = data[i]; } ctx.putImageData(tmpImgData, 0, 0); From 55b3b005b8cd11fb93202dfc74714d3de23f00fd Mon Sep 17 00:00:00 2001 From: Yury Delendik Date: Thu, 9 Aug 2012 13:40:40 -0500 Subject: [PATCH 2/4] Using createImageData when available --- src/canvas.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/canvas.js b/src/canvas.js index 97ff8f8d4..9f61ba77b 100644 --- a/src/canvas.js +++ b/src/canvas.js @@ -1279,7 +1279,8 @@ function checkPutBinaryImageDataCompatibility() { } catch (e) { CanvasGraphics.prototype.putBinaryImageData = function CanvasGraphicsPutBinaryImageDataShim(ctx, imgData, w, h) { - var tmpImgData = ctx.getImageData(0, 0, w, h); + var tmpImgData = 'createImageData' in ctx ? ctx.createImageData(w, h) : + ctx.getImageData(0, 0, w, h); var tmpImgDataPixels = tmpImgData.data; var data = imgData.data; From 4de0d3131822145d6ca6ddb09aa377bea274df40 Mon Sep 17 00:00:00 2001 From: Yury Delendik Date: Thu, 9 Aug 2012 17:07:41 -0500 Subject: [PATCH 3/4] Finds correct window/notification box for fallback message --- .../firefox/components/PdfStreamConverter.js | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/extensions/firefox/components/PdfStreamConverter.js b/extensions/firefox/components/PdfStreamConverter.js index d371e50cd..7fb42c0cd 100644 --- a/extensions/firefox/components/PdfStreamConverter.js +++ b/extensions/firefox/components/PdfStreamConverter.js @@ -219,9 +219,26 @@ ChromeActions.prototype = { var strings = getLocalizedStrings('chrome.properties'); var message = getLocalizedString(strings, 'unsupported_feature'); - var win = Services.wm.getMostRecentWindow('navigator:browser'); - var browser = win.gBrowser.getBrowserForDocument(domWindow.top.document); - var notificationBox = win.gBrowser.getNotificationBox(browser); + var notificationBox = null; + // Multiple browser windows can be opened, finding one for notification box + var windowsEnum = Services.wm + .getZOrderDOMWindowEnumerator('navigator:browser', true); + while (windowsEnum.hasMoreElements()) { + var win = windowsEnum.getNext(); + if (win.closed) + continue; + var browser = win.gBrowser.getBrowserForDocument(domWindow.top.document); + if (browser) { + // right window/browser is found, getting the notification box + notificationBox = win.gBrowser.getNotificationBox(browser); + break; + } + } + if (!notificationBox) { + log('Unable to get a notification box for the fallback message'); + return; + } + // Flag so we don't call the response callback twice, since if the user // clicks open with different viewer both the button callback and // eventCallback will be called. From 5e3882ab6956f52f70e3b40f244a1f98479d9741 Mon Sep 17 00:00:00 2001 From: Yury Delendik Date: Fri, 10 Aug 2012 08:30:20 -0500 Subject: [PATCH 4/4] Changing cubic spline interpolation error to TODO --- src/function.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/function.js b/src/function.js index 56b405ede..2088ee219 100644 --- a/src/function.js +++ b/src/function.js @@ -103,11 +103,12 @@ var PDFFunction = (function PDFFunctionClosure() { var size = dict.get('Size'); var bps = dict.get('BitsPerSample'); - var order = dict.get('Order'); - if (!order) - order = 1; - if (order !== 1) - error('No support for cubic spline interpolation: ' + order); + var order = dict.get('Order') || 1; + if (order !== 1) { + // No description how cubic spline interpolation works in PDF32000:2008 + // As in poppler, ignoring order, linear interpolation may work as good + TODO('No support for cubic spline interpolation: ' + order); + } var encode = dict.get('Encode'); if (!encode) {