From 1e2c557e0fa0e47c8bafdb31c833ea4f90f5fedd Mon Sep 17 00:00:00 2001 From: tsepez Date: Wed, 25 May 2016 14:58:09 -0700 Subject: Remove CFX_PrivateData from CPDF_Page CFX_PrivateData served two purposes here: The first was to hold an opaque pointer to the corresponding page structure in the next higher layer, of which it knows no details. Introduce an empty CPDF_Page::View class to represent this higher class, so as to get type safety while preserving layering. The second was to hold an opaque render context, which it also happened to own. Make this a CFX_Deletable to help with management. Also remove an unused inheritance from CFX_PrivateData in CPDF_Annot. Review-Url: https://codereview.chromium.org/2008553008 --- core/fpdfapi/fpdf_page/cpdf_page.cpp | 1 + core/fpdfapi/fpdf_page/include/cpdf_page.h | 14 +++++++++++++- core/fpdfdoc/include/fpdf_doc.h | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/fpdfapi/fpdf_page/cpdf_page.cpp b/core/fpdfapi/fpdf_page/cpdf_page.cpp index 6b0609ff00..441bbfe28b 100644 --- a/core/fpdfapi/fpdf_page/cpdf_page.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_page.cpp @@ -21,6 +21,7 @@ CPDF_Page::CPDF_Page(CPDF_Document* pDocument, bool bPageCache) : m_PageWidth(100), m_PageHeight(100), + m_pView(nullptr), m_pPageRender(bPageCache ? new CPDF_PageRenderCache(this) : nullptr) { m_pFormDict = pPageDict; m_pDocument = pDocument; diff --git a/core/fpdfapi/fpdf_page/include/cpdf_page.h b/core/fpdfapi/fpdf_page/include/cpdf_page.h index 7f4430187a..99734889af 100644 --- a/core/fpdfapi/fpdf_page/include/cpdf_page.h +++ b/core/fpdfapi/fpdf_page/include/cpdf_page.h @@ -19,8 +19,10 @@ class CPDF_Document; class CPDF_Object; class CPDF_PageRenderCache; -class CPDF_Page : public CPDF_PageObjectHolder, public CFX_PrivateData { +class CPDF_Page : public CPDF_PageObjectHolder { public: + class View {}; // Caller implements as desired, empty here due to layering. + CPDF_Page(CPDF_Document* pDocument, CPDF_Dictionary* pPageDict, bool bPageCache); @@ -42,6 +44,14 @@ class CPDF_Page : public CPDF_PageObjectHolder, public CFX_PrivateData { CPDF_Object* GetPageAttr(const CFX_ByteString& name) const; CPDF_PageRenderCache* GetRenderCache() const { return m_pPageRender.get(); } + CFX_Deletable* GetRenderContext() const { return m_pRenderContext.get(); } + void SetRenderContext(std::unique_ptr pContext) { + m_pRenderContext = std::move(pContext); + } + + View* GetView() const { return m_pView; } + void SetView(View* pView) { m_pView = pView; } + protected: friend class CPDF_ContentParser; @@ -50,7 +60,9 @@ class CPDF_Page : public CPDF_PageObjectHolder, public CFX_PrivateData { FX_FLOAT m_PageWidth; FX_FLOAT m_PageHeight; CFX_Matrix m_PageMatrix; + View* m_pView; std::unique_ptr m_pPageRender; + std::unique_ptr m_pRenderContext; }; #endif // CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_PAGE_H_ diff --git a/core/fpdfdoc/include/fpdf_doc.h b/core/fpdfdoc/include/fpdf_doc.h index 3ee583d778..8c7ce4eeab 100644 --- a/core/fpdfdoc/include/fpdf_doc.h +++ b/core/fpdfdoc/include/fpdf_doc.h @@ -317,7 +317,7 @@ class CPDF_Link { #define ANNOTFLAG_LOCKED 0x0080 #define ANNOTFLAG_TOGGLENOVIEW 0x0100 -class CPDF_Annot : public CFX_PrivateData { +class CPDF_Annot { public: enum AppearanceMode { Normal, Rollover, Down }; -- cgit v1.2.3