From ee3ac35e0553f5614c58a76952da451a35529466 Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Wed, 23 Aug 2023 11:14:29 -0400 Subject: [PATCH] Revert fix for bug 1838855 (bug 1849876) The issue described in the mentioned bug is reall because Acrobat is rendering the XFA instead of the Acroform. The original patch just tried to workaround the issue but it induces some regressions. --- src/core/annotation.js | 11 -------- src/core/document.js | 5 ---- src/display/annotation_layer.js | 8 +++--- test/integration/annotation_spec.js | 40 ----------------------------- test/unit/api_spec.js | 23 +++-------------- 5 files changed, 8 insertions(+), 79 deletions(-) diff --git a/src/core/annotation.js b/src/core/annotation.js index 5674b1b75..8520cc3e5 100644 --- a/src/core/annotation.js +++ b/src/core/annotation.js @@ -1661,17 +1661,6 @@ class WidgetAnnotation extends Annotation { if (data.fieldName === undefined) { data.fieldName = this._constructFieldName(dict); } - if ( - data.fieldName && - /\[\d+\]$/.test(data.fieldName) && - !dict.has("Kids") && - dict.has("T") - ) { - data.baseFieldName = data.fieldName.substring( - 0, - data.fieldName.lastIndexOf("[") - ); - } if (data.actions === undefined) { data.actions = collectActions(xref, dict, AnnotationActionEventType); diff --git a/src/core/document.js b/src/core/document.js index ca859761c..66197ea13 100644 --- a/src/core/document.js +++ b/src/core/document.js @@ -1710,11 +1710,6 @@ class PDFDocument { name = name === "" ? partName : `${name}.${partName}`; } - if (!field.has("Kids") && field.has("T") && /\[\d+\]$/.test(name)) { - // We've a terminal node: strip the index. - name = name.substring(0, name.lastIndexOf("[")); - } - if (!promises.has(name)) { promises.set(name, []); } diff --git a/src/display/annotation_layer.js b/src/display/annotation_layer.js index c0239b2b4..306b74c8d 100644 --- a/src/display/annotation_layer.js +++ b/src/display/annotation_layer.js @@ -1197,7 +1197,7 @@ class TextWidgetAnnotationElement extends WidgetAnnotationElement { element.setAttribute("data-element-id", id); element.disabled = this.data.readOnly; - element.name = this.data.baseFieldName || this.data.fieldName; + element.name = this.data.fieldName; element.tabIndex = DEFAULT_TAB_INDEX; this._setRequired(element, this.data.required); @@ -1499,7 +1499,7 @@ class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement { element.disabled = data.readOnly; this._setRequired(element, this.data.required); element.type = "checkbox"; - element.name = data.baseFieldName || data.fieldName; + element.name = data.fieldName; if (value) { element.setAttribute("checked", true); } @@ -1584,7 +1584,7 @@ class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement { element.disabled = data.readOnly; this._setRequired(element, this.data.required); element.type = "radio"; - element.name = data.baseFieldName || data.fieldName; + element.name = data.fieldName; if (value) { element.setAttribute("checked", true); } @@ -1697,7 +1697,7 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement { selectElement.disabled = this.data.readOnly; this._setRequired(selectElement, this.data.required); - selectElement.name = this.data.baseFieldName || this.data.fieldName; + selectElement.name = this.data.fieldName; selectElement.tabIndex = DEFAULT_TAB_INDEX; let addAnEmptyEntry = this.data.combo && this.data.options.length > 0; diff --git a/test/integration/annotation_spec.js b/test/integration/annotation_spec.js index bacca3712..c324e1f5f 100644 --- a/test/integration/annotation_spec.js +++ b/test/integration/annotation_spec.js @@ -121,46 +121,6 @@ describe("Checkbox annotation", () => { }); }); - describe("f1040_2022.pdf", () => { - let pages; - - beforeAll(async () => { - pages = await loadAndWait( - "f1040_2022.pdf", - "[data-annotation-id='1566R']" - ); - }); - - afterAll(async () => { - await closePages(pages); - }); - - it("must check the checkbox", async () => { - await Promise.all( - pages.map(async ([_browserName, page]) => { - const selectors = [1566, 1568, 1569, 1570, 1571].map( - id => `[data-annotation-id='${id}R']` - ); - for (const selector of selectors) { - await page.click(selector); - for (const otherSelector of selectors) { - if (otherSelector === selector) { - await page.waitForFunction( - `document.querySelector("${selector} > :first-child").checked` - ); - } else { - await page.waitForFunction( - `!document.querySelector("${otherSelector} > :first-child").checked` - ); - } - } - page.waitForTimeout(10); - } - }) - ); - }); - }); - describe("bug1847733.pdf", () => { let pages; diff --git a/test/unit/api_spec.js b/test/unit/api_spec.js index 70e3f47e4..ad7bf96fa 100644 --- a/test/unit/api_spec.js +++ b/test/unit/api_spec.js @@ -1586,11 +1586,12 @@ describe("api", function () { case "pdf_submission_new": case "simple_spc": case "adobeWarning": + case "typeA13[0]": + case "typeA13[1]": + case "typeA13[2]": + case "typeA13[3]": expected = [0]; break; - case "typeA13": - expected = [0, 0, 0, 0]; - break; case "typeA15[0]": case "typeA15[1]": case "typeA15[2]": @@ -1604,22 +1605,6 @@ describe("api", function () { await loadingTask.destroy(); }); - it("check field object for group of buttons", async function () { - if (isNodeJS) { - pending("Linked test-cases are not supported in Node.js."); - } - - const loadingTask = getDocument(buildGetDocumentParams("f1040_2022.pdf")); - const pdfDoc = await loadingTask.promise; - const fieldObjects = await pdfDoc.getFieldObjects(); - - expect( - fieldObjects["topmostSubform[0].Page1[0].c1_01"].map(o => o.id) - ).toEqual(["1566R", "1568R", "1569R", "1570R", "1571R"]); - - await loadingTask.destroy(); - }); - it("gets non-existent calculationOrder", async function () { const calculationOrder = await pdfDocument.getCalculationOrderIds(); expect(calculationOrder).toEqual(null);