mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Merge pull request #5828 from Rob--W/mozCurrentTransform-fix
Fix flaw in mozCurrentTransform polyfill
This commit is contained in:
commit
6159da0598
2 changed files with 13 additions and 8 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue