From 8fbb05613ea9baf47f263043359f2ecae1c7c76e Mon Sep 17 00:00:00 2001 From: Artur Adib Date: Tue, 25 Oct 2011 09:10:56 -0700 Subject: [PATCH] Progress --- Makefile | 34 ++++++++++++------------- src/canvas.js | 2 +- src/charsets.js | 2 -- src/cidmaps.js | 2 -- src/core.js | 2 -- src/crypto.js | 2 -- src/fonts.js | 1 - src/glyphlist.js | 2 -- src/metrics.js | 2 -- src/pattern.js | 45 +++++++++++++++++---------------- src/pdf.js | 11 +++----- src/utils/cffStandardStrings.js | 2 -- src/utils/fonts_utils.js | 2 -- src/worker/console.js | 2 -- src/worker/message_handler.js | 3 --- src/worker/processor_handler.js | 2 -- test/test.py | 2 +- test/test_slave.html | 10 +------- web/viewer.html | 2 +- 19 files changed, 48 insertions(+), 82 deletions(-) diff --git a/Makefile b/Makefile index 9e7c36a8b..46cddc13b 100644 --- a/Makefile +++ b/Makefile @@ -41,6 +41,15 @@ PDF_WORKER_FILES = \ worker/processor_handler.js \ $(NULL) +# make server +# +# This target starts a local web server at localhost:8888. This can be +# used for testing all browsers. +server: + @cd test; python test.py --port=8888; + +test: pdfjs shell-test browser-test + # # Bundle pdf.js # @@ -53,22 +62,6 @@ pdfjs: rm -f all_files.tmp; \ cd .. -# -# Watch for file changes, regenerate pdf.js if change found -# -watch: - @echo "Watching for file changes in src/" - @python watch.py src/*.js - 'make pdfjs' - -# make server -# -# This target starts a local web server at localhost:8888. This can be -# used for testing all browsers. -server: - @cd test; python test.py --port=8888; - -test: shell-test browser-test - # make browser-test # # This target runs in-browser tests using two primary arguments: a @@ -240,5 +233,12 @@ clean: help: @echo "Read the comments in the Makefile for guidance."; -.PHONY:: all test browser-test font-test shell-test \ +# +# Watch for file changes, regenerate pdf.js if change found +# +watch: + @echo "Watching for file changes in src/" + @python watch.py src/*.js - 'make pdfjs' + +.PHONY:: all pdfjs watch test browser-test font-test shell-test \ shell-msg lint clean web compiler help server diff --git a/src/canvas.js b/src/canvas.js index f8b3a6d87..4139f29ba 100644 --- a/src/canvas.js +++ b/src/canvas.js @@ -558,7 +558,7 @@ var CanvasGraphics = (function canvasGraphics() { color = base.getRgb(color); } var pattern = new TilingPattern(IR, color, this.ctx, this.objs); - } else if (IR[0] == 'RadialAxialShading' || IR[0] == 'DummyShading') { + } else if (IR[0] == 'RadialAxial' || IR[0] == 'Dummy') { var pattern = Pattern.shadingFromIR(this.ctx, IR); } else { throw 'Unkown IR type'; diff --git a/src/charsets.js b/src/charsets.js index 7f54ab327..21554d769 100644 --- a/src/charsets.js +++ b/src/charsets.js @@ -1,8 +1,6 @@ /* -*- 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 7de3d14f6..9efb3669e 100644 --- a/src/cidmaps.js +++ b/src/cidmaps.js @@ -1,8 +1,6 @@ /* -*- 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/core.js b/src/core.js index 05cd8cd32..b969392ca 100644 --- a/src/core.js +++ b/src/core.js @@ -1,8 +1,6 @@ /* -*- 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 ERRORS = 0, WARNINGS = 1, TODOS = 5; var verbosity = WARNINGS; diff --git a/src/crypto.js b/src/crypto.js index 5699ea1df..7721556b4 100644 --- a/src/crypto.js +++ b/src/crypto.js @@ -1,8 +1,6 @@ /* -*- 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/fonts.js b/src/fonts.js index 9dc088f6c..56e2fc1b0 100644 --- a/src/fonts.js +++ b/src/fonts.js @@ -1,7 +1,6 @@ /* -*- 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/glyphlist.js b/src/glyphlist.js index 5691f8546..d81d4c138 100644 --- a/src/glyphlist.js +++ b/src/glyphlist.js @@ -1,8 +1,6 @@ /* -*- 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/metrics.js b/src/metrics.js index d4d07ec0d..9cb8eb0e6 100644 --- a/src/metrics.js +++ b/src/metrics.js @@ -1,8 +1,6 @@ /* -*- 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/pattern.js b/src/pattern.js index a5c917db7..dcfe78379 100644 --- a/src/pattern.js +++ b/src/pattern.js @@ -13,8 +13,7 @@ var Pattern = (function patternPattern() { }; constructor.shadingFromIR = function pattern_shadingFromIR(ctx, raw) { - var obj = window[raw[0]]; - return obj.fromIR(ctx, raw); + return Shadings[raw[0]].fromIR(ctx, raw); } constructor.parseShading = function pattern_shading(shading, matrix, @@ -27,34 +26,19 @@ var Pattern = (function patternPattern() { case 2: case 3: // both radial and axial shadings are handled by RadialAxial shading - return new RadialAxialShading(dict, matrix, xref, res, ctx); + return new Shadings.RadialAxial(dict, matrix, xref, res, ctx); default: - return new DummyShading(); + return new Shadings.Dummy(); } }; return constructor; })(); -var DummyShading = (function dummyShading() { - function constructor() { - this.type = 'Pattern'; - } - - constructor.fromIR = function() { - return 'hotpink'; - } - - constructor.prototype = { - getIR: function dummpy_getir() { - return ['DummyShading']; - } - }; - return constructor; -})(); +var Shadings = {}; // Radial and axial shading have very similar implementations // If needed, the implementations can be broken into two classes -var RadialAxialShading = (function radialAxialShading() { +Shadings.RadialAxial = (function radialAxialShading() { function constructor(dict, matrix, xref, res, ctx) { this.matrix = matrix; this.coordsArr = dict.get('Coords'); @@ -163,13 +147,30 @@ var RadialAxialShading = (function radialAxialShading() { p1 = Util.applyTransform(p1, matrix); } - return ['RadialAxialShading', type, this.colorStops, p0, p1, r0, r1]; + return ['RadialAxial', type, this.colorStops, p0, p1, r0, r1]; } }; return constructor; })(); +Shadings.Dummy = (function dummyShading() { + function constructor() { + this.type = 'Pattern'; + } + + constructor.fromIR = function() { + return 'hotpink'; + } + + constructor.prototype = { + getIR: function dummpy_getir() { + return ['Dummy']; + } + }; + return constructor; +})(); + var TilingPattern = (function tilingPattern() { var PAINT_TYPE_COLORED = 1, PAINT_TYPE_UNCOLORED = 2; diff --git a/src/pdf.js b/src/pdf.js index ba721d0b5..9970f9067 100644 --- a/src/pdf.js +++ b/src/pdf.js @@ -4,18 +4,15 @@ // // TODO: Global namespace // var PDF = {}; -// Stay away from global (function(){ - + // Use strict in our context only - users might not want it 'use strict'; - // All files will be inserted below this point - // INSERT_POINT + // Files are inserted below - see Makefile + /* INSERT_POINT */ - // // Expose API in global object - // window.PDFDoc = PDFDoc; window.getPdf = getPdf; -})(); // self-executing function +})(); diff --git a/src/utils/cffStandardStrings.js b/src/utils/cffStandardStrings.js index 743c60b25..97d7e5a25 100644 --- a/src/utils/cffStandardStrings.js +++ b/src/utils/cffStandardStrings.js @@ -1,8 +1,6 @@ /* -*- 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 CFFEncodingMap = { '0': '-reserved-', '1': 'hstem', diff --git a/src/utils/fonts_utils.js b/src/utils/fonts_utils.js index 654e98db1..2a1f0ea72 100644 --- a/src/utils/fonts_utils.js +++ b/src/utils/fonts_utils.js @@ -1,8 +1,6 @@ /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ -'use strict'; - /* * The Type2 reader code below is only used for debugging purpose since Type2 * is only a CharString format and is never used directly as a Font file. diff --git a/src/worker/console.js b/src/worker/console.js index ffcaaf9a2..6d77e642d 100644 --- a/src/worker/console.js +++ b/src/worker/console.js @@ -1,8 +1,6 @@ /* -*- 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 consoleTimer = {}; var console = { log: function log() { diff --git a/src/worker/message_handler.js b/src/worker/message_handler.js index 70a38e474..64723f537 100644 --- a/src/worker/message_handler.js +++ b/src/worker/message_handler.js @@ -1,9 +1,6 @@ /* -*- 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; diff --git a/src/worker/processor_handler.js b/src/worker/processor_handler.js index 6844168e6..47fb89ab6 100644 --- a/src/worker/processor_handler.js +++ b/src/worker/processor_handler.js @@ -1,8 +1,6 @@ /* -*- 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 WorkerProcessorHandler = { setup: function(handler) { var pdfDoc = null; diff --git a/test/test.py b/test/test.py index 46106965b..73a776545 100644 --- a/test/test.py +++ b/test/test.py @@ -318,7 +318,7 @@ def downloadLinkedPDFs(manifestList): def setUp(options): # Only serve files from a pdf.js clone - assert not ANAL or os.path.isfile('../pdf.js') and os.path.isdir('../.git') + assert not ANAL or os.path.isfile('../build/pdf.js') and os.path.isdir('../.git') if options.masterMode and os.path.isdir(TMPDIR): print 'Temporary snapshot dir tmp/ is still around.' diff --git a/test/test_slave.html b/test/test_slave.html index 124537a88..70d39017d 100644 --- a/test/test_slave.html +++ b/test/test_slave.html @@ -3,16 +3,8 @@ pdf.js test slave - - - - - - - + - - diff --git a/web/viewer.html b/web/viewer.html index f6e492d3e..e01aab17d 100644 --- a/web/viewer.html +++ b/web/viewer.html @@ -6,7 +6,7 @@ - +