summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fpdfapi/cmaps/fpdf_cmaps.cpp2
-rw-r--r--core/fpdfapi/font/font_int.h5
-rw-r--r--core/fpdfapi/page/cpdf_color.cpp2
-rw-r--r--core/fpdfapi/page/cpdf_colorspace.cpp2
-rw-r--r--core/fpdfapi/page/cpdf_shadingobject.h3
-rw-r--r--core/fpdfapi/page/cpdf_shadingpattern.h6
-rw-r--r--core/fpdfapi/parser/cfdf_document.h5
-rw-r--r--core/fpdfapi/parser/cpdf_data_avail.h3
-rw-r--r--core/fpdfapi/parser/cpdf_object_unittest.cpp26
-rw-r--r--core/fpdfapi/render/cpdf_imageloader.cpp4
-rw-r--r--core/fpdfapi/render/cpdf_imageloader.h5
-rw-r--r--core/fpdfapi/render/cpdf_imagerenderer.cpp8
-rw-r--r--core/fpdfapi/render/cpdf_imagerenderer.h3
-rw-r--r--core/fpdfapi/render/cpdf_pagerendercache.cpp4
-rw-r--r--core/fpdfapi/render/cpdf_rendercontext.cpp10
-rw-r--r--core/fpdfapi/render/cpdf_rendercontext.h7
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.cpp35
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.h11
-rw-r--r--core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp4
-rw-r--r--core/fpdfapi/render/cpdf_scaledrenderbuffer.h12
-rw-r--r--core/fpdfdoc/cpdf_formfield.cpp2
-rw-r--r--core/fpdfdoc/cpdf_formfield.h4
-rw-r--r--core/fpdfdoc/cpdf_interform.cpp2
-rw-r--r--core/fpdfdoc/cpdf_interform.h5
-rw-r--r--core/fpdfdoc/cpdf_link.cpp8
-rw-r--r--core/fpdfdoc/cpdf_link.h12
-rw-r--r--core/fpdftext/cpdf_textpage.cpp12
-rw-r--r--core/fpdftext/cpdf_textpage.h6
-rw-r--r--core/fxcodec/codec/ccodec_jbig2module.h3
-rw-r--r--core/fxcodec/codec/ccodec_progressivedecoder.h5
-rw-r--r--core/fxcodec/codec/fx_codec_progress.cpp14
-rw-r--r--core/fxcodec/jbig2/JBig2_GrdProc.cpp34
-rw-r--r--core/fxcodec/jbig2/JBig2_GrdProc.h4
-rw-r--r--core/fxcodec/lgif/cgifcontext.h3
-rw-r--r--core/fxge/agg/fx_agg_driver.cpp2
-rw-r--r--core/fxge/android/cfpf_skiafont.h5
-rw-r--r--core/fxge/android/cfx_androidfontinfo.h3
-rw-r--r--core/fxge/cfx_facecache.h3
-rw-r--r--core/fxge/cfx_renderdevice.h9
-rw-r--r--core/fxge/dib/cfx_bitmapcomposer.h3
-rw-r--r--core/fxge/dib/cfx_imagerenderer.cpp4
-rw-r--r--core/fxge/dib/cfx_imagerenderer.h3
-rw-r--r--core/fxge/dib/cstretchengine.h3
-rw-r--r--core/fxge/ge/cfx_facecache.cpp4
-rw-r--r--core/fxge/ge/cfx_folderfontinfo.h3
-rw-r--r--core/fxge/ge/cfx_font.cpp4
-rw-r--r--core/fxge/ge/cfx_renderdevice.cpp9
-rw-r--r--core/fxge/skia/fx_skia_device.cpp6
-rw-r--r--core/fxge/win32/cfx_psrenderer.cpp2
-rw-r--r--core/fxge/win32/fx_win32_device.cpp2
-rw-r--r--fpdfsdk/cba_annotiterator.h3
-rw-r--r--fpdfsdk/cpdfsdk_annot.h5
-rw-r--r--fpdfsdk/cpdfsdk_widget.cpp8
-rw-r--r--fpdfsdk/cpdfsdk_widget.h5
-rw-r--r--fpdfsdk/cpdfsdk_widgethandler.h6
-rw-r--r--fpdfsdk/cpdfsdk_xfawidget.cpp4
-rw-r--r--fpdfsdk/cpdfsdk_xfawidget.h10
-rw-r--r--fpdfsdk/formfiller/cffl_checkbox.cpp2
-rw-r--r--fpdfsdk/formfiller/cffl_combobox.cpp6
-rw-r--r--fpdfsdk/formfiller/cffl_formfiller.cpp14
-rw-r--r--fpdfsdk/formfiller/cffl_formfiller.h6
-rw-r--r--fpdfsdk/formfiller/cffl_listbox.cpp8
-rw-r--r--fpdfsdk/formfiller/cffl_radiobutton.cpp2
-rw-r--r--fpdfsdk/formfiller/cffl_textfield.cpp23
-rw-r--r--fpdfsdk/fpdf_sysfontinfo.cpp5
-rw-r--r--fpdfsdk/fpdfdoc_unittest.cpp48
-rw-r--r--fpdfsdk/fxedit/fxet_edit.cpp2
-rw-r--r--fpdfsdk/fxedit/fxet_edit.h21
-rw-r--r--fpdfsdk/fxedit/fxet_list.cpp2
-rw-r--r--fpdfsdk/fxedit/fxet_list.h5
-rw-r--r--fpdfsdk/javascript/JS_EventHandler.h6
-rw-r--r--fpdfsdk/pdfwindow/PWL_ComboBox.h10
-rw-r--r--fpdfsdk/pdfwindow/PWL_Edit.h2
-rw-r--r--fpdfsdk/pdfwindow/PWL_Icon.cpp8
-rw-r--r--fpdfsdk/pdfwindow/PWL_Icon.h9
-rw-r--r--fpdfsdk/pdfwindow/PWL_ListBox.cpp6
-rw-r--r--fpdfsdk/pdfwindow/PWL_ListBox.h4
-rw-r--r--fpdfsdk/pdfwindow/PWL_ScrollBar.h7
-rw-r--r--fpdfsdk/pdfwindow/PWL_Wnd.cpp13
-rw-r--r--fpdfsdk/pdfwindow/PWL_Wnd.h7
-rw-r--r--fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp10
-rw-r--r--fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h2
-rw-r--r--fxbarcode/datamatrix/BC_EncoderContext.h3
-rw-r--r--fxbarcode/oned/BC_OneDimWriter.cpp5
-rw-r--r--fxbarcode/oned/BC_OneDimWriter.h3
-rw-r--r--fxbarcode/oned/BC_OnedEAN13Writer.cpp14
-rw-r--r--fxbarcode/oned/BC_OnedEAN8Writer.cpp10
-rw-r--r--fxbarcode/oned/BC_OnedUPCAWriter.cpp18
-rw-r--r--fxbarcode/qrcode/BC_QRCoder.cpp4
-rw-r--r--fxbarcode/qrcode/BC_QRCoder.h6
-rw-r--r--fxjs/cfxjse_arguments.cpp11
-rw-r--r--fxjs/cfxjse_arguments.h9
-rw-r--r--fxjs/cfxjse_class.h7
-rw-r--r--fxjs/cfxjse_context.cpp2
94 files changed, 390 insertions, 307 deletions
diff --git a/core/fpdfapi/cmaps/fpdf_cmaps.cpp b/core/fpdfapi/cmaps/fpdf_cmaps.cpp
index cb2f09fb3c..13aec268ae 100644
--- a/core/fpdfapi/cmaps/fpdf_cmaps.cpp
+++ b/core/fpdfapi/cmaps/fpdf_cmaps.cpp
@@ -61,7 +61,7 @@ void FPDFAPI_FindEmbeddedCMap(const CFX_ByteString& bsName,
CPDF_FontGlobals* pFontGlobals =
CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals();
const FXCMAP_CMap* pCMaps =
- pFontGlobals->m_EmbeddedCharsets[charset].m_pMapList;
+ pFontGlobals->m_EmbeddedCharsets[charset].m_pMapList.Get();
for (uint32_t i = 0; i < pFontGlobals->m_EmbeddedCharsets[charset].m_Count;
i++) {
if (bsName == pCMaps[i].m_Name) {
diff --git a/core/fpdfapi/font/font_int.h b/core/fpdfapi/font/font_int.h
index ebd08e258a..5544a1b016 100644
--- a/core/fpdfapi/font/font_int.h
+++ b/core/fpdfapi/font/font_int.h
@@ -14,6 +14,7 @@
#include "core/fpdfapi/font/cpdf_cidfont.h"
#include "core/fxcrt/cfx_retain_ptr.h"
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_basic.h"
class CPDF_CID2UnicodeMap;
@@ -194,7 +195,7 @@ class CPDF_ToUnicodeMap {
uint32_t GetUnicode();
std::map<uint32_t, uint32_t> m_Map;
- CPDF_CID2UnicodeMap* m_pBaseMap;
+ CFX_UnownedPtr<CPDF_CID2UnicodeMap> m_pBaseMap;
CFX_WideTextBuf m_MultiCharBuf;
};
@@ -213,7 +214,7 @@ class CPDF_FontGlobals {
CPDF_CMapManager m_CMapManager;
struct {
- const FXCMAP_CMap* m_pMapList;
+ CFX_UnownedPtr<const FXCMAP_CMap> m_pMapList;
uint32_t m_Count;
} m_EmbeddedCharsets[CIDSET_NUM_SETS];
struct {
diff --git a/core/fpdfapi/page/cpdf_color.cpp b/core/fpdfapi/page/cpdf_color.cpp
index e6665c83ac..747e6844ec 100644
--- a/core/fpdfapi/page/cpdf_color.cpp
+++ b/core/fpdfapi/page/cpdf_color.cpp
@@ -160,6 +160,6 @@ CPDF_Pattern* CPDF_Color::GetPattern() const {
if (!m_pBuffer || m_pCS->GetFamily() != PDFCS_PATTERN)
return nullptr;
- PatternValue* pvalue = (PatternValue*)m_pBuffer;
+ PatternValue* pvalue = reinterpret_cast<PatternValue*>(m_pBuffer);
return pvalue->m_pPattern;
}
diff --git a/core/fpdfapi/page/cpdf_colorspace.cpp b/core/fpdfapi/page/cpdf_colorspace.cpp
index 345180f368..90ef8944d3 100644
--- a/core/fpdfapi/page/cpdf_colorspace.cpp
+++ b/core/fpdfapi/page/cpdf_colorspace.cpp
@@ -190,7 +190,7 @@ class CPDF_IndexedCS : public CPDF_ColorSpace {
void EnableStdConversion(bool bEnabled) override;
CPDF_ColorSpace* m_pBaseCS;
- CPDF_CountedColorSpace* m_pCountedBaseCS;
+ CFX_UnownedPtr<CPDF_CountedColorSpace> m_pCountedBaseCS;
int m_nBaseComponents;
int m_MaxIndex;
CFX_ByteString m_Table;
diff --git a/core/fpdfapi/page/cpdf_shadingobject.h b/core/fpdfapi/page/cpdf_shadingobject.h
index ffd622379e..9db6712824 100644
--- a/core/fpdfapi/page/cpdf_shadingobject.h
+++ b/core/fpdfapi/page/cpdf_shadingobject.h
@@ -8,6 +8,7 @@
#define CORE_FPDFAPI_PAGE_CPDF_SHADINGOBJECT_H_
#include "core/fpdfapi/page/cpdf_pageobject.h"
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_coordinates.h"
class CPDF_ShadingPattern;
@@ -26,7 +27,7 @@ class CPDF_ShadingObject : public CPDF_PageObject {
void CalcBoundingBox();
- CPDF_ShadingPattern* m_pShading;
+ CFX_UnownedPtr<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 068d772bc3..24ad4c200e 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; }
CPDF_Object* GetShadingObject() const { return m_pShadingObj.Get(); }
- CPDF_ColorSpace* GetCS() const { return m_pCS; }
+ CPDF_ColorSpace* GetCS() const { return m_pCS.Get(); }
const std::vector<std::unique_ptr<CPDF_Function>>& GetFuncs() const {
return m_pFunctions;
}
@@ -67,9 +67,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.
- CPDF_ColorSpace* m_pCS;
+ CFX_UnownedPtr<CPDF_ColorSpace> m_pCS;
- CPDF_CountedColorSpace* m_pCountedCS;
+ CFX_UnownedPtr<CPDF_CountedColorSpace> m_pCountedCS;
std::vector<std::unique_ptr<CPDF_Function>> m_pFunctions;
};
diff --git a/core/fpdfapi/parser/cfdf_document.h b/core/fpdfapi/parser/cfdf_document.h
index f83adc1a30..9a13877544 100644
--- a/core/fpdfapi/parser/cfdf_document.h
+++ b/core/fpdfapi/parser/cfdf_document.h
@@ -11,6 +11,7 @@
#include "core/fpdfapi/parser/cpdf_indirect_object_holder.h"
#include "core/fpdfapi/parser/cpdf_object.h"
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_basic.h"
class CPDF_Dictionary;
@@ -27,12 +28,12 @@ class CFDF_Document : public CPDF_IndirectObjectHolder {
~CFDF_Document() override;
bool WriteBuf(CFX_ByteTextBuf& buf) const;
- CPDF_Dictionary* GetRoot() const { return m_pRootDict; }
+ CPDF_Dictionary* GetRoot() const { return m_pRootDict.Get(); }
protected:
void ParseStream(const CFX_RetainPtr<IFX_SeekableReadStream>& pFile);
- CPDF_Dictionary* m_pRootDict;
+ CFX_UnownedPtr<CPDF_Dictionary> m_pRootDict;
CFX_RetainPtr<IFX_SeekableReadStream> m_pFile;
};
diff --git a/core/fpdfapi/parser/cpdf_data_avail.h b/core/fpdfapi/parser/cpdf_data_avail.h
index 8edf062590..f47c859697 100644
--- a/core/fpdfapi/parser/cpdf_data_avail.h
+++ b/core/fpdfapi/parser/cpdf_data_avail.h
@@ -13,6 +13,7 @@
#include "core/fpdfapi/parser/cpdf_parser.h"
#include "core/fpdfapi/parser/cpdf_syntax_parser.h"
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_basic.h"
class CPDF_Dictionary;
@@ -204,7 +205,7 @@ class CPDF_DataAvail final {
uint32_t m_dwRootObjNum;
uint32_t m_dwInfoObjNum;
std::unique_ptr<CPDF_LinearizedHeader> m_pLinearized;
- CPDF_Object* m_pTrailer;
+ CFX_UnownedPtr<CPDF_Object> m_pTrailer;
bool m_bDocAvail;
FX_FILESIZE m_dwHeaderOffset;
FX_FILESIZE m_dwLastXRefOffset;
diff --git a/core/fpdfapi/parser/cpdf_object_unittest.cpp b/core/fpdfapi/parser/cpdf_object_unittest.cpp
index 1923992d7a..24a989665f 100644
--- a/core/fpdfapi/parser/cpdf_object_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_object_unittest.cpp
@@ -82,7 +82,7 @@ class PDFObjectsTest : public testing::Test {
// All direct objects.
CPDF_Object* objs[] = {boolean_false_obj, boolean_true_obj, number_int_obj,
number_float_obj, str_reg_obj, str_spec_obj,
- name_obj, m_ArrayObj, m_DictObj,
+ name_obj, m_ArrayObj.Get(), m_DictObj.Get(),
stream_obj, null_obj};
m_DirectObjTypes = {
CPDF_Object::BOOLEAN, CPDF_Object::BOOLEAN, CPDF_Object::NUMBER,
@@ -179,9 +179,9 @@ class PDFObjectsTest : public testing::Test {
std::vector<std::unique_ptr<CPDF_Object>> m_DirectObjs;
std::vector<int> m_DirectObjTypes;
std::vector<std::unique_ptr<CPDF_Object>> m_RefObjs;
- CPDF_Dictionary* m_DictObj;
- CPDF_Dictionary* m_StreamDictObj;
- CPDF_Array* m_ArrayObj;
+ CFX_UnownedPtr<CPDF_Dictionary> m_DictObj;
+ CFX_UnownedPtr<CPDF_Dictionary> m_StreamDictObj;
+ CFX_UnownedPtr<CPDF_Array> m_ArrayObj;
std::vector<CPDF_Object*> m_IndirectObjs;
};
@@ -244,23 +244,29 @@ TEST_F(PDFObjectsTest, GetInteger) {
TEST_F(PDFObjectsTest, GetDict) {
const CPDF_Dictionary* const direct_obj_results[] = {
- nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
- nullptr, nullptr, m_DictObj, m_StreamDictObj, nullptr};
+ nullptr, nullptr, nullptr, nullptr, nullptr,
+ nullptr, nullptr, nullptr, m_DictObj.Get(), m_StreamDictObj.Get(),
+ nullptr};
// Check for direct objects.
for (size_t i = 0; i < m_DirectObjs.size(); ++i)
EXPECT_EQ(direct_obj_results[i], m_DirectObjs[i]->GetDict());
// Check indirect references.
- const CPDF_Dictionary* const indirect_obj_results[] = {
- nullptr, nullptr, nullptr, nullptr, nullptr, m_DictObj, m_StreamDictObj};
+ const CPDF_Dictionary* const indirect_obj_results[] = {nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ m_DictObj.Get(),
+ m_StreamDictObj.Get()};
for (size_t i = 0; i < m_RefObjs.size(); ++i)
EXPECT_TRUE(Equal(indirect_obj_results[i], m_RefObjs[i]->GetDict()));
}
TEST_F(PDFObjectsTest, GetArray) {
const CPDF_Array* const direct_obj_results[] = {
- nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
- nullptr, m_ArrayObj, nullptr, nullptr, nullptr};
+ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
+ nullptr, m_ArrayObj.Get(), nullptr, nullptr, nullptr};
// Check for direct objects.
for (size_t i = 0; i < m_DirectObjs.size(); ++i)
EXPECT_EQ(direct_obj_results[i], m_DirectObjs[i]->AsArray());
diff --git a/core/fpdfapi/render/cpdf_imageloader.cpp b/core/fpdfapi/render/cpdf_imageloader.cpp
index 53b6009c15..b09b919baa 100644
--- a/core/fpdfapi/render/cpdf_imageloader.cpp
+++ b/core/fpdfapi/render/cpdf_imageloader.cpp
@@ -36,8 +36,8 @@ bool CPDF_ImageLoader::Start(const CPDF_ImageObject* pImage,
GroupFamily, bLoadMask, pRenderStatus);
} else {
ret = m_pImageObject->GetImage()->StartLoadDIBSource(
- pRenderStatus->m_pFormResource, pRenderStatus->m_pPageResource, bStdCS,
- GroupFamily, bLoadMask);
+ pRenderStatus->m_pFormResource.Get(),
+ pRenderStatus->m_pPageResource.Get(), bStdCS, GroupFamily, bLoadMask);
}
if (!ret)
HandleFailure();
diff --git a/core/fpdfapi/render/cpdf_imageloader.h b/core/fpdfapi/render/cpdf_imageloader.h
index f17f29cce5..47dd2f9812 100644
--- a/core/fpdfapi/render/cpdf_imageloader.h
+++ b/core/fpdfapi/render/cpdf_imageloader.h
@@ -9,6 +9,7 @@
#include <memory>
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_basic.h"
#include "core/fxge/fx_dib.h"
@@ -37,8 +38,8 @@ class CPDF_ImageLoader {
private:
void HandleFailure();
- CPDF_PageRenderCache* m_pCache;
- CPDF_ImageObject* m_pImageObject;
+ CFX_UnownedPtr<CPDF_PageRenderCache> m_pCache;
+ CFX_UnownedPtr<CPDF_ImageObject> m_pImageObject;
};
#endif // CORE_FPDFAPI_RENDER_CPDF_IMAGELOADER_H_
diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp
index ff4ed9c7d9..716203a7a5 100644
--- a/core/fpdfapi/render/cpdf_imagerenderer.cpp
+++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp
@@ -225,8 +225,8 @@ void CPDF_ImageRenderer::CalculateDrawImage(
CFX_Matrix* pNewMatrix,
const FX_RECT& rect) const {
CPDF_RenderStatus bitmap_render;
- bitmap_render.Initialize(m_pRenderStatus->m_pContext, pBitmapDevice2, nullptr,
- nullptr, nullptr, nullptr, nullptr, 0,
+ bitmap_render.Initialize(m_pRenderStatus->m_pContext.Get(), pBitmapDevice2,
+ nullptr, nullptr, nullptr, nullptr, nullptr, 0,
m_pRenderStatus->m_bDropObjects, nullptr, true);
CPDF_ImageRenderer image_render;
if (image_render.Start(&bitmap_render, pDIBSource, 0xffffffff, 255,
@@ -276,7 +276,7 @@ bool CPDF_ImageRenderer::DrawPatternImage(const CFX_Matrix* pObj2Device) {
bitmap_device1.GetBitmap()->Clear(0xffffff);
CPDF_RenderStatus bitmap_render;
- bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1,
+ bitmap_render.Initialize(m_pRenderStatus->m_pContext.Get(), &bitmap_device1,
nullptr, nullptr, nullptr, nullptr,
&m_pRenderStatus->m_Options, 0,
m_pRenderStatus->m_bDropObjects, nullptr, true);
@@ -329,7 +329,7 @@ bool CPDF_ImageRenderer::DrawMaskedImage() {
bitmap_device1.GetBitmap()->Clear(0xffffff);
#endif
CPDF_RenderStatus bitmap_render;
- bitmap_render.Initialize(m_pRenderStatus->m_pContext, &bitmap_device1,
+ bitmap_render.Initialize(m_pRenderStatus->m_pContext.Get(), &bitmap_device1,
nullptr, nullptr, nullptr, nullptr, nullptr, 0,
m_pRenderStatus->m_bDropObjects, nullptr, true);
CPDF_ImageRenderer image_render;
diff --git a/core/fpdfapi/render/cpdf_imagerenderer.h b/core/fpdfapi/render/cpdf_imagerenderer.h
index bf73098cde..46159284b2 100644
--- a/core/fpdfapi/render/cpdf_imagerenderer.h
+++ b/core/fpdfapi/render/cpdf_imagerenderer.h
@@ -10,6 +10,7 @@
#include <memory>
#include "core/fpdfapi/render/cpdf_imageloader.h"
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxge/dib/cfx_imagerenderer.h"
@@ -72,7 +73,7 @@ class CPDF_ImageRenderer {
CFX_RetainPtr<CFX_DIBitmap> m_pClone;
int m_BitmapAlpha;
bool m_bPatternColor;
- CPDF_Pattern* m_pPattern;
+ CFX_UnownedPtr<CPDF_Pattern> m_pPattern;
FX_ARGB m_FillArgb;
uint32_t m_Flags;
std::unique_ptr<CFX_ImageTransformer> m_pTransformer;
diff --git a/core/fpdfapi/render/cpdf_pagerendercache.cpp b/core/fpdfapi/render/cpdf_pagerendercache.cpp
index a997e34906..455b7f5ddb 100644
--- a/core/fpdfapi/render/cpdf_pagerendercache.cpp
+++ b/core/fpdfapi/render/cpdf_pagerendercache.cpp
@@ -95,8 +95,8 @@ bool CPDF_PageRenderCache::StartGetCachedBitmap(
new CPDF_ImageCacheEntry(m_pPage->m_pDocument.Get(), pImage);
}
int ret = m_pCurImageCacheEntry->StartGetCachedBitmap(
- pRenderStatus->m_pFormResource, m_pPage->m_pPageResources.Get(), bStdCS,
- GroupFamily, bLoadMask, pRenderStatus);
+ pRenderStatus->m_pFormResource.Get(), m_pPage->m_pPageResources.Get(),
+ bStdCS, GroupFamily, bLoadMask, pRenderStatus);
if (ret == 2)
return true;
diff --git a/core/fpdfapi/render/cpdf_rendercontext.cpp b/core/fpdfapi/render/cpdf_rendercontext.cpp
index 2cd59cac18..dec513276d 100644
--- a/core/fpdfapi/render/cpdf_rendercontext.cpp
+++ b/core/fpdfapi/render/cpdf_rendercontext.cpp
@@ -72,12 +72,12 @@ void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice,
status.Initialize(this, pDevice, pLastMatrix, pStopObj, nullptr, nullptr,
pOptions, layer.m_pObjectHolder->m_Transparency, false,
nullptr);
- status.RenderObjectList(layer.m_pObjectHolder, &FinalMatrix);
+ status.RenderObjectList(layer.m_pObjectHolder.Get(), &FinalMatrix);
} else {
status.Initialize(this, pDevice, nullptr, pStopObj, nullptr, nullptr,
pOptions, layer.m_pObjectHolder->m_Transparency, false,
nullptr);
- status.RenderObjectList(layer.m_pObjectHolder, &layer.m_Matrix);
+ status.RenderObjectList(layer.m_pObjectHolder.Get(), &layer.m_Matrix);
}
if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE)
m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize);
@@ -85,3 +85,9 @@ void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice,
break;
}
}
+
+CPDF_RenderContext::Layer::Layer() {}
+
+CPDF_RenderContext::Layer::Layer(const Layer& that) = default;
+
+CPDF_RenderContext::Layer::~Layer() {}
diff --git a/core/fpdfapi/render/cpdf_rendercontext.h b/core/fpdfapi/render/cpdf_rendercontext.h
index 4980d37ed6..220ff2b775 100644
--- a/core/fpdfapi/render/cpdf_rendercontext.h
+++ b/core/fpdfapi/render/cpdf_rendercontext.h
@@ -9,6 +9,7 @@
#include <vector>
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_basic.h"
#include "core/fxcrt/fx_coordinates.h"
@@ -27,7 +28,11 @@ class CPDF_RenderContext {
public:
class Layer {
public:
- CPDF_PageObjectHolder* m_pObjectHolder;
+ Layer();
+ Layer(const Layer& that);
+ ~Layer();
+
+ CFX_UnownedPtr<CPDF_PageObjectHolder> m_pObjectHolder;
CFX_Matrix m_Matrix;
};
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 7c17ff56b4..beeca3febe 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -1235,7 +1235,8 @@ void CPDF_RenderStatus::DrawObjWithBackground(CPDF_PageObject* pObj,
res = 0;
}
CPDF_ScaledRenderBuffer buffer;
- if (!buffer.Initialize(m_pContext, m_pDevice, rect, pObj, &m_Options, res)) {
+ if (!buffer.Initialize(m_pContext.Get(), m_pDevice, rect, pObj, &m_Options,
+ res)) {
return;
}
CFX_Matrix matrix = *pObj2Device;
@@ -1249,8 +1250,8 @@ void CPDF_RenderStatus::DrawObjWithBackground(CPDF_PageObject* pObj,
}
}
CPDF_RenderStatus status;
- status.Initialize(m_pContext, buffer.GetDevice(), buffer.GetMatrix(), nullptr,
- nullptr, nullptr, &m_Options, m_Transparency,
+ status.Initialize(m_pContext.Get(), buffer.GetDevice(), buffer.GetMatrix(),
+ nullptr, nullptr, nullptr, &m_Options, m_Transparency,
m_bDropObjects, pFormResource);
status.RenderSingleObject(pObj, &matrix);
buffer.OutputToDevice();
@@ -1273,9 +1274,9 @@ bool CPDF_RenderStatus::ProcessForm(const CPDF_FormObject* pFormObj,
pResources = pFormObj->m_pForm->m_pFormDict->GetDictFor("Resources");
}
CPDF_RenderStatus status;
- status.Initialize(m_pContext, m_pDevice, nullptr, m_pStopObj, this, pFormObj,
- &m_Options, m_Transparency, m_bDropObjects, pResources,
- false);
+ status.Initialize(m_pContext.Get(), m_pDevice, nullptr, m_pStopObj, this,
+ pFormObj, &m_Options, m_Transparency, m_bDropObjects,
+ pResources, false);
status.m_curBlend = m_curBlend;
{
CFX_RenderDevice::StateRestorer restorer(m_pDevice);
@@ -1605,9 +1606,9 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj,
}
}
CPDF_RenderStatus bitmap_render;
- bitmap_render.Initialize(m_pContext, &bitmap_device, nullptr, m_pStopObj,
- nullptr, nullptr, &m_Options, 0, m_bDropObjects,
- pFormResource, true);
+ bitmap_render.Initialize(m_pContext.Get(), &bitmap_device, nullptr,
+ m_pStopObj, nullptr, nullptr, &m_Options, 0,
+ m_bDropObjects, pFormResource, true);
bitmap_render.ProcessObjectNoClip(pPageObj, &new_matrix);
#if defined _SKIA_SUPPORT_PATHS_
bitmap_device.Flush();
@@ -1871,7 +1872,7 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj,
matrix.e += iChar ? textobj->m_CharPos[iChar - 1] : 0;
matrix.Concat(text_matrix);
matrix.Concat(*pObj2Device);
- if (!pType3Char->LoadBitmap(m_pContext)) {
+ if (!pType3Char->LoadBitmap(m_pContext.Get())) {
if (!glyphs.empty()) {
for (int i = 0; i < iChar; i++) {
const FXTEXT_GLYPHPOS& glyph = glyphs[i];
@@ -1897,7 +1898,7 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj,
}
if (fill_alpha == 255) {
CPDF_RenderStatus status;
- status.Initialize(m_pContext, m_pDevice, nullptr, nullptr, this,
+ status.Initialize(m_pContext.Get(), m_pDevice, nullptr, nullptr, this,
pStates.get(), &Options,
pType3Char->m_pForm->m_Transparency, m_bDropObjects,
pFormResource, false, pType3Char, fill_argb);
@@ -1919,8 +1920,8 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj,
}
bitmap_device.GetBitmap()->Clear(0);
CPDF_RenderStatus status;
- status.Initialize(m_pContext, &bitmap_device, nullptr, nullptr, this,
- pStates.get(), &Options,
+ status.Initialize(m_pContext.Get(), &bitmap_device, nullptr, nullptr,
+ this, pStates.get(), &Options,
pType3Char->m_pForm->m_Transparency, m_bDropObjects,
pFormResource, false, pType3Char, fill_argb);
status.m_Type3FontCache = m_Type3FontCache;
@@ -2093,7 +2094,7 @@ void CPDF_RenderStatus::DrawShading(CPDF_ShadingPattern* pPattern,
return;
}
CPDF_DeviceBuffer buffer;
- buffer.Initialize(m_pContext, m_pDevice, &clip_rect, m_pCurObj, 150);
+ buffer.Initialize(m_pContext.Get(), m_pDevice, &clip_rect, m_pCurObj, 150);
CFX_Matrix FinalMatrix = *pMatrix;
FinalMatrix.Concat(*buffer.GetMatrix());
CFX_RetainPtr<CFX_DIBitmap> pBitmap = buffer.GetBitmap();
@@ -2190,7 +2191,7 @@ void CPDF_RenderStatus::ProcessShading(const CPDF_ShadingObject* pShadingObj,
CFX_Matrix matrix = pShadingObj->m_Matrix;
matrix.Concat(*pObj2Device);
- DrawShading(pShadingObj->m_pShading, &matrix, rect,
+ DrawShading(pShadingObj->m_pShading.Get(), &matrix, rect,
FXSYS_round(255 * pShadingObj->m_GeneralState.GetFillAlpha()),
m_Options.m_ColorMode == RENDER_COLOR_ALPHA);
}
@@ -2276,7 +2277,7 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern,
original.y - mtPattern2Device.f);
CFX_RenderDevice::StateRestorer restorer2(m_pDevice);
CPDF_RenderStatus status;
- status.Initialize(m_pContext, m_pDevice, nullptr, nullptr, this,
+ status.Initialize(m_pContext.Get(), m_pDevice, nullptr, nullptr, this,
pStates.get(), &m_Options,
pPattern->form()->m_Transparency, m_bDropObjects,
pFormResource);
@@ -2628,7 +2629,7 @@ CFX_RetainPtr<CFX_DIBitmap> CPDF_RenderStatus::LoadSMask(
CPDF_RenderOptions options;
options.m_ColorMode = bLuminosity ? RENDER_COLOR_NORMAL : RENDER_COLOR_ALPHA;
CPDF_RenderStatus status;
- status.Initialize(m_pContext, &bitmap_device, nullptr, nullptr, nullptr,
+ status.Initialize(m_pContext.Get(), &bitmap_device, nullptr, nullptr, nullptr,
nullptr, &options, 0, m_bDropObjects, pFormResource, true,
nullptr, 0, color_space_family, bLuminosity);
status.RenderObjectList(&form, &matrix);
diff --git a/core/fpdfapi/render/cpdf_renderstatus.h b/core/fpdfapi/render/cpdf_renderstatus.h
index ab5ddd9f0d..47fbac8a7c 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.h
+++ b/core/fpdfapi/render/cpdf_renderstatus.h
@@ -13,6 +13,7 @@
#include "core/fpdfapi/page/cpdf_clippath.h"
#include "core/fpdfapi/page/cpdf_graphicstates.h"
#include "core/fpdfapi/render/cpdf_renderoptions.h"
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxge/cfx_renderdevice.h"
class CFX_PathData;
@@ -61,15 +62,15 @@ class CPDF_RenderStatus {
bool ContinueSingleObject(CPDF_PageObject* pObj,
const CFX_Matrix* pObj2Device,
IFX_Pause* pPause);
- CPDF_RenderContext* GetContext() { return m_pContext; }
+ CPDF_RenderContext* GetContext() const { return m_pContext.Get(); }
#if defined _SKIA_SUPPORT_
void DebugVerifyDeviceIsPreMultiplied() const;
#endif
CPDF_RenderOptions m_Options;
- CPDF_Dictionary* m_pFormResource;
- CPDF_Dictionary* m_pPageResource;
+ CFX_UnownedPtr<CPDF_Dictionary> m_pFormResource;
+ CFX_UnownedPtr<CPDF_Dictionary> m_pPageResource;
std::vector<CPDF_Type3Font*> m_Type3FontCache;
private:
@@ -157,7 +158,7 @@ class CPDF_RenderStatus {
static const int kRenderMaxRecursionDepth = 64;
static int s_CurrentRecursionDepth;
- CPDF_RenderContext* m_pContext;
+ CFX_UnownedPtr<CPDF_RenderContext> m_pContext;
bool m_bStopped;
CFX_RenderDevice* m_pDevice;
CFX_Matrix m_DeviceMatrix;
@@ -172,7 +173,7 @@ class CPDF_RenderStatus {
bool m_bStdCS;
uint32_t m_GroupFamily;
bool m_bLoadMask;
- CPDF_Type3Char* m_pType3Char;
+ CFX_UnownedPtr<CPDF_Type3Char> m_pType3Char;
FX_ARGB m_T3FillColor;
int m_curBlend;
};
diff --git a/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp b/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp
index 74d506c05c..17e33af3b1 100644
--- a/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp
+++ b/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp
@@ -67,8 +67,8 @@ bool CPDF_ScaledRenderBuffer::Initialize(CPDF_RenderContext* pContext,
}
m_Matrix.Scale(0.5f, 0.5f);
}
- m_pContext->GetBackground(m_pBitmapDevice->GetBitmap(), m_pObject, pOptions,
- &m_Matrix);
+ m_pContext->GetBackground(m_pBitmapDevice->GetBitmap(), m_pObject.Get(),
+ pOptions, &m_Matrix);
return true;
}
diff --git a/core/fpdfapi/render/cpdf_scaledrenderbuffer.h b/core/fpdfapi/render/cpdf_scaledrenderbuffer.h
index 92fabefbee..47ab5ad39f 100644
--- a/core/fpdfapi/render/cpdf_scaledrenderbuffer.h
+++ b/core/fpdfapi/render/cpdf_scaledrenderbuffer.h
@@ -9,6 +9,7 @@
#include <memory>
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxge/cfx_defaultrenderdevice.h"
@@ -28,17 +29,18 @@ class CPDF_ScaledRenderBuffer {
const CPDF_PageObject* pObj,
const CPDF_RenderOptions* pOptions,
int max_dpi);
- CFX_RenderDevice* GetDevice() {
- return m_pBitmapDevice ? m_pBitmapDevice.get() : m_pDevice;
+
+ CFX_RenderDevice* GetDevice() const {
+ return m_pBitmapDevice ? m_pBitmapDevice.get() : m_pDevice.Get();
}
CFX_Matrix* GetMatrix() { return &m_Matrix; }
void OutputToDevice();
private:
- CFX_RenderDevice* m_pDevice;
- CPDF_RenderContext* m_pContext;
+ CFX_UnownedPtr<CFX_RenderDevice> m_pDevice;
+ CFX_UnownedPtr<CPDF_RenderContext> m_pContext;
FX_RECT m_Rect;
- const CPDF_PageObject* m_pObject;
+ CFX_UnownedPtr<const CPDF_PageObject> m_pObject;
std::unique_ptr<CFX_DefaultRenderDevice> m_pBitmapDevice;
CFX_Matrix m_Matrix;
};
diff --git a/core/fpdfdoc/cpdf_formfield.cpp b/core/fpdfdoc/cpdf_formfield.cpp
index 97ea052436..cd47f269bc 100644
--- a/core/fpdfdoc/cpdf_formfield.cpp
+++ b/core/fpdfdoc/cpdf_formfield.cpp
@@ -899,7 +899,7 @@ bool CPDF_FormField::ClearSelectedOptions(bool bNotify) {
}
void CPDF_FormField::LoadDA() {
- CPDF_Dictionary* pFormDict = m_pForm->m_pFormDict;
+ CPDF_Dictionary* pFormDict = m_pForm->m_pFormDict.Get();
if (!pFormDict)
return;
diff --git a/core/fpdfdoc/cpdf_formfield.h b/core/fpdfdoc/cpdf_formfield.h
index f2038e41bd..f5c4c6964b 100644
--- a/core/fpdfdoc/cpdf_formfield.h
+++ b/core/fpdfdoc/cpdf_formfield.h
@@ -134,7 +134,7 @@ class CPDF_FormField {
#endif // PDF_ENABLE_XFA
float GetFontSize() const { return m_FontSize; }
- CPDF_Font* GetFont() const { return m_pFont; }
+ CPDF_Font* GetFont() const { return m_pFont.Get(); }
const CPDF_Dictionary* GetDict() const { return m_pDict.Get(); }
const CPDF_InterForm* GetForm() const { return m_pForm.Get(); }
@@ -176,7 +176,7 @@ class CPDF_FormField {
// Owned by InterForm parent.
std::vector<CFX_UnownedPtr<CPDF_FormControl>> m_ControlList;
float m_FontSize;
- CPDF_Font* m_pFont;
+ CFX_UnownedPtr<CPDF_Font> m_pFont;
};
#endif // CORE_FPDFDOC_CPDF_FORMFIELD_H_
diff --git a/core/fpdfdoc/cpdf_interform.cpp b/core/fpdfdoc/cpdf_interform.cpp
index de99a5de0f..9c3730ad70 100644
--- a/core/fpdfdoc/cpdf_interform.cpp
+++ b/core/fpdfdoc/cpdf_interform.cpp
@@ -961,7 +961,7 @@ int CPDF_InterForm::FindFieldInCalculationOrder(const CPDF_FormField* pField) {
}
CPDF_Font* CPDF_InterForm::GetFormFont(CFX_ByteString csNameTag) const {
- return GetFont(m_pFormDict, m_pDocument.Get(), csNameTag);
+ return GetFont(m_pFormDict.Get(), m_pDocument.Get(), csNameTag);
}
CPDF_DefaultAppearance CPDF_InterForm::GetDefaultAppearance() const {
diff --git a/core/fpdfdoc/cpdf_interform.h b/core/fpdfdoc/cpdf_interform.h
index 0a9b3e0e4a..9dc0532939 100644
--- a/core/fpdfdoc/cpdf_interform.h
+++ b/core/fpdfdoc/cpdf_interform.h
@@ -13,6 +13,7 @@
#include "core/fpdfapi/parser/fpdf_parser_decode.h"
#include "core/fpdfdoc/cpdf_defaultappearance.h"
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/fx_system.h"
@@ -109,12 +110,12 @@ class CPDF_InterForm {
static bool s_bUpdateAP;
CFX_UnownedPtr<CPDF_Document> const m_pDocument;
- CPDF_Dictionary* m_pFormDict;
+ CFX_UnownedPtr<CPDF_Dictionary> m_pFormDict;
std::map<const CPDF_Dictionary*, std::unique_ptr<CPDF_FormControl>>
m_ControlMap;
std::unique_ptr<CFieldTree> m_pFieldTree;
CFX_ByteString m_bsEncoding;
- IPDF_FormNotify* m_pFormNotify;
+ CFX_UnownedPtr<IPDF_FormNotify> m_pFormNotify;
};
#endif // CORE_FPDFDOC_CPDF_INTERFORM_H_
diff --git a/core/fpdfdoc/cpdf_link.cpp b/core/fpdfdoc/cpdf_link.cpp
index 20ec486df2..b622094a73 100644
--- a/core/fpdfdoc/cpdf_link.cpp
+++ b/core/fpdfdoc/cpdf_link.cpp
@@ -9,6 +9,14 @@
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfdoc/cpdf_nametree.h"
+CPDF_Link::CPDF_Link() {}
+
+CPDF_Link::CPDF_Link(CPDF_Dictionary* pDict) : m_pDict(pDict) {}
+
+CPDF_Link::CPDF_Link(const CPDF_Link& that) = default;
+
+CPDF_Link::~CPDF_Link() {}
+
CFX_FloatRect CPDF_Link::GetRect() {
return m_pDict->GetRectFor("Rect");
}
diff --git a/core/fpdfdoc/cpdf_link.h b/core/fpdfdoc/cpdf_link.h
index 162630d6ac..82f50fe004 100644
--- a/core/fpdfdoc/cpdf_link.h
+++ b/core/fpdfdoc/cpdf_link.h
@@ -9,23 +9,25 @@
#include "core/fpdfdoc/cpdf_action.h"
#include "core/fpdfdoc/cpdf_dest.h"
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_coordinates.h"
class CPDF_Dictionary;
class CPDF_Link {
public:
- CPDF_Link() : m_pDict(nullptr) {}
- explicit CPDF_Link(CPDF_Dictionary* pDict) : m_pDict(pDict) {}
-
- CPDF_Dictionary* GetDict() const { return m_pDict; }
+ CPDF_Link();
+ explicit CPDF_Link(CPDF_Dictionary* pDict);
+ CPDF_Link(const CPDF_Link& that);
+ ~CPDF_Link();
+ CPDF_Dictionary* GetDict() const { return m_pDict.Get(); }
CFX_FloatRect GetRect();
CPDF_Dest GetDest(CPDF_Document* pDoc);
CPDF_Action GetAction();
private:
- CPDF_Dictionary* m_pDict;
+ CFX_UnownedPtr<CPDF_Dictionary> m_pDict;
};
#endif // CORE_FPDFDOC_CPDF_LINK_H_
diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp
index 7a493c004d..e3db1c62c9 100644
--- a/core/fpdftext/cpdf_textpage.cpp
+++ b/core/fpdftext/cpdf_textpage.cpp
@@ -108,6 +108,12 @@ float MaskPercentFilled(const std::vector<bool>& mask,
} // namespace
+PDFTEXT_Obj::PDFTEXT_Obj() {}
+
+PDFTEXT_Obj::PDFTEXT_Obj(const PDFTEXT_Obj& that) = default;
+
+PDFTEXT_Obj::~PDFTEXT_Obj() {}
+
FPDF_CHAR_INFO::FPDF_CHAR_INFO()
: m_Unicode(0),
m_Charcode(0),
@@ -799,7 +805,7 @@ void CPDF_TextPage::ProcessTextObject(
}
FPDFText_MarkedContent CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) {
- CPDF_TextObject* pTextObj = Obj.m_pTextObj;
+ CPDF_TextObject* pTextObj = Obj.m_pTextObj.Get();
if (!pTextObj->m_ContentMark.HasRef())
return FPDFText_MarkedContent::Pass;
@@ -862,7 +868,7 @@ FPDFText_MarkedContent CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) {
}
void CPDF_TextPage::ProcessMarkedContent(PDFTEXT_Obj Obj) {
- CPDF_TextObject* pTextObj = Obj.m_pTextObj;
+ CPDF_TextObject* pTextObj = Obj.m_pTextObj.Get();
if (!pTextObj->m_ContentMark.HasRef())
return;
@@ -952,7 +958,7 @@ bool CPDF_TextPage::IsRightToLeft(const CPDF_TextObject* pTextObj,
}
void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) {
- CPDF_TextObject* pTextObj = Obj.m_pTextObj;
+ CPDF_TextObject* pTextObj = Obj.m_pTextObj.Get();
if (fabs(pTextObj->m_Right - pTextObj->m_Left) < 0.01f)
return;
CFX_Matrix formMatrix = Obj.m_formMatrix;
diff --git a/core/fpdftext/cpdf_textpage.h b/core/fpdftext/cpdf_textpage.h
index a18310667d..0f507de4aa 100644
--- a/core/fpdftext/cpdf_textpage.h
+++ b/core/fpdftext/cpdf_textpage.h
@@ -84,7 +84,11 @@ class PAGECHAR_INFO {
};
struct PDFTEXT_Obj {
- CPDF_TextObject* m_pTextObj;
+ PDFTEXT_Obj();
+ PDFTEXT_Obj(const PDFTEXT_Obj& that);
+ ~PDFTEXT_Obj();
+
+ CFX_UnownedPtr<CPDF_TextObject> m_pTextObj;
CFX_Matrix m_formMatrix;
};
diff --git a/core/fxcodec/codec/ccodec_jbig2module.h b/core/fxcodec/codec/ccodec_jbig2module.h
index 43abe042f0..e8dec945b8 100644
--- a/core/fxcodec/codec/ccodec_jbig2module.h
+++ b/core/fxcodec/codec/ccodec_jbig2module.h
@@ -10,6 +10,7 @@
#include <memory>
#include "core/fxcodec/fx_codec_def.h"
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_basic.h"
class CJBig2_Context;
@@ -29,7 +30,7 @@ class CCodec_Jbig2Context {
CFX_RetainPtr<CPDF_StreamAcc> m_pSrcStream;
uint8_t* m_dest_buf;
uint32_t m_dest_pitch;
- IFX_Pause* m_pPause;
+ CFX_UnownedPtr<IFX_Pause> m_pPause;
std::unique_ptr<CJBig2_Context> m_pContext;
};
diff --git a/core/fxcodec/codec/ccodec_progressivedecoder.h b/core/fxcodec/codec/ccodec_progressivedecoder.h
index 2b343b7e94..6dd7357b12 100644
--- a/core/fxcodec/codec/ccodec_progressivedecoder.h
+++ b/core/fxcodec/codec/ccodec_progressivedecoder.h
@@ -17,6 +17,7 @@
#include "core/fxcodec/fx_codec_def.h"
#include "core/fxcodec/lgif/cgifcontext.h"
#include "core/fxcrt/cfx_retain_ptr.h"
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_system.h"
#include "core/fxge/fx_dib.h"
@@ -127,12 +128,12 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate,
};
CFX_RetainPtr<IFX_SeekableReadStream> m_pFile;
- CCodec_ModuleMgr* m_pCodecMgr;
+ CFX_UnownedPtr<CCodec_ModuleMgr> m_pCodecMgr;
FXJPEG_Context* m_pJpegContext;
FXPNG_Context* m_pPngContext;
std::unique_ptr<CGifContext> m_pGifContext;
FXBMP_Context* m_pBmpContext;
- CCodec_TiffContext* m_pTiffContext;
+ CFX_UnownedPtr<CCodec_TiffContext> m_pTiffContext;
FXCODEC_IMAGE_TYPE m_imagType;
uint32_t m_offSet;
uint8_t* m_pSrcBuf;
diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp
index 9e470f3f14..209a9735f0 100644
--- a/core/fxcodec/codec/fx_codec_progress.cpp
+++ b/core/fxcodec/codec/fx_codec_progress.cpp
@@ -302,7 +302,7 @@ CCodec_ProgressiveDecoder::~CCodec_ProgressiveDecoder() {
if (m_pPngContext)
m_pCodecMgr->GetPngModule()->Finish(m_pPngContext);
if (m_pTiffContext)
- m_pCodecMgr->GetTiffModule()->DestroyDecoder(m_pTiffContext);
+ m_pCodecMgr->GetTiffModule()->DestroyDecoder(m_pTiffContext.Get());
FX_Free(m_pSrcBuf);
FX_Free(m_pDecodeBuf);
FX_Free(m_pSrcPalette);
@@ -1213,13 +1213,13 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType,
return false;
}
int32_t dummy_bpc;
- bool ret = pTiffModule->LoadFrameInfo(m_pTiffContext, 0, &m_SrcWidth,
- &m_SrcHeight, &m_SrcComponents,
- &dummy_bpc, pAttribute);
+ bool ret = pTiffModule->LoadFrameInfo(
+ m_pTiffContext.Get(), 0, &m_SrcWidth, &m_SrcHeight, &m_SrcComponents,
+ &dummy_bpc, pAttribute);
m_SrcComponents = 4;
m_clipBox = FX_RECT(0, 0, m_SrcWidth, m_SrcHeight);
if (!ret) {
- pTiffModule->DestroyDecoder(m_pTiffContext);
+ pTiffModule->DestroyDecoder(m_pTiffContext.Get());
m_pTiffContext = nullptr;
m_status = FXCODEC_STATUS_ERR_FORMAT;
return false;
@@ -2170,7 +2170,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode() {
m_SrcHeight == m_sizeY && m_startX == 0 && m_startY == 0 &&
m_clipBox.left == 0 && m_clipBox.top == 0 &&
m_clipBox.right == m_SrcWidth && m_clipBox.bottom == m_SrcHeight) {
- ret = pTiffModule->Decode(m_pTiffContext, m_pDeviceBitmap);
+ ret = pTiffModule->Decode(m_pTiffContext.Get(), m_pDeviceBitmap);
m_pDeviceBitmap = nullptr;
m_pFile = nullptr;
if (!ret) {
@@ -2189,7 +2189,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode() {
m_status = FXCODEC_STATUS_ERR_MEMORY;
return m_status;
}
- ret = pTiffModule->Decode(m_pTiffContext, pDIBitmap);
+ ret = pTiffModule->Decode(m_pTiffContext.Get(), pDIBitmap);
if (!ret) {
m_pDeviceBitmap = nullptr;
m_pFile = nullptr;
diff --git a/core/fxcodec/jbig2/JBig2_GrdProc.cpp b/core/fxcodec/jbig2/JBig2_GrdProc.cpp
index 0d9f991d4c..a8140bdd24 100644
--- a/core/fxcodec/jbig2/JBig2_GrdProc.cpp
+++ b/core/fxcodec/jbig2/JBig2_GrdProc.cpp
@@ -25,6 +25,8 @@ CJBig2_GRDProc::CJBig2_GRDProc()
m_ReplaceRect.right = 0;
}
+CJBig2_GRDProc::~CJBig2_GRDProc() {}
+
bool CJBig2_GRDProc::UseTemplate0Opt3() const {
return (GBAT[0] == 3) && (GBAT[1] == -1) && (GBAT[2] == -3) &&
(GBAT[3] == -1) && (GBAT[4] == 2) && (GBAT[5] == -2) &&
@@ -663,35 +665,35 @@ FXCODEC_STATUS CJBig2_GRDProc::decode_Arith(IFX_Pause* pPause) {
CJBig2_Image* pImage = *m_pImage;
if (GBTEMPLATE == 0) {
if (UseTemplate0Opt3()) {
- m_ProssiveStatus = decode_Arith_Template0_opt3(pImage, m_pArithDecoder,
- m_gbContext, pPause);
+ m_ProssiveStatus = decode_Arith_Template0_opt3(
+ pImage, m_pArithDecoder.Get(), m_gbContext, pPause);
} else {
- m_ProssiveStatus = decode_Arith_Template0_unopt(pImage, m_pArithDecoder,
- m_gbContext, pPause);
+ m_ProssiveStatus = decode_Arith_Template0_unopt(
+ pImage, m_pArithDecoder.Get(), m_gbContext, pPause);
}
} else if (GBTEMPLATE == 1) {
if (UseTemplate1Opt3()) {
- m_ProssiveStatus = decode_Arith_Template1_opt3(pImage, m_pArithDecoder,
- m_gbContext, pPause);
+ m_ProssiveStatus = decode_Arith_Template1_opt3(
+ pImage, m_pArithDecoder.Get(), m_gbContext, pPause);
} else {
- m_ProssiveStatus = decode_Arith_Template1_unopt(pImage, m_pArithDecoder,
- m_gbContext, pPause);
+ m_ProssiveStatus = decode_Arith_Template1_unopt(
+ pImage, m_pArithDecoder.Get(), m_gbContext, pPause);
}
} else if (GBTEMPLATE == 2) {
if (UseTemplate23Opt3()) {
- m_ProssiveStatus = decode_Arith_Template2_opt3(pImage, m_pArithDecoder,
- m_gbContext, pPause);
+ m_ProssiveStatus = decode_Arith_Template2_opt3(
+ pImage, m_pArithDecoder.Get(), m_gbContext, pPause);
} else {
- m_ProssiveStatus = decode_Arith_Template2_unopt(pImage, m_pArithDecoder,
- m_gbContext, pPause);
+ m_ProssiveStatus = decode_Arith_Template2_unopt(
+ pImage, m_pArithDecoder.Get(), m_gbContext, pPause);
}
} else {
if (UseTemplate23Opt3()) {
- m_ProssiveStatus = decode_Arith_Template3_opt3(pImage, m_pArithDecoder,
- m_gbContext, pPause);
+ m_ProssiveStatus = decode_Arith_Template3_opt3(
+ pImage, m_pArithDecoder.Get(), m_gbContext, pPause);
} else {
- m_ProssiveStatus = decode_Arith_Template3_unopt(pImage, m_pArithDecoder,
- m_gbContext, pPause);
+ m_ProssiveStatus = decode_Arith_Template3_unopt(
+ pImage, m_pArithDecoder.Get(), m_gbContext, pPause);
}
}
m_ReplaceRect.left = 0;
diff --git a/core/fxcodec/jbig2/JBig2_GrdProc.h b/core/fxcodec/jbig2/JBig2_GrdProc.h
index 447447fe8b..c6e8ae38d0 100644
--- a/core/fxcodec/jbig2/JBig2_GrdProc.h
+++ b/core/fxcodec/jbig2/JBig2_GrdProc.h
@@ -8,6 +8,7 @@
#define CORE_FXCODEC_JBIG2_JBIG2_GRDPROC_H_
#include "core/fxcodec/fx_codec_def.h"
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_system.h"
@@ -20,6 +21,7 @@ struct JBig2ArithCtx;
class CJBig2_GRDProc {
public:
CJBig2_GRDProc();
+ ~CJBig2_GRDProc();
CJBig2_Image* decode_Arith(CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext);
@@ -112,7 +114,7 @@ class CJBig2_GRDProc {
uint8_t* m_pLine;
FXCODEC_STATUS m_ProssiveStatus;
CJBig2_Image** m_pImage;
- CJBig2_ArithDecoder* m_pArithDecoder;
+ CFX_UnownedPtr<CJBig2_ArithDecoder> m_pArithDecoder;
JBig2ArithCtx* m_gbContext;
uint16_t m_DecodeType;
int m_LTP;
diff --git a/core/fxcodec/lgif/cgifcontext.h b/core/fxcodec/lgif/cgifcontext.h
index 08a66c18e2..20d640ef35 100644
--- a/core/fxcodec/lgif/cgifcontext.h
+++ b/core/fxcodec/lgif/cgifcontext.h
@@ -11,6 +11,7 @@
#include <vector>
#include "core/fxcodec/lgif/fx_gif.h"
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_basic.h"
class CCodec_GifModule;
@@ -44,7 +45,7 @@ class CGifContext {
int32_t decode_status;
uint32_t skip_size;
- CCodec_GifModule* m_Module;
+ CFX_UnownedPtr<CCodec_GifModule> m_Module;
char* err_ptr;
CFX_ByteString cmt_data;
std::unique_ptr<GifGCE> m_GifGCE;
diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp
index 6174f6e18f..22d80071a9 100644
--- a/core/fxge/agg/fx_agg_driver.cpp
+++ b/core/fxge/agg/fx_agg_driver.cpp
@@ -438,7 +438,7 @@ class CFX_Renderer {
CFX_RetainPtr<CFX_DIBitmap> m_pOriDevice;
CFX_RetainPtr<CFX_DIBitmap> m_pClipMask;
CFX_RetainPtr<CFX_DIBitmap> m_pDevice;
- const CFX_ClipRgn* m_pClipRgn;
+ CFX_UnownedPtr<const CFX_ClipRgn> m_pClipRgn;
};
void CFX_Renderer::CompositeSpan(uint8_t* dest_scan,
diff --git a/core/fxge/android/cfpf_skiafont.h b/core/fxge/android/cfpf_skiafont.h
index 657ced88f2..5686e9e31f 100644
--- a/core/fxge/android/cfpf_skiafont.h
+++ b/core/fxge/android/cfpf_skiafont.h
@@ -7,6 +7,7 @@
#ifndef CORE_FXGE_ANDROID_CFPF_SKIAFONT_H_
#define CORE_FXGE_ANDROID_CFPF_SKIAFONT_H_
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_system.h"
#include "core/fxge/fx_font.h"
@@ -42,8 +43,8 @@ class CFPF_SkiaFont {
uint8_t uCharset);
private:
- CFPF_SkiaFontMgr* m_pFontMgr;
- CFPF_SkiaFontDescriptor* m_pFontDes;
+ CFX_UnownedPtr<CFPF_SkiaFontMgr> m_pFontMgr;
+ CFX_UnownedPtr<CFPF_SkiaFontDescriptor> m_pFontDes;
FXFT_Face m_Face;
uint32_t m_dwStyle;
uint8_t m_uCharset;
diff --git a/core/fxge/android/cfx_androidfontinfo.h b/core/fxge/android/cfx_androidfontinfo.h
index ce08f2558a..17bbf89a3e 100644
--- a/core/fxge/android/cfx_androidfontinfo.h
+++ b/core/fxge/android/cfx_androidfontinfo.h
@@ -7,6 +7,7 @@
#ifndef CORE_FXGE_ANDROID_CFX_ANDROIDFONTINFO_H_
#define CORE_FXGE_ANDROID_CFX_ANDROIDFONTINFO_H_
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_system.h"
#include "core/fxge/cfx_fontmapper.h"
#include "core/fxge/fx_font.h"
@@ -39,7 +40,7 @@ class CFX_AndroidFontInfo : public IFX_SystemFontInfo {
void DeleteFont(void* hFont) override;
protected:
- CFPF_SkiaFontMgr* m_pFontMgr;
+ CFX_UnownedPtr<CFPF_SkiaFontMgr> m_pFontMgr;
};
#endif // CORE_FXGE_ANDROID_CFX_ANDROIDFONTINFO_H_
diff --git a/core/fxge/cfx_facecache.h b/core/fxge/cfx_facecache.h
index 5857a6310b..d6847debdb 100644
--- a/core/fxge/cfx_facecache.h
+++ b/core/fxge/cfx_facecache.h
@@ -10,6 +10,7 @@
#include <map>
#include <memory>
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxge/fx_font.h"
#include "core/fxge/fx_freetype.h"
@@ -59,7 +60,7 @@ class CFX_FaceCache {
std::map<CFX_ByteString, std::unique_ptr<CFX_SizeGlyphCache>> m_SizeMap;
std::map<uint32_t, std::unique_ptr<CFX_PathData>> m_PathMap;
#if defined _SKIA_SUPPORT_ || _SKIA_SUPPORT_PATHS_
- CFX_TypeFace* m_pTypeface;
+ CFX_UnownedPtr<CFX_TypeFace> m_pTypeface;
#endif
};
diff --git a/core/fxge/cfx_renderdevice.h b/core/fxge/cfx_renderdevice.h
index 4d8b407b35..f33da57cc9 100644
--- a/core/fxge/cfx_renderdevice.h
+++ b/core/fxge/cfx_renderdevice.h
@@ -9,6 +9,7 @@
#include <memory>
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxge/fx_dib.h"
#include "core/fxge/fx_font.h"
@@ -84,13 +85,11 @@ class CFX_RenderDevice {
public:
class StateRestorer {
public:
- explicit StateRestorer(CFX_RenderDevice* pDevice) : m_pDevice(pDevice) {
- m_pDevice->SaveState();
- }
- ~StateRestorer() { m_pDevice->RestoreState(false); }
+ explicit StateRestorer(CFX_RenderDevice* pDevice);
+ ~StateRestorer();
private:
- CFX_RenderDevice* m_pDevice;
+ CFX_UnownedPtr<CFX_RenderDevice> m_pDevice;
};
CFX_RenderDevice();
diff --git a/core/fxge/dib/cfx_bitmapcomposer.h b/core/fxge/dib/cfx_bitmapcomposer.h
index 6e961cbd45..cc4ecb13fe 100644
--- a/core/fxge/dib/cfx_bitmapcomposer.h
+++ b/core/fxge/dib/cfx_bitmapcomposer.h
@@ -10,6 +10,7 @@
#include <vector>
#include "core/fxcrt/cfx_retain_ptr.h"
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxge/dib/cfx_scanlinecompositor.h"
#include "core/fxge/dib/ifx_scanlinecomposer.h"
@@ -56,7 +57,7 @@ class CFX_BitmapComposer : public IFX_ScanlineComposer {
const uint8_t* scan_extra_alpha);
CFX_RetainPtr<CFX_DIBitmap> m_pBitmap;
- const CFX_ClipRgn* m_pClipRgn;
+ CFX_UnownedPtr<const CFX_ClipRgn> m_pClipRgn;
FXDIB_Format m_SrcFormat;
int m_DestLeft;
int m_DestTop;
diff --git a/core/fxge/dib/cfx_imagerenderer.cpp b/core/fxge/dib/cfx_imagerenderer.cpp
index cff95fdd70..ec611cacbe 100644
--- a/core/fxge/dib/cfx_imagerenderer.cpp
+++ b/core/fxge/dib/cfx_imagerenderer.cpp
@@ -122,14 +122,14 @@ bool CFX_ImageRenderer::Continue(IFX_Pause* pPause) {
m_pDevice->CompositeMask(
m_pTransformer->result().left, m_pTransformer->result().top,
pBitmap->GetWidth(), pBitmap->GetHeight(), pBitmap, m_MaskColor, 0, 0,
- m_BlendType, m_pClipRgn, m_bRgbByteOrder, m_AlphaFlag);
+ m_BlendType, m_pClipRgn.Get(), m_bRgbByteOrder, m_AlphaFlag);
} else {
if (m_BitmapAlpha != 255)
pBitmap->MultiplyAlpha(m_BitmapAlpha);
m_pDevice->CompositeBitmap(
m_pTransformer->result().left, m_pTransformer->result().top,
pBitmap->GetWidth(), pBitmap->GetHeight(), pBitmap, 0, 0, m_BlendType,
- m_pClipRgn, m_bRgbByteOrder);
+ m_pClipRgn.Get(), m_bRgbByteOrder);
}
return false;
}
diff --git a/core/fxge/dib/cfx_imagerenderer.h b/core/fxge/dib/cfx_imagerenderer.h
index f3d1286dc6..cad621e19c 100644
--- a/core/fxge/dib/cfx_imagerenderer.h
+++ b/core/fxge/dib/cfx_imagerenderer.h
@@ -10,6 +10,7 @@
#include <memory>
#include "core/fxcrt/cfx_retain_ptr.h"
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxge/dib/cfx_bitmapcomposer.h"
#include "core/fxge/dib/cfx_dibitmap.h"
@@ -38,7 +39,7 @@ class CFX_ImageRenderer {
private:
CFX_RetainPtr<CFX_DIBitmap> m_pDevice;
- const CFX_ClipRgn* m_pClipRgn;
+ CFX_UnownedPtr<const CFX_ClipRgn> m_pClipRgn;
int m_BitmapAlpha;
uint32_t m_MaskColor;
CFX_Matrix m_Matrix;
diff --git a/core/fxge/dib/cstretchengine.h b/core/fxge/dib/cstretchengine.h
index 280641cb59..049059361e 100644
--- a/core/fxge/dib/cstretchengine.h
+++ b/core/fxge/dib/cstretchengine.h
@@ -9,6 +9,7 @@
#include <vector>
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxge/fx_dib.h"
@@ -58,7 +59,7 @@ class CStretchEngine {
int m_DestBpp;
int m_SrcBpp;
int m_bHasAlpha;
- IFX_ScanlineComposer* m_pDestBitmap;
+ CFX_UnownedPtr<IFX_ScanlineComposer> m_pDestBitmap;
int m_DestWidth;
int m_DestHeight;
FX_RECT m_DestClip;
diff --git a/core/fxge/ge/cfx_facecache.cpp b/core/fxge/ge/cfx_facecache.cpp
index 9c79444dd3..6049729089 100644
--- a/core/fxge/ge/cfx_facecache.cpp
+++ b/core/fxge/ge/cfx_facecache.cpp
@@ -90,7 +90,7 @@ CFX_FaceCache::CFX_FaceCache(FXFT_Face face)
CFX_FaceCache::~CFX_FaceCache() {
#if defined _SKIA_SUPPORT_ || _SKIA_SUPPORT_PATHS_
- SkSafeUnref(m_pTypeface);
+ SkSafeUnref(m_pTypeface.Get());
#endif
}
@@ -370,7 +370,7 @@ CFX_TypeFace* CFX_FaceCache::GetDeviceCache(const CFX_Font* pFont) {
new SkMemoryStream(pFont->GetFontData(), pFont->GetSize()));
}
#endif
- return m_pTypeface;
+ return m_pTypeface.Get();
}
#endif
diff --git a/core/fxge/ge/cfx_folderfontinfo.h b/core/fxge/ge/cfx_folderfontinfo.h
index 6aadb1526f..ad363b5f0d 100644
--- a/core/fxge/ge/cfx_folderfontinfo.h
+++ b/core/fxge/ge/cfx_folderfontinfo.h
@@ -11,6 +11,7 @@
#include <memory>
#include <vector>
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxge/cfx_fontmapper.h"
#include "core/fxge/fx_font.h"
#include "core/fxge/ifx_systemfontinfo.h"
@@ -62,7 +63,7 @@ class CFX_FolderFontInfo : public IFX_SystemFontInfo {
std::map<CFX_ByteString, std::unique_ptr<CFX_FontFaceInfo>> m_FontList;
std::vector<CFX_ByteString> m_PathList;
- CFX_FontMapper* m_pMapper;
+ CFX_UnownedPtr<CFX_FontMapper> m_pMapper;
};
#endif // CORE_FXGE_GE_CFX_FOLDERFONTINFO_H_
diff --git a/core/fxge/ge/cfx_font.cpp b/core/fxge/ge/cfx_font.cpp
index 229ede7894..144675cdbd 100644
--- a/core/fxge/ge/cfx_font.cpp
+++ b/core/fxge/ge/cfx_font.cpp
@@ -28,12 +28,12 @@
namespace {
-typedef struct {
+struct OUTLINE_PARAMS {
CFX_PathData* m_pPath;
int m_CurX;
int m_CurY;
float m_CoordUnit;
-} OUTLINE_PARAMS;
+};
#ifdef PDF_ENABLE_XFA
diff --git a/core/fxge/ge/cfx_renderdevice.cpp b/core/fxge/ge/cfx_renderdevice.cpp
index f9153d1cdb..4404833758 100644
--- a/core/fxge/ge/cfx_renderdevice.cpp
+++ b/core/fxge/ge/cfx_renderdevice.cpp
@@ -1120,3 +1120,12 @@ bool CFX_RenderDevice::DrawTextPath(int nChars,
}
return true;
}
+
+CFX_RenderDevice::StateRestorer::StateRestorer(CFX_RenderDevice* pDevice)
+ : m_pDevice(pDevice) {
+ m_pDevice->SaveState();
+}
+
+CFX_RenderDevice::StateRestorer::~StateRestorer() {
+ m_pDevice->RestoreState(false);
+}
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index 7d91ab2b72..f4b72fe2ad 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -822,7 +822,7 @@ class SkiaState {
skPaint.setAntiAlias(true);
skPaint.setColor(m_fillColor);
if (m_pTypeFace) { // exclude placeholder test fonts
- sk_sp<SkTypeface> typeface(SkSafeRef(m_pTypeFace));
+ sk_sp<SkTypeface> typeface(SkSafeRef(m_pTypeFace.Get()));
skPaint.setTypeface(typeface);
}
skPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
@@ -1266,8 +1266,8 @@ class SkiaState {
CFX_GraphStateData m_clipState;
CFX_GraphStateData m_drawState;
CFX_Matrix m_clipMatrix;
- CFX_SkiaDeviceDriver* m_pDriver;
- CFX_TypeFace* m_pTypeFace;
+ CFX_UnownedPtr<CFX_SkiaDeviceDriver> m_pDriver;
+ CFX_UnownedPtr<CFX_TypeFace> m_pTypeFace;
float m_fontSize;
uint32_t m_fillColor;
uint32_t m_strokeColor;
diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp
index 400babd16b..b5260c1073 100644
--- a/core/fxge/win32/cfx_psrenderer.cpp
+++ b/core/fxge/win32/cfx_psrenderer.cpp
@@ -76,7 +76,7 @@ void PSCompressData(int PSLevel,
} // namespace
struct PSGlyph {
- CFX_Font* m_pFont;
+ CFX_UnownedPtr<CFX_Font> m_pFont;
uint32_t m_GlyphIndex;
bool m_bGlyphAdjust;
float m_AdjustMatrix[4];
diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp
index b495251dee..f6481187b3 100644
--- a/core/fxge/win32/fx_win32_device.cpp
+++ b/core/fxge/win32/fx_win32_device.cpp
@@ -363,7 +363,7 @@ class CFX_Win32FontInfo final : public IFX_SystemFontInfo {
CFX_ByteString FindFont(const CFX_ByteString& name);
HDC m_hDC;
- CFX_FontMapper* m_pMapper;
+ CFX_UnownedPtr<CFX_FontMapper> m_pMapper;
CFX_ByteString m_LastFamily;
CFX_ByteString m_KaiTi, m_FangSong;
};
diff --git a/fpdfsdk/cba_annotiterator.h b/fpdfsdk/cba_annotiterator.h
index 5cbe8e3d57..36eacd91c0 100644
--- a/fpdfsdk/cba_annotiterator.h
+++ b/fpdfsdk/cba_annotiterator.h
@@ -10,6 +10,7 @@
#include <vector>
#include "core/fpdfdoc/cpdf_annot.h"
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_string.h"
@@ -37,7 +38,7 @@ class CBA_AnnotIterator {
std::vector<size_t>* aSelect);
TabOrder m_eTabOrder;
- CPDFSDK_PageView* m_pPageView;
+ CFX_UnownedPtr<CPDFSDK_PageView> m_pPageView;
CPDF_Annot::Subtype m_nAnnotSubtype;
std::vector<CPDFSDK_Annot*> m_Annots;
};
diff --git a/fpdfsdk/cpdfsdk_annot.h b/fpdfsdk/cpdfsdk_annot.h
index 1053c00c13..abcdc2ebae 100644
--- a/fpdfsdk/cpdfsdk_annot.h
+++ b/fpdfsdk/cpdfsdk_annot.h
@@ -11,6 +11,7 @@
#include "core/fpdfdoc/cpdf_annot.h"
#include "core/fpdfdoc/cpdf_defaultappearance.h"
#include "core/fxcrt/cfx_observable.h"
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_basic.h"
#include "fpdfsdk/cfx_systemhandler.h"
#include "fpdfsdk/fsdk_common.h"
@@ -52,13 +53,13 @@ class CPDFSDK_Annot : public CFX_Observable<CPDFSDK_Annot> {
#endif // PDF_ENABLE_XFA
void SetPage(CPDFSDK_PageView* pPageView);
- CPDFSDK_PageView* GetPageView() const { return m_pPageView; }
+ CPDFSDK_PageView* GetPageView() const { return m_pPageView.Get(); }
bool IsSelected();
void SetSelected(bool bSelected);
protected:
- CPDFSDK_PageView* m_pPageView;
+ CFX_UnownedPtr<CPDFSDK_PageView> m_pPageView;
bool m_bSelected;
};
diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp
index a1cd8c7ce4..7d9357adb9 100644
--- a/fpdfsdk/cpdfsdk_widget.cpp
+++ b/fpdfsdk/cpdfsdk_widget.cpp
@@ -88,9 +88,8 @@ CXFA_FFWidget* CPDFSDK_Widget::GetMixXFAWidget() const {
m_hMixXFAWidget = pDocView->GetWidgetByName(sName, nullptr);
}
}
- return m_hMixXFAWidget;
+ return m_hMixXFAWidget.Get();
}
-
return nullptr;
}
@@ -113,10 +112,11 @@ CXFA_FFWidgetHandler* CPDFSDK_Widget::GetXFAWidgetHandler() const {
return nullptr;
if (!m_pWidgetHandler) {
- if (CXFA_FFDocView* pDocView = pContext->GetXFADocView())
+ CXFA_FFDocView* pDocView = pContext->GetXFADocView();
+ if (pDocView)
m_pWidgetHandler = pDocView->GetWidgetHandler();
}
- return m_pWidgetHandler;
+ return m_pWidgetHandler.Get();
}
static XFA_EVENTTYPE GetXFAEventType(PDFSDK_XFAAActionType eXFAAAT) {
diff --git a/fpdfsdk/cpdfsdk_widget.h b/fpdfsdk/cpdfsdk_widget.h
index a5e5b702dc..fe8d015123 100644
--- a/fpdfsdk/cpdfsdk_widget.h
+++ b/fpdfsdk/cpdfsdk_widget.h
@@ -12,6 +12,7 @@
#include "core/fpdfdoc/cpdf_aaction.h"
#include "core/fpdfdoc/cpdf_action.h"
#include "core/fpdfdoc/cpdf_annot.h"
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_string.h"
#include "fpdfsdk/cpdfsdk_baannot.h"
@@ -166,8 +167,8 @@ class CPDFSDK_Widget : public CPDFSDK_BAAnnot {
int32_t m_nValueAge;
#ifdef PDF_ENABLE_XFA
- mutable CXFA_FFWidget* m_hMixXFAWidget;
- mutable CXFA_FFWidgetHandler* m_pWidgetHandler;
+ mutable CFX_UnownedPtr<CXFA_FFWidget> m_hMixXFAWidget;
+ mutable CFX_UnownedPtr<CXFA_FFWidgetHandler> m_pWidgetHandler;
#endif // PDF_ENABLE_XFA
};
diff --git a/fpdfsdk/cpdfsdk_widgethandler.h b/fpdfsdk/cpdfsdk_widgethandler.h
index a772471418..4e8c9ef480 100644
--- a/fpdfsdk/cpdfsdk_widgethandler.h
+++ b/fpdfsdk/cpdfsdk_widgethandler.h
@@ -100,11 +100,13 @@ class CPDFSDK_WidgetHandler : public IPDFSDK_AnnotHandler {
void SetFormFiller(CFFL_InteractiveFormFiller* pFiller) {
m_pFormFiller = pFiller;
}
- CFFL_InteractiveFormFiller* GetFormFiller() { return m_pFormFiller; }
+ CFFL_InteractiveFormFiller* GetFormFiller() const {
+ return m_pFormFiller.Get();
+ }
private:
CFX_UnownedPtr<CPDFSDK_FormFillEnvironment> const m_pFormFillEnv;
- CFFL_InteractiveFormFiller* m_pFormFiller;
+ CFX_UnownedPtr<CFFL_InteractiveFormFiller> m_pFormFiller;
};
#endif // FPDFSDK_CPDFSDK_WIDGETHANDLER_H_
diff --git a/fpdfsdk/cpdfsdk_xfawidget.cpp b/fpdfsdk/cpdfsdk_xfawidget.cpp
index 902ff2a2e8..af08023ef8 100644
--- a/fpdfsdk/cpdfsdk_xfawidget.cpp
+++ b/fpdfsdk/cpdfsdk_xfawidget.cpp
@@ -16,12 +16,14 @@ CPDFSDK_XFAWidget::CPDFSDK_XFAWidget(CXFA_FFWidget* pAnnot,
m_pInterForm(pInterForm),
m_hXFAWidget(pAnnot) {}
+CPDFSDK_XFAWidget::~CPDFSDK_XFAWidget() {}
+
bool CPDFSDK_XFAWidget::IsXFAField() {
return true;
}
CXFA_FFWidget* CPDFSDK_XFAWidget::GetXFAWidget() const {
- return m_hXFAWidget;
+ return m_hXFAWidget.Get();
}
CPDF_Annot::Subtype CPDFSDK_XFAWidget::GetAnnotSubtype() const {
diff --git a/fpdfsdk/cpdfsdk_xfawidget.h b/fpdfsdk/cpdfsdk_xfawidget.h
index 9d0be75f13..42448b804f 100644
--- a/fpdfsdk/cpdfsdk_xfawidget.h
+++ b/fpdfsdk/cpdfsdk_xfawidget.h
@@ -7,6 +7,7 @@
#ifndef FPDFSDK_CPDFSDK_XFAWIDGET_H_
#define FPDFSDK_CPDFSDK_XFAWIDGET_H_
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_string.h"
#include "fpdfsdk/cpdfsdk_annot.h"
@@ -20,18 +21,19 @@ class CPDFSDK_XFAWidget : public CPDFSDK_Annot {
CPDFSDK_XFAWidget(CXFA_FFWidget* pAnnot,
CPDFSDK_PageView* pPageView,
CPDFSDK_InterForm* pInterForm);
- ~CPDFSDK_XFAWidget() override {}
+ ~CPDFSDK_XFAWidget() override;
+ // CPDFSDK_Annot:
bool IsXFAField() override;
CXFA_FFWidget* GetXFAWidget() const override;
CPDF_Annot::Subtype GetAnnotSubtype() const override;
CFX_FloatRect GetRect() const override;
- CPDFSDK_InterForm* GetInterForm() { return m_pInterForm; }
+ CPDFSDK_InterForm* GetInterForm() const { return m_pInterForm.Get(); }
private:
- CPDFSDK_InterForm* m_pInterForm;
- CXFA_FFWidget* m_hXFAWidget;
+ CFX_UnownedPtr<CPDFSDK_InterForm> m_pInterForm;
+ CFX_UnownedPtr<CXFA_FFWidget> m_hXFAWidget;
};
#endif // FPDFSDK_CPDFSDK_XFAWIDGET_H_
diff --git a/fpdfsdk/formfiller/cffl_checkbox.cpp b/fpdfsdk/formfiller/cffl_checkbox.cpp
index c233c136c1..323dcf4f91 100644
--- a/fpdfsdk/formfiller/cffl_checkbox.cpp
+++ b/fpdfsdk/formfiller/cffl_checkbox.cpp
@@ -48,7 +48,7 @@ bool CFFL_CheckBox::OnChar(CPDFSDK_Annot* pAnnot,
bool bReset = false;
bool bExit = false;
- CPDFSDK_Annot::ObservedPtr pObserved(m_pWidget);
+ CPDFSDK_Annot::ObservedPtr pObserved(m_pWidget.Get());
m_pFormFillEnv->GetInteractiveFormFiller()->OnButtonUp(
&pObserved, pPageView, bReset, bExit, nFlags);
if (!pObserved) {
diff --git a/fpdfsdk/formfiller/cffl_combobox.cpp b/fpdfsdk/formfiller/cffl_combobox.cpp
index 1f2491fe95..7887593b15 100644
--- a/fpdfsdk/formfiller/cffl_combobox.cpp
+++ b/fpdfsdk/formfiller/cffl_combobox.cpp
@@ -38,8 +38,10 @@ PWL_CREATEPARAM CFFL_ComboBox::GetCreateParam() {
if (m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT)
cp.dwFlags |= PCBS_ALLOWCUSTOMTEXT;
- if (!m_pFontMap)
- m_pFontMap = pdfium::MakeUnique<CBA_FontMap>(m_pWidget, GetSystemHandler());
+ if (!m_pFontMap) {
+ m_pFontMap =
+ pdfium::MakeUnique<CBA_FontMap>(m_pWidget.Get(), GetSystemHandler());
+ }
cp.pFontMap = m_pFontMap.get();
cp.pFocusHandler = this;
return cp;
diff --git a/fpdfsdk/formfiller/cffl_formfiller.cpp b/fpdfsdk/formfiller/cffl_formfiller.cpp
index 947c495f19..2bc240fc2e 100644
--- a/fpdfsdk/formfiller/cffl_formfiller.cpp
+++ b/fpdfsdk/formfiller/cffl_formfiller.cpp
@@ -356,16 +356,14 @@ CPWL_Wnd* CFFL_FormFiller::GetPDFWindow(CPDFSDK_PageView* pPageView,
}
} else {
PWL_CREATEPARAM cp = GetCreateParam();
- cp.pAttachedWidget.Reset(m_pWidget);
+ cp.pAttachedWidget.Reset(m_pWidget.Get());
CFFL_PrivateData* pPrivateData = new CFFL_PrivateData;
- pPrivateData->pWidget = m_pWidget;
+ pPrivateData->pWidget = m_pWidget.Get();
pPrivateData->pPageView = pPageView;
pPrivateData->nWidgetAge = m_pWidget->GetAppearanceAge();
pPrivateData->nValueAge = 0;
-
cp.pAttachedData = pPrivateData;
-
pWnd = NewPDFWindow(cp, pPageView);
m_Maps[pPageView] = pWnd;
}
@@ -506,7 +504,7 @@ bool CFFL_FormFiller::CommitData(CPDFSDK_PageView* pPageView, uint32_t nFlag) {
bool bExit = false;
CFFL_InteractiveFormFiller* pFormFiller =
m_pFormFillEnv->GetInteractiveFormFiller();
- CPDFSDK_Annot::ObservedPtr pObserved(m_pWidget);
+ CPDFSDK_Annot::ObservedPtr pObserved(m_pWidget.Get());
pFormFiller->OnKeyStrokeCommit(&pObserved, pPageView, bRC, bExit, nFlag);
if (!pObserved || bExit)
return true;
@@ -522,11 +520,11 @@ bool CFFL_FormFiller::CommitData(CPDFSDK_PageView* pPageView, uint32_t nFlag) {
return true;
}
SaveData(pPageView);
- pFormFiller->OnCalculate(m_pWidget, pPageView, bExit, nFlag);
+ pFormFiller->OnCalculate(m_pWidget.Get(), pPageView, bExit, nFlag);
if (bExit)
return true;
- pFormFiller->OnFormat(m_pWidget, pPageView, bExit, nFlag);
+ pFormFiller->OnFormat(m_pWidget.Get(), pPageView, bExit, nFlag);
}
return true;
}
@@ -582,7 +580,7 @@ void CFFL_FormFiller::EscapeFiller(CPDFSDK_PageView* pPageView,
bool bDestroyPDFWindow) {
m_bValid = false;
- InvalidateRect(GetViewBBox(pPageView, m_pWidget));
+ InvalidateRect(GetViewBBox(pPageView, m_pWidget.Get()));
if (bDestroyPDFWindow)
DestroyPDFWindow(pPageView);
}
diff --git a/fpdfsdk/formfiller/cffl_formfiller.h b/fpdfsdk/formfiller/cffl_formfiller.h
index f9a155be86..bbb1e4b21b 100644
--- a/fpdfsdk/formfiller/cffl_formfiller.h
+++ b/fpdfsdk/formfiller/cffl_formfiller.h
@@ -140,7 +140,7 @@ class CFFL_FormFiller : public IPWL_Provider, public CPWL_TimerHandler {
void SetChangeMark();
virtual void InvalidateRect(const FX_RECT& rect);
- CPDFSDK_Annot* GetSDKAnnot() { return m_pAnnot; }
+ CPDFSDK_Annot* GetSDKAnnot() { return m_pAnnot.Get(); }
protected:
using CFFL_PageView2PDFWindow = std::map<CPDFSDK_PageView*, CPWL_Wnd*>;
@@ -154,8 +154,8 @@ class CFFL_FormFiller : public IPWL_Provider, public CPWL_TimerHandler {
void DestroyWindows();
CFX_UnownedPtr<CPDFSDK_FormFillEnvironment> const m_pFormFillEnv;
- CPDFSDK_Widget* m_pWidget;
- CPDFSDK_Annot* m_pAnnot;
+ CFX_UnownedPtr<CPDFSDK_Widget> m_pWidget;
+ CFX_UnownedPtr<CPDFSDK_Annot> m_pAnnot;
bool m_bValid;
CFFL_PageView2PDFWindow m_Maps;
CFX_PointF m_ptOldPos;
diff --git a/fpdfsdk/formfiller/cffl_listbox.cpp b/fpdfsdk/formfiller/cffl_listbox.cpp
index 556e0e17d7..399e3902b1 100644
--- a/fpdfsdk/formfiller/cffl_listbox.cpp
+++ b/fpdfsdk/formfiller/cffl_listbox.cpp
@@ -25,12 +25,9 @@ CFFL_ListBox::~CFFL_ListBox() {}
PWL_CREATEPARAM CFFL_ListBox::GetCreateParam() {
PWL_CREATEPARAM cp = CFFL_FormFiller::GetCreateParam();
-
uint32_t dwFieldFlag = m_pWidget->GetFieldFlags();
-
- if (dwFieldFlag & FIELDFLAG_MULTISELECT) {
+ if (dwFieldFlag & FIELDFLAG_MULTISELECT)
cp.dwFlags |= PLBS_MULTIPLESEL;
- }
cp.dwFlags |= PWS_VSCROLL;
@@ -39,10 +36,9 @@ PWL_CREATEPARAM CFFL_ListBox::GetCreateParam() {
if (!m_pFontMap) {
m_pFontMap = pdfium::MakeUnique<CBA_FontMap>(
- m_pWidget, m_pFormFillEnv->GetSysHandler());
+ m_pWidget.Get(), m_pFormFillEnv->GetSysHandler());
}
cp.pFontMap = m_pFontMap.get();
-
return cp;
}
diff --git a/fpdfsdk/formfiller/cffl_radiobutton.cpp b/fpdfsdk/formfiller/cffl_radiobutton.cpp
index e78160e5dc..68f5cb0d88 100644
--- a/fpdfsdk/formfiller/cffl_radiobutton.cpp
+++ b/fpdfsdk/formfiller/cffl_radiobutton.cpp
@@ -51,7 +51,7 @@ bool CFFL_RadioButton::OnChar(CPDFSDK_Annot* pAnnot,
bool bReset = false;
bool bExit = false;
- CPDFSDK_Annot::ObservedPtr pObserved(m_pWidget);
+ CPDFSDK_Annot::ObservedPtr pObserved(m_pWidget.Get());
m_pFormFillEnv->GetInteractiveFormFiller()->OnButtonUp(
&pObserved, pPageView, bReset, bExit, nFlags);
if (!pObserved || bReset || bExit)
diff --git a/fpdfsdk/formfiller/cffl_textfield.cpp b/fpdfsdk/formfiller/cffl_textfield.cpp
index 71fc9291dc..b874a51b8c 100644
--- a/fpdfsdk/formfiller/cffl_textfield.cpp
+++ b/fpdfsdk/formfiller/cffl_textfield.cpp
@@ -28,34 +28,25 @@ CFFL_TextField::~CFFL_TextField() {
PWL_CREATEPARAM CFFL_TextField::GetCreateParam() {
PWL_CREATEPARAM cp = CFFL_FormFiller::GetCreateParam();
-
int nFlags = m_pWidget->GetFieldFlags();
-
- if (nFlags & FIELDFLAG_PASSWORD) {
+ if (nFlags & FIELDFLAG_PASSWORD)
cp.dwFlags |= PES_PASSWORD;
- }
if (nFlags & FIELDFLAG_MULTILINE) {
cp.dwFlags |= PES_MULTILINE | PES_AUTORETURN | PES_TOP;
-
- if (!(nFlags & FIELDFLAG_DONOTSCROLL)) {
+ if (!(nFlags & FIELDFLAG_DONOTSCROLL))
cp.dwFlags |= PWS_VSCROLL | PES_AUTOSCROLL;
- }
} else {
cp.dwFlags |= PES_CENTER;
-
- if (!(nFlags & FIELDFLAG_DONOTSCROLL)) {
+ if (!(nFlags & FIELDFLAG_DONOTSCROLL))
cp.dwFlags |= PES_AUTOSCROLL;
- }
}
- if (nFlags & FIELDFLAG_COMB) {
+ if (nFlags & FIELDFLAG_COMB)
cp.dwFlags |= PES_CHARARRAY;
- }
- if (nFlags & FIELDFLAG_RICHTEXT) {
+ if (nFlags & FIELDFLAG_RICHTEXT)
cp.dwFlags |= PES_RICH;
- }
cp.dwFlags |= PES_UNDO;
@@ -71,14 +62,12 @@ PWL_CREATEPARAM CFFL_TextField::GetCreateParam() {
cp.dwFlags |= PES_RIGHT;
break;
}
-
if (!m_pFontMap) {
m_pFontMap = pdfium::MakeUnique<CBA_FontMap>(
- m_pWidget, m_pFormFillEnv->GetSysHandler());
+ m_pWidget.Get(), m_pFormFillEnv->GetSysHandler());
}
cp.pFontMap = m_pFontMap.get();
cp.pFocusHandler = this;
-
return cp;
}
diff --git a/fpdfsdk/fpdf_sysfontinfo.cpp b/fpdfsdk/fpdf_sysfontinfo.cpp
index 1f73887532..28af1ac582 100644
--- a/fpdfsdk/fpdf_sysfontinfo.cpp
+++ b/fpdfsdk/fpdf_sysfontinfo.cpp
@@ -123,13 +123,12 @@ DLLEXPORT const FPDF_CharsetFontMap* STDCALL FPDF_GetDefaultTTFMap() {
}
struct FPDF_SYSFONTINFO_DEFAULT : public FPDF_SYSFONTINFO {
- IFX_SystemFontInfo* m_pFontInfo;
+ CFX_UnownedPtr<IFX_SystemFontInfo> m_pFontInfo;
};
static void DefaultRelease(struct _FPDF_SYSFONTINFO* pThis) {
auto* pDefault = static_cast<FPDF_SYSFONTINFO_DEFAULT*>(pThis);
- // TODO(thestig): Should this be set to nullptr too?
- delete pDefault->m_pFontInfo;
+ delete pDefault->m_pFontInfo.Release();
}
static void DefaultEnumFonts(struct _FPDF_SYSFONTINFO* pThis, void* pMapper) {
diff --git a/fpdfsdk/fpdfdoc_unittest.cpp b/fpdfsdk/fpdfdoc_unittest.cpp
index 449121d351..6409f70fe2 100644
--- a/fpdfsdk/fpdfdoc_unittest.cpp
+++ b/fpdfsdk/fpdfdoc_unittest.cpp
@@ -87,7 +87,7 @@ class PDFDocTest : public testing::Test {
protected:
std::unique_ptr<CPDF_TestPdfDocument> m_pDoc;
- CPDF_IndirectObjectHolder* m_pIndirectObjs;
+ CFX_UnownedPtr<CPDF_IndirectObjectHolder> m_pIndirectObjs;
std::unique_ptr<CPDF_Dictionary> m_pRootObj;
};
@@ -116,25 +116,25 @@ TEST_F(PDFDocTest, FindBookmark) {
auto bookmarks = CreateDictObjs(3);
bookmarks[1].obj->SetNewFor<CPDF_String>("Title", L"Chapter 1");
- bookmarks[1].obj->SetNewFor<CPDF_Reference>("Parent", m_pIndirectObjs,
+ bookmarks[1].obj->SetNewFor<CPDF_Reference>("Parent", m_pIndirectObjs.Get(),
bookmarks[0].num);
- bookmarks[1].obj->SetNewFor<CPDF_Reference>("Next", m_pIndirectObjs,
+ bookmarks[1].obj->SetNewFor<CPDF_Reference>("Next", m_pIndirectObjs.Get(),
bookmarks[2].num);
bookmarks[2].obj->SetNewFor<CPDF_String>("Title", L"Chapter 2");
- bookmarks[2].obj->SetNewFor<CPDF_Reference>("Parent", m_pIndirectObjs,
+ bookmarks[2].obj->SetNewFor<CPDF_Reference>("Parent", m_pIndirectObjs.Get(),
bookmarks[0].num);
- bookmarks[2].obj->SetNewFor<CPDF_Reference>("Prev", m_pIndirectObjs,
+ bookmarks[2].obj->SetNewFor<CPDF_Reference>("Prev", m_pIndirectObjs.Get(),
bookmarks[1].num);
bookmarks[0].obj->SetNewFor<CPDF_Name>("Type", "Outlines");
bookmarks[0].obj->SetNewFor<CPDF_Number>("Count", 2);
- bookmarks[0].obj->SetNewFor<CPDF_Reference>("First", m_pIndirectObjs,
+ bookmarks[0].obj->SetNewFor<CPDF_Reference>("First", m_pIndirectObjs.Get(),
bookmarks[1].num);
- bookmarks[0].obj->SetNewFor<CPDF_Reference>("Last", m_pIndirectObjs,
+ bookmarks[0].obj->SetNewFor<CPDF_Reference>("Last", m_pIndirectObjs.Get(),
bookmarks[2].num);
- m_pRootObj->SetNewFor<CPDF_Reference>("Outlines", m_pIndirectObjs,
+ m_pRootObj->SetNewFor<CPDF_Reference>("Outlines", m_pIndirectObjs.Get(),
bookmarks[0].num);
// Title with no match.
@@ -159,25 +159,25 @@ TEST_F(PDFDocTest, FindBookmark) {
auto bookmarks = CreateDictObjs(3);
bookmarks[1].obj->SetNewFor<CPDF_String>("Title", L"Chapter 1");
- bookmarks[1].obj->SetNewFor<CPDF_Reference>("Parent", m_pIndirectObjs,
+ bookmarks[1].obj->SetNewFor<CPDF_Reference>("Parent", m_pIndirectObjs.Get(),
bookmarks[0].num);
- bookmarks[1].obj->SetNewFor<CPDF_Reference>("First", m_pIndirectObjs,
+ bookmarks[1].obj->SetNewFor<CPDF_Reference>("First", m_pIndirectObjs.Get(),
bookmarks[2].num);
bookmarks[2].obj->SetNewFor<CPDF_String>("Title", L"Chapter 2");
- bookmarks[2].obj->SetNewFor<CPDF_Reference>("Parent", m_pIndirectObjs,
+ bookmarks[2].obj->SetNewFor<CPDF_Reference>("Parent", m_pIndirectObjs.Get(),
bookmarks[1].num);
- bookmarks[2].obj->SetNewFor<CPDF_Reference>("First", m_pIndirectObjs,
+ bookmarks[2].obj->SetNewFor<CPDF_Reference>("First", m_pIndirectObjs.Get(),
bookmarks[1].num);
bookmarks[0].obj->SetNewFor<CPDF_Name>("Type", "Outlines");
bookmarks[0].obj->SetNewFor<CPDF_Number>("Count", 2);
- bookmarks[0].obj->SetNewFor<CPDF_Reference>("First", m_pIndirectObjs,
+ bookmarks[0].obj->SetNewFor<CPDF_Reference>("First", m_pIndirectObjs.Get(),
bookmarks[1].num);
- bookmarks[0].obj->SetNewFor<CPDF_Reference>("Last", m_pIndirectObjs,
+ bookmarks[0].obj->SetNewFor<CPDF_Reference>("Last", m_pIndirectObjs.Get(),
bookmarks[2].num);
- m_pRootObj->SetNewFor<CPDF_Reference>("Outlines", m_pIndirectObjs,
+ m_pRootObj->SetNewFor<CPDF_Reference>("Outlines", m_pIndirectObjs.Get(),
bookmarks[0].num);
// Title with no match.
@@ -194,31 +194,31 @@ TEST_F(PDFDocTest, FindBookmark) {
auto bookmarks = CreateDictObjs(4);
bookmarks[1].obj->SetNewFor<CPDF_String>("Title", L"Chapter 1");
- bookmarks[1].obj->SetNewFor<CPDF_Reference>("Parent", m_pIndirectObjs,
+ bookmarks[1].obj->SetNewFor<CPDF_Reference>("Parent", m_pIndirectObjs.Get(),
bookmarks[0].num);
- bookmarks[1].obj->SetNewFor<CPDF_Reference>("Next", m_pIndirectObjs,
+ bookmarks[1].obj->SetNewFor<CPDF_Reference>("Next", m_pIndirectObjs.Get(),
bookmarks[2].num);
bookmarks[2].obj->SetNewFor<CPDF_String>("Title", L"Chapter 2");
- bookmarks[2].obj->SetNewFor<CPDF_Reference>("Parent", m_pIndirectObjs,
+ bookmarks[2].obj->SetNewFor<CPDF_Reference>("Parent", m_pIndirectObjs.Get(),
bookmarks[0].num);
- bookmarks[2].obj->SetNewFor<CPDF_Reference>("Next", m_pIndirectObjs,
+ bookmarks[2].obj->SetNewFor<CPDF_Reference>("Next", m_pIndirectObjs.Get(),
bookmarks[3].num);
bookmarks[3].obj->SetNewFor<CPDF_String>("Title", L"Chapter 3");
- bookmarks[3].obj->SetNewFor<CPDF_Reference>("Parent", m_pIndirectObjs,
+ bookmarks[3].obj->SetNewFor<CPDF_Reference>("Parent", m_pIndirectObjs.Get(),
bookmarks[0].num);
- bookmarks[3].obj->SetNewFor<CPDF_Reference>("Next", m_pIndirectObjs,
+ bookmarks[3].obj->SetNewFor<CPDF_Reference>("Next", m_pIndirectObjs.Get(),
bookmarks[1].num);
bookmarks[0].obj->SetNewFor<CPDF_Name>("Type", "Outlines");
bookmarks[0].obj->SetNewFor<CPDF_Number>("Count", 2);
- bookmarks[0].obj->SetNewFor<CPDF_Reference>("First", m_pIndirectObjs,
+ bookmarks[0].obj->SetNewFor<CPDF_Reference>("First", m_pIndirectObjs.Get(),
bookmarks[1].num);
- bookmarks[0].obj->SetNewFor<CPDF_Reference>("Last", m_pIndirectObjs,
+ bookmarks[0].obj->SetNewFor<CPDF_Reference>("Last", m_pIndirectObjs.Get(),
bookmarks[2].num);
- m_pRootObj->SetNewFor<CPDF_Reference>("Outlines", m_pIndirectObjs,
+ m_pRootObj->SetNewFor<CPDF_Reference>("Outlines", m_pIndirectObjs.Get(),
bookmarks[0].num);
// Title with no match.
diff --git a/fpdfsdk/fxedit/fxet_edit.cpp b/fpdfsdk/fxedit/fxet_edit.cpp
index cf4fdc3d91..0e86562044 100644
--- a/fpdfsdk/fxedit/fxet_edit.cpp
+++ b/fpdfsdk/fxedit/fxet_edit.cpp
@@ -145,7 +145,7 @@ CFX_Edit_Provider::CFX_Edit_Provider(IPVT_FontMap* pFontMap)
CFX_Edit_Provider::~CFX_Edit_Provider() {}
-IPVT_FontMap* CFX_Edit_Provider::GetFontMap() {
+IPVT_FontMap* CFX_Edit_Provider::GetFontMap() const {
return m_pFontMap;
}
diff --git a/fpdfsdk/fxedit/fxet_edit.h b/fpdfsdk/fxedit/fxet_edit.h
index ebc326f5a9..01759aaba9 100644
--- a/fpdfsdk/fxedit/fxet_edit.h
+++ b/fpdfsdk/fxedit/fxet_edit.h
@@ -13,6 +13,7 @@
#include "core/fpdfdoc/cpvt_secprops.h"
#include "core/fpdfdoc/cpvt_wordprops.h"
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "fpdfsdk/fxedit/fx_edit.h"
class CFFL_FormFiller;
@@ -158,7 +159,7 @@ class CFXEU_InsertWord : public CFX_Edit_UndoItem {
void Undo() override;
private:
- CFX_Edit* m_pEdit;
+ CFX_UnownedPtr<CFX_Edit> m_pEdit;
CPVT_WordPlace m_wpOld;
CPVT_WordPlace m_wpNew;
@@ -181,7 +182,7 @@ class CFXEU_InsertReturn : public CFX_Edit_UndoItem {
void Undo() override;
private:
- CFX_Edit* m_pEdit;
+ CFX_UnownedPtr<CFX_Edit> m_pEdit;
CPVT_WordPlace m_wpOld;
CPVT_WordPlace m_wpNew;
@@ -205,7 +206,7 @@ class CFXEU_Backspace : public CFX_Edit_UndoItem {
void Undo() override;
private:
- CFX_Edit* m_pEdit;
+ CFX_UnownedPtr<CFX_Edit> m_pEdit;
CPVT_WordPlace m_wpOld;
CPVT_WordPlace m_wpNew;
@@ -232,7 +233,7 @@ class CFXEU_Delete : public CFX_Edit_UndoItem {
void Undo() override;
private:
- CFX_Edit* m_pEdit;
+ CFX_UnownedPtr<CFX_Edit> m_pEdit;
CPVT_WordPlace m_wpOld;
CPVT_WordPlace m_wpNew;
@@ -255,7 +256,7 @@ class CFXEU_Clear : public CFX_Edit_UndoItem {
void Undo() override;
private:
- CFX_Edit* m_pEdit;
+ CFX_UnownedPtr<CFX_Edit> m_pEdit;
CPVT_WordRange m_wrSel;
CFX_WideString m_swText;
@@ -275,7 +276,7 @@ class CFXEU_InsertText : public CFX_Edit_UndoItem {
void Undo() override;
private:
- CFX_Edit* m_pEdit;
+ CFX_UnownedPtr<CFX_Edit> m_pEdit;
CPVT_WordPlace m_wpOld;
CPVT_WordPlace m_wpNew;
@@ -449,8 +450,8 @@ class CFX_Edit {
private:
std::unique_ptr<CPDF_VariableText> m_pVT;
- CPWL_EditCtrl* m_pNotify;
- CPWL_Edit* m_pOprNotify;
+ CFX_UnownedPtr<CPWL_EditCtrl> m_pNotify;
+ CFX_UnownedPtr<CPWL_Edit> m_pOprNotify;
std::unique_ptr<CFX_Edit_Provider> m_pVTProvider;
CPVT_WordPlace m_wpCaret;
CPVT_WordPlace m_wpOldCaret;
@@ -485,7 +486,7 @@ class CFX_Edit_Iterator {
const CPVT_WordPlace& GetAt() const;
private:
- CFX_Edit* m_pEdit;
+ CFX_UnownedPtr<CFX_Edit> m_pEdit;
CPDF_VariableText::Iterator* m_pVTIterator;
};
@@ -494,7 +495,7 @@ class CFX_Edit_Provider : public CPDF_VariableText::Provider {
explicit CFX_Edit_Provider(IPVT_FontMap* pFontMap);
~CFX_Edit_Provider() override;
- IPVT_FontMap* GetFontMap();
+ IPVT_FontMap* GetFontMap() const;
// CPDF_VariableText::Provider:
int32_t GetCharWidth(int32_t nFontIndex, uint16_t word) override;
diff --git a/fpdfsdk/fxedit/fxet_list.cpp b/fpdfsdk/fxedit/fxet_list.cpp
index c8fef948af..a3badf32fb 100644
--- a/fpdfsdk/fxedit/fxet_list.cpp
+++ b/fpdfsdk/fxedit/fxet_list.cpp
@@ -590,7 +590,7 @@ void CFX_ListCtrl::SetFontSize(float fFontSize) {
void CFX_ListCtrl::AddItem(const CFX_WideString& str) {
auto pListItem = pdfium::MakeUnique<CFX_ListItem>();
- pListItem->SetFontMap(m_pFontMap);
+ pListItem->SetFontMap(m_pFontMap.Get());
pListItem->SetFontSize(m_fFontSize);
pListItem->SetText(str);
m_ListItems.push_back(std::move(pListItem));
diff --git a/fpdfsdk/fxedit/fxet_list.h b/fpdfsdk/fxedit/fxet_list.h
index cd6e2ddeff..b4b0a56c1e 100644
--- a/fpdfsdk/fxedit/fxet_list.h
+++ b/fpdfsdk/fxedit/fxet_list.h
@@ -11,6 +11,7 @@
#include <memory>
#include <vector>
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_coordinates.h"
#include "fpdfsdk/fxedit/fx_edit.h"
@@ -263,7 +264,7 @@ class CFX_ListCtrl : protected CFX_ListContainer {
void SetItemSelect(int32_t nItemIndex, bool bSelected);
int32_t GetLastSelected() const;
- CPWL_List_Notify* m_pNotify;
+ CFX_UnownedPtr<CPWL_List_Notify> m_pNotify;
bool m_bNotifyFlag;
CFX_PointF m_ptScrollPos;
CPLST_Select m_aSelItems; // for multiple
@@ -273,7 +274,7 @@ class CFX_ListCtrl : protected CFX_ListContainer {
int32_t m_nCaretIndex; // for multiple
std::vector<std::unique_ptr<CFX_ListItem>> m_ListItems;
float m_fFontSize;
- IPVT_FontMap* m_pFontMap;
+ CFX_UnownedPtr<IPVT_FontMap> m_pFontMap;
bool m_bMultiple;
};
diff --git a/fpdfsdk/javascript/JS_EventHandler.h b/fpdfsdk/javascript/JS_EventHandler.h
index 5dcb70b4c8..82d9d6a93b 100644
--- a/fpdfsdk/javascript/JS_EventHandler.h
+++ b/fpdfsdk/javascript/JS_EventHandler.h
@@ -172,7 +172,7 @@ class CJS_EventHandler {
CFX_WideString m_strTargetName;
CFX_WideString m_strSourceName;
- CFX_WideString* m_pWideStrChange;
+ CFX_UnownedPtr<CFX_WideString> m_pWideStrChange;
CFX_WideString m_WideStrChangeDu;
CFX_WideString m_WideStrChangeEx;
int m_nCommitKey;
@@ -184,12 +184,12 @@ class CJS_EventHandler {
int* m_pISelStart;
int m_nSelStartDu;
bool m_bWillCommit;
- CFX_WideString* m_pValue;
+ CFX_UnownedPtr<CFX_WideString> m_pValue;
bool m_bFieldFull;
bool* m_pbRc;
bool m_bRcDu;
- CPDF_Bookmark* m_pTargetBookMark;
+ CFX_UnownedPtr<CPDF_Bookmark> m_pTargetBookMark;
CPDFSDK_FormFillEnvironment::ObservedPtr m_pTargetFormFillEnv;
CPDFSDK_Annot::ObservedPtr m_pTargetAnnot;
};
diff --git a/fpdfsdk/pdfwindow/PWL_ComboBox.h b/fpdfsdk/pdfwindow/PWL_ComboBox.h
index 0dfb3bd86b..27cdb61b1a 100644
--- a/fpdfsdk/pdfwindow/PWL_ComboBox.h
+++ b/fpdfsdk/pdfwindow/PWL_ComboBox.h
@@ -52,7 +52,7 @@ class CPWL_ComboBox : public CPWL_Wnd {
CPWL_ComboBox();
~CPWL_ComboBox() override;
- CPWL_Edit* GetEdit() const { return m_pEdit; }
+ CPWL_Edit* GetEdit() const { return m_pEdit.Get(); }
// CPWL_Wnd:
CFX_ByteString GetClassName() const override;
@@ -93,14 +93,14 @@ class CPWL_ComboBox : public CPWL_Wnd {
void CreateListBox(const PWL_CREATEPARAM& cp);
void SetPopup(bool bPopup);
- CPWL_CBEdit* m_pEdit;
- CPWL_CBButton* m_pButton;
- CPWL_CBListBox* m_pList;
+ CFX_UnownedPtr<CPWL_CBEdit> m_pEdit;
+ CFX_UnownedPtr<CPWL_CBButton> m_pButton;
+ CFX_UnownedPtr<CPWL_CBListBox> m_pList;
bool m_bPopup;
CFX_FloatRect m_rcOldWindow;
int32_t m_nPopupWhere;
int32_t m_nSelectItem;
- IPWL_Filler_Notify* m_pFillerNotify;
+ CFX_UnownedPtr<IPWL_Filler_Notify> m_pFillerNotify;
CFX_UnownedPtr<CFFL_FormFiller> m_pFormFiller;
};
diff --git a/fpdfsdk/pdfwindow/PWL_Edit.h b/fpdfsdk/pdfwindow/PWL_Edit.h
index bd3799141a..82c1f19629 100644
--- a/fpdfsdk/pdfwindow/PWL_Edit.h
+++ b/fpdfsdk/pdfwindow/PWL_Edit.h
@@ -134,7 +134,7 @@ class CPWL_Edit : public CPWL_EditCtrl {
CPVT_WordRange GetSameWordsRange(const CPVT_WordPlace& place,
bool bLatin,
bool bArabic) const;
- IPWL_Filler_Notify* m_pFillerNotify;
+ CFX_UnownedPtr<IPWL_Filler_Notify> m_pFillerNotify;
bool m_bFocus;
CFX_FloatRect m_rcOldWindow;
CFX_UnownedPtr<CFFL_FormFiller> m_pFormFiller;
diff --git a/fpdfsdk/pdfwindow/PWL_Icon.cpp b/fpdfsdk/pdfwindow/PWL_Icon.cpp
index 3ae7244552..e1397bff0c 100644
--- a/fpdfsdk/pdfwindow/PWL_Icon.cpp
+++ b/fpdfsdk/pdfwindow/PWL_Icon.cpp
@@ -55,8 +55,8 @@ void CPWL_Image::SetPDFStream(CPDF_Stream* pStream) {
m_pPDFStream = pStream;
}
-CPDF_Stream* CPWL_Image::GetPDFStream() {
- return m_pPDFStream;
+CPDF_Stream* CPWL_Image::GetPDFStream() const {
+ return m_pPDFStream.Get();
}
void CPWL_Image::GetImageSize(float& fWidth, float& fHeight) {
@@ -114,8 +114,8 @@ CPWL_Icon::CPWL_Icon() : m_pIconFit(nullptr) {}
CPWL_Icon::~CPWL_Icon() {}
-CPDF_IconFit* CPWL_Icon::GetIconFit() {
- return m_pIconFit;
+CPDF_IconFit* CPWL_Icon::GetIconFit() const {
+ return m_pIconFit.Get();
}
int32_t CPWL_Icon::GetScaleMethod() {
diff --git a/fpdfsdk/pdfwindow/PWL_Icon.h b/fpdfsdk/pdfwindow/PWL_Icon.h
index 49ac1f3f3d..c5d116be69 100644
--- a/fpdfsdk/pdfwindow/PWL_Icon.h
+++ b/fpdfsdk/pdfwindow/PWL_Icon.h
@@ -7,6 +7,7 @@
#ifndef FPDFSDK_PDFWINDOW_PWL_ICON_H_
#define FPDFSDK_PDFWINDOW_PWL_ICON_H_
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_string.h"
#include "fpdfsdk/pdfwindow/PWL_Wnd.h"
@@ -19,7 +20,7 @@ class CPWL_Image : public CPWL_Wnd {
virtual void GetScale(float& fHScale, float& fVScale);
virtual void GetImageOffset(float& x, float& y);
- virtual CPDF_Stream* GetPDFStream();
+ virtual CPDF_Stream* GetPDFStream() const;
public:
void SetPDFStream(CPDF_Stream* pStream);
@@ -29,7 +30,7 @@ class CPWL_Image : public CPWL_Wnd {
void SetImageAlias(const char* sImageAlias);
protected:
- CPDF_Stream* m_pPDFStream;
+ CFX_UnownedPtr<CPDF_Stream> m_pPDFStream;
CFX_ByteString m_sImageAlias;
};
@@ -38,7 +39,7 @@ class CPWL_Icon : public CPWL_Image {
CPWL_Icon();
~CPWL_Icon() override;
- virtual CPDF_IconFit* GetIconFit();
+ virtual CPDF_IconFit* GetIconFit() const;
// CPWL_Image
void GetScale(float& fHScale, float& fVScale) override;
@@ -51,7 +52,7 @@ class CPWL_Icon : public CPWL_Image {
void SetIconFit(CPDF_IconFit* pIconFit) { m_pIconFit = pIconFit; }
private:
- CPDF_IconFit* m_pIconFit;
+ CFX_UnownedPtr<CPDF_IconFit> m_pIconFit;
};
#endif // FPDFSDK_PDFWINDOW_PWL_ICON_H_
diff --git a/fpdfsdk/pdfwindow/PWL_ListBox.cpp b/fpdfsdk/pdfwindow/PWL_ListBox.cpp
index b682959426..09487c3314 100644
--- a/fpdfsdk/pdfwindow/PWL_ListBox.cpp
+++ b/fpdfsdk/pdfwindow/PWL_ListBox.cpp
@@ -36,7 +36,8 @@ void CPWL_List_Notify::IOnSetScrollInfoY(float fPlateMin,
Info.fSmallStep = fSmallStep;
Info.fBigStep = fBigStep;
- m_pList->OnNotify(m_pList, PNM_SETSCROLLINFO, SBT_VSCROLL, (intptr_t)&Info);
+ m_pList->OnNotify(m_pList.Get(), PNM_SETSCROLLINFO, SBT_VSCROLL,
+ reinterpret_cast<intptr_t>(&Info));
if (CPWL_ScrollBar* pScroll = m_pList->GetVScrollBar()) {
if (IsFloatBigger(Info.fPlateWidth, Info.fContentMax - Info.fContentMin) ||
@@ -55,7 +56,8 @@ void CPWL_List_Notify::IOnSetScrollInfoY(float fPlateMin,
}
void CPWL_List_Notify::IOnSetScrollPosY(float fy) {
- m_pList->OnNotify(m_pList, PNM_SETSCROLLPOS, SBT_VSCROLL, (intptr_t)&fy);
+ m_pList->OnNotify(m_pList.Get(), PNM_SETSCROLLPOS, SBT_VSCROLL,
+ reinterpret_cast<intptr_t>(&fy));
}
void CPWL_List_Notify::IOnInvalidateRect(CFX_FloatRect* pRect) {
diff --git a/fpdfsdk/pdfwindow/PWL_ListBox.h b/fpdfsdk/pdfwindow/PWL_ListBox.h
index 0de9c91195..75d23bb7c6 100644
--- a/fpdfsdk/pdfwindow/PWL_ListBox.h
+++ b/fpdfsdk/pdfwindow/PWL_ListBox.h
@@ -41,7 +41,7 @@ class CPWL_List_Notify {
const CPVT_WordPlace& place);
private:
- CPWL_ListBox* m_pList;
+ CFX_UnownedPtr<CPWL_ListBox> m_pList;
};
class CPWL_ListBox : public CPWL_Wnd {
@@ -109,7 +109,7 @@ class CPWL_ListBox : public CPWL_Wnd {
std::unique_ptr<CPWL_List_Notify> m_pListNotify;
bool m_bMouseDown;
bool m_bHoverSel;
- IPWL_Filler_Notify* m_pFillerNotify;
+ CFX_UnownedPtr<IPWL_Filler_Notify> m_pFillerNotify;
private:
CFX_UnownedPtr<CFFL_FormFiller> m_pFormFiller;
diff --git a/fpdfsdk/pdfwindow/PWL_ScrollBar.h b/fpdfsdk/pdfwindow/PWL_ScrollBar.h
index 50b0801ca3..41df6550e0 100644
--- a/fpdfsdk/pdfwindow/PWL_ScrollBar.h
+++ b/fpdfsdk/pdfwindow/PWL_ScrollBar.h
@@ -7,6 +7,7 @@
#ifndef FPDFSDK_PDFWINDOW_PWL_SCROLLBAR_H_
#define FPDFSDK_PDFWINDOW_PWL_SCROLLBAR_H_
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "fpdfsdk/pdfwindow/PWL_Wnd.h"
class CPWL_SBButton;
@@ -169,9 +170,9 @@ class CPWL_ScrollBar : public CPWL_Wnd {
PWL_SCROLLBAR_TYPE m_sbType;
PWL_SCROLL_INFO m_OriginInfo;
- CPWL_SBButton* m_pMinButton;
- CPWL_SBButton* m_pMaxButton;
- CPWL_SBButton* m_pPosButton;
+ CFX_UnownedPtr<CPWL_SBButton> m_pMinButton;
+ CFX_UnownedPtr<CPWL_SBButton> m_pMaxButton;
+ CFX_UnownedPtr<CPWL_SBButton> m_pPosButton;
PWL_SCROLL_PRIVATEDATA m_sData;
bool m_bMouseDown;
bool m_bMinOrMax;
diff --git a/fpdfsdk/pdfwindow/PWL_Wnd.cpp b/fpdfsdk/pdfwindow/PWL_Wnd.cpp
index 5523c59317..1db79b4bc7 100644
--- a/fpdfsdk/pdfwindow/PWL_Wnd.cpp
+++ b/fpdfsdk/pdfwindow/PWL_Wnd.cpp
@@ -180,9 +180,9 @@ class CPWL_MsgControl {
private:
std::vector<CPWL_Wnd*> m_aMousePath;
std::vector<CPWL_Wnd*> m_aKeyboardPath;
- CPWL_Wnd* m_pCreatedWnd;
- CPWL_Wnd* m_pMainMouseWnd;
- CPWL_Wnd* m_pMainKeyboardWnd;
+ CFX_UnownedPtr<CPWL_Wnd> m_pCreatedWnd;
+ CFX_UnownedPtr<CPWL_Wnd> m_pMainMouseWnd;
+ CFX_UnownedPtr<CPWL_Wnd> m_pMainKeyboardWnd;
};
CPWL_Wnd::CPWL_Wnd()
@@ -594,10 +594,7 @@ void* CPWL_Wnd::GetAttachedData() const {
}
CPWL_ScrollBar* CPWL_Wnd::GetVScrollBar() const {
- if (HasFlag(PWS_VSCROLL))
- return m_pVScrollBar;
-
- return nullptr;
+ return HasFlag(PWS_VSCROLL) ? m_pVScrollBar.Get() : nullptr;
}
void CPWL_Wnd::CreateScrollBar(const PWL_CREATEPARAM& cp) {
@@ -885,7 +882,7 @@ void CPWL_Wnd::SetChildMatrix(const CFX_Matrix& mt) {
const CPWL_Wnd* CPWL_Wnd::GetFocused() const {
CPWL_MsgControl* pMsgCtrl = GetMsgControl();
- return pMsgCtrl ? pMsgCtrl->m_pMainKeyboardWnd : nullptr;
+ return pMsgCtrl ? pMsgCtrl->m_pMainKeyboardWnd.Get() : nullptr;
}
void CPWL_Wnd::EnableWindow(bool bEnable) {
diff --git a/fpdfsdk/pdfwindow/PWL_Wnd.h b/fpdfsdk/pdfwindow/PWL_Wnd.h
index ded003c31b..59de290653 100644
--- a/fpdfsdk/pdfwindow/PWL_Wnd.h
+++ b/fpdfsdk/pdfwindow/PWL_Wnd.h
@@ -12,6 +12,7 @@
#include "core/fpdfdoc/cpdf_formcontrol.h"
#include "core/fxcrt/cfx_observable.h"
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_basic.h"
#include "fpdfsdk/cfx_systemhandler.h"
#include "fpdfsdk/cpdfsdk_widget.h"
@@ -224,8 +225,8 @@ class CPWL_Timer {
private:
int32_t m_nTimerID;
- CPWL_TimerHandler* m_pAttached;
- CFX_SystemHandler* m_pSystemHandler;
+ CFX_UnownedPtr<CPWL_TimerHandler> m_pAttached;
+ CFX_UnownedPtr<CFX_SystemHandler> m_pSystemHandler;
};
class CPWL_TimerHandler {
@@ -398,7 +399,7 @@ class CPWL_Wnd : public CPWL_TimerHandler {
std::vector<CPWL_Wnd*> m_Children;
PWL_CREATEPARAM m_sPrivateParam;
- CPWL_ScrollBar* m_pVScrollBar;
+ CFX_UnownedPtr<CPWL_ScrollBar> m_pVScrollBar;
CFX_FloatRect m_rcWindow;
CFX_FloatRect m_rcClip;
bool m_bCreated;
diff --git a/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp b/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
index 5c26188f53..ef83691d4f 100644
--- a/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
+++ b/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
@@ -106,7 +106,7 @@ int32_t CBC_ReedSolomonGF256Poly::EvaluateAt(int32_t a) {
std::unique_ptr<CBC_ReedSolomonGF256Poly> CBC_ReedSolomonGF256Poly::Clone()
const {
auto temp = pdfium::MakeUnique<CBC_ReedSolomonGF256Poly>();
- if (!temp->Init(m_field, &m_coefficients))
+ if (!temp->Init(m_field.Get(), &m_coefficients))
return nullptr;
return temp;
}
@@ -133,7 +133,7 @@ CBC_ReedSolomonGF256Poly::AddOrSubtract(const CBC_ReedSolomonGF256Poly* other) {
smallerCoefficients[j - lengthDiff], largerCoefficients[j]);
}
auto temp = pdfium::MakeUnique<CBC_ReedSolomonGF256Poly>();
- if (!temp->Init(m_field, &sumDiff))
+ if (!temp->Init(m_field.Get(), &sumDiff))
return nullptr;
return temp;
}
@@ -156,7 +156,7 @@ std::unique_ptr<CBC_ReedSolomonGF256Poly> CBC_ReedSolomonGF256Poly::Multiply(
}
}
auto temp = pdfium::MakeUnique<CBC_ReedSolomonGF256Poly>();
- if (!temp->Init(m_field, &product))
+ if (!temp->Init(m_field.Get(), &product))
return nullptr;
return temp;
}
@@ -174,7 +174,7 @@ std::unique_ptr<CBC_ReedSolomonGF256Poly> CBC_ReedSolomonGF256Poly::Multiply(
product[i] = m_field->Multiply(m_coefficients[i], scalar);
auto temp = pdfium::MakeUnique<CBC_ReedSolomonGF256Poly>();
- if (!temp->Init(m_field, &product))
+ if (!temp->Init(m_field.Get(), &product))
return nullptr;
return temp;
}
@@ -193,7 +193,7 @@ CBC_ReedSolomonGF256Poly::MultiplyByMonomial(int32_t degree,
product[i] = m_field->Multiply(m_coefficients[i], coefficient);
auto temp = pdfium::MakeUnique<CBC_ReedSolomonGF256Poly>();
- if (!temp->Init(m_field, &product))
+ if (!temp->Init(m_field.Get(), &product))
return nullptr;
return temp;
}
diff --git a/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h b/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h
index ce8a572704..f7aea2bf53 100644
--- a/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h
+++ b/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h
@@ -40,7 +40,7 @@ class CBC_ReedSolomonGF256Poly final {
std::unique_ptr<CBC_ReedSolomonGF256Poly> Clone() const;
private:
- CBC_ReedSolomonGF256* m_field;
+ CFX_UnownedPtr<CBC_ReedSolomonGF256> m_field;
std::vector<int32_t> m_coefficients;
};
diff --git a/fxbarcode/datamatrix/BC_EncoderContext.h b/fxbarcode/datamatrix/BC_EncoderContext.h
index 6cb2b42fa9..21ea695c3d 100644
--- a/fxbarcode/datamatrix/BC_EncoderContext.h
+++ b/fxbarcode/datamatrix/BC_EncoderContext.h
@@ -7,6 +7,7 @@
#ifndef FXBARCODE_DATAMATRIX_BC_ENCODERCONTEXT_H_
#define FXBARCODE_DATAMATRIX_BC_ENCODERCONTEXT_H_
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/cfx_widestring.h"
#include "fxbarcode/datamatrix/BC_SymbolShapeHint.h"
@@ -38,7 +39,7 @@ class CBC_EncoderContext {
CFX_WideString m_codewords;
int32_t m_pos;
int32_t m_newEncoding;
- CBC_SymbolInfo* m_symbolInfo;
+ CFX_UnownedPtr<CBC_SymbolInfo> m_symbolInfo;
private:
int32_t getTotalMessageCharCount();
diff --git a/fxbarcode/oned/BC_OneDimWriter.cpp b/fxbarcode/oned/BC_OneDimWriter.cpp
index a7539e4897..22cc09513f 100644
--- a/fxbarcode/oned/BC_OneDimWriter.cpp
+++ b/fxbarcode/oned/BC_OneDimWriter.cpp
@@ -197,7 +197,7 @@ void CBC_OneDimWriter::ShowDeviceChars(CFX_RenderDevice* device,
if (matrix) {
affine_matrix.Concat(*matrix);
}
- device->DrawNormalText(str.GetLength(), pCharPos, m_pFont,
+ device->DrawNormalText(str.GetLength(), pCharPos, m_pFont.Get(),
static_cast<float>(iFontSize), &affine_matrix,
m_fontColor, FXTEXT_CLEARTYPE);
}
@@ -224,7 +224,8 @@ bool CBC_OneDimWriter::ShowChars(const CFX_WideStringC& contents,
}
int32_t iFontSize = (int32_t)fabs(m_fFontSize);
int32_t iTextHeight = iFontSize + 1;
- CalcTextInfo(str, charpos.data(), m_pFont, geWidth, iFontSize, charsLen);
+ CalcTextInfo(str, charpos.data(), m_pFont.Get(), geWidth, iFontSize,
+ charsLen);
if (charsLen < 1)
return true;
diff --git a/fxbarcode/oned/BC_OneDimWriter.h b/fxbarcode/oned/BC_OneDimWriter.h
index 3bd1b611c6..d81a3e0a0a 100644
--- a/fxbarcode/oned/BC_OneDimWriter.h
+++ b/fxbarcode/oned/BC_OneDimWriter.h
@@ -10,6 +10,7 @@
#include <memory>
#include <vector>
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxge/cfx_renderdevice.h"
#include "fxbarcode/BC_Library.h"
#include "fxbarcode/BC_Writer.h"
@@ -86,7 +87,7 @@ class CBC_OneDimWriter : public CBC_Writer {
bool m_bPrintChecksum;
int32_t m_iDataLenth;
bool m_bCalcChecksum;
- CFX_Font* m_pFont;
+ CFX_UnownedPtr<CFX_Font> m_pFont;
float m_fFontSize;
int32_t m_iFontStyle;
uint32_t m_fontColor;
diff --git a/fxbarcode/oned/BC_OnedEAN13Writer.cpp b/fxbarcode/oned/BC_OnedEAN13Writer.cpp
index bae43b464e..0e4bab9518 100644
--- a/fxbarcode/oned/BC_OnedEAN13Writer.cpp
+++ b/fxbarcode/oned/BC_OnedEAN13Writer.cpp
@@ -192,7 +192,7 @@ bool CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents,
iLen = tempStr.GetLength();
strWidth = (int32_t)(strWidth * m_outputHScale);
- CalcTextInfo(tempStr, &charpos[1], m_pFont, (float)strWidth, iFontSize,
+ CalcTextInfo(tempStr, &charpos[1], m_pFont.Get(), (float)strWidth, iFontSize,
blank);
{
CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0,
@@ -200,13 +200,13 @@ bool CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents,
(float)(m_Height - iTextHeight) + iFontSize);
if (matrix)
affine_matrix1.Concat(*matrix);
- device->DrawNormalText(iLen, &charpos[1], m_pFont,
+ device->DrawNormalText(iLen, &charpos[1], m_pFont.Get(),
static_cast<float>(iFontSize), &affine_matrix1,
m_fontColor, FXTEXT_CLEARTYPE);
}
tempStr = str.Mid(7, 6);
iLen = tempStr.GetLength();
- CalcTextInfo(tempStr, &charpos[7], m_pFont, (float)strWidth, iFontSize,
+ CalcTextInfo(tempStr, &charpos[7], m_pFont.Get(), (float)strWidth, iFontSize,
blank);
{
CFX_Matrix affine_matrix1(
@@ -215,7 +215,7 @@ bool CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents,
(float)(m_Height - iTextHeight + iFontSize));
if (matrix)
affine_matrix1.Concat(*matrix);
- device->DrawNormalText(iLen, &charpos[7], m_pFont,
+ device->DrawNormalText(iLen, &charpos[7], m_pFont.Get(),
static_cast<float>(iFontSize), &affine_matrix1,
m_fontColor, FXTEXT_CLEARTYPE);
}
@@ -224,14 +224,14 @@ bool CBC_OnedEAN13Writer::ShowChars(const CFX_WideStringC& contents,
strWidth = multiple * 7;
strWidth = (int32_t)(strWidth * m_outputHScale);
- CalcTextInfo(tempStr, charpos.data(), m_pFont, (float)strWidth, iFontSize,
- blank);
+ CalcTextInfo(tempStr, charpos.data(), m_pFont.Get(), (float)strWidth,
+ iFontSize, blank);
{
CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, 0.0,
(float)(m_Height - iTextHeight + iFontSize));
if (matrix)
affine_matrix1.Concat(*matrix);
- device->DrawNormalText(iLen, charpos.data(), m_pFont,
+ device->DrawNormalText(iLen, charpos.data(), m_pFont.Get(),
static_cast<float>(iFontSize), &affine_matrix1,
m_fontColor, FXTEXT_CLEARTYPE);
}
diff --git a/fxbarcode/oned/BC_OnedEAN8Writer.cpp b/fxbarcode/oned/BC_OnedEAN8Writer.cpp
index 49d77b72c4..f891c08fc6 100644
--- a/fxbarcode/oned/BC_OnedEAN8Writer.cpp
+++ b/fxbarcode/oned/BC_OnedEAN8Writer.cpp
@@ -184,20 +184,20 @@ bool CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents,
device->FillRect(&re, m_backgroundColor);
strWidth = (int32_t)(strWidth * m_outputHScale);
- CalcTextInfo(tempStr, charpos.data(), m_pFont, (float)strWidth, iFontSize,
- blank);
+ CalcTextInfo(tempStr, charpos.data(), m_pFont.Get(), (float)strWidth,
+ iFontSize, blank);
{
CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0,
(float)leftPosition * m_outputHScale,
(float)(m_Height - iTextHeight + iFontSize));
affine_matrix1.Concat(*matrix);
- device->DrawNormalText(iLen, charpos.data(), m_pFont,
+ device->DrawNormalText(iLen, charpos.data(), m_pFont.Get(),
static_cast<float>(iFontSize), &affine_matrix1,
m_fontColor, FXTEXT_CLEARTYPE);
}
tempStr = str.Mid(4, 4);
iLen = tempStr.GetLength();
- CalcTextInfo(tempStr, &charpos[4], m_pFont, (float)strWidth, iFontSize,
+ CalcTextInfo(tempStr, &charpos[4], m_pFont.Get(), (float)strWidth, iFontSize,
blank);
{
CFX_Matrix affine_matrix1(
@@ -206,7 +206,7 @@ bool CBC_OnedEAN8Writer::ShowChars(const CFX_WideStringC& contents,
(float)(m_Height - iTextHeight + iFontSize));
if (matrix)
affine_matrix1.Concat(*matrix);
- device->DrawNormalText(iLen, &charpos[4], m_pFont,
+ device->DrawNormalText(iLen, &charpos[4], m_pFont.Get(),
static_cast<float>(iFontSize), &affine_matrix1,
m_fontColor, FXTEXT_CLEARTYPE);
}
diff --git a/fxbarcode/oned/BC_OnedUPCAWriter.cpp b/fxbarcode/oned/BC_OnedUPCAWriter.cpp
index 614268e742..78ada1783a 100644
--- a/fxbarcode/oned/BC_OnedUPCAWriter.cpp
+++ b/fxbarcode/oned/BC_OnedUPCAWriter.cpp
@@ -158,20 +158,20 @@ bool CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents,
device->FillRect(&re, m_backgroundColor);
strWidth = strWidth * m_outputHScale;
- CalcTextInfo(tempStr, &charpos[1], m_pFont, strWidth, iFontSize, blank);
+ CalcTextInfo(tempStr, &charpos[1], m_pFont.Get(), strWidth, iFontSize, blank);
{
CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0,
(float)leftPosition * m_outputHScale,
(float)(m_Height - iTextHeight + iFontSize));
if (matrix)
affine_matrix1.Concat(*matrix);
- device->DrawNormalText(iLen, &charpos[1], m_pFont,
+ device->DrawNormalText(iLen, &charpos[1], m_pFont.Get(),
static_cast<float>(iFontSize), &affine_matrix1,
m_fontColor, FXTEXT_CLEARTYPE);
}
tempStr = str.Mid(6, 5);
iLen = tempStr.GetLength();
- CalcTextInfo(tempStr, &charpos[6], m_pFont, strWidth, iFontSize, blank);
+ CalcTextInfo(tempStr, &charpos[6], m_pFont.Get(), strWidth, iFontSize, blank);
{
CFX_Matrix affine_matrix1(
1.0, 0.0, 0.0, -1.0,
@@ -179,7 +179,7 @@ bool CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents,
(float)(m_Height - iTextHeight + iFontSize));
if (matrix)
affine_matrix1.Concat(*matrix);
- device->DrawNormalText(iLen, &charpos[6], m_pFont,
+ device->DrawNormalText(iLen, &charpos[6], m_pFont.Get(),
static_cast<float>(iFontSize), &affine_matrix1,
m_fontColor, FXTEXT_CLEARTYPE);
}
@@ -188,19 +188,21 @@ bool CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents,
strWidth = (float)multiple * 7;
strWidth = strWidth * m_outputHScale;
- CalcTextInfo(tempStr, charpos.data(), m_pFont, strWidth, iFontSize, blank);
+ CalcTextInfo(tempStr, charpos.data(), m_pFont.Get(), strWidth, iFontSize,
+ blank);
{
CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, 0,
(float)(m_Height - iTextHeight + iFontSize));
if (matrix)
affine_matrix1.Concat(*matrix);
- device->DrawNormalText(iLen, charpos.data(), m_pFont,
+ device->DrawNormalText(iLen, charpos.data(), m_pFont.Get(),
static_cast<float>(iFontSize), &affine_matrix1,
m_fontColor, FXTEXT_CLEARTYPE);
}
tempStr = str.Mid(11, 1);
iLen = tempStr.GetLength();
- CalcTextInfo(tempStr, &charpos[11], m_pFont, strWidth, iFontSize, blank);
+ CalcTextInfo(tempStr, &charpos[11], m_pFont.Get(), strWidth, iFontSize,
+ blank);
{
CFX_Matrix affine_matrix1(
1.0, 0.0, 0.0, -1.0,
@@ -208,7 +210,7 @@ bool CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents,
(float)(m_Height - iTextHeight + iFontSize));
if (matrix)
affine_matrix1.Concat(*matrix);
- device->DrawNormalText(iLen, &charpos[11], m_pFont,
+ device->DrawNormalText(iLen, &charpos[11], m_pFont.Get(),
static_cast<float>(iFontSize), &affine_matrix1,
m_fontColor, FXTEXT_CLEARTYPE);
}
diff --git a/fxbarcode/qrcode/BC_QRCoder.cpp b/fxbarcode/qrcode/BC_QRCoder.cpp
index e3ac763499..b0a24fa27c 100644
--- a/fxbarcode/qrcode/BC_QRCoder.cpp
+++ b/fxbarcode/qrcode/BC_QRCoder.cpp
@@ -42,11 +42,11 @@ CBC_QRCoder::CBC_QRCoder()
CBC_QRCoder::~CBC_QRCoder() {}
CBC_QRCoderMode* CBC_QRCoder::GetMode() const {
- return m_mode;
+ return m_mode.Get();
}
const CBC_QRCoderErrorCorrectionLevel* CBC_QRCoder::GetECLevel() const {
- return m_ecLevel;
+ return m_ecLevel.Get();
}
int32_t CBC_QRCoder::GetVersion() const {
diff --git a/fxbarcode/qrcode/BC_QRCoder.h b/fxbarcode/qrcode/BC_QRCoder.h
index adeae6c521..fe34b5250b 100644
--- a/fxbarcode/qrcode/BC_QRCoder.h
+++ b/fxbarcode/qrcode/BC_QRCoder.h
@@ -9,6 +9,8 @@
#include <memory>
+#include "core/fxcrt/cfx_unowned_ptr.h"
+
class CBC_QRCoderErrorCorrectionLevel;
class CBC_QRCoderMode;
class CBC_CommonByteMatrix;
@@ -48,8 +50,8 @@ class CBC_QRCoder {
void SetMatrix(std::unique_ptr<CBC_CommonByteMatrix> pMatrix);
private:
- CBC_QRCoderMode* m_mode;
- const CBC_QRCoderErrorCorrectionLevel* m_ecLevel;
+ CFX_UnownedPtr<CBC_QRCoderMode> m_mode;
+ CFX_UnownedPtr<const CBC_QRCoderErrorCorrectionLevel> m_ecLevel;
int32_t m_version;
int32_t m_matrixWidth;
int32_t m_maskPattern;
diff --git a/fxjs/cfxjse_arguments.cpp b/fxjs/cfxjse_arguments.cpp
index f406ba34de..363f39ce11 100644
--- a/fxjs/cfxjse_arguments.cpp
+++ b/fxjs/cfxjse_arguments.cpp
@@ -10,6 +10,13 @@
#include "fxjs/cfxjse_value.h"
#include "third_party/base/ptr_util.h"
+CFXJSE_Arguments::CFXJSE_Arguments(
+ const v8::FunctionCallbackInfo<v8::Value>* pInfo,
+ CFXJSE_Value* pRetValue)
+ : m_pInfo(pInfo), m_pRetValue(pRetValue) {}
+
+CFXJSE_Arguments::~CFXJSE_Arguments() {}
+
int32_t CFXJSE_Arguments::GetLength() const {
return m_pInfo->Length();
}
@@ -47,6 +54,6 @@ CFXJSE_HostObject* CFXJSE_Arguments::GetObject(int32_t index,
return FXJSE_RetrieveObjectBinding(hValue.As<v8::Object>(), pClass);
}
-CFXJSE_Value* CFXJSE_Arguments::GetReturnValue() {
- return m_pRetValue;
+CFXJSE_Value* CFXJSE_Arguments::GetReturnValue() const {
+ return m_pRetValue.Get();
}
diff --git a/fxjs/cfxjse_arguments.h b/fxjs/cfxjse_arguments.h
index beaf1525bb..9317d70898 100644
--- a/fxjs/cfxjse_arguments.h
+++ b/fxjs/cfxjse_arguments.h
@@ -9,14 +9,15 @@
#include <memory>
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "fxjs/cfxjse_class.h"
#include "fxjs/fxjse.h"
class CFXJSE_Arguments {
public:
CFXJSE_Arguments(const v8::FunctionCallbackInfo<v8::Value>* pInfo,
- CFXJSE_Value* pRetValue)
- : m_pInfo(pInfo), m_pRetValue(pRetValue) {}
+ CFXJSE_Value* pRetValue);
+ ~CFXJSE_Arguments();
int32_t GetLength() const;
std::unique_ptr<CFXJSE_Value> GetValue(int32_t index) const;
@@ -26,11 +27,11 @@ class CFXJSE_Arguments {
CFX_ByteString GetUTF8String(int32_t index) const;
CFXJSE_HostObject* GetObject(int32_t index,
CFXJSE_Class* pClass = nullptr) const;
- CFXJSE_Value* GetReturnValue();
+ CFXJSE_Value* GetReturnValue() const;
private:
const v8::FunctionCallbackInfo<v8::Value>* m_pInfo;
- CFXJSE_Value* m_pRetValue;
+ CFX_UnownedPtr<CFXJSE_Value> m_pRetValue;
};
#endif // FXJS_CFXJSE_ARGUMENTS_H_
diff --git a/fxjs/cfxjse_class.h b/fxjs/cfxjse_class.h
index 04354941fa..c3a5c84777 100644
--- a/fxjs/cfxjse_class.h
+++ b/fxjs/cfxjse_class.h
@@ -7,6 +7,7 @@
#ifndef FXJS_CFXJSE_CLASS_H_
#define FXJS_CFXJSE_CLASS_H_
+#include "core/fxcrt/cfx_unowned_ptr.h"
#include "fxjs/fxjse.h"
#include "v8/include/v8.h"
@@ -27,13 +28,13 @@ class CFXJSE_Class {
explicit CFXJSE_Class(CFXJSE_Context* lpContext);
~CFXJSE_Class();
- CFXJSE_Context* GetContext() const { return m_pContext; }
+ CFXJSE_Context* GetContext() const { return m_pContext.Get(); }
v8::Global<v8::FunctionTemplate>& GetTemplate() { return m_hTemplate; }
protected:
CFX_ByteString m_szClassName;
- const FXJSE_CLASS_DESCRIPTOR* m_lpClassDefinition;
- CFXJSE_Context* m_pContext;
+ CFX_UnownedPtr<const FXJSE_CLASS_DESCRIPTOR> m_lpClassDefinition;
+ CFX_UnownedPtr<CFXJSE_Context> m_pContext;
v8::Global<v8::FunctionTemplate> m_hTemplate;
friend class CFXJSE_Context;
friend class CFXJSE_Value;
diff --git a/fxjs/cfxjse_context.cpp b/fxjs/cfxjse_context.cpp
index 8696cee42f..40882bac56 100644
--- a/fxjs/cfxjse_context.cpp
+++ b/fxjs/cfxjse_context.cpp
@@ -68,7 +68,7 @@ class CFXJSE_ScopeUtil_IsolateHandleContext {
void* operator new(size_t size) = delete;
void operator delete(void*, size_t) = delete;
- CFXJSE_Context* m_context;
+ CFX_UnownedPtr<CFXJSE_Context> m_context;
CFXJSE_ScopeUtil_IsolateHandle m_parent;
v8::Context::Scope m_cscope;
};