Only instantiate XFA when installing FormFillEnv.

It needn't be present at document creation time, so remove it
from two document creation routines to match the behavior when
loading a document.

This avoids an issue where Chromium printing tests may diff
when XFA is present.

Change-Id: I51e8a9502672eeeae2d92eef83c472d58427b250
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/77370
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Daniel Hosseinian <dhoss@chromium.org>
diff --git a/fpdfsdk/fpdf_dataavail.cpp b/fpdfsdk/fpdf_dataavail.cpp
index 05713ff..186cc4c 100644
--- a/fpdfsdk/fpdf_dataavail.cpp
+++ b/fpdfsdk/fpdf_dataavail.cpp
@@ -170,10 +170,6 @@
     return nullptr;
   }
 
-#ifdef PDF_ENABLE_XFA
-  document->SetExtension(std::make_unique<CPDFXFA_Context>(document.get()));
-#endif  // PDF_ENABLE_XFA
-
   ReportUnsupportedFeatures(document.get());
   return FPDFDocumentFromCPDFDocument(document.release());
 }
diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp
index a5a406a..8441c09 100644
--- a/fpdfsdk/fpdf_editpage.cpp
+++ b/fpdfsdk/fpdf_editpage.cpp
@@ -174,10 +174,6 @@
     pInfoDict->SetNewFor<CPDF_String>("Creator", L"PDFium");
   }
 
-#ifdef PDF_ENABLE_XFA
-  pDoc->SetExtension(std::make_unique<CPDFXFA_Context>(pDoc.get()));
-#endif  // PDF_ENABLE_XFA
-
   // Caller takes ownership of pDoc.
   return FPDFDocumentFromCPDFDocument(pDoc.release());
 }