Rename map
to _map
inside of Dict
, to make it clearer that it should be regarded as a "private" property
This commit is contained in:
parent
3a20fd165f
commit
73234577e1
@ -60,7 +60,7 @@ var Dict = (function DictClosure() {
|
||||
// xref is optional
|
||||
function Dict(xref) {
|
||||
// Map should only be used internally, use functions below to access.
|
||||
this.map = Object.create(null);
|
||||
this._map = Object.create(null);
|
||||
this.xref = xref;
|
||||
this.objId = null;
|
||||
this.suppressEncryption = false;
|
||||
@ -76,15 +76,15 @@ var Dict = (function DictClosure() {
|
||||
get: function Dict_get(key1, key2, key3) {
|
||||
var value;
|
||||
var xref = this.xref, suppressEncryption = this.suppressEncryption;
|
||||
if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map ||
|
||||
typeof key2 === 'undefined') {
|
||||
if (typeof (value = this._map[key1]) !== 'undefined' ||
|
||||
key1 in this._map || typeof key2 === 'undefined') {
|
||||
return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
|
||||
}
|
||||
if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map ||
|
||||
typeof key3 === 'undefined') {
|
||||
if (typeof (value = this._map[key2]) !== 'undefined' ||
|
||||
key2 in this._map || typeof key3 === 'undefined') {
|
||||
return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
|
||||
}
|
||||
value = this.map[key3] || null;
|
||||
value = this._map[key3] || null;
|
||||
return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
|
||||
},
|
||||
|
||||
@ -92,21 +92,21 @@ var Dict = (function DictClosure() {
|
||||
getAsync: function Dict_getAsync(key1, key2, key3) {
|
||||
var value;
|
||||
var xref = this.xref, suppressEncryption = this.suppressEncryption;
|
||||
if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map ||
|
||||
typeof key2 === 'undefined') {
|
||||
if (typeof (value = this._map[key1]) !== 'undefined' ||
|
||||
key1 in this._map || typeof key2 === 'undefined') {
|
||||
if (xref) {
|
||||
return xref.fetchIfRefAsync(value, suppressEncryption);
|
||||
}
|
||||
return Promise.resolve(value);
|
||||
}
|
||||
if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map ||
|
||||
typeof key3 === 'undefined') {
|
||||
if (typeof (value = this._map[key2]) !== 'undefined' ||
|
||||
key2 in this._map || typeof key3 === 'undefined') {
|
||||
if (xref) {
|
||||
return xref.fetchIfRefAsync(value, suppressEncryption);
|
||||
}
|
||||
return Promise.resolve(value);
|
||||
}
|
||||
value = this.map[key3] || null;
|
||||
value = this._map[key3] || null;
|
||||
if (xref) {
|
||||
return xref.fetchIfRefAsync(value, suppressEncryption);
|
||||
}
|
||||
@ -132,23 +132,23 @@ var Dict = (function DictClosure() {
|
||||
|
||||
// no dereferencing
|
||||
getRaw: function Dict_getRaw(key) {
|
||||
return this.map[key];
|
||||
return this._map[key];
|
||||
},
|
||||
|
||||
getKeys: function Dict_getKeys() {
|
||||
return Object.keys(this.map);
|
||||
return Object.keys(this._map);
|
||||
},
|
||||
|
||||
set: function Dict_set(key, value) {
|
||||
this.map[key] = value;
|
||||
this._map[key] = value;
|
||||
},
|
||||
|
||||
has: function Dict_has(key) {
|
||||
return key in this.map;
|
||||
return key in this._map;
|
||||
},
|
||||
|
||||
forEach: function Dict_forEach(callback) {
|
||||
for (var key in this.map) {
|
||||
for (var key in this._map) {
|
||||
callback(key, this.get(key));
|
||||
}
|
||||
},
|
||||
@ -156,19 +156,19 @@ var Dict = (function DictClosure() {
|
||||
|
||||
Dict.empty = new Dict(null);
|
||||
|
||||
Dict.merge = function Dict_merge(xref, dictArray) {
|
||||
var mergedDict = new Dict(xref);
|
||||
Dict.merge = function(xref, dictArray) {
|
||||
let mergedDict = new Dict(xref);
|
||||
|
||||
for (var i = 0, ii = dictArray.length; i < ii; i++) {
|
||||
var dict = dictArray[i];
|
||||
for (let i = 0, ii = dictArray.length; i < ii; i++) {
|
||||
let dict = dictArray[i];
|
||||
if (!isDict(dict)) {
|
||||
continue;
|
||||
}
|
||||
for (var keyName in dict.map) {
|
||||
if (mergedDict.map[keyName]) {
|
||||
for (let keyName in dict._map) {
|
||||
if (mergedDict._map[keyName] !== undefined) {
|
||||
continue;
|
||||
}
|
||||
mergedDict.map[keyName] = dict.map[keyName];
|
||||
mergedDict._map[keyName] = dict._map[keyName];
|
||||
}
|
||||
}
|
||||
return mergedDict;
|
||||
|
@ -361,9 +361,9 @@ var Type2Parser = function type2Parser(aFilePath) {
|
||||
dump('privateData:' + privateDict);
|
||||
parseAsToken(privateDict, CFFDictPrivateDataMap);
|
||||
|
||||
for (var p in font.map) {
|
||||
dump(p + '::' + font.get(p));
|
||||
}
|
||||
font.forEach(function(key, value) {
|
||||
dump(key + '::' + value);
|
||||
});
|
||||
|
||||
// Read CharStrings Index
|
||||
var charStringsOffset = font.get('CharStrings');
|
||||
|
Loading…
x
Reference in New Issue
Block a user