Merge pull request #15632 from Snuffleupagus/issue-15629-2
[api-minor] Move the handling of unbalanced markedContent to the worker-thread (PR 15630 follow-up)
This commit is contained in:
commit
8b970109ea
@ -2283,12 +2283,16 @@ class PartialEvaluator {
|
||||
sink,
|
||||
seenStyles = new Set(),
|
||||
viewBox,
|
||||
markedContentData = null,
|
||||
}) {
|
||||
// Ensure that `resources`/`stateManager` is correctly initialized,
|
||||
// even if the provided parameter is e.g. `null`.
|
||||
resources = resources || Dict.empty;
|
||||
stateManager = stateManager || new StateManager(new TextState());
|
||||
|
||||
if (includeMarkedContent) {
|
||||
markedContentData = markedContentData || { level: 0 };
|
||||
}
|
||||
const NormalizedUnicodes = getNormalizedUnicodes();
|
||||
|
||||
const textContent = {
|
||||
@ -3225,6 +3229,7 @@ class PartialEvaluator {
|
||||
sink: sinkWrapper,
|
||||
seenStyles,
|
||||
viewBox,
|
||||
markedContentData,
|
||||
})
|
||||
.then(function () {
|
||||
if (!sinkWrapper.enqueueInvoked) {
|
||||
@ -3305,6 +3310,8 @@ class PartialEvaluator {
|
||||
case OPS.beginMarkedContent:
|
||||
flushTextContentItem();
|
||||
if (includeMarkedContent) {
|
||||
markedContentData.level++;
|
||||
|
||||
textContent.items.push({
|
||||
type: "beginMarkedContent",
|
||||
tag: args[0] instanceof Name ? args[0].name : null,
|
||||
@ -3314,6 +3321,8 @@ class PartialEvaluator {
|
||||
case OPS.beginMarkedContentProps:
|
||||
flushTextContentItem();
|
||||
if (includeMarkedContent) {
|
||||
markedContentData.level++;
|
||||
|
||||
let mcid = null;
|
||||
if (args[1] instanceof Dict) {
|
||||
mcid = args[1].get("MCID");
|
||||
@ -3330,6 +3339,13 @@ class PartialEvaluator {
|
||||
case OPS.endMarkedContent:
|
||||
flushTextContentItem();
|
||||
if (includeMarkedContent) {
|
||||
if (markedContentData.level === 0) {
|
||||
// Handle unbalanced beginMarkedContent/endMarkedContent
|
||||
// operators (fixes issue15629.pdf).
|
||||
break;
|
||||
}
|
||||
markedContentData.level--;
|
||||
|
||||
textContent.items.push({
|
||||
type: "endMarkedContent",
|
||||
});
|
||||
|
@ -224,8 +224,6 @@ function render(task) {
|
||||
}
|
||||
|
||||
class TextLayerRenderTask {
|
||||
#initialContainer = null;
|
||||
|
||||
constructor({
|
||||
textContent,
|
||||
textContentStream,
|
||||
@ -237,7 +235,6 @@ class TextLayerRenderTask {
|
||||
this._textContent = textContent;
|
||||
this._textContentStream = textContentStream;
|
||||
this._container = container;
|
||||
this.#initialContainer = container;
|
||||
this._document = container.ownerDocument;
|
||||
this._viewport = viewport;
|
||||
this._textDivs = textDivs || [];
|
||||
@ -321,13 +318,7 @@ class TextLayerRenderTask {
|
||||
}
|
||||
parent.append(this._container);
|
||||
} else if (item.type === "endMarkedContent") {
|
||||
const parent = this._container.parentNode;
|
||||
if (!parent || this._container === this.#initialContainer) {
|
||||
// Handle unbalanced beginMarkedContent/endMarkedContent operators
|
||||
// (fixes issue15629.pdf).
|
||||
continue;
|
||||
}
|
||||
this._container = parent;
|
||||
this._container = this._container.parentNode;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user