summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-05-22 15:15:30 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-05-22 23:44:01 +0000
commit4cb82ee95256f110489f2b503e70729c44419e74 (patch)
tree56d11efe9bd8e93af2145c02f4f3c84ea3954f55 /core
parent355954b8f09a65934b95dd6ca1299a73ae5e24b2 (diff)
downloadpdfium-4cb82ee95256f110489f2b503e70729c44419e74.tar.xz
Convert more c-style pointers to CFX_UnownedPtr
Change-Id: I551b4210c95db0b916e9fe6cddf11e6c3d015c50 Reviewed-on: https://pdfium-review.googlesource.com/5790 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp4
-rw-r--r--core/fpdfapi/font/cpdf_type3font.cpp3
-rw-r--r--core/fpdfapi/font/cpdf_type3font.h6
-rw-r--r--core/fpdfapi/page/cpdf_colorspace.h5
-rw-r--r--core/fpdfapi/page/cpdf_contentparser.cpp13
-rw-r--r--core/fpdfapi/page/cpdf_contentparser.h5
-rw-r--r--core/fpdfapi/page/cpdf_generalstate.cpp8
-rw-r--r--core/fpdfapi/page/cpdf_generalstate.h11
-rw-r--r--core/fpdfapi/page/cpdf_page.cpp2
-rw-r--r--core/fpdfapi/page/cpdf_pageobjectholder.h11
-rw-r--r--core/fpdfapi/page/cpdf_shadingpattern.cpp2
-rw-r--r--core/fpdfapi/page/cpdf_shadingpattern.h5
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.cpp14
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.h16
-rw-r--r--core/fpdfapi/render/cpdf_imagerenderer.cpp5
-rw-r--r--core/fpdfapi/render/cpdf_pagerendercache.cpp6
-rw-r--r--core/fpdfapi/render/cpdf_rendercontext.cpp4
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.cpp5
-rw-r--r--core/fpdfdoc/cpdf_annot.cpp4
-rw-r--r--core/fpdfdoc/cpdf_annotlist.cpp2
-rw-r--r--core/fpdfdoc/cpdf_interform.cpp2
21 files changed, 73 insertions, 60 deletions
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
index e431b9bf57..8238414e64 100644
--- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
+++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
@@ -49,7 +49,7 @@ bool GetColor(const CPDF_Color* pColor, float* rgb) {
} // namespace
CPDF_PageContentGenerator::CPDF_PageContentGenerator(CPDF_Page* pPage)
- : m_pPage(pPage), m_pDocument(m_pPage->m_pDocument) {
+ : m_pPage(pPage), m_pDocument(m_pPage->m_pDocument.Get()) {
for (const auto& pObj : *pPage->GetPageObjectList()) {
if (pObj)
m_pageObjects.push_back(pObj.get());
@@ -68,7 +68,7 @@ void CPDF_PageContentGenerator::GenerateContent() {
else if (CPDF_TextObject* pTextObj = pPageObj->AsText())
ProcessText(&buf, pTextObj);
}
- CPDF_Dictionary* pPageDict = m_pPage->m_pFormDict;
+ CPDF_Dictionary* pPageDict = m_pPage->m_pFormDict.Get();
CPDF_Object* pContent =
pPageDict ? pPageDict->GetDirectObjectFor("Contents") : nullptr;
if (pContent)
diff --git a/core/fpdfapi/font/cpdf_type3font.cpp b/core/fpdfapi/font/cpdf_type3font.cpp
index 79f6617ce3..1e8c567a7f 100644
--- a/core/fpdfapi/font/cpdf_type3font.cpp
+++ b/core/fpdfapi/font/cpdf_type3font.cpp
@@ -107,7 +107,8 @@ CPDF_Type3Char* CPDF_Type3Font::LoadChar(uint32_t charcode) {
auto pNewChar =
pdfium::MakeUnique<CPDF_Type3Char>(pdfium::MakeUnique<CPDF_Form>(
- m_pDocument, m_pFontResources ? m_pFontResources : m_pPageResources,
+ m_pDocument,
+ m_pFontResources ? m_pFontResources.Get() : m_pPageResources.Get(),
pStream, nullptr));
// This can trigger recursion into this method. The content of |m_CacheMap|
diff --git a/core/fpdfapi/font/cpdf_type3font.h b/core/fpdfapi/font/cpdf_type3font.h
index 0bae192d61..135a19fb7c 100644
--- a/core/fpdfapi/font/cpdf_type3font.h
+++ b/core/fpdfapi/font/cpdf_type3font.h
@@ -48,9 +48,9 @@ class CPDF_Type3Font : public CPDF_SimpleFont {
void LoadGlyphMap() override {}
int m_CharWidthL[256];
- CPDF_Dictionary* m_pCharProcs;
- CPDF_Dictionary* m_pPageResources;
- CPDF_Dictionary* m_pFontResources;
+ CFX_UnownedPtr<CPDF_Dictionary> m_pCharProcs;
+ CFX_UnownedPtr<CPDF_Dictionary> m_pPageResources;
+ CFX_UnownedPtr<CPDF_Dictionary> m_pFontResources;
std::map<uint32_t, std::unique_ptr<CPDF_Type3Char>> m_CacheMap;
// The depth char loading is in, to avoid recurive calling LoadChar().
int m_CharLoadingDepth;
diff --git a/core/fpdfapi/page/cpdf_colorspace.h b/core/fpdfapi/page/cpdf_colorspace.h
index 76072d1260..15029026c2 100644
--- a/core/fpdfapi/page/cpdf_colorspace.h
+++ b/core/fpdfapi/page/cpdf_colorspace.h
@@ -9,6 +9,7 @@
#include <memory>
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/fx_system.h"
@@ -61,7 +62,7 @@ class CPDF_ColorSpace {
int image_height,
bool bTransMask) const;
- CPDF_Array*& GetArray() { return m_pArray; }
+ CPDF_Array* GetArray() const { return m_pArray.Get(); }
virtual CPDF_ColorSpace* GetBaseCS() const;
virtual void EnableStdConversion(bool bEnabled);
@@ -82,7 +83,7 @@ class CPDF_ColorSpace {
int m_Family;
uint32_t m_nComponents;
- CPDF_Array* m_pArray;
+ CFX_UnownedPtr<CPDF_Array> m_pArray;
uint32_t m_dwStdConversion;
};
diff --git a/core/fpdfapi/page/cpdf_contentparser.cpp b/core/fpdfapi/page/cpdf_contentparser.cpp
index eeac3c17b1..4f4036f078 100644
--- a/core/fpdfapi/page/cpdf_contentparser.cpp
+++ b/core/fpdfapi/page/cpdf_contentparser.cpp
@@ -98,8 +98,9 @@ void CPDF_ContentParser::Start(CPDF_Form* pForm,
CPDF_Dictionary* pResources = pForm->m_pFormDict->GetDictFor("Resources");
m_pParser = pdfium::MakeUnique<CPDF_StreamContentParser>(
- pForm->m_pDocument, pForm->m_pPageResources, pForm->m_pResources,
- pParentMatrix, pForm, pResources, &form_bbox, pGraphicStates, level);
+ pForm->m_pDocument.Get(), pForm->m_pPageResources.Get(),
+ pForm->m_pResources.Get(), pParentMatrix, pForm, pResources, &form_bbox,
+ pGraphicStates, level);
m_pParser->GetCurStates()->m_CTM = form_matrix;
m_pParser->GetCurStates()->m_ParentMatrix = form_matrix;
if (ClipPath.HasRef()) {
@@ -114,7 +115,8 @@ void CPDF_ContentParser::Start(CPDF_Form* pForm,
pState->SetSoftMask(nullptr);
}
m_nStreams = 0;
- m_pSingleStream = pdfium::MakeRetain<CPDF_StreamAcc>(pForm->m_pFormStream);
+ m_pSingleStream =
+ pdfium::MakeRetain<CPDF_StreamAcc>(pForm->m_pFormStream.Get());
m_pSingleStream->LoadAllData(false);
m_pData = (uint8_t*)m_pSingleStream->GetData();
m_Size = m_pSingleStream->GetSize();
@@ -167,8 +169,9 @@ void CPDF_ContentParser::Continue(IFX_Pause* pPause) {
if (m_InternalStage == STAGE_PARSE) {
if (!m_pParser) {
m_pParser = pdfium::MakeUnique<CPDF_StreamContentParser>(
- m_pObjectHolder->m_pDocument, m_pObjectHolder->m_pPageResources,
- nullptr, nullptr, m_pObjectHolder, m_pObjectHolder->m_pResources,
+ m_pObjectHolder->m_pDocument.Get(),
+ m_pObjectHolder->m_pPageResources.Get(), nullptr, nullptr,
+ m_pObjectHolder.Get(), m_pObjectHolder->m_pResources.Get(),
&m_pObjectHolder->m_BBox, nullptr, 0);
m_pParser->GetCurStates()->m_ColorState.SetDefault();
}
diff --git a/core/fpdfapi/page/cpdf_contentparser.h b/core/fpdfapi/page/cpdf_contentparser.h
index 402fd2fdd0..58a977301f 100644
--- a/core/fpdfapi/page/cpdf_contentparser.h
+++ b/core/fpdfapi/page/cpdf_contentparser.h
@@ -13,6 +13,7 @@
#include "core/fpdfapi/page/cpdf_pageobjectholder.h"
#include "core/fpdfapi/page/cpdf_streamcontentparser.h"
#include "core/fpdfapi/parser/cpdf_stream_acc.h"
+#include "core/fxcrt/cfx_unowned_ptr.h"
class CPDF_AllStates;
class CPDF_Form;
@@ -45,9 +46,9 @@ class CPDF_ContentParser {
ParseStatus m_Status;
InternalStage m_InternalStage;
- CPDF_PageObjectHolder* m_pObjectHolder;
+ CFX_UnownedPtr<CPDF_PageObjectHolder> m_pObjectHolder;
bool m_bForm;
- CPDF_Type3Char* m_pType3Char;
+ CFX_UnownedPtr<CPDF_Type3Char> m_pType3Char;
uint32_t m_nStreams;
CFX_RetainPtr<CPDF_StreamAcc> m_pSingleStream;
std::vector<CFX_RetainPtr<CPDF_StreamAcc>> m_StreamArray;
diff --git a/core/fpdfapi/page/cpdf_generalstate.cpp b/core/fpdfapi/page/cpdf_generalstate.cpp
index 513e5ff7a5..e07a3ca13d 100644
--- a/core/fpdfapi/page/cpdf_generalstate.cpp
+++ b/core/fpdfapi/page/cpdf_generalstate.cpp
@@ -108,7 +108,7 @@ void CPDF_GeneralState::SetStrokeAlpha(float alpha) {
CPDF_Object* CPDF_GeneralState::GetSoftMask() const {
const StateData* pData = m_Ref.GetObject();
- return pData ? pData->m_pSoftMask : nullptr;
+ return pData ? pData->m_pSoftMask.Get() : nullptr;
}
void CPDF_GeneralState::SetSoftMask(CPDF_Object* pObject) {
@@ -117,7 +117,7 @@ void CPDF_GeneralState::SetSoftMask(CPDF_Object* pObject) {
CPDF_Object* CPDF_GeneralState::GetTR() const {
const StateData* pData = m_Ref.GetObject();
- return pData ? pData->m_pTR : nullptr;
+ return pData ? pData->m_pTR.Get() : nullptr;
}
void CPDF_GeneralState::SetTR(CPDF_Object* pObject) {
@@ -271,7 +271,7 @@ CPDF_GeneralState::StateData::StateData(const StateData& that)
CPDF_DocRenderData* pDocCache =
that.m_pTransferFunc->m_pPDFDoc->GetRenderData();
if (pDocCache)
- m_pTransferFunc = pDocCache->GetTransferFunc(m_pTR);
+ m_pTransferFunc = pDocCache->GetTransferFunc(m_pTR.Get());
}
}
@@ -280,7 +280,7 @@ CPDF_GeneralState::StateData::~StateData() {
CPDF_DocRenderData* pDocCache = m_pTransferFunc->m_pPDFDoc->GetRenderData();
if (pDocCache) {
m_pTransferFunc.Reset(); // Give up our reference first.
- pDocCache->MaybePurgeTransferFunc(m_pTR);
+ pDocCache->MaybePurgeTransferFunc(m_pTR.Get());
}
}
}
diff --git a/core/fpdfapi/page/cpdf_generalstate.h b/core/fpdfapi/page/cpdf_generalstate.h
index 9305785256..4ec08ca9c5 100644
--- a/core/fpdfapi/page/cpdf_generalstate.h
+++ b/core/fpdfapi/page/cpdf_generalstate.h
@@ -8,6 +8,7 @@
#define CORE_FPDFAPI_PAGE_CPDF_GENERALSTATE_H_
#include "core/fxcrt/cfx_shared_copy_on_write.h"
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_basic.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxge/fx_dib.h"
@@ -83,11 +84,11 @@ class CPDF_GeneralState {
CFX_ByteString m_BlendMode;
int m_BlendType;
- CPDF_Object* m_pSoftMask;
+ CFX_UnownedPtr<CPDF_Object> m_pSoftMask;
CFX_Matrix m_SMaskMatrix;
float m_StrokeAlpha;
float m_FillAlpha;
- CPDF_Object* m_pTR;
+ CFX_UnownedPtr<CPDF_Object> m_pTR;
CFX_RetainPtr<CPDF_TransferFunc> m_pTransferFunc;
CFX_Matrix m_Matrix;
int m_RenderIntent;
@@ -97,9 +98,9 @@ class CPDF_GeneralState {
bool m_StrokeOP;
bool m_FillOP;
int m_OPMode;
- CPDF_Object* m_pBG;
- CPDF_Object* m_pUCR;
- CPDF_Object* m_pHT;
+ CFX_UnownedPtr<CPDF_Object> m_pBG;
+ CFX_UnownedPtr<CPDF_Object> m_pUCR;
+ CFX_UnownedPtr<CPDF_Object> m_pHT;
float m_Flatness;
float m_Smoothness;
};
diff --git a/core/fpdfapi/page/cpdf_page.cpp b/core/fpdfapi/page/cpdf_page.cpp
index 5ea575e307..d528d3da0b 100644
--- a/core/fpdfapi/page/cpdf_page.cpp
+++ b/core/fpdfapi/page/cpdf_page.cpp
@@ -103,7 +103,7 @@ void CPDF_Page::SetRenderContext(
}
CPDF_Object* CPDF_Page::GetPageAttr(const CFX_ByteString& name) const {
- CPDF_Dictionary* pPageDict = m_pFormDict;
+ CPDF_Dictionary* pPageDict = m_pFormDict.Get();
std::set<CPDF_Dictionary*> visited;
while (1) {
visited.insert(pPageDict);
diff --git a/core/fpdfapi/page/cpdf_pageobjectholder.h b/core/fpdfapi/page/cpdf_pageobjectholder.h
index f5b60fff9d..c95ae50520 100644
--- a/core/fpdfapi/page/cpdf_pageobjectholder.h
+++ b/core/fpdfapi/page/cpdf_pageobjectholder.h
@@ -11,6 +11,7 @@
#include <vector>
#include "core/fpdfapi/page/cpdf_pageobjectlist.h"
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_system.h"
@@ -50,11 +51,11 @@ class CPDF_PageObjectHolder {
void Transform(const CFX_Matrix& matrix);
CFX_FloatRect CalcBoundingBox() const;
- CPDF_Dictionary* m_pFormDict;
- CPDF_Stream* m_pFormStream;
- CPDF_Document* m_pDocument;
- CPDF_Dictionary* m_pPageResources;
- CPDF_Dictionary* m_pResources;
+ CFX_UnownedPtr<CPDF_Dictionary> m_pFormDict;
+ CFX_UnownedPtr<CPDF_Stream> m_pFormStream;
+ CFX_UnownedPtr<CPDF_Document> m_pDocument;
+ CFX_UnownedPtr<CPDF_Dictionary> m_pPageResources;
+ CFX_UnownedPtr<CPDF_Dictionary> m_pResources;
CFX_FloatRect m_BBox;
int m_Transparency;
diff --git a/core/fpdfapi/page/cpdf_shadingpattern.cpp b/core/fpdfapi/page/cpdf_shadingpattern.cpp
index dae5ec356c..80eea63f9c 100644
--- a/core/fpdfapi/page/cpdf_shadingpattern.cpp
+++ b/core/fpdfapi/page/cpdf_shadingpattern.cpp
@@ -93,7 +93,7 @@ bool CPDF_ShadingPattern::Load() {
m_ShadingType = ToShadingType(pShadingDict->GetIntegerFor("ShadingType"));
// We expect to have a stream if our shading type is a mesh.
- if (IsMeshShading() && !ToStream(m_pShadingObj))
+ if (IsMeshShading() && !ToStream(m_pShadingObj.Get()))
return false;
return true;
diff --git a/core/fpdfapi/page/cpdf_shadingpattern.h b/core/fpdfapi/page/cpdf_shadingpattern.h
index 136153d4a0..c2d55cc3d5 100644
--- a/core/fpdfapi/page/cpdf_shadingpattern.h
+++ b/core/fpdfapi/page/cpdf_shadingpattern.h
@@ -12,6 +12,7 @@
#include "core/fpdfapi/page/cpdf_countedobject.h"
#include "core/fpdfapi/page/cpdf_pattern.h"
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_system.h"
enum ShadingType {
@@ -53,7 +54,7 @@ class CPDF_ShadingPattern : public CPDF_Pattern {
ShadingType GetShadingType() const { return m_ShadingType; }
bool IsShadingObject() const { return m_bShadingObj; }
- CPDF_Object* GetShadingObject() const { return m_pShadingObj; }
+ CPDF_Object* GetShadingObject() const { return m_pShadingObj.Get(); }
CPDF_ColorSpace* GetCS() const { return m_pCS; }
const std::vector<std::unique_ptr<CPDF_Function>>& GetFuncs() const {
return m_pFunctions;
@@ -62,7 +63,7 @@ class CPDF_ShadingPattern : public CPDF_Pattern {
private:
ShadingType m_ShadingType;
bool m_bShadingObj;
- CPDF_Object* m_pShadingObj;
+ CFX_UnownedPtr<CPDF_Object> m_pShadingObj;
// Still keep |m_pCS| as some CPDF_ColorSpace (name object) are not managed
// as counted objects. Refer to CPDF_DocPageData::GetColorSpace.
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 099ddf6b05..a5af1dbee0 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -633,7 +633,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() {
if (!key.IsEmpty()) {
uint32_t dwObjNum = pObj ? pObj->GetObjNum() : 0;
if (dwObjNum)
- pDict->SetNewFor<CPDF_Reference>(key, m_pDocument, dwObjNum);
+ pDict->SetNewFor<CPDF_Reference>(key, m_pDocument.Get(), dwObjNum);
else
pDict->SetFor(key, std::move(pObj));
}
@@ -653,7 +653,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() {
}
pDict->SetNewFor<CPDF_Name>("Subtype", "Image");
std::unique_ptr<CPDF_Stream> pStream =
- m_pSyntax->ReadInlineStream(m_pDocument, std::move(pDict), pCSObj);
+ m_pSyntax->ReadInlineStream(m_pDocument.Get(), std::move(pDict), pCSObj);
while (1) {
CPDF_StreamParser::SyntaxType type = m_pSyntax->ParseNextElement();
if (type == CPDF_StreamParser::EndOfData) {
@@ -771,7 +771,7 @@ void CPDF_StreamContentParser::Handle_ExecuteXObject() {
void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream) {
auto pFormObj = pdfium::MakeUnique<CPDF_FormObject>();
pFormObj->m_pForm = pdfium::MakeUnique<CPDF_Form>(
- m_pDocument, m_pPageResources, pStream, m_pResources);
+ m_pDocument.Get(), m_pPageResources.Get(), pStream, m_pResources.Get());
pFormObj->m_FormMatrix = m_pCurStates->m_CTM;
pFormObj->m_FormMatrix.Concat(m_mtContentToUser);
CPDF_AllStates status;
@@ -796,7 +796,7 @@ CPDF_ImageObject* CPDF_StreamContentParser::AddImage(
auto pImageObj = pdfium::MakeUnique<CPDF_ImageObject>();
pImageObj->SetImage(
- pdfium::MakeRetain<CPDF_Image>(m_pDocument, std::move(pStream)));
+ pdfium::MakeRetain<CPDF_Image>(m_pDocument.Get(), std::move(pStream)));
return AddImageObject(std::move(pImageObj));
}
@@ -1176,12 +1176,12 @@ CPDF_Font* CPDF_StreamContentParser::FindFont(const CFX_ByteString& name) {
CPDF_Dictionary* pFontDict = ToDictionary(FindResourceObj("Font", name));
if (!pFontDict) {
m_bResourceMissing = true;
- return CPDF_Font::GetStockFont(m_pDocument, "Helvetica");
+ return CPDF_Font::GetStockFont(m_pDocument.Get(), "Helvetica");
}
CPDF_Font* pFont = m_pDocument->LoadFont(pFontDict);
if (pFont && pFont->IsType3Font()) {
- pFont->AsType3Font()->SetPageResources(m_pResources);
+ pFont->AsType3Font()->SetPageResources(m_pResources.Get());
pFont->AsType3Font()->CheckType3FontMetrics();
}
return pFont;
@@ -1255,7 +1255,7 @@ void CPDF_StreamContentParser::AddTextObject(CFX_ByteString* pStrs,
{
auto pText = pdfium::MakeUnique<CPDF_TextObject>();
m_pLastTextObject = pText.get();
- SetGraphicStates(m_pLastTextObject, true, true, true);
+ SetGraphicStates(m_pLastTextObject.Get(), true, true, true);
if (TextRenderingModeIsStrokeMode(text_mode)) {
float* pCTM = pText->m_TextState.GetMutableCTM();
pCTM[0] = m_pCurStates->m_CTM.a;
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.h b/core/fpdfapi/page/cpdf_streamcontentparser.h
index 50eb0eb63a..5436f8f8c6 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.h
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.h
@@ -43,7 +43,9 @@ class CPDF_StreamContentParser {
~CPDF_StreamContentParser();
uint32_t Parse(const uint8_t* pData, uint32_t dwSize, uint32_t max_cost);
- CPDF_PageObjectHolder* GetPageObjectHolder() const { return m_pObjectHolder; }
+ CPDF_PageObjectHolder* GetPageObjectHolder() const {
+ return m_pObjectHolder.Get();
+ }
CPDF_AllStates* GetCurStates() const { return m_pCurStates.get(); }
bool IsColored() const { return m_bColored; }
const float* GetType3Data() const { return m_Type3Data; }
@@ -186,11 +188,11 @@ class CPDF_StreamContentParser {
void Handle_NextLineShowText_Space();
void Handle_Invalid();
- CPDF_Document* const m_pDocument;
- CPDF_Dictionary* m_pPageResources;
- CPDF_Dictionary* m_pParentResources;
- CPDF_Dictionary* m_pResources;
- CPDF_PageObjectHolder* m_pObjectHolder;
+ CFX_UnownedPtr<CPDF_Document> const m_pDocument;
+ CFX_UnownedPtr<CPDF_Dictionary> m_pPageResources;
+ CFX_UnownedPtr<CPDF_Dictionary> m_pParentResources;
+ CFX_UnownedPtr<CPDF_Dictionary> m_pResources;
+ CFX_UnownedPtr<CPDF_PageObjectHolder> m_pObjectHolder;
int m_Level;
CFX_Matrix m_mtContentToUser;
CFX_FloatRect m_BBox;
@@ -201,7 +203,7 @@ class CPDF_StreamContentParser {
std::unique_ptr<CPDF_AllStates> m_pCurStates;
CPDF_ContentMark m_CurContentMark;
std::vector<std::unique_ptr<CPDF_TextObject>> m_ClipTextList;
- CPDF_TextObject* m_pLastTextObject;
+ CFX_UnownedPtr<CPDF_TextObject> m_pLastTextObject;
float m_DefFontSize;
std::vector<FX_PATHPOINT> m_PathPoints;
float m_PathStartX;
diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp
index 22eb32b4e9..70371d847b 100644
--- a/core/fpdfapi/render/cpdf_imagerenderer.cpp
+++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp
@@ -138,11 +138,12 @@ bool CPDF_ImageRenderer::StartRenderDIBSource() {
CPDF_Page* pPage = nullptr;
if (auto* pPageCache = m_pRenderStatus->m_pContext->GetPageCache()) {
pPage = pPageCache->GetPage();
- pDocument = pPage->m_pDocument;
+ pDocument = pPage->m_pDocument.Get();
} else {
pDocument = m_pImageObject->GetImage()->GetDocument();
}
- CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : nullptr;
+ CPDF_Dictionary* pPageResources =
+ pPage ? pPage->m_pPageResources.Get() : nullptr;
CPDF_Object* pCSObj =
m_pImageObject->GetImage()->GetStream()->GetDict()->GetDirectObjectFor(
"ColorSpace");
diff --git a/core/fpdfapi/render/cpdf_pagerendercache.cpp b/core/fpdfapi/render/cpdf_pagerendercache.cpp
index fa23355154..cc1f267f14 100644
--- a/core/fpdfapi/render/cpdf_pagerendercache.cpp
+++ b/core/fpdfapi/render/cpdf_pagerendercache.cpp
@@ -88,10 +88,10 @@ bool CPDF_PageRenderCache::StartGetCachedBitmap(
m_pCurImageCacheEntry = it->second;
} else {
m_pCurImageCacheEntry =
- new CPDF_ImageCacheEntry(m_pPage->m_pDocument, pStream);
+ new CPDF_ImageCacheEntry(m_pPage->m_pDocument.Get(), pStream);
}
int ret = m_pCurImageCacheEntry->StartGetCachedBitmap(
- pRenderStatus->m_pFormResource, m_pPage->m_pPageResources, bStdCS,
+ pRenderStatus->m_pFormResource, m_pPage->m_pPageResources.Get(), bStdCS,
GroupFamily, bLoadMask, pRenderStatus);
if (ret == 2)
return true;
@@ -129,7 +129,7 @@ void CPDF_PageRenderCache::ResetBitmap(
if (!pBitmap)
return;
- pEntry = new CPDF_ImageCacheEntry(m_pPage->m_pDocument, pStream);
+ pEntry = new CPDF_ImageCacheEntry(m_pPage->m_pDocument.Get(), pStream);
m_ImageCache[pStream] = pEntry;
} else {
pEntry = it->second;
diff --git a/core/fpdfapi/render/cpdf_rendercontext.cpp b/core/fpdfapi/render/cpdf_rendercontext.cpp
index c8626af9ff..2cd59cac18 100644
--- a/core/fpdfapi/render/cpdf_rendercontext.cpp
+++ b/core/fpdfapi/render/cpdf_rendercontext.cpp
@@ -20,8 +20,8 @@
#include "core/fxge/fx_dib.h"
CPDF_RenderContext::CPDF_RenderContext(CPDF_Page* pPage)
- : m_pDocument(pPage->m_pDocument),
- m_pPageResources(pPage->m_pPageResources),
+ : m_pDocument(pPage->m_pDocument.Get()),
+ m_pPageResources(pPage->m_pPageResources.Get()),
m_pPageCache(pPage->GetRenderCache()) {}
CPDF_RenderContext::CPDF_RenderContext(CPDF_Document* pDoc,
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index d485d1dede..e6b01eff3b 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -1487,11 +1487,12 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj,
CPDF_Page* pPage = nullptr;
if (m_pContext->GetPageCache()) {
pPage = m_pContext->GetPageCache()->GetPage();
- pDocument = pPage->m_pDocument;
+ pDocument = pPage->m_pDocument.Get();
} else {
pDocument = pPageObj->AsImage()->GetImage()->GetDocument();
}
- CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : nullptr;
+ CPDF_Dictionary* pPageResources =
+ pPage ? pPage->m_pPageResources.Get() : nullptr;
CPDF_Object* pCSObj = pPageObj->AsImage()
->GetImage()
->GetStream()
diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp
index a3ee70ab36..146c863cf3 100644
--- a/core/fpdfdoc/cpdf_annot.cpp
+++ b/core/fpdfdoc/cpdf_annot.cpp
@@ -204,8 +204,8 @@ CPDF_Form* CPDF_Annot::GetAPForm(const CPDF_Page* pPage, AppearanceMode mode) {
if (it != m_APMap.end())
return it->second.get();
- auto pNewForm =
- pdfium::MakeUnique<CPDF_Form>(m_pDocument, pPage->m_pResources, pStream);
+ auto pNewForm = pdfium::MakeUnique<CPDF_Form>(
+ m_pDocument, pPage->m_pResources.Get(), pStream);
pNewForm->ParseContent(nullptr, nullptr, nullptr);
CPDF_Form* pResult = pNewForm.get();
diff --git a/core/fpdfdoc/cpdf_annotlist.cpp b/core/fpdfdoc/cpdf_annotlist.cpp
index ed1b60c287..1427c85616 100644
--- a/core/fpdfdoc/cpdf_annotlist.cpp
+++ b/core/fpdfdoc/cpdf_annotlist.cpp
@@ -62,7 +62,7 @@ std::unique_ptr<CPDF_Annot> CreatePopupAnnot(CPDF_Annot* pAnnot,
} // namespace
CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage)
- : m_pDocument(pPage->m_pDocument) {
+ : m_pDocument(pPage->m_pDocument.Get()) {
if (!pPage->m_pFormDict)
return;
diff --git a/core/fpdfdoc/cpdf_interform.cpp b/core/fpdfdoc/cpdf_interform.cpp
index 88787d2e5b..21e2244703 100644
--- a/core/fpdfdoc/cpdf_interform.cpp
+++ b/core/fpdfdoc/cpdf_interform.cpp
@@ -1048,7 +1048,7 @@ bool CPDF_InterForm::HasXFAForm() const {
}
void CPDF_InterForm::FixPageFields(const CPDF_Page* pPage) {
- CPDF_Dictionary* pPageDict = pPage->m_pFormDict;
+ CPDF_Dictionary* pPageDict = pPage->m_pFormDict.Get();
if (!pPageDict)
return;