Kill global vars FontsMap, FontLoadedCounter, objIdCounter.
This commit is contained in:
parent
633baa881f
commit
9b8ce24924
42
pdf.js
42
pdf.js
@ -3580,10 +3580,9 @@ var Page = (function pagePage() {
|
|||||||
content = new StreamsSequenceStream(content);
|
content = new StreamsSequenceStream(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
var pe = this.pe = new PartialEvaluator();
|
var pe = this.pe = new PartialEvaluator(xref, handler, 'p' + this.pageNumber + '_');
|
||||||
var IRQueue = {};
|
var IRQueue = {};
|
||||||
return this.IRQueue = pe.getIRQueue(content, xref, resources, IRQueue,
|
return this.IRQueue = pe.getIRQueue(content, resources, IRQueue, dependency);
|
||||||
handler, 'p' + this.pageNumber + '_', dependency);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
ensureFonts: function(fonts, callback) {
|
ensureFonts: function(fonts, callback) {
|
||||||
@ -4451,15 +4450,15 @@ var EvalState = (function evalState() {
|
|||||||
return constructor;
|
return constructor;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
var FontsMap = {};
|
|
||||||
var FontLoadedCounter = 0;
|
|
||||||
|
|
||||||
var objIdCounter = 0;
|
|
||||||
|
|
||||||
var PartialEvaluator = (function partialEvaluator() {
|
var PartialEvaluator = (function partialEvaluator() {
|
||||||
function constructor() {
|
function constructor(xref, handler, uniquePrefix) {
|
||||||
this.state = new EvalState();
|
this.state = new EvalState();
|
||||||
this.stateStack = [];
|
this.stateStack = [];
|
||||||
|
|
||||||
|
this.xref = xref;
|
||||||
|
this.handler = handler;
|
||||||
|
this.uniquePrefix = uniquePrefix;
|
||||||
|
this.objIdCounter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
var OP_MAP = {
|
var OP_MAP = {
|
||||||
@ -4560,8 +4559,12 @@ var PartialEvaluator = (function partialEvaluator() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
constructor.prototype = {
|
constructor.prototype = {
|
||||||
getIRQueue: function partialEvaluatorGetIRQueue(stream, xref, resources,
|
getIRQueue: function partialEvaluatorGetIRQueue(stream, resources,
|
||||||
queue, handler, uniquePrefix, dependency) {
|
queue, dependency) {
|
||||||
|
|
||||||
|
var xref = this.xref;
|
||||||
|
var handler = this.handler;
|
||||||
|
var uniquePrefix = this.uniquePrefix;
|
||||||
|
|
||||||
function insertDependency(depList) {
|
function insertDependency(depList) {
|
||||||
fnArray.push('dependency');
|
fnArray.push('dependency');
|
||||||
@ -4590,10 +4593,9 @@ var PartialEvaluator = (function partialEvaluator() {
|
|||||||
if (font.translated) {
|
if (font.translated) {
|
||||||
// keep track of each font we translated so the caller can
|
// keep track of each font we translated so the caller can
|
||||||
// load them asynchronously before calling display on a page
|
// load them asynchronously before calling display on a page
|
||||||
loadedName = 'font_' + uniquePrefix + (FontLoadedCounter++);
|
loadedName = 'font_' + uniquePrefix + ++this.objIdCounter;
|
||||||
font.translated.properties.loadedName = loadedName;
|
font.translated.properties.loadedName = loadedName;
|
||||||
font.loadedName = loadedName;
|
font.loadedName = loadedName;
|
||||||
FontsMap[loadedName] = font;
|
|
||||||
|
|
||||||
handler.send('obj', [
|
handler.send('obj', [
|
||||||
loadedName,
|
loadedName,
|
||||||
@ -4625,7 +4627,7 @@ var PartialEvaluator = (function partialEvaluator() {
|
|||||||
var h = dict.get('Height', 'H');
|
var h = dict.get('Height', 'H');
|
||||||
|
|
||||||
if (image instanceof JpegStream) {
|
if (image instanceof JpegStream) {
|
||||||
var objId = 'img_' + ++objIdCounter;
|
var objId = 'img_' + uniquePrefix + ++self.objIdCounter;
|
||||||
handler.send('obj', [objId, 'JpegStream', image.getIR()]);
|
handler.send('obj', [objId, 'JpegStream', image.getIR()]);
|
||||||
|
|
||||||
// Add the dependency on the image object.
|
// Add the dependency on the image object.
|
||||||
@ -4735,9 +4737,8 @@ var PartialEvaluator = (function partialEvaluator() {
|
|||||||
if (typeNum == 1) {
|
if (typeNum == 1) {
|
||||||
// Create an IR of the pattern code.
|
// Create an IR of the pattern code.
|
||||||
var depIdx = dependency.length;
|
var depIdx = dependency.length;
|
||||||
var codeIR = this.getIRQueue(pattern, xref,
|
var codeIR = this.getIRQueue(pattern,
|
||||||
dict.get('Resources'), {}, handler,
|
dict.get('Resources'), {}, dependency);
|
||||||
uniquePrefix, dependency);
|
|
||||||
|
|
||||||
// Add the dependencies that are required to execute the
|
// Add the dependencies that are required to execute the
|
||||||
// codeIR.
|
// codeIR.
|
||||||
@ -4781,8 +4782,7 @@ var PartialEvaluator = (function partialEvaluator() {
|
|||||||
// This adds the IRQueue of the xObj to the current queue.
|
// This adds the IRQueue of the xObj to the current queue.
|
||||||
var depIdx = dependency.length;
|
var depIdx = dependency.length;
|
||||||
|
|
||||||
this.getIRQueue(xobj, xref, xobj.dict.get('Resources'), queue,
|
this.getIRQueue(xobj, xobj.dict.get('Resources'), queue, dependency);
|
||||||
handler, uniquePrefix, dependency);
|
|
||||||
|
|
||||||
// Add the dependencies that are required to execute the
|
// Add the dependencies that are required to execute the
|
||||||
// codeIR.
|
// codeIR.
|
||||||
@ -5318,8 +5318,8 @@ var PartialEvaluator = (function partialEvaluator() {
|
|||||||
for (var key in charProcs.map) {
|
for (var key in charProcs.map) {
|
||||||
var glyphStream = xref.fetchIfRef(charProcs.map[key]);
|
var glyphStream = xref.fetchIfRef(charProcs.map[key]);
|
||||||
var queue = {};
|
var queue = {};
|
||||||
properties.glyphs[key].IRQueue = this.getIRQueue(glyphStream, xref,
|
properties.glyphs[key].IRQueue = this.getIRQueue(glyphStream,
|
||||||
fontResources, queue, handler, uniquePrefix, dependency);
|
fontResources, queue, dependency);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
ewer/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var kDefaultURL = 'compressed.tracemonkey-pldi-09.pdf';
|
var kDefaultURL = 'compressed.tracemonkey-pldi-09.pdf';
|
||||||
var kDefaultScale = 1;
|
var kDefaultScale = 1.5;
|
||||||
var kDefaultScaleDelta = 1.1;
|
var kDefaultScaleDelta = 1.1;
|
||||||
var kCacheSize = 20;
|
var kCacheSize = 20;
|
||||||
var kCssUnits = 96.0 / 72.0;
|
var kCssUnits = 96.0 / 72.0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user