diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-06-26 18:42:28 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-06-26 18:42:28 +0000 |
commit | 0a6dbeffbc61f2140b1b845f6791c1b15b34cbd7 (patch) | |
tree | 7f17e935721f2e9752d2b80fe4cdcbb4f8eb79ba /core | |
parent | 785da23f6cce8004b8e7759345abd877dab953ea (diff) | |
download | pdfium-0a6dbeffbc61f2140b1b845f6791c1b15b34cbd7.tar.xz |
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 <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/fpdfapi/edit/cpdf_creator.h | 2 | ||||
-rw-r--r-- | core/fpdfapi/edit/cpdf_pagecontentmanager.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/edit/cpdf_pagecontentmanager.h | 4 | ||||
-rw-r--r-- | core/fpdfapi/font/cpdf_cidfont.h | 2 | ||||
-rw-r--r-- | core/fpdfapi/font/cpdf_tounicodemap.h | 2 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_generalstate.cpp | 3 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_generalstate.h | 10 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_image.h | 6 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_shadingobject.h | 2 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_shadingpattern.h | 6 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_streamcontentparser.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_parser.cpp | 4 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_parser.h | 6 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_imagerenderer.cpp | 2 |
14 files changed, 26 insertions, 27 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<CPDF_Document> const m_pDocument; - UnownedPtr<CPDF_Parser> const m_pParser; + UnownedPtr<const CPDF_Parser> const m_pParser; UnownedPtr<CPDF_Dictionary> m_pEncryptDict; fxcrt::MaybeOwned<CPDF_SecurityHandler> m_pSecurityHandler; UnownedPtr<const CPDF_Object> 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<CPDF_PageObjectHolder> const obj_holder_; + UnownedPtr<const CPDF_PageObjectHolder> const obj_holder_; UnownedPtr<CPDF_Document> const doc_; UnownedPtr<CPDF_Array> contents_array_; UnownedPtr<CPDF_Stream> 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<CPDF_CMap> m_pCMap; - UnownedPtr<CPDF_CID2UnicodeMap> m_pCID2UnicodeMap; + UnownedPtr<const CPDF_CID2UnicodeMap> 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<uint32_t, uint32_t> m_Map; - UnownedPtr<CPDF_CID2UnicodeMap> m_pBaseMap; + UnownedPtr<const CPDF_CID2UnicodeMap> 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<CPDF_TransferFunc> GetTransferFunc() const; @@ -89,7 +89,7 @@ class CPDF_GeneralState { CFX_Matrix m_SMaskMatrix; float m_StrokeAlpha; float m_FillAlpha; - UnownedPtr<CPDF_Object> m_pTR; + UnownedPtr<const CPDF_Object> m_pTR; RetainPtr<CPDF_TransferFunc> 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<CPDF_Object> m_pBG; - UnownedPtr<CPDF_Object> m_pUCR; - UnownedPtr<CPDF_Object> m_pHT; + UnownedPtr<const CPDF_Object> m_pBG; + UnownedPtr<const CPDF_Object> m_pUCR; + UnownedPtr<const CPDF_Object> 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<CPDF_Document> const m_pDocument; MaybeOwned<CPDF_Stream> m_pStream; - UnownedPtr<CPDF_Dictionary> m_pOC; + UnownedPtr<const CPDF_Dictionary> 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<CPDF_ShadingPattern> m_pShading; + UnownedPtr<const CPDF_ShadingPattern> 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<std::unique_ptr<CPDF_Function>>& 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<CPDF_ColorSpace> m_pCS; + UnownedPtr<const CPDF_ColorSpace> m_pCS; - UnownedPtr<CPDF_CountedColorSpace> m_pCountedCS; + UnownedPtr<const CPDF_CountedColorSpace> m_pCountedCS; std::vector<std::unique_ptr<CPDF_Function>> 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_Dictionary> 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)) { |