Replaces literal {} created lookup tables with Object.create

This commit is contained in:
Yury Delendik 2016-01-27 11:04:13 -06:00
parent d6adf84159
commit 2edf2792dc
18 changed files with 106 additions and 104 deletions

View File

@ -313,9 +313,9 @@ var ChunkedStreamManager = (function ChunkedStreamManagerClosure() {
this.currRequestId = 0; this.currRequestId = 0;
this.chunksNeededByRequest = {}; this.chunksNeededByRequest = Object.create(null);
this.requestsByChunk = {}; this.requestsByChunk = Object.create(null);
this.promisesByRequest = {}; this.promisesByRequest = Object.create(null);
this.progressiveDataLength = 0; this.progressiveDataLength = 0;
this._loadedStreamCapability = createPromiseCapability(); this._loadedStreamCapability = createPromiseCapability();
@ -341,9 +341,9 @@ var ChunkedStreamManager = (function ChunkedStreamManagerClosure() {
_requestChunks: function ChunkedStreamManager_requestChunks(chunks) { _requestChunks: function ChunkedStreamManager_requestChunks(chunks) {
var requestId = this.currRequestId++; var requestId = this.currRequestId++;
var chunksNeeded;
var i, ii; var i, ii;
this.chunksNeededByRequest[requestId] = chunksNeeded = {}; var chunksNeeded = Object.create(null);
this.chunksNeededByRequest[requestId] = chunksNeeded;
for (i = 0, ii = chunks.length; i < ii; i++) { for (i = 0, ii = chunks.length; i < ii; i++) {
if (!this.stream.hasChunk(chunks[i])) { if (!this.stream.hasChunk(chunks[i])) {
chunksNeeded[chunks[i]] = true; chunksNeeded[chunks[i]] = true;

View File

@ -731,7 +731,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
var self = this; var self = this;
var xref = this.xref; var xref = this.xref;
var imageCache = {}; var imageCache = Object.create(null);
assert(operatorList); assert(operatorList);
@ -1054,7 +1054,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
// The xobj is parsed iff it's needed, e.g. if there is a `DO` cmd. // The xobj is parsed iff it's needed, e.g. if there is a `DO` cmd.
var xobjs = null; var xobjs = null;
var xobjsCache = {}; var xobjsCache = Object.create(null);
var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager); var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
@ -2093,7 +2093,7 @@ var TranslatedFont = (function TranslatedFontClosure() {
var charProcs = this.dict.get('CharProcs').getAll(); var charProcs = this.dict.get('CharProcs').getAll();
var fontResources = this.dict.get('Resources') || resources; var fontResources = this.dict.get('Resources') || resources;
var charProcKeys = Object.keys(charProcs); var charProcKeys = Object.keys(charProcs);
var charProcOperatorList = {}; var charProcOperatorList = Object.create(null);
for (var i = 0, n = charProcKeys.length; i < n; ++i) { for (var i = 0, n = charProcKeys.length; i < n; ++i) {
loadCharProcsPromise = loadCharProcsPromise.then(function (key) { loadCharProcsPromise = loadCharProcsPromise.then(function (key) {
var glyphStream = charProcs[key]; var glyphStream = charProcs[key];
@ -2147,7 +2147,7 @@ var OperatorList = (function OperatorListClosure() {
this.messageHandler = messageHandler; this.messageHandler = messageHandler;
this.fnArray = []; this.fnArray = [];
this.argsArray = []; this.argsArray = [];
this.dependencies = {}; this.dependencies = Object.create(null);
this._totalLength = 0; this._totalLength = 0;
this.pageIndex = pageIndex; this.pageIndex = pageIndex;
this.intent = intent; this.intent = intent;
@ -2227,7 +2227,7 @@ var OperatorList = (function OperatorListClosure() {
pageIndex: this.pageIndex, pageIndex: this.pageIndex,
intent: this.intent intent: this.intent
}, transfers); }, transfers);
this.dependencies = {}; this.dependencies = Object.create(null);
this.fnArray.length = 0; this.fnArray.length = 0;
this.argsArray.length = 0; this.argsArray.length = 0;
} }

View File

@ -609,7 +609,7 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
var noop = ''; var noop = '';
function CompiledFont(fontMatrix) { function CompiledFont(fontMatrix) {
this.compiledGlyphs = {}; this.compiledGlyphs = Object.create(null);
this.fontMatrix = fontMatrix; this.fontMatrix = fontMatrix;
} }
CompiledFont.prototype = { CompiledFont.prototype = {

View File

@ -469,7 +469,7 @@ var Font = (function FontClosure() {
this.isType3Font = properties.isType3Font; this.isType3Font = properties.isType3Font;
this.sizes = []; this.sizes = [];
this.glyphCache = {}; this.glyphCache = Object.create(null);
var names = name.split('+'); var names = name.split('+');
names = names.length > 1 ? names[1] : names[0]; names = names.length > 1 ? names[1] : names[0];
@ -1218,6 +1218,7 @@ var Font = (function FontClosure() {
}, },
exportData: function Font_exportData() { exportData: function Font_exportData() {
// TODO remove enumerating of the properties, e.g. hardcode exact names.
var data = {}; var data = {};
for (var i in this) { for (var i in this) {
if (this.hasOwnProperty(i)) { if (this.hasOwnProperty(i)) {
@ -1668,7 +1669,7 @@ var Font = (function FontClosure() {
var newGlyfData = new Uint8Array(oldGlyfDataLength); var newGlyfData = new Uint8Array(oldGlyfDataLength);
var startOffset = itemDecode(locaData, 0); var startOffset = itemDecode(locaData, 0);
var writeOffset = 0; var writeOffset = 0;
var missingGlyphData = {}; var missingGlyphData = Object.create(null);
itemEncode(locaData, 0, writeOffset); itemEncode(locaData, 0, writeOffset);
var i, j; var i, j;
for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) { for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
@ -2100,8 +2101,16 @@ var Font = (function FontClosure() {
var numTables = header.numTables; var numTables = header.numTables;
var cff, cffFile; var cff, cffFile;
var tables = { 'OS/2': null, cmap: null, head: null, hhea: null, var tables = Object.create(null);
hmtx: null, maxp: null, name: null, post: null }; tables['OS/2'] = null;
tables['cmap'] = null;
tables['head'] = null;
tables['hhea'] = null;
tables['hmtx'] = null;
tables['maxp'] = null;
tables['name'] = null;
tables['post'] = null;
var table; var table;
for (var i = 0; i < numTables; i++) { for (var i = 0; i < numTables; i++) {
table = readTableEntry(font); table = readTableEntry(font);
@ -2118,7 +2127,8 @@ var Font = (function FontClosure() {
if (!isTrueType) { if (!isTrueType) {
// OpenType font // OpenType font
if ((header.version === 'OTTO' && properties.type !== 'CIDFontType2') || if ((header.version === 'OTTO' && properties.type !== 'CIDFontType2') ||
!tables.head || !tables.hhea || !tables.maxp || !tables.post) { !tables['head'] || !tables['hhea'] || !tables['maxp'] ||
!tables['post']) {
// no major tables: throwing everything at CFFFont // no major tables: throwing everything at CFFFont
cffFile = new Stream(tables['CFF '].data); cffFile = new Stream(tables['CFF '].data);
cff = new CFFFont(cffFile, properties); cff = new CFFFont(cffFile, properties);
@ -2128,20 +2138,20 @@ var Font = (function FontClosure() {
return this.convert(name, cff, properties); return this.convert(name, cff, properties);
} }
delete tables.glyf; delete tables['glyf'];
delete tables.loca; delete tables['loca'];
delete tables.fpgm; delete tables['fpgm'];
delete tables.prep; delete tables['prep'];
delete tables['cvt ']; delete tables['cvt '];
this.isOpenType = true; this.isOpenType = true;
} else { } else {
if (!tables.loca) { if (!tables['loca']) {
error('Required "loca" table is not found'); error('Required "loca" table is not found');
} }
if (!tables.glyf) { if (!tables['glyf']) {
warn('Required "glyf" table is not found -- trying to recover.'); warn('Required "glyf" table is not found -- trying to recover.');
// Note: We use `sanitizeGlyphLocations` to add dummy glyf data below. // Note: We use `sanitizeGlyphLocations` to add dummy glyf data below.
tables.glyf = { tables['glyf'] = {
tag: 'glyf', tag: 'glyf',
data: new Uint8Array(0), data: new Uint8Array(0),
}; };
@ -2149,21 +2159,21 @@ var Font = (function FontClosure() {
this.isOpenType = false; this.isOpenType = false;
} }
if (!tables.maxp) { if (!tables['maxp']) {
error('Required "maxp" table is not found'); error('Required "maxp" table is not found');
} }
font.pos = (font.start || 0) + tables.maxp.offset; font.pos = (font.start || 0) + tables['maxp'].offset;
var version = font.getInt32(); var version = font.getInt32();
var numGlyphs = font.getUint16(); var numGlyphs = font.getUint16();
var maxFunctionDefs = 0; var maxFunctionDefs = 0;
if (version >= 0x00010000 && tables.maxp.length >= 22) { if (version >= 0x00010000 && tables['maxp'].length >= 22) {
// maxZones can be invalid // maxZones can be invalid
font.pos += 8; font.pos += 8;
var maxZones = font.getUint16(); var maxZones = font.getUint16();
if (maxZones > 2) { // reset to 2 if font has invalid maxZones if (maxZones > 2) { // reset to 2 if font has invalid maxZones
tables.maxp.data[14] = 0; tables['maxp'].data[14] = 0;
tables.maxp.data[15] = 2; tables['maxp'].data[15] = 2;
} }
font.pos += 4; font.pos += 4;
maxFunctionDefs = font.getUint16(); maxFunctionDefs = font.getUint16();
@ -2175,56 +2185,57 @@ var Font = (function FontClosure() {
// oracle's defect (see 3427), duplicating first entry // oracle's defect (see 3427), duplicating first entry
dupFirstEntry = true; dupFirstEntry = true;
numGlyphs++; numGlyphs++;
tables.maxp.data[4] = numGlyphs >> 8; tables['maxp'].data[4] = numGlyphs >> 8;
tables.maxp.data[5] = numGlyphs & 255; tables['maxp'].data[5] = numGlyphs & 255;
} }
var hintsValid = sanitizeTTPrograms(tables.fpgm, tables.prep, var hintsValid = sanitizeTTPrograms(tables['fpgm'], tables['prep'],
tables['cvt '], maxFunctionDefs); tables['cvt '], maxFunctionDefs);
if (!hintsValid) { if (!hintsValid) {
delete tables.fpgm; delete tables['fpgm'];
delete tables.prep; delete tables['prep'];
delete tables['cvt ']; delete tables['cvt '];
} }
// Ensure the hmtx table contains the advance width and // Ensure the hmtx table contains the advance width and
// sidebearings information for numGlyphs in the maxp table // sidebearings information for numGlyphs in the maxp table
sanitizeMetrics(font, tables.hhea, tables.hmtx, numGlyphs); sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs);
if (!tables.head) { if (!tables['head']) {
error('Required "head" table is not found'); error('Required "head" table is not found');
} }
sanitizeHead(tables.head, numGlyphs, isTrueType ? tables.loca.length : 0); sanitizeHead(tables['head'], numGlyphs,
isTrueType ? tables['loca'].length : 0);
var missingGlyphs = {}; var missingGlyphs = Object.create(null);
if (isTrueType) { if (isTrueType) {
var isGlyphLocationsLong = int16(tables.head.data[50], var isGlyphLocationsLong = int16(tables['head'].data[50],
tables.head.data[51]); tables['head'].data[51]);
missingGlyphs = sanitizeGlyphLocations(tables.loca, tables.glyf, missingGlyphs = sanitizeGlyphLocations(tables['loca'], tables['glyf'],
numGlyphs, isGlyphLocationsLong, numGlyphs, isGlyphLocationsLong,
hintsValid, dupFirstEntry); hintsValid, dupFirstEntry);
} }
if (!tables.hhea) { if (!tables['hhea']) {
error('Required "hhea" table is not found'); error('Required "hhea" table is not found');
} }
// Sanitizer reduces the glyph advanceWidth to the maxAdvanceWidth // Sanitizer reduces the glyph advanceWidth to the maxAdvanceWidth
// Sometimes it's 0. That needs to be fixed // Sometimes it's 0. That needs to be fixed
if (tables.hhea.data[10] === 0 && tables.hhea.data[11] === 0) { if (tables['hhea'].data[10] === 0 && tables['hhea'].data[11] === 0) {
tables.hhea.data[10] = 0xFF; tables['hhea'].data[10] = 0xFF;
tables.hhea.data[11] = 0xFF; tables['hhea'].data[11] = 0xFF;
} }
// Extract some more font properties from the OpenType head and // Extract some more font properties from the OpenType head and
// hhea tables; yMin and descent value are always negative. // hhea tables; yMin and descent value are always negative.
var metricsOverride = { var metricsOverride = {
unitsPerEm: int16(tables.head.data[18], tables.head.data[19]), unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]),
yMax: int16(tables.head.data[42], tables.head.data[43]), yMax: int16(tables['head'].data[42], tables['head'].data[43]),
yMin: int16(tables.head.data[38], tables.head.data[39]) - 0x10000, yMin: int16(tables['head'].data[38], tables['head'].data[39]) - 0x10000,
ascent: int16(tables.hhea.data[4], tables.hhea.data[5]), ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]),
descent: int16(tables.hhea.data[6], tables.hhea.data[7]) - 0x10000 descent: int16(tables['hhea'].data[6], tables['hhea'].data[7]) - 0x10000
}; };
// PDF FontDescriptor metrics lie -- using data from actual font. // PDF FontDescriptor metrics lie -- using data from actual font.
@ -2232,10 +2243,10 @@ var Font = (function FontClosure() {
this.descent = metricsOverride.descent / metricsOverride.unitsPerEm; this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
// The 'post' table has glyphs names. // The 'post' table has glyphs names.
if (tables.post) { if (tables['post']) {
var valid = readPostScriptTable(tables.post, properties, numGlyphs); var valid = readPostScriptTable(tables['post'], properties, numGlyphs);
if (!valid) { if (!valid) {
tables.post = null; tables['post'] = null;
} }
} }
@ -2287,7 +2298,7 @@ var Font = (function FontClosure() {
var hasEncoding = var hasEncoding =
properties.differences.length > 0 || !!properties.baseEncodingName; properties.differences.length > 0 || !!properties.baseEncodingName;
var cmapTable = var cmapTable =
readCmapTable(tables.cmap, font, this.isSymbolicFont, hasEncoding); readCmapTable(tables['cmap'], font, this.isSymbolicFont, hasEncoding);
var cmapPlatformId = cmapTable.platformId; var cmapPlatformId = cmapTable.platformId;
var cmapEncodingId = cmapTable.encodingId; var cmapEncodingId = cmapTable.encodingId;
var cmapMappings = cmapTable.mappings; var cmapMappings = cmapTable.mappings;
@ -2394,7 +2405,7 @@ var Font = (function FontClosure() {
// Converting glyphs and ids into font's cmap table // Converting glyphs and ids into font's cmap table
var newMapping = adjustMapping(charCodeToGlyphId, properties); var newMapping = adjustMapping(charCodeToGlyphId, properties);
this.toFontChar = newMapping.toFontChar; this.toFontChar = newMapping.toFontChar;
tables.cmap = { tables['cmap'] = {
tag: 'cmap', tag: 'cmap',
data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs) data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs)
}; };
@ -2408,8 +2419,8 @@ var Font = (function FontClosure() {
} }
// Rewrite the 'post' table if needed // Rewrite the 'post' table if needed
if (!tables.post) { if (!tables['post']) {
tables.post = { tables['post'] = {
tag: 'post', tag: 'post',
data: createPostTable(properties) data: createPostTable(properties)
}; };
@ -2429,15 +2440,15 @@ var Font = (function FontClosure() {
} }
// Re-creating 'name' table // Re-creating 'name' table
if (!tables.name) { if (!tables['name']) {
tables.name = { tables['name'] = {
tag: 'name', tag: 'name',
data: createNameTable(this.name) data: createNameTable(this.name)
}; };
} else { } else {
// ... using existing 'name' table as prototype // ... using existing 'name' table as prototype
var namePrototype = readNameTable(tables.name); var namePrototype = readNameTable(tables['name']);
tables.name.data = createNameTable(name, namePrototype); tables['name'].data = createNameTable(name, namePrototype);
} }
var builder = new OpenTypeFileBuilder(header.version); var builder = new OpenTypeFileBuilder(header.version);
@ -2855,7 +2866,7 @@ var Font = (function FontClosure() {
if (this.cMap) { if (this.cMap) {
// composite fonts have multi-byte strings convert the string from // composite fonts have multi-byte strings convert the string from
// single-byte to multi-byte // single-byte to multi-byte
var c = {}; var c = Object.create(null);
while (i < chars.length) { while (i < chars.length) {
this.cMap.readCharCode(chars, i, c); this.cMap.readCharCode(chars, i, c);
charcode = c.charcode; charcode = c.charcode;
@ -3442,13 +3453,13 @@ var Type1Parser = (function Type1ParserClosure() {
var stream = this.stream; var stream = this.stream;
var subrs = [], charstrings = []; var subrs = [], charstrings = [];
var privateData = Object.create(null);
privateData['lenIV'] = 4;
var program = { var program = {
subrs: [], subrs: [],
charstrings: [], charstrings: [],
properties: { properties: {
'privateData': { 'privateData': privateData
'lenIV': 4
}
} }
}; };
var token, length, data, lenIV, encoded; var token, length, data, lenIV, encoded;
@ -3770,7 +3781,7 @@ Type1Font.prototype = {
} }
var encoding = properties.builtInEncoding; var encoding = properties.builtInEncoding;
if (encoding) { if (encoding) {
var builtInEncoding = {}; var builtInEncoding = Object.create(null);
for (var charCode in encoding) { for (var charCode in encoding) {
glyphId = glyphNames.indexOf(encoding[charCode]); glyphId = glyphNames.indexOf(encoding[charCode]);
if (glyphId >= 0) { if (glyphId >= 0) {
@ -3904,7 +3915,7 @@ Type1Font.prototype = {
]; ];
for (i = 0, ii = fields.length; i < ii; i++) { for (i = 0, ii = fields.length; i < ii; i++) {
var field = fields[i]; var field = fields[i];
if (!properties.privateData.hasOwnProperty(field)) { if (!(field in properties.privateData)) {
continue; continue;
} }
var value = properties.privateData[field]; var value = properties.privateData[field];
@ -4655,7 +4666,7 @@ var CFFParser = (function CFFParserClosure() {
properties, properties,
strings, strings,
charset) { charset) {
var encoding = {}; var encoding = Object.create(null);
var bytes = this.bytes; var bytes = this.bytes;
var predefined = false; var predefined = false;
var hasSupplement = false; var hasSupplement = false;
@ -4851,7 +4862,7 @@ var CFFDict = (function CFFDictClosure() {
this.opcodes = tables.opcodes; this.opcodes = tables.opcodes;
this.order = tables.order; this.order = tables.order;
this.strings = strings; this.strings = strings;
this.values = {}; this.values = Object.create(null);
} }
CFFDict.prototype = { CFFDict.prototype = {
// value should always be an array // value should always be an array
@ -5048,7 +5059,7 @@ var CFFFDSelect = (function CFFFDSelectClosure() {
// filling in that offset once it's known. // filling in that offset once it's known.
var CFFOffsetTracker = (function CFFOffsetTrackerClosure() { var CFFOffsetTracker = (function CFFOffsetTrackerClosure() {
function CFFOffsetTracker() { function CFFOffsetTracker() {
this.offsets = {}; this.offsets = Object.create(null);
} }
CFFOffsetTracker.prototype = { CFFOffsetTracker.prototype = {
isTracking: function CFFOffsetTracker_isTracking(key) { isTracking: function CFFOffsetTracker_isTracking(key) {

View File

@ -434,7 +434,7 @@ var PDFFunction = (function PDFFunctionClosure() {
var evaluator = new PostScriptEvaluator(code); var evaluator = new PostScriptEvaluator(code);
// Cache the values for a big speed up, the cache size is limited though // Cache the values for a big speed up, the cache size is limited though
// since the number of possible values can be huge from a PS function. // since the number of possible values can be huge from a PS function.
var cache = {}; var cache = Object.create(null);
// The MAX_CACHE_SIZE is set to ~4x the maximum number of distinct values // The MAX_CACHE_SIZE is set to ~4x the maximum number of distinct values
// seen in our tests. // seen in our tests.
var MAX_CACHE_SIZE = 2048 * 4; var MAX_CACHE_SIZE = 2048 * 4;

View File

@ -52,8 +52,8 @@ var NetworkManager = (function NetworkManagerClosure() {
}; };
this.currXhrId = 0; this.currXhrId = 0;
this.pendingRequests = {}; this.pendingRequests = Object.create(null);
this.loadedRequests = {}; this.loadedRequests = Object.create(null);
} }
function getArrayBuffer(xhr) { function getArrayBuffer(xhr) {

View File

@ -229,9 +229,6 @@ var Catalog = (function CatalogClosure() {
var nameTree = new NameTree(nameTreeRef, xref); var nameTree = new NameTree(nameTreeRef, xref);
var names = nameTree.getAll(); var names = nameTree.getAll();
for (var name in names) { for (var name in names) {
if (!names.hasOwnProperty(name)) {
continue;
}
dests[name] = fetchDestination(names[name]); dests[name] = fetchDestination(names[name]);
} }
} }
@ -291,7 +288,7 @@ var Catalog = (function CatalogClosure() {
var currentLabel = '', currentIndex = 1; var currentLabel = '', currentIndex = 1;
for (var i = 0, ii = this.numPages; i < ii; i++) { for (var i = 0, ii = this.numPages; i < ii; i++) {
if (nums.hasOwnProperty(i)) { if (i in nums) {
var labelDict = nums[i]; var labelDict = nums[i];
assert(isDict(labelDict), 'The PageLabel is not a dictionary.'); assert(isDict(labelDict), 'The PageLabel is not a dictionary.');
@ -365,12 +362,9 @@ var Catalog = (function CatalogClosure() {
var nameTree = new NameTree(nameTreeRef, xref); var nameTree = new NameTree(nameTreeRef, xref);
var names = nameTree.getAll(); var names = nameTree.getAll();
for (var name in names) { for (var name in names) {
if (!names.hasOwnProperty(name)) {
continue;
}
var fs = new FileSpec(names[name], xref); var fs = new FileSpec(names[name], xref);
if (!attachments) { if (!attachments) {
attachments = {}; attachments = Object.create(null);
} }
attachments[stringToPDFString(name)] = fs.serializable; attachments[stringToPDFString(name)] = fs.serializable;
} }
@ -399,9 +393,6 @@ var Catalog = (function CatalogClosure() {
var nameTree = new NameTree(obj.getRaw('JavaScript'), xref); var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);
var names = nameTree.getAll(); var names = nameTree.getAll();
for (var name in names) { for (var name in names) {
if (!names.hasOwnProperty(name)) {
continue;
}
// We don't really use the JavaScript right now. This code is // We don't really use the JavaScript right now. This code is
// defensive so we don't cause errors on document load. // defensive so we don't cause errors on document load.
var jsDict = names[name]; var jsDict = names[name];
@ -602,7 +593,7 @@ var XRef = (function XRefClosure() {
function XRef(stream, password) { function XRef(stream, password) {
this.stream = stream; this.stream = stream;
this.entries = []; this.entries = [];
this.xrefstms = {}; this.xrefstms = Object.create(null);
// prepare the XRef cache // prepare the XRef cache
this.cache = []; this.cache = [];
this.password = password; this.password = password;
@ -1239,7 +1230,7 @@ var NameOrNumberTree = (function NameOrNumberTreeClosure() {
NameOrNumberTree.prototype = { NameOrNumberTree.prototype = {
getAll: function NameOrNumberTree_getAll() { getAll: function NameOrNumberTree_getAll() {
var dict = {}; var dict = Object.create(null);
if (!this.root) { if (!this.root) {
return dict; return dict;
} }

View File

@ -70,7 +70,7 @@ var Parser = (function ParserClosure() {
this.lexer = lexer; this.lexer = lexer;
this.allowStreams = allowStreams; this.allowStreams = allowStreams;
this.xref = xref; this.xref = xref;
this.imageCache = {}; this.imageCache = Object.create(null);
this.refill(); this.refill();
} }

View File

@ -35,7 +35,7 @@ var Name = (function NameClosure() {
Name.prototype = {}; Name.prototype = {};
var nameCache = {}; var nameCache = Object.create(null);
Name.get = function Name_get(name) { Name.get = function Name_get(name) {
var nameValue = nameCache[name]; var nameValue = nameCache[name];
@ -52,7 +52,7 @@ var Cmd = (function CmdClosure() {
Cmd.prototype = {}; Cmd.prototype = {};
var cmdCache = {}; var cmdCache = Object.create(null);
Cmd.get = function Cmd_get(cmd) { Cmd.get = function Cmd_get(cmd) {
var cmdValue = cmdCache[cmd]; var cmdValue = cmdCache[cmd];
@ -281,7 +281,7 @@ var Ref = (function RefClosure() {
// This structure stores only one instance of the reference. // This structure stores only one instance of the reference.
var RefSet = (function RefSetClosure() { var RefSet = (function RefSetClosure() {
function RefSet() { function RefSet() {
this.dict = {}; this.dict = Object.create(null);
} }
RefSet.prototype = { RefSet.prototype = {

View File

@ -126,7 +126,7 @@ var PostScriptToken = (function PostScriptTokenClosure() {
this.value = value; this.value = value;
} }
var opCache = {}; var opCache = Object.create(null);
PostScriptToken.getOperator = function PostScriptToken_getOperator(op) { PostScriptToken.getOperator = function PostScriptToken_getOperator(op) {
var opValue = opCache[op]; var opValue = opCache[op];

View File

@ -873,7 +873,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
this.objs = new PDFObjects(); this.objs = new PDFObjects();
this.cleanupAfterRender = false; this.cleanupAfterRender = false;
this.pendingCleanup = false; this.pendingCleanup = false;
this.intentStates = {}; this.intentStates = Object.create(null);
this.destroyed = false; this.destroyed = false;
} }
PDFPageProxy.prototype = /** @lends PDFPageProxy.prototype */ { PDFPageProxy.prototype = /** @lends PDFPageProxy.prototype */ {
@ -948,7 +948,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
var renderingIntent = (params.intent === 'print' ? 'print' : 'display'); var renderingIntent = (params.intent === 'print' ? 'print' : 'display');
if (!this.intentStates[renderingIntent]) { if (!this.intentStates[renderingIntent]) {
this.intentStates[renderingIntent] = {}; this.intentStates[renderingIntent] = Object.create(null);
} }
var intentState = this.intentStates[renderingIntent]; var intentState = this.intentStates[renderingIntent];
@ -1040,7 +1040,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
var renderingIntent = 'oplist'; var renderingIntent = 'oplist';
if (!this.intentStates[renderingIntent]) { if (!this.intentStates[renderingIntent]) {
this.intentStates[renderingIntent] = {}; this.intentStates[renderingIntent] = Object.create(null);
} }
var intentState = this.intentStates[renderingIntent]; var intentState = this.intentStates[renderingIntent];
@ -1871,7 +1871,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
*/ */
var PDFObjects = (function PDFObjectsClosure() { var PDFObjects = (function PDFObjectsClosure() {
function PDFObjects() { function PDFObjects() {
this.objs = {}; this.objs = Object.create(null);
} }
PDFObjects.prototype = { PDFObjects.prototype = {
@ -1962,7 +1962,7 @@ var PDFObjects = (function PDFObjectsClosure() {
}, },
clear: function PDFObjects_clear() { clear: function PDFObjects_clear() {
this.objs = {}; this.objs = Object.create(null);
} }
}; };
return PDFObjects; return PDFObjects;

View File

@ -39,7 +39,7 @@ var CustomStyle = (function CustomStyleClosure() {
// in some versions of IE9 it is critical that ms appear in this list // in some versions of IE9 it is critical that ms appear in this list
// before Moz // before Moz
var prefixes = ['ms', 'Moz', 'Webkit', 'O']; var prefixes = ['ms', 'Moz', 'Webkit', 'O'];
var _cache = {}; var _cache = Object.create(null);
function CustomStyle() {} function CustomStyle() {}

View File

@ -340,7 +340,7 @@ Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', {
var FontFaceObject = (function FontFaceObjectClosure() { var FontFaceObject = (function FontFaceObjectClosure() {
function FontFaceObject(translatedData) { function FontFaceObject(translatedData) {
this.compiledGlyphs = {}; this.compiledGlyphs = Object.create(null);
// importing translated data // importing translated data
for (var i in translatedData) { for (var i in translatedData) {
this[i] = translatedData[i]; this[i] = translatedData[i];

View File

@ -58,7 +58,7 @@ var Metadata = PDFJS.Metadata = (function MetadataClosure() {
} }
this.metaDocument = meta; this.metaDocument = meta;
this.metadata = {}; this.metadata = Object.create(null);
this.parse(); this.parse();
} }

View File

@ -385,7 +385,7 @@ var SVGGraphics = (function SVGGraphicsClosure() {
this.pendingEOFill = false; this.pendingEOFill = false;
this.embedFonts = false; this.embedFonts = false;
this.embeddedFonts = {}; this.embeddedFonts = Object.create(null);
this.cssStyle = null; this.cssStyle = null;
} }

View File

@ -1466,7 +1466,7 @@ var StatTimer = (function StatTimerClosure() {
return str; return str;
} }
function StatTimer() { function StatTimer() {
this.started = {}; this.started = Object.create(null);
this.times = []; this.times = [];
this.enabled = true; this.enabled = true;
} }
@ -1560,8 +1560,8 @@ function MessageHandler(sourceName, targetName, comObj) {
this.comObj = comObj; this.comObj = comObj;
this.callbackIndex = 1; this.callbackIndex = 1;
this.postMessageTransfers = true; this.postMessageTransfers = true;
var callbacksCapabilities = this.callbacksCapabilities = {}; var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
var ah = this.actionHandler = {}; var ah = this.actionHandler = Object.create(null);
this._onComObjOnMessage = function messageHandlerComObjOnMessage(event) { this._onComObjOnMessage = function messageHandlerComObjOnMessage(event) {
var data = event.data; var data = event.data;

View File

@ -165,7 +165,7 @@ var StepperManager = (function StepperManagerClosure() {
var stepperDiv = null; var stepperDiv = null;
var stepperControls = null; var stepperControls = null;
var stepperChooser = null; var stepperChooser = null;
var breakPoints = {}; var breakPoints = Object.create(null);
return { return {
// Properties/functions needed by PDFBug. // Properties/functions needed by PDFBug.
id: 'Stepper', id: 'Stepper',

View File

@ -34,7 +34,7 @@ var PDFFindController = (function PDFFindControllerClosure() {
function PDFFindController(options) { function PDFFindController(options) {
this.startedTextExtraction = false; this.startedTextExtraction = false;
this.extractTextPromises = []; this.extractTextPromises = [];
this.pendingFindMatches = {}; this.pendingFindMatches = Object.create(null);
this.active = false; // If active, find results will be highlighted. this.active = false; // If active, find results will be highlighted.
this.pageContents = []; // Stores the text for each page. this.pageContents = []; // Stores the text for each page.
this.pageMatches = []; this.pageMatches = [];