Fix warnings in strict mode

This commit is contained in:
Vivien Nicolas 2011-10-17 20:39:29 +02:00
parent 2c6935f868
commit 674d6a7d18
4 changed files with 25 additions and 10 deletions

View File

@ -710,7 +710,13 @@ var Font = (function Font() {
}; };
function createOS2Table(properties, override) { function createOS2Table(properties, override) {
var override = override || {}; override = override || {
unitsPerEm: 0,
yMax: 0,
yMin: 0,
ascent: 0,
descent: 0
};
var ulUnicodeRange1 = 0; var ulUnicodeRange1 = 0;
var ulUnicodeRange2 = 0; var ulUnicodeRange2 = 0;
@ -1322,7 +1328,8 @@ var Font = (function Font() {
'OS/2': stringToArray(createOS2Table(properties)), 'OS/2': stringToArray(createOS2Table(properties)),
// Character to glyphs mapping // Character to glyphs mapping
'cmap': createCMapTable(charstrings.slice(), font.glyphIds), 'cmap': createCMapTable(charstrings.slice(),
('glyphIds' in font) ? font.glyphIds: null),
// Font header // Font header
'head': (function fontFieldsHead() { 'head': (function fontFieldsHead() {
@ -2612,7 +2619,8 @@ var Type2CFF = (function type2CFF() {
if (unicode <= 0x1f || (unicode >= 127 && unicode <= 255)) if (unicode <= 0x1f || (unicode >= 127 && unicode <= 255))
unicode += kCmapGlyphOffset; unicode += kCmapGlyphOffset;
var width = isNum(mapping.width) ? mapping.width : defaultWidth; var width = ('width' in mapping) && isNum(mapping.width) ? mapping.width
: defaultWidth;
properties.encoding[code] = { properties.encoding[code] = {
unicode: unicode, unicode: unicode,
width: width width: width

12
pdf.js
View File

@ -5163,7 +5163,8 @@ var CanvasGraphics = (function canvasGraphics() {
stroke: function canvasGraphicsStroke() { stroke: function canvasGraphicsStroke() {
var ctx = this.ctx; var ctx = this.ctx;
var strokeColor = this.current.strokeColor; 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 // for patterns, we transform to pattern space, calculate
// the pattern, call stroke, and restore to user space // the pattern, call stroke, and restore to user space
ctx.save(); ctx.save();
@ -5184,7 +5185,8 @@ var CanvasGraphics = (function canvasGraphics() {
var ctx = this.ctx; var ctx = this.ctx;
var fillColor = this.current.fillColor; var fillColor = this.current.fillColor;
if (fillColor && fillColor.type === 'Pattern') { if (fillColor && fillColor.hasOwnProperty('type') &&
fillColor.type === 'Pattern') {
ctx.save(); ctx.save();
ctx.fillStyle = fillColor.getPattern(ctx); ctx.fillStyle = fillColor.getPattern(ctx);
ctx.fill(); ctx.fill();
@ -5204,7 +5206,8 @@ var CanvasGraphics = (function canvasGraphics() {
var ctx = this.ctx; var ctx = this.ctx;
var fillColor = this.current.fillColor; var fillColor = this.current.fillColor;
if (fillColor && fillColor.type === 'Pattern') { if (fillColor && fillColor.hasOwnProperty('type') &&
fillColor.type === 'Pattern') {
ctx.save(); ctx.save();
ctx.fillStyle = fillColor.getPattern(ctx); ctx.fillStyle = fillColor.getPattern(ctx);
ctx.fill(); ctx.fill();
@ -5214,7 +5217,8 @@ var CanvasGraphics = (function canvasGraphics() {
} }
var strokeColor = this.current.strokeColor; var strokeColor = this.current.strokeColor;
if (strokeColor && strokeColor.type === 'Pattern') { if (strokeColor && strokeColor.hasOwnProperty('type') &&
strokeColor.type === 'Pattern') {
ctx.save(); ctx.save();
ctx.strokeStyle = strokeColor.getPattern(ctx); ctx.strokeStyle = strokeColor.getPattern(ctx);
ctx.stroke(); ctx.stroke();

View File

@ -163,7 +163,7 @@
// IE9 text/html data URI // IE9 text/html data URI
(function checkDocumentDocumentModeCompatibility() { (function checkDocumentDocumentModeCompatibility() {
if (document.documentMode !== 9) if (!('documentMode' in document) || document.documentMode !== 9)
return; return;
// overriding the src property // overriding the src property
var originalSrcDescriptor = Object.getOwnPropertyDescriptor( var originalSrcDescriptor = Object.getOwnPropertyDescriptor(

View File

@ -178,7 +178,9 @@ var PDFView = {
while (sidebar.hasChildNodes()) while (sidebar.hasChildNodes())
sidebar.removeChild(sidebar.lastChild); sidebar.removeChild(sidebar.lastChild);
clearInterval(sidebar._loadingInterval);
if ('_loadingInterval' in sidebar)
clearInterval(sidebar._loadingInterval);
var container = document.getElementById('viewer'); var container = document.getElementById('viewer');
while (container.hasChildNodes()) while (container.hasChildNodes())
@ -544,7 +546,8 @@ window.addEventListener('load', function webViewerLoad(evt) {
params[unescape(param[0])] = unescape(param[1]); 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) if (!window.File || !window.FileReader || !window.FileList || !window.Blob)
document.getElementById('fileInput').style.display = 'none'; document.getElementById('fileInput').style.display = 'none';