Merge pull request #13437 from calixteman/xfa_mv_root

XFA - Move the fake HTML representation of XFA from the worker to the main thread
This commit is contained in:
calixteman 2021-05-31 10:14:15 +02:00 committed by GitHub
commit 8c53bf8647
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 50 additions and 32 deletions

View file

@ -695,7 +695,15 @@ class PDFDocumentProxy {
* @type {boolean} True if only XFA form.
*/
get isPureXfa() {
return this._pdfInfo.isPureXfa;
return !!this._transport._htmlForXfa;
}
/**
* @type {Object | null} An object representing a HTML tree structure
* to render the XFA, or `null` when no XFA form exists.
*/
get allXfaHtml() {
return this._transport._htmlForXfa;
}
/**
@ -1253,8 +1261,8 @@ class PDFPageProxy {
* are {Object} with a name, attributes (class, style, ...), value and
* children, very similar to a HTML DOM tree), or `null` if no XFA exists.
*/
getXfa() {
return (this._xfaPromise ||= this._transport.getPageXfa(this._pageIndex));
async getXfa() {
return this._transport._htmlForXfa?.children[this._pageIndex] || null;
}
/**
@ -1540,7 +1548,6 @@ class PDFPageProxy {
this.objs.clear();
this._annotationsPromise = null;
this._jsActionsPromise = null;
this._xfaPromise = null;
this._structTreePromise = null;
this.pendingCleanup = false;
return Promise.all(waitOn);
@ -1576,7 +1583,6 @@ class PDFPageProxy {
this.objs.clear();
this._annotationsPromise = null;
this._jsActionsPromise = null;
this._xfaPromise = null;
this._structTreePromise = null;
if (resetStats && this._stats) {
this._stats = new StatTimer();
@ -2444,6 +2450,8 @@ class WorkerTransport {
messageHandler.on("GetDoc", ({ pdfInfo }) => {
this._numPages = pdfInfo.numPages;
this._htmlForXfa = pdfInfo.htmlForXfa;
delete pdfInfo.htmlForXfa;
loadingTask._capability.resolve(new PDFDocumentProxy(pdfInfo, this));
});
@ -2800,12 +2808,6 @@ class WorkerTransport {
});
}
getPageXfa(pageIndex) {
return this.messageHandler.sendWithPromise("GetPageXfa", {
pageIndex,
});
}
getStructTree(pageIndex) {
return this.messageHandler.sendWithPromise("GetStructTree", {
pageIndex,