summaryrefslogtreecommitdiff
path: root/core/fpdfdoc
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-01-30 10:04:07 -0800
committerChromium commit bot <commit-bot@chromium.org>2017-01-30 18:46:09 +0000
commitf716f0bd85cabfa02cea1d092890a0dea67ef0e3 (patch)
tree78c46e5ce93774bdb8ef3de2e3475acd9ecb44bd /core/fpdfdoc
parent4ada364e183e05479bc45d2ce41700ae18b7f6a3 (diff)
downloadpdfium-f716f0bd85cabfa02cea1d092890a0dea67ef0e3.tar.xz
Refcount CPDF_OCContext.
Avoids explicit deletes through CPDF_RenderOptions holding pointers to it which may have been copy constructed. Ick. Change-Id: Ic044b66d13bd7c5eaa53de995373858081e115ec Reviewed-on: https://pdfium-review.googlesource.com/2451 Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfdoc')
-rw-r--r--core/fpdfdoc/cpdf_annotlist.cpp2
-rw-r--r--core/fpdfdoc/cpdf_occontext.h12
2 files changed, 9 insertions, 5 deletions
diff --git a/core/fpdfdoc/cpdf_annotlist.cpp b/core/fpdfdoc/cpdf_annotlist.cpp
index 1ad6ab23a6..b1bc4c9ca9 100644
--- a/core/fpdfdoc/cpdf_annotlist.cpp
+++ b/core/fpdfdoc/cpdf_annotlist.cpp
@@ -126,7 +126,7 @@ void CPDF_AnnotList::DisplayPass(CPDF_Page* pPage,
continue;
if (pOptions) {
- CPDF_OCContext* pOCContext = pOptions->m_pOCContext;
+ CFX_RetainPtr<CPDF_OCContext> pOCContext = pOptions->m_pOCContext;
CPDF_Dictionary* pAnnotDict = pAnnot->GetAnnotDict();
if (pOCContext && pAnnotDict &&
!pOCContext->CheckOCGVisible(pAnnotDict->GetDictFor("OC"))) {
diff --git a/core/fpdfdoc/cpdf_occontext.h b/core/fpdfdoc/cpdf_occontext.h
index 49bbd76d0c..ecdcfae31b 100644
--- a/core/fpdfdoc/cpdf_occontext.h
+++ b/core/fpdfdoc/cpdf_occontext.h
@@ -9,6 +9,7 @@
#include <unordered_map>
+#include "core/fxcrt/cfx_retain_ptr.h"
#include "core/fxcrt/fx_string.h"
class CPDF_Array;
@@ -16,17 +17,20 @@ class CPDF_Dictionary;
class CPDF_Document;
class CPDF_PageObject;
-class CPDF_OCContext {
+class CPDF_OCContext : public CFX_Retainable {
public:
- enum UsageType { View = 0, Design, Print, Export };
+ template <typename T, typename... Args>
+ friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args);
- CPDF_OCContext(CPDF_Document* pDoc, UsageType eUsageType);
- ~CPDF_OCContext();
+ enum UsageType { View = 0, Design, Print, Export };
bool CheckOCGVisible(const CPDF_Dictionary* pOCGDict);
bool CheckObjectVisible(const CPDF_PageObject* pObj);
private:
+ CPDF_OCContext(CPDF_Document* pDoc, UsageType eUsageType);
+ ~CPDF_OCContext() override;
+
bool LoadOCGStateFromConfig(const CFX_ByteString& csConfig,
const CPDF_Dictionary* pOCGDict) const;
bool LoadOCGState(const CPDF_Dictionary* pOCGDict) const;