From 674d6a7d18821fcea8570b70a2454d5a1ab2d4ec Mon Sep 17 00:00:00 2001 From: Vivien Nicolas <21@vingtetun.org> Date: Mon, 17 Oct 2011 20:39:29 +0200 Subject: [PATCH 1/3] Fix warnings in strict mode --- fonts.js | 14 +++++++++++--- pdf.js | 12 ++++++++---- web/compatibility.js | 2 +- web/viewer.js | 7 +++++-- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/fonts.js b/fonts.js index bbff14e89..bcec5d2ac 100644 --- a/fonts.js +++ b/fonts.js @@ -710,7 +710,13 @@ var Font = (function Font() { }; function createOS2Table(properties, override) { - var override = override || {}; + override = override || { + unitsPerEm: 0, + yMax: 0, + yMin: 0, + ascent: 0, + descent: 0 + }; var ulUnicodeRange1 = 0; var ulUnicodeRange2 = 0; @@ -1322,7 +1328,8 @@ var Font = (function Font() { 'OS/2': stringToArray(createOS2Table(properties)), // Character to glyphs mapping - 'cmap': createCMapTable(charstrings.slice(), font.glyphIds), + 'cmap': createCMapTable(charstrings.slice(), + ('glyphIds' in font) ? font.glyphIds: null), // Font header 'head': (function fontFieldsHead() { @@ -2612,7 +2619,8 @@ var Type2CFF = (function type2CFF() { if (unicode <= 0x1f || (unicode >= 127 && unicode <= 255)) unicode += kCmapGlyphOffset; - var width = isNum(mapping.width) ? mapping.width : defaultWidth; + var width = ('width' in mapping) && isNum(mapping.width) ? mapping.width + : defaultWidth; properties.encoding[code] = { unicode: unicode, width: width diff --git a/pdf.js b/pdf.js index ef8493001..2ee61ada6 100644 --- a/pdf.js +++ b/pdf.js @@ -5163,7 +5163,8 @@ var CanvasGraphics = (function canvasGraphics() { stroke: function canvasGraphicsStroke() { var ctx = this.ctx; var strokeColor = this.current.strokeColor; - if (strokeColor && strokeColor.type === 'Pattern') { + if (strokeColor && strokeColor.hasOwnProperty('type') && + strokeColor.type === 'Pattern') { // for patterns, we transform to pattern space, calculate // the pattern, call stroke, and restore to user space ctx.save(); @@ -5184,7 +5185,8 @@ var CanvasGraphics = (function canvasGraphics() { var ctx = this.ctx; var fillColor = this.current.fillColor; - if (fillColor && fillColor.type === 'Pattern') { + if (fillColor && fillColor.hasOwnProperty('type') && + fillColor.type === 'Pattern') { ctx.save(); ctx.fillStyle = fillColor.getPattern(ctx); ctx.fill(); @@ -5204,7 +5206,8 @@ var CanvasGraphics = (function canvasGraphics() { var ctx = this.ctx; var fillColor = this.current.fillColor; - if (fillColor && fillColor.type === 'Pattern') { + if (fillColor && fillColor.hasOwnProperty('type') && + fillColor.type === 'Pattern') { ctx.save(); ctx.fillStyle = fillColor.getPattern(ctx); ctx.fill(); @@ -5214,7 +5217,8 @@ var CanvasGraphics = (function canvasGraphics() { } var strokeColor = this.current.strokeColor; - if (strokeColor && strokeColor.type === 'Pattern') { + if (strokeColor && strokeColor.hasOwnProperty('type') && + strokeColor.type === 'Pattern') { ctx.save(); ctx.strokeStyle = strokeColor.getPattern(ctx); ctx.stroke(); diff --git a/web/compatibility.js b/web/compatibility.js index 36df0e2a5..ad4c8f8a9 100644 --- a/web/compatibility.js +++ b/web/compatibility.js @@ -163,7 +163,7 @@ // IE9 text/html data URI (function checkDocumentDocumentModeCompatibility() { - if (document.documentMode !== 9) + if (!('documentMode' in document) || document.documentMode !== 9) return; // overriding the src property var originalSrcDescriptor = Object.getOwnPropertyDescriptor( diff --git a/web/viewer.js b/web/viewer.js index 93f6acd31..91562baf4 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -178,7 +178,9 @@ var PDFView = { while (sidebar.hasChildNodes()) sidebar.removeChild(sidebar.lastChild); - clearInterval(sidebar._loadingInterval); + + if ('_loadingInterval' in sidebar) + clearInterval(sidebar._loadingInterval); var container = document.getElementById('viewer'); while (container.hasChildNodes()) @@ -544,7 +546,8 @@ window.addEventListener('load', function webViewerLoad(evt) { params[unescape(param[0])] = unescape(param[1]); } - PDFView.open(params.file || kDefaultURL, parseFloat(params.scale)); + var scale = ('scale' in params) ? params.scale : kDefaultScale; + PDFView.open(params.file || kDefaultURL, parseFloat(scale)); if (!window.File || !window.FileReader || !window.FileList || !window.Blob) document.getElementById('fileInput').style.display = 'none'; From e83c77148d4c64602ad3d88aba0c4b5c5e998186 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas <21@vingtetun.org> Date: Mon, 17 Oct 2011 21:04:54 +0200 Subject: [PATCH 2/3] add oncontextmenu='return false;' to buttons --- web/viewer.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/web/viewer.html b/web/viewer.html index 160c5ce57..428171b9e 100644 --- a/web/viewer.html +++ b/web/viewer.html @@ -17,12 +17,12 @@
- - @@ -36,16 +36,16 @@
- -
- @@ -59,14 +59,14 @@
-
- +
From f1444d6175794dd942c8a7d0f74b02508cb96bac Mon Sep 17 00:00:00 2001 From: Vivien Nicolas <21@vingtetun.org> Date: Tue, 18 Oct 2011 00:18:12 +0200 Subject: [PATCH 3/3] Fix wrongs ids --- web/viewer.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/viewer.html b/web/viewer.html index 428171b9e..5da063b91 100644 --- a/web/viewer.html +++ b/web/viewer.html @@ -36,10 +36,10 @@
- -