Merge pull request #7330 from Snuffleupagus/issue-7188

Try to prevent `CanvasGraphics_getSinglePixelWidth` from intermittently returning incorrect values in Firefox (issue 7188)
This commit is contained in:
Jonas Jenwald 2016-08-22 20:36:54 +02:00 committed by GitHub
commit e5baf7ec36

View File

@ -2298,7 +2298,13 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
},
getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
if (this.cachedGetSinglePixelWidth === null) {
// NOTE: The `save` and `restore` commands used below is a workaround
// that is necessary in order to prevent `mozCurrentTransformInverse`
// from intermittently returning incorrect values in Firefox, see:
// https://github.com/mozilla/pdf.js/issues/7188.
this.ctx.save();
var inverse = this.ctx.mozCurrentTransformInverse;
this.ctx.restore();
// max of the current horizontal and vertical scale
this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(
(inverse[0] * inverse[0] + inverse[1] * inverse[1]),