diff --git a/src/display/canvas.js b/src/display/canvas.js index 5a2a4230f..4ef3307f1 100644 --- a/src/display/canvas.js +++ b/src/display/canvas.js @@ -46,11 +46,8 @@ function createScratchCanvas(width, height) { } function addContextCurrentTransform(ctx) { - // If the context doesn't expose a `mozCurrentTransform`, add a JS based on. + // If the context doesn't expose a `mozCurrentTransform`, add a JS based one. if (!ctx.mozCurrentTransform) { - // Store the original context - ctx._scaleX = ctx._scaleX || 1.0; - ctx._scaleY = ctx._scaleY || 1.0; ctx._originalSave = ctx.save; ctx._originalRestore = ctx.restore; ctx._originalRotate = ctx.rotate; @@ -59,7 +56,7 @@ function addContextCurrentTransform(ctx) { ctx._originalTransform = ctx.transform; ctx._originalSetTransform = ctx.setTransform; - ctx._transformMatrix = [ctx._scaleX, 0, 0, ctx._scaleY, 0, 0]; + ctx._transformMatrix = ctx._transformMatrix || [1, 0, 0, 1, 0, 0]; ctx._transformStack = []; Object.defineProperty(ctx, 'mozCurrentTransform', { @@ -435,6 +432,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { this.smaskCounter = 0; this.tempSMask = null; if (canvasCtx) { + // NOTE: if mozCurrentTransform is polyfilled, then the current state of + // the transformation must already be set in canvasCtx._transformMatrix. addContextCurrentTransform(canvasCtx); } this.cachedGetSinglePixelWidth = null; diff --git a/web/pdf_page_view.js b/web/pdf_page_view.js index 8e49cbaf6..c21980939 100644 --- a/web/pdf_page_view.js +++ b/web/pdf_page_view.js @@ -362,10 +362,11 @@ var PDFPageView = (function PDFPageViewClosure() { } this.textLayer = textLayer; - // TODO(mack): use data attributes to store these - ctx._scaleX = outputScale.sx; - ctx._scaleY = outputScale.sy; if (outputScale.scaled) { +//#if !(MOZCENTRAL || FIREFOX) + // Used by the mozCurrentTransform polyfill in src/display/canvas.js. + ctx._transformMatrix = [outputScale.sx, 0, 0, outputScale.sy, 0, 0]; +//#endif ctx.scale(outputScale.sx, outputScale.sy); } @@ -516,6 +517,11 @@ var PDFPageView = (function PDFPageViewClosure() { ctx.fillStyle = 'rgb(255, 255, 255)'; ctx.fillRect(0, 0, canvas.width, canvas.height); ctx.restore(); +//#if !(MOZCENTRAL || FIREFOX) + // Used by the mozCurrentTransform polyfill in src/display/canvas.js. + ctx._transformMatrix = + [PRINT_OUTPUT_SCALE, 0, 0, PRINT_OUTPUT_SCALE, 0, 0]; +//#endif ctx.scale(PRINT_OUTPUT_SCALE, PRINT_OUTPUT_SCALE); var renderContext = {