[Pkg-javascript-commits] [pdf.js] 05/119: Fix flaw in mozCurrentTransform polyfill
David Prévot
taffit at moszumanska.debian.org
Wed May 13 21:27:35 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 6eb9e6a6a40ab2a19440319b5e521bf5ff7c043c
Author: Rob Wu <rob at robwu.nl>
Date: Wed Mar 11 20:55:26 2015 +0100
Fix flaw in mozCurrentTransform polyfill
Set transformation matrix in (polyfilled) mozPrintCallback when a scale
is applied. Removed _scaleX and _scaleY in favor of _transformMatrix to
emphasize that the caller MUST ensure that the state of the matrix is
correct before `addContextCurrentTransform` is called.
---
src/display/canvas.js | 9 ++++-----
web/pdf_page_view.js | 12 +++++++++---
2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/src/display/canvas.js b/src/display/canvas.js
index 5a2a423..4ef3307 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 8e49cba..c219809 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 = {
--
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