From 08af0c7686bc2ca5b0648196e5b8887c93ae78d2 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas <21@vingtetun.org> Date: Tue, 18 Oct 2011 19:43:43 +0200 Subject: [PATCH 01/66] Initial Chrome extension import --- Makefile | 33 ++++++++++++++++++++++--------- extensions/chrome/manifest.json | 11 +++++++++++ extensions/chrome/pdfHandler.html | 17 ++++++++++++++++ 3 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 extensions/chrome/manifest.json create mode 100644 extensions/chrome/pdfHandler.html diff --git a/Makefile b/Makefile index ebffb374c..603b33b6a 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,9 @@ BUILD_DIR := build DEFAULT_BROWSERS := resources/browser_manifests/browser_manifest.json DEFAULT_TESTS := test_manifest.json -EXTENSION_SRC := ./extensions/firefox -EXTENSION_NAME := pdf.js.xpi +EXTENSION_SRC := ./extensions/ +FIREFOX_EXTENSION_NAME := pdf.js.xpi +CHROME_EXTENSION_NAME := pdf.js.crx # Let folks define custom rules for their clones. -include local.mk @@ -17,6 +18,7 @@ PDF_JS_FILES = \ fonts.js \ metrics.js \ charsets.js \ + cidmaps.js \ glyphlist.js \ $(NULL) @@ -92,7 +94,7 @@ browser-test: # # SRC_DIRS := . utils worker web test examples/helloworld extensions/firefox \ - extensions/firefox/components + extensions/firefox/components extensions/chrome GJSLINT_FILES = $(foreach DIR,$(SRC_DIRS),$(wildcard $(DIR)/*.js)) lint: gjslint $(GJSLINT_FILES) @@ -110,7 +112,8 @@ web: | extension compiler pages-repo \ $(addprefix $(GH_PAGES)/, $(PDF_JS_FILES)) \ $(addprefix $(GH_PAGES)/, $(wildcard web/*.*)) \ $(addprefix $(GH_PAGES)/, $(wildcard web/images/*.*)) \ - $(addprefix $(GH_PAGES)/, $(wildcard $(EXTENSION_SRC)/*.xpi)) + $(addprefix $(GH_PAGES)/, $(wildcard $(EXTENSION_SRC)/firefox/*.xpi)) \ + $(addprefix $(GH_PAGES)/, $(wildcard $(EXTENSION_SRC)/chrome/*.crx)) @cp $(GH_PAGES)/web/index.html.template $(GH_PAGES)/index.html; @cd $(GH_PAGES); git add -A; @@ -132,7 +135,8 @@ pages-repo: | $(BUILD_DIR) fi; @mkdir -p $(GH_PAGES)/web; @mkdir -p $(GH_PAGES)/web/images; - @mkdir -p $(GH_PAGES)/$(EXTENSION_SRC); + @mkdir -p $(GH_PAGES)/$(EXTENSION_SRC)/firefox; + @mkdir -p $(GH_PAGES)/$(EXTENSION_SRC)/chrome; $(GH_PAGES)/%.js: %.js @cp $< $@ @@ -143,9 +147,11 @@ $(GH_PAGES)/web/%: web/% $(GH_PAGES)/web/images/%: web/images/% @cp $< $@ -$(GH_PAGES)/$(EXTENSION_SRC)/%: $(EXTENSION_SRC)/% +$(GH_PAGES)/$(EXTENSION_SRC)/firefox/%: $(EXTENSION_SRC)/firefox/% @cp -R $< $@ +$(GH_PAGES)/$(EXTENSION_SRC)/chrome/%: $(EXTENSION_SRC)/chrome/% + # # make compiler # # # # This target downloads the Closure compiler, and places it in the @@ -163,7 +169,7 @@ $(GH_PAGES)/$(EXTENSION_SRC)/%: $(EXTENSION_SRC)/% # # This target produce a restartless firefox extension containing a # copy of the pdf.js source. -CONTENT_DIR := content +CONTENT_DIR := firefox/content PDF_WEB_FILES = \ web/images \ web/compatibility.js \ @@ -179,8 +185,17 @@ extension: @cp -r $(PDF_WEB_FILES) $(EXTENSION_SRC)/$(CONTENT_DIR)/web/ # Create the xpi - @cd $(EXTENSION_SRC); zip -r $(EXTENSION_NAME) * - @echo "extension created: " $(EXTENSION_NAME) + @cd $(EXTENSION_SRC)/firefox; zip -r $(FIREFOX_EXTENSION_NAME) * + @echo "extension created: " $(FIREFOX_EXTENSION_NAME) + + # Copy a standalone version of pdf.js inside the extension directory + @cp $(PDF_JS_FILES) $(EXTENSION_SRC)/chrome/ + @mkdir -p $(EXTENSION_SRC)/chrome/web + @cp -r $(PDF_WEB_FILES) $(EXTENSION_SRC)/chrome/web/ + + # Create the crx + #TODO + # Make sure there's a build directory. diff --git a/extensions/chrome/manifest.json b/extensions/chrome/manifest.json new file mode 100644 index 000000000..629e41b31 --- /dev/null +++ b/extensions/chrome/manifest.json @@ -0,0 +1,11 @@ +{ + "name": "uriloader@pdf.js", + "version": "0.1", + "description": "Read PDF Document", + "permissions": [ + "experimental", + "http://*/*.pdf", + "file:///*/*.pdf" + ], + "background_page": "pdfHandler.html" +} diff --git a/extensions/chrome/pdfHandler.html b/extensions/chrome/pdfHandler.html new file mode 100644 index 000000000..dcce1a665 --- /dev/null +++ b/extensions/chrome/pdfHandler.html @@ -0,0 +1,17 @@ + + + From a17b13019b17f71a55c47e829dbbc59b815eb158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionu=C8=9B=20G=2E=20Stan?= Date: Thu, 27 Oct 2011 02:47:18 +0300 Subject: [PATCH 02/66] Fix strict mode syntax error in Safari This happens in Safari 5.1 and Mobile Safari on iOS 5. Apparently, Safari considers the function name as part of the ECMA's FormalParameterList and applies the strict mode rules from section 13.1 of the specification. > It is a SyntaxError if any Identifier value occurs more than once > within a FormalParameterList of a strict mode > FunctionDeclaration or FunctionExpression. --- pdf.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pdf.js b/pdf.js index f45993210..05a21538d 100644 --- a/pdf.js +++ b/pdf.js @@ -7522,19 +7522,19 @@ var Promise = (function() { Promise.prototype = { hasData: false, - set data(data) { - if (data === undefined) { + set data(value) { + if (value === undefined) { return; } if (this._data !== EMPTY_PROMISE) { throw 'Promise ' + this.name + ': Cannot set the data of a promise twice'; } - this._data = data; + this._data = value; this.hasData = true; if (this.onDataCallback) { - this.onDataCallback(data); + this.onDataCallback(value); } }, From 56b9a3543dfd365fb065a85ac056d29064c72797 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionu=C8=9B=20G=2E=20Stan?= Date: Thu, 27 Oct 2011 03:08:11 +0300 Subject: [PATCH 03/66] Close path in `closeFillStroke` and `closeEOFillStroke` See Chapter 4, page 230, Table 4.10 of the PDF specification. --- pdf.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pdf.js b/pdf.js index 05a21538d..43df4a168 100644 --- a/pdf.js +++ b/pdf.js @@ -5643,10 +5643,12 @@ var CanvasGraphics = (function canvasGraphics() { this.restoreFillRule(savedFillRule); }, closeFillStroke: function canvasGraphicsCloseFillStroke() { - return this.fillStroke(); + this.closePath(); + this.fillStroke(); }, closeEOFillStroke: function canvasGraphicsCloseEOFillStroke() { var savedFillRule = this.setEOFillRule(); + this.closePath(); this.fillStroke(); this.restoreFillRule(savedFillRule); }, From 0c321466dce4377f58a038515260c66a0f74603b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionu=C8=9B=20G=2E=20Stan?= Date: Thu, 27 Oct 2011 05:45:10 +0300 Subject: [PATCH 04/66] Set DeviceGray as initial value for color space MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See the PDF reference, section 4.3 Graphics State, table 4.2, third row. > The current color space in which color values are to be interpreted > (see Section 4.5, “Color Spaces”). There are two separate color space > parameters: one for stroking and one for all other painting opera- > tions. Initial value: DeviceGray. The problem before was that certain PDFs didn't explicitly set the color space, so a call to `setFillColor` or `setStrokeColor` were failing when the `getRgb` method was call, as the color space was null. See source code of CanvasGraphics.prototype.setFillColor/setStrokeColor. --- pdf.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pdf.js b/pdf.js index 43df4a168..cb3ca3dc5 100644 --- a/pdf.js +++ b/pdf.js @@ -5344,6 +5344,9 @@ var CanvasExtraState = (function canvasExtraState() { this.strokeColor = '#000000'; this.old = old; + + this.fillColorSpace = new DeviceGrayCS; + this.strokeColorSpace = new DeviceGrayCS; } constructor.prototype = { From 009d6a8863fae350c8b95f1a6f0936f7b3fbf12d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionu=C8=9B=20G=2E=20Stan?= Date: Fri, 28 Oct 2011 14:27:41 +0300 Subject: [PATCH 05/66] Log error stacktrace only when available Safari does not provide a `stack` property on Error instances. --- pdf.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pdf.js b/pdf.js index cb3ca3dc5..4a8b9a091 100644 --- a/pdf.js +++ b/pdf.js @@ -22,16 +22,15 @@ function warn(msg) { } function backtrace() { - var stackStr; try { throw new Error(); } catch (e) { - stackStr = e.stack; + return e.stack ? e.stack.split('\n').slice(2).join('\n') : ""; } - return stackStr.split('\n').slice(1).join('\n'); } function error(msg) { + log("Error: " + msg); log(backtrace()); throw new Error(msg); } From 1e6d1f99221ff180ee8947dbb198f2119418b17d Mon Sep 17 00:00:00 2001 From: Julian Viereck Date: Fri, 28 Oct 2011 14:32:36 +0200 Subject: [PATCH 06/66] Make worker support work again after file split. Add PDFJS_WORKER_DIR/PDFJS_WORKER_FILE to specify where to load files if worker support is enabled --- examples/helloworld/hello.js | 2 +- examples/helloworld/index.html | 43 +++++++++++++++------------ src/core.js | 21 ++++++++++++- src/pdf.js | 1 - src/worker.js | 5 ++-- src/worker_loader.js | 54 ++++++++++++++++++++++------------ web/viewer-snippet.html | 5 ++++ web/viewer.html | 6 ++-- 8 files changed, 91 insertions(+), 46 deletions(-) diff --git a/examples/helloworld/hello.js b/examples/helloworld/hello.js index 45e61eb6f..c97b53c66 100644 --- a/examples/helloworld/hello.js +++ b/examples/helloworld/hello.js @@ -7,7 +7,7 @@ 'use strict'; -PDFJS.getPdf('helloworld.pdf', function getPdfHelloWorld(data) { +getPdf('helloworld.pdf', function getPdfHelloWorld(data) { // // Instantiate PDFDoc with PDF data // diff --git a/examples/helloworld/index.html b/examples/helloworld/index.html index b10e9eaeb..0fa711fe4 100644 --- a/examples/helloworld/index.html +++ b/examples/helloworld/index.html @@ -3,27 +3,32 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + diff --git a/src/core.js b/src/core.js index e7241acfa..8d3d6d434 100644 --- a/src/core.js +++ b/src/core.js @@ -471,7 +471,26 @@ var PDFDoc = (function() { this.pageCache = []; if (useWorker) { - var worker = new Worker('../src/worker_loader.js'); + var worker; + if (typeof PDFJS_WORKER_DIR !== 'undefined') { + // If `PDFJS_WORKER_DIR` is specified, we assume the pdf.js files + // located all in that directory. Create a new worker and tell him + // the directory, such that he can load the scripts from there. + worker = new Worker(PDFJS_WORKER_DIR + 'worker_loader.js'); + console.log('main: post dir'); + + worker.postMessage(PDFJS_WORKER_DIR); + } else if (typeof PDFJS_WORKER_FILE !== 'undefined') { + // If we build the worker using a worker file, then we assume, that + // everything the worker needs is already included in that file. + // Therefore the worker doesn't have to call `importScripts` to load + // all the single files and therefore it's not necessary to tell the + // worker a directory to laod the js files from. + // (Which is different from the PDFJS_WORKER_DIR case above.) + worker = new Worker(PDFJS_WORKER_FILE); + } else { + throw 'No worker file or directory specified.'; + } } else { // If we don't use a worker, just post/sendMessage to the main thread. var worker = { diff --git a/src/pdf.js b/src/pdf.js index 34e163967..2ecd2fddc 100644 --- a/src/pdf.js +++ b/src/pdf.js @@ -4,7 +4,6 @@ var PDFJS = {}; (function pdfjsWrapper() { - // Use strict in our context only - users might not want it 'use strict'; diff --git a/src/worker.js b/src/worker.js index a83f31668..5545fc459 100644 --- a/src/worker.js +++ b/src/worker.js @@ -174,10 +174,9 @@ var workerConsole = { // Worker thread? if (typeof window === 'undefined') { - globalScope.console = workerConsole; + this.console = workerConsole; - // Listen for messages from the main thread. - var handler = new MessageHandler('worker_processor', globalScope); + var handler = new MessageHandler('worker_processor', this); WorkerProcessorHandler.setup(handler); } diff --git a/src/worker_loader.js b/src/worker_loader.js index fb37ca9c4..69f7d55ba 100644 --- a/src/worker_loader.js +++ b/src/worker_loader.js @@ -3,22 +3,40 @@ 'use strict'; -importScripts('../src/core.js'); -importScripts('../src/util.js'); -importScripts('../src/canvas.js'); -importScripts('../src/obj.js'); -importScripts('../src/function.js'); -importScripts('../src/charsets.js'); -importScripts('../src/cidmaps.js'); -importScripts('../src/colorspace.js'); -importScripts('../src/crypto.js'); -importScripts('../src/evaluator.js'); -importScripts('../src/fonts.js'); -importScripts('../src/glyphlist.js'); -importScripts('../src/image.js'); -importScripts('../src/metrics.js'); -importScripts('../src/parser.js'); -importScripts('../src/pattern.js'); -importScripts('../src/stream.js'); -importScripts('../src/worker.js'); +this.onmessage = function(evt) { + // Reset the `onmessage` function as it was only set to call + // this function the first time a message is passed to the worker + // but shouldn't get called anytime afterwards. + delete this.onmessage; + // Directory the include files are contained is send as the + // first message to the worker. + var dir = evt.data; + + // List of files to include; + var files = [ + 'core.js', + 'util.js', + 'canvas.js', + 'obj.js', + 'function.js', + 'charsets.js', + 'cidmaps.js', + 'colorspace.js', + 'crypto.js', + 'evaluator.js', + 'fonts.js', + 'glyphlist.js', + 'image.js', + 'metrics.js', + 'parser.js', + 'pattern.js', + 'stream.js', + 'worker.js' + ]; + + // Load all the files. + for (var i = 0; i < files.length; i++) { + importScripts(dir + files[i]); + } +}.bind(this); diff --git a/web/viewer-snippet.html b/web/viewer-snippet.html index c99897a44..4d2a4f7b7 100644 --- a/web/viewer-snippet.html +++ b/web/viewer-snippet.html @@ -1,2 +1,7 @@ + diff --git a/web/viewer.html b/web/viewer.html index f7a5378ed..4505331d6 100644 --- a/web/viewer.html +++ b/web/viewer.html @@ -3,9 +3,9 @@ Simple pdf.js page viewer - + - + @@ -114,7 +114,7 @@ - +
Loading... 0%
From 8a6cf185fd71ea6132bc305ac8282141aab86914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionu=C8=9B=20G=2E=20Stan?= Date: Fri, 28 Oct 2011 16:38:55 +0300 Subject: [PATCH 07/66] Add eq test for close path rendering bug See: 56b9a3543dfd365fb065a85ac056d29064c72797 --- test/pdfs/.gitignore | 2 +- test/pdfs/close-path-bug.pdf | 69 ++++++++++++++++++++++++++++++++++++ test/test_manifest.json | 5 +++ 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 test/pdfs/close-path-bug.pdf diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index e7eb0da43..49267e36f 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -12,4 +12,4 @@ !rotation.pdf !simpletype3font.pdf !sizes.pdf - +!close-path-bug.pdf diff --git a/test/pdfs/close-path-bug.pdf b/test/pdfs/close-path-bug.pdf new file mode 100644 index 000000000..994d4e572 --- /dev/null +++ b/test/pdfs/close-path-bug.pdf @@ -0,0 +1,69 @@ +%PDF-1.4 +1 0 obj + <> +endobj + +2 0 obj + <> +endobj + +3 0 obj + <> +endobj + +4 0 obj + <>>> +endobj + +5 0 obj + << /Length 885 >> +stream + % Draw a black line segment, using the default line width. + 150 250 m + 150 350 l + S + + % Draw a thicker, dashed line segment. + 4 w % Set line width to 4 points + [4 6] 0 d % Set dash pattern to 4 units on, 6 units off + 150 250 m + 400 250 l + S + + [] 0 d % Reset dash pattern to a solid line + 1 w % Reset line width to 1 unit + + % Draw a rectangle with a 1−unit red border, filled with light blue. + 1.0 0.0 0.0 RG % Red for stroke color + 0.5 0.75 1.0 rg % Light blue for fill color + 200 300 50 75 re + B + + % Draw a curve filled with gray and with a colored border. + 0.5 0.1 0.2 RG + 0.7 g + 300 300 m + 300 400 400 400 400 300 c + b +endstream +endobj + +6 0 obj + [/PDF] +endobj + +xref +0 7 +0000000000 65535 f +0000000009 00000 n +0000000074 00000 n +0000000120 00000 n +0000000179 00000 n +0000000300 00000 n +0000001532 00000 n + +trailer + <> +startxref +1556 +%%EOF diff --git a/test/test_manifest.json b/test/test_manifest.json index d7ac34cef..4837dd2b7 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -217,5 +217,10 @@ "link": false, "rounds": 1, "type": "eq" + }, + { "id": "close-path-bug", + "file": "pdfs/close-path-bug.pdf", + "rounds": 1, + "type": "eq" } ] From 5cb64fbab7f20a53b48582be5a582f6df8e5f747 Mon Sep 17 00:00:00 2001 From: Brendan Dahl Date: Fri, 28 Oct 2011 14:10:10 -0700 Subject: [PATCH 08/66] Initial alpha transparency support. --- src/canvas.js | 54 ++++++++++++++++++--------------------- src/evaluator.js | 4 +-- test/pdfs/alphatrans.pdf | Bin 0 -> 16910 bytes 3 files changed, 27 insertions(+), 31 deletions(-) create mode 100644 test/pdfs/alphatrans.pdf diff --git a/src/canvas.js b/src/canvas.js index 70dd65e3d..3c7551404 100644 --- a/src/canvas.js +++ b/src/canvas.js @@ -28,6 +28,9 @@ var CanvasExtraState = (function canvasExtraState() { // Default fore and background colors this.fillColor = '#000000'; this.strokeColor = '#000000'; + // Note: fill alpha applies to all non-stroking operations + this.fillAlpha = 1; + this.strokeAlpha = 1; this.old = old; } @@ -206,6 +209,13 @@ var CanvasGraphics = (function canvasGraphics() { case 'Font': this.setFont(state[1], state[2]); break; + case 'CA': + this.current.strokeAlpha = state[1]; + break; + case 'ca': + this.current.fillAlpha = state[1]; + this.ctx.globalAlpha = state[1]; + break; } } }, @@ -254,9 +264,13 @@ var CanvasGraphics = (function canvasGraphics() { rectangle: function canvasGraphicsRectangle(x, y, width, height) { this.ctx.rect(x, y, width, height); }, - stroke: function canvasGraphicsStroke() { + stroke: function canvasGraphicsStroke(consumePath) { + consumePath = typeof consumePath !== 'undefined' ? consumePath : true; var ctx = this.ctx; var strokeColor = this.current.strokeColor; + // For stroke we want to temporarily change the global alpha to the + // stroking alpha. + ctx.globalAlpha = this.current.strokeAlpha; if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') { // for patterns, we transform to pattern space, calculate @@ -268,14 +282,17 @@ var CanvasGraphics = (function canvasGraphics() { } else { ctx.stroke(); } - - this.consumePath(); + if (consumePath) + this.consumePath(); + // Restore the global alpha to the fill alpha + ctx.globalAlpha = this.current.fillAlpha; }, closeStroke: function canvasGraphicsCloseStroke() { this.closePath(); this.stroke(); }, - fill: function canvasGraphicsFill() { + fill: function canvasGraphicsFill(consumePath) { + consumePath = typeof consumePath !== 'undefined' ? consumePath : true; var ctx = this.ctx; var fillColor = this.current.fillColor; @@ -288,8 +305,8 @@ var CanvasGraphics = (function canvasGraphics() { } else { ctx.fill(); } - - this.consumePath(); + if (consumePath) + this.consumePath(); }, eoFill: function canvasGraphicsEoFill() { var savedFillRule = this.setEOFillRule(); @@ -297,29 +314,8 @@ var CanvasGraphics = (function canvasGraphics() { this.restoreFillRule(savedFillRule); }, fillStroke: function canvasGraphicsFillStroke() { - var ctx = this.ctx; - - var fillColor = this.current.fillColor; - if (fillColor && fillColor.hasOwnProperty('type') && - fillColor.type === 'Pattern') { - ctx.save(); - ctx.fillStyle = fillColor.getPattern(ctx); - ctx.fill(); - ctx.restore(); - } else { - ctx.fill(); - } - - var strokeColor = this.current.strokeColor; - if (strokeColor && strokeColor.hasOwnProperty('type') && - strokeColor.type === 'Pattern') { - ctx.save(); - ctx.strokeStyle = strokeColor.getPattern(ctx); - ctx.stroke(); - ctx.restore(); - } else { - ctx.stroke(); - } + this.fill(false); + this.stroke(false); this.consumePath(); }, diff --git a/src/evaluator.js b/src/evaluator.js index 5007394b4..ea152717a 100644 --- a/src/evaluator.js +++ b/src/evaluator.js @@ -405,6 +405,8 @@ var PartialEvaluator = (function partialEvaluator() { case 'D': case 'RI': case 'FL': + case 'CA': + case 'ca': gsStateObj.push([key, value]); break; case 'Font': @@ -428,8 +430,6 @@ var PartialEvaluator = (function partialEvaluator() { case 'SA': case 'BM': case 'SMask': - case 'CA': - case 'ca': case 'AIS': case 'TK': TODO('graphic state operator ' + key); diff --git a/test/pdfs/alphatrans.pdf b/test/pdfs/alphatrans.pdf new file mode 100644 index 0000000000000000000000000000000000000000..6274ce3ac67ad08df9f2097455db2679230086f9 GIT binary patch literal 16910 zcmdUXc|4R~`~TRNiU=VxF|r#owjukz?^;k9W-yGIF*Ej1Dk1w?5(&{_&04f5OA>|b zO4g8yqDcJi8MHm0=lOho-|zGL<2Uni&wZbBo$H+II@fibb6>CbA!?;(AOn+CW)&SB z>*!)t1j~W(E}pDvYG9~cAOQ`AS|Q!3S0Wlm2E%}A8!*%iNg|u$Q5ZK28U+^DQ-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3#=%sA`6q32mkdtr$+JUpH2QZq5!jHZvNN8Y*~f3_m(_VVpTo7t1l(+80%^H z`eIP3Fc?Y&rsAe3|+2+_cK0U)k!1!zi* zt*Zyx8~LAGlBhHyzcvHroq#5i1OIbF!Y0+mn!%#>+h|oc*pmKJfT4y1;8YO_P1y^p z3vV5*+E_Ly3&2kqRB^x|3E&8lD;n5tX>2ZNzr_oHmTKlyJKU7~_g0k2{evrkh<3vS zXaH@0YqnYZ7Y#PV(%4v`DSPn^75~t&TZ`w$L~X3ye`_XNbGl`= zs=y8d?T#k~YG8n)ZbTdsSf?qL^sn`sI{6m{zpj|}_QrZ(7vS6u3fSZUVp2{B62ZWR z223KLU4bW8Fb3y}1iGPamGEw0Bp9_BjsEEOSGNDIYs#Ey{EQ!eaG=)yyQY3ftS{A- zGyos@qv6lGAFcne%&n#8mnqobv0>q=e@xgPt*J{ruyOg{+Vx)sHw+5;+fe?YT~p>9 zgZi!I-x@aH(!h%yFynvc*Z+SSvlWs^1_LI#Atq&kLm`QqD*E9b|JY1{00!)^e{-#W zXrRV`W4fb>e>DClM*5E<=)XAie>Ey-0}&5Jje7qzZ6dw@oQQv@OiDKB|6ff4i5%+N zA+Xf~W6^$S?0?TbU4OFvLqGp-HM)T6JN6NNNlu1}l&?M6gm)d>bFIlA@x#BG?VQRfa$SJSiVAZnF#~r=keR_FEb7vZ(+h z{eCM0{yl&akP!W?40xa<_x>nTkOOj{f0U^x07=l_%Ygqj@Go>QIVE6P{-A>^06DDR z%3yMe^8Z?<1iY*LNvA9iW5CzJ)chxqT?STJN3hz~n;PXsjq;vGc}@HEEluN} bkWh2)z;Z?;Q)eBfB(DNv6&2ODG+_Nd7c+O^ literal 0 HcmV?d00001 From 11b843325b6e3412e67bdd98f884cf8567744f0a Mon Sep 17 00:00:00 2001 From: Brendan Dahl Date: Fri, 28 Oct 2011 14:11:14 -0700 Subject: [PATCH 09/66] Add the alpha trans test pdf. --- test/pdfs/.gitignore | 1 + test/test_manifest.json | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index e7eb0da43..09618a7e6 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -12,4 +12,5 @@ !rotation.pdf !simpletype3font.pdf !sizes.pdf +!alphatrans.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index d7ac34cef..1d51c935f 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -217,5 +217,11 @@ "link": false, "rounds": 1, "type": "eq" + }, + { "id": "alphatrans", + "file": "pdfs/alphatrans.pdf", + "link": false, + "rounds": 1, + "type": "eq" } ] From 56789aea47efa22912034d4f337f14b23be23699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionu=C8=9B=20G=2E=20Stan?= Date: Sat, 29 Oct 2011 01:26:55 +0300 Subject: [PATCH 10/66] Fix lint errors Single quotes instead of double quotes --- src/util.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util.js b/src/util.js index 953732057..9765914ca 100644 --- a/src/util.js +++ b/src/util.js @@ -19,12 +19,12 @@ function backtrace() { try { throw new Error(); } catch (e) { - return e.stack ? e.stack.split('\n').slice(2).join('\n') : ""; + return e.stack ? e.stack.split('\n').slice(2).join('\n') : ''; } } function error(msg) { - log("Error: " + msg); + log('Error: ' + msg); log(backtrace()); throw new Error(msg); } From 7e762169cf183792e83a65c81ada5d0d2f74076a Mon Sep 17 00:00:00 2001 From: Kalervo Kujala Date: Sat, 29 Oct 2011 13:20:48 +0300 Subject: [PATCH 11/66] Name a few anonymous functions. Also rename some functions. --- src/pattern.js | 12 ++++++------ src/stream.js | 2 +- src/util.js | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/pattern.js b/src/pattern.js index 8e7760e51..2539a288e 100644 --- a/src/pattern.js +++ b/src/pattern.js @@ -43,7 +43,7 @@ var Shadings = {}; // Radial and axial shading have very similar implementations // If needed, the implementations can be broken into two classes -Shadings.RadialAxial = (function radialAxialShading() { +Shadings.RadialAxial = (function radialAxialShadings() { function constructor(dict, matrix, xref, res, ctx) { this.matrix = matrix; this.coordsArr = dict.get('Coords'); @@ -97,7 +97,7 @@ Shadings.RadialAxial = (function radialAxialShading() { this.colorStops = colorStops; } - constructor.fromIR = function(ctx, raw) { + constructor.fromIR = function radialAxialShadingsGetIR(ctx, raw) { var type = raw[1]; var colorStops = raw[2]; var p0 = raw[3]; @@ -129,7 +129,7 @@ Shadings.RadialAxial = (function radialAxialShading() { } constructor.prototype = { - getIR: function RadialAxialShading_getIR() { + getIR: function radialAxialShadingsGetIR() { var coordsArr = this.coordsArr; var type = this.shadingType; if (type == 2) { @@ -159,17 +159,17 @@ Shadings.RadialAxial = (function radialAxialShading() { return constructor; })(); -Shadings.Dummy = (function dummyShading() { +Shadings.Dummy = (function dummyShadings() { function constructor() { this.type = 'Pattern'; } - constructor.fromIR = function() { + constructor.fromIR = function dummyShadingsFromIR() { return 'hotpink'; } constructor.prototype = { - getIR: function dummpy_getir() { + getIR: function dummyShadingsGetIR() { return ['Dummy']; } }; diff --git a/src/stream.js b/src/stream.js index 2b10e2fbd..73b096f1e 100644 --- a/src/stream.js +++ b/src/stream.js @@ -801,7 +801,7 @@ var JpegStream = (function jpegStream() { } constructor.prototype = { - getIR: function() { + getIR: function jpegStreamGetIR() { return this.src; }, getChar: function jpegStreamGetChar() { diff --git a/src/util.js b/src/util.js index 9765914ca..41ae4cc96 100644 --- a/src/util.js +++ b/src/util.js @@ -197,7 +197,7 @@ function isPDFFunction(v) { * can be set. If any of these happens twice or the data is required before * it was set, an exception is throw. */ -var Promise = (function() { +var Promise = (function promise() { var EMPTY_PROMISE = {}; /** @@ -244,7 +244,7 @@ var Promise = (function() { return this._data; }, - onData: function(callback) { + onData: function promiseOnData(callback) { if (this._data !== EMPTY_PROMISE) { callback(this._data); } else { @@ -252,7 +252,7 @@ var Promise = (function() { } }, - resolve: function(data) { + resolve: function promiseResolve(data) { if (this.isResolved) { throw 'A Promise can be resolved only once ' + this.name; } @@ -266,7 +266,7 @@ var Promise = (function() { } }, - then: function(callback) { + then: function promiseThen(callback) { if (!callback) { throw 'Requiring callback' + this.name; } From 8a5516c96cddcb6f06e9a829e237a29c727c6f9e Mon Sep 17 00:00:00 2001 From: Kalervo Kujala Date: Sat, 29 Oct 2011 17:57:31 +0300 Subject: [PATCH 12/66] Rename Shanding related functions with better name names. --- src/pattern.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pattern.js b/src/pattern.js index 2539a288e..2a31fec4a 100644 --- a/src/pattern.js +++ b/src/pattern.js @@ -43,7 +43,7 @@ var Shadings = {}; // Radial and axial shading have very similar implementations // If needed, the implementations can be broken into two classes -Shadings.RadialAxial = (function radialAxialShadings() { +Shadings.RadialAxial = (function radialAxialShading() { function constructor(dict, matrix, xref, res, ctx) { this.matrix = matrix; this.coordsArr = dict.get('Coords'); @@ -97,7 +97,7 @@ Shadings.RadialAxial = (function radialAxialShadings() { this.colorStops = colorStops; } - constructor.fromIR = function radialAxialShadingsGetIR(ctx, raw) { + constructor.fromIR = function radialAxialShadingGetIR(ctx, raw) { var type = raw[1]; var colorStops = raw[2]; var p0 = raw[3]; @@ -129,7 +129,7 @@ Shadings.RadialAxial = (function radialAxialShadings() { } constructor.prototype = { - getIR: function radialAxialShadingsGetIR() { + getIR: function radialAxialShadingGetIR() { var coordsArr = this.coordsArr; var type = this.shadingType; if (type == 2) { @@ -159,17 +159,17 @@ Shadings.RadialAxial = (function radialAxialShadings() { return constructor; })(); -Shadings.Dummy = (function dummyShadings() { +Shadings.Dummy = (function dummyShading() { function constructor() { this.type = 'Pattern'; } - constructor.fromIR = function dummyShadingsFromIR() { + constructor.fromIR = function dummyShadingFromIR() { return 'hotpink'; } constructor.prototype = { - getIR: function dummyShadingsGetIR() { + getIR: function dummyShadingGetIR() { return ['Dummy']; } }; From b9748a91f1030ff37629cf987bdb617627c580d7 Mon Sep 17 00:00:00 2001 From: Kalervo Kujala Date: Sat, 29 Oct 2011 20:31:56 +0300 Subject: [PATCH 13/66] Name anonymous functions in obj.js. --- src/obj.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/obj.js b/src/obj.js index 8d5684ec2..fd1579280 100644 --- a/src/obj.js +++ b/src/obj.js @@ -642,7 +642,7 @@ var XRef = (function xRefXRef() { * inside of a worker. The `PDFObjects` implements some basic functions to * manage these objects. */ -var PDFObjects = (function() { +var PDFObjects = (function pdfObjects() { function PDFObjects() { this.objs = {}; } @@ -655,7 +655,7 @@ var PDFObjects = (function() { * Ensures there is an object defined for `objId`. Stores `data` on the * object *if* it is created. */ - ensureObj: function(objId, data) { + ensureObj: function pdfObjectsEnsureObj(objId, data) { if (this.objs[objId]) return this.objs[objId]; return this.objs[objId] = new Promise(objId, data); @@ -670,7 +670,7 @@ var PDFObjects = (function() { * function and the object is already resolved, the callback gets called * right away. */ - get: function(objId, callback) { + get: function pdfObjectsGet(objId, callback) { // If there is a callback, then the get can be async and the object is // not required to be resolved right now if (callback) { @@ -695,7 +695,7 @@ var PDFObjects = (function() { /** * Resolves the object `objId` with optional `data`. */ - resolve: function(objId, data) { + resolve: function pdfObjectsResolve(objId, data) { var objs = this.objs; // In case there is a promise already on this object, just resolve it. @@ -706,11 +706,11 @@ var PDFObjects = (function() { } }, - onData: function(objId, callback) { + onData: function pdfObjectsOnData(objId, callback) { this.ensureObj(objId).onData(callback); }, - isResolved: function(objId) { + isResolved: function pdfObjectsIsResolved(objId) { var objs = this.objs; if (!objs[objId]) { return false; @@ -719,7 +719,7 @@ var PDFObjects = (function() { } }, - hasData: function(objId) { + hasData: function pdfObjectsHasData(objId) { var objs = this.objs; if (!objs[objId]) { return false; @@ -731,7 +731,7 @@ var PDFObjects = (function() { /** * Sets the data of an object but *doesn't* resolve it. */ - setData: function(objId, data) { + setData: function pdfObjectsSetData(objId, data) { // Watchout! If you call `this.ensureObj(objId, data)` you're going to // create a *resolved* promise which shouldn't be the case! this.ensureObj(objId).data = data; From dc15019248d5fcfbf71099c77f1516d1e48ccffc Mon Sep 17 00:00:00 2001 From: Kalervo Kujala Date: Sat, 29 Oct 2011 20:59:49 +0300 Subject: [PATCH 14/66] Name anonymous funtions in function.js. --- src/function.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/function.js b/src/function.js index e2b191274..a8c797a29 100644 --- a/src/function.js +++ b/src/function.js @@ -3,14 +3,15 @@ 'use strict'; -var PDFFunction = (function() { +var PDFFunction = (function pdfFunction() { var CONSTRUCT_SAMPLED = 0; var CONSTRUCT_INTERPOLATED = 2; var CONSTRUCT_STICHED = 3; var CONSTRUCT_POSTSCRIPT = 4; return { - getSampleArray: function(size, outputSize, bps, str) { + getSampleArray: function pdfFunctionGetSampleArray(size, outputSize, bps, + str) { var length = 1; for (var i = 0; i < size.length; i++) length *= size[i]; @@ -35,7 +36,7 @@ var PDFFunction = (function() { return array; }, - getIR: function(xref, fn) { + getIR: function pdfFunctionGetIR(xref, fn) { var dict = fn.dict; if (!dict) dict = fn; @@ -54,7 +55,7 @@ var PDFFunction = (function() { return typeFn.call(this, fn, dict, xref); }, - fromIR: function(IR) { + fromIR: function pdfFunctionFromIR(IR) { var type = IR[0]; switch (type) { case CONSTRUCT_SAMPLED: @@ -69,12 +70,12 @@ var PDFFunction = (function() { } }, - parse: function(xref, fn) { + parse: function pdfFunctionParse(xref, fn) { var IR = this.getIR(xref, fn); return this.fromIR(IR); }, - constructSampled: function(str, dict) { + constructSampled: function pdfFunctionConstructSampled(str, dict) { var domain = dict.get('Domain'); var range = dict.get('Range'); @@ -116,7 +117,7 @@ var PDFFunction = (function() { ]; }, - constructSampledFromIR: function(IR) { + constructSampledFromIR: function pdfFunctionConstructSampledFromIR(IR) { var inputSize = IR[1]; var domain = IR[2]; var encode = IR[3]; @@ -127,8 +128,8 @@ var PDFFunction = (function() { var bps = IR[8]; var range = IR[9]; - return function(args) { - var clip = function(v, min, max) { + return function constructSampledFromIRResult(args) { + var clip = function constructSampledFromIRClip(v, min, max) { if (v > max) v = max; else if (v < min) @@ -212,7 +213,7 @@ var PDFFunction = (function() { var length = diff.length; - return function(args) { + return function constructInterpolatedFromIRResult(args) { var x = n == 1 ? args[0] : Math.pow(args[0], n); var out = []; @@ -257,8 +258,8 @@ var PDFFunction = (function() { fns.push(PDFFunction.fromIR(fnsIR[i])); } - return function(args) { - var clip = function(v, min, max) { + return function constructStichedFromIRResult(args) { + var clip = function constructStichedFromIRClip(v, min, max) { if (v > max) v = max; else if (v < min) @@ -298,7 +299,7 @@ var PDFFunction = (function() { constructPostScriptFromIR: function pdfFunctionConstructPostScriptFromIR() { TODO('unhandled type of function'); - return function() { + return function constructPostScriptFromIRResult() { return [255, 105, 180]; }; } From 0912959503cc566af7ac04f0d277931fb6647dea Mon Sep 17 00:00:00 2001 From: notmasteryet Date: Sat, 29 Oct 2011 16:00:13 -0500 Subject: [PATCH 15/66] Fixing 'compatibility.js' load order; add Object.keys emulation --- web/compatibility.js | 15 +++++++++++++++ web/viewer.html | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/web/compatibility.js b/web/compatibility.js index ad4c8f8a9..7d1d72553 100644 --- a/web/compatibility.js +++ b/web/compatibility.js @@ -83,6 +83,21 @@ }; })(); +// Object.keys() ? +(function checkObjectKeysCompatibility() { + if (typeof Object.keys !== 'undefined') + return; + + Object.keys = function objectKeys(obj) { + var result = []; + for (var i in obj) { + if (obj.hasOwnProperty(i)) + result.push(i); + } + return result; + }; +})(); + // No XMLHttpRequest.response ? (function checkXMLHttpRequestResponseCompatibility() { var xhrPrototype = XMLHttpRequest.prototype; diff --git a/web/viewer.html b/web/viewer.html index f7a5378ed..0c6ab385e 100644 --- a/web/viewer.html +++ b/web/viewer.html @@ -3,6 +3,7 @@ Simple pdf.js page viewer + @@ -25,7 +26,6 @@ - From ce3f9ae3e8134f33917740e38ad1a0fcc0641a20 Mon Sep 17 00:00:00 2001 From: Kalervo Kujala Date: Sun, 30 Oct 2011 12:41:55 +0200 Subject: [PATCH 16/66] Name anonymous functions in core.js. --- src/core.js | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/core.js b/src/core.js index e7241acfa..09d665972 100644 --- a/src/core.js +++ b/src/core.js @@ -153,7 +153,7 @@ var Page = (function pagePage() { return shadow(this, 'rotate', rotate); }, - startRenderingFromIRQueue: function startRenderingFromIRQueue( + startRenderingFromIRQueue: function pageStartRenderingFromIRQueue( IRQueue, fonts) { var self = this; this.IRQueue = IRQueue; @@ -173,12 +173,13 @@ var Page = (function pagePage() { }); }; - this.ensureFonts(fonts, function() { + this.ensureFonts(fonts, + function pageStartRenderingFromIRQueueEnsureFonts() { displayContinuation(); }); }, - getIRQueue: function(handler, dependency) { + getIRQueue: function pageGetIRQueue(handler, dependency) { if (this.IRQueue) { // content was compiled return this.IRQueue; @@ -202,7 +203,7 @@ var Page = (function pagePage() { content, resources, IRQueue, dependency); }, - ensureFonts: function(fonts, callback) { + ensureFonts: function pageEnsureFonts(fonts, callback) { // Convert the font names to the corresponding font obj. for (var i = 0; i < fonts.length; i++) { fonts[i] = this.objs.objs[fonts[i]].data; @@ -211,7 +212,7 @@ var Page = (function pagePage() { // Load all the fonts var fontObjs = FontLoader.bind( fonts, - function(fontObjs) { + function pageEnsureFontsFontObjs(fontObjs) { this.stats.fonts = Date.now(); callback.call(this); @@ -220,7 +221,7 @@ var Page = (function pagePage() { ); }, - display: function(gfx, callback) { + display: function pageDisplay(gfx, callback) { var xref = this.xref; var resources = xref.fetchIfRef(this.resources); var mediaBox = xref.fetchIfRef(this.mediaBox); @@ -305,7 +306,7 @@ var Page = (function pagePage() { } return links; }, - startRendering: function(ctx, callback) { + startRendering: function pageStartRendering(ctx, callback) { this.ctx = ctx; this.callback = callback; @@ -446,7 +447,7 @@ var PDFDocModel = (function pdfDoc() { return constructor; })(); -var PDFDoc = (function() { +var PDFDoc = (function pdfDoc() { function constructor(arg, callback) { var stream = null; var data = null; @@ -475,10 +476,10 @@ var PDFDoc = (function() { } else { // If we don't use a worker, just post/sendMessage to the main thread. var worker = { - postMessage: function(obj) { + postMessage: function pdfDocPostMessage(obj) { worker.onmessage({data: obj}); }, - terminate: function() {} + terminate: function pdfDocTerminate() {} }; } this.worker = worker; @@ -488,7 +489,7 @@ var PDFDoc = (function() { var processorHandler = this.processorHandler = new MessageHandler('main', worker); - processorHandler.on('page', function(data) { + processorHandler.on('page', function pdfDocPage(data) { var pageNum = data.pageNum; var page = this.pageCache[pageNum]; var depFonts = data.depFonts; @@ -496,7 +497,7 @@ var PDFDoc = (function() { page.startRenderingFromIRQueue(data.IRQueue, depFonts); }, this); - processorHandler.on('obj', function(data) { + processorHandler.on('obj', function pdfDocObj(data) { var id = data[0]; var type = data[1]; @@ -540,7 +541,7 @@ var PDFDoc = (function() { } }, this); - processorHandler.on('font_ready', function(data) { + processorHandler.on('font_ready', function pdfDocFontReady(data) { var id = data[0]; var font = new FontShape(data[1]); @@ -559,7 +560,7 @@ var PDFDoc = (function() { } this.workerReadyPromise = new Promise('workerReady'); - setTimeout(function() { + setTimeout(function pdfDocFontReadySetTimeout() { processorHandler.send('doc', this.data); this.workerReadyPromise.resolve(true); }.bind(this)); @@ -570,14 +571,14 @@ var PDFDoc = (function() { return this.pdf.numPages; }, - startRendering: function(page) { + startRendering: function pdfDocStartRendering(page) { // The worker might not be ready to receive the page request yet. - this.workerReadyPromise.then(function() { + this.workerReadyPromise.then(function pdfDocStartRenderingThen() { this.processorHandler.send('page_request', page.pageNumber + 1); }.bind(this)); }, - getPage: function(n) { + getPage: function pdfDocGetPage(n) { if (this.pageCache[n]) return this.pageCache[n]; @@ -589,7 +590,7 @@ var PDFDoc = (function() { return this.pageCache[n] = page; }, - destroy: function() { + destroy: function pdfDocDestroy() { if (this.worker) this.worker.terminate(); From 11098d66dc6868759940b99eb54ac90b463f175e Mon Sep 17 00:00:00 2001 From: Kalervo Kujala Date: Sun, 30 Oct 2011 13:07:38 +0200 Subject: [PATCH 17/66] Name anonymous functions in image.js. --- src/image.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/image.js b/src/image.js index b281e21c1..71aa0f113 100644 --- a/src/image.js +++ b/src/image.js @@ -229,12 +229,12 @@ var PDFImage = (function pdfImage() { return constructor; })(); -var JpegImage = (function() { +var JpegImage = (function jpegImage() { function JpegImage(objId, imageData, objs) { var src = 'data:image/jpeg;base64,' + window.btoa(imageData); var img = new Image(); - img.onload = (function() { + img.onload = (function jpegImageOnload() { this.loaded = true; objs.resolve(objId, this); @@ -247,7 +247,7 @@ var JpegImage = (function() { } JpegImage.prototype = { - getImage: function() { + getImage: function jpegImageGetImage() { return this.domImage; } }; From 8f3448e9a8cea057b775a00678d5758bf4fe42e1 Mon Sep 17 00:00:00 2001 From: Kalervo Kujala Date: Sun, 30 Oct 2011 13:44:10 +0200 Subject: [PATCH 18/66] Name anonymous functions in colorspace.js. --- src/colorspace.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/colorspace.js b/src/colorspace.js index 1c5c291f4..6bfad4c39 100644 --- a/src/colorspace.js +++ b/src/colorspace.js @@ -12,17 +12,17 @@ var ColorSpace = (function colorSpaceColorSpace() { constructor.prototype = { // Input: array of size numComps representing color component values // Output: array of rgb values, each value ranging from [0.1] - getRgb: function cs_getRgb(color) { + getRgb: function colorSpaceGetRgb(color) { error('Should not call ColorSpace.getRgb: ' + color); }, // Input: Uint8Array of component values, each value scaled to [0,255] // Output: Uint8Array of rgb values, each value scaled to [0,255] - getRgbBuffer: function cs_getRgbBuffer(input) { + getRgbBuffer: function colorSpaceGetRgbBuffer(input) { error('Should not call ColorSpace.getRgbBuffer: ' + input); } }; - constructor.parse = function colorspace_parse(cs, xref, res) { + constructor.parse = function colorSpaceParse(cs, xref, res) { var IR = constructor.parseToIR(cs, xref, res, true); if (IR instanceof SeparationCS) return IR; @@ -30,7 +30,7 @@ var ColorSpace = (function colorSpaceColorSpace() { return constructor.fromIR(IR); }; - constructor.fromIR = function(IR) { + constructor.fromIR = function colorSpaceFromIR(IR) { var name; if (isArray(IR)) { name = IR[0]; @@ -71,7 +71,8 @@ var ColorSpace = (function colorSpaceColorSpace() { return null; } - constructor.parseToIR = function colorspace_parse(cs, xref, res, parseOnly) { + constructor.parseToIR = function colorSpaceParseToIR(cs, xref, res, + parseOnly) { if (isName(cs)) { var colorSpaces = xref.fetchIfRef(res.get('ColorSpace')); if (isDict(colorSpaces)) { From a7690dea0a162738c9f458156343d45a054ab960 Mon Sep 17 00:00:00 2001 From: Kalervo Kujala Date: Sun, 30 Oct 2011 13:46:15 +0200 Subject: [PATCH 19/66] Name anonymous functions in canvas.js. --- src/canvas.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/canvas.js b/src/canvas.js index 23258b71f..d40368a9e 100644 --- a/src/canvas.js +++ b/src/canvas.js @@ -541,8 +541,7 @@ var CanvasGraphics = (function canvasGraphics() { }, // Color - setStrokeColorSpace: - function canvasGraphicsSetStrokeColorSpacefunction(raw) { + setStrokeColorSpace: function canvasGraphicsSetStrokeColorSpace(raw) { this.current.strokeColorSpace = ColorSpace.fromIR(raw); }, setFillColorSpace: function canvasGraphicsSetFillColorSpace(raw) { @@ -553,7 +552,7 @@ var CanvasGraphics = (function canvasGraphics() { var color = cs.getRgb(arguments); this.setStrokeRGBColor.apply(this, color); }, - getColorN_IR_Pattern: function(IR, cs) { + getColorN_IR_Pattern: function canvasGraphicsGetColorN_IR_Pattern(IR, cs) { if (IR[0] == 'TilingPattern') { var args = IR[1]; var base = cs.base; @@ -669,8 +668,8 @@ var CanvasGraphics = (function canvasGraphics() { error('Should not call beginImageData'); }, - paintFormXObjectBegin: - function canvasGraphicsPaintFormXObject(matrix, bbox) { + paintFormXObjectBegin: function canvasGraphicsPaintFormXObjectBegin(matrix, + bbox) { this.save(); if (matrix && isArray(matrix) && 6 == matrix.length) @@ -685,11 +684,11 @@ var CanvasGraphics = (function canvasGraphics() { } }, - paintFormXObjectEnd: function() { + paintFormXObjectEnd: function canvasGraphicsPaintFormXObjectEnd() { this.restore(); }, - paintJpegXObject: function(objId, w, h) { + paintJpegXObject: function canvasGraphicsPaintJpegXObject(objId, w, h) { var image = this.objs.get(objId); if (!image) { error('Dependent image isn\'t ready yet'); @@ -708,7 +707,8 @@ var CanvasGraphics = (function canvasGraphics() { this.restore(); }, - paintImageMaskXObject: function(imgArray, inverseDecode, width, height) { + paintImageMaskXObject: function canvasGraphicsPaintImageMaskXObject( + imgArray, inverseDecode, width, height) { function applyStencilMask(buffer, inverseDecode) { var imgArrayPos = 0; var i, j, mask, buf; @@ -756,7 +756,7 @@ var CanvasGraphics = (function canvasGraphics() { this.restore(); }, - paintImageXObject: function(imgData) { + paintImageXObject: function canvasGraphicsPaintImageXObject(imgData) { this.save(); var ctx = this.ctx; var w = imgData.width; From 0331847927a26449555843339a9c7060941563d8 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas <21@vingtetun.org> Date: Mon, 31 Oct 2011 13:18:30 +0100 Subject: [PATCH 20/66] Add support for disabling the firefox extension on the fly --- extensions/firefox/bootstrap.js | 18 ++++++++++++++---- .../firefox/components/pdfContentHandler.js | 3 +++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/extensions/firefox/bootstrap.js b/extensions/firefox/bootstrap.js index 5384a05df..e51df28f8 100644 --- a/extensions/firefox/bootstrap.js +++ b/extensions/firefox/bootstrap.js @@ -16,21 +16,31 @@ function log(str) { function startup(aData, aReason) { let manifestPath = 'chrome.manifest'; - let file = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsILocalFile); + let manifest = Cc['@mozilla.org/file/local;1'] + .createInstance(Ci.nsILocalFile); try { - file.initWithPath(aData.installPath.path); - file.append(manifestPath); - Cm.QueryInterface(Ci.nsIComponentRegistrar).autoRegister(file); + manifest.initWithPath(aData.installPath.path); + manifest.append(manifestPath); + Cm.QueryInterface(Ci.nsIComponentRegistrar).autoRegister(manifest); + Services.prefs.setBoolPref('extensions.pdf.js.active', true); } catch (e) { log(e); } } function shutdown(aData, aReason) { + if (Services.prefs.getBoolPref('extensions.pdf.js.active')) + Services.prefs.setBoolPref('extensions.pdf.js.active', false); } function install(aData, aReason) { let url = 'chrome://pdf.js/content/web/viewer.html?file=%s'; Services.prefs.setCharPref('extensions.pdf.js.url', url); + Services.prefs.setBoolPref('extensions.pdf.js.active', false); +} + +function uninstall(aData, aReason) { + Services.prefs.clearUserPref('extensions.pdf.js.url'); + Services.prefs.clearUserPref('extensions.pdf.js.active'); } diff --git a/extensions/firefox/components/pdfContentHandler.js b/extensions/firefox/components/pdfContentHandler.js index 7746e41b6..a23461085 100644 --- a/extensions/firefox/components/pdfContentHandler.js +++ b/extensions/firefox/components/pdfContentHandler.js @@ -32,6 +32,9 @@ pdfContentHandler.prototype = { if (!(aRequest instanceof Ci.nsIChannel)) throw NS_ERROR_WONT_HANDLE_CONTENT; + if (!Services.prefs.getBoolPref('extensions.pdf.js.active')) + throw NS_ERROR_WONT_HANDLE_CONTENT; + let window = null; let callbacks = aRequest.notificationCallbacks || aRequest.loadGroup.notificationCallbacks; From 0d02ab5098f3b3ae92ea710d27a43b2ad2132605 Mon Sep 17 00:00:00 2001 From: gigaherz Date: Mon, 31 Oct 2011 20:44:29 +0100 Subject: [PATCH 21/66] The extension should urlencode the pdf when sending it over to the viewer. --- extensions/firefox/components/pdfContentHandler.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extensions/firefox/components/pdfContentHandler.js b/extensions/firefox/components/pdfContentHandler.js index a23461085..5f659bd9c 100644 --- a/extensions/firefox/components/pdfContentHandler.js +++ b/extensions/firefox/components/pdfContentHandler.js @@ -56,7 +56,8 @@ pdfContentHandler.prototype = { throw NS_ERROR_WONT_HANDLE_CONTENT; aRequest.cancel(Cr.NS_BINDING_ABORTED); - window.location = url.replace('%s', targetUrl); + aRequest.cancel(Cr.NS_BINDING_ABORTED); + window.location = url.replace('%s', encodeURIComponent(targetUrl)); }, classID: Components.ID('{2278dfd0-b75c-11e0-8257-1ba3d93c9f1a}'), From 2d8b0f767752f70568d35afa30c4f3d1b0205030 Mon Sep 17 00:00:00 2001 From: gigaherz Date: Mon, 31 Oct 2011 21:18:41 +0100 Subject: [PATCH 22/66] Properly fix the previous commit. --- extensions/firefox/components/pdfContentHandler.js | 1 - 1 file changed, 1 deletion(-) diff --git a/extensions/firefox/components/pdfContentHandler.js b/extensions/firefox/components/pdfContentHandler.js index 5f659bd9c..444db1c1f 100644 --- a/extensions/firefox/components/pdfContentHandler.js +++ b/extensions/firefox/components/pdfContentHandler.js @@ -55,7 +55,6 @@ pdfContentHandler.prototype = { if (targetUrl.indexOf('?pdfjs.action=download') >= 0) throw NS_ERROR_WONT_HANDLE_CONTENT; - aRequest.cancel(Cr.NS_BINDING_ABORTED); aRequest.cancel(Cr.NS_BINDING_ABORTED); window.location = url.replace('%s', encodeURIComponent(targetUrl)); }, From 46c0f6c23ec6b117a7272100d8e11bc8f57fa7b2 Mon Sep 17 00:00:00 2001 From: Alex Cornejo Date: Mon, 31 Oct 2011 18:23:03 -0400 Subject: [PATCH 23/66] Slimmed down toolbar height, from 40 to 24px. This matches the height of the regular Firefox toolbars, 40px takes too much screenspace, and (in my opinion) unecessarily so, since the fonts are not even larger. --- web/viewer.css | 17 +++++++++-------- web/viewer.html | 20 ++++++++++---------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/web/viewer.css b/web/viewer.css index 27ad0638a..c379e91c4 100644 --- a/web/viewer.css +++ b/web/viewer.css @@ -18,11 +18,11 @@ body { background: -moz-linear-gradient(center bottom, #eee 0%, #fff 100%); background: -webkit-gradient(linear, left bottom, left top, color-stop(0.0, #ddd), color-stop(1.0, #fff)); border-bottom: 1px solid #666; - padding: 4px; + padding: 3px; position: fixed; left: 0px; top: 0px; - height: 40px; + height: 24px; width: 100%; z-index: 1; white-space:nowrap; @@ -33,22 +33,23 @@ body { display: inline; border-left: 1px solid #d3d3d3; border-right: 1px solid #fff; - height: 32px; + height: 16px; width:0px; margin: 4px; } #controls > a > img { - margin: 2px; + margin: 4px; + height: 16px; } #controls > button { - line-height: 32px; + line-height: 16px; } #controls > button > img { - width: 32px; - height: 32px; + width: 16px; + height: 16px; } #controls > button[disabled] > img { @@ -60,7 +61,7 @@ body { } #fileInput { - line-height: 32px; + line-height: 16px; } span#info { diff --git a/web/viewer.html b/web/viewer.html index 0c6ab385e..f329d3438 100644 --- a/web/viewer.html +++ b/web/viewer.html @@ -32,12 +32,12 @@
From 1f80b0b26692617a72eae44fcd42f007dd964fa8 Mon Sep 17 00:00:00 2001 From: Artur Adib Date: Tue, 1 Nov 2011 08:46:39 -0400 Subject: [PATCH 24/66] Replace andreasgal/pdf.js --> mozilla/pdf.js --- Makefile | 2 +- README.md | 10 +++++----- extensions/firefox/install.rdf | 2 +- web/index.html.template | 18 +++++++++--------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 80003bdf6..3484ab414 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -REPO = git@github.com:andreasgal/pdf.js.git +REPO = git@github.com:mozilla/pdf.js.git BUILD_DIR := build BUILD_TARGET := $(BUILD_DIR)/pdf.js DEFAULT_BROWSERS := resources/browser_manifests/browser_manifest.json diff --git a/README.md b/README.md index 42669da28..d6d2d886d 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ However, note that the extension might not reflect the latest source in our mast To get a local copy of the current code, clone it using git: - $ git clone git://github.com/andreasgal/pdf.js.git pdfjs + $ git clone git://github.com/mozilla/pdf.js.git pdfjs $ cd pdfjs Next, you need to start a local web server as some browsers don't allow opening @@ -73,7 +73,7 @@ Additional resources are available in a separate section below. For a "hello world" example, take a look at: -+ [examples/helloworld/hello.js](https://github.com/andreasgal/pdf.js/blob/master/examples/helloworld/hello.js) ++ [examples/helloworld/hello.js](https://github.com/mozilla/pdf.js/blob/master/examples/helloworld/hello.js) This example illustrates the bare minimum ingredients for integrating pdf.js in a custom project. @@ -92,10 +92,10 @@ workings of PDF and pdf.js: pdf.js is a community-driven project, so contributors are always welcome. Simply fork our repo and contribute away. A great place to start is our -[open issues](https://github.com/andreasgal/pdf.js/issues). For better consistency and +[open issues](https://github.com/mozilla/pdf.js/issues). For better consistency and long-term stability, please do look around the code and try to follow our conventions. More information about the contributor process can be found on the -[contributor wiki page](https://github.com/andreasgal/pdf.js/wiki/Contributing). +[contributor wiki page](https://github.com/mozilla/pdf.js/wiki/Contributing). If you don't want to hack on the project or have little spare time, __you still can help!__ Just open PDFs in the @@ -104,7 +104,7 @@ any breakage in rendering. Our Github contributors so far: -+ https://github.com/andreasgal/pdf.js/contributors ++ https://github.com/mozilla/pdf.js/contributors You can add your name to it! :) diff --git a/extensions/firefox/install.rdf b/extensions/firefox/install.rdf index 0dfd6bf57..26b2192b6 100644 --- a/extensions/firefox/install.rdf +++ b/extensions/firefox/install.rdf @@ -19,6 +19,6 @@ true Vivien Nicolas pdf.js uri loader - https://github.com/andreasgal/pdf.js/ + https://github.com/mozilla/pdf.js/ diff --git a/web/index.html.template b/web/index.html.template index 12e606371..44e9a0cbe 100644 --- a/web/index.html.template +++ b/web/index.html.template @@ -3,7 +3,7 @@ - andreasgal/pdf.js @ GitHub + mozilla/pdf.js @ GitHub - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/web/viewer-snippet.html b/web/viewer-snippet.html index 4d2a4f7b7..6b0c8821b 100644 --- a/web/viewer-snippet.html +++ b/web/viewer-snippet.html @@ -1,7 +1,6 @@ diff --git a/web/viewer.html b/web/viewer.html index 4505331d6..7dd81e0af 100644 --- a/web/viewer.html +++ b/web/viewer.html @@ -5,7 +5,6 @@ - @@ -25,6 +24,8 @@ + + From 51d4a1723210359abfed47332d3d0352d4f9d7f4 Mon Sep 17 00:00:00 2001 From: Julian Viereck Date: Tue, 1 Nov 2011 22:23:16 +0100 Subject: [PATCH 29/66] Change workerSrc location --- src/core.js | 2 +- web/viewer.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core.js b/src/core.js index 2bc4c50aa..5685cdf31 100644 --- a/src/core.js +++ b/src/core.js @@ -7,7 +7,7 @@ var globalScope = (typeof window === 'undefined') ? this : window; var ERRORS = 0, WARNINGS = 1, TODOS = 5; var verbosity = WARNINGS; -var useWorker = false; +var useWorker = true; // The global PDFJS object exposes the API // In production, it will be declared outside a global wrapper diff --git a/web/viewer.html b/web/viewer.html index 60eab8eab..3883804f0 100644 --- a/web/viewer.html +++ b/web/viewer.html @@ -26,7 +26,7 @@ - + From 090b4d6647c08f9b2a962966c892b84ef05fdd41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionu=C8=9B=20G=2E=20Stan?= Date: Wed, 2 Nov 2011 12:47:41 +0200 Subject: [PATCH 30/66] Fix same origin policy issue when adding @font-face rules If the first stylesheet in the document is located on an external domain, then trying to access the `cssRules` property of that `CSSStyleSheet` object will result in a Security error being thrown in Firefox. In Safari, `cssRules` will be null, which causes a null pointer exception in the `styleSheet.cssRules.length` expression. --- src/fonts.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/fonts.js b/src/fonts.js index b027b766a..f4f71c4f6 100644 --- a/src/fonts.js +++ b/src/fonts.js @@ -1787,12 +1787,11 @@ var Font = (function Font() { var url = ('url(data:' + this.mimetype + ';base64,' + window.btoa(data) + ');'); var rule = "@font-face { font-family:'" + fontName + "';src:" + url + '}'; - var styleSheet = document.styleSheets[0]; - if (!styleSheet) { - document.documentElement.firstChild.appendChild( - document.createElement('style')); - styleSheet = document.styleSheets[0]; - } + + document.documentElement.firstChild.appendChild( + document.createElement('style')); + + var styleSheet = document.styleSheets[document.styleSheets.length - 1]; styleSheet.insertRule(rule, styleSheet.cssRules.length); return rule; From c8c5b4f8eac55d850effccb2e6a366a16d0be386 Mon Sep 17 00:00:00 2001 From: Artur Adib Date: Wed, 2 Nov 2011 14:43:27 -0400 Subject: [PATCH 31/66] First iteration, tracemonkey/ecma262 working --- src/canvas.js | 4 +-- src/core.js | 2 +- src/fonts.js | 79 ++++++++++++++++++++++++++------------------------- 3 files changed, 43 insertions(+), 42 deletions(-) diff --git a/src/canvas.js b/src/canvas.js index 474cc250f..1aeb851df 100644 --- a/src/canvas.js +++ b/src/canvas.js @@ -125,7 +125,7 @@ var CanvasGraphics = (function canvasGraphics() { this[fnArray[i]].apply(this, argsArray[i]); } else { var deps = argsArray[i]; - for (var n = 0; n < deps.length; n++) { + for (var n = 0, depsLength = deps.length; n < depsLength; n++) { var depObjId = deps[n]; // If the promise isn't resolved yet, add the continueCallback @@ -184,7 +184,7 @@ var CanvasGraphics = (function canvasGraphics() { TODO('set flatness: ' + flatness); }, setGState: function canvasGraphicsSetGState(states) { - for (var i = 0; i < states.length; i++) { + for (var i = 0, statesLength = states.length; i < statesLength; i++) { var state = states[i]; var key = state[0]; var value = state[1]; diff --git a/src/core.js b/src/core.js index 09d665972..112883ba2 100644 --- a/src/core.js +++ b/src/core.js @@ -205,7 +205,7 @@ var Page = (function pagePage() { ensureFonts: function pageEnsureFonts(fonts, callback) { // Convert the font names to the corresponding font obj. - for (var i = 0; i < fonts.length; i++) { + for (var i = 0, fontsLength = fonts.length; i < fontsLength; i++) { fonts[i] = this.objs.objs[fonts[i]].data; } diff --git a/src/fonts.js b/src/fonts.js index b027b766a..7c753deb2 100644 --- a/src/fonts.js +++ b/src/fonts.js @@ -393,7 +393,7 @@ var FontLoader = { bind: function fontLoaderBind(fonts, callback) { function checkFontsLoaded() { - for (var i = 0; i < objs.length; i++) { + for (var i = 0, objsLength = objs.length; i < objsLength; i++) { var fontObj = objs[i]; if (fontObj.loading) { return false; @@ -409,7 +409,7 @@ var FontLoader = { var rules = [], names = [], objs = []; - for (var i = 0; i < fonts.length; i++) { + for (var i = 0, fontsLength = fonts.length; i < fontsLength; i++) { var font = fonts[i]; // If there is already a fontObj on the font, then it was loaded/attached @@ -490,7 +490,7 @@ var FontLoader = { 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;'); var html = ''; - for (var i = 0; i < names.length; ++i) { + for (var i = 0, namesLength = names.length; i < namesLength; ++i) { html += 'Hi'; } div.innerHTML = html; @@ -501,7 +501,7 @@ var FontLoader = { 'message', function fontLoaderMessage(e) { var fontNames = JSON.parse(e.data); - for (var i = 0; i < objs.length; ++i) { + for (var i = 0, objsLength = objs.length; i < objsLength; ++i) { var font = objs[i]; font.loading = false; } @@ -517,13 +517,13 @@ var FontLoader = { // pdfjsFontLoadFailed? var src = ''; src += ''; src += ''; - for (var i = 0; i < names.length; ++i) { + for (var i = 0, namesLength = names.length; i < namesLength; ++i) { src += '

Hi

'; } src += ''; @@ -673,7 +673,7 @@ var UnicodeRanges = [ ]; function getUnicodeRangeFor(value) { - for (var i = 0; i < UnicodeRanges.length; i++) { + for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) { var range = UnicodeRanges[i]; if (value >= range.begin && value < range.end) return i; @@ -782,7 +782,7 @@ var Font = (function Font() { function stringToArray(str) { var array = []; - for (var i = 0; i < str.length; ++i) + for (var i = 0, strLength = str.length; i < strLength; ++i) array[i] = str.charCodeAt(i); return array; @@ -790,7 +790,7 @@ var Font = (function Font() { function arrayToString(arr) { var str = ''; - for (var i = 0; i < arr.length; ++i) + for (var i = 0, arrLength = arr.length; i < arrLength; ++i) str += String.fromCharCode(arr[i]); return str; @@ -1116,11 +1116,11 @@ var Font = (function Font() { // Mac want 1-byte per character strings while Windows want // 2-bytes per character, so duplicate the names table var stringsUnicode = []; - for (var i = 0; i < strings.length; i++) { + for (var i = 0, stringsLength = strings.length; i < stringsLength; i++) { var str = strings[i]; var strUnicode = ''; - for (var j = 0; j < str.length; j++) + for (var j = 0, strLength = str.length; j < strLength; j++) strUnicode += string16(str.charCodeAt(j)); stringsUnicode.push(strUnicode); } @@ -1138,9 +1138,9 @@ var Font = (function Font() { // Build the name records field var strOffset = 0; - for (var i = 0; i < platforms.length; i++) { + for (var i = 0, platfLength = platforms.length; i < platfLength; i++) { var strs = names[i]; - for (var j = 0; j < strs.length; j++) { + for (var j = 0, strsLength = strs.length; j < strsLength; j++) { var str = strs[j]; var nameRecord = platforms[i] + // platform ID @@ -1258,7 +1258,7 @@ var Font = (function Font() { string32(table.offset); } - for (var i = 0; i < data.length; i++) + for (var i = 0, dataLength = data.length; i < dataLength; i++) cmap.data[i] = data.charCodeAt(i); } @@ -1345,7 +1345,7 @@ var Font = (function Font() { if (numMissing > 0) { font.pos = (font.start ? font.start : 0) + metrics.offset; var entries = ''; - for (var i = 0; i < hmtx.length; i++) + for (var i = 0, hmtxLength = hmtx.length; i < hmtxLength; i++) entries += String.fromCharCode(font.getByte()); for (var i = 0; i < numMissing; i++) entries += '\x00\x00'; @@ -1549,18 +1549,18 @@ var Font = (function Font() { }); // rewrite the tables but tweak offsets - for (var i = 0; i < tables.length; i++) { + for (var i = 0, tablesLength = tables.length; i < tablesLength; i++) { var table = tables[i]; var data = []; var tableData = table.data; - for (var j = 0; j < tableData.length; j++) + for (var j = 0, dataLength = tableData.length; j < dataLength; j++) data.push(tableData[j]); createTableEntry(ttf, table.tag, data); } // Add the table datas - for (var i = 0; i < tables.length; i++) { + for (var i = 0, tablesLength = tables.length; i < tablesLength; i++) { var table = tables[i]; var tableData = table.data; ttf.file += arrayToString(tableData); @@ -1575,7 +1575,7 @@ var Font = (function Font() { convert: function font_convert(fontName, font, properties) { function isFixedPitch(glyphs) { - for (var i = 0; i < glyphs.length - 1; i++) { + for (var i = 0, glyphsMax = glyphs.length - 1; i < glyphsMax; i++) { if (glyphs[i] != glyphs[i + 1]) return false; } @@ -1657,7 +1657,7 @@ var Font = (function Font() { // Horizontal metrics 'hmtx': (function fontFieldsHmtx() { var hmtx = '\x00\x00\x00\x00'; // Fake .notdef - for (var i = 0; i < charstrings.length; i++) { + for (var i = 0, cstrMax = charstrings.length; i < cstrMax; i++) { hmtx += string16(charstrings[i].width) + string16(0); } return stringToArray(hmtx); @@ -1729,8 +1729,8 @@ var Font = (function Font() { } encoding[0] = { unicode: 0, width: 0 }; - var glyph = 1, i, j, k; - for (i = 0; i < cidToUnicode.length; ++i) { + var glyph = 1, i, j, k, cidLength; + for (i = 0, cidLength = cidToUnicode.length; i < cidLength; ++i) { var unicode = cidToUnicode[i]; var width; if (isArray(unicode)) { @@ -1844,7 +1844,7 @@ var Font = (function Font() { } } else { - for (var i = 0; i < chars.length; ++i) { + for (var i = 0, charsLength = chars.length; i < charsLength; ++i) { var charcode = chars.charCodeAt(i); var glyph = encoding[charcode]; if ('undefined' == typeof(glyph)) { @@ -2142,7 +2142,7 @@ var Type1Parser = function type1Parser() { count++; var array = str.substr(start, count).split(' '); - for (var i = 0; i < array.length; i++) + for (var i = 0, arrayLength = array.length; i < arrayLength; i++) array[i] = parseFloat(array[i] || 0); return array; } @@ -2167,7 +2167,7 @@ var Type1Parser = function type1Parser() { this.extractFontProgram = function t1_extractFontProgram(stream) { var eexec = decrypt(stream, kEexecEncryptionKey, 4); var eexecStr = ''; - for (var i = 0; i < eexec.length; i++) + for (var i = 0, eexecLength = eexec.length; i < eexecLength; i++) eexecStr += String.fromCharCode(eexec[i]); var glyphsSection = false, subrsSection = false; @@ -2291,7 +2291,7 @@ var Type1Parser = function type1Parser() { this.extractFontHeader = function t1_extractFontHeader(stream, properties) { var headerString = ''; - for (var i = 0; i < stream.length; i++) + for (var i = 0, streamLength = stream.length; i < streamLength; i++) headerString += String.fromCharCode(stream[i]); var token = ''; @@ -2318,7 +2318,7 @@ var Type1Parser = function type1Parser() { var matrix = readNumberArray(headerString, i + 1); // The FontMatrix is in unitPerEm, so make it pixels - for (var j = 0; j < matrix.length; j++) + for (var j = 0, matLength = matrix.length; j < matLength; j++) matrix[j] *= 1000; // Make the angle into the right direction @@ -2479,7 +2479,7 @@ CFF.prototype = { } for (var i = 0; i < count; i++) { - for (var j = 0; j < objects[i].length; j++) + for (var j = 0, objLength = objects[i].length; j < objLength; j++) data += isByte ? String.fromCharCode(objects[i][j] & 0xFF) : objects[i][j]; } @@ -2507,7 +2507,7 @@ CFF.prototype = { var charstrings = []; var missings = []; - for (var i = 0; i < glyphs.length; i++) { + for (var i = 0, glLength = glyphs.length; i < glLength; i++) { var glyph = glyphs[i]; var mapping = properties.glyphs[glyph.glyph]; if (!mapping) { @@ -2597,6 +2597,7 @@ CFF.prototype = { }, flattenCharstring: function flattenCharstring(charstring, map) { + // charstring changes size - can't cache .length in loop for (var i = 0; i < charstring.length; i++) { var command = charstring[i]; if (command.charAt) { @@ -2641,7 +2642,7 @@ CFF.prototype = { '\x1c\x00\x00\x10'; // Encoding var boundingBox = properties.bbox; - for (var i = 0; i < boundingBox.length; i++) + for (var i = 0, boxLength = boundingBox.length; i < boxLength; i++) dict += self.encodeNumber(boundingBox[i]); dict += '\x05'; // FontBBox; @@ -2731,7 +2732,7 @@ CFF.prototype = { if (isArray(value)) { data += self.encodeNumber(value[0]); - for (var i = 1; i < value.length; i++) + for (var i = 1, valLength = value.length; i < valLength; i++) data += self.encodeNumber(value[i] - value[i - 1]); } else { data += self.encodeNumber(value); @@ -2752,7 +2753,7 @@ CFF.prototype = { var cff = []; for (var index in fields) { var field = fields[index]; - for (var i = 0; i < field.length; i++) + for (var i = 0, fLength = field.length; i < fLength; i++) cff.push(field.charCodeAt(i)); } @@ -2849,7 +2850,7 @@ var Type2CFF = (function type2CFF() { // create the mapping between charstring and glyph id var glyphIds = []; - for (var i = 0; i < charstrings.length; i++) + for (var i = 0, cstrLength = charstrings.length; i < cstrLength; i++) glyphIds.push(charstrings[i].gid); this.charstrings = charstrings; @@ -2867,7 +2868,7 @@ var Type2CFF = (function type2CFF() { var charstrings = []; var firstChar = properties.firstChar; var glyphMap = {}; - for (var i = 0; i < charsets.length; i++) { + for (var i = 0, csetLength = charsets.length; i < csetLength; i++) { var glyph = charsets[i]; for (var charcode in encoding) { if (encoding[charcode] == i) @@ -2876,7 +2877,7 @@ var Type2CFF = (function type2CFF() { } var differences = properties.differences; - for (var i = 0; i < differences.length; ++i) { + for (var i = 0, diffLength = differences.length; i < diffLength; ++i) { var glyph = differences[i]; if (!glyph) continue; @@ -2887,7 +2888,7 @@ var Type2CFF = (function type2CFF() { } var glyphs = properties.glyphs; - for (var i = 1; i < charsets.length; i++) { + for (var i = 1, csetLength = charsets.length; i < csetLength; i++) { var glyph = charsets[i]; var code = glyphMap[glyph] || 0; @@ -2921,7 +2922,7 @@ var Type2CFF = (function type2CFF() { // properties.glyphs[code] || properties.glyphs[glyph] var nextUnusedUnicode = kCmapGlyphOffset + 0x0020; var lastUnicode = charstrings[0].unicode, wasModified = false; - for (var i = 1; i < charstrings.length; ++i) { + for (var i = 1, cstrLength = charstrings.length; i < cstrLength; ++i) { if (lastUnicode != charstrings[i].unicode) { lastUnicode = charstrings[i].unicode; continue; @@ -2966,7 +2967,7 @@ var Type2CFF = (function type2CFF() { var gid = 1; var baseEncoding = pos ? Encodings.ExpertEncoding.slice() : Encodings.StandardEncoding.slice(); - for (var i = 0; i < charset.length; i++) { + for (var i = 0, csetLength = charset.length; i < csetLength; i++) { var index = baseEncoding.indexOf(charset[i]); if (index != -1) encoding[index] = gid++; From 249385b4bb5b53c2f56ab4b69dbffeebccf58d62 Mon Sep 17 00:00:00 2001 From: Artur Adib Date: Wed, 2 Nov 2011 15:08:19 -0400 Subject: [PATCH 32/66] Progress --- src/crypto.js | 4 ++-- src/evaluator.js | 18 +++++++++--------- src/function.js | 4 ++-- src/obj.js | 6 +++--- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/crypto.js b/src/crypto.js index 2c86038f0..d4d36fb20 100644 --- a/src/crypto.js +++ b/src/crypto.js @@ -338,7 +338,7 @@ var AES128Cipher = (function aes128Cipher() { } function decryptBlock2(data) { - var i, j, sourceLength = data.length, + var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv; for (i = 0; i < sourceLength; ++i) { @@ -366,7 +366,7 @@ var AES128Cipher = (function aes128Cipher() { return result[0]; // combining plain text blocks into one var output = new Uint8Array(16 * result.length); - for (i = 0, j = 0; i < result.length; ++i, j += 16) + for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) output.set(result[i], j); return output; } diff --git a/src/evaluator.js b/src/evaluator.js index b7a5ef583..cb10b200a 100644 --- a/src/evaluator.js +++ b/src/evaluator.js @@ -123,7 +123,7 @@ var PartialEvaluator = (function partialEvaluator() { function insertDependency(depList) { fnArray.push('dependency'); argsArray.push(depList); - for (var i = 0; i < depList.length; i++) { + for (var i = 0, ii = depList.length; i < ii; i++) { var dep = depList[i]; if (dependency.indexOf(dep) == -1) { dependency.push(depList[i]); @@ -471,10 +471,10 @@ var PartialEvaluator = (function partialEvaluator() { var widths = xref.fetchIfRef(dict.get('W')); if (widths) { var start = 0, end = 0; - for (var i = 0; i < widths.length; i++) { + for (var i = 0, ii = widths.length; i < ii; i++) { var code = widths[i]; if (isArray(code)) { - for (var j = 0; j < code.length; j++) + for (var j = 0, jj = code.length; j < jj; j++) glyphsWidths[start++] = code[j]; start = 0; } else if (start) { @@ -515,7 +515,7 @@ var PartialEvaluator = (function partialEvaluator() { // Set encoding 0 to later verify the font has an encoding encoding[0] = { unicode: 0, width: 0 }; - for (var j = 0; j < glyphsData.length; j++) { + for (var j = 0, jj = glyphsData.length; j < jj; j++) { var glyphID = (glyphsData[j++] << 8) | glyphsData[j]; if (glyphID == 0) continue; @@ -545,7 +545,7 @@ var PartialEvaluator = (function partialEvaluator() { if (encoding.has('Differences')) { var diffEncoding = encoding.get('Differences'); var index = 0; - for (var j = 0; j < diffEncoding.length; j++) { + for (var j = 0, jj = diffEncoding.length; j < jj; j++) { var data = diffEncoding[j]; if (isNum(data)) index = data; @@ -623,7 +623,7 @@ var PartialEvaluator = (function partialEvaluator() { var beginArrayToken = {}; var cmap = cmapObj.getBytes(cmapObj.length); - for (var i = 0; i < cmap.length; i++) { + for (var i = 0, ii = cmap.length; i < ii; i++) { var byte = cmap[i]; if (byte == 0x20 || byte == 0x0D || byte == 0x0A || byte == 0x3C || byte == 0x5B || byte == 0x5D) { @@ -642,7 +642,7 @@ var PartialEvaluator = (function partialEvaluator() { case 'endcidrange': case 'endbfrange': - for (var j = 0; j < tokens.length; j += 3) { + for (var j = 0, jj = tokens.length; j < jj; j += 3) { var startRange = tokens[j]; var endRange = tokens[j + 1]; var code = tokens[j + 2]; @@ -657,7 +657,7 @@ var PartialEvaluator = (function partialEvaluator() { case 'endcidchar': case 'endbfchar': - for (var j = 0; j < tokens.length; j += 2) { + for (var j = 0, jj = tokens.length; j < jj; j += 2) { var index = tokens[j]; var code = tokens[j + 1]; var mapping = map[index] || {}; @@ -807,7 +807,7 @@ var PartialEvaluator = (function partialEvaluator() { var encoding = {}; var widths = xref.fetchIfRef(dict.get('Widths')); if (widths) { - for (var i = 0, j = firstChar; i < widths.length; i++, j++) + for (var i = 0, j = firstChar, ii = widths.length; i < ii; i++, j++) glyphWidths[j] = widths[i]; defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0; } else { diff --git a/src/function.js b/src/function.js index a8c797a29..80c5a5460 100644 --- a/src/function.js +++ b/src/function.js @@ -13,7 +13,7 @@ var PDFFunction = (function pdfFunction() { getSampleArray: function pdfFunctionGetSampleArray(size, outputSize, bps, str) { var length = 1; - for (var i = 0; i < size.length; i++) + for (var i = 0, ii = size.length; i < ii; i++) length *= size[i]; length *= outputSize; @@ -254,7 +254,7 @@ var PDFFunction = (function pdfFunction() { var fnsIR = IR[4]; var fns = []; - for (var i = 0; i < fnsIR.length; i++) { + for (var i = 0, ii = fnsIR.length; i < ii; i++) { fns.push(PDFFunction.fromIR(fnsIR[i])); } diff --git a/src/obj.js b/src/obj.js index fd1579280..7aebb732a 100644 --- a/src/obj.js +++ b/src/obj.js @@ -178,7 +178,7 @@ var Catalog = (function catalogCatalog() { var kids = pagesDict.get('Kids'); assertWellFormed(isArray(kids), 'page dictionary kids object is not an array'); - for (var i = 0; i < kids.length; ++i) { + for (var i = 0, ii = kids.length; i < ii; ++i) { var kid = kids[i]; assertWellFormed(isRef(kid), 'page dictionary kid is not a reference'); @@ -490,12 +490,12 @@ var XRef = (function xRefXRef() { position += token.length + 1; } // reading XRef streams - for (var i = 0; i < xrefStms.length; ++i) { + for (var i = 0, ii = xrefStms.length; i < ii; ++i) { this.readXRef(xrefStms[i]); } // finding main trailer var dict; - for (var i = 0; i < trailers.length; ++i) { + for (var i = 0, ii = trailers.length; i < ii; ++i) { stream.pos = trailers[i]; var parser = new Parser(new Lexer(stream), true); var obj = parser.getObj(); From 2c3991f8b03d6c64976de2459f3d899858da5878 Mon Sep 17 00:00:00 2001 From: Artur Adib Date: Wed, 2 Nov 2011 15:11:33 -0400 Subject: [PATCH 33/66] More progress, workers working --- src/util.js | 2 +- src/worker.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util.js b/src/util.js index 41ae4cc96..4fb96f062 100644 --- a/src/util.js +++ b/src/util.js @@ -261,7 +261,7 @@ var Promise = (function promise() { this.data = data; var callbacks = this.callbacks; - for (var i = 0; i < callbacks.length; i++) { + for (var i = 0, ii = callbacks.length; i < ii; i++) { callbacks[i].call(null, data); } }, diff --git a/src/worker.js b/src/worker.js index d62e0c86b..9860ef978 100644 --- a/src/worker.js +++ b/src/worker.js @@ -75,7 +75,7 @@ var WorkerProcessorHandler = { // Filter the dependecies for fonts. var fonts = {}; - for (var i = 0; i < dependency.length; i++) { + for (var i = 0, ii = dependency.length; i < ii; i++) { var dep = dependency[i]; if (dep.indexOf('font_') == 0) { fonts[dep] = true; From ddf77cda6bc4bec6622ebdee34f1bca8c1754a81 Mon Sep 17 00:00:00 2001 From: Artur Adib Date: Wed, 2 Nov 2011 15:21:45 -0400 Subject: [PATCH 34/66] Using ii convention --- src/canvas.js | 4 +-- src/core.js | 2 +- src/fonts.js | 80 +++++++++++++++++++++++++-------------------------- 3 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/canvas.js b/src/canvas.js index 1aeb851df..43b10aeda 100644 --- a/src/canvas.js +++ b/src/canvas.js @@ -125,7 +125,7 @@ var CanvasGraphics = (function canvasGraphics() { this[fnArray[i]].apply(this, argsArray[i]); } else { var deps = argsArray[i]; - for (var n = 0, depsLength = deps.length; n < depsLength; n++) { + for (var n = 0, nn = deps.length; n < nn; n++) { var depObjId = deps[n]; // If the promise isn't resolved yet, add the continueCallback @@ -184,7 +184,7 @@ var CanvasGraphics = (function canvasGraphics() { TODO('set flatness: ' + flatness); }, setGState: function canvasGraphicsSetGState(states) { - for (var i = 0, statesLength = states.length; i < statesLength; i++) { + for (var i = 0, ii = states.length; i < ii; i++) { var state = states[i]; var key = state[0]; var value = state[1]; diff --git a/src/core.js b/src/core.js index 112883ba2..c9be997d1 100644 --- a/src/core.js +++ b/src/core.js @@ -205,7 +205,7 @@ var Page = (function pagePage() { ensureFonts: function pageEnsureFonts(fonts, callback) { // Convert the font names to the corresponding font obj. - for (var i = 0, fontsLength = fonts.length; i < fontsLength; i++) { + for (var i = 0, ii = fonts.length; i < ii; i++) { fonts[i] = this.objs.objs[fonts[i]].data; } diff --git a/src/fonts.js b/src/fonts.js index 7c753deb2..16f09c495 100644 --- a/src/fonts.js +++ b/src/fonts.js @@ -393,7 +393,7 @@ var FontLoader = { bind: function fontLoaderBind(fonts, callback) { function checkFontsLoaded() { - for (var i = 0, objsLength = objs.length; i < objsLength; i++) { + for (var i = 0, ii = objs.length; i < ii; i++) { var fontObj = objs[i]; if (fontObj.loading) { return false; @@ -409,7 +409,7 @@ var FontLoader = { var rules = [], names = [], objs = []; - for (var i = 0, fontsLength = fonts.length; i < fontsLength; i++) { + for (var i = 0, ii = fonts.length; i < ii; i++) { var font = fonts[i]; // If there is already a fontObj on the font, then it was loaded/attached @@ -490,7 +490,7 @@ var FontLoader = { 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;'); var html = ''; - for (var i = 0, namesLength = names.length; i < namesLength; ++i) { + for (var i = 0, ii = names.length; i < ii; ++i) { html += 'Hi'; } div.innerHTML = html; @@ -501,7 +501,7 @@ var FontLoader = { 'message', function fontLoaderMessage(e) { var fontNames = JSON.parse(e.data); - for (var i = 0, objsLength = objs.length; i < objsLength; ++i) { + for (var i = 0, ii = objs.length; i < ii; ++i) { var font = objs[i]; font.loading = false; } @@ -517,13 +517,13 @@ var FontLoader = { // pdfjsFontLoadFailed? var src = ''; src += ''; src += ''; - for (var i = 0, namesLength = names.length; i < namesLength; ++i) { + for (var i = 0, ii = names.length; i < ii; ++i) { src += '

Hi

'; } src += ''; @@ -782,7 +782,7 @@ var Font = (function Font() { function stringToArray(str) { var array = []; - for (var i = 0, strLength = str.length; i < strLength; ++i) + for (var i = 0, ii = str.length; i < ii; ++i) array[i] = str.charCodeAt(i); return array; @@ -790,7 +790,7 @@ var Font = (function Font() { function arrayToString(arr) { var str = ''; - for (var i = 0, arrLength = arr.length; i < arrLength; ++i) + for (var i = 0, ii = arr.length; i < ii; ++i) str += String.fromCharCode(arr[i]); return str; @@ -1116,11 +1116,11 @@ var Font = (function Font() { // Mac want 1-byte per character strings while Windows want // 2-bytes per character, so duplicate the names table var stringsUnicode = []; - for (var i = 0, stringsLength = strings.length; i < stringsLength; i++) { + for (var i = 0, ii = strings.length; i < ii; i++) { var str = strings[i]; var strUnicode = ''; - for (var j = 0, strLength = str.length; j < strLength; j++) + for (var j = 0, jj = str.length; j < jj; j++) strUnicode += string16(str.charCodeAt(j)); stringsUnicode.push(strUnicode); } @@ -1138,9 +1138,9 @@ var Font = (function Font() { // Build the name records field var strOffset = 0; - for (var i = 0, platfLength = platforms.length; i < platfLength; i++) { + for (var i = 0, ii = platforms.length; i < ii; i++) { var strs = names[i]; - for (var j = 0, strsLength = strs.length; j < strsLength; j++) { + for (var j = 0, jj = strs.length; j < jj; j++) { var str = strs[j]; var nameRecord = platforms[i] + // platform ID @@ -1258,7 +1258,7 @@ var Font = (function Font() { string32(table.offset); } - for (var i = 0, dataLength = data.length; i < dataLength; i++) + for (var i = 0, ii = data.length; i < ii; i++) cmap.data[i] = data.charCodeAt(i); } @@ -1345,7 +1345,7 @@ var Font = (function Font() { if (numMissing > 0) { font.pos = (font.start ? font.start : 0) + metrics.offset; var entries = ''; - for (var i = 0, hmtxLength = hmtx.length; i < hmtxLength; i++) + for (var i = 0, ii = hmtx.length; i < ii; i++) entries += String.fromCharCode(font.getByte()); for (var i = 0; i < numMissing; i++) entries += '\x00\x00'; @@ -1549,18 +1549,18 @@ var Font = (function Font() { }); // rewrite the tables but tweak offsets - for (var i = 0, tablesLength = tables.length; i < tablesLength; i++) { + for (var i = 0, ii = tables.length; i < ii; i++) { var table = tables[i]; var data = []; var tableData = table.data; - for (var j = 0, dataLength = tableData.length; j < dataLength; j++) + for (var j = 0, jj = tableData.length; j < jj; j++) data.push(tableData[j]); createTableEntry(ttf, table.tag, data); } // Add the table datas - for (var i = 0, tablesLength = tables.length; i < tablesLength; i++) { + for (var i = 0, ii = tables.length; i < ii; i++) { var table = tables[i]; var tableData = table.data; ttf.file += arrayToString(tableData); @@ -1575,7 +1575,7 @@ var Font = (function Font() { convert: function font_convert(fontName, font, properties) { function isFixedPitch(glyphs) { - for (var i = 0, glyphsMax = glyphs.length - 1; i < glyphsMax; i++) { + for (var i = 0, ii = glyphs.length - 1; i < ii; i++) { if (glyphs[i] != glyphs[i + 1]) return false; } @@ -1657,7 +1657,7 @@ var Font = (function Font() { // Horizontal metrics 'hmtx': (function fontFieldsHmtx() { var hmtx = '\x00\x00\x00\x00'; // Fake .notdef - for (var i = 0, cstrMax = charstrings.length; i < cstrMax; i++) { + for (var i = 0, ii = charstrings.length; i < ii; i++) { hmtx += string16(charstrings[i].width) + string16(0); } return stringToArray(hmtx); @@ -1730,7 +1730,7 @@ var Font = (function Font() { encoding[0] = { unicode: 0, width: 0 }; var glyph = 1, i, j, k, cidLength; - for (i = 0, cidLength = cidToUnicode.length; i < cidLength; ++i) { + for (i = 0, ii = cidToUnicode.length; i < ii; ++i) { var unicode = cidToUnicode[i]; var width; if (isArray(unicode)) { @@ -1844,7 +1844,7 @@ var Font = (function Font() { } } else { - for (var i = 0, charsLength = chars.length; i < charsLength; ++i) { + for (var i = 0, ii = chars.length; i < ii; ++i) { var charcode = chars.charCodeAt(i); var glyph = encoding[charcode]; if ('undefined' == typeof(glyph)) { @@ -2142,7 +2142,7 @@ var Type1Parser = function type1Parser() { count++; var array = str.substr(start, count).split(' '); - for (var i = 0, arrayLength = array.length; i < arrayLength; i++) + for (var i = 0, ii = array.length; i < ii; i++) array[i] = parseFloat(array[i] || 0); return array; } @@ -2167,7 +2167,7 @@ var Type1Parser = function type1Parser() { this.extractFontProgram = function t1_extractFontProgram(stream) { var eexec = decrypt(stream, kEexecEncryptionKey, 4); var eexecStr = ''; - for (var i = 0, eexecLength = eexec.length; i < eexecLength; i++) + for (var i = 0, ii = eexec.length; i < ii; i++) eexecStr += String.fromCharCode(eexec[i]); var glyphsSection = false, subrsSection = false; @@ -2291,7 +2291,7 @@ var Type1Parser = function type1Parser() { this.extractFontHeader = function t1_extractFontHeader(stream, properties) { var headerString = ''; - for (var i = 0, streamLength = stream.length; i < streamLength; i++) + for (var i = 0, ii = stream.length; i < ii; i++) headerString += String.fromCharCode(stream[i]); var token = ''; @@ -2318,7 +2318,7 @@ var Type1Parser = function type1Parser() { var matrix = readNumberArray(headerString, i + 1); // The FontMatrix is in unitPerEm, so make it pixels - for (var j = 0, matLength = matrix.length; j < matLength; j++) + for (var j = 0, jj = matrix.length; j < jj; j++) matrix[j] *= 1000; // Make the angle into the right direction @@ -2479,7 +2479,7 @@ CFF.prototype = { } for (var i = 0; i < count; i++) { - for (var j = 0, objLength = objects[i].length; j < objLength; j++) + for (var j = 0, jj = objects[i].length; j < jj; j++) data += isByte ? String.fromCharCode(objects[i][j] & 0xFF) : objects[i][j]; } @@ -2507,7 +2507,7 @@ CFF.prototype = { var charstrings = []; var missings = []; - for (var i = 0, glLength = glyphs.length; i < glLength; i++) { + for (var i = 0, ii = glyphs.length; i < ii; i++) { var glyph = glyphs[i]; var mapping = properties.glyphs[glyph.glyph]; if (!mapping) { @@ -2642,7 +2642,7 @@ CFF.prototype = { '\x1c\x00\x00\x10'; // Encoding var boundingBox = properties.bbox; - for (var i = 0, boxLength = boundingBox.length; i < boxLength; i++) + for (var i = 0, ii = boundingBox.length; i < ii; i++) dict += self.encodeNumber(boundingBox[i]); dict += '\x05'; // FontBBox; @@ -2732,7 +2732,7 @@ CFF.prototype = { if (isArray(value)) { data += self.encodeNumber(value[0]); - for (var i = 1, valLength = value.length; i < valLength; i++) + for (var i = 1, ii = value.length; i < ii; i++) data += self.encodeNumber(value[i] - value[i - 1]); } else { data += self.encodeNumber(value); @@ -2753,7 +2753,7 @@ CFF.prototype = { var cff = []; for (var index in fields) { var field = fields[index]; - for (var i = 0, fLength = field.length; i < fLength; i++) + for (var i = 0, ii = field.length; i < ii; i++) cff.push(field.charCodeAt(i)); } @@ -2850,7 +2850,7 @@ var Type2CFF = (function type2CFF() { // create the mapping between charstring and glyph id var glyphIds = []; - for (var i = 0, cstrLength = charstrings.length; i < cstrLength; i++) + for (var i = 0, ii = charstrings.length; i < ii; i++) glyphIds.push(charstrings[i].gid); this.charstrings = charstrings; @@ -2868,7 +2868,7 @@ var Type2CFF = (function type2CFF() { var charstrings = []; var firstChar = properties.firstChar; var glyphMap = {}; - for (var i = 0, csetLength = charsets.length; i < csetLength; i++) { + for (var i = 0, ii = charsets.length; i < ii; i++) { var glyph = charsets[i]; for (var charcode in encoding) { if (encoding[charcode] == i) @@ -2877,7 +2877,7 @@ var Type2CFF = (function type2CFF() { } var differences = properties.differences; - for (var i = 0, diffLength = differences.length; i < diffLength; ++i) { + for (var i = 0, ii = differences.length; i < ii; ++i) { var glyph = differences[i]; if (!glyph) continue; @@ -2888,7 +2888,7 @@ var Type2CFF = (function type2CFF() { } var glyphs = properties.glyphs; - for (var i = 1, csetLength = charsets.length; i < csetLength; i++) { + for (var i = 1, ii = charsets.length; i < ii; i++) { var glyph = charsets[i]; var code = glyphMap[glyph] || 0; @@ -2922,7 +2922,7 @@ var Type2CFF = (function type2CFF() { // properties.glyphs[code] || properties.glyphs[glyph] var nextUnusedUnicode = kCmapGlyphOffset + 0x0020; var lastUnicode = charstrings[0].unicode, wasModified = false; - for (var i = 1, cstrLength = charstrings.length; i < cstrLength; ++i) { + for (var i = 1, ii = charstrings.length; i < ii; ++i) { if (lastUnicode != charstrings[i].unicode) { lastUnicode = charstrings[i].unicode; continue; @@ -2967,7 +2967,7 @@ var Type2CFF = (function type2CFF() { var gid = 1; var baseEncoding = pos ? Encodings.ExpertEncoding.slice() : Encodings.StandardEncoding.slice(); - for (var i = 0, csetLength = charset.length; i < csetLength; i++) { + for (var i = 0, ii = charset.length; i < ii; i++) { var index = baseEncoding.indexOf(charset[i]); if (index != -1) encoding[index] = gid++; @@ -3118,16 +3118,16 @@ var Type2CFF = (function type2CFF() { getStrings: function cff_getStrings(stringIndex) { function bytesToString(bytesArray) { var str = ''; - for (var i = 0, length = bytesArray.length; i < length; i++) + for (var i = 0, ii = bytesArray.length; i < ii; i++) str += String.fromCharCode(bytesArray[i]); return str; } var stringArray = []; - for (var i = 0, length = CFFStrings.length; i < length; i++) + for (var i = 0, ii = CFFStrings.length; i < ii; i++) stringArray.push(CFFStrings[i]); - for (var i = 0, length = stringIndex.length; i < length; i++) + for (var i = 0, ii = stringIndex.length; i < ii; i++) stringArray.push(bytesToString(stringIndex.get(i).data)); return stringArray; From 7d38d7f062bf5c6e89b932f80c4b7d0ff83c8edf Mon Sep 17 00:00:00 2001 From: Artur Adib Date: Wed, 2 Nov 2011 17:34:24 -0400 Subject: [PATCH 35/66] Missing var --- src/fonts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fonts.js b/src/fonts.js index 16f09c495..217d0733e 100644 --- a/src/fonts.js +++ b/src/fonts.js @@ -1729,7 +1729,7 @@ var Font = (function Font() { } encoding[0] = { unicode: 0, width: 0 }; - var glyph = 1, i, j, k, cidLength; + var glyph = 1, i, j, k, cidLength, ii; for (i = 0, ii = cidToUnicode.length; i < ii; ++i) { var unicode = cidToUnicode[i]; var width; From 50fe4f55e2f78320dc265f9cf828dc0d3a25666e Mon Sep 17 00:00:00 2001 From: Julian Viereck Date: Wed, 2 Nov 2011 23:00:08 +0100 Subject: [PATCH 36/66] Fix lint warning + turn off worker support --- src/core.js | 2 +- src/worker_loader.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core.js b/src/core.js index 5685cdf31..2bc4c50aa 100644 --- a/src/core.js +++ b/src/core.js @@ -7,7 +7,7 @@ var globalScope = (typeof window === 'undefined') ? this : window; var ERRORS = 0, WARNINGS = 1, TODOS = 5; var verbosity = WARNINGS; -var useWorker = true; +var useWorker = false; // The global PDFJS object exposes the API // In production, it will be declared outside a global wrapper diff --git a/src/worker_loader.js b/src/worker_loader.js index 8eb1da7b2..8d342d116 100644 --- a/src/worker_loader.js +++ b/src/worker_loader.js @@ -3,7 +3,7 @@ 'use strict'; -this.onmessage = function(evt) { +function onMessageLoader(evt) { // Reset the `onmessage` function as it was only set to call // this function the first time a message is passed to the worker // but shouldn't get called anytime afterwards. @@ -47,4 +47,6 @@ this.onmessage = function(evt) { for (var i = 0; i < files.length; i++) { importScripts(dir + files[i]); } -}.bind(this); +} + +this.onmessage = onMessageLoader.bind(this); From 493c25dcaa00fa75b0e1f6f4e836d67eca190895 Mon Sep 17 00:00:00 2001 From: Julian Viereck Date: Tue, 1 Nov 2011 20:23:48 +0100 Subject: [PATCH 37/66] Remove `useWorker` variable and turn worker support whenever this is possible. --- src/core.js | 207 +++++++++++++++++++++++++++----------------------- src/worker.js | 4 + 2 files changed, 118 insertions(+), 93 deletions(-) diff --git a/src/core.js b/src/core.js index 2bc4c50aa..492f36927 100644 --- a/src/core.js +++ b/src/core.js @@ -7,7 +7,6 @@ var globalScope = (typeof window === 'undefined') ? this : window; var ERRORS = 0, WARNINGS = 1, TODOS = 5; var verbosity = WARNINGS; -var useWorker = false; // The global PDFJS object exposes the API // In production, it will be declared outside a global wrapper @@ -470,8 +469,14 @@ var PDFDoc = (function pdfDoc() { this.objs = new PDFObjects(); this.pageCache = []; + this.workerReadyPromise = new Promise('workerReady'); - if (useWorker) { + // If worker support isn't disabled explicit and the browser has worker + // support, create a new web worker and test if it/the browser fullfills + // all requirements to run parts of pdf.js in a web worker. + // Right now, the requirement is, that an Uint8Array is still an Uint8Array + // as it arrives on the worker. Chrome added this with version 15. + if (!globalScope.PDFJS.disableWorker && typeof Worker !== 'undefined') { var workerSrc = PDFJS.workerSrc; if (typeof workerSrc === 'undefined') { throw 'No PDFJS.workerSrc specified'; @@ -479,105 +484,121 @@ var PDFDoc = (function pdfDoc() { var worker = new Worker(workerSrc); + var processorHandler = new MessageHandler('main', worker); + // Tell the worker the file it was created from. - worker.postMessage({ - action: 'workerSrc', - data: workerSrc - }); + processorHandler.send('workerSrc', workerSrc); + + processorHandler.on('test', function pdfDocTest(supportTypedArray) { + if (supportTypedArray) { + this.worker = worker; + this.setupProcessorHandler(processorHandler); + } else { + this.setupFakeWorker(); + } + }.bind(this)); + + var testObj = new Uint8Array(1); + processorHandler.send('test', testObj); } else { - // If we don't use a worker, just post/sendMessage to the main thread. - var worker = { - postMessage: function pdfDocPostMessage(obj) { - worker.onmessage({data: obj}); - }, - terminate: function pdfDocTerminate() {} - }; + this.setupFakeWorker(); } - this.worker = worker; this.fontsLoading = {}; - - var processorHandler = this.processorHandler = - new MessageHandler('main', worker); - - processorHandler.on('page', function pdfDocPage(data) { - var pageNum = data.pageNum; - var page = this.pageCache[pageNum]; - var depFonts = data.depFonts; - - page.startRenderingFromIRQueue(data.IRQueue, depFonts); - }, this); - - processorHandler.on('obj', function pdfDocObj(data) { - var id = data[0]; - var type = data[1]; - - switch (type) { - case 'JpegStream': - var IR = data[2]; - new JpegImage(id, IR, this.objs); - break; - case 'Font': - var name = data[2]; - var file = data[3]; - var properties = data[4]; - - if (file) { - var fontFileDict = new Dict(); - fontFileDict.map = file.dict.map; - - var fontFile = new Stream(file.bytes, file.start, - file.end - file.start, fontFileDict); - - // Check if this is a FlateStream. Otherwise just use the created - // Stream one. This makes complex_ttf_font.pdf work. - var cmf = file.bytes[0]; - if ((cmf & 0x0f) == 0x08) { - file = new FlateStream(fontFile); - } else { - file = fontFile; - } - } - - // For now, resolve the font object here direclty. The real font - // object is then created in FontLoader.bind(). - this.objs.resolve(id, { - name: name, - file: file, - properties: properties - }); - break; - default: - throw 'Got unkown object type ' + type; - } - }, this); - - processorHandler.on('font_ready', function pdfDocFontReady(data) { - var id = data[0]; - var font = new FontShape(data[1]); - - // If there is no string, then there is nothing to attach to the DOM. - if (!font.str) { - this.objs.resolve(id, font); - } else { - this.objs.setData(id, font); - } - }.bind(this)); - - if (!useWorker) { - // If the main thread is our worker, setup the handling for the messages - // the main thread sends to it self. - WorkerProcessorHandler.setup(processorHandler); - } - - this.workerReadyPromise = new Promise('workerReady'); - setTimeout(function pdfDocFontReadySetTimeout() { - processorHandler.send('doc', this.data); - this.workerReadyPromise.resolve(true); - }.bind(this)); } constructor.prototype = { + setupFakeWorker: function() { + // If we don't use a worker, just post/sendMessage to the main thread. + var fakeWorker = { + postMessage: function pdfDocPostMessage(obj) { + fakeWorker.onmessage({data: obj}); + }, + terminate: function pdfDocTerminate() {} + }; + + var processorHandler = new MessageHandler('main', fakeWorker); + this.setupProcessorHandler(processorHandler); + + // If the main thread is our worker, setup the handling for the messages + // the main thread sends to it self. + WorkerProcessorHandler.setup(processorHandler); + }, + + + setupProcessorHandler: function(processorHandler) { + this.processorHandler = processorHandler; + + processorHandler.on('page', function pdfDocPage(data) { + var pageNum = data.pageNum; + var page = this.pageCache[pageNum]; + var depFonts = data.depFonts; + + page.startRenderingFromIRQueue(data.IRQueue, depFonts); + }, this); + + processorHandler.on('obj', function pdfDocObj(data) { + var id = data[0]; + var type = data[1]; + + switch (type) { + case 'JpegStream': + var IR = data[2]; + new JpegImage(id, IR, this.objs); + break; + case 'Font': + var name = data[2]; + var file = data[3]; + var properties = data[4]; + + if (file) { + var fontFileDict = new Dict(); + fontFileDict.map = file.dict.map; + + var fontFile = new Stream(file.bytes, file.start, + file.end - file.start, fontFileDict); + + // Check if this is a FlateStream. Otherwise just use the created + // Stream one. This makes complex_ttf_font.pdf work. + var cmf = file.bytes[0]; + if ((cmf & 0x0f) == 0x08) { + file = new FlateStream(fontFile); + } else { + file = fontFile; + } + } + + // For now, resolve the font object here direclty. The real font + // object is then created in FontLoader.bind(). + this.objs.resolve(id, { + name: name, + file: file, + properties: properties + }); + break; + default: + throw 'Got unkown object type ' + type; + } + }, this); + + processorHandler.on('font_ready', function pdfDocFontReady(data) { + var id = data[0]; + var font = new FontShape(data[1]); + + // If there is no string, then there is nothing to attach to the DOM. + if (!font.str) { + this.objs.resolve(id, font); + } else { + this.objs.setData(id, font); + } + }.bind(this)); + + setTimeout(function pdfDocFontReadySetTimeout() { + processorHandler.send('doc', this.data); + this.workerReadyPromise.resolve(true); + }.bind(this)); + }, + get numPages() { return this.pdf.numPages; }, diff --git a/src/worker.js b/src/worker.js index 74a880cae..45a76e147 100644 --- a/src/worker.js +++ b/src/worker.js @@ -47,6 +47,10 @@ var WorkerProcessorHandler = { setup: function wphSetup(handler) { var pdfDoc = null; + handler.on('test', function wphSetupTest(data) { + handler.send('test', data instanceof Uint8Array); + }); + handler.on('workerSrc', function wphSetupWorkerSrc(data) { // In development, the `workerSrc` message is handled in the // `worker_loader.js` file. In production the workerProcessHandler is From 80b759b0939b9b2956cfd4902b5ea7982c2b5d0a Mon Sep 17 00:00:00 2001 From: Julian Viereck Date: Tue, 1 Nov 2011 20:27:19 +0100 Subject: [PATCH 38/66] Fix style nit from brendandahl --- src/core.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core.js b/src/core.js index 492f36927..404d601da 100644 --- a/src/core.js +++ b/src/core.js @@ -545,7 +545,7 @@ var PDFDoc = (function pdfDoc() { case 'JpegStream': var IR = data[2]; new JpegImage(id, IR, this.objs); - break; + break; case 'Font': var name = data[2]; var file = data[3]; @@ -575,7 +575,7 @@ var PDFDoc = (function pdfDoc() { file: file, properties: properties }); - break; + break; default: throw 'Got unkown object type ' + type; } From d9d2ab4c8e2e78cde7c2603522b1d20af793d8c7 Mon Sep 17 00:00:00 2001 From: Julian Viereck Date: Thu, 3 Nov 2011 15:30:53 +0100 Subject: [PATCH 39/66] Rename processorHandler to messageHandler --- src/core.js | 30 +++++++++++++++--------------- src/worker.js | 4 ++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/core.js b/src/core.js index 404d601da..ddf1cebbe 100644 --- a/src/core.js +++ b/src/core.js @@ -484,22 +484,22 @@ var PDFDoc = (function pdfDoc() { var worker = new Worker(workerSrc); - var processorHandler = new MessageHandler('main', worker); + var messageHandler = new MessageHandler('main', worker); // Tell the worker the file it was created from. - processorHandler.send('workerSrc', workerSrc); + messageHandler.send('workerSrc', workerSrc); - processorHandler.on('test', function pdfDocTest(supportTypedArray) { + messageHandler.on('test', function pdfDocTest(supportTypedArray) { if (supportTypedArray) { this.worker = worker; - this.setupProcessorHandler(processorHandler); + this.setupMessageHandler(messageHandler); } else { this.setupFakeWorker(); } }.bind(this)); var testObj = new Uint8Array(1); - processorHandler.send('test', testObj); + messageHandler.send('test', testObj); } else { this.setupFakeWorker(); } @@ -517,19 +517,19 @@ var PDFDoc = (function pdfDoc() { terminate: function pdfDocTerminate() {} }; - var processorHandler = new MessageHandler('main', fakeWorker); - this.setupProcessorHandler(processorHandler); + var messageHandler = new MessageHandler('main', fakeWorker); + this.setupMessageHandler(messageHandler); // If the main thread is our worker, setup the handling for the messages // the main thread sends to it self. - WorkerProcessorHandler.setup(processorHandler); + WorkerMessageHandler.setup(messageHandler); }, - setupProcessorHandler: function(processorHandler) { - this.processorHandler = processorHandler; + setupMessageHandler: function(messageHandler) { + this.messageHandler = messageHandler; - processorHandler.on('page', function pdfDocPage(data) { + messageHandler.on('page', function pdfDocPage(data) { var pageNum = data.pageNum; var page = this.pageCache[pageNum]; var depFonts = data.depFonts; @@ -537,7 +537,7 @@ var PDFDoc = (function pdfDoc() { page.startRenderingFromIRQueue(data.IRQueue, depFonts); }, this); - processorHandler.on('obj', function pdfDocObj(data) { + messageHandler.on('obj', function pdfDocObj(data) { var id = data[0]; var type = data[1]; @@ -581,7 +581,7 @@ var PDFDoc = (function pdfDoc() { } }, this); - processorHandler.on('font_ready', function pdfDocFontReady(data) { + messageHandler.on('font_ready', function pdfDocFontReady(data) { var id = data[0]; var font = new FontShape(data[1]); @@ -594,7 +594,7 @@ var PDFDoc = (function pdfDoc() { }.bind(this)); setTimeout(function pdfDocFontReadySetTimeout() { - processorHandler.send('doc', this.data); + messageHandler.send('doc', this.data); this.workerReadyPromise.resolve(true); }.bind(this)); }, @@ -606,7 +606,7 @@ var PDFDoc = (function pdfDoc() { startRendering: function pdfDocStartRendering(page) { // The worker might not be ready to receive the page request yet. this.workerReadyPromise.then(function pdfDocStartRenderingThen() { - this.processorHandler.send('page_request', page.pageNumber + 1); + this.messageHandler.send('page_request', page.pageNumber + 1); }.bind(this)); }, diff --git a/src/worker.js b/src/worker.js index 45a76e147..b6ea68741 100644 --- a/src/worker.js +++ b/src/worker.js @@ -43,7 +43,7 @@ MessageHandler.prototype = { } }; -var WorkerProcessorHandler = { +var WorkerMessageHandler = { setup: function wphSetup(handler) { var pdfDoc = null; @@ -188,6 +188,6 @@ if (typeof window === 'undefined') { globalScope.console = workerConsole; var handler = new MessageHandler('worker_processor', this); - WorkerProcessorHandler.setup(handler); + WorkerMessageHandler.setup(handler); } From 6b5d5d85188ab874e5fc7cc6708b9d03c88b2c82 Mon Sep 17 00:00:00 2001 From: Artur Adib Date: Thu, 3 Nov 2011 16:16:21 -0400 Subject: [PATCH 40/66] Updated external link --- test/pdfs/cable.pdf.link | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/pdfs/cable.pdf.link b/test/pdfs/cable.pdf.link index 9cf92a5b8..ea9270592 100644 --- a/test/pdfs/cable.pdf.link +++ b/test/pdfs/cable.pdf.link @@ -1 +1,2 @@ -http://www.wrapon.com/docs/PIPEHEATCABLE.PDF +https://wrap-on.com/docs/PIPEHEATCABLE.PDF + From 7bb9f74fa290641c2eb134076f683b4d492fc909 Mon Sep 17 00:00:00 2001 From: Artur Adib Date: Thu, 3 Nov 2011 16:29:08 -0400 Subject: [PATCH 41/66] nit --- test/pdfs/cable.pdf.link | 1 - 1 file changed, 1 deletion(-) diff --git a/test/pdfs/cable.pdf.link b/test/pdfs/cable.pdf.link index ea9270592..671f06166 100644 --- a/test/pdfs/cable.pdf.link +++ b/test/pdfs/cable.pdf.link @@ -1,2 +1 @@ https://wrap-on.com/docs/PIPEHEATCABLE.PDF - From 33af12abd0e1f1ac54bf4f8776e1dca69a5c2a95 Mon Sep 17 00:00:00 2001 From: Kalervo Kujala Date: Thu, 3 Nov 2011 23:26:58 +0200 Subject: [PATCH 42/66] Fix jslint warnings. --- src/canvas.js | 4 ++-- src/core.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/canvas.js b/src/canvas.js index 474cc250f..686430cc1 100644 --- a/src/canvas.js +++ b/src/canvas.js @@ -24,9 +24,9 @@ var CanvasExtraState = (function canvasExtraState() { this.wordSpacing = 0; this.textHScale = 1; // Color spaces - this.fillColorSpace = new DeviceGrayCS; + this.fillColorSpace = new DeviceGrayCS(); this.fillColorSpaceObj = null; - this.strokeColorSpace = new DeviceGrayCS; + this.strokeColorSpace = new DeviceGrayCS(); this.strokeColorSpaceObj = null; this.fillColorObj = null; this.strokeColorObj = null; diff --git a/src/core.js b/src/core.js index 2bc4c50aa..0e6f13e97 100644 --- a/src/core.js +++ b/src/core.js @@ -199,8 +199,8 @@ var Page = (function pagePage() { var pe = this.pe = new PartialEvaluator( xref, handler, 'p' + this.pageNumber + '_'); var IRQueue = {}; - return this.IRQueue = pe.getIRQueue( - content, resources, IRQueue, dependency); + return (this.IRQueue = pe.getIRQueue(content, resources, IRQueue, + dependency)); }, ensureFonts: function pageEnsureFonts(fonts, callback) { @@ -598,7 +598,7 @@ var PDFDoc = (function pdfDoc() { // to the CanvasGraphics and so on. page.objs = this.objs; page.pdf = this; - return this.pageCache[n] = page; + return (this.pageCache[n] = page); }, destroy: function pdfDocDestroy() { From 2d51ee8fcd0e02f3d51044b36f167f34486f0942 Mon Sep 17 00:00:00 2001 From: Artur Adib Date: Thu, 3 Nov 2011 19:01:10 -0400 Subject: [PATCH 43/66] Fixing ref/ update --- test/test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test.py b/test/test.py index 66e1acd31..e3aefcfb5 100644 --- a/test/test.py +++ b/test/test.py @@ -506,9 +506,7 @@ def maybeUpdateRefImages(options, browser): print ' Yes! The references in tmp/ can be synced with ref/.' if options.reftest: startReftest(browser, options) - if options.noPrompts or not prompt('Would you like to update the master copy in ref/?'): - print ' OK, not updating.' - else: + if options.noPrompts or prompt('Would you like to update the master copy in ref/?'): sys.stdout.write(' Updating ref/ ... ') # XXX unclear what to do on errors here ... @@ -517,6 +515,8 @@ def maybeUpdateRefImages(options, browser): subprocess.check_call(( 'rsync', '-arv', 'tmp/', 'ref/' )) print 'done' + else: + print ' OK, not updating.' def startReftest(browser, options): url = "http://%s:%s" % (SERVER_HOST, options.port) From 989ad4952f7822c9853f6125a58021d5d73b3108 Mon Sep 17 00:00:00 2001 From: Artur Adib Date: Thu, 3 Nov 2011 19:50:28 -0400 Subject: [PATCH 44/66] Quiet rsync --- test/test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test.py b/test/test.py index e3aefcfb5..7d16ea796 100644 --- a/test/test.py +++ b/test/test.py @@ -512,7 +512,7 @@ def maybeUpdateRefImages(options, browser): # XXX unclear what to do on errors here ... # NB: do *NOT* pass --delete to rsync. That breaks this # entire scheme. - subprocess.check_call(( 'rsync', '-arv', 'tmp/', 'ref/' )) + subprocess.check_call(( 'rsync', '-arvq', 'tmp/', 'ref/' )) print 'done' else: From c4ffbdb951969a0d9e12bf5f4e1de4cddcb812cd Mon Sep 17 00:00:00 2001 From: Brendan Dahl Date: Fri, 4 Nov 2011 09:14:52 -0700 Subject: [PATCH 45/66] Hash files to make sure they haven't changed. --- test/test.py | 27 ++++++++++++++++++++++++++- test/test_manifest.json | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/test/test.py b/test/test.py index 7d16ea796..bce5ae8f3 100644 --- a/test/test.py +++ b/test/test.py @@ -1,4 +1,4 @@ -import json, platform, os, shutil, sys, subprocess, tempfile, threading, time, urllib, urllib2 +import json, platform, os, shutil, sys, subprocess, tempfile, threading, time, urllib, urllib2, hashlib from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer import SocketServer from optparse import OptionParser @@ -316,6 +316,28 @@ def downloadLinkedPDFs(manifestList): print 'done' +def verifyPDFs(manifestList): + error = False + for item in manifestList: + f = item['file'] + if os.access(f, os.R_OK): + fileMd5 = hashlib.md5(open(f).read()).hexdigest() + if 'md5' not in item: + print 'ERROR: Missing md5 for file "' + f + '".', + print 'Hash for current file is "' + fileMd5 + '"' + error = True + continue + md5 = item['md5'] + if fileMd5 != md5: + print 'ERROR: MD5 of file "' + f + '" does not match file.', + print 'Expected "' + md5 + '" computed "' + fileMd5 + '"' + error = True + continue + else: + print 'ERROR: Unable to open file for reading "' + f + '".' + error = True + return not error + def setUp(options): # Only serve files from a pdf.js clone assert not ANAL or os.path.isfile('../src/pdf.js') and os.path.isdir('../.git') @@ -342,6 +364,9 @@ def setUp(options): downloadLinkedPDFs(manifestList) + if not verifyPDFs(manifestList): + raise Exception('ERROR: failed to verify pdfs.') + for b in testBrowsers: State.taskResults[b.name] = { } for item in manifestList: diff --git a/test/test_manifest.json b/test/test_manifest.json index 25f609e8d..c3ebe6c05 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -1,151 +1,178 @@ [ { "id": "tracemonkey-eq", "file": "pdfs/tracemonkey.pdf", + "md5": "9a192d8b1a7dc652a19835f6f08098bd", "rounds": 1, "type": "eq" }, { "id": "tracemonkey-fbf", "file": "pdfs/tracemonkey.pdf", + "md5": "9a192d8b1a7dc652a19835f6f08098bd", "rounds": 2, "type": "fbf" }, { "id": "html5-canvas-cheat-sheet-load", "file": "pdfs/canvas.pdf", + "md5": "59510028561daf62e00bf9f6f066b033", "rounds": 1, "type": "load" }, { "id": "intelisa-load", "file": "pdfs/intelisa.pdf", + "md5": "f3ed5487d1afa34d8b77c0c734a95c79", "link": true, "rounds": 1, "type": "load" }, { "id": "pdfspec-load", "file": "pdfs/pdf.pdf", + "md5": "dbdb23c939d2be09b43126c3c56060c7", "link": true, "rounds": 1, "type": "load" }, { "id": "shavian-load", "file": "pdfs/shavian.pdf", + "md5": "4fabf0a03e82693007435020bc446f9b", "link": true, "rounds": 1, "type": "load" }, { "id": "sizes", "file": "pdfs/sizes.pdf", + "md5": "c101ba7b44aee36048e1ac7b98f302ea", "rounds": 1, "type": "eq" }, { "id": "openweb-cover", "file": "pdfs/openweb_tm-PRINT.pdf", + "md5": "53f611dfc19ddfb50554c21c4af465c0", "link": true, "rounds": 1, "type": "eq" }, { "id": "plusminus", "file": "pdfs/Test-plusminus.pdf", + "md5": "1ec7ade5b95ac9aaba3a618af28d34c7", "rounds": 1, "type": "eq" }, { "id": "openoffice-pdf", "file": "pdfs/DiwanProfile.pdf", + "md5": "55d0c6a1a6d26c9ec9dcecaa7a471e0e", "link": true, "rounds": 1, "type": "load" }, { "id": "openofficecidtruetype-pdf", "file": "pdfs/arial_unicode_en_cidfont.pdf", + "md5": "03591cdf20214fb0b2dd5e5c3dd32d8c", "rounds": 1, "type": "load" }, { "id": "openofficearabiccidtruetype-pdf", "file": "pdfs/arial_unicode_ab_cidfont.pdf", + "md5": "35090fa7d29e7196ae3421812e554988", "rounds": 1, "type": "load" }, { "id": "arabiccidtruetype-pdf", "file": "pdfs/ArabicCIDTrueType.pdf", + "md5": "d66dbd18bdb572d3ac8b88b32de2ece6", "rounds": 1, "type": "load" }, { "id": "complexttffont-pdf", "file": "pdfs/complex_ttf_font.pdf", + "md5": "76de93f9116b01b693bf8583b3e76d91", "rounds": 1, "type": "load" }, { "id": "thuluthfont-pdf", "file": "pdfs/ThuluthFeatures.pdf", + "md5": "b7e18bf7a3d6a9c82aefa12d721072fc", "rounds": 1, "type": "eq" }, { "id": "wnv_chinese-pdf", "file": "pdfs/wnv_chinese.pdf", + "md5": "db682638e68391125e8982d3c984841e", "link": true, "rounds": 1, "type": "eq" }, { "id": "i9-pdf", "file": "pdfs/i9.pdf", + "md5": "ba7cd54fdff083bb389295bc0415f6c5", "link": true, "rounds": 1, "type": "eq" }, { "id": "hmm-pdf", "file": "pdfs/hmm.pdf", + "md5": "e08467e60101ee5f4a59716e86db6dc9", "link": true, "rounds": 1, "type": "load" }, { "id": "rotation", "file": "pdfs/rotation.pdf", + "md5": "4fb25ada00ce7528569d9791c14decf5", "rounds": 1, "type": "eq" }, { "id": "ecma262-pdf", "file": "pdfs/ecma262.pdf", + "md5": "763ead98f535578842891e5574e0af0f", "link": true, "rounds": 1, "type": "load" }, { "id": "jai-pdf", "file": "pdfs/jai.pdf", + "md5": "1f5dd128c3757420a881a155f2f8ace3", "link": true, "rounds": 1, "type": "load" }, { "id": "cable", "file": "pdfs/cable.pdf", + "md5": "09a41b9a759d60c698228224ab85b46d", "link": true, "rounds": 1, "type": "eq" }, { "id": "pdkids", "file": "pdfs/pdkids.pdf", + "md5": "278982bf016dbe46d2066f9245d9b3e6", "link": true, "rounds": 1, "type": "eq" }, { "id": "artofwar", "file": "pdfs/artofwar.pdf", + "md5": "7bdd51c327b74f1f7abdd90eedb2f912", "link": true, "rounds": 1, "type": "eq" }, { "id": "wdsg_fitc", "file": "pdfs/wdsg_fitc.pdf", + "md5": "5bb1c2b83705d4cdfc43197ee74f07f9", "link": true, "rounds": 1, "type": "eq" }, { "id": "unix01", "file": "pdfs/unix01.pdf", + "md5": "2742999f0bf9b9c035dbb0736096e220", "link": true, "rounds": 1, "type": "eq" }, { "id": "fit11-talk", "file": "pdfs/fit11-talk.pdf", + "md5": "eb7b224107205db4fea9f7df0185f77d", "link": true, "rounds": 1, "skipPages": [12,31], @@ -153,48 +180,56 @@ }, { "id": "fips197", "file": "pdfs/fips197.pdf", + "md5": "374800cf78ce4b4abd02cd10a856b57f", "link": true, "rounds": 1, "type": "eq" }, { "id": "txt2pdf", "file": "pdfs/txt2pdf.pdf", + "md5": "02cefa0f5e8d96313bb05163b2f88c8c", "link": true, "rounds": 1, "type": "load" }, { "id": "f1040", "file": "pdfs/f1040.pdf", + "md5": "7323b50c6d28d959b8b4b92c469b2469", "link": true, "rounds": 1, "type": "load" }, { "id": "hudsonsurvey", "file": "pdfs/hudsonsurvey.pdf", + "md5": "bf0e6576a7b6c2fe7485bce1b78e006f", "link": true, "rounds": 1, "type": "load" }, { "id": "extgstate", "file": "pdfs/extgstate.pdf", + "md5": "001bb4ec04463a01d93aad748361f049", "link": false, "rounds": 1, "type": "eq" }, { "id": "usmanm-bad", "file": "pdfs/usmanm-bad.pdf", + "md5": "38afb822433aaf07fc8f54807cd4f61a", "link": true, "rounds": 1, "type": "eq" }, { "id": "vesta-bad", "file": "pdfs/vesta.pdf", + "md5": "0afebc109b7c17b95619ea3fab5eafe6", "link": true, "rounds": 1, "type": "load" }, { "id": "ibwa-bad", "file": "pdfs/ibwa-bad.pdf", + "md5": "6ca059d32b74ac2688ae06f727fee755", "link": true, "rounds": 1, "skipPages": [ 16 ], @@ -202,29 +237,34 @@ }, { "id": "tcpdf_033", "file": "pdfs/tcpdf_033.pdf", + "md5": "de7a4a8b1b476b579df606c2d6e7ed05", "link": true, "rounds": 1, "type": "eq" }, { "id": "pal-o47", "file": "pdfs/pal-o47.pdf", + "md5": "81ae15e539e89f0f0b41169d923b611b", "link": true, "rounds": 1, "type": "eq" }, { "id": "simpletype3font", "file": "pdfs/simpletype3font.pdf", + "md5": "b374c7543920840c61999e9e86939f99", "link": false, "rounds": 1, "type": "eq" }, { "id": "close-path-bug", "file": "pdfs/close-path-bug.pdf", + "md5": "48dd17ef58393857d2d038d33699cac5", "rounds": 1, "type": "eq" }, { "id": "alphatrans", "file": "pdfs/alphatrans.pdf", + "md5": "5ca2d3da0c5f20b3a5a14e895ad24b65", "link": false, "rounds": 1, "type": "eq" From a8c94ede1f24035cbe356823b5bd28fa15d1fe12 Mon Sep 17 00:00:00 2001 From: Brendan Dahl Date: Fri, 4 Nov 2011 10:55:00 -0700 Subject: [PATCH 46/66] Updating md5 for tcpdf. --- test/test_manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_manifest.json b/test/test_manifest.json index c3ebe6c05..8085506a2 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -237,7 +237,7 @@ }, { "id": "tcpdf_033", "file": "pdfs/tcpdf_033.pdf", - "md5": "de7a4a8b1b476b579df606c2d6e7ed05", + "md5": "861294df58d185aae80919173f2732ff", "link": true, "rounds": 1, "type": "eq" From d22885a97c62e08ee9f6f7e2c89b839054a19c3a Mon Sep 17 00:00:00 2001 From: Harald Kirschner Date: Fri, 4 Nov 2011 13:23:42 -0700 Subject: [PATCH 47/66] - FIX: Removed unnecessary .bind in worker_loader.js that broke Safari --- src/worker_loader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/worker_loader.js b/src/worker_loader.js index 8d342d116..cb0a91071 100644 --- a/src/worker_loader.js +++ b/src/worker_loader.js @@ -49,4 +49,4 @@ function onMessageLoader(evt) { } } -this.onmessage = onMessageLoader.bind(this); +this.onmessage = onMessageLoader; From ed33d13de57716c49080e286c45031abac2b4967 Mon Sep 17 00:00:00 2001 From: Artur Adib Date: Fri, 4 Nov 2011 16:30:05 -0400 Subject: [PATCH 48/66] Fixes Makefile for web deployment --- Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 3484ab414..35e8675c2 100644 --- a/Makefile +++ b/Makefile @@ -159,7 +159,7 @@ web: | production extension compiler pages-repo \ # everything with data from the master repo. The 'make web' target # then uses 'git add -A' to track additions, modifications, moves, # and deletions. -pages-repo: | $(BUILD_DIR) +pages-repo: | $(BUILD_DIR) @if [ ! -d "$(GH_PAGES)" ]; then \ git clone -b gh-pages $(REPO) $(GH_PAGES); \ rm -rf $(GH_PAGES)/*; \ @@ -169,8 +169,9 @@ pages-repo: | $(BUILD_DIR) @mkdir -p $(GH_PAGES)/build; @mkdir -p $(GH_PAGES)/$(EXTENSION_SRC); -$(GH_PAGES)/$(BUILD_DIR)/%.js: build/%.js - @cp $< $@ +$(GH_PAGES)/$(BUILD_DIR)/pdf.js: + @mkdir -p $(GH_PAGES)/$(BUILD_DIR) + @cp build/pdf.js $(GH_PAGES)/$(BUILD_DIR) $(GH_PAGES)/web/%: web/% @cp $< $@ From 57ecc46b028bbe4c58ea42a54f2b66e72816bf5b Mon Sep 17 00:00:00 2001 From: Artur Adib Date: Fri, 4 Nov 2011 16:37:33 -0400 Subject: [PATCH 49/66] nit --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 35e8675c2..110709906 100644 --- a/Makefile +++ b/Makefile @@ -159,7 +159,7 @@ web: | production extension compiler pages-repo \ # everything with data from the master repo. The 'make web' target # then uses 'git add -A' to track additions, modifications, moves, # and deletions. -pages-repo: | $(BUILD_DIR) +pages-repo: | $(BUILD_DIR) @if [ ! -d "$(GH_PAGES)" ]; then \ git clone -b gh-pages $(REPO) $(GH_PAGES); \ rm -rf $(GH_PAGES)/*; \ From e58c2ab99517ec71a8bf36cf5669a25809e88d9a Mon Sep 17 00:00:00 2001 From: Artur Adib Date: Fri, 4 Nov 2011 17:18:23 -0400 Subject: [PATCH 50/66] Fixing again --- Makefile | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index 110709906..c642f1eb1 100644 --- a/Makefile +++ b/Makefile @@ -139,12 +139,11 @@ lint: # TODO: Use the Closure compiler to optimize the pdf.js files. # GH_PAGES = $(BUILD_DIR)/gh-pages -web: | production extension compiler pages-repo \ - $(addprefix $(GH_PAGES)/, $(BUILD_TARGET)) \ - $(addprefix $(GH_PAGES)/, $(wildcard web/*.*)) \ - $(addprefix $(GH_PAGES)/, $(wildcard web/images/*.*)) \ - $(addprefix $(GH_PAGES)/, $(wildcard $(EXTENSION_SRC)/*.xpi)) - +web: | production extension compiler pages-repo + @cp $(BUILD_TARGET) $(GH_PAGES)/$(BUILD_TARGET) + @cp -R web/* $(GH_PAGES)/web + @cp web/images/* $(GH_PAGES)/web/images + @cp $(EXTENSION_SRC)/*.xpi $(GH_PAGES)/$(EXTENSION_SRC) @cp $(GH_PAGES)/web/index.html.template $(GH_PAGES)/index.html; @mv -f $(GH_PAGES)/web/viewer-production.html $(GH_PAGES)/web/viewer.html; @cd $(GH_PAGES); git add -A; @@ -169,19 +168,6 @@ pages-repo: | $(BUILD_DIR) @mkdir -p $(GH_PAGES)/build; @mkdir -p $(GH_PAGES)/$(EXTENSION_SRC); -$(GH_PAGES)/$(BUILD_DIR)/pdf.js: - @mkdir -p $(GH_PAGES)/$(BUILD_DIR) - @cp build/pdf.js $(GH_PAGES)/$(BUILD_DIR) - -$(GH_PAGES)/web/%: web/% - @cp $< $@ - -$(GH_PAGES)/web/images/%: web/images/% - @cp $< $@ - -$(GH_PAGES)/$(EXTENSION_SRC)/%: $(EXTENSION_SRC)/% - @cp -R $< $@ - # # make compiler # # # # This target downloads the Closure compiler, and places it in the From 1074478274d3bd86efc285a6bef3eb2d3f3ee219 Mon Sep 17 00:00:00 2001 From: Artur Adib Date: Fri, 4 Nov 2011 18:57:01 -0300 Subject: [PATCH 51/66] Dummy commit to test post-receive hook --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8414ad2a9..66be3cd3c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # pdf.js - + ## Overview From ba54b641894340677f8cde7710f2a9c63eed2525 Mon Sep 17 00:00:00 2001 From: Artur Adib Date: Fri, 4 Nov 2011 19:15:30 -0300 Subject: [PATCH 52/66] Dummy commit to test post-receive hook (again) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 66be3cd3c..fc62700f4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # pdf.js - + ## Overview From 8a6ec5f5e073ade9ea73939432ff231808a0da02 Mon Sep 17 00:00:00 2001 From: Artur Adib Date: Fri, 4 Nov 2011 19:41:50 -0300 Subject: [PATCH 53/66] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fc62700f4..66be3cd3c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # pdf.js - + ## Overview From f0f5ebc7b5109917f236a64182a5af68e2f6f6c5 Mon Sep 17 00:00:00 2001 From: Artur Adib Date: Fri, 4 Nov 2011 19:45:05 -0300 Subject: [PATCH 54/66] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 66be3cd3c..8414ad2a9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # pdf.js - + ## Overview From feb621380da9cdc6971f763989bb17378c8ded19 Mon Sep 17 00:00:00 2001 From: Artur Adib Date: Sat, 5 Nov 2011 14:42:50 -0400 Subject: [PATCH 55/66] Disabling workers until localhost fix lands in FF --- src/core.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core.js b/src/core.js index ed16e1a42..9426f5d4d 100644 --- a/src/core.js +++ b/src/core.js @@ -15,6 +15,10 @@ if (!globalScope.PDFJS) { globalScope.PDFJS = {}; } +// Temporarily disabling workers until 'localhost' FF bugfix lands: +// https://bugzilla.mozilla.org/show_bug.cgi?id=683280 +globalScope.PDFJS.disableWorker = true; + // getPdf() // Convenience function to perform binary Ajax GET // Usage: getPdf('http://...', callback) From cac9044161ce9f3deee4fe230d932400b2ae45ac Mon Sep 17 00:00:00 2001 From: Kalervo Kujala Date: Sat, 5 Nov 2011 22:13:16 +0200 Subject: [PATCH 56/66] Refactor colorspace.js and fix jslint warnings. --- src/colorspace.js | 90 ++++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 51 deletions(-) diff --git a/src/colorspace.js b/src/colorspace.js index 6bfad4c39..946a1bdf4 100644 --- a/src/colorspace.js +++ b/src/colorspace.js @@ -23,7 +23,7 @@ var ColorSpace = (function colorSpaceColorSpace() { }; constructor.parse = function colorSpaceParse(cs, xref, res) { - var IR = constructor.parseToIR(cs, xref, res, true); + var IR = constructor.parseToIR(cs, xref, res); if (IR instanceof SeparationCS) return IR; @@ -31,12 +31,7 @@ var ColorSpace = (function colorSpaceColorSpace() { }; constructor.fromIR = function colorSpaceFromIR(IR) { - var name; - if (isArray(IR)) { - name = IR[0]; - } else { - name = IR; - } + var name = isArray(IR) ? IR[0] : IR; switch (name) { case 'DeviceGrayCS': @@ -46,33 +41,28 @@ var ColorSpace = (function colorSpaceColorSpace() { case 'DeviceCmykCS': return new DeviceCmykCS(); case 'PatternCS': - var baseCS = IR[1]; - if (baseCS == null) { - return new PatternCS(null); - } else { - return new PatternCS(ColorSpace.fromIR(baseCS)); - } + var basePatternCS = IR[1]; + if (basePatternCS) + basePatternCS = ColorSpace.fromIR(basePatternCS); + return new PatternCS(basePatternCS); case 'IndexedCS': - var baseCS = IR[1]; + var baseIndexedCS = IR[1]; var hiVal = IR[2]; var lookup = IR[3]; - return new IndexedCS(ColorSpace.fromIR(baseCS), hiVal, lookup); + return new IndexedCS(ColorSpace.fromIR(baseIndexedCS), hiVal, lookup); case 'SeparationCS': var alt = IR[1]; var tintFnIR = IR[2]; - return new SeparationCS( - ColorSpace.fromIR(alt), - PDFFunction.fromIR(tintFnIR) - ); + return new SeparationCS(ColorSpace.fromIR(alt), + PDFFunction.fromIR(tintFnIR)); default: error('Unkown name ' + name); } return null; - } + }; - constructor.parseToIR = function colorSpaceParseToIR(cs, xref, res, - parseOnly) { + constructor.parseToIR = function colorSpaceParseToIR(cs, xref, res) { if (isName(cs)) { var colorSpaces = xref.fetchIfRef(res.get('ColorSpace')); if (isDict(colorSpaces)) { @@ -83,9 +73,10 @@ var ColorSpace = (function colorSpaceColorSpace() { } cs = xref.fetchIfRef(cs); + var mode; if (isName(cs)) { - var mode = cs.name; + mode = cs.name; this.mode = mode; switch (mode) { @@ -104,7 +95,7 @@ var ColorSpace = (function colorSpaceColorSpace() { error('unrecognized colorspace ' + mode); } } else if (isArray(cs)) { - var mode = cs[0].name; + mode = cs[0].name; this.mode = mode; switch (mode) { @@ -133,15 +124,15 @@ var ColorSpace = (function colorSpaceColorSpace() { return 'DeviceCmykCS'; break; case 'Pattern': - var baseCS = cs[1]; - if (baseCS) - baseCS = ColorSpace.parseToIR(baseCS, xref, res); - return ['PatternCS', baseCS]; + var basePatternCS = cs[1]; + if (basePatternCS) + basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res); + return ['PatternCS', basePatternCS]; case 'Indexed': - var baseCS = ColorSpace.parseToIR(cs[1], xref, res); + var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res); var hiVal = cs[2] + 1; var lookup = xref.fetchIfRef(cs[3]); - return ['IndexedCS', baseCS, hiVal, lookup]; + return ['IndexedCS', baseIndexedCS, hiVal, lookup]; case 'Separation': var alt = ColorSpace.parseToIR(cs[2], xref, res); var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3])); @@ -165,7 +156,6 @@ var SeparationCS = (function separationCS() { this.name = 'Separation'; this.numComps = 1; this.defaultColor = [1]; - this.base = base; this.tintFn = tintFn; } @@ -179,12 +169,11 @@ var SeparationCS = (function separationCS() { var tintFn = this.tintFn; var base = this.base; var scale = 1 / ((1 << bits) - 1); - var length = input.length; var pos = 0; - var numComps = base.numComps; var baseBuf = new Uint8Array(numComps * length); + for (var i = 0; i < length; ++i) { var scaled = input[i] * scale; var tinted = tintFn([scaled]); @@ -213,13 +202,13 @@ var IndexedCS = (function indexedCS() { this.name = 'Indexed'; this.numComps = 1; this.defaultColor = [0]; - this.base = base; - var baseNumComps = base.numComps; this.highVal = highVal; + var baseNumComps = base.numComps; var length = baseNumComps * highVal; var lookupArray = new Uint8Array(length); + if (isStream(lookup)) { var bytes = lookup.getBytes(length); lookupArray.set(bytes); @@ -235,7 +224,6 @@ var IndexedCS = (function indexedCS() { constructor.prototype = { getRgb: function indexcs_getRgb(color) { var numComps = this.base.numComps; - var start = color[0] * numComps; var c = []; @@ -249,9 +237,9 @@ var IndexedCS = (function indexedCS() { var numComps = base.numComps; var lookup = this.lookup; var length = input.length; - var baseBuf = new Uint8Array(length * numComps); var baseBufPos = 0; + for (var i = 0; i < length; ++i) { var lookupPos = input[i] * numComps; for (var j = 0; j < numComps; ++j) { @@ -294,7 +282,7 @@ var DeviceGrayCS = (function deviceGrayCS() { })(); var DeviceRgbCS = (function deviceRgbCS() { - function constructor(bits) { + function constructor() { this.name = 'DeviceRGB'; this.numComps = 3; this.defaultColor = [0, 0, 0]; @@ -337,41 +325,41 @@ var DeviceCmykCS = (function deviceCmykCS() { r += 0.1373 * x; g += 0.1216 * x; b += 0.1255 * x; - x = c1 * m1 * y * k1; // 0 0 1 0 + x = c1 * m1 * y * k1; // 0 0 1 0 r += x; g += 0.9490 * x; - x = c1 * m1 * y * k; // 0 0 1 1 + x = c1 * m1 * y * k; // 0 0 1 1 r += 0.1098 * x; g += 0.1020 * x; - x = c1 * m * y1 * k1; // 0 1 0 0 + x = c1 * m * y1 * k1; // 0 1 0 0 r += 0.9255 * x; b += 0.5490 * x; - x = c1 * m * y1 * k; // 0 1 0 1 + x = c1 * m * y1 * k; // 0 1 0 1 r += 0.1412 * x; - x = c1 * m * y * k1; // 0 1 1 0 + x = c1 * m * y * k1; // 0 1 1 0 r += 0.9294 * x; g += 0.1098 * x; b += 0.1412 * x; - x = c1 * m * y * k; // 0 1 1 1 + x = c1 * m * y * k; // 0 1 1 1 r += 0.1333 * x; - x = c * m1 * y1 * k1; // 1 0 0 0 + x = c * m1 * y1 * k1; // 1 0 0 0 g += 0.6784 * x; b += 0.9373 * x; - x = c * m1 * y1 * k; // 1 0 0 1 + x = c * m1 * y1 * k; // 1 0 0 1 g += 0.0588 * x; b += 0.1412 * x; - x = c * m1 * y * k1; // 1 0 1 0 + x = c * m1 * y * k1; // 1 0 1 0 g += 0.6510 * x; b += 0.3137 * x; - x = c * m1 * y * k; // 1 0 1 1 + x = c * m1 * y * k; // 1 0 1 1 g += 0.0745 * x; - x = c * m * y1 * k1; // 1 1 0 0 + x = c * m * y1 * k1; // 1 1 0 0 r += 0.1804 * x; g += 0.1922 * x; b += 0.5725 * x; - x = c * m * y1 * k; // 1 1 0 1 + x = c * m * y1 * k; // 1 1 0 1 b += 0.0078 * x; - x = c * m * y * k1; // 1 1 1 0 + x = c * m * y * k1; // 1 1 1 0 r += 0.2118 * x; g += 0.2119 * x; b += 0.2235 * x; From 7f0e35c50d694245f1bc2ad8506fb0f89a6cf8bf Mon Sep 17 00:00:00 2001 From: Kalervo Kujala Date: Sun, 6 Nov 2011 22:15:41 +0200 Subject: [PATCH 57/66] Remove unused variables. --- src/core.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/core.js b/src/core.js index 303aa8830..5e97763ab 100644 --- a/src/core.js +++ b/src/core.js @@ -161,7 +161,6 @@ var Page = (function pagePage() { var self = this; this.IRQueue = IRQueue; var gfx = new CanvasGraphics(this.ctx, this.objs); - var startTime = Date.now(); var displayContinuation = function pageDisplayContinuation() { // Always defer call to display() to work around bug in @@ -242,7 +241,6 @@ var Page = (function pagePage() { var IRQueue = this.IRQueue; var self = this; - var startTime = Date.now(); function next() { startIdx = gfx.executeIRQueue(IRQueue, startIdx, next); if (startIdx == length) { From b321768f595d2290a9ec80d2b96e46d0feb3b62c Mon Sep 17 00:00:00 2001 From: Kalervo Kujala Date: Sun, 6 Nov 2011 22:16:35 +0200 Subject: [PATCH 58/66] Remove unused parameters and fix jslint warnings. --- src/evaluator.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/evaluator.js b/src/evaluator.js index cb10b200a..064288c6f 100644 --- a/src/evaluator.js +++ b/src/evaluator.js @@ -145,12 +145,12 @@ var PartialEvaluator = (function partialEvaluator() { var font = xref.fetchIfRef(fontRef); assertWellFormed(isDict(font)); if (!font.translated) { - font.translated = self.translateFont(font, xref, resources, handler, - uniquePrefix, dependency); + font.translated = self.translateFont(font, xref, resources, + dependency); if (font.translated) { // keep track of each font we translated so the caller can // load them asynchronously before calling display on a page - loadedName = 'font_' + uniquePrefix + ++self.objIdCounter; + loadedName = 'font_' + uniquePrefix + (++self.objIdCounter); font.translated.properties.loadedName = loadedName; font.loadedName = loadedName; @@ -180,7 +180,7 @@ var PartialEvaluator = (function partialEvaluator() { var h = dict.get('Height', 'H'); if (image instanceof JpegStream) { - var objId = 'img_' + uniquePrefix + ++self.objIdCounter; + var objId = 'img_' + uniquePrefix + (++self.objIdCounter); handler.send('obj', [objId, 'JpegStream', image.getIR()]); // Add the dependency on the image object. @@ -470,7 +470,7 @@ var PartialEvaluator = (function partialEvaluator() { var glyphsWidths = {}; var widths = xref.fetchIfRef(dict.get('W')); if (widths) { - var start = 0, end = 0; + var start = 0; for (var i = 0, ii = widths.length; i < ii; i++) { var code = widths[i]; if (isArray(code)) { @@ -710,7 +710,8 @@ var PartialEvaluator = (function partialEvaluator() { // special case for symbols var encoding = Encodings.symbolsEncoding.slice(); for (var i = 0, n = encoding.length, j; i < n; i++) { - if (!(j = encoding[i])) + j = encoding[i]; + if (!j) continue; map[i] = GlyphsUnicode[j] || 0; } @@ -731,7 +732,7 @@ var PartialEvaluator = (function partialEvaluator() { }, translateFont: function partialEvaluatorTranslateFont(dict, xref, resources, - queue, handler, uniquePrefix, dependency) { + dependency) { var baseDict = dict; var type = dict.get('Subtype'); assertWellFormed(isName(type), 'invalid font Subtype'); From 89a6c4fc88f8624137ae4d0ed00e0a6a59cce8ea Mon Sep 17 00:00:00 2001 From: Kalervo Kujala Date: Sun, 6 Nov 2011 22:17:20 +0200 Subject: [PATCH 59/66] Fix jslint warnings and refactor small issues. --- src/crypto.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/crypto.js b/src/crypto.js index d4d36fb20..955598644 100644 --- a/src/crypto.js +++ b/src/crypto.js @@ -26,7 +26,6 @@ var ARCFourCipher = (function arcFourCipher() { var a = this.a, b = this.b, s = this.s; var output = new Uint8Array(n); for (i = 0; i < n; ++i) { - var tmp; a = (a + 1) & 0xFF; tmp = s[a]; b = (b + tmp) & 0xFF; @@ -75,8 +74,8 @@ var calculateMD5 = (function calculateMD5() { padded[i] = data[offset++]; padded[i++] = 0x80; n = paddedLength - 8; - for (; i < n; ++i) - padded[i] = 0; + while (i < n) + padded[i++] = 0; padded[i++] = (length << 3) & 0xFF; padded[i++] = (length >> 5) & 0xFF; padded[i++] = (length >> 13) & 0xFF; @@ -322,12 +321,12 @@ var AES128Cipher = (function aes128Cipher() { state[10] = state[2]; state[6] = t; state[2] = u; t = state[15]; u = state[11]; v = state[7]; state[15] = state[3]; state[11] = t; state[7] = u; state[3] = v; - // InvSubBytes - for (j = 0; j < 16; ++j) + for (j = 0; j < 16; ++j) { + // InvSubBytes state[j] = inv_s[state[j]]; - // AddRoundKey - for (j = 0; j < 16; ++j) + // AddRoundKey state[j] ^= key[j]; + } return state; } @@ -471,11 +470,11 @@ var CipherTransformFactory = (function cipherTransformFactory() { cipher = new ARCFourCipher(encryptionKey); var checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i)); n = encryptionKey.length; - var derrivedKey = new Uint8Array(n), k; + var derivedKey = new Uint8Array(n), k; for (j = 1; j <= 19; ++j) { for (k = 0; k < n; ++k) - derrivedKey[k] = encryptionKey[k] ^ j; - cipher = new ARCFourCipher(derrivedKey); + derivedKey[k] = encryptionKey[k] ^ j; + cipher = new ARCFourCipher(derivedKey); checkData = cipher.encryptBlock(checkData); } } else { From 6e10114647e087be0fa77be6d3d29c177f0b4b29 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas <21@vingtetun.org> Date: Mon, 7 Nov 2011 16:01:50 +0100 Subject: [PATCH 60/66] Add content/ to the viewer.html path --- extensions/chrome/pdfHandler.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extensions/chrome/pdfHandler.html b/extensions/chrome/pdfHandler.html index dcce1a665..c13e24c57 100644 --- a/extensions/chrome/pdfHandler.html +++ b/extensions/chrome/pdfHandler.html @@ -2,7 +2,8 @@