diff options
Diffstat (limited to 'core')
47 files changed, 141 insertions, 78 deletions
diff --git a/core/fpdfapi/font/font_int.h b/core/fpdfapi/font/font_int.h index f434f2b41d..ebd08e258a 100644 --- a/core/fpdfapi/font/font_int.h +++ b/core/fpdfapi/font/font_int.h @@ -150,7 +150,7 @@ class CPDF_CMapParser { const CFX_ByteStringC& first, const CFX_ByteStringC& second); - CPDF_CMap* const m_pCMap; + CFX_UnownedPtr<CPDF_CMap> const m_pCMap; int m_Status; int m_CodeSeq; uint32_t m_CodePoints[4]; diff --git a/core/fpdfapi/page/cpdf_iccprofile.h b/core/fpdfapi/page/cpdf_iccprofile.h index 05ac9bf1ba..a0cf744b9c 100644 --- a/core/fpdfapi/page/cpdf_iccprofile.h +++ b/core/fpdfapi/page/cpdf_iccprofile.h @@ -8,6 +8,7 @@ #define CORE_FPDFAPI_PAGE_CPDF_ICCPROFILE_H_ #include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/cfx_unowned_ptr.h" class CPDF_Stream; @@ -16,7 +17,7 @@ class CPDF_IccProfile : public CFX_Retainable { template <typename T, typename... Args> friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args); - CPDF_Stream* GetStream() const { return m_pStream; } + CPDF_Stream* GetStream() const { return m_pStream.Get(); } bool IsValid() const { return IsSRGB() || IsSupported(); } bool IsSRGB() const { return m_bsRGB; } bool IsSupported() const { return !!m_pTransform; } @@ -28,7 +29,7 @@ class CPDF_IccProfile : public CFX_Retainable { ~CPDF_IccProfile() override; const bool m_bsRGB; - CPDF_Stream* const m_pStream; + CFX_UnownedPtr<CPDF_Stream> const m_pStream; void* m_pTransform = nullptr; uint32_t m_nSrcComponents = 0; }; diff --git a/core/fpdfapi/page/cpdf_meshstream.h b/core/fpdfapi/page/cpdf_meshstream.h index e02c3bb4e8..af636a964d 100644 --- a/core/fpdfapi/page/cpdf_meshstream.h +++ b/core/fpdfapi/page/cpdf_meshstream.h @@ -67,8 +67,8 @@ class CPDF_MeshStream { const ShadingType m_type; const std::vector<std::unique_ptr<CPDF_Function>>& m_funcs; - CPDF_Stream* const m_pShadingStream; - CPDF_ColorSpace* const m_pCS; + CFX_UnownedPtr<CPDF_Stream> const m_pShadingStream; + CFX_UnownedPtr<CPDF_ColorSpace> const m_pCS; uint32_t m_nCoordBits; uint32_t m_nComponentBits; uint32_t m_nFlagBits; diff --git a/core/fpdfapi/parser/cpdf_stream_acc.h b/core/fpdfapi/parser/cpdf_stream_acc.h index 5bfdd186c4..bc03cb097b 100644 --- a/core/fpdfapi/parser/cpdf_stream_acc.h +++ b/core/fpdfapi/parser/cpdf_stream_acc.h @@ -27,7 +27,7 @@ class CPDF_StreamAcc : public CFX_Retainable { uint32_t estimated_size = 0, bool bImageAcc = false); - const CPDF_Stream* GetStream() const { return m_pStream; } + const CPDF_Stream* GetStream() const { return m_pStream.Get(); } CPDF_Dictionary* GetDict() const { return m_pStream ? m_pStream->GetDict() : nullptr; } @@ -47,7 +47,7 @@ class CPDF_StreamAcc : public CFX_Retainable { bool m_bNewBuf; CFX_ByteString m_ImageDecoder; CPDF_Dictionary* m_pImageParam; - const CPDF_Stream* const m_pStream; + CFX_UnownedPtr<const CPDF_Stream> const m_pStream; uint8_t* m_pSrcData; }; diff --git a/core/fpdfapi/render/cpdf_pagerendercache.h b/core/fpdfapi/render/cpdf_pagerendercache.h index 626e24bd2e..a874212392 100644 --- a/core/fpdfapi/render/cpdf_pagerendercache.h +++ b/core/fpdfapi/render/cpdf_pagerendercache.h @@ -10,6 +10,7 @@ #include <map> #include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_system.h" class CFX_DIBitmap; @@ -29,7 +30,7 @@ class CPDF_PageRenderCache { uint32_t GetTimeCount() const { return m_nTimeCount; } void ResetBitmap(const CFX_RetainPtr<CPDF_Image>& pImage, const CFX_RetainPtr<CFX_DIBitmap>& pBitmap); - CPDF_Page* GetPage() const { return m_pPage; } + CPDF_Page* GetPage() const { return m_pPage.Get(); } CPDF_ImageCacheEntry* GetCurImageCacheEntry() const { return m_pCurImageCacheEntry; } @@ -45,7 +46,7 @@ class CPDF_PageRenderCache { private: void ClearImageCacheEntry(CPDF_Stream* pStream); - CPDF_Page* const m_pPage; + CFX_UnownedPtr<CPDF_Page> const m_pPage; CPDF_ImageCacheEntry* m_pCurImageCacheEntry; std::map<CPDF_Stream*, CPDF_ImageCacheEntry*> m_ImageCache; uint32_t m_nTimeCount; diff --git a/core/fpdfapi/render/cpdf_progressiverenderer.cpp b/core/fpdfapi/render/cpdf_progressiverenderer.cpp index c3cef1fc77..4505db6874 100644 --- a/core/fpdfapi/render/cpdf_progressiverenderer.cpp +++ b/core/fpdfapi/render/cpdf_progressiverenderer.cpp @@ -53,8 +53,9 @@ void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) { m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->end(); m_pRenderStatus = pdfium::MakeUnique<CPDF_RenderStatus>(); m_pRenderStatus->Initialize( - m_pContext, m_pDevice, nullptr, nullptr, nullptr, nullptr, m_pOptions, - m_pCurrentLayer->m_pObjectHolder->m_Transparency, false, nullptr); + m_pContext.Get(), m_pDevice.Get(), nullptr, nullptr, nullptr, nullptr, + m_pOptions, m_pCurrentLayer->m_pObjectHolder->m_Transparency, false, + nullptr); m_pDevice->SaveState(); m_ClipRect = CFX_FloatRect(m_pDevice->GetClipBox()); CFX_Matrix device2object; diff --git a/core/fpdfapi/render/cpdf_progressiverenderer.h b/core/fpdfapi/render/cpdf_progressiverenderer.h index f0b1579601..cadbd2d089 100644 --- a/core/fpdfapi/render/cpdf_progressiverenderer.h +++ b/core/fpdfapi/render/cpdf_progressiverenderer.h @@ -47,8 +47,8 @@ class CPDF_ProgressiveRenderer { static const int kStepLimit = 100; Status m_Status; - CPDF_RenderContext* const m_pContext; - CFX_RenderDevice* const m_pDevice; + CFX_UnownedPtr<CPDF_RenderContext> const m_pContext; + CFX_UnownedPtr<CFX_RenderDevice> const m_pDevice; const CPDF_RenderOptions* const m_pOptions; std::unique_ptr<CPDF_RenderStatus> m_pRenderStatus; CFX_FloatRect m_ClipRect; diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index 1d2218c166..7c17ff56b4 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -82,11 +82,11 @@ class CPDF_RefType3Cache { ~CPDF_RefType3Cache() { while (m_dwCount--) - ReleaseCachedType3(m_pType3Font); + ReleaseCachedType3(m_pType3Font.Get()); } uint32_t m_dwCount; - CPDF_Type3Font* const m_pType3Font; + CFX_UnownedPtr<CPDF_Type3Font> const m_pType3Font; }; uint32_t CountOutputs( diff --git a/core/fpdfapi/render/cpdf_type3cache.h b/core/fpdfapi/render/cpdf_type3cache.h index 3c7d95b8c0..36a1d6f98a 100644 --- a/core/fpdfapi/render/cpdf_type3cache.h +++ b/core/fpdfapi/render/cpdf_type3cache.h @@ -38,7 +38,7 @@ class CPDF_Type3Cache : public CFX_Retainable { float retinaScaleX, float retinaScaleY); - CPDF_Type3Font* const m_pFont; + CFX_UnownedPtr<CPDF_Type3Font> const m_pFont; std::map<CFX_ByteString, std::unique_ptr<CPDF_Type3Glyphs>> m_SizeMap; }; diff --git a/core/fpdfdoc/cpdf_aaction.cpp b/core/fpdfdoc/cpdf_aaction.cpp index 7dc42828f4..033bf03a6a 100644 --- a/core/fpdfdoc/cpdf_aaction.cpp +++ b/core/fpdfdoc/cpdf_aaction.cpp @@ -14,6 +14,14 @@ const char* g_sAATypes[] = {"E", "X", "D", "U", "Fo", "Bl", "PO", "PC", } // namespace +CPDF_AAction::CPDF_AAction() {} + +CPDF_AAction::CPDF_AAction(CPDF_Dictionary* pDict) : m_pDict(pDict) {} + +CPDF_AAction::CPDF_AAction(const CPDF_AAction& that) = default; + +CPDF_AAction::~CPDF_AAction() {} + bool CPDF_AAction::ActionExist(AActionType eType) const { return m_pDict && m_pDict->KeyExist(g_sAATypes[eType]); } diff --git a/core/fpdfdoc/cpdf_aaction.h b/core/fpdfdoc/cpdf_aaction.h index d615915ee3..b2b691fc26 100644 --- a/core/fpdfdoc/cpdf_aaction.h +++ b/core/fpdfdoc/cpdf_aaction.h @@ -37,15 +37,17 @@ class CPDF_AAction { DocumentPrinted }; - CPDF_AAction() : m_pDict(nullptr) {} - explicit CPDF_AAction(CPDF_Dictionary* pDict) : m_pDict(pDict) {} + CPDF_AAction(); + explicit CPDF_AAction(CPDF_Dictionary* pDict); + CPDF_AAction(const CPDF_AAction& that); + ~CPDF_AAction(); bool ActionExist(AActionType eType) const; CPDF_Action GetAction(AActionType eType) const; - CPDF_Dictionary* GetDict() const { return m_pDict; } + CPDF_Dictionary* GetDict() const { return m_pDict.Get(); } private: - CPDF_Dictionary* const m_pDict; + CFX_UnownedPtr<CPDF_Dictionary> const m_pDict; }; #endif // CORE_FPDFDOC_CPDF_AACTION_H_ diff --git a/core/fpdfdoc/cpdf_action.cpp b/core/fpdfdoc/cpdf_action.cpp index f523f86b37..b40fdcd225 100644 --- a/core/fpdfdoc/cpdf_action.cpp +++ b/core/fpdfdoc/cpdf_action.cpp @@ -21,6 +21,14 @@ const char* const g_sATypes[] = { } // namespace +CPDF_Action::CPDF_Action() {} + +CPDF_Action::CPDF_Action(CPDF_Dictionary* pDict) : m_pDict(pDict) {} + +CPDF_Action::CPDF_Action(const CPDF_Action& that) = default; + +CPDF_Action::~CPDF_Action() {} + CPDF_Dest CPDF_Action::GetDest(CPDF_Document* pDoc) const { if (!m_pDict) return CPDF_Dest(); diff --git a/core/fpdfdoc/cpdf_action.h b/core/fpdfdoc/cpdf_action.h index 426edb12e9..bd1ce58ec6 100644 --- a/core/fpdfdoc/cpdf_action.h +++ b/core/fpdfdoc/cpdf_action.h @@ -37,10 +37,12 @@ class CPDF_Action { GoTo3DView }; - CPDF_Action() : m_pDict(nullptr) {} - explicit CPDF_Action(CPDF_Dictionary* pDict) : m_pDict(pDict) {} + CPDF_Action(); + explicit CPDF_Action(CPDF_Dictionary* pDict); + CPDF_Action(const CPDF_Action& that); + ~CPDF_Action(); - CPDF_Dictionary* GetDict() const { return m_pDict; } + CPDF_Dictionary* GetDict() const { return m_pDict.Get(); } ActionType GetType() const; CPDF_Dest GetDest(CPDF_Document* pDoc) const; CFX_WideString GetFilePath() const; @@ -53,7 +55,7 @@ class CPDF_Action { CPDF_Action GetSubAction(size_t iIndex) const; private: - CPDF_Dictionary* const m_pDict; + CFX_UnownedPtr<CPDF_Dictionary> const m_pDict; }; #endif // CORE_FPDFDOC_CPDF_ACTION_H_ diff --git a/core/fpdfdoc/cpdf_actionfields.cpp b/core/fpdfdoc/cpdf_actionfields.cpp index 35ec92c1b8..f3c3f5ed25 100644 --- a/core/fpdfdoc/cpdf_actionfields.cpp +++ b/core/fpdfdoc/cpdf_actionfields.cpp @@ -10,6 +10,11 @@ #include "core/fpdfapi/parser/cpdf_dictionary.h" #include "core/fpdfdoc/cpdf_action.h" +CPDF_ActionFields::CPDF_ActionFields(const CPDF_Action* pAction) + : m_pAction(pAction) {} + +CPDF_ActionFields::~CPDF_ActionFields() {} + size_t CPDF_ActionFields::GetFieldsCount() const { if (!m_pAction) return 0; diff --git a/core/fpdfdoc/cpdf_actionfields.h b/core/fpdfdoc/cpdf_actionfields.h index 9e0664cadb..71b42475a7 100644 --- a/core/fpdfdoc/cpdf_actionfields.h +++ b/core/fpdfdoc/cpdf_actionfields.h @@ -11,19 +11,22 @@ #include <vector> +#include "core/fxcrt/cfx_unowned_ptr.h" + class CPDF_Action; class CPDF_Object; class CPDF_ActionFields { public: - explicit CPDF_ActionFields(const CPDF_Action* pAction) : m_pAction(pAction) {} + explicit CPDF_ActionFields(const CPDF_Action* pAction); + ~CPDF_ActionFields(); size_t GetFieldsCount() const; std::vector<CPDF_Object*> GetAllFields() const; CPDF_Object* GetField(size_t iIndex) const; private: - const CPDF_Action* const m_pAction; + CFX_UnownedPtr<const CPDF_Action> const m_pAction; }; #endif // CORE_FPDFDOC_CPDF_ACTIONFIELDS_H_ diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp index 146c863cf3..eab6cd0145 100644 --- a/core/fpdfdoc/cpdf_annot.cpp +++ b/core/fpdfdoc/cpdf_annot.cpp @@ -90,23 +90,23 @@ void CPDF_Annot::GenerateAPIfNeeded() { CPDF_Dictionary* pDict = m_pAnnotDict.Get(); bool result = false; if (m_nSubtype == CPDF_Annot::Subtype::CIRCLE) - result = CPVT_GenerateAP::GenerateCircleAP(m_pDocument, pDict); + result = CPVT_GenerateAP::GenerateCircleAP(m_pDocument.Get(), pDict); else if (m_nSubtype == CPDF_Annot::Subtype::HIGHLIGHT) - result = CPVT_GenerateAP::GenerateHighlightAP(m_pDocument, pDict); + result = CPVT_GenerateAP::GenerateHighlightAP(m_pDocument.Get(), pDict); else if (m_nSubtype == CPDF_Annot::Subtype::INK) - result = CPVT_GenerateAP::GenerateInkAP(m_pDocument, pDict); + result = CPVT_GenerateAP::GenerateInkAP(m_pDocument.Get(), pDict); else if (m_nSubtype == CPDF_Annot::Subtype::POPUP) - result = CPVT_GenerateAP::GeneratePopupAP(m_pDocument, pDict); + result = CPVT_GenerateAP::GeneratePopupAP(m_pDocument.Get(), pDict); else if (m_nSubtype == CPDF_Annot::Subtype::SQUARE) - result = CPVT_GenerateAP::GenerateSquareAP(m_pDocument, pDict); + result = CPVT_GenerateAP::GenerateSquareAP(m_pDocument.Get(), pDict); else if (m_nSubtype == CPDF_Annot::Subtype::SQUIGGLY) - result = CPVT_GenerateAP::GenerateSquigglyAP(m_pDocument, pDict); + result = CPVT_GenerateAP::GenerateSquigglyAP(m_pDocument.Get(), pDict); else if (m_nSubtype == CPDF_Annot::Subtype::STRIKEOUT) - result = CPVT_GenerateAP::GenerateStrikeOutAP(m_pDocument, pDict); + result = CPVT_GenerateAP::GenerateStrikeOutAP(m_pDocument.Get(), pDict); else if (m_nSubtype == CPDF_Annot::Subtype::TEXT) - result = CPVT_GenerateAP::GenerateTextAP(m_pDocument, pDict); + result = CPVT_GenerateAP::GenerateTextAP(m_pDocument.Get(), pDict); else if (m_nSubtype == CPDF_Annot::Subtype::UNDERLINE) - result = CPVT_GenerateAP::GenerateUnderlineAP(m_pDocument, pDict); + result = CPVT_GenerateAP::GenerateUnderlineAP(m_pDocument.Get(), pDict); if (result) { m_pAnnotDict->SetNewFor<CPDF_Boolean>(kPDFiumKey_HasGeneratedAP, result); @@ -205,7 +205,7 @@ CPDF_Form* CPDF_Annot::GetAPForm(const CPDF_Page* pPage, AppearanceMode mode) { return it->second.get(); auto pNewForm = pdfium::MakeUnique<CPDF_Form>( - m_pDocument, pPage->m_pResources.Get(), pStream); + m_pDocument.Get(), pPage->m_pResources.Get(), pStream); pNewForm->ParseContent(nullptr, nullptr, nullptr); CPDF_Form* pResult = pNewForm.get(); diff --git a/core/fpdfdoc/cpdf_annot.h b/core/fpdfdoc/cpdf_annot.h index 188106acdf..85a205345e 100644 --- a/core/fpdfdoc/cpdf_annot.h +++ b/core/fpdfdoc/cpdf_annot.h @@ -82,7 +82,7 @@ class CPDF_Annot { CPDF_Annot::Subtype GetSubtype() const; uint32_t GetFlags() const; CFX_FloatRect GetRect() const; - CPDF_Document* GetDocument() const { return m_pDocument; } + CPDF_Document* GetDocument() const { return m_pDocument.Get(); } CPDF_Dictionary* GetAnnotDict() const { return m_pAnnotDict.Get(); } bool DrawAppearance(CPDF_Page* pPage, @@ -112,7 +112,7 @@ class CPDF_Annot { CFX_FloatRect RectForDrawing() const; CFX_MaybeOwned<CPDF_Dictionary> m_pAnnotDict; - CPDF_Document* const m_pDocument; + CFX_UnownedPtr<CPDF_Document> const m_pDocument; CPDF_Annot::Subtype m_nSubtype; std::map<CPDF_Stream*, std::unique_ptr<CPDF_Form>> m_APMap; // |m_bOpenState| is only set for popup annotations. diff --git a/core/fpdfdoc/cpdf_apsettings.cpp b/core/fpdfdoc/cpdf_apsettings.cpp index 4c44f5a13e..ee205e01dc 100644 --- a/core/fpdfdoc/cpdf_apsettings.cpp +++ b/core/fpdfdoc/cpdf_apsettings.cpp @@ -14,6 +14,10 @@ CPDF_ApSettings::CPDF_ApSettings(CPDF_Dictionary* pDict) : m_pDict(pDict) {} +CPDF_ApSettings::CPDF_ApSettings(const CPDF_ApSettings& that) = default; + +CPDF_ApSettings::~CPDF_ApSettings() {} + bool CPDF_ApSettings::HasMKEntry(const CFX_ByteString& csEntry) const { return m_pDict && m_pDict->KeyExist(csEntry); } diff --git a/core/fpdfdoc/cpdf_apsettings.h b/core/fpdfdoc/cpdf_apsettings.h index ba0b05bd2b..2f8f9e49d9 100644 --- a/core/fpdfdoc/cpdf_apsettings.h +++ b/core/fpdfdoc/cpdf_apsettings.h @@ -8,6 +8,7 @@ #define CORE_FPDFDOC_CPDF_APSETTINGS_H_ #include "core/fpdfdoc/cpdf_iconfit.h" +#include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_string.h" #include "core/fxcrt/fx_system.h" #include "core/fxge/fx_dib.h" @@ -19,6 +20,8 @@ class CPDF_Stream; class CPDF_ApSettings { public: explicit CPDF_ApSettings(CPDF_Dictionary* pDict); + CPDF_ApSettings(const CPDF_ApSettings& that); + ~CPDF_ApSettings(); bool HasMKEntry(const CFX_ByteString& csEntry) const; int GetRotation() const; @@ -68,7 +71,7 @@ class CPDF_ApSettings { CFX_WideString GetCaption(const CFX_ByteString& csEntry) const; CPDF_Stream* GetIcon(const CFX_ByteString& csEntry) const; - CPDF_Dictionary* const m_pDict; + CFX_UnownedPtr<CPDF_Dictionary> const m_pDict; }; #endif // CORE_FPDFDOC_CPDF_APSETTINGS_H_ diff --git a/core/fpdfdoc/cpdf_formcontrol.cpp b/core/fpdfdoc/cpdf_formcontrol.cpp index d9740f7c99..54524a64e2 100644 --- a/core/fpdfdoc/cpdf_formcontrol.cpp +++ b/core/fpdfdoc/cpdf_formcontrol.cpp @@ -32,6 +32,8 @@ CPDF_FormControl::CPDF_FormControl(CPDF_FormField* pField, m_pWidgetDict(pWidgetDict), m_pForm(m_pField->GetForm()) {} +CPDF_FormControl::~CPDF_FormControl() {} + CFX_ByteString CPDF_FormControl::GetOnStateName() const { ASSERT(GetType() == CPDF_FormField::CheckBox || GetType() == CPDF_FormField::RadioButton); @@ -167,7 +169,7 @@ void CPDF_FormControl::DrawControl(CFX_RenderDevice* pDevice, if (m_pWidgetDict->GetIntegerFor("F") & ANNOTFLAG_HIDDEN) return; - CPDF_Stream* pStream = FPDFDOC_GetAnnotAP(m_pWidgetDict, mode); + CPDF_Stream* pStream = FPDFDOC_GetAnnotAP(m_pWidgetDict.Get(), mode); if (!pStream) return; @@ -178,7 +180,7 @@ void CPDF_FormControl::DrawControl(CFX_RenderDevice* pDevice, CFX_Matrix matrix; matrix.MatchRect(arect, form_bbox); matrix.Concat(*pMatrix); - CPDF_Form form(m_pField->GetForm()->m_pDocument, + CPDF_Form form(m_pField->GetForm()->m_pDocument.Get(), m_pField->GetForm()->m_pFormDict->GetDictFor("DR"), pStream); form.ParseContent(nullptr, nullptr, nullptr); CPDF_RenderContext context(pPage); @@ -286,7 +288,7 @@ CPDF_Font* CPDF_FormControl::GetDefaultControlFont() { if (csFontNameTag.IsEmpty()) return nullptr; - CPDF_Object* pObj = FPDF_GetFieldAttr(m_pWidgetDict, "DR"); + CPDF_Object* pObj = FPDF_GetFieldAttr(m_pWidgetDict.Get(), "DR"); if (CPDF_Dictionary* pDict = ToDictionary(pObj)) { CPDF_Dictionary* pFonts = pDict->GetDictFor("Font"); if (pFonts) { diff --git a/core/fpdfdoc/cpdf_formcontrol.h b/core/fpdfdoc/cpdf_formcontrol.h index 154d592f32..eb63b5b6f0 100644 --- a/core/fpdfdoc/cpdf_formcontrol.h +++ b/core/fpdfdoc/cpdf_formcontrol.h @@ -47,11 +47,12 @@ class CPDF_FormControl { enum HighlightingMode { None = 0, Invert, Outline, Push, Toggle }; CPDF_FormControl(CPDF_FormField* pField, CPDF_Dictionary* pWidgetDict); + ~CPDF_FormControl(); CPDF_FormField::Type GetType() const { return m_pField->GetType(); } - const CPDF_InterForm* GetInterForm() const { return m_pForm; } + const CPDF_InterForm* GetInterForm() const { return m_pForm.Get(); } CPDF_FormField* GetField() const { return m_pField; } - CPDF_Dictionary* GetWidget() const { return m_pWidgetDict; } + CPDF_Dictionary* GetWidget() const { return m_pWidgetDict.Get(); } CFX_FloatRect GetRect() const { return m_pWidgetDict->GetRectFor("Rect"); } void DrawControl(CFX_RenderDevice* pDevice, @@ -127,8 +128,8 @@ class CPDF_FormControl { CPDF_ApSettings GetMK() const; CPDF_FormField* const m_pField; - CPDF_Dictionary* const m_pWidgetDict; - const CPDF_InterForm* const m_pForm; + CFX_UnownedPtr<CPDF_Dictionary> const m_pWidgetDict; + CFX_UnownedPtr<const CPDF_InterForm> const m_pForm; }; #endif // CORE_FPDFDOC_CPDF_FORMCONTROL_H_ diff --git a/core/fpdfdoc/cpdf_formfield.cpp b/core/fpdfdoc/cpdf_formfield.cpp index 7a48826cbd..97ea052436 100644 --- a/core/fpdfdoc/cpdf_formfield.cpp +++ b/core/fpdfdoc/cpdf_formfield.cpp @@ -408,7 +408,7 @@ int CPDF_FormField::GetMaxLen() const { for (auto& pControl : m_ControlList) { if (!pControl) continue; - CPDF_Dictionary* pWidgetDict = pControl->m_pWidgetDict; + CPDF_Dictionary* pWidgetDict = pControl->m_pWidgetDict.Get(); if (pWidgetDict->KeyExist("MaxLen")) return pWidgetDict->GetIntegerFor("MaxLen"); } diff --git a/core/fpdfdoc/cpdf_iconfit.cpp b/core/fpdfdoc/cpdf_iconfit.cpp index 0f05d7de35..a28f3bc430 100644 --- a/core/fpdfdoc/cpdf_iconfit.cpp +++ b/core/fpdfdoc/cpdf_iconfit.cpp @@ -10,6 +10,12 @@ #include "core/fpdfapi/parser/cpdf_dictionary.h" #include "core/fxcrt/fx_string.h" +CPDF_IconFit::CPDF_IconFit(const CPDF_Dictionary* pDict) : m_pDict(pDict) {} + +CPDF_IconFit::CPDF_IconFit(const CPDF_IconFit& that) = default; + +CPDF_IconFit::~CPDF_IconFit() {} + CPDF_IconFit::ScaleMethod CPDF_IconFit::GetScaleMethod() { if (!m_pDict) return Always; diff --git a/core/fpdfdoc/cpdf_iconfit.h b/core/fpdfdoc/cpdf_iconfit.h index 6e3b8cf50a..0fa8d37e24 100644 --- a/core/fpdfdoc/cpdf_iconfit.h +++ b/core/fpdfdoc/cpdf_iconfit.h @@ -7,6 +7,7 @@ #ifndef CORE_FPDFDOC_CPDF_ICONFIT_H_ #define CORE_FPDFDOC_CPDF_ICONFIT_H_ +#include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_system.h" class CPDF_Dictionary; @@ -15,16 +16,18 @@ class CPDF_IconFit { public: enum ScaleMethod { Always = 0, Bigger, Smaller, Never }; - explicit CPDF_IconFit(const CPDF_Dictionary* pDict) : m_pDict(pDict) {} + explicit CPDF_IconFit(const CPDF_Dictionary* pDict); + CPDF_IconFit(const CPDF_IconFit& that); + ~CPDF_IconFit(); ScaleMethod GetScaleMethod(); bool IsProportionalScale(); void GetIconPosition(float& fLeft, float& fBottom); bool GetFittingBounds(); - const CPDF_Dictionary* GetDict() const { return m_pDict; } + const CPDF_Dictionary* GetDict() const { return m_pDict.Get(); } private: - const CPDF_Dictionary* const m_pDict; + CFX_UnownedPtr<const CPDF_Dictionary> const m_pDict; }; #endif // CORE_FPDFDOC_CPDF_ICONFIT_H_ diff --git a/core/fpdfdoc/cpdf_interform.cpp b/core/fpdfdoc/cpdf_interform.cpp index 455158b74d..de99a5de0f 100644 --- a/core/fpdfdoc/cpdf_interform.cpp +++ b/core/fpdfdoc/cpdf_interform.cpp @@ -961,7 +961,7 @@ int CPDF_InterForm::FindFieldInCalculationOrder(const CPDF_FormField* pField) { } CPDF_Font* CPDF_InterForm::GetFormFont(CFX_ByteString csNameTag) const { - return GetFont(m_pFormDict, m_pDocument, csNameTag); + return GetFont(m_pFormDict, m_pDocument.Get(), csNameTag); } CPDF_DefaultAppearance CPDF_InterForm::GetDefaultAppearance() const { diff --git a/core/fpdfdoc/cpdf_interform.h b/core/fpdfdoc/cpdf_interform.h index 23530e57b2..0a9b3e0e4a 100644 --- a/core/fpdfdoc/cpdf_interform.h +++ b/core/fpdfdoc/cpdf_interform.h @@ -108,7 +108,7 @@ class CPDF_InterForm { static bool s_bUpdateAP; - CPDF_Document* const m_pDocument; + CFX_UnownedPtr<CPDF_Document> const m_pDocument; CPDF_Dictionary* m_pFormDict; std::map<const CPDF_Dictionary*, std::unique_ptr<CPDF_FormControl>> m_ControlMap; diff --git a/core/fpdfdoc/cpdf_numbertree.cpp b/core/fpdfdoc/cpdf_numbertree.cpp index 5f2bc06666..952fb4ef1d 100644 --- a/core/fpdfdoc/cpdf_numbertree.cpp +++ b/core/fpdfdoc/cpdf_numbertree.cpp @@ -47,6 +47,10 @@ CPDF_Object* SearchNumberNode(const CPDF_Dictionary* pNode, int num) { } // namespace +CPDF_NumberTree::CPDF_NumberTree(CPDF_Dictionary* pRoot) : m_pRoot(pRoot) {} + +CPDF_NumberTree::~CPDF_NumberTree() {} + CPDF_Object* CPDF_NumberTree::LookupValue(int num) const { - return SearchNumberNode(m_pRoot, num); + return SearchNumberNode(m_pRoot.Get(), num); } diff --git a/core/fpdfdoc/cpdf_numbertree.h b/core/fpdfdoc/cpdf_numbertree.h index bfe44fddb9..843e186208 100644 --- a/core/fpdfdoc/cpdf_numbertree.h +++ b/core/fpdfdoc/cpdf_numbertree.h @@ -7,17 +7,20 @@ #ifndef CORE_FPDFDOC_CPDF_NUMBERTREE_H_ #define CORE_FPDFDOC_CPDF_NUMBERTREE_H_ +#include "core/fxcrt/cfx_unowned_ptr.h" + class CPDF_Dictionary; class CPDF_Object; class CPDF_NumberTree { public: - explicit CPDF_NumberTree(CPDF_Dictionary* pRoot) : m_pRoot(pRoot) {} + explicit CPDF_NumberTree(CPDF_Dictionary* pRoot); + ~CPDF_NumberTree(); CPDF_Object* LookupValue(int num) const; protected: - CPDF_Dictionary* const m_pRoot; + CFX_UnownedPtr<CPDF_Dictionary> const m_pRoot; }; #endif // CORE_FPDFDOC_CPDF_NUMBERTREE_H_ diff --git a/core/fpdfdoc/cpdf_occontext.cpp b/core/fpdfdoc/cpdf_occontext.cpp index c4272f4897..66950c9406 100644 --- a/core/fpdfdoc/cpdf_occontext.cpp +++ b/core/fpdfdoc/cpdf_occontext.cpp @@ -101,7 +101,7 @@ CPDF_OCContext::~CPDF_OCContext() {} bool CPDF_OCContext::LoadOCGStateFromConfig( const CFX_ByteString& csConfig, const CPDF_Dictionary* pOCGDict) const { - CPDF_Dictionary* pConfig = GetConfig(m_pDocument, pOCGDict); + CPDF_Dictionary* pConfig = GetConfig(m_pDocument.Get(), pOCGDict); if (!pConfig) return true; diff --git a/core/fpdfdoc/cpdf_occontext.h b/core/fpdfdoc/cpdf_occontext.h index 753aa5c176..ea8eea2489 100644 --- a/core/fpdfdoc/cpdf_occontext.h +++ b/core/fpdfdoc/cpdf_occontext.h @@ -38,7 +38,7 @@ class CPDF_OCContext : public CFX_Retainable { bool GetOCGVE(CPDF_Array* pExpression, int nLevel); bool LoadOCMDState(const CPDF_Dictionary* pOCMDDict); - CPDF_Document* const m_pDocument; + CFX_UnownedPtr<CPDF_Document> const m_pDocument; const UsageType m_eUsageType; std::map<const CPDF_Dictionary*, bool> m_OCGStates; }; diff --git a/core/fpdfdoc/cpdf_pagelabel.cpp b/core/fpdfdoc/cpdf_pagelabel.cpp index 4200a28f64..3892abad5e 100644 --- a/core/fpdfdoc/cpdf_pagelabel.cpp +++ b/core/fpdfdoc/cpdf_pagelabel.cpp @@ -75,6 +75,8 @@ CFX_WideString GetLabelNumPortion(int num, const CFX_ByteString& bsStyle) { CPDF_PageLabel::CPDF_PageLabel(CPDF_Document* pDocument) : m_pDocument(pDocument) {} +CPDF_PageLabel::~CPDF_PageLabel() {} + bool CPDF_PageLabel::GetLabel(int nPage, CFX_WideString* wsLabel) const { if (!m_pDocument) return false; diff --git a/core/fpdfdoc/cpdf_pagelabel.h b/core/fpdfdoc/cpdf_pagelabel.h index 0f91f614d9..66324f87c6 100644 --- a/core/fpdfdoc/cpdf_pagelabel.h +++ b/core/fpdfdoc/cpdf_pagelabel.h @@ -14,13 +14,14 @@ class CPDF_Document; class CPDF_PageLabel { public: explicit CPDF_PageLabel(CPDF_Document* pDocument); + ~CPDF_PageLabel(); bool GetLabel(int nPage, CFX_WideString* wsLabel) const; int32_t GetPageByLabel(const CFX_ByteStringC& bsLabel) const; int32_t GetPageByLabel(const CFX_WideStringC& wsLabel) const; private: - CPDF_Document* const m_pDocument; + CFX_UnownedPtr<CPDF_Document> const m_pDocument; }; #endif // CORE_FPDFDOC_CPDF_PAGELABEL_H_ diff --git a/core/fpdfdoc/cpdf_structelement.cpp b/core/fpdfdoc/cpdf_structelement.cpp index c85ae0dd42..c5f2b6bd79 100644 --- a/core/fpdfdoc/cpdf_structelement.cpp +++ b/core/fpdfdoc/cpdf_structelement.cpp @@ -133,5 +133,5 @@ void CPDF_StructElement::LoadKid(uint32_t PageObjNum, } pKid->m_pElement = - pdfium::MakeRetain<CPDF_StructElement>(m_pTree, this, pKidDict); + pdfium::MakeRetain<CPDF_StructElement>(m_pTree.Get(), this, pKidDict); } diff --git a/core/fpdfdoc/cpdf_structelement.h b/core/fpdfdoc/cpdf_structelement.h index d8820a141c..8fe73e51c8 100644 --- a/core/fpdfdoc/cpdf_structelement.h +++ b/core/fpdfdoc/cpdf_structelement.h @@ -41,7 +41,7 @@ class CPDF_StructElement : public CFX_Retainable { const CFX_ByteString& GetType() const { return m_Type; } const CFX_ByteString& GetTitle() const { return m_Title; } - CPDF_Dictionary* GetDict() const { return m_pDict; } + CPDF_Dictionary* GetDict() const { return m_pDict.Get(); } int CountKids() const; CPDF_StructElement* GetKidIfElement(int index) const; @@ -56,9 +56,9 @@ class CPDF_StructElement : public CFX_Retainable { void LoadKids(CPDF_Dictionary* pDict); void LoadKid(uint32_t PageObjNum, CPDF_Object* pObj, CPDF_StructKid* pKid); - CPDF_StructTree* const m_pTree; - CPDF_StructElement* const m_pParent; - CPDF_Dictionary* const m_pDict; + CFX_UnownedPtr<CPDF_StructTree> const m_pTree; + CFX_UnownedPtr<CPDF_StructElement> const m_pParent; + CFX_UnownedPtr<CPDF_Dictionary> const m_pDict; CFX_ByteString m_Type; CFX_ByteString m_Title; std::vector<CPDF_StructKid> m_Kids; diff --git a/core/fpdfdoc/cpdf_variabletext.h b/core/fpdfdoc/cpdf_variabletext.h index 2e6caf63d6..a226350006 100644 --- a/core/fpdfdoc/cpdf_variabletext.h +++ b/core/fpdfdoc/cpdf_variabletext.h @@ -58,7 +58,7 @@ class CPDF_VariableText { private: CPVT_WordPlace m_CurPos; - CPDF_VariableText* const m_pVT; + CFX_UnownedPtr<CPDF_VariableText> const m_pVT; }; class Provider { diff --git a/core/fpdfdoc/csection.h b/core/fpdfdoc/csection.h index b465d1d63d..aefdcaf7b2 100644 --- a/core/fpdfdoc/csection.h +++ b/core/fpdfdoc/csection.h @@ -57,7 +57,7 @@ class CSection final { void ClearRightWords(int32_t nWordIndex); void ClearMidWords(int32_t nBeginIndex, int32_t nEndIndex); - CPDF_VariableText* const m_pVT; + CFX_UnownedPtr<CPDF_VariableText> const m_pVT; }; #endif // CORE_FPDFDOC_CSECTION_H_ diff --git a/core/fpdfdoc/ctypeset.h b/core/fpdfdoc/ctypeset.h index f769fe1311..1b016ea562 100644 --- a/core/fpdfdoc/ctypeset.h +++ b/core/fpdfdoc/ctypeset.h @@ -27,7 +27,7 @@ class CTypeset final { void OutputLines(); CPVT_FloatRect m_rcRet; - CPDF_VariableText* const m_pVT; + CFX_UnownedPtr<CPDF_VariableText> const m_pVT; CSection* const m_pSection; }; diff --git a/core/fpdftext/cpdf_linkextract.h b/core/fpdftext/cpdf_linkextract.h index 43306cf87a..564d552548 100644 --- a/core/fpdftext/cpdf_linkextract.h +++ b/core/fpdftext/cpdf_linkextract.h @@ -38,7 +38,7 @@ class CPDF_LinkExtract { CFX_WideString m_strUrl; }; - const CPDF_TextPage* const m_pTextPage; + CFX_UnownedPtr<const CPDF_TextPage> const m_pTextPage; CFX_WideString m_strPageText; std::vector<Link> m_LinkArray; }; diff --git a/core/fxcodec/codec/cjpx_decoder.h b/core/fxcodec/codec/cjpx_decoder.h index 2e63caac73..a62b41aafc 100644 --- a/core/fxcodec/codec/cjpx_decoder.h +++ b/core/fxcodec/codec/cjpx_decoder.h @@ -9,6 +9,7 @@ #include <vector> +#include "core/fxcrt/cfx_unowned_ptr.h" #include "third_party/libopenjpeg20/openjpeg.h" class CPDF_ColorSpace; @@ -30,7 +31,7 @@ class CJPX_Decoder { opj_image_t* image; opj_codec_t* l_codec; opj_stream_t* l_stream; - const CPDF_ColorSpace* const m_ColorSpace; + CFX_UnownedPtr<const CPDF_ColorSpace> const m_ColorSpace; }; #endif // CORE_FXCODEC_CODEC_CJPX_DECODER_H_ diff --git a/core/fxcodec/jbig2/JBig2_ArithDecoder.h b/core/fxcodec/jbig2/JBig2_ArithDecoder.h index 24fb80cfbd..2ec64fe954 100644 --- a/core/fxcodec/jbig2/JBig2_ArithDecoder.h +++ b/core/fxcodec/jbig2/JBig2_ArithDecoder.h @@ -9,6 +9,8 @@ #include <stdint.h> +#include "core/fxcrt/cfx_unowned_ptr.h" + class CJBig2_BitStream; struct JBig2ArithCtx { @@ -37,7 +39,7 @@ class CJBig2_ArithDecoder { unsigned int m_C; unsigned int m_A; unsigned int m_CT; - CJBig2_BitStream* const m_pStream; + CFX_UnownedPtr<CJBig2_BitStream> const m_pStream; }; #endif // CORE_FXCODEC_JBIG2_JBIG2_ARITHDECODER_H_ diff --git a/core/fxcodec/jbig2/JBig2_Context.h b/core/fxcodec/jbig2/JBig2_Context.h index 8568aab7e7..4151fa356e 100644 --- a/core/fxcodec/jbig2/JBig2_Context.h +++ b/core/fxcodec/jbig2/JBig2_Context.h @@ -95,7 +95,7 @@ class CJBig2_Context { bool m_bInPage; bool m_bBufSpecified; int32_t m_PauseStep; - IFX_Pause* const m_pPause; + CFX_UnownedPtr<IFX_Pause> const m_pPause; FXCODEC_STATUS m_ProcessingStatus; std::vector<JBig2ArithCtx> m_gbContext; std::unique_ptr<CJBig2_ArithDecoder> m_pArithDecoder; diff --git a/core/fxcodec/jbig2/JBig2_HuffmanDecoder.h b/core/fxcodec/jbig2/JBig2_HuffmanDecoder.h index c72346ac18..c7192b74ed 100644 --- a/core/fxcodec/jbig2/JBig2_HuffmanDecoder.h +++ b/core/fxcodec/jbig2/JBig2_HuffmanDecoder.h @@ -18,7 +18,7 @@ class CJBig2_HuffmanDecoder { int decodeAValue(CJBig2_HuffmanTable* pTable, int* nResult); private: - CJBig2_BitStream* const m_pStream; + CFX_UnownedPtr<CJBig2_BitStream> const m_pStream; }; #endif // CORE_FXCODEC_JBIG2_JBIG2_HUFFMANDECODER_H_ diff --git a/core/fxcrt/xml/cxml_element.h b/core/fxcrt/xml/cxml_element.h index 2eb6caf74c..d708032adb 100644 --- a/core/fxcrt/xml/cxml_element.h +++ b/core/fxcrt/xml/cxml_element.h @@ -30,7 +30,7 @@ class CXML_Element : public CXML_Object { CFX_ByteString GetTagName(bool bQualified = false) const; CFX_ByteString GetNamespace(bool bQualified = false) const; CFX_ByteString GetNamespaceURI(const CFX_ByteString& qName) const; - const CXML_Element* GetParent() const { return m_pParent; } + const CXML_Element* GetParent() const { return m_pParent.Get(); } uint32_t CountAttrs() const { return m_AttrMap.GetSize(); } void GetAttrByIndex(int index, CFX_ByteString* space, @@ -104,7 +104,7 @@ class CXML_Element : public CXML_Object { friend class CXML_Parser; friend class CXML_Composer; - const CXML_Element* const m_pParent; + CFX_UnownedPtr<const CXML_Element> const m_pParent; CFX_ByteString m_QSpaceName; CFX_ByteString m_TagName; CXML_AttrMap m_AttrMap; diff --git a/core/fxge/cfx_fontmapper.h b/core/fxge/cfx_fontmapper.h index 96630a77df..1b262bf0f4 100644 --- a/core/fxge/cfx_fontmapper.h +++ b/core/fxge/cfx_fontmapper.h @@ -80,7 +80,7 @@ class CFX_FontMapper { std::vector<FaceData> m_FaceArray; std::unique_ptr<IFX_SystemFontInfo> m_pFontInfo; FXFT_Face m_FoxitFaces[FOXIT_FACE_COUNT]; - CFX_FontMgr* const m_pFontMgr; + CFX_UnownedPtr<CFX_FontMgr> const m_pFontMgr; }; #endif // CORE_FXGE_CFX_FONTMAPPER_H_ diff --git a/core/fxge/dib/cfx_imagestretcher.cpp b/core/fxge/dib/cfx_imagestretcher.cpp index 809b72d1fb..3c0a065868 100644 --- a/core/fxge/dib/cfx_imagestretcher.cpp +++ b/core/fxge/dib/cfx_imagestretcher.cpp @@ -133,8 +133,8 @@ bool CFX_ImageStretcher::Continue(IFX_Pause* pPause) { bool CFX_ImageStretcher::StartStretch() { m_pStretchEngine = pdfium::MakeUnique<CStretchEngine>( - m_pDest, m_DestFormat, m_DestWidth, m_DestHeight, m_ClipRect, m_pSource, - m_Flags); + m_pDest.Get(), m_DestFormat, m_DestWidth, m_DestHeight, m_ClipRect, + m_pSource, m_Flags); m_pStretchEngine->StartStretchHorz(); if (SourceSizeWithinLimit(m_pSource->GetWidth(), m_pSource->GetHeight())) { m_pStretchEngine->Continue(nullptr); diff --git a/core/fxge/dib/cfx_imagestretcher.h b/core/fxge/dib/cfx_imagestretcher.h index 63863cd1a9..45928ee141 100644 --- a/core/fxge/dib/cfx_imagestretcher.h +++ b/core/fxge/dib/cfx_imagestretcher.h @@ -37,7 +37,7 @@ class CFX_ImageStretcher { bool ContinueQuickStretch(IFX_Pause* pPause); bool ContinueStretch(IFX_Pause* pPause); - IFX_ScanlineComposer* const m_pDest; + CFX_UnownedPtr<IFX_ScanlineComposer> const m_pDest; CFX_RetainPtr<CFX_DIBSource> m_pSource; std::unique_ptr<CStretchEngine> m_pStretchEngine; std::unique_ptr<uint8_t, FxFreeDeleter> m_pScanline; diff --git a/core/fxge/dib/cfx_imagetransformer.h b/core/fxge/dib/cfx_imagetransformer.h index 52aca9792e..90f605dce9 100644 --- a/core/fxge/dib/cfx_imagetransformer.h +++ b/core/fxge/dib/cfx_imagetransformer.h @@ -33,7 +33,7 @@ class CFX_ImageTransformer { private: const CFX_RetainPtr<CFX_DIBSource> m_pSrc; - const CFX_Matrix* const m_pMatrix; + CFX_UnownedPtr<const CFX_Matrix> const m_pMatrix; const FX_RECT* const m_pClip; FX_RECT m_StretchClip; FX_RECT m_result; |