Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pause translation when appending the xfaLayer to the page #17177

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions web/l10n_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ const NullL10n = {
},

pause() {
ConstL10n.instance.pause();
return ConstL10n.instance.pause();
},

resume() {
ConstL10n.instance.resume();
return ConstL10n.instance.resume();
},
};

Expand Down
14 changes: 11 additions & 3 deletions web/pdf_page_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,12 +359,23 @@ class PDFPageView {
try {
const result = await this.xfaLayer.render(this.viewport, "display");
if (result?.textDivs && this._textHighlighter) {
// Given that the following method fetches the text asynchronously we
// can invoke it *before* appending the xfaLayer to the DOM (below),
// since a pending search-highlight/scroll operation thus won't run
// until after the xfaLayer is available in the viewer.
this.#buildXfaTextContentItems(result.textDivs);
}
} catch (ex) {
console.error(`#renderXfaLayer: "${ex}".`);
error = ex;
} finally {
if (this.xfaLayer?.div) {
// Pause translation when inserting the xfaLayer in the DOM.
this.l10n.pause();
this.div.append(this.xfaLayer.div);
this.l10n.resume();
}

this.eventBus.dispatch("xfalayerrendered", {
source: this,
pageNumber: this.id,
Expand Down Expand Up @@ -1020,9 +1031,6 @@ class PDFPageView {
annotationStorage,
linkService,
});
} else if (this.xfaLayer.div) {
// The xfa layer needs to stay on top.
div.append(this.xfaLayer.div);
}
this.#renderXfaLayer();
}
Expand Down
1 change: 0 additions & 1 deletion web/xfa_layer_builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ class XfaLayerBuilder {
}
// Create an xfa layer div and render the form
this.div = document.createElement("div");
this.pageDiv.append(this.div);
parameters.div = this.div;

return XfaLayer.render(parameters);
Expand Down