From 0a6dbeffbc61f2140b1b845f6791c1b15b34cbd7 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 26 Jun 2018 18:42:28 +0000 Subject: Add some more consts to unowned pointers. Ideally, unowned ptrs might well be const, as updating something through an unowned reference is best avoided. Change-Id: Ida8111ffe0ee1e30bbf6b7718b0929dfb5cafdff Reviewed-on: https://pdfium-review.googlesource.com/36050 Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- core/fpdfapi/edit/cpdf_creator.h | 2 +- core/fpdfapi/edit/cpdf_pagecontentmanager.cpp | 2 +- core/fpdfapi/edit/cpdf_pagecontentmanager.h | 4 ++-- core/fpdfapi/font/cpdf_cidfont.h | 2 +- core/fpdfapi/font/cpdf_tounicodemap.h | 2 +- core/fpdfapi/page/cpdf_generalstate.cpp | 3 +-- core/fpdfapi/page/cpdf_generalstate.h | 10 +++++----- core/fpdfapi/page/cpdf_image.h | 6 +++--- core/fpdfapi/page/cpdf_shadingobject.h | 2 +- core/fpdfapi/page/cpdf_shadingpattern.h | 6 +++--- core/fpdfapi/page/cpdf_streamcontentparser.cpp | 2 +- core/fpdfapi/parser/cpdf_parser.cpp | 4 ++-- core/fpdfapi/parser/cpdf_parser.h | 6 +++--- core/fpdfapi/render/cpdf_imagerenderer.cpp | 2 +- fpdfsdk/fpdf_editpage.cpp | 2 +- 15 files changed, 27 insertions(+), 28 deletions(-) diff --git a/core/fpdfapi/edit/cpdf_creator.h b/core/fpdfapi/edit/cpdf_creator.h index 079f1c2666..a7261145e9 100644 --- a/core/fpdfapi/edit/cpdf_creator.h +++ b/core/fpdfapi/edit/cpdf_creator.h @@ -77,7 +77,7 @@ class CPDF_Creator { CPDF_CryptoHandler* GetCryptoHandler(); UnownedPtr const m_pDocument; - UnownedPtr const m_pParser; + UnownedPtr const m_pParser; UnownedPtr m_pEncryptDict; fxcrt::MaybeOwned m_pSecurityHandler; UnownedPtr m_pMetadata; diff --git a/core/fpdfapi/edit/cpdf_pagecontentmanager.cpp b/core/fpdfapi/edit/cpdf_pagecontentmanager.cpp index 3ba23a88fb..b635144b36 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentmanager.cpp +++ b/core/fpdfapi/edit/cpdf_pagecontentmanager.cpp @@ -16,7 +16,7 @@ #include "core/fpdfapi/parser/cpdf_stream.h" CPDF_PageContentManager::CPDF_PageContentManager( - CPDF_PageObjectHolder* obj_holder) + const CPDF_PageObjectHolder* obj_holder) : obj_holder_(obj_holder), doc_(obj_holder_->GetDocument()) { CPDF_Dictionary* page_dict = obj_holder_->GetDict(); CPDF_Object* contents_obj = page_dict->GetObjectFor("Contents"); diff --git a/core/fpdfapi/edit/cpdf_pagecontentmanager.h b/core/fpdfapi/edit/cpdf_pagecontentmanager.h index bad8c7a38c..b49b403a75 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentmanager.h +++ b/core/fpdfapi/edit/cpdf_pagecontentmanager.h @@ -18,7 +18,7 @@ class CPDF_PageObjectHolder; class CPDF_PageContentManager { public: - explicit CPDF_PageContentManager(CPDF_PageObjectHolder* pObjHolder); + explicit CPDF_PageContentManager(const CPDF_PageObjectHolder* pObjHolder); ~CPDF_PageContentManager(); // Gets the Content stream at a given index. If Contents is a single stream @@ -39,7 +39,7 @@ class CPDF_PageContentManager { void ExecuteScheduledRemovals(); private: - UnownedPtr const obj_holder_; + UnownedPtr const obj_holder_; UnownedPtr const doc_; UnownedPtr contents_array_; UnownedPtr contents_stream_; diff --git a/core/fpdfapi/font/cpdf_cidfont.h b/core/fpdfapi/font/cpdf_cidfont.h index 7d7b33eea8..3ff60b0f67 100644 --- a/core/fpdfapi/font/cpdf_cidfont.h +++ b/core/fpdfapi/font/cpdf_cidfont.h @@ -73,7 +73,7 @@ class CPDF_CIDFont : public CPDF_Font { wchar_t GetUnicodeFromCharCode(uint32_t charcode) const; RetainPtr m_pCMap; - UnownedPtr m_pCID2UnicodeMap; + UnownedPtr m_pCID2UnicodeMap; CIDSet m_Charset; bool m_bType1; bool m_bCIDIsGID; diff --git a/core/fpdfapi/font/cpdf_tounicodemap.h b/core/fpdfapi/font/cpdf_tounicodemap.h index 8f70791f97..54984d7f3d 100644 --- a/core/fpdfapi/font/cpdf_tounicodemap.h +++ b/core/fpdfapi/font/cpdf_tounicodemap.h @@ -35,7 +35,7 @@ class CPDF_ToUnicodeMap { uint32_t GetUnicode(); std::map m_Map; - UnownedPtr m_pBaseMap; + UnownedPtr m_pBaseMap; CFX_WideTextBuf m_MultiCharBuf; }; diff --git a/core/fpdfapi/page/cpdf_generalstate.cpp b/core/fpdfapi/page/cpdf_generalstate.cpp index a5b718bfff..2657578ab7 100644 --- a/core/fpdfapi/page/cpdf_generalstate.cpp +++ b/core/fpdfapi/page/cpdf_generalstate.cpp @@ -154,7 +154,7 @@ void CPDF_GeneralState::SetSoftMask(CPDF_Object* pObject) { m_Ref.GetPrivateCopy()->m_pSoftMask = pObject; } -CPDF_Object* CPDF_GeneralState::GetTR() const { +const CPDF_Object* CPDF_GeneralState::GetTR() const { const StateData* pData = m_Ref.GetObject(); return pData ? pData->m_pTR.Get() : nullptr; } @@ -262,7 +262,6 @@ CFX_Matrix* CPDF_GeneralState::GetMutableMatrix() { CPDF_GeneralState::StateData::StateData() : m_BlendMode(pdfium::transparency::kNormal), m_BlendType(0), - m_pSoftMask(nullptr), m_StrokeAlpha(1.0), m_FillAlpha(1.0f), m_pTR(nullptr), diff --git a/core/fpdfapi/page/cpdf_generalstate.h b/core/fpdfapi/page/cpdf_generalstate.h index 5d6d5dc552..4a101b99de 100644 --- a/core/fpdfapi/page/cpdf_generalstate.h +++ b/core/fpdfapi/page/cpdf_generalstate.h @@ -40,7 +40,7 @@ class CPDF_GeneralState { CPDF_Object* GetSoftMask() const; void SetSoftMask(CPDF_Object* pObject); - CPDF_Object* GetTR() const; + const CPDF_Object* GetTR() const; void SetTR(CPDF_Object* pObject); RetainPtr GetTransferFunc() const; @@ -89,7 +89,7 @@ class CPDF_GeneralState { CFX_Matrix m_SMaskMatrix; float m_StrokeAlpha; float m_FillAlpha; - UnownedPtr m_pTR; + UnownedPtr m_pTR; RetainPtr m_pTransferFunc; CFX_Matrix m_Matrix; int m_RenderIntent; @@ -99,9 +99,9 @@ class CPDF_GeneralState { bool m_StrokeOP; bool m_FillOP; int m_OPMode; - UnownedPtr m_pBG; - UnownedPtr m_pUCR; - UnownedPtr m_pHT; + UnownedPtr m_pBG; + UnownedPtr m_pUCR; + UnownedPtr m_pHT; float m_Flatness; float m_Smoothness; }; diff --git a/core/fpdfapi/page/cpdf_image.h b/core/fpdfapi/page/cpdf_image.h index 9281a2c77d..be5883b946 100644 --- a/core/fpdfapi/page/cpdf_image.h +++ b/core/fpdfapi/page/cpdf_image.h @@ -29,9 +29,9 @@ class CPDF_Image : public Retainable { void ConvertStreamToIndirectObject(); - CPDF_Stream* GetStream() const { return m_pStream.Get(); } CPDF_Dictionary* GetDict() const; - CPDF_Dictionary* GetOC() const { return m_pOC.Get(); } + CPDF_Stream* GetStream() const { return m_pStream.Get(); } + const CPDF_Dictionary* GetOC() const { return m_pOC.Get(); } CPDF_Document* GetDocument() const { return m_pDocument.Get(); } int32_t GetPixelHeight() const { return m_Height; } @@ -82,7 +82,7 @@ class CPDF_Image : public Retainable { bool m_bInterpolate = false; UnownedPtr const m_pDocument; MaybeOwned m_pStream; - UnownedPtr m_pOC; + UnownedPtr m_pOC; }; #endif // CORE_FPDFAPI_PAGE_CPDF_IMAGE_H_ diff --git a/core/fpdfapi/page/cpdf_shadingobject.h b/core/fpdfapi/page/cpdf_shadingobject.h index 69b606749d..af88128443 100644 --- a/core/fpdfapi/page/cpdf_shadingobject.h +++ b/core/fpdfapi/page/cpdf_shadingobject.h @@ -33,7 +33,7 @@ class CPDF_ShadingObject : public CPDF_PageObject { const CFX_Matrix& matrix() const { return m_Matrix; } private: - UnownedPtr m_pShading; + UnownedPtr m_pShading; CFX_Matrix m_Matrix; }; diff --git a/core/fpdfapi/page/cpdf_shadingpattern.h b/core/fpdfapi/page/cpdf_shadingpattern.h index 3c68c818ea..d7aa1cb272 100644 --- a/core/fpdfapi/page/cpdf_shadingpattern.h +++ b/core/fpdfapi/page/cpdf_shadingpattern.h @@ -55,7 +55,7 @@ class CPDF_ShadingPattern : public CPDF_Pattern { ShadingType GetShadingType() const { return m_ShadingType; } bool IsShadingObject() const { return m_bShadingObj; } const CPDF_Object* GetShadingObject() const { return m_pShadingObj.Get(); } - CPDF_ColorSpace* GetCS() const { return m_pCS.Get(); } + const CPDF_ColorSpace* GetCS() const { return m_pCS.Get(); } const std::vector>& GetFuncs() const { return m_pFunctions; } @@ -73,9 +73,9 @@ class CPDF_ShadingPattern : public CPDF_Pattern { // Still keep |m_pCS| as some CPDF_ColorSpace (name object) are not managed // as counted objects. Refer to CPDF_DocPageData::GetColorSpace. - UnownedPtr m_pCS; + UnownedPtr m_pCS; - UnownedPtr m_pCountedCS; + UnownedPtr m_pCountedCS; std::vector> m_pFunctions; }; diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp index 9d6e86def0..8f3e70a278 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp +++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp @@ -76,7 +76,7 @@ CFX_FloatRect GetShadingBBox(CPDF_ShadingPattern* pShading, const CFX_Matrix& matrix) { ShadingType type = pShading->GetShadingType(); const CPDF_Stream* pStream = ToStream(pShading->GetShadingObject()); - CPDF_ColorSpace* pCS = pShading->GetCS(); + const CPDF_ColorSpace* pCS = pShading->GetCS(); if (!pStream || !pCS) return CFX_FloatRect(); diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp index 854d6e7f60..3a7afd0b49 100644 --- a/core/fpdfapi/parser/cpdf_parser.cpp +++ b/core/fpdfapi/parser/cpdf_parser.cpp @@ -1135,11 +1135,11 @@ std::unique_ptr CPDF_Parser::GetCombinedTrailer() const { return m_TrailerData->GetCombinedTrailer(); } -uint32_t CPDF_Parser::GetInfoObjNum() { +uint32_t CPDF_Parser::GetInfoObjNum() const { return m_TrailerData->GetInfoObjNum(); } -uint32_t CPDF_Parser::GetRootObjNum() { +uint32_t CPDF_Parser::GetRootObjNum() const { return m_TrailerData->GetRootObjNum(); } diff --git a/core/fpdfapi/parser/cpdf_parser.h b/core/fpdfapi/parser/cpdf_parser.h index b74f1d52ab..3151da61c9 100644 --- a/core/fpdfapi/parser/cpdf_parser.h +++ b/core/fpdfapi/parser/cpdf_parser.h @@ -57,7 +57,7 @@ class CPDF_Parser { CPDF_Document* pDocument); void SetPassword(const char* password) { m_Password = password; } - ByteString GetPassword() { return m_Password; } + ByteString GetPassword() const { return m_Password; } CPDF_Dictionary* GetTrailer() const; @@ -68,8 +68,8 @@ class CPDF_Parser { FX_FILESIZE GetLastXRefOffset() const { return m_LastXRefOffset; } uint32_t GetPermissions() const; - uint32_t GetRootObjNum(); - uint32_t GetInfoObjNum(); + uint32_t GetRootObjNum() const; + uint32_t GetInfoObjNum() const; const CPDF_Array* GetIDArray() const; CPDF_Dictionary* GetEncryptDict() const { return m_pEncryptDict.Get(); } diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp index a5e2e27a25..d3e7075cc2 100644 --- a/core/fpdfapi/render/cpdf_imagerenderer.cpp +++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp @@ -175,7 +175,7 @@ bool CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, m_pImageObject = pImageObject; m_BlendType = blendType; m_pObj2Device = pObj2Device; - CPDF_Dictionary* pOC = m_pImageObject->GetImage()->GetOC(); + const CPDF_Dictionary* pOC = m_pImageObject->GetImage()->GetOC(); if (pOC && m_pRenderStatus->GetRenderOptions()->GetOCContext() && !m_pRenderStatus->GetRenderOptions()->GetOCContext()->CheckOCGVisible( pOC)) { diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp index 4acb5b6cb5..2d9a2c7aa0 100644 --- a/fpdfsdk/fpdf_editpage.cpp +++ b/fpdfsdk/fpdf_editpage.cpp @@ -382,7 +382,7 @@ FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject) { if (blend_type != FXDIB_BLEND_NORMAL) return true; - CPDF_Dictionary* pSMaskDict = + const CPDF_Dictionary* pSMaskDict = ToDictionary(pPageObj->m_GeneralState.GetSoftMask()); if (pSMaskDict) return true; -- cgit v1.2.3