From 84d8eb9b6fdd2afd43f5970b3544d63aa990d30e Mon Sep 17 00:00:00 2001 From: Henrique Nakashima Date: Thu, 22 Jun 2017 11:51:04 -0400 Subject: Avoid regenerating appearance stream when already present. Since cpdfsdk_widget.cpp already generates it, we can expect that FPDF_GenerateAP will not be called. That implementation does not work with widgets with a shared field. Bug: chromium:733528 Change-Id: Ia436b4e8bc87ca86b67a02cf7301ac2328339128 Reviewed-on: https://pdfium-review.googlesource.com/6752 Reviewed-by: Lei Zhang Commit-Queue: Henrique Nakashima --- core/fpdfdoc/cpdf_annotlist.cpp | 2 +- testing/resources/pixel/bug_733528.in | 72 +++++++++++++++++++++ .../resources/pixel/bug_733528_expected.pdf.0.png | Bin 0 -> 3492 bytes .../pixel/bug_733528_expected_mac.pdf.0.png | Bin 0 -> 3349 bytes 4 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 testing/resources/pixel/bug_733528.in create mode 100644 testing/resources/pixel/bug_733528_expected.pdf.0.png create mode 100644 testing/resources/pixel/bug_733528_expected_mac.pdf.0.png diff --git a/core/fpdfdoc/cpdf_annotlist.cpp b/core/fpdfdoc/cpdf_annotlist.cpp index 1427c85616..1f94779c15 100644 --- a/core/fpdfdoc/cpdf_annotlist.cpp +++ b/core/fpdfdoc/cpdf_annotlist.cpp @@ -86,7 +86,7 @@ CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage) pAnnots->ConvertToIndirectObjectAt(i, m_pDocument); m_AnnotList.push_back(pdfium::MakeUnique(pDict, m_pDocument)); if (bRegenerateAP && subtype == "Widget" && - CPDF_InterForm::IsUpdateAPEnabled()) { + CPDF_InterForm::IsUpdateAPEnabled() && !pDict->GetDictFor("AP")) { FPDF_GenerateAP(m_pDocument, pDict); } } diff --git a/testing/resources/pixel/bug_733528.in b/testing/resources/pixel/bug_733528.in new file mode 100644 index 0000000000..3602c3f2b5 --- /dev/null +++ b/testing/resources/pixel/bug_733528.in @@ -0,0 +1,72 @@ +{{header}} +{{object 1 0}} << + /Type /Catalog + /Pages 2 0 R + /AcroForm << + /Fields [ 4 0 R 9 0 R ] + /DR 5 0 R + /NeedAppearances true + >> +>> +endobj +{{object 2 0}} << + /Count 1 + /Kids [ 3 0 R ] + /Type /Pages +>> +endobj +{{object 3 0}} << + /Type /Page + /Parent 2 0 R + /Resources 5 0 R + /MediaBox [ 0 0 300 200 ] + /Contents 8 0 R + /Annots [ 4 0 R 9 0 R ] +>> +endobj +{{object 4 0}} << + /Type /Annot + /FT /Tx + /T (SharedField) + /DA (0 0 0 rg /F1 12 Tf) + /Rect [ 100 100 200 130 ] + /Subtype /Widget + /V (Hello, world) +>> +endobj +{{object 5 0}} << + /Font 6 0 R +>> +endobj +{{object 6 0}} << + /F1 7 0 R +>> +endobj +{{object 7 0}} << + /Type /Font + /Subtype /Type1 + /BaseFont /Helvetica +>> +endobj +{{object 8 0}} << +>> +stream +endstream +endobj +{{object 9 0}} << + /Type /Annot + /FT /Tx + /T (SharedField) + /DA (0 0 0 rg /F1 12 Tf) + /Rect [ 100 40 200 70 ] + /Subtype /Widget + /V () +>> +endobj +{{xref}} +trailer << + /Root 1 0 R + /Size 10 +>> +{{startxref}} +%%EOF diff --git a/testing/resources/pixel/bug_733528_expected.pdf.0.png b/testing/resources/pixel/bug_733528_expected.pdf.0.png new file mode 100644 index 0000000000..cdd39c1434 Binary files /dev/null and b/testing/resources/pixel/bug_733528_expected.pdf.0.png differ diff --git a/testing/resources/pixel/bug_733528_expected_mac.pdf.0.png b/testing/resources/pixel/bug_733528_expected_mac.pdf.0.png new file mode 100644 index 0000000000..f7c8302b1e Binary files /dev/null and b/testing/resources/pixel/bug_733528_expected_mac.pdf.0.png differ -- cgit v1.2.3