Merge pull request #8196 from Snuffleupagus/evaluator-rm-redundant-xref
Remove unnecessary `xref` parameters from various method signatures in `PartialEvaluator`, since `this.xref` is already available in the relevant scope
This commit is contained in:
commit
b6bf1a3eb8
@ -515,7 +515,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
return this.loadFont(fontName, fontRef, this.xref, resources).then(
|
return this.loadFont(fontName, fontRef, resources).then(
|
||||||
function (translated) {
|
function (translated) {
|
||||||
if (!translated.font.isType3Font) {
|
if (!translated.font.isType3Font) {
|
||||||
return translated;
|
return translated;
|
||||||
@ -572,7 +572,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
|
|
||||||
setGState: function PartialEvaluator_setGState(resources, gState,
|
setGState: function PartialEvaluator_setGState(resources, gState,
|
||||||
operatorList, task,
|
operatorList, task,
|
||||||
xref, stateManager) {
|
stateManager) {
|
||||||
// This array holds the converted/processed state data.
|
// This array holds the converted/processed state data.
|
||||||
var gStateObj = [];
|
var gStateObj = [];
|
||||||
var gStateKeys = gState.getKeys();
|
var gStateKeys = gState.getKeys();
|
||||||
@ -655,14 +655,13 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
loadFont: function PartialEvaluator_loadFont(fontName, font, xref,
|
loadFont: function PartialEvaluator_loadFont(fontName, font, resources) {
|
||||||
resources) {
|
|
||||||
|
|
||||||
function errorFont() {
|
function errorFont() {
|
||||||
return Promise.resolve(new TranslatedFont('g_font_error',
|
return Promise.resolve(new TranslatedFont('g_font_error',
|
||||||
new ErrorFont('Font ' + fontName + ' is not available'), font));
|
new ErrorFont('Font ' + fontName + ' is not available'), font));
|
||||||
}
|
}
|
||||||
var fontRef;
|
|
||||||
|
var fontRef, xref = this.xref;
|
||||||
if (font) { // Loading by ref.
|
if (font) { // Loading by ref.
|
||||||
assert(isRef(font));
|
assert(isRef(font));
|
||||||
fontRef = font;
|
fontRef = font;
|
||||||
@ -697,7 +696,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
|
|
||||||
var fontCapability = createPromiseCapability();
|
var fontCapability = createPromiseCapability();
|
||||||
|
|
||||||
var preEvaluatedFont = this.preEvaluateFont(font, xref);
|
var preEvaluatedFont = this.preEvaluateFont(font);
|
||||||
var descriptor = preEvaluatedFont.descriptor;
|
var descriptor = preEvaluatedFont.descriptor;
|
||||||
|
|
||||||
var fontRefIsRef = isRef(fontRef), fontID;
|
var fontRefIsRef = isRef(fontRef), fontID;
|
||||||
@ -767,7 +766,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
// TODO move promises into translate font
|
// TODO move promises into translate font
|
||||||
var translatedPromise;
|
var translatedPromise;
|
||||||
try {
|
try {
|
||||||
translatedPromise = this.translateFont(preEvaluatedFont, xref);
|
translatedPromise = this.translateFont(preEvaluatedFont);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
translatedPromise = Promise.reject(e);
|
translatedPromise = Promise.reject(e);
|
||||||
}
|
}
|
||||||
@ -821,7 +820,8 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args,
|
handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args,
|
||||||
cs, patterns, resources, task, xref) {
|
cs, patterns,
|
||||||
|
resources, task) {
|
||||||
// compile tiling patterns
|
// compile tiling patterns
|
||||||
var patternName = args[args.length - 1];
|
var patternName = args[args.length - 1];
|
||||||
// SCN/scn applies patterns along with normal colors
|
// SCN/scn applies patterns along with normal colors
|
||||||
@ -838,7 +838,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
} else if (typeNum === SHADING_PATTERN) {
|
} else if (typeNum === SHADING_PATTERN) {
|
||||||
var shading = dict.get('Shading');
|
var shading = dict.get('Shading');
|
||||||
var matrix = dict.getArray('Matrix');
|
var matrix = dict.getArray('Matrix');
|
||||||
pattern = Pattern.parseShading(shading, matrix, xref, resources,
|
pattern = Pattern.parseShading(shading, matrix, this.xref, resources,
|
||||||
this.handler);
|
this.handler);
|
||||||
operatorList.addOp(fn, pattern.getIR());
|
operatorList.addOp(fn, pattern.getIR());
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
@ -1052,7 +1052,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
cs = stateManager.state.fillColorSpace;
|
cs = stateManager.state.fillColorSpace;
|
||||||
if (cs.name === 'Pattern') {
|
if (cs.name === 'Pattern') {
|
||||||
next(self.handleColorN(operatorList, OPS.setFillColorN, args,
|
next(self.handleColorN(operatorList, OPS.setFillColorN, args,
|
||||||
cs, patterns, resources, task, xref));
|
cs, patterns, resources, task));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
args = cs.getRgb(args, 0);
|
args = cs.getRgb(args, 0);
|
||||||
@ -1062,7 +1062,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
cs = stateManager.state.strokeColorSpace;
|
cs = stateManager.state.strokeColorSpace;
|
||||||
if (cs.name === 'Pattern') {
|
if (cs.name === 'Pattern') {
|
||||||
next(self.handleColorN(operatorList, OPS.setStrokeColorN, args,
|
next(self.handleColorN(operatorList, OPS.setStrokeColorN, args,
|
||||||
cs, patterns, resources, task, xref));
|
cs, patterns, resources, task));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
args = cs.getRgb(args, 0);
|
args = cs.getRgb(args, 0);
|
||||||
@ -1071,14 +1071,10 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
|
|
||||||
case OPS.shadingFill:
|
case OPS.shadingFill:
|
||||||
var shadingRes = resources.get('Shading');
|
var shadingRes = resources.get('Shading');
|
||||||
if (!shadingRes) {
|
assert(shadingRes, 'No shading resource found');
|
||||||
error('No shading resource found');
|
|
||||||
}
|
|
||||||
|
|
||||||
var shading = shadingRes.get(args[0].name);
|
var shading = shadingRes.get(args[0].name);
|
||||||
if (!shading) {
|
assert(shading, 'No shading object found');
|
||||||
error('No shading object found');
|
|
||||||
}
|
|
||||||
|
|
||||||
var shadingFill = Pattern.parseShading(shading, null, xref,
|
var shadingFill = Pattern.parseShading(shading, null, xref,
|
||||||
resources, self.handler);
|
resources, self.handler);
|
||||||
@ -1095,8 +1091,8 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var gState = extGState.get(dictName.name);
|
var gState = extGState.get(dictName.name);
|
||||||
next(self.setGState(resources, gState, operatorList, task, xref,
|
next(self.setGState(resources, gState, operatorList, task,
|
||||||
stateManager));
|
stateManager));
|
||||||
return;
|
return;
|
||||||
case OPS.moveTo:
|
case OPS.moveTo:
|
||||||
case OPS.lineTo:
|
case OPS.lineTo:
|
||||||
@ -1303,7 +1299,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleSetFont(fontName, fontRef) {
|
function handleSetFont(fontName, fontRef) {
|
||||||
return self.loadFont(fontName, fontRef, xref, resources).
|
return self.loadFont(fontName, fontRef, resources).
|
||||||
then(function (translated) {
|
then(function (translated) {
|
||||||
textState.font = translated.font;
|
textState.font = translated.font;
|
||||||
textState.fontMatrix = translated.font.fontMatrix ||
|
textState.fontMatrix = translated.font.fontMatrix ||
|
||||||
@ -1671,7 +1667,8 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
|
|
||||||
extractDataStructures:
|
extractDataStructures:
|
||||||
function PartialEvaluator_extractDataStructures(dict, baseDict,
|
function PartialEvaluator_extractDataStructures(dict, baseDict,
|
||||||
xref, properties) {
|
properties) {
|
||||||
|
var xref = this.xref;
|
||||||
// 9.10.2
|
// 9.10.2
|
||||||
var toUnicode = (dict.get('ToUnicode') || baseDict.get('ToUnicode'));
|
var toUnicode = (dict.get('ToUnicode') || baseDict.get('ToUnicode'));
|
||||||
var toUnicodePromise = toUnicode ?
|
var toUnicodePromise = toUnicode ?
|
||||||
@ -1986,9 +1983,9 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
extractWidths: function PartialEvaluator_extractWidths(dict, xref,
|
extractWidths: function PartialEvaluator_extractWidths(dict, descriptor,
|
||||||
descriptor,
|
|
||||||
properties) {
|
properties) {
|
||||||
|
var xref = this.xref;
|
||||||
var glyphsWidths = [];
|
var glyphsWidths = [];
|
||||||
var defaultWidth = 0;
|
var defaultWidth = 0;
|
||||||
var glyphsVMetrics = [];
|
var glyphsVMetrics = [];
|
||||||
@ -2153,7 +2150,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
return widths;
|
return widths;
|
||||||
},
|
},
|
||||||
|
|
||||||
preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict, xref) {
|
preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict) {
|
||||||
var baseDict = dict;
|
var baseDict = dict;
|
||||||
var type = dict.get('Subtype');
|
var type = dict.get('Subtype');
|
||||||
assert(isName(type), 'invalid font Subtype');
|
assert(isName(type), 'invalid font Subtype');
|
||||||
@ -2166,10 +2163,8 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
// - set the type according to the descendant font
|
// - set the type according to the descendant font
|
||||||
// - get the FontDescriptor from the descendant font
|
// - get the FontDescriptor from the descendant font
|
||||||
var df = dict.get('DescendantFonts');
|
var df = dict.get('DescendantFonts');
|
||||||
if (!df) {
|
assert(df, 'Descendant fonts are not specified');
|
||||||
error('Descendant fonts are not specified');
|
dict = (isArray(df) ? this.xref.fetchIfRef(df[0]) : df);
|
||||||
}
|
|
||||||
dict = (isArray(df) ? xref.fetchIfRef(df[0]) : df);
|
|
||||||
|
|
||||||
type = dict.get('Subtype');
|
type = dict.get('Subtype');
|
||||||
assert(isName(type), 'invalid font Subtype');
|
assert(isName(type), 'invalid font Subtype');
|
||||||
@ -2239,8 +2234,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
translateFont: function PartialEvaluator_translateFont(preEvaluatedFont,
|
translateFont: function PartialEvaluator_translateFont(preEvaluatedFont) {
|
||||||
xref) {
|
|
||||||
var baseDict = preEvaluatedFont.baseDict;
|
var baseDict = preEvaluatedFont.baseDict;
|
||||||
var dict = preEvaluatedFont.dict;
|
var dict = preEvaluatedFont.dict;
|
||||||
var composite = preEvaluatedFont.composite;
|
var composite = preEvaluatedFont.composite;
|
||||||
@ -2261,9 +2255,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
// FontDescriptor was not required.
|
// FontDescriptor was not required.
|
||||||
// This case is here for compatibility.
|
// This case is here for compatibility.
|
||||||
var baseFontName = dict.get('BaseFont');
|
var baseFontName = dict.get('BaseFont');
|
||||||
if (!isName(baseFontName)) {
|
assert(isName(baseFontName), 'Base font is not specified');
|
||||||
error('Base font is not specified');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Using base font name as a font name.
|
// Using base font name as a font name.
|
||||||
baseFontName = baseFontName.name.replace(/[,_]/g, '-');
|
baseFontName = baseFontName.name.replace(/[,_]/g, '-');
|
||||||
@ -2286,7 +2278,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
firstChar: 0,
|
firstChar: 0,
|
||||||
lastChar: maxCharIndex
|
lastChar: maxCharIndex
|
||||||
};
|
};
|
||||||
return this.extractDataStructures(dict, dict, xref, properties).then(
|
return this.extractDataStructures(dict, dict, properties).then(
|
||||||
function (properties) {
|
function (properties) {
|
||||||
properties.widths = this.buildCharCodeToWidth(metrics.widths,
|
properties.widths = this.buildCharCodeToWidth(metrics.widths,
|
||||||
properties);
|
properties);
|
||||||
@ -2389,9 +2381,9 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return cMapPromise.then(function () {
|
return cMapPromise.then(function () {
|
||||||
return this.extractDataStructures(dict, baseDict, xref, properties);
|
return this.extractDataStructures(dict, baseDict, properties);
|
||||||
}.bind(this)).then(function (properties) {
|
}.bind(this)).then(function (properties) {
|
||||||
this.extractWidths(dict, xref, descriptor, properties);
|
this.extractWidths(dict, descriptor, properties);
|
||||||
|
|
||||||
if (type === 'Type3') {
|
if (type === 'Type3') {
|
||||||
properties.isType3Font = true;
|
properties.isType3Font = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user