diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-05-24 13:21:45 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-05-24 22:34:21 +0000 |
commit | edc1e4e5baac33c8f2799e82ff52fd556d3c5e02 (patch) | |
tree | 0811327da4c67fe4babb07d299619382445c8be8 | |
parent | 4734512572776f8fc705e28fba8a46d981372e99 (diff) | |
download | pdfium-edc1e4e5baac33c8f2799e82ff52fd556d3c5e02.tar.xz |
Convert to CFX_UnownedPtr, part 9
Change-Id: Ia1151e0855accda0873251938a521df1913c73fa
Reviewed-on: https://pdfium-review.googlesource.com/5852
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
-rw-r--r-- | core/fpdfapi/font/cpdf_font.h | 5 | ||||
-rw-r--r-- | core/fpdfapi/font/cpdf_type3font.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_pattern.h | 9 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_textstate.h | 3 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_transferfunc.h | 3 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_bookmarktree.cpp | 4 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_bookmarktree.h | 8 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_docjsactions.cpp | 10 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_docjsactions.h | 6 |
9 files changed, 32 insertions, 18 deletions
diff --git a/core/fpdfapi/font/cpdf_font.h b/core/fpdfapi/font/cpdf_font.h index be1d91319e..c8e65e26a5 100644 --- a/core/fpdfapi/font/cpdf_font.h +++ b/core/fpdfapi/font/cpdf_font.h @@ -11,6 +11,7 @@ #include <vector> #include "core/fpdfapi/parser/cpdf_stream_acc.h" +#include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_string.h" #include "core/fxcrt/fx_system.h" #include "core/fxge/fx_font.h" @@ -78,7 +79,7 @@ class CPDF_Font { virtual int GetCharWidthF(uint32_t charcode) = 0; virtual FX_RECT GetCharBBox(uint32_t charcode) = 0; - CPDF_Document* GetDocument() { return m_pDocument; } + CPDF_Document* GetDocument() const { return m_pDocument.Get(); } CFX_Font* GetFont() { return &m_Font; } const CFX_Font* GetFont() const { return &m_Font; } CFX_Font* GetFontFallback(int position); @@ -101,7 +102,7 @@ class CPDF_Font { const std::vector<CFX_ByteString>& charnames, int charcode); - CPDF_Document* m_pDocument; + CFX_UnownedPtr<CPDF_Document> m_pDocument; CFX_Font m_Font; std::vector<std::unique_ptr<CFX_Font>> m_FontFallbacks; CFX_ByteString m_BaseFont; diff --git a/core/fpdfapi/font/cpdf_type3font.cpp b/core/fpdfapi/font/cpdf_type3font.cpp index 1e8c567a7f..b1ac99b0c3 100644 --- a/core/fpdfapi/font/cpdf_type3font.cpp +++ b/core/fpdfapi/font/cpdf_type3font.cpp @@ -107,7 +107,7 @@ CPDF_Type3Char* CPDF_Type3Font::LoadChar(uint32_t charcode) { auto pNewChar = pdfium::MakeUnique<CPDF_Type3Char>(pdfium::MakeUnique<CPDF_Form>( - m_pDocument, + m_pDocument.Get(), m_pFontResources ? m_pFontResources.Get() : m_pPageResources.Get(), pStream, nullptr)); diff --git a/core/fpdfapi/page/cpdf_pattern.h b/core/fpdfapi/page/cpdf_pattern.h index 3b948aedb7..dba301b922 100644 --- a/core/fpdfapi/page/cpdf_pattern.h +++ b/core/fpdfapi/page/cpdf_pattern.h @@ -7,6 +7,7 @@ #ifndef CORE_FPDFAPI_PAGE_CPDF_PATTERN_H_ #define CORE_FPDFAPI_PAGE_CPDF_PATTERN_H_ +#include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_coordinates.h" #include "core/fxcrt/fx_system.h" @@ -25,8 +26,8 @@ class CPDF_Pattern { virtual CPDF_ShadingPattern* AsShadingPattern() = 0; // All the getters that return pointers return non-NULL pointers. - CPDF_Document* document() { return m_pDocument; } - CPDF_Object* pattern_obj() { return m_pPatternObj; } + CPDF_Document* document() const { return m_pDocument.Get(); } + 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; } @@ -38,8 +39,8 @@ class CPDF_Pattern { void SetPatternToFormMatrix(); private: - CPDF_Document* const m_pDocument; - CPDF_Object* const m_pPatternObj; + CFX_UnownedPtr<CPDF_Document> const m_pDocument; + CFX_UnownedPtr<CPDF_Object> const m_pPatternObj; CFX_Matrix m_Pattern2Form; const CFX_Matrix m_ParentMatrix; }; diff --git a/core/fpdfapi/page/cpdf_textstate.h b/core/fpdfapi/page/cpdf_textstate.h index 84d2c13a6c..ff3ab8dd6c 100644 --- a/core/fpdfapi/page/cpdf_textstate.h +++ b/core/fpdfapi/page/cpdf_textstate.h @@ -8,6 +8,7 @@ #define CORE_FPDFAPI_PAGE_CPDF_TEXTSTATE_H_ #include "core/fxcrt/cfx_shared_copy_on_write.h" +#include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_basic.h" class CPDF_Document; @@ -72,7 +73,7 @@ class CPDF_TextState { float GetShearAngle() const; CPDF_Font* m_pFont; - CPDF_Document* m_pDocument; + CFX_UnownedPtr<CPDF_Document> m_pDocument; float m_FontSize; float m_CharSpace; float m_WordSpace; diff --git a/core/fpdfapi/render/cpdf_transferfunc.h b/core/fpdfapi/render/cpdf_transferfunc.h index 82e7a39037..ad7bf28c2f 100644 --- a/core/fpdfapi/render/cpdf_transferfunc.h +++ b/core/fpdfapi/render/cpdf_transferfunc.h @@ -8,6 +8,7 @@ #define CORE_FPDFAPI_RENDER_CPDF_TRANSFERFUNC_H_ #include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxge/fx_dib.h" class CPDF_Document; @@ -22,7 +23,7 @@ class CPDF_TransferFunc : public CFX_Retainable { CFX_RetainPtr<CFX_DIBSource> TranslateImage( const CFX_RetainPtr<CFX_DIBSource>& pSrc); - CPDF_Document* const m_pPDFDoc; + CFX_UnownedPtr<CPDF_Document> const m_pPDFDoc; bool m_bIdentity; uint8_t m_Samples[256 * 3]; diff --git a/core/fpdfdoc/cpdf_bookmarktree.cpp b/core/fpdfdoc/cpdf_bookmarktree.cpp index 2a4314547c..b5dfe4f45f 100644 --- a/core/fpdfdoc/cpdf_bookmarktree.cpp +++ b/core/fpdfdoc/cpdf_bookmarktree.cpp @@ -8,6 +8,10 @@ #include "core/fpdfapi/parser/cpdf_document.h" +CPDF_BookmarkTree::CPDF_BookmarkTree(CPDF_Document* pDoc) : m_pDocument(pDoc) {} + +CPDF_BookmarkTree::~CPDF_BookmarkTree() {} + CPDF_Bookmark CPDF_BookmarkTree::GetFirstChild( const CPDF_Bookmark& parent) const { CPDF_Dictionary* pParentDict = parent.GetDict(); diff --git a/core/fpdfdoc/cpdf_bookmarktree.h b/core/fpdfdoc/cpdf_bookmarktree.h index 7207357b1e..a854d6f4b1 100644 --- a/core/fpdfdoc/cpdf_bookmarktree.h +++ b/core/fpdfdoc/cpdf_bookmarktree.h @@ -8,19 +8,21 @@ #define CORE_FPDFDOC_CPDF_BOOKMARKTREE_H_ #include "core/fpdfdoc/cpdf_bookmark.h" +#include "core/fxcrt/cfx_unowned_ptr.h" class CPDF_Document; class CPDF_BookmarkTree { public: - explicit CPDF_BookmarkTree(CPDF_Document* pDoc) : m_pDocument(pDoc) {} + explicit CPDF_BookmarkTree(CPDF_Document* pDoc); + ~CPDF_BookmarkTree(); CPDF_Bookmark GetFirstChild(const CPDF_Bookmark& parent) const; CPDF_Bookmark GetNextSibling(const CPDF_Bookmark& bookmark) const; - CPDF_Document* GetDocument() const { return m_pDocument; } + CPDF_Document* GetDocument() const { return m_pDocument.Get(); } private: - CPDF_Document* const m_pDocument; + CFX_UnownedPtr<CPDF_Document> const m_pDocument; }; #endif // CORE_FPDFDOC_CPDF_BOOKMARKTREE_H_ diff --git a/core/fpdfdoc/cpdf_docjsactions.cpp b/core/fpdfdoc/cpdf_docjsactions.cpp index c0e7a78fd6..59dbccce85 100644 --- a/core/fpdfdoc/cpdf_docjsactions.cpp +++ b/core/fpdfdoc/cpdf_docjsactions.cpp @@ -10,9 +10,11 @@ CPDF_DocJSActions::CPDF_DocJSActions(CPDF_Document* pDoc) : m_pDocument(pDoc) {} +CPDF_DocJSActions::~CPDF_DocJSActions() {} + int CPDF_DocJSActions::CountJSActions() const { ASSERT(m_pDocument); - CPDF_NameTree name_tree(m_pDocument, "JavaScript"); + CPDF_NameTree name_tree(m_pDocument.Get(), "JavaScript"); return name_tree.GetCount(); } @@ -20,7 +22,7 @@ CPDF_Action CPDF_DocJSActions::GetJSActionAndName( int index, CFX_ByteString* csName) const { ASSERT(m_pDocument); - CPDF_NameTree name_tree(m_pDocument, "JavaScript"); + CPDF_NameTree name_tree(m_pDocument.Get(), "JavaScript"); CPDF_Object* pAction = name_tree.LookupValueAndName(index, csName); return ToDictionary(pAction) ? CPDF_Action(pAction->GetDict()) : CPDF_Action(); @@ -28,7 +30,7 @@ CPDF_Action CPDF_DocJSActions::GetJSActionAndName( CPDF_Action CPDF_DocJSActions::GetJSAction(const CFX_ByteString& csName) const { ASSERT(m_pDocument); - CPDF_NameTree name_tree(m_pDocument, "JavaScript"); + CPDF_NameTree name_tree(m_pDocument.Get(), "JavaScript"); CPDF_Object* pAction = name_tree.LookupValue(csName); return ToDictionary(pAction) ? CPDF_Action(pAction->GetDict()) : CPDF_Action(); @@ -36,6 +38,6 @@ CPDF_Action CPDF_DocJSActions::GetJSAction(const CFX_ByteString& csName) const { int CPDF_DocJSActions::FindJSAction(const CFX_ByteString& csName) const { ASSERT(m_pDocument); - CPDF_NameTree name_tree(m_pDocument, "JavaScript"); + CPDF_NameTree name_tree(m_pDocument.Get(), "JavaScript"); return name_tree.GetIndex(csName); } diff --git a/core/fpdfdoc/cpdf_docjsactions.h b/core/fpdfdoc/cpdf_docjsactions.h index 16b6be3d69..328b8869f6 100644 --- a/core/fpdfdoc/cpdf_docjsactions.h +++ b/core/fpdfdoc/cpdf_docjsactions.h @@ -8,6 +8,7 @@ #define CORE_FPDFDOC_CPDF_DOCJSACTIONS_H_ #include "core/fpdfdoc/cpdf_action.h" +#include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_string.h" class CPDF_Document; @@ -15,15 +16,16 @@ class CPDF_Document; class CPDF_DocJSActions { public: explicit CPDF_DocJSActions(CPDF_Document* pDoc); + ~CPDF_DocJSActions(); int CountJSActions() const; CPDF_Action GetJSActionAndName(int index, CFX_ByteString* csName) const; CPDF_Action GetJSAction(const CFX_ByteString& csName) const; int FindJSAction(const CFX_ByteString& csName) const; - CPDF_Document* GetDocument() const { return m_pDocument; } + CPDF_Document* GetDocument() const { return m_pDocument.Get(); } private: - CPDF_Document* const m_pDocument; + CFX_UnownedPtr<CPDF_Document> const m_pDocument; }; #endif // CORE_FPDFDOC_CPDF_DOCJSACTIONS_H_ |