diff options
author | Lei Zhang <thestig@chromium.org> | 2018-05-25 16:24:48 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-05-25 16:24:48 +0000 |
commit | 710fa99b0bd26e6761c4481b4b9b6d26d2954c3e (patch) | |
tree | 0c744f3485faa3a91779286dd0f5ef9c0ac26337 /core/fpdfapi/page | |
parent | cbf1550e48e300142a53f635daba3c1d8910add9 (diff) | |
download | pdfium-710fa99b0bd26e6761c4481b4b9b6d26d2954c3e.tar.xz |
Mark CPDF_Object pointers in pattern code as const.
Change-Id: Id7bf252ebe25c92d26065d1138a445ebb2f78d0b
Reviewed-on: https://pdfium-review.googlesource.com/32187
Reviewed-by: dsinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'core/fpdfapi/page')
-rw-r--r-- | core/fpdfapi/page/cpdf_docpagedata.cpp | 6 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_docpagedata.h | 5 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_pattern.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_pattern.h | 3 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_shadingpattern.cpp | 6 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_shadingpattern.h | 4 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_streamcontentparser.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_tilingpattern.cpp | 2 |
8 files changed, 16 insertions, 14 deletions
diff --git a/core/fpdfapi/page/cpdf_docpagedata.cpp b/core/fpdfapi/page/cpdf_docpagedata.cpp index 79e148c72a..92dca138cf 100644 --- a/core/fpdfapi/page/cpdf_docpagedata.cpp +++ b/core/fpdfapi/page/cpdf_docpagedata.cpp @@ -457,13 +457,13 @@ void CPDF_DocPageData::MaybePurgeIccProfile(const CPDF_Stream* pProfileStream) { } RetainPtr<CPDF_StreamAcc> CPDF_DocPageData::GetFontFileStreamAcc( - CPDF_Stream* pFontStream) { + const CPDF_Stream* pFontStream) { ASSERT(pFontStream); auto it = m_FontFileMap.find(pFontStream); if (it != m_FontFileMap.end()) return it->second; - CPDF_Dictionary* pFontDict = pFontStream->GetDict(); + const CPDF_Dictionary* pFontDict = pFontStream->GetDict(); int32_t org_size = pFontDict->GetIntegerFor("Length1") + pFontDict->GetIntegerFor("Length2") + pFontDict->GetIntegerFor("Length3"); @@ -495,7 +495,7 @@ CPDF_CountedColorSpace* CPDF_DocPageData::FindColorSpacePtr( } CPDF_CountedPattern* CPDF_DocPageData::FindPatternPtr( - CPDF_Object* pPatternObj) const { + const CPDF_Object* pPatternObj) const { if (!pPatternObj) return nullptr; diff --git a/core/fpdfapi/page/cpdf_docpagedata.h b/core/fpdfapi/page/cpdf_docpagedata.h index 04b77cf3ed..41a5cd68be 100644 --- a/core/fpdfapi/page/cpdf_docpagedata.h +++ b/core/fpdfapi/page/cpdf_docpagedata.h @@ -64,11 +64,12 @@ class CPDF_DocPageData { RetainPtr<CPDF_IccProfile> GetIccProfile(const CPDF_Stream* pProfileStream); void MaybePurgeIccProfile(const CPDF_Stream* pProfileStream); - RetainPtr<CPDF_StreamAcc> GetFontFileStreamAcc(CPDF_Stream* pFontStream); + RetainPtr<CPDF_StreamAcc> GetFontFileStreamAcc( + const CPDF_Stream* pFontStream); void MaybePurgeFontFileStreamAcc(const CPDF_Stream* pFontStream); CPDF_CountedColorSpace* FindColorSpacePtr(const CPDF_Object* pCSObj) const; - CPDF_CountedPattern* FindPatternPtr(CPDF_Object* pPatternObj) const; + CPDF_CountedPattern* FindPatternPtr(const CPDF_Object* pPatternObj) const; private: using CPDF_CountedFont = CPDF_CountedObject<CPDF_Font>; diff --git a/core/fpdfapi/page/cpdf_pattern.cpp b/core/fpdfapi/page/cpdf_pattern.cpp index 88e5dee35c..e2dc4f4f77 100644 --- a/core/fpdfapi/page/cpdf_pattern.cpp +++ b/core/fpdfapi/page/cpdf_pattern.cpp @@ -16,7 +16,7 @@ CPDF_Pattern::CPDF_Pattern(CPDF_Document* pDoc, CPDF_Pattern::~CPDF_Pattern() {} void CPDF_Pattern::SetPatternToFormMatrix() { - CPDF_Dictionary* pDict = pattern_obj()->GetDict(); + const CPDF_Dictionary* pDict = pattern_obj()->GetDict(); m_Pattern2Form = pDict->GetMatrixFor("Matrix"); m_Pattern2Form.Concat(m_ParentMatrix); } diff --git a/core/fpdfapi/page/cpdf_pattern.h b/core/fpdfapi/page/cpdf_pattern.h index 307c677775..f1d98922c7 100644 --- a/core/fpdfapi/page/cpdf_pattern.h +++ b/core/fpdfapi/page/cpdf_pattern.h @@ -28,7 +28,8 @@ class CPDF_Pattern { // All the getters that return pointers return non-NULL pointers. CPDF_Document* document() const { return m_pDocument.Get(); } - CPDF_Object* pattern_obj() const { return m_pPatternObj.Get(); } + CPDF_Object* pattern_obj() { return m_pPatternObj.Get(); } + const CPDF_Object* pattern_obj() const { return m_pPatternObj.Get(); } CFX_Matrix* pattern_to_form() { return &m_Pattern2Form; } const CFX_Matrix& parent_matrix() const { return m_ParentMatrix; } diff --git a/core/fpdfapi/page/cpdf_shadingpattern.cpp b/core/fpdfapi/page/cpdf_shadingpattern.cpp index 76f201f767..52f4e1e10a 100644 --- a/core/fpdfapi/page/cpdf_shadingpattern.cpp +++ b/core/fpdfapi/page/cpdf_shadingpattern.cpp @@ -63,15 +63,15 @@ bool CPDF_ShadingPattern::Load() { if (m_ShadingType != kInvalidShading) return true; - CPDF_Dictionary* pShadingDict = + const CPDF_Dictionary* pShadingDict = m_pShadingObj ? m_pShadingObj->GetDict() : nullptr; if (!pShadingDict) return false; m_pFunctions.clear(); - CPDF_Object* pFunc = pShadingDict->GetDirectObjectFor("Function"); + const CPDF_Object* pFunc = pShadingDict->GetDirectObjectFor("Function"); if (pFunc) { - if (CPDF_Array* pArray = pFunc->AsArray()) { + if (const CPDF_Array* pArray = pFunc->AsArray()) { m_pFunctions.resize(std::min<size_t>(pArray->GetCount(), 4)); for (size_t i = 0; i < m_pFunctions.size(); ++i) m_pFunctions[i] = CPDF_Function::Load(pArray->GetDirectObjectAt(i)); diff --git a/core/fpdfapi/page/cpdf_shadingpattern.h b/core/fpdfapi/page/cpdf_shadingpattern.h index bb633f9a4d..3c68c818ea 100644 --- a/core/fpdfapi/page/cpdf_shadingpattern.h +++ b/core/fpdfapi/page/cpdf_shadingpattern.h @@ -54,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.Get(); } + const CPDF_Object* GetShadingObject() const { return m_pShadingObj.Get(); } CPDF_ColorSpace* GetCS() const { return m_pCS.Get(); } const std::vector<std::unique_ptr<CPDF_Function>>& GetFuncs() const { return m_pFunctions; @@ -69,7 +69,7 @@ class CPDF_ShadingPattern : public CPDF_Pattern { ShadingType m_ShadingType = kInvalidShading; const bool m_bShadingObj; - UnownedPtr<CPDF_Object> m_pShadingObj; + UnownedPtr<const 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 5f4bdf794d..9dd66f673b 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp +++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp @@ -75,7 +75,7 @@ class CPDF_StreamParserAutoClearer { CFX_FloatRect GetShadingBBox(CPDF_ShadingPattern* pShading, const CFX_Matrix& matrix) { ShadingType type = pShading->GetShadingType(); - CPDF_Stream* pStream = ToStream(pShading->GetShadingObject()); + const CPDF_Stream* pStream = ToStream(pShading->GetShadingObject()); CPDF_ColorSpace* pCS = pShading->GetCS(); if (!pStream || !pCS) return CFX_FloatRect(); diff --git a/core/fpdfapi/page/cpdf_tilingpattern.cpp b/core/fpdfapi/page/cpdf_tilingpattern.cpp index 5a71baaf7b..3cbfa07fa4 100644 --- a/core/fpdfapi/page/cpdf_tilingpattern.cpp +++ b/core/fpdfapi/page/cpdf_tilingpattern.cpp @@ -35,7 +35,7 @@ bool CPDF_TilingPattern::Load() { if (m_pForm) return true; - CPDF_Dictionary* pDict = pattern_obj()->GetDict(); + const CPDF_Dictionary* pDict = pattern_obj()->GetDict(); if (!pDict) return false; |