]> git.parisson.com Git - pdf.js.git/commitdiff
Fix warnings in strict mode
authorVivien Nicolas <21@vingtetun.org>
Mon, 17 Oct 2011 18:39:29 +0000 (20:39 +0200)
committerVivien Nicolas <21@vingtetun.org>
Mon, 17 Oct 2011 18:39:29 +0000 (20:39 +0200)
fonts.js
pdf.js
web/compatibility.js
web/viewer.js

index bbff14e89f8f5b55ad5e32dd08ed7d0f8db386dc..bcec5d2acf35b9aeb0fb7d43d842fd7f7b8dd7c2 100644 (file)
--- 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 ef8493001613635f9d12d7734cfea8ca980e1b0d..2ee61ada63c29af032a808562327da00b2bcdc3f 100644 (file)
--- 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();
index 36df0e2a5d631a6b419256b5caf4b4615019b854..ad4c8f8a997e3ee5a215d847f20f9702fea36ca9 100644 (file)
 
 // 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(
index 93f6acd315051573e1faa2e7a612aba64ee7cf57..91562baf44d2145bbf90e58509497559574ba79f 100644 (file)
@@ -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';