From e71b6188c6ce27054531ff3e9e7f13dd5247b859 Mon Sep 17 00:00:00 2001 From: Artur Adib Date: Tue, 25 Oct 2011 18:18:22 -0700 Subject: [PATCH] 'use strict' everywhere --- Makefile | 2 +- src/canvas.js | 3 +++ src/charsets.js | 2 ++ src/cidmaps.js | 2 ++ src/colorspace.js | 5 +++++ src/core.js | 13 ++++++++----- src/crypto.js | 2 ++ src/evaluator.js | 5 +++++ src/fonts.js | 2 ++ src/function.js | 5 +++++ src/glyphlist.js | 2 ++ src/image.js | 5 +++++ src/metrics.js | 2 ++ src/obj.js | 5 +++++ src/parser.js | 5 +++++ src/pattern.js | 5 +++++ src/stream.js | 5 +++++ src/util.js | 5 +++++ src/worker.js | 8 +++++--- src/worker_loader.js | 5 +++++ 20 files changed, 79 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 515fe6c5f..1347e409e 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,7 @@ test: pdfjs shell-test browser-test # Create production output (pdf.js, and corresponding changes to web files) # production: | bundle - @echo "Preparing production viewer..."; \ + @echo "Preparing viewer-production.html..."; \ cd web; \ sed '/PDFJSSCRIPT_REMOVE/d' viewer.html > viewer-1.tmp; \ sed '/PDFJSSCRIPT_INCLUDE_BUILD/ r viewer-snippet.html' viewer-1.tmp > viewer-production.html; \ diff --git a/src/canvas.js b/src/canvas.js index 4139f29ba..70dd65e3d 100644 --- a/src/canvas.js +++ b/src/canvas.js @@ -1,5 +1,8 @@ // contexts store most of the state we need natively. // However, PDF needs a bit more state, which we store here. + +'use strict'; + var CanvasExtraState = (function canvasExtraState() { function constructor(old) { // Are soft masks and alpha values shapes or opacities? diff --git a/src/charsets.js b/src/charsets.js index 21554d769..7f54ab327 100644 --- a/src/charsets.js +++ b/src/charsets.js @@ -1,6 +1,8 @@ /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ +'use strict'; + var ISOAdobeCharset = [ '.notdef', 'space', 'exclam', 'quotedbl', 'numbersign', 'dollar', 'percent', 'ampersand', 'quoteright', 'parenleft', 'parenright', diff --git a/src/cidmaps.js b/src/cidmaps.js index 9efb3669e..7de3d14f6 100644 --- a/src/cidmaps.js +++ b/src/cidmaps.js @@ -1,6 +1,8 @@ /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ +'use strict'; + var CIDToUnicodeMaps = { 'Adobe-Japan1': [[32, 160], {f: 12, c: 33}, [45, 8209], {f: 46, c: 46}, 165, {f: 2, c: 93}, [95, 818], [96, 768], {f: 27, c: 97}, 166, 125, [732, 771], diff --git a/src/colorspace.js b/src/colorspace.js index c49117d90..3ce383a09 100644 --- a/src/colorspace.js +++ b/src/colorspace.js @@ -1,3 +1,8 @@ +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ + +'use strict'; + var ColorSpace = (function colorSpaceColorSpace() { // Constructor should define this.numComps, this.defaultColor, this.name function constructor() { diff --git a/src/core.js b/src/core.js index 55525c788..be43fc269 100644 --- a/src/core.js +++ b/src/core.js @@ -1,16 +1,19 @@ /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ +'use strict'; + +var globalScope = (typeof window === 'undefined') ? this : window; + var ERRORS = 0, WARNINGS = 1, TODOS = 5; var verbosity = WARNINGS; - var useWorker = false; // The global PDF object exposes the API // In production, it will be declared outside a global wrapper // In development, it will be declared here -if (typeof PDF === 'undefined') { - PDF = {}; +if (!globalScope.PDF) { + globalScope.PDF = {}; } // getPdf() @@ -46,7 +49,7 @@ function getPdf(arg, callback) { }; xhr.send(null); } -PDF.getPdf = getPdf; +globalScope.PDF.getPdf = getPdf; var Page = (function pagePage() { function constructor(xref, pageNumber, pageDict, ref) { @@ -605,4 +608,4 @@ var PDFDoc = (function() { return constructor; })(); -PDF.PDFDoc = PDFDoc; +globalScope.PDF.PDFDoc = PDFDoc; diff --git a/src/crypto.js b/src/crypto.js index 7721556b4..5699ea1df 100644 --- a/src/crypto.js +++ b/src/crypto.js @@ -1,6 +1,8 @@ /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ +'use strict'; + var ARCFourCipher = (function arcFourCipher() { function constructor(key) { this.a = 0; diff --git a/src/evaluator.js b/src/evaluator.js index e8ac4e60d..1327b3a69 100644 --- a/src/evaluator.js +++ b/src/evaluator.js @@ -1,3 +1,8 @@ +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ + +'use strict'; + var PartialEvaluator = (function partialEvaluator() { function constructor(xref, handler, uniquePrefix) { this.state = new EvalState(); diff --git a/src/fonts.js b/src/fonts.js index 56e2fc1b0..1663fe750 100644 --- a/src/fonts.js +++ b/src/fonts.js @@ -1,6 +1,8 @@ /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ +'use strict'; + var isWorker = (typeof window == 'undefined'); /** diff --git a/src/function.js b/src/function.js index 26c2af834..0f0ec8643 100644 --- a/src/function.js +++ b/src/function.js @@ -1,3 +1,8 @@ +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ + +'use strict'; + var PDFFunction = (function() { var CONSTRUCT_SAMPLED = 0; var CONSTRUCT_INTERPOLATED = 2; diff --git a/src/glyphlist.js b/src/glyphlist.js index d81d4c138..5691f8546 100644 --- a/src/glyphlist.js +++ b/src/glyphlist.js @@ -1,6 +1,8 @@ /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ +'use strict'; + var GlyphsUnicode = { A: 0x0041, AE: 0x00C6, diff --git a/src/image.js b/src/image.js index 31580f51a..b997245a3 100644 --- a/src/image.js +++ b/src/image.js @@ -1,3 +1,8 @@ +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ + +'use strict'; + var PDFImage = (function pdfImage() { function constructor(xref, res, image, inline) { this.image = image; diff --git a/src/metrics.js b/src/metrics.js index 9cb8eb0e6..d4d07ec0d 100644 --- a/src/metrics.js +++ b/src/metrics.js @@ -1,6 +1,8 @@ /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ +'use strict'; + var Metrics = { 'Courier': 600, 'Courier-Bold': 600, diff --git a/src/obj.js b/src/obj.js index 54e5254b4..8716d465d 100644 --- a/src/obj.js +++ b/src/obj.js @@ -1,3 +1,8 @@ +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ + +'use strict'; + var Name = (function nameName() { function constructor(name) { this.name = name; diff --git a/src/parser.js b/src/parser.js index e5be024ad..677eaad94 100644 --- a/src/parser.js +++ b/src/parser.js @@ -1,3 +1,8 @@ +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ + +'use strict'; + var EOF = {}; function isEOF(v) { diff --git a/src/pattern.js b/src/pattern.js index dcfe78379..a551ac411 100644 --- a/src/pattern.js +++ b/src/pattern.js @@ -1,3 +1,8 @@ +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ + +'use strict'; + var Pattern = (function patternPattern() { // Constructor should define this.getPattern function constructor() { diff --git a/src/stream.js b/src/stream.js index 88dc5dd2e..baebc3190 100644 --- a/src/stream.js +++ b/src/stream.js @@ -1,3 +1,8 @@ +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ + +'use strict'; + var Stream = (function streamStream() { function constructor(arrayBuffer, start, length, dict) { this.bytes = new Uint8Array(arrayBuffer); diff --git a/src/util.js b/src/util.js index 6ea013079..344b99e53 100644 --- a/src/util.js +++ b/src/util.js @@ -1,3 +1,8 @@ +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ + +'use strict'; + function log(msg) { if (console && console.log) console.log(msg); diff --git a/src/worker.js b/src/worker.js index bedb6a6f5..d1ab48458 100644 --- a/src/worker.js +++ b/src/worker.js @@ -1,6 +1,8 @@ -/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- / +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ +'use strict'; + function MessageHandler(name, comObj) { this.name = name; this.comObj = comObj; @@ -172,9 +174,9 @@ var workerConsole = { // Worker thread? if (typeof window === 'undefined') { - console = workerConsole; + globalScope.console = workerConsole; // Listen for messages from the main thread. - var handler = new MessageHandler('worker_processor', this); + var handler = new MessageHandler('worker_processor', globalScope); WorkerProcessorHandler.setup(handler); } diff --git a/src/worker_loader.js b/src/worker_loader.js index 0119996a7..f3646e530 100644 --- a/src/worker_loader.js +++ b/src/worker_loader.js @@ -1,3 +1,8 @@ +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ + +'use strict'; + importScripts('../src/core.js'); importScripts('../src/util.js'); importScripts('../src/canvas.js');