Merge pull request #6982 from Snuffleupagus/evaluator-remove-getAll
Remove the only remaining `Dict_getAll` usage (in evaluator.js) and the method itself
This commit is contained in:
commit
e9a1a47d28
@ -1005,9 +1005,20 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
// but doing so is meaningless without knowing the semantics.
|
// but doing so is meaningless without knowing the semantics.
|
||||||
continue;
|
continue;
|
||||||
default:
|
default:
|
||||||
// Note: Let's hope that the ignored operator does not have any
|
// Note: Ignore the operator if it has `Dict` arguments, since
|
||||||
// non-serializable arguments, otherwise postMessage will throw
|
// those are non-serializable, otherwise postMessage will throw
|
||||||
// "An object could not be cloned.".
|
// "An object could not be cloned.".
|
||||||
|
if (args !== null) {
|
||||||
|
for (i = 0, ii = args.length; i < ii; i++) {
|
||||||
|
if (args[i] instanceof Dict) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i < ii) {
|
||||||
|
warn('getOperatorList - ignoring operator: ' + fn);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
operatorList.addOp(fn, args);
|
operatorList.addOp(fn, args);
|
||||||
}
|
}
|
||||||
@ -2555,7 +2566,7 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
|
|||||||
if (!args) {
|
if (!args) {
|
||||||
args = [];
|
args = [];
|
||||||
}
|
}
|
||||||
args.push((obj instanceof Dict ? obj.getAll() : obj));
|
args.push(obj);
|
||||||
assert(args.length <= 33, 'Too many arguments');
|
assert(args.length <= 33, 'Too many arguments');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,24 +67,6 @@ var Dict = (function DictClosure() {
|
|||||||
return nonSerializable; // creating closure on some variable
|
return nonSerializable; // creating closure on some variable
|
||||||
};
|
};
|
||||||
|
|
||||||
var GETALL_DICTIONARY_TYPES_WHITELIST = {
|
|
||||||
'Background': true,
|
|
||||||
'ExtGState': true,
|
|
||||||
'Halftone': true,
|
|
||||||
'Layout': true,
|
|
||||||
'Mask': true,
|
|
||||||
'Pagination': true,
|
|
||||||
'Printing': true
|
|
||||||
};
|
|
||||||
|
|
||||||
function isRecursionAllowedFor(dict) {
|
|
||||||
if (!isName(dict.Type)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
var dictType = dict.Type.name;
|
|
||||||
return GETALL_DICTIONARY_TYPES_WHITELIST[dictType] === true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// xref is optional
|
// xref is optional
|
||||||
function Dict(xref) {
|
function Dict(xref) {
|
||||||
// Map should only be used internally, use functions below to access.
|
// Map should only be used internally, use functions below to access.
|
||||||
@ -162,58 +144,6 @@ var Dict = (function DictClosure() {
|
|||||||
return this.map[key];
|
return this.map[key];
|
||||||
},
|
},
|
||||||
|
|
||||||
// creates new map and dereferences all Refs
|
|
||||||
getAll: function Dict_getAll() {
|
|
||||||
var all = Object.create(null);
|
|
||||||
var queue = null;
|
|
||||||
var key, obj;
|
|
||||||
for (key in this.map) {
|
|
||||||
obj = this.get(key);
|
|
||||||
if (obj instanceof Dict) {
|
|
||||||
if (isRecursionAllowedFor(obj)) {
|
|
||||||
(queue || (queue = [])).push({target: all, key: key, obj: obj});
|
|
||||||
} else {
|
|
||||||
all[key] = this.getRaw(key);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
all[key] = obj;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!queue) {
|
|
||||||
return all;
|
|
||||||
}
|
|
||||||
|
|
||||||
// trying to take cyclic references into the account
|
|
||||||
var processed = Object.create(null);
|
|
||||||
while (queue.length > 0) {
|
|
||||||
var item = queue.shift();
|
|
||||||
var itemObj = item.obj;
|
|
||||||
var objId = itemObj.objId;
|
|
||||||
if (objId && objId in processed) {
|
|
||||||
item.target[item.key] = processed[objId];
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
var dereferenced = Object.create(null);
|
|
||||||
for (key in itemObj.map) {
|
|
||||||
obj = itemObj.get(key);
|
|
||||||
if (obj instanceof Dict) {
|
|
||||||
if (isRecursionAllowedFor(obj)) {
|
|
||||||
queue.push({target: dereferenced, key: key, obj: obj});
|
|
||||||
} else {
|
|
||||||
dereferenced[key] = itemObj.getRaw(key);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
dereferenced[key] = obj;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (objId) {
|
|
||||||
processed[objId] = dereferenced;
|
|
||||||
}
|
|
||||||
item.target[item.key] = dereferenced;
|
|
||||||
}
|
|
||||||
return all;
|
|
||||||
},
|
|
||||||
|
|
||||||
getKeys: function Dict_getKeys() {
|
getKeys: function Dict_getKeys() {
|
||||||
return Object.keys(this.map);
|
return Object.keys(this.map);
|
||||||
},
|
},
|
||||||
|
1
test/pdfs/issue6549.pdf.link
Normal file
1
test/pdfs/issue6549.pdf.link
Normal file
@ -0,0 +1 @@
|
|||||||
|
http://web.archive.org/web/20150306062422/http://www.kokuyo-st.co.jp/stationery/camiapp/CamiApp_Sample.pdf
|
@ -781,6 +781,15 @@
|
|||||||
"rounds": 1,
|
"rounds": 1,
|
||||||
"type": "load"
|
"type": "load"
|
||||||
},
|
},
|
||||||
|
{ "id": "issue6549",
|
||||||
|
"file": "pdfs/issue6549.pdf",
|
||||||
|
"md5": "699aeea73a6f45375022ffc6cc80f12a",
|
||||||
|
"link": true,
|
||||||
|
"rounds": 1,
|
||||||
|
"firstPage": 2,
|
||||||
|
"lastPage": 3,
|
||||||
|
"type": "load"
|
||||||
|
},
|
||||||
{ "id": "ibwa-bad",
|
{ "id": "ibwa-bad",
|
||||||
"file": "pdfs/ibwa-bad.pdf",
|
"file": "pdfs/ibwa-bad.pdf",
|
||||||
"md5": "6ca059d32b74ac2688ae06f727fee755",
|
"md5": "6ca059d32b74ac2688ae06f727fee755",
|
||||||
|
Loading…
Reference in New Issue
Block a user