diff options
author | dsinclair <dsinclair@chromium.org> | 2016-10-13 12:14:34 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-10-13 12:14:35 -0700 |
commit | a282c7380f3964de41ea93c9980b12c4513d3473 (patch) | |
tree | 5202284e527cd2bdcd7bcd22495018c9fbff1fd5 /fpdfsdk/fpdfxfa/cpdfxfa_document.cpp | |
parent | f3736bca5f874b0889c5906ffbd74a405089f671 (diff) | |
download | pdfium-a282c7380f3964de41ea93c9980b12c4513d3473.tar.xz |
Revert of Reland: Make the CPDFXFA_App non-global (patchset #2 id:20001 of https://codereview.chromium.org/2418653003/ )
Reason for revert:
https://build.chromium.org/p/client.pdfium/builders/linux_xfa_asan_lsan/builds/117/steps/corpus%20tests/logs/stdio
Original issue's description:
> Reland: Make the CPDFXFA_App non-global
>
> This reverts commit b685e6471075bebd26711bc183de3128f54932e3.
>
> This CL changes CPDFXFA_App from a global object to a child of the CPDFXFA_Document objects.
>
> BUG=pdfium:623
>
> Committed: https://pdfium.googlesource.com/pdfium/+/f3736bca5f874b0889c5906ffbd74a405089f671
TBR=tsepez@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=pdfium:623
Review-Url: https://codereview.chromium.org/2414883006
Diffstat (limited to 'fpdfsdk/fpdfxfa/cpdfxfa_document.cpp')
-rw-r--r-- | fpdfsdk/fpdfxfa/cpdfxfa_document.cpp | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_document.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_document.cpp index 79d28c0637..df0da31beb 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_document.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_document.cpp @@ -16,7 +16,6 @@ #include "fpdfsdk/fsdk_define.h" #include "fpdfsdk/javascript/ijs_runtime.h" #include "public/fpdf_formfill.h" -#include "third_party/base/ptr_util.h" #include "xfa/fxfa/cxfa_eventparam.h" #include "xfa/fxfa/xfa_ffapp.h" #include "xfa/fxfa/xfa_ffdoc.h" @@ -29,11 +28,13 @@ extern void SetLastError(int err); extern int GetLastError(); #endif -CPDFXFA_Document::CPDFXFA_Document(std::unique_ptr<CPDF_Document> pPDFDoc) +CPDFXFA_Document::CPDFXFA_Document(std::unique_ptr<CPDF_Document> pPDFDoc, + CPDFXFA_App* pProvider) : m_iDocType(DOCTYPE_PDF), m_pPDFDoc(std::move(pPDFDoc)), m_pFormFillEnv(nullptr), m_pXFADocView(nullptr), + m_pApp(pProvider), m_nLoadStatus(FXFA_LOADSTATUS_PRELOAD), m_nPageCount(0), m_DocEnv(this) {} @@ -41,12 +42,6 @@ CPDFXFA_Document::CPDFXFA_Document(std::unique_ptr<CPDF_Document> pPDFDoc) CPDFXFA_Document::~CPDFXFA_Document() { m_nLoadStatus = FXFA_LOADSTATUS_CLOSING; - // Must happen before we remove the form fill environment. - if (m_pXFADoc) { - if (CXFA_FFApp* pApp = GetApp()->GetXFAApp()) - CloseXFADoc(pApp->GetDocHandler()); - } - if (m_pFormFillEnv) { m_pFormFillEnv->ClearAllFocusedAnnots(); // Once we're deleted the FormFillEnvironment will point at a bad underlying @@ -55,21 +50,17 @@ CPDFXFA_Document::~CPDFXFA_Document() { m_pFormFillEnv = nullptr; } - m_nLoadStatus = FXFA_LOADSTATUS_CLOSED; -} - -void CPDFXFA_Document::CloseXFADoc(CXFA_FFDocHandler* pDoc) { - if (!pDoc) - return; - m_pXFADoc->CloseDoc(); - m_pXFADoc.reset(); - m_pXFADocView = nullptr; -} + if (m_pXFADoc) { + CXFA_FFApp* pApp = m_pApp->GetXFAApp(); + if (pApp) { + CXFA_FFDocHandler* pDocHandler = pApp->GetDocHandler(); + if (pDocHandler) + CloseXFADoc(pDocHandler); + } + m_pXFADoc.reset(); + } -CPDFXFA_App* CPDFXFA_Document::GetApp() { - if (!m_pApp) - m_pApp = pdfium::MakeUnique<CPDFXFA_App>(); - return m_pApp.get(); + m_nLoadStatus = FXFA_LOADSTATUS_CLOSED; } FX_BOOL CPDFXFA_Document::LoadXFADoc() { @@ -80,7 +71,7 @@ FX_BOOL CPDFXFA_Document::LoadXFADoc() { m_XFAPageList.RemoveAll(); - CXFA_FFApp* pApp = GetApp()->GetXFAApp(); + CXFA_FFApp* pApp = m_pApp->GetXFAApp(); if (!pApp) return FALSE; @@ -104,7 +95,7 @@ FX_BOOL CPDFXFA_Document::LoadXFADoc() { return FALSE; } m_pXFADoc->StopLoad(); - m_pXFADoc->GetXFADoc()->InitScriptContext(GetApp()->GetJSERuntime()); + m_pXFADoc->GetXFADoc()->InitScriptContext(m_pApp->GetJSERuntime()); if (m_pXFADoc->GetDocType() == XFA_DOCTYPE_Dynamic) m_iDocType = DOCTYPE_DYNAMIC_XFA; |