[Regression] Re-factor the *internal* renderInteractiveForms
handling, since it's currently subtly wrong
The value of the `renderInteractiveForms` parameter, as passed to the `PDFPageProxy.render` method, will (potentially) affect the size/content of the operatorList that's returned from the worker (for documents with forms). Given that operatorLists will generally, unless they contain huge images, be cached in the API, repeated `PDFPageProxy.render` calls that *only* change the `renderInteractiveForms` parameter can thus return an incorrect operatorList. As far as I can tell, this *subtle* bug has existed ever since `renderInteractiveForms`-support was first added in PR 7633 (which is almost five years ago). With the previous patch, fixing this is now really simple by "encoding" the `renderInteractiveForms` parameter in the *internal* renderingIntent handling.
This commit is contained in:
parent
47f94235ab
commit
107efdb178
@ -320,14 +320,7 @@ class Page {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getOperatorList({
|
getOperatorList({ handler, sink, task, intent, annotationStorage }) {
|
||||||
handler,
|
|
||||||
sink,
|
|
||||||
task,
|
|
||||||
intent,
|
|
||||||
renderInteractiveForms,
|
|
||||||
annotationStorage,
|
|
||||||
}) {
|
|
||||||
const contentStreamPromise = this.getContentStream(handler);
|
const contentStreamPromise = this.getContentStream(handler);
|
||||||
const resourcesPromise = this.loadResources([
|
const resourcesPromise = this.loadResources([
|
||||||
"ColorSpace",
|
"ColorSpace",
|
||||||
@ -384,7 +377,8 @@ class Page {
|
|||||||
pageOpList.flush(true);
|
pageOpList.flush(true);
|
||||||
return { length: pageOpList.totalLength };
|
return { length: pageOpList.totalLength };
|
||||||
}
|
}
|
||||||
const intentAny = !!(intent & RenderingIntentFlag.ANY),
|
const renderForms = !!(intent & RenderingIntentFlag.ANNOTATION_FORMS),
|
||||||
|
intentAny = !!(intent & RenderingIntentFlag.ANY),
|
||||||
intentDisplay = !!(intent & RenderingIntentFlag.DISPLAY),
|
intentDisplay = !!(intent & RenderingIntentFlag.DISPLAY),
|
||||||
intentPrint = !!(intent & RenderingIntentFlag.PRINT);
|
intentPrint = !!(intent & RenderingIntentFlag.PRINT);
|
||||||
|
|
||||||
@ -402,7 +396,7 @@ class Page {
|
|||||||
.getOperatorList(
|
.getOperatorList(
|
||||||
partialEvaluator,
|
partialEvaluator,
|
||||||
task,
|
task,
|
||||||
renderInteractiveForms,
|
renderForms,
|
||||||
annotationStorage
|
annotationStorage
|
||||||
)
|
)
|
||||||
.catch(function (reason) {
|
.catch(function (reason) {
|
||||||
|
@ -688,7 +688,6 @@ class WorkerMessageHandler {
|
|||||||
sink,
|
sink,
|
||||||
task,
|
task,
|
||||||
intent: data.intent,
|
intent: data.intent,
|
||||||
renderInteractiveForms: data.renderInteractiveForms,
|
|
||||||
annotationStorage: data.annotationStorage,
|
annotationStorage: data.annotationStorage,
|
||||||
})
|
})
|
||||||
.then(
|
.then(
|
||||||
|
@ -515,7 +515,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRenderingIntent(intent, { isOpList = false }) {
|
function getRenderingIntent(intent, { renderForms = false, isOpList = false }) {
|
||||||
let renderingIntent = RenderingIntentFlag.DISPLAY; // Default value.
|
let renderingIntent = RenderingIntentFlag.DISPLAY; // Default value.
|
||||||
switch (intent) {
|
switch (intent) {
|
||||||
case "any":
|
case "any":
|
||||||
@ -529,6 +529,9 @@ function getRenderingIntent(intent, { isOpList = false }) {
|
|||||||
default:
|
default:
|
||||||
warn(`getRenderingIntent - invalid intent: ${intent}`);
|
warn(`getRenderingIntent - invalid intent: ${intent}`);
|
||||||
}
|
}
|
||||||
|
if (renderForms) {
|
||||||
|
renderingIntent += RenderingIntentFlag.ANNOTATION_FORMS;
|
||||||
|
}
|
||||||
if (isOpList) {
|
if (isOpList) {
|
||||||
renderingIntent += RenderingIntentFlag.OPLIST;
|
renderingIntent += RenderingIntentFlag.OPLIST;
|
||||||
}
|
}
|
||||||
@ -1356,7 +1359,9 @@ class PDFPageProxy {
|
|||||||
this._stats.time("Overall");
|
this._stats.time("Overall");
|
||||||
}
|
}
|
||||||
|
|
||||||
const renderingIntent = getRenderingIntent(intent, {});
|
const renderingIntent = getRenderingIntent(intent, {
|
||||||
|
renderForms: renderInteractiveForms === true,
|
||||||
|
});
|
||||||
// If there was a pending destroy, cancel it so no cleanup happens during
|
// If there was a pending destroy, cancel it so no cleanup happens during
|
||||||
// this call to render.
|
// this call to render.
|
||||||
this.pendingCleanup = false;
|
this.pendingCleanup = false;
|
||||||
@ -1400,7 +1405,6 @@ class PDFPageProxy {
|
|||||||
this._pumpOperatorList({
|
this._pumpOperatorList({
|
||||||
pageIndex: this._pageIndex,
|
pageIndex: this._pageIndex,
|
||||||
intent: renderingIntent,
|
intent: renderingIntent,
|
||||||
renderInteractiveForms: renderInteractiveForms === true,
|
|
||||||
annotationStorage,
|
annotationStorage,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ const RenderingIntentFlag = {
|
|||||||
ANY: 0x01,
|
ANY: 0x01,
|
||||||
DISPLAY: 0x02,
|
DISPLAY: 0x02,
|
||||||
PRINT: 0x04,
|
PRINT: 0x04,
|
||||||
|
ANNOTATION_FORMS: 0x20,
|
||||||
OPLIST: 0x100,
|
OPLIST: 0x100,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user