summaryrefslogtreecommitdiff
path: root/fpdfsdk/cpdfsdk_formfillenvironment.h
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-05-18 12:32:20 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-05-18 20:16:06 +0000
commit940967de0b588d3abb9cba5822ae5f5c5fe05017 (patch)
tree6c34432c66d716918efd1917075076dbd870084a /fpdfsdk/cpdfsdk_formfillenvironment.h
parent690d456ad54f021063dcc17fde27c7ba4d910717 (diff)
downloadpdfium-940967de0b588d3abb9cba5822ae5f5c5fe05017.tar.xz
Use Unowned/Observed pointers between doc and FF onwership hierarchies.
See the explanation in CPDFSDK_FormFillEnvironment.h Change-Id: I52feb25fb358831233a636e3ead5aa70e98c5baa Reviewed-on: https://pdfium-review.googlesource.com/5658 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/cpdfsdk_formfillenvironment.h')
-rw-r--r--fpdfsdk/cpdfsdk_formfillenvironment.h21
1 files changed, 16 insertions, 5 deletions
diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.h b/fpdfsdk/cpdfsdk_formfillenvironment.h
index 5aead04191..0462426e0f 100644
--- a/fpdfsdk/cpdfsdk_formfillenvironment.h
+++ b/fpdfsdk/cpdfsdk_formfillenvironment.h
@@ -29,6 +29,17 @@ class CPDFSDK_InterForm;
class CPDFSDK_PageView;
class IJS_Runtime;
+// The CPDFSDK_FormFillEnvironment is "owned" by the embedder across the
+// C API as a FPDF_FormHandle, and may pop out of existence at any time,
+// so long as the associated embedder-owned FPDF_Document outlives it.
+// Pointers from objects in the FPDF_Document ownership hierarchy should
+// be ObservedPtr<> so as to clear themselves when the embedder "exits"
+// the form fill environment. Pointers from objects in this ownership
+// heirarcy to objects in the FPDF_Document ownership hierarcy should be
+// UnownedPtr<>, as should pointers from objects in this ownership
+// hierarcy back to the form fill environment itself, so as to flag any
+// lingering lifetime issues via the memory tools.
+
class CPDFSDK_FormFillEnvironment
: public CFX_Observable<CPDFSDK_FormFillEnvironment> {
public:
@@ -95,7 +106,7 @@ class CPDFSDK_FormFillEnvironment
int sizeOfArray);
UnderlyingDocumentType* GetUnderlyingDocument() const {
- return m_pUnderlyingDoc;
+ return m_pUnderlyingDoc.Get();
}
#ifdef PDF_ENABLE_XFA
@@ -103,7 +114,7 @@ class CPDFSDK_FormFillEnvironment
return m_pUnderlyingDoc ? m_pUnderlyingDoc->GetPDFDoc() : nullptr;
}
- CPDFXFA_Context* GetXFAContext() const { return m_pUnderlyingDoc; }
+ CPDFXFA_Context* GetXFAContext() const { return m_pUnderlyingDoc.Get(); }
void ResetXFADocument() { m_pUnderlyingDoc = nullptr; }
int GetPageViewCount() const { return m_PageMap.size(); }
@@ -154,7 +165,7 @@ class CPDFSDK_FormFillEnvironment
void PageEvent(int iPageCount, uint32_t dwEventType) const;
#else // PDF_ENABLE_XFA
- CPDF_Document* GetPDFDocument() const { return m_pUnderlyingDoc; }
+ CPDF_Document* GetPDFDocument() const { return m_pUnderlyingDoc.Get(); }
#endif // PDF_ENABLE_XFA
int JS_appAlert(const wchar_t* Msg,
@@ -203,14 +214,14 @@ class CPDFSDK_FormFillEnvironment
CPDFSDK_InterForm* GetInterForm(); // Creates if not present.
private:
+ FPDF_FORMFILLINFO* const m_pInfo;
std::unique_ptr<CPDFSDK_AnnotHandlerMgr> m_pAnnotHandlerMgr;
std::unique_ptr<CPDFSDK_ActionHandler> m_pActionHandler;
std::unique_ptr<IJS_Runtime> m_pJSRuntime;
- FPDF_FORMFILLINFO* const m_pInfo;
std::map<UnderlyingPageType*, std::unique_ptr<CPDFSDK_PageView>> m_PageMap;
std::unique_ptr<CPDFSDK_InterForm> m_pInterForm;
CPDFSDK_Annot::ObservedPtr m_pFocusAnnot;
- UnderlyingDocumentType* m_pUnderlyingDoc;
+ CFX_UnownedPtr<UnderlyingDocumentType> m_pUnderlyingDoc;
std::unique_ptr<CFFL_InteractiveFormFiller> m_pFormFiller;
std::unique_ptr<CFX_SystemHandler> m_pSysHandler;
bool m_bChangeMask;