summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fpdfapi/cpdf_modulemgr.cpp3
-rw-r--r--core/fpdfapi/edit/fpdf_edit_create.cpp5
-rw-r--r--core/fpdfapi/font/cpdf_cidfont.cpp5
-rw-r--r--core/fpdfapi/font/cpdf_font.cpp12
-rw-r--r--core/fpdfapi/font/fpdf_font.cpp3
-rw-r--r--core/fpdfapi/page/cpdf_contentparser.cpp15
-rw-r--r--core/fpdfapi/page/cpdf_form.cpp3
-rw-r--r--core/fpdfapi/page/cpdf_page.cpp3
-rw-r--r--core/fpdfapi/page/cpdf_tilingpattern.cpp3
-rw-r--r--core/fpdfapi/page/fpdf_page_func.cpp11
-rw-r--r--core/fpdfapi/parser/cpdf_document_unittest.cpp2
-rw-r--r--core/fpdfapi/parser/cpdf_parser.cpp5
-rw-r--r--core/fpdfapi/parser/cpdf_stream.cpp3
-rw-r--r--core/fpdfapi/render/cpdf_devicebuffer.cpp3
-rw-r--r--core/fpdfapi/render/cpdf_imagerenderer.cpp5
-rw-r--r--core/fpdfapi/render/cpdf_progressiverenderer.cpp3
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.cpp9
-rw-r--r--core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp3
-rw-r--r--core/fpdfapi/render/fpdf_render_loadimage.cpp11
-rw-r--r--core/fpdfdoc/cpdf_variabletext.cpp3
-rw-r--r--core/fpdfdoc/cpvt_sectioninfo.cpp6
-rw-r--r--core/fpdfdoc/cpvt_wordinfo.cpp3
-rw-r--r--core/fxcodec/codec/fx_codec_jbig.cpp7
-rw-r--r--core/fxcodec/jbig2/JBig2_Context.cpp109
-rw-r--r--core/fxcodec/jbig2/JBig2_HtrdProc.cpp3
-rw-r--r--core/fxcodec/jbig2/JBig2_SddProc.cpp9
-rw-r--r--core/fxcodec/jbig2/JBig2_TrdProc.cpp21
-rw-r--r--fpdfsdk/fpdfdoc.cpp3
-rw-r--r--fpdfsdk/fpdfdoc_unittest.cpp3
-rw-r--r--xfa/fde/cfde_txtedtengine.cpp2
-rw-r--r--xfa/fde/cfde_txtedtpage.cpp3
-rw-r--r--xfa/fde/cfx_wordbreak.cpp3
-rw-r--r--xfa/fde/css/fde_cssstyleselector.cpp3
-rw-r--r--xfa/fde/fde_render.cpp5
-rw-r--r--xfa/fde/tto/fde_textout.cpp5
-rw-r--r--xfa/fgas/layout/fgas_textbreak.cpp5
-rw-r--r--xfa/fwl/cfwl_combobox.cpp4
-rw-r--r--xfa/fwl/cfwl_datetimepicker.cpp3
-rw-r--r--xfa/fwl/cfwl_widgetmgr.cpp2
-rw-r--r--xfa/fwl/theme/cfwl_checkboxtp.cpp3
-rw-r--r--xfa/fwl/theme/cfwl_widgettp.cpp5
-rw-r--r--xfa/fxbarcode/BC_TwoDimWriter.cpp3
-rw-r--r--xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp6
-rw-r--r--xfa/fxbarcode/oned/BC_OneDimWriter.cpp3
-rw-r--r--xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp3
-rw-r--r--xfa/fxbarcode/pdf417/BC_PDF417.cpp4
-rw-r--r--xfa/fxfa/app/xfa_ffapp.cpp11
-rw-r--r--xfa/fxfa/app/xfa_ffdoc.cpp10
-rw-r--r--xfa/fxfa/app/xfa_ffdocview.cpp7
-rw-r--r--xfa/fxfa/app/xfa_ffwidgetacc.cpp24
-rw-r--r--xfa/fxfa/app/xfa_fontmgr.cpp3
-rw-r--r--xfa/fxfa/app/xfa_textlayout.cpp7
-rw-r--r--xfa/fxfa/parser/cxfa_document_parser.cpp3
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp5
-rw-r--r--xfa/fxfa/parser/cxfa_scriptcontext.cpp4
-rw-r--r--xfa/fxgraphics/cfx_graphics.cpp3
-rw-r--r--xfa/fxgraphics/cfx_path.cpp3
57 files changed, 237 insertions, 179 deletions
diff --git a/core/fpdfapi/cpdf_modulemgr.cpp b/core/fpdfapi/cpdf_modulemgr.cpp
index 8ae8464ef5..ac28b36663 100644
--- a/core/fpdfapi/cpdf_modulemgr.cpp
+++ b/core/fpdfapi/cpdf_modulemgr.cpp
@@ -8,6 +8,7 @@
#include "core/fpdfapi/page/cpdf_pagemodule.h"
#include "core/fxcodec/fx_codec.h"
+#include "third_party/base/ptr_util.h"
namespace {
@@ -33,7 +34,7 @@ CPDF_ModuleMgr::CPDF_ModuleMgr() : m_pCodecModule(nullptr) {}
CPDF_ModuleMgr::~CPDF_ModuleMgr() {}
void CPDF_ModuleMgr::InitPageModule() {
- m_pPageModule.reset(new CPDF_PageModule);
+ m_pPageModule = pdfium::MakeUnique<CPDF_PageModule>();
}
CCodec_FaxModule* CPDF_ModuleMgr::GetFaxModule() {
diff --git a/core/fpdfapi/edit/fpdf_edit_create.cpp b/core/fpdfapi/edit/fpdf_edit_create.cpp
index 62314f43f5..7b38883ef8 100644
--- a/core/fpdfapi/edit/fpdf_edit_create.cpp
+++ b/core/fpdfapi/edit/fpdf_edit_create.cpp
@@ -25,6 +25,7 @@
#include "core/fpdfapi/parser/fpdf_parser_decode.h"
#include "core/fxcrt/cfx_maybe_owned.h"
#include "core/fxcrt/fx_ext.h"
+#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
#define PDF_OBJECTSTREAM_MAXLENGTH (256 * 1024)
@@ -1446,7 +1447,7 @@ int32_t CPDF_Creator::WriteDoc_Stage1(IFX_Pause* pPause) {
CPDF_Dictionary* pDict = m_pDocument->GetRoot();
m_pMetadata = pDict ? pDict->GetDirectObjectFor("Metadata") : nullptr;
if (m_dwFlags & FPDFCREATE_OBJECTSTREAM) {
- m_pXRefStream.reset(new CPDF_XRefStream);
+ m_pXRefStream = pdfium::MakeUnique<CPDF_XRefStream>();
m_pXRefStream->Start();
if ((m_dwFlags & FPDFCREATE_INCREMENTAL) != 0 && m_pParser) {
FX_FILESIZE prev = m_pParser->GetLastXRefOffset();
@@ -1929,7 +1930,7 @@ void CPDF_Creator::InitID(bool bDefault) {
CPDF_Array* pOldIDArray = m_pParser ? m_pParser->GetIDArray() : nullptr;
bool bNewId = !m_pIDArray;
if (bNewId) {
- m_pIDArray.reset(new CPDF_Array);
+ m_pIDArray = pdfium::MakeUnique<CPDF_Array>();
CPDF_Object* pID1 = pOldIDArray ? pOldIDArray->GetObjectAt(0) : nullptr;
if (pID1) {
m_pIDArray->Add(pID1->Clone());
diff --git a/core/fpdfapi/font/cpdf_cidfont.cpp b/core/fpdfapi/font/cpdf_cidfont.cpp
index 0217391c12..91df025e0f 100644
--- a/core/fpdfapi/font/cpdf_cidfont.cpp
+++ b/core/fpdfapi/font/cpdf_cidfont.cpp
@@ -19,6 +19,7 @@
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_stream_acc.h"
#include "third_party/base/numerics/safe_math.h"
+#include "third_party/base/ptr_util.h"
namespace {
@@ -398,7 +399,7 @@ bool CPDF_CIDFont::Load() {
CPDF_Object* pmap = pCIDFontDict->GetDirectObjectFor("CIDToGIDMap");
if (pmap) {
if (CPDF_Stream* pStream = pmap->AsStream()) {
- m_pStreamAcc.reset(new CPDF_StreamAcc);
+ m_pStreamAcc = pdfium::MakeUnique<CPDF_StreamAcc>();
m_pStreamAcc->LoadAllData(pStream, false);
} else if (pmap->GetString() == "Identity") {
#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
@@ -581,7 +582,7 @@ int CPDF_CIDFont::GetGlyphIndex(uint32_t unicode, bool* pVertGlyph) {
if (error || !m_Font.GetSubData())
return index;
- m_pTTGSUBTable.reset(new CFX_CTTGSUBTable);
+ m_pTTGSUBTable = pdfium::MakeUnique<CFX_CTTGSUBTable>();
m_pTTGSUBTable->LoadGSUBTable((FT_Bytes)m_Font.GetSubData());
return GetVerticalGlyph(index, pVertGlyph);
}
diff --git a/core/fpdfapi/font/cpdf_font.cpp b/core/fpdfapi/font/cpdf_font.cpp
index 0b76ceedff..5563202455 100644
--- a/core/fpdfapi/font/cpdf_font.cpp
+++ b/core/fpdfapi/font/cpdf_font.cpp
@@ -279,7 +279,7 @@ void CPDF_Font::LoadUnicodeMap() const {
if (!pStream) {
return;
}
- m_pToUnicodeMap.reset(new CPDF_ToUnicodeMap);
+ m_pToUnicodeMap = pdfium::MakeUnique<CPDF_ToUnicodeMap>();
m_pToUnicodeMap->Load(pStream);
}
@@ -324,18 +324,18 @@ std::unique_ptr<CPDF_Font> CPDF_Font::Create(CPDF_Document* pDoc,
if (tag == CFX_ByteString(kChineseFontNames[i], 4)) {
CPDF_Dictionary* pFontDesc = pFontDict->GetDictFor("FontDescriptor");
if (!pFontDesc || !pFontDesc->KeyExist("FontFile2"))
- pFont.reset(new CPDF_CIDFont);
+ pFont = pdfium::MakeUnique<CPDF_CIDFont>();
break;
}
}
if (!pFont)
- pFont.reset(new CPDF_TrueTypeFont);
+ pFont = pdfium::MakeUnique<CPDF_TrueTypeFont>();
} else if (type == "Type3") {
- pFont.reset(new CPDF_Type3Font);
+ pFont = pdfium::MakeUnique<CPDF_Type3Font>();
} else if (type == "Type0") {
- pFont.reset(new CPDF_CIDFont);
+ pFont = pdfium::MakeUnique<CPDF_CIDFont>();
} else {
- pFont.reset(new CPDF_Type1Font);
+ pFont = pdfium::MakeUnique<CPDF_Type1Font>();
}
pFont->m_pFontDict = pFontDict;
pFont->m_pDocument = pDoc;
diff --git a/core/fpdfapi/font/fpdf_font.cpp b/core/fpdfapi/font/fpdf_font.cpp
index bf1fac4518..7bbd637177 100644
--- a/core/fpdfapi/font/fpdf_font.cpp
+++ b/core/fpdfapi/font/fpdf_font.cpp
@@ -24,6 +24,7 @@
#include "core/fxcrt/fx_safe_types.h"
#include "core/fxge/fx_freetype.h"
#include "third_party/base/numerics/safe_conversions.h"
+#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
int TT2PDF(int m, FXFT_Face face) {
@@ -87,7 +88,7 @@ CPDF_Font* CPDF_FontGlobals::Set(CPDF_Document* pDoc,
uint32_t index,
std::unique_ptr<CPDF_Font> pFont) {
if (!pdfium::ContainsKey(m_StockMap, pDoc))
- m_StockMap[pDoc].reset(new CFX_StockFontArray);
+ m_StockMap[pDoc] = pdfium::MakeUnique<CFX_StockFontArray>();
return m_StockMap[pDoc]->SetFont(index, std::move(pFont));
}
diff --git a/core/fpdfapi/page/cpdf_contentparser.cpp b/core/fpdfapi/page/cpdf_contentparser.cpp
index 0b8574bfd4..1e0fe62e09 100644
--- a/core/fpdfapi/page/cpdf_contentparser.cpp
+++ b/core/fpdfapi/page/cpdf_contentparser.cpp
@@ -17,6 +17,7 @@
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fpdfapi/parser/cpdf_stream_acc.h"
#include "core/fxcrt/fx_safe_types.h"
+#include "third_party/base/ptr_util.h"
#define PARSE_STEP_LIMIT 100
@@ -54,7 +55,7 @@ void CPDF_ContentParser::Start(CPDF_Page* pPage) {
}
if (CPDF_Stream* pStream = pContent->AsStream()) {
m_nStreams = 0;
- m_pSingleStream.reset(new CPDF_StreamAcc);
+ m_pSingleStream = pdfium::MakeUnique<CPDF_StreamAcc>();
m_pSingleStream->LoadAllData(pStream, false);
} else if (CPDF_Array* pArray = pContent->AsArray()) {
m_nStreams = pArray->GetCount();
@@ -94,9 +95,9 @@ void CPDF_ContentParser::Start(CPDF_Form* pForm,
form_bbox.Transform(pParentMatrix);
}
CPDF_Dictionary* pResources = pForm->m_pFormDict->GetDictFor("Resources");
- m_pParser.reset(new CPDF_StreamContentParser(
+ m_pParser = pdfium::MakeUnique<CPDF_StreamContentParser>(
pForm->m_pDocument, pForm->m_pPageResources, pForm->m_pResources,
- pParentMatrix, pForm, pResources, &form_bbox, pGraphicStates, level));
+ pParentMatrix, pForm, pResources, &form_bbox, pGraphicStates, level);
m_pParser->GetCurStates()->m_CTM = form_matrix;
m_pParser->GetCurStates()->m_ParentMatrix = form_matrix;
if (ClipPath) {
@@ -111,7 +112,7 @@ void CPDF_ContentParser::Start(CPDF_Form* pForm,
pState->SetSoftMask(nullptr);
}
m_nStreams = 0;
- m_pSingleStream.reset(new CPDF_StreamAcc);
+ m_pSingleStream = pdfium::MakeUnique<CPDF_StreamAcc>();
m_pSingleStream->LoadAllData(pForm->m_pFormStream, false);
m_pData = (uint8_t*)m_pSingleStream->GetData();
m_Size = m_pSingleStream->GetSize();
@@ -153,7 +154,7 @@ void CPDF_ContentParser::Continue(IFX_Pause* pPause) {
} else {
CPDF_Array* pContent =
m_pObjectHolder->m_pFormDict->GetArrayFor("Contents");
- m_StreamArray[m_CurrentOffset].reset(new CPDF_StreamAcc);
+ m_StreamArray[m_CurrentOffset] = pdfium::MakeUnique<CPDF_StreamAcc>();
CPDF_Stream* pStreamObj = ToStream(
pContent ? pContent->GetDirectObjectAt(m_CurrentOffset) : nullptr);
m_StreamArray[m_CurrentOffset]->LoadAllData(pStreamObj, false);
@@ -162,10 +163,10 @@ void CPDF_ContentParser::Continue(IFX_Pause* pPause) {
}
if (m_InternalStage == STAGE_PARSE) {
if (!m_pParser) {
- m_pParser.reset(new CPDF_StreamContentParser(
+ m_pParser = pdfium::MakeUnique<CPDF_StreamContentParser>(
m_pObjectHolder->m_pDocument, m_pObjectHolder->m_pPageResources,
nullptr, nullptr, m_pObjectHolder, m_pObjectHolder->m_pResources,
- &m_pObjectHolder->m_BBox, nullptr, 0));
+ &m_pObjectHolder->m_BBox, nullptr, 0);
m_pParser->GetCurStates()->m_ColorState.SetDefault();
}
if (m_CurrentOffset >= m_Size) {
diff --git a/core/fpdfapi/page/cpdf_form.cpp b/core/fpdfapi/page/cpdf_form.cpp
index 3a5fa0a74a..b3f2b372e3 100644
--- a/core/fpdfapi/page/cpdf_form.cpp
+++ b/core/fpdfapi/page/cpdf_form.cpp
@@ -12,6 +12,7 @@
#include "core/fpdfapi/page/pageint.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
+#include "third_party/base/ptr_util.h"
CPDF_Form::CPDF_Form(CPDF_Document* pDoc,
CPDF_Dictionary* pPageResources,
@@ -39,7 +40,7 @@ void CPDF_Form::StartParse(CPDF_AllStates* pGraphicStates,
if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING)
return;
- m_pParser.reset(new CPDF_ContentParser);
+ m_pParser = pdfium::MakeUnique<CPDF_ContentParser>();
m_pParser->Start(this, pGraphicStates, pParentMatrix, pType3Char, level);
m_ParseState = CONTENT_PARSING;
}
diff --git a/core/fpdfapi/page/cpdf_page.cpp b/core/fpdfapi/page/cpdf_page.cpp
index b4e2e67939..f9c02837a7 100644
--- a/core/fpdfapi/page/cpdf_page.cpp
+++ b/core/fpdfapi/page/cpdf_page.cpp
@@ -17,6 +17,7 @@
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_object.h"
#include "core/fpdfapi/render/cpdf_pagerendercache.h"
+#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
CPDF_Page::CPDF_Page(CPDF_Document* pDocument,
@@ -88,7 +89,7 @@ void CPDF_Page::StartParse() {
if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING)
return;
- m_pParser.reset(new CPDF_ContentParser);
+ m_pParser = pdfium::MakeUnique<CPDF_ContentParser>();
m_pParser->Start(this);
m_ParseState = CONTENT_PARSING;
}
diff --git a/core/fpdfapi/page/cpdf_tilingpattern.cpp b/core/fpdfapi/page/cpdf_tilingpattern.cpp
index 1b7bee4366..a041f38074 100644
--- a/core/fpdfapi/page/cpdf_tilingpattern.cpp
+++ b/core/fpdfapi/page/cpdf_tilingpattern.cpp
@@ -10,6 +10,7 @@
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_object.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
+#include "third_party/base/ptr_util.h"
CPDF_TilingPattern::CPDF_TilingPattern(CPDF_Document* pDoc,
CPDF_Object* pPatternObj,
@@ -47,7 +48,7 @@ bool CPDF_TilingPattern::Load() {
if (!pStream)
return false;
- m_pForm.reset(new CPDF_Form(m_pDocument, nullptr, pStream));
+ m_pForm = pdfium::MakeUnique<CPDF_Form>(m_pDocument, nullptr, pStream);
m_pForm->ParseContent(nullptr, &m_ParentMatrix, nullptr);
m_BBox = pDict->GetRectFor("BBox");
return true;
diff --git a/core/fpdfapi/page/fpdf_page_func.cpp b/core/fpdfapi/page/fpdf_page_func.cpp
index a6c73b0e5f..672bfc02be 100644
--- a/core/fpdfapi/page/fpdf_page_func.cpp
+++ b/core/fpdfapi/page/fpdf_page_func.cpp
@@ -20,6 +20,7 @@
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fpdfapi/parser/cpdf_stream_acc.h"
#include "core/fxcrt/fx_safe_types.h"
+#include "third_party/base/ptr_util.h"
namespace {
@@ -495,7 +496,7 @@ bool CPDF_SampledFunc::v_Init(CPDF_Object* pObj) {
return false;
m_SampleMax = 0xffffffff >> (32 - m_nBitsPerSample);
- m_pSampleStream.reset(new CPDF_StreamAcc);
+ m_pSampleStream = pdfium::MakeUnique<CPDF_StreamAcc>();
m_pSampleStream->LoadAllData(pStream, false);
FX_SAFE_UINT32 nTotalSampleBits = 1;
m_EncodeInfo.resize(m_nInputs);
@@ -742,13 +743,13 @@ std::unique_ptr<CPDF_Function> CPDF_Function::Load(CPDF_Object* pFuncObj) {
Type type = IntegerToFunctionType(iType);
if (type == Type::kType0Sampled)
- pFunc.reset(new CPDF_SampledFunc());
+ pFunc = pdfium::MakeUnique<CPDF_SampledFunc>();
else if (type == Type::kType2ExpotentialInterpolation)
- pFunc.reset(new CPDF_ExpIntFunc());
+ pFunc = pdfium::MakeUnique<CPDF_ExpIntFunc>();
else if (type == Type::kType3Stitching)
- pFunc.reset(new CPDF_StitchFunc());
+ pFunc = pdfium::MakeUnique<CPDF_StitchFunc>();
else if (type == Type::kType4PostScript)
- pFunc.reset(new CPDF_PSFunc());
+ pFunc = pdfium::MakeUnique<CPDF_PSFunc>();
if (!pFunc || !pFunc->Init(pFuncObj))
return nullptr;
diff --git a/core/fpdfapi/parser/cpdf_document_unittest.cpp b/core/fpdfapi/parser/cpdf_document_unittest.cpp
index e4fe033c8a..91beba3a6b 100644
--- a/core/fpdfapi/parser/cpdf_document_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_document_unittest.cpp
@@ -108,7 +108,7 @@ class CPDF_TestDocumentWithPageWithoutPageNum : public CPDF_Document {
allPages->Add(CreateNumberedPage(2));
CPDF_Dictionary* pagesDict =
CreatePageTreeNode(std::move(allPages), this, 3);
- m_pOwnedRootDict.reset(new CPDF_Dictionary());
+ m_pOwnedRootDict = pdfium::MakeUnique<CPDF_Dictionary>();
m_pOwnedRootDict->SetNewFor<CPDF_Reference>("Pages", this,
pagesDict->GetObjNum());
m_pRootDict = m_pOwnedRootDict.get();
diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp
index 47c5c4eab4..62364c0a75 100644
--- a/core/fpdfapi/parser/cpdf_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_parser.cpp
@@ -24,6 +24,7 @@
#include "core/fpdfapi/parser/fpdf_parser_utility.h"
#include "core/fxcrt/fx_ext.h"
#include "core/fxcrt/fx_safe_types.h"
+#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
namespace {
@@ -57,7 +58,7 @@ CPDF_Parser::CPDF_Parser()
m_FileVersion(0),
m_pEncryptDict(nullptr),
m_dwXrefStartObjNum(0) {
- m_pSyntax.reset(new CPDF_SyntaxParser);
+ m_pSyntax = pdfium::MakeUnique<CPDF_SyntaxParser>();
}
CPDF_Parser::~CPDF_Parser() {
@@ -242,7 +243,7 @@ CPDF_Parser::Error CPDF_Parser::SetEncryptHandler() {
std::unique_ptr<CPDF_SecurityHandler> pSecurityHandler;
Error err = HANDLER_ERROR;
if (filter == "Standard") {
- pSecurityHandler.reset(new CPDF_SecurityHandler);
+ pSecurityHandler = pdfium::MakeUnique<CPDF_SecurityHandler>();
err = PASSWORD_ERROR;
}
if (!pSecurityHandler)
diff --git a/core/fpdfapi/parser/cpdf_stream.cpp b/core/fpdfapi/parser/cpdf_stream.cpp
index 4f76ec1c63..3159791e82 100644
--- a/core/fpdfapi/parser/cpdf_stream.cpp
+++ b/core/fpdfapi/parser/cpdf_stream.cpp
@@ -13,6 +13,7 @@
#include "core/fpdfapi/parser/cpdf_stream_acc.h"
#include "core/fpdfapi/parser/fpdf_parser_decode.h"
#include "third_party/base/numerics/safe_conversions.h"
+#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
CPDF_Stream::CPDF_Stream() {}
@@ -103,7 +104,7 @@ void CPDF_Stream::SetData(const uint8_t* pData, uint32_t size) {
FXSYS_memcpy(m_pDataBuf.get(), pData, size);
m_dwSize = size;
if (!m_pDict)
- m_pDict.reset(new CPDF_Dictionary());
+ m_pDict = pdfium::MakeUnique<CPDF_Dictionary>();
m_pDict->SetNewFor<CPDF_Number>("Length", static_cast<int>(size));
m_pDict->RemoveFor("Filter");
m_pDict->RemoveFor("DecodeParms");
diff --git a/core/fpdfapi/render/cpdf_devicebuffer.cpp b/core/fpdfapi/render/cpdf_devicebuffer.cpp
index 06b4d13c7a..edc91802fb 100644
--- a/core/fpdfapi/render/cpdf_devicebuffer.cpp
+++ b/core/fpdfapi/render/cpdf_devicebuffer.cpp
@@ -12,6 +12,7 @@
#include "core/fxge/cfx_fxgedevice.h"
#include "core/fxge/cfx_renderdevice.h"
#include "core/fxge/fx_dib.h"
+#include "third_party/base/ptr_util.h"
CPDF_DeviceBuffer::CPDF_DeviceBuffer()
: m_pDevice(nullptr), m_pContext(nullptr), m_pObject(nullptr) {}
@@ -49,7 +50,7 @@ bool CPDF_DeviceBuffer::Initialize(CPDF_RenderContext* pContext,
CFX_FloatRect rect(*pRect);
m_Matrix.TransformRect(rect);
FX_RECT bitmap_rect = rect.GetOuterRect();
- m_pBitmap.reset(new CFX_DIBitmap);
+ m_pBitmap = pdfium::MakeUnique<CFX_DIBitmap>();
m_pBitmap->Create(bitmap_rect.Width(), bitmap_rect.Height(), FXDIB_Argb);
return true;
}
diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp
index eae32443d8..5ca7ea842f 100644
--- a/core/fpdfapi/render/cpdf_imagerenderer.cpp
+++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp
@@ -28,6 +28,7 @@
#include "core/fxcrt/fx_safe_types.h"
#include "core/fxge/cfx_fxgedevice.h"
#include "core/fxge/cfx_pathdata.h"
+#include "third_party/base/ptr_util.h"
#ifdef _SKIA_SUPPORT_
#include "core/fxge/skia/fx_skia_device.h"
@@ -437,8 +438,8 @@ bool CPDF_ImageRenderer::StartDIBSource() {
FX_RECT clip_box = m_pRenderStatus->m_pDevice->GetClipBox();
clip_box.Intersect(image_rect);
m_Status = 2;
- m_pTransformer.reset(new CFX_ImageTransformer(m_pDIBSource, &m_ImageMatrix,
- m_Flags, &clip_box));
+ m_pTransformer = pdfium::MakeUnique<CFX_ImageTransformer>(
+ m_pDIBSource, &m_ImageMatrix, m_Flags, &clip_box);
m_pTransformer->Start();
return true;
}
diff --git a/core/fpdfapi/render/cpdf_progressiverenderer.cpp b/core/fpdfapi/render/cpdf_progressiverenderer.cpp
index 46d78b6c4e..6aa3b8a309 100644
--- a/core/fpdfapi/render/cpdf_progressiverenderer.cpp
+++ b/core/fpdfapi/render/cpdf_progressiverenderer.cpp
@@ -12,6 +12,7 @@
#include "core/fpdfapi/render/cpdf_renderoptions.h"
#include "core/fpdfapi/render/cpdf_renderstatus.h"
#include "core/fxge/cfx_renderdevice.h"
+#include "third_party/base/ptr_util.h"
CPDF_ProgressiveRenderer::CPDF_ProgressiveRenderer(
CPDF_RenderContext* pContext,
@@ -48,7 +49,7 @@ void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) {
m_pCurrentLayer = m_pContext->GetLayer(m_LayerIndex);
m_LastObjectRendered =
m_pCurrentLayer->m_pObjectHolder->GetPageObjectList()->end();
- m_pRenderStatus.reset(new CPDF_RenderStatus());
+ m_pRenderStatus = pdfium::MakeUnique<CPDF_RenderStatus>();
m_pRenderStatus->Initialize(
m_pContext, m_pDevice, nullptr, nullptr, nullptr, nullptr, m_pOptions,
m_pCurrentLayer->m_pObjectHolder->m_Transparency, false, nullptr);
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index b23b98cdb1..3897963de8 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -54,6 +54,7 @@
#include "core/fxge/cfx_renderdevice.h"
#include "core/fxge/ifx_renderdevicedriver.h"
#include "third_party/base/numerics/safe_math.h"
+#include "third_party/base/ptr_util.h"
#ifdef _SKIA_SUPPORT_
#include "core/fxge/skia/fx_skia_device.h"
@@ -1079,7 +1080,7 @@ bool CPDF_RenderStatus::ContinueSingleObject(CPDF_PageObject* pObj,
return false;
if (pObj->IsImage()) {
- m_pImageRenderer.reset(new CPDF_ImageRenderer);
+ m_pImageRenderer = pdfium::MakeUnique<CPDF_ImageRenderer>();
if (!m_pImageRenderer->Start(this, pObj, pObj2Device, false,
FXDIB_BLEND_NORMAL)) {
if (!m_pImageRenderer->GetResult())
@@ -1382,7 +1383,7 @@ void CPDF_RenderStatus::ProcessClipPath(CPDF_ClipPath ClipPath,
CPDF_TextObject* pText = ClipPath.GetText(i);
if (pText) {
if (!pTextClippingPath)
- pTextClippingPath.reset(new CFX_PathData);
+ pTextClippingPath = pdfium::MakeUnique<CFX_PathData>();
ProcessText(pText, pObj2Device, pTextClippingPath.get());
continue;
}
@@ -1513,7 +1514,7 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj,
CFX_FxgeDevice bitmap_device;
std::unique_ptr<CFX_DIBitmap> oriDevice;
if (!isolated && (m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) {
- oriDevice.reset(new CFX_DIBitmap);
+ oriDevice = pdfium::MakeUnique<CFX_DIBitmap>();
if (!m_pDevice->CreateCompatibleBitmap(oriDevice.get(), width, height))
return true;
m_pDevice->GetDIBits(oriDevice.get(), rect.left, rect.top);
@@ -1527,7 +1528,7 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj,
new_matrix.Scale(scaleX, scaleY);
std::unique_ptr<CFX_DIBitmap> pTextMask;
if (bTextClip) {
- pTextMask.reset(new CFX_DIBitmap);
+ pTextMask = pdfium::MakeUnique<CFX_DIBitmap>();
if (!pTextMask->Create(width, height, FXDIB_8bppMask))
return true;
diff --git a/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp b/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp
index a14bb9ea43..bcc03ba2dd 100644
--- a/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp
+++ b/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp
@@ -10,6 +10,7 @@
#include "core/fpdfapi/render/cpdf_renderoptions.h"
#include "core/fxge/cfx_fxgedevice.h"
#include "core/fxge/cfx_renderdevice.h"
+#include "third_party/base/ptr_util.h"
#define _FPDFAPI_IMAGESIZE_LIMIT_ (30 * 1024 * 1024)
@@ -43,7 +44,7 @@ bool CPDF_ScaledRenderBuffer::Initialize(CPDF_RenderContext* pContext,
if (dpiv > max_dpi)
m_Matrix.Scale(1.0f, (FX_FLOAT)(max_dpi) / (FX_FLOAT)dpiv);
}
- m_pBitmapDevice.reset(new CFX_FxgeDevice);
+ m_pBitmapDevice = pdfium::MakeUnique<CFX_FxgeDevice>();
FXDIB_Format dibFormat = FXDIB_Rgb;
int32_t bpp = 24;
if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_ALPHA_OUTPUT) {
diff --git a/core/fpdfapi/render/fpdf_render_loadimage.cpp b/core/fpdfapi/render/fpdf_render_loadimage.cpp
index 085077f2e9..4a018a849d 100644
--- a/core/fpdfapi/render/fpdf_render_loadimage.cpp
+++ b/core/fpdfapi/render/fpdf_render_loadimage.cpp
@@ -22,6 +22,7 @@
#include "core/fpdfapi/render/cpdf_renderstatus.h"
#include "core/fxcodec/fx_codec.h"
#include "core/fxcrt/fx_safe_types.h"
+#include "third_party/base/ptr_util.h"
namespace {
@@ -171,7 +172,7 @@ bool CPDF_DIBSource::Load(CPDF_Document* pDoc,
if (!src_size.IsValid()) {
return false;
}
- m_pStreamAcc.reset(new CPDF_StreamAcc);
+ m_pStreamAcc = pdfium::MakeUnique<CPDF_StreamAcc>();
m_pStreamAcc->LoadAllData(pStream, false, src_size.ValueOrDie(), true);
if (m_pStreamAcc->GetSize() == 0 || !m_pStreamAcc->GetData()) {
return false;
@@ -293,7 +294,7 @@ int CPDF_DIBSource::StartLoadDIBSource(CPDF_Document* pDoc,
if (!src_size.IsValid()) {
return 0;
}
- m_pStreamAcc.reset(new CPDF_StreamAcc);
+ m_pStreamAcc = pdfium::MakeUnique<CPDF_StreamAcc>();
m_pStreamAcc->LoadAllData(pStream, false, src_size.ValueOrDie(), true);
if (m_pStreamAcc->GetSize() == 0 || !m_pStreamAcc->GetData()) {
return 0;
@@ -335,12 +336,12 @@ int CPDF_DIBSource::ContinueLoadDIBSource(IFX_Pause* pPause) {
}
CCodec_Jbig2Module* pJbig2Module = CPDF_ModuleMgr::Get()->GetJbig2Module();
if (!m_pJbig2Context) {
- m_pJbig2Context.reset(new CCodec_Jbig2Context());
+ m_pJbig2Context = pdfium::MakeUnique<CCodec_Jbig2Context>();
if (m_pStreamAcc->GetImageParam()) {
CPDF_Stream* pGlobals =
m_pStreamAcc->GetImageParam()->GetStreamFor("JBIG2Globals");
if (pGlobals) {
- m_pGlobalStream.reset(new CPDF_StreamAcc);
+ m_pGlobalStream = pdfium::MakeUnique<CPDF_StreamAcc>();
m_pGlobalStream->LoadAllData(pGlobals, false);
}
}
@@ -676,7 +677,7 @@ void CPDF_DIBSource::LoadJpxBitmap() {
format = FXDIB_Rgb;
}
- m_pCachedBitmap.reset(new CFX_DIBitmap);
+ m_pCachedBitmap = pdfium::MakeUnique<CFX_DIBitmap>();
if (!m_pCachedBitmap->Create(width, height, format)) {
m_pCachedBitmap.reset();
return;
diff --git a/core/fpdfdoc/cpdf_variabletext.cpp b/core/fpdfdoc/cpdf_variabletext.cpp
index 5cc7e9bf11..1313516f22 100644
--- a/core/fpdfdoc/cpdf_variabletext.cpp
+++ b/core/fpdfdoc/cpdf_variabletext.cpp
@@ -15,6 +15,7 @@
#include "core/fpdfdoc/cpvt_wordinfo.h"
#include "core/fpdfdoc/csection.h"
#include "core/fpdfdoc/ipvt_fontmap.h"
+#include "third_party/base/ptr_util.h"
namespace {
@@ -1096,7 +1097,7 @@ bool CPDF_VariableText::IsLatinWord(uint16_t word) {
CPDF_VariableText::Iterator* CPDF_VariableText::GetIterator() {
if (!m_pVTIterator)
- m_pVTIterator.reset(new CPDF_VariableText::Iterator(this));
+ m_pVTIterator = pdfium::MakeUnique<CPDF_VariableText::Iterator>(this);
return m_pVTIterator.get();
}
diff --git a/core/fpdfdoc/cpvt_sectioninfo.cpp b/core/fpdfdoc/cpvt_sectioninfo.cpp
index eb5c1bb809..ec0262c1a0 100644
--- a/core/fpdfdoc/cpvt_sectioninfo.cpp
+++ b/core/fpdfdoc/cpvt_sectioninfo.cpp
@@ -5,6 +5,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "core/fpdfdoc/cpvt_sectioninfo.h"
+#include "third_party/base/ptr_util.h"
CPVT_SectionInfo::CPVT_SectionInfo() : rcSection(), nTotalLine(0) {}
@@ -21,11 +22,12 @@ void CPVT_SectionInfo::operator=(const CPVT_SectionInfo& other) {
rcSection = other.rcSection;
nTotalLine = other.nTotalLine;
if (other.pSecProps)
- pSecProps.reset(new CPVT_SecProps(*other.pSecProps));
+ pSecProps = pdfium::MakeUnique<CPVT_SecProps>(*other.pSecProps);
else
pSecProps.reset();
+
if (other.pWordProps)
- pWordProps.reset(new CPVT_WordProps(*other.pWordProps));
+ pWordProps = pdfium::MakeUnique<CPVT_WordProps>(*other.pWordProps);
else
pWordProps.reset();
}
diff --git a/core/fpdfdoc/cpvt_wordinfo.cpp b/core/fpdfdoc/cpvt_wordinfo.cpp
index 2303f30032..f1ea11915c 100644
--- a/core/fpdfdoc/cpvt_wordinfo.cpp
+++ b/core/fpdfdoc/cpvt_wordinfo.cpp
@@ -5,6 +5,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "core/fpdfdoc/cpvt_wordinfo.h"
+#include "third_party/base/ptr_util.h"
CPVT_WordInfo::CPVT_WordInfo()
: Word(0),
@@ -48,7 +49,7 @@ void CPVT_WordInfo::operator=(const CPVT_WordInfo& word) {
fWordY = word.fWordY;
fWordTail = word.fWordTail;
if (word.pWordProps)
- pWordProps.reset(new CPVT_WordProps(*word.pWordProps));
+ pWordProps = pdfium::MakeUnique<CPVT_WordProps>(*word.pWordProps);
else
pWordProps.reset();
}
diff --git a/core/fxcodec/codec/fx_codec_jbig.cpp b/core/fxcodec/codec/fx_codec_jbig.cpp
index 8d20894231..926541f07d 100644
--- a/core/fxcodec/codec/fx_codec_jbig.cpp
+++ b/core/fxcodec/codec/fx_codec_jbig.cpp
@@ -14,6 +14,7 @@
#include "core/fxcodec/jbig2/JBig2_Context.h"
#include "core/fxcodec/jbig2/JBig2_Image.h"
#include "core/fxcrt/fx_memory.h"
+#include "third_party/base/ptr_util.h"
JBig2_DocumentContext::JBig2_DocumentContext() {}
@@ -22,7 +23,7 @@ JBig2_DocumentContext::~JBig2_DocumentContext() {}
JBig2_DocumentContext* GetJBig2DocumentContext(
std::unique_ptr<JBig2_DocumentContext>* pContextHolder) {
if (!pContextHolder->get())
- pContextHolder->reset(new JBig2_DocumentContext());
+ *pContextHolder = pdfium::MakeUnique<JBig2_DocumentContext>();
return pContextHolder->get();
}
@@ -62,9 +63,9 @@ FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(
pJbig2Context->m_dest_pitch = dest_pitch;
pJbig2Context->m_pPause = pPause;
FXSYS_memset(dest_buf, 0, height * dest_pitch);
- pJbig2Context->m_pContext.reset(new CJBig2_Context(
+ pJbig2Context->m_pContext = pdfium::MakeUnique<CJBig2_Context>(
global_stream, src_stream, pJBig2DocumentContext->GetSymbolDictCache(),
- pPause, false));
+ pPause, false);
if (!pJbig2Context->m_pContext)
return FXCODEC_STATUS_ERROR;
diff --git a/core/fxcodec/jbig2/JBig2_Context.cpp b/core/fxcodec/jbig2/JBig2_Context.cpp
index febd00b463..757840598a 100644
--- a/core/fxcodec/jbig2/JBig2_Context.cpp
+++ b/core/fxcodec/jbig2/JBig2_Context.cpp
@@ -22,6 +22,7 @@
#include "core/fxcodec/jbig2/JBig2_PddProc.h"
#include "core/fxcodec/jbig2/JBig2_SddProc.h"
#include "core/fxcodec/jbig2/JBig2_TrdProc.h"
+#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
namespace {
@@ -60,10 +61,10 @@ CJBig2_Context::CJBig2_Context(CPDF_StreamAcc* pGlobalStream,
m_pSymbolDictCache(pSymbolDictCache),
m_bIsGlobal(bIsGlobal) {
if (pGlobalStream && (pGlobalStream->GetSize() > 0)) {
- m_pGlobalContext.reset(new CJBig2_Context(nullptr, pGlobalStream,
- pSymbolDictCache, pPause, true));
+ m_pGlobalContext = pdfium::MakeUnique<CJBig2_Context>(
+ nullptr, pGlobalStream, pSymbolDictCache, pPause, true);
}
- m_pStream.reset(new CJBig2_BitStream(pSrcStream));
+ m_pStream = pdfium::MakeUnique<CJBig2_BitStream>(pSrcStream);
}
CJBig2_Context::~CJBig2_Context() {}
@@ -75,7 +76,7 @@ int32_t CJBig2_Context::decode_SquentialOrgnazation(IFX_Pause* pPause) {
while (m_pStream->getByteLeft() >= JBIG2_MIN_SEGMENT_SIZE) {
if (!m_pSegment) {
- m_pSegment.reset(new CJBig2_Segment);
+ m_pSegment = pdfium::MakeUnique<CJBig2_Segment>();
nRet = parseSegmentHeader(m_pSegment.get());
if (nRet != JBIG2_SUCCESS) {
m_pSegment.reset();
@@ -172,7 +173,7 @@ int32_t CJBig2_Context::getFirstPage(uint8_t* pBuf,
}
}
m_PauseStep = 0;
- m_pPage.reset(new CJBig2_Image(width, height, stride, pBuf));
+ m_pPage = pdfium::MakeUnique<CJBig2_Image>(width, height, stride, pBuf);
m_bBufSpecified = true;
if (pPause && pPause->NeedToPauseNow()) {
m_PauseStep = 1;
@@ -383,7 +384,8 @@ int32_t CJBig2_Context::ProcessingParseSegmentData(CJBig2_Segment* pSegment,
if (!m_bBufSpecified) {
uint32_t height =
bMaxHeight ? pPageInfo->m_wMaxStripeSize : pPageInfo->m_dwHeight;
- m_pPage.reset(new CJBig2_Image(pPageInfo->m_dwWidth, height));
+ m_pPage =
+ pdfium::MakeUnique<CJBig2_Image>(pPageInfo->m_dwWidth, height);
}
if (!m_pPage->m_pData) {
@@ -497,12 +499,12 @@ int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment* pSegment,
int32_t nIndex = 0;
if (cSDHUFFDH == 0) {
- Table_B4.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B4, HuffmanTable_B4_Size, HuffmanTable_HTOOB_B4));
+ Table_B4 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B4, HuffmanTable_B4_Size, HuffmanTable_HTOOB_B4);
pSymbolDictDecoder->SDHUFFDH = Table_B4.get();
} else if (cSDHUFFDH == 1) {
- Table_B5.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B5, HuffmanTable_B5_Size, HuffmanTable_HTOOB_B5));
+ Table_B5 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B5, HuffmanTable_B5_Size, HuffmanTable_HTOOB_B5);
pSymbolDictDecoder->SDHUFFDH = Table_B5.get();
} else {
CJBig2_Segment* pSeg =
@@ -512,12 +514,12 @@ int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment* pSegment,
pSymbolDictDecoder->SDHUFFDH = pSeg->m_Result.ht;
}
if (cSDHUFFDW == 0) {
- Table_B2.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B2, HuffmanTable_B2_Size, HuffmanTable_HTOOB_B2));
+ Table_B2 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B2, HuffmanTable_B2_Size, HuffmanTable_HTOOB_B2);
pSymbolDictDecoder->SDHUFFDW = Table_B2.get();
} else if (cSDHUFFDW == 1) {
- Table_B3.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B3, HuffmanTable_B3_Size, HuffmanTable_HTOOB_B3));
+ Table_B3 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B3, HuffmanTable_B3_Size, HuffmanTable_HTOOB_B3);
pSymbolDictDecoder->SDHUFFDW = Table_B3.get();
} else {
CJBig2_Segment* pSeg =
@@ -527,8 +529,8 @@ int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment* pSegment,
pSymbolDictDecoder->SDHUFFDW = pSeg->m_Result.ht;
}
if (cSDHUFFBMSIZE == 0) {
- Table_B1.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B1, HuffmanTable_B1_Size, HuffmanTable_HTOOB_B1));
+ Table_B1 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B1, HuffmanTable_B1_Size, HuffmanTable_HTOOB_B1);
pSymbolDictDecoder->SDHUFFBMSIZE = Table_B1.get();
} else {
CJBig2_Segment* pSeg =
@@ -540,8 +542,8 @@ int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment* pSegment,
if (pSymbolDictDecoder->SDREFAGG == 1) {
if (cSDHUFFAGGINST == 0) {
if (!Table_B1) {
- Table_B1.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B1, HuffmanTable_B1_Size, HuffmanTable_HTOOB_B1));
+ Table_B1 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B1, HuffmanTable_B1_Size, HuffmanTable_HTOOB_B1);
}
pSymbolDictDecoder->SDHUFFAGGINST = Table_B1.get();
} else {
@@ -759,12 +761,12 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
}
int32_t nIndex = 0;
if (cSBHUFFFS == 0) {
- Table_B6.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B6, HuffmanTable_B6_Size, HuffmanTable_HTOOB_B6));
+ Table_B6 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B6, HuffmanTable_B6_Size, HuffmanTable_HTOOB_B6);
pTRD->SBHUFFFS = Table_B6.get();
} else if (cSBHUFFFS == 1) {
- Table_B7.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B7, HuffmanTable_B7_Size, HuffmanTable_HTOOB_B7));
+ Table_B7 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B7, HuffmanTable_B7_Size, HuffmanTable_HTOOB_B7);
pTRD->SBHUFFFS = Table_B7.get();
} else {
CJBig2_Segment* pSeg =
@@ -774,16 +776,16 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
pTRD->SBHUFFFS = pSeg->m_Result.ht;
}
if (cSBHUFFDS == 0) {
- Table_B8.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B8, HuffmanTable_B8_Size, HuffmanTable_HTOOB_B8));
+ Table_B8 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B8, HuffmanTable_B8_Size, HuffmanTable_HTOOB_B8);
pTRD->SBHUFFDS = Table_B8.get();
} else if (cSBHUFFDS == 1) {
- Table_B9.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B9, HuffmanTable_B9_Size, HuffmanTable_HTOOB_B9));
+ Table_B9 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B9, HuffmanTable_B9_Size, HuffmanTable_HTOOB_B9);
pTRD->SBHUFFDS = Table_B9.get();
} else if (cSBHUFFDS == 2) {
- Table_B10.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B10, HuffmanTable_B10_Size, HuffmanTable_HTOOB_B10));
+ Table_B10 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B10, HuffmanTable_B10_Size, HuffmanTable_HTOOB_B10);
pTRD->SBHUFFDS = Table_B10.get();
} else {
CJBig2_Segment* pSeg =
@@ -793,16 +795,16 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
pTRD->SBHUFFDS = pSeg->m_Result.ht;
}
if (cSBHUFFDT == 0) {
- Table_B11.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B11, HuffmanTable_B11_Size, HuffmanTable_HTOOB_B11));
+ Table_B11 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B11, HuffmanTable_B11_Size, HuffmanTable_HTOOB_B11);
pTRD->SBHUFFDT = Table_B11.get();
} else if (cSBHUFFDT == 1) {
- Table_B12.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B12, HuffmanTable_B12_Size, HuffmanTable_HTOOB_B12));
+ Table_B12 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B12, HuffmanTable_B12_Size, HuffmanTable_HTOOB_B12);
pTRD->SBHUFFDT = Table_B12.get();
} else if (cSBHUFFDT == 2) {
- Table_B13.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B13, HuffmanTable_B13_Size, HuffmanTable_HTOOB_B13));
+ Table_B13 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B13, HuffmanTable_B13_Size, HuffmanTable_HTOOB_B13);
pTRD->SBHUFFDT = Table_B13.get();
} else {
CJBig2_Segment* pSeg =
@@ -812,12 +814,12 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
pTRD->SBHUFFDT = pSeg->m_Result.ht;
}
if (cSBHUFFRDW == 0) {
- Table_B14.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B14, HuffmanTable_B14_Size, HuffmanTable_HTOOB_B14));
+ Table_B14 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B14, HuffmanTable_B14_Size, HuffmanTable_HTOOB_B14);
pTRD->SBHUFFRDW = Table_B14.get();
} else if (cSBHUFFRDW == 1) {
- Table_B15.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15));
+ Table_B15 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15);
pTRD->SBHUFFRDW = Table_B15.get();
} else {
CJBig2_Segment* pSeg =
@@ -828,14 +830,14 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
}
if (cSBHUFFRDH == 0) {
if (!Table_B14) {
- Table_B14.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B14, HuffmanTable_B14_Size, HuffmanTable_HTOOB_B14));
+ Table_B14 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B14, HuffmanTable_B14_Size, HuffmanTable_HTOOB_B14);
}
pTRD->SBHUFFRDH = Table_B14.get();
} else if (cSBHUFFRDH == 1) {
if (!Table_B15) {
- Table_B15.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15));
+ Table_B15 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15);
}
pTRD->SBHUFFRDH = Table_B15.get();
} else {
@@ -847,14 +849,14 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
}
if (cSBHUFFRDX == 0) {
if (!Table_B14) {
- Table_B14.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B14, HuffmanTable_B14_Size, HuffmanTable_HTOOB_B14));
+ Table_B14 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B14, HuffmanTable_B14_Size, HuffmanTable_HTOOB_B14);
}
pTRD->SBHUFFRDX = Table_B14.get();
} else if (cSBHUFFRDX == 1) {
if (!Table_B15) {
- Table_B15.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15));
+ Table_B15 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15);
}
pTRD->SBHUFFRDX = Table_B15.get();
} else {
@@ -866,14 +868,14 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
}
if (cSBHUFFRDY == 0) {
if (!Table_B14) {
- Table_B14.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B14, HuffmanTable_B14_Size, HuffmanTable_HTOOB_B14));
+ Table_B14 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B14, HuffmanTable_B14_Size, HuffmanTable_HTOOB_B14);
}
pTRD->SBHUFFRDY = Table_B14.get();
} else if (cSBHUFFRDY == 1) {
if (!Table_B15) {
- Table_B15.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15));
+ Table_B15 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15);
}
pTRD->SBHUFFRDY = Table_B15.get();
} else {
@@ -884,8 +886,8 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
pTRD->SBHUFFRDY = pSeg->m_Result.ht;
}
if (cSBHUFFRSIZE == 0) {
- Table_B1.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B1, HuffmanTable_B1_Size, HuffmanTable_HTOOB_B1));
+ Table_B1 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B1, HuffmanTable_B1_Size, HuffmanTable_HTOOB_B1);
pTRD->SBHUFFRSIZE = Table_B1.get();
} else {
CJBig2_Segment* pSeg =
@@ -1095,7 +1097,8 @@ int32_t CJBig2_Context::parseGenericRegion(CJBig2_Segment* pSegment,
m_gbContext.resize(size);
}
if (!m_pArithDecoder) {
- m_pArithDecoder.reset(new CJBig2_ArithDecoder(m_pStream.get()));
+ m_pArithDecoder =
+ pdfium::MakeUnique<CJBig2_ArithDecoder>(m_pStream.get());
m_ProcessingStatus = m_pGRD->Start_decode_Arith(&pSegment->m_Result.im,
m_pArithDecoder.get(),
&m_gbContext[0], pPause);
diff --git a/core/fxcodec/jbig2/JBig2_HtrdProc.cpp b/core/fxcodec/jbig2/JBig2_HtrdProc.cpp
index f3391b32ff..121bf1d6df 100644
--- a/core/fxcodec/jbig2/JBig2_HtrdProc.cpp
+++ b/core/fxcodec/jbig2/JBig2_HtrdProc.cpp
@@ -10,6 +10,7 @@
#include "core/fxcodec/jbig2/JBig2_GsidProc.h"
#include "core/fxcrt/fx_basic.h"
+#include "third_party/base/ptr_util.h"
CJBig2_Image* CJBig2_HTRDProc::decode_Arith(CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext,
@@ -22,7 +23,7 @@ CJBig2_Image* CJBig2_HTRDProc::decode_Arith(CJBig2_ArithDecoder* pArithDecoder,
std::unique_ptr<CJBig2_Image> HTREG(new CJBig2_Image(HBW, HBH));
HTREG->fill(HDEFPIXEL);
if (HENABLESKIP == 1) {
- HSKIP.reset(new CJBig2_Image(HGW, HGH));
+ HSKIP = pdfium::MakeUnique<CJBig2_Image>(HGW, HGH);
for (mg = 0; mg < HGH; mg++) {
for (ng = 0; ng < HGW; ng++) {
x = (HGX + mg * HRY + ng * HRX) >> 8;
diff --git a/core/fxcodec/jbig2/JBig2_SddProc.cpp b/core/fxcodec/jbig2/JBig2_SddProc.cpp
index 7e9ace2046..d27ff680d5 100644
--- a/core/fxcodec/jbig2/JBig2_SddProc.cpp
+++ b/core/fxcodec/jbig2/JBig2_SddProc.cpp
@@ -18,6 +18,7 @@
#include "core/fxcodec/jbig2/JBig2_SymbolDict.h"
#include "core/fxcodec/jbig2/JBig2_TrdProc.h"
#include "core/fxcrt/fx_basic.h"
+#include "third_party/base/ptr_util.h"
CJBig2_SymbolDict* CJBig2_SDDProc::decode_Arith(
CJBig2_ArithDecoder* pArithDecoder,
@@ -59,7 +60,7 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Arith(
while ((uint32_t)(1 << nTmp) < (SDNUMINSYMS + SDNUMNEWSYMS)) {
nTmp++;
}
- IAID.reset(new CJBig2_ArithIaidDecoder((uint8_t)nTmp));
+ IAID = pdfium::MakeUnique<CJBig2_ArithIaidDecoder>((uint8_t)nTmp);
SDNEWSYMS = FX_Alloc(CJBig2_Image*, SDNUMNEWSYMS);
FXSYS_memset(SDNEWSYMS, 0, SDNUMNEWSYMS * sizeof(CJBig2_Image*));
@@ -258,7 +259,7 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Arith(
goto failed;
}
- pDict.reset(new CJBig2_SymbolDict);
+ pDict = pdfium::MakeUnique<CJBig2_SymbolDict>();
I = J = 0;
for (I = 0; I < SDNUMINSYMS + SDNUMNEWSYMS; I++) {
if (EXFLAGS[I] && J < SDNUMEXSYMS) {
@@ -562,8 +563,8 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Huffman(
}
EXINDEX = 0;
CUREXFLAG = 0;
- pTable.reset(new CJBig2_HuffmanTable(HuffmanTable_B1, HuffmanTable_B1_Size,
- HuffmanTable_HTOOB_B1));
+ pTable = pdfium::MakeUnique<CJBig2_HuffmanTable>(
+ HuffmanTable_B1, HuffmanTable_B1_Size, HuffmanTable_HTOOB_B1);
EXFLAGS = FX_Alloc(bool, SDNUMINSYMS + SDNUMNEWSYMS);
num_ex_syms = 0;
while (EXINDEX < SDNUMINSYMS + SDNUMNEWSYMS) {
diff --git a/core/fxcodec/jbig2/JBig2_TrdProc.cpp b/core/fxcodec/jbig2/JBig2_TrdProc.cpp
index 1fa4373d79..84042dbd8c 100644
--- a/core/fxcodec/jbig2/JBig2_TrdProc.cpp
+++ b/core/fxcodec/jbig2/JBig2_TrdProc.cpp
@@ -12,6 +12,7 @@
#include "core/fxcodec/jbig2/JBig2_ArithIntDecoder.h"
#include "core/fxcodec/jbig2/JBig2_GrrdProc.h"
#include "core/fxcodec/jbig2/JBig2_HuffmanDecoder.h"
+#include "third_party/base/ptr_util.h"
CJBig2_Image* CJBig2_TRDProc::decode_Huffman(CJBig2_BitStream* pStream,
JBig2ArithCtx* grContext) {
@@ -242,16 +243,16 @@ CJBig2_Image* CJBig2_TRDProc::decode_Arith(CJBig2_ArithDecoder* pArithDecoder,
pIARDY = pIDS->IARDY;
pIAID = pIDS->IAID;
} else {
- IADT.reset(new CJBig2_ArithIntDecoder());
- IAFS.reset(new CJBig2_ArithIntDecoder());
- IADS.reset(new CJBig2_ArithIntDecoder());
- IAIT.reset(new CJBig2_ArithIntDecoder());
- IARI.reset(new CJBig2_ArithIntDecoder());
- IARDW.reset(new CJBig2_ArithIntDecoder());
- IARDH.reset(new CJBig2_ArithIntDecoder());
- IARDX.reset(new CJBig2_ArithIntDecoder());
- IARDY.reset(new CJBig2_ArithIntDecoder());
- IAID.reset(new CJBig2_ArithIaidDecoder(SBSYMCODELEN));
+ IADT = pdfium::MakeUnique<CJBig2_ArithIntDecoder>();
+ IAFS = pdfium::MakeUnique<CJBig2_ArithIntDecoder>();
+ IADS = pdfium::MakeUnique<CJBig2_ArithIntDecoder>();
+ IAIT = pdfium::MakeUnique<CJBig2_ArithIntDecoder>();
+ IARI = pdfium::MakeUnique<CJBig2_ArithIntDecoder>();
+ IARDW = pdfium::MakeUnique<CJBig2_ArithIntDecoder>();
+ IARDH = pdfium::MakeUnique<CJBig2_ArithIntDecoder>();
+ IARDX = pdfium::MakeUnique<CJBig2_ArithIntDecoder>();
+ IARDY = pdfium::MakeUnique<CJBig2_ArithIntDecoder>();
+ IAID = pdfium::MakeUnique<CJBig2_ArithIaidDecoder>(SBSYMCODELEN);
pIADT = IADT.get();
pIAFS = IAFS.get();
pIADS = IADS.get();
diff --git a/fpdfsdk/fpdfdoc.cpp b/fpdfsdk/fpdfdoc.cpp
index ce4fc34982..82b898aa85 100644
--- a/fpdfsdk/fpdfdoc.cpp
+++ b/fpdfsdk/fpdfdoc.cpp
@@ -17,6 +17,7 @@
#include "core/fpdfdoc/cpdf_dest.h"
#include "core/fpdfdoc/cpdf_pagelabel.h"
#include "fpdfsdk/fsdk_define.h"
+#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
namespace {
@@ -55,7 +56,7 @@ CPDF_LinkList* GetLinkList(CPDF_Page* page) {
CPDF_Document* pDoc = page->m_pDocument;
std::unique_ptr<CPDF_LinkList>* pHolder = pDoc->LinksContext();
if (!pHolder->get())
- pHolder->reset(new CPDF_LinkList);
+ *pHolder = pdfium::MakeUnique<CPDF_LinkList>();
return pHolder->get();
}
diff --git a/fpdfsdk/fpdfdoc_unittest.cpp b/fpdfsdk/fpdfdoc_unittest.cpp
index 664ce39381..c63d6c2e77 100644
--- a/fpdfsdk/fpdfdoc_unittest.cpp
+++ b/fpdfsdk/fpdfdoc_unittest.cpp
@@ -65,8 +65,9 @@ class PDFDocTest : public testing::Test {
m_pDoc = pdfium::MakeUnique<CPDF_TestPdfDocument>();
m_pIndirectObjs = m_pDoc->GetHolder();
+
// Setup the root directory.
- m_pRootObj.reset(new CPDF_Dictionary());
+ m_pRootObj = pdfium::MakeUnique<CPDF_Dictionary>();
m_pDoc->SetRoot(m_pRootObj.get());
}
diff --git a/xfa/fde/cfde_txtedtengine.cpp b/xfa/fde/cfde_txtedtengine.cpp
index ced5bdca52..7df4e0fb96 100644
--- a/xfa/fde/cfde_txtedtengine.cpp
+++ b/xfa/fde/cfde_txtedtengine.cpp
@@ -82,7 +82,7 @@ CFDE_TxtEdtEngine::~CFDE_TxtEdtEngine() {
void CFDE_TxtEdtEngine::SetEditParams(const FDE_TXTEDTPARAMS& params) {
if (!m_pTextBreak)
- m_pTextBreak.reset(new CFX_TxtBreak(FX_TXTBREAKPOLICY_None));
+ m_pTextBreak = pdfium::MakeUnique<CFX_TxtBreak>(FX_TXTBREAKPOLICY_None);
FXSYS_memcpy(&m_Param, &params, sizeof(FDE_TXTEDTPARAMS));
m_wLineEnd = params.wLineBreakChar;
diff --git a/xfa/fde/cfde_txtedtpage.cpp b/xfa/fde/cfde_txtedtpage.cpp
index 0abb1d69f3..51621dae1c 100644
--- a/xfa/fde/cfde_txtedtpage.cpp
+++ b/xfa/fde/cfde_txtedtpage.cpp
@@ -8,6 +8,7 @@
#include <algorithm>
+#include "third_party/base/ptr_util.h"
#include "xfa/fde/cfde_txtedtbuf.h"
#include "xfa/fde/cfde_txtedtbufiter.h"
#include "xfa/fde/cfde_txtedtengine.h"
@@ -303,7 +304,7 @@ int32_t CFDE_TxtEdtPage::LoadPage(const CFX_RectF* pClipBox,
(bVertial && bLineReserve) ? (-pParams->fLineSpace) : pParams->fLineSpace;
FX_FLOAT fLinePos = fLineStart;
if (!m_pTextSet)
- m_pTextSet.reset(new CFDE_TxtEdtTextSet(this));
+ m_pTextSet = pdfium::MakeUnique<CFDE_TxtEdtTextSet>(this);
m_PieceMassArr.RemoveAll(true);
uint32_t dwBreakStatus = FX_TXTBREAK_None;
diff --git a/xfa/fde/cfx_wordbreak.cpp b/xfa/fde/cfx_wordbreak.cpp
index 48b45a4e82..2d37ba1707 100644
--- a/xfa/fde/cfx_wordbreak.cpp
+++ b/xfa/fde/cfx_wordbreak.cpp
@@ -8,6 +8,7 @@
#include <utility>
+#include "third_party/base/ptr_util.h"
#include "xfa/fde/cfx_chariter.h"
namespace {
@@ -2788,7 +2789,7 @@ void CFX_WordBreak::Attach(IFX_CharIter* pIter) {
}
void CFX_WordBreak::Attach(const CFX_WideString& wsText) {
- m_pCurIter.reset(new CFX_CharIter(wsText));
+ m_pCurIter = pdfium::MakeUnique<CFX_CharIter>(wsText);
}
bool CFX_WordBreak::Next(bool bPrev) {
diff --git a/xfa/fde/css/fde_cssstyleselector.cpp b/xfa/fde/css/fde_cssstyleselector.cpp
index 117afcc7ab..72e5ffc12b 100644
--- a/xfa/fde/css/fde_cssstyleselector.cpp
+++ b/xfa/fde/css/fde_cssstyleselector.cpp
@@ -9,6 +9,7 @@
#include <algorithm>
#include <memory>
+#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
#include "xfa/fde/css/fde_csscache.h"
#include "xfa/fde/css/fde_cssdeclaration.h"
@@ -126,7 +127,7 @@ void CFDE_CSSStyleSelector::SetDefFontSize(FX_FLOAT fFontSize) {
CFDE_CSSAccelerator* CFDE_CSSStyleSelector::InitAccelerator() {
if (!m_pAccelerator)
- m_pAccelerator.reset(new CFDE_CSSAccelerator);
+ m_pAccelerator = pdfium::MakeUnique<CFDE_CSSAccelerator>();
m_pAccelerator->Clear();
return m_pAccelerator.get();
}
diff --git a/xfa/fde/fde_render.cpp b/xfa/fde/fde_render.cpp
index e1d46f55f9..9528219b45 100644
--- a/xfa/fde/fde_render.cpp
+++ b/xfa/fde/fde_render.cpp
@@ -6,6 +6,7 @@
#include "xfa/fde/fde_render.h"
+#include "third_party/base/ptr_util.h"
#include "xfa/fde/fde_gedevice.h"
#include "xfa/fde/fde_object.h"
#include "xfa/fgas/crt/fgas_memory.h"
@@ -38,7 +39,7 @@ bool CFDE_RenderContext::StartRender(CFDE_RenderDevice* pRenderDevice,
m_pRenderDevice = pRenderDevice;
m_Transform = tmDoc2Device;
if (!m_pIterator)
- m_pIterator.reset(new CFDE_VisualSetIterator);
+ m_pIterator = pdfium::MakeUnique<CFDE_VisualSetIterator>();
return m_pIterator->AttachCanvas(pCanvasSet) && m_pIterator->FilterObjects();
}
@@ -116,7 +117,7 @@ void CFDE_RenderContext::RenderText(IFDE_TextSet* pTextSet,
return;
if (!m_pBrush)
- m_pBrush.reset(new CFDE_Brush);
+ m_pBrush = pdfium::MakeUnique<CFDE_Brush>();
if (m_CharPos.size() < static_cast<size_t>(iCount))
m_CharPos.resize(iCount, FXTEXT_CHARPOS());
diff --git a/xfa/fde/tto/fde_textout.cpp b/xfa/fde/tto/fde_textout.cpp
index 68a68565d1..d7155b7107 100644
--- a/xfa/fde/tto/fde_textout.cpp
+++ b/xfa/fde/tto/fde_textout.cpp
@@ -10,6 +10,7 @@
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_system.h"
+#include "third_party/base/ptr_util.h"
#include "xfa/fde/cfde_path.h"
#include "xfa/fde/fde_gedevice.h"
#include "xfa/fde/fde_object.h"
@@ -132,12 +133,12 @@ void CFDE_TextOut::SetDIBitmap(CFX_DIBitmap* pDIB) {
m_pRenderDevice.reset();
CFX_FxgeDevice* device = new CFX_FxgeDevice;
device->Attach(pDIB, false, nullptr, false);
- m_pRenderDevice.reset(new CFDE_RenderDevice(device, false));
+ m_pRenderDevice = pdfium::MakeUnique<CFDE_RenderDevice>(device, false);
}
void CFDE_TextOut::SetRenderDevice(CFX_RenderDevice* pDevice) {
ASSERT(pDevice);
- m_pRenderDevice.reset(new CFDE_RenderDevice(pDevice, false));
+ m_pRenderDevice = pdfium::MakeUnique<CFDE_RenderDevice>(pDevice, false);
}
void CFDE_TextOut::SetClipRect(const CFX_Rect& rtClip) {
diff --git a/xfa/fgas/layout/fgas_textbreak.cpp b/xfa/fgas/layout/fgas_textbreak.cpp
index 4b6e22593d..a3f8e9841d 100644
--- a/xfa/fgas/layout/fgas_textbreak.cpp
+++ b/xfa/fgas/layout/fgas_textbreak.cpp
@@ -11,6 +11,7 @@
#include "core/fxcrt/fx_arabic.h"
#include "core/fxcrt/fx_arb.h"
#include "core/fxcrt/fx_memory.h"
+#include "third_party/base/ptr_util.h"
#include "xfa/fgas/font/cfgas_gefont.h"
#include "xfa/fgas/layout/fgas_linebreak.h"
#include "xfa/fgas/layout/fgas_unicode.h"
@@ -70,8 +71,8 @@ CFX_TxtBreak::CFX_TxtBreak(uint32_t dwPolicies)
m_iCharSpace(0) {
m_bPagination = (m_dwPolicies & FX_TXTBREAKPOLICY_Pagination) != 0;
int32_t iSize = m_bPagination ? sizeof(CFX_Char) : sizeof(CFX_TxtChar);
- m_pTxtLine1.reset(new CFX_TxtLine(iSize));
- m_pTxtLine2.reset(new CFX_TxtLine(iSize));
+ m_pTxtLine1 = pdfium::MakeUnique<CFX_TxtLine>(iSize);
+ m_pTxtLine2 = pdfium::MakeUnique<CFX_TxtLine>(iSize);
m_pCurLine = m_pTxtLine1.get();
ResetArabicContext();
}
diff --git a/xfa/fwl/cfwl_combobox.cpp b/xfa/fwl/cfwl_combobox.cpp
index eb6bb632cd..7e5d1b8d74 100644
--- a/xfa/fwl/cfwl_combobox.cpp
+++ b/xfa/fwl/cfwl_combobox.cpp
@@ -56,8 +56,8 @@ CFWL_ComboBox::CFWL_ComboBox(const CFWL_App* app)
pdfium::MakeUnique<CFWL_ComboList>(m_pOwnerApp, std::move(prop), this);
if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown) && !m_pEdit) {
- m_pEdit.reset(new CFWL_ComboEdit(
- m_pOwnerApp, pdfium::MakeUnique<CFWL_WidgetProperties>(), this));
+ m_pEdit = pdfium::MakeUnique<CFWL_ComboEdit>(
+ m_pOwnerApp, pdfium::MakeUnique<CFWL_WidgetProperties>(), this);
m_pEdit->SetOuter(this);
}
if (m_pEdit)
diff --git a/xfa/fwl/cfwl_datetimepicker.cpp b/xfa/fwl/cfwl_datetimepicker.cpp
index fe7b90307b..10e26b4891 100644
--- a/xfa/fwl/cfwl_datetimepicker.cpp
+++ b/xfa/fwl/cfwl_datetimepicker.cpp
@@ -53,7 +53,8 @@ CFWL_DateTimePicker::CFWL_DateTimePicker(const CFWL_App* app)
editProp->m_pParent = this;
editProp->m_pThemeProvider = m_pProperties->m_pThemeProvider;
- m_pEdit.reset(new CFWL_DateTimeEdit(m_pOwnerApp, std::move(editProp), this));
+ m_pEdit = pdfium::MakeUnique<CFWL_DateTimeEdit>(m_pOwnerApp,
+ std::move(editProp), this);
RegisterEventTarget(m_pMonthCal.get());
RegisterEventTarget(m_pEdit.get());
}
diff --git a/xfa/fwl/cfwl_widgetmgr.cpp b/xfa/fwl/cfwl_widgetmgr.cpp
index e7eca100cc..7df7fb234d 100644
--- a/xfa/fwl/cfwl_widgetmgr.cpp
+++ b/xfa/fwl/cfwl_widgetmgr.cpp
@@ -563,7 +563,7 @@ CFX_Graphics* CFWL_WidgetMgr::DrawWidgetBefore(CFWL_Widget* pWidget,
Item* pItem = GetWidgetMgrItem(pWidget);
if (!pItem->pOffscreen) {
- pItem->pOffscreen.reset(new CFX_Graphics);
+ pItem->pOffscreen = pdfium::MakeUnique<CFX_Graphics>();
CFX_RectF rect = pWidget->GetWidgetRect();
pItem->pOffscreen->Create((int32_t)rect.width, (int32_t)rect.height,
FXDIB_Argb);
diff --git a/xfa/fwl/theme/cfwl_checkboxtp.cpp b/xfa/fwl/theme/cfwl_checkboxtp.cpp
index 4ff2ccd2a6..9109cb61c4 100644
--- a/xfa/fwl/theme/cfwl_checkboxtp.cpp
+++ b/xfa/fwl/theme/cfwl_checkboxtp.cpp
@@ -7,6 +7,7 @@
#include "xfa/fwl/theme/cfwl_checkboxtp.h"
#include "core/fxge/cfx_pathdata.h"
+#include "third_party/base/ptr_util.h"
#include "xfa/fde/tto/fde_textout.h"
#include "xfa/fwl/cfwl_checkbox.h"
#include "xfa/fwl/cfwl_themebackground.h"
@@ -219,7 +220,7 @@ void CFWL_CheckBoxTP::SetThemeData() {
void CFWL_CheckBoxTP::InitCheckPath(FX_FLOAT fCheckLen) {
if (!m_pCheckPath) {
- m_pCheckPath.reset(new CFX_Path);
+ m_pCheckPath = pdfium::MakeUnique<CFX_Path>();
m_pCheckPath->Create();
FX_FLOAT fWidth = kSignPath;
FX_FLOAT fHeight = -kSignPath;
diff --git a/xfa/fwl/theme/cfwl_widgettp.cpp b/xfa/fwl/theme/cfwl_widgettp.cpp
index efc1e96335..3b436d8302 100644
--- a/xfa/fwl/theme/cfwl_widgettp.cpp
+++ b/xfa/fwl/theme/cfwl_widgettp.cpp
@@ -9,6 +9,7 @@
#include <algorithm>
#include <utility>
+#include "third_party/base/ptr_util.h"
#include "xfa/fde/tto/fde_textout.h"
#include "xfa/fgas/font/cfgas_fontmgr.h"
#include "xfa/fgas/font/cfgas_gefont.h"
@@ -173,7 +174,7 @@ void CFWL_WidgetTP::InitTTO() {
m_pFDEFont =
CFWL_FontManager::GetInstance()->FindFont(FX_WSTRC(L"Helvetica"), 0, 0);
- m_pTextOut.reset(new CFDE_TextOut);
+ m_pTextOut = pdfium::MakeUnique<CFDE_TextOut>();
m_pTextOut->SetFont(m_pFDEFont);
m_pTextOut->SetFontSize(FWLTHEME_CAPACITY_FontSize);
m_pTextOut->SetTextColor(FWLTHEME_CAPACITY_TextColor);
@@ -641,7 +642,7 @@ bool CFWL_FontData::LoadFont(const CFX_WideStringC& wsFontFamily,
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
m_pFontMgr = CFGAS_FontMgr::Create(FX_GetDefFontEnumerator());
#else
- m_pFontSource.reset(new CFX_FontSourceEnum_File);
+ m_pFontSource = pdfium::MakeUnique<CFX_FontSourceEnum_File>();
m_pFontMgr = CFGAS_FontMgr::Create(m_pFontSource.get());
#endif
}
diff --git a/xfa/fxbarcode/BC_TwoDimWriter.cpp b/xfa/fxbarcode/BC_TwoDimWriter.cpp
index ec6c3626b2..84678a81da 100644
--- a/xfa/fxbarcode/BC_TwoDimWriter.cpp
+++ b/xfa/fxbarcode/BC_TwoDimWriter.cpp
@@ -10,6 +10,7 @@
#include "core/fxge/cfx_pathdata.h"
#include "core/fxge/cfx_renderdevice.h"
#include "third_party/base/numerics/safe_math.h"
+#include "third_party/base/ptr_util.h"
#include "xfa/fxbarcode/BC_TwoDimWriter.h"
#include "xfa/fxbarcode/BC_Writer.h"
#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h"
@@ -134,7 +135,7 @@ void CBC_TwoDimWriter::RenderResult(uint8_t* code,
if (topPadding < 0) {
topPadding = 0;
}
- m_output.reset(new CBC_CommonBitMatrix);
+ m_output = pdfium::MakeUnique<CBC_CommonBitMatrix>();
m_output->Init(outputWidth, outputHeight);
for (int32_t inputY = 0, outputY = topPadding;
(inputY < inputHeight) && (outputY < outputHeight - multiY);
diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp
index c9425dfa19..33b828cc1e 100644
--- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp
+++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp
@@ -21,6 +21,8 @@
*/
#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h"
+
+#include "third_party/base/ptr_util.h"
#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h"
CBC_ReedSolomonGF256* CBC_ReedSolomonGF256::QRCodeField = nullptr;
@@ -56,8 +58,8 @@ CBC_ReedSolomonGF256::CBC_ReedSolomonGF256(int32_t primitive) {
}
void CBC_ReedSolomonGF256::Init() {
- m_zero.reset(new CBC_ReedSolomonGF256Poly(this, 0));
- m_one.reset(new CBC_ReedSolomonGF256Poly(this, 1));
+ m_zero = pdfium::MakeUnique<CBC_ReedSolomonGF256Poly>(this, 0);
+ m_one = pdfium::MakeUnique<CBC_ReedSolomonGF256Poly>(this, 1);
}
CBC_ReedSolomonGF256::~CBC_ReedSolomonGF256() {}
diff --git a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp
index 09f7aea9db..24d257a630 100644
--- a/xfa/fxbarcode/oned/BC_OneDimWriter.cpp
+++ b/xfa/fxbarcode/oned/BC_OneDimWriter.cpp
@@ -31,6 +31,7 @@
#include "core/fxge/cfx_pathdata.h"
#include "core/fxge/cfx_renderdevice.h"
#include "core/fxge/cfx_unicodeencodingex.h"
+#include "third_party/base/ptr_util.h"
#include "xfa/fxbarcode/BC_Writer.h"
#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h"
@@ -442,7 +443,7 @@ void CBC_OneDimWriter::RenderResult(const CFX_WideStringC& contents,
if (!isDevice) {
m_barWidth = codeLength * m_multiple;
}
- m_output.reset(new CBC_CommonBitMatrix);
+ m_output = pdfium::MakeUnique<CBC_CommonBitMatrix>();
m_output->Init(outputWidth, outputHeight);
int32_t outputX = leftPadding * m_multiple;
for (int32_t inputX = 0; inputX < codeOldLength; inputX++) {
diff --git a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp
index db1b67beef..42e84b7117 100644
--- a/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp
+++ b/xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp
@@ -22,6 +22,7 @@
#include "core/fxge/cfx_fxgedevice.h"
#include "core/fxge/cfx_gemodule.h"
+#include "third_party/base/ptr_util.h"
#include "xfa/fxbarcode/BC_Writer.h"
#include "xfa/fxbarcode/oned/BC_OneDimWriter.h"
#include "xfa/fxbarcode/oned/BC_OnedEAN13Writer.h"
@@ -33,7 +34,7 @@ CBC_OnedUPCAWriter::CBC_OnedUPCAWriter() {
}
void CBC_OnedUPCAWriter::Init() {
- m_subWriter.reset(new CBC_OnedEAN13Writer);
+ m_subWriter = pdfium::MakeUnique<CBC_OnedEAN13Writer>();
}
CBC_OnedUPCAWriter::~CBC_OnedUPCAWriter() {}
diff --git a/xfa/fxbarcode/pdf417/BC_PDF417.cpp b/xfa/fxbarcode/pdf417/BC_PDF417.cpp
index 9d827acff6..9b8d0c149c 100644
--- a/xfa/fxbarcode/pdf417/BC_PDF417.cpp
+++ b/xfa/fxbarcode/pdf417/BC_PDF417.cpp
@@ -21,6 +21,8 @@
*/
#include "xfa/fxbarcode/pdf417/BC_PDF417.h"
+
+#include "third_party/base/ptr_util.h"
#include "xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h"
#include "xfa/fxbarcode/pdf417/BC_PDF417BarcodeRow.h"
#include "xfa/fxbarcode/pdf417/BC_PDF417Compaction.h"
@@ -432,7 +434,7 @@ void CBC_PDF417::generateBarcodeLogic(CFX_WideString msg,
dataCodewords, errorCorrectionLevel, e);
BC_EXCEPTION_CHECK_ReturnVoid(e);
CFX_WideString fullCodewords = dataCodewords + ec;
- m_barcodeMatrix.reset(new CBC_BarcodeMatrix(rows, cols));
+ m_barcodeMatrix = pdfium::MakeUnique<CBC_BarcodeMatrix>(rows, cols);
encodeLowLevel(fullCodewords, cols, rows, errorCorrectionLevel,
m_barcodeMatrix.get());
}
diff --git a/xfa/fxfa/app/xfa_ffapp.cpp b/xfa/fxfa/app/xfa_ffapp.cpp
index c264e03ec8..273b9f5b36 100644
--- a/xfa/fxfa/app/xfa_ffapp.cpp
+++ b/xfa/fxfa/app/xfa_ffapp.cpp
@@ -11,6 +11,7 @@
#include <utility>
#include <vector>
+#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
#include "xfa/fgas/font/cfgas_fontmgr.h"
#include "xfa/fwl/cfwl_notedriver.h"
@@ -97,7 +98,7 @@ CXFA_FFApp::~CXFA_FFApp() {}
CXFA_FFDocHandler* CXFA_FFApp::GetDocHandler() {
if (!m_pDocHandler)
- m_pDocHandler.reset(new CXFA_FFDocHandler);
+ m_pDocHandler = pdfium::MakeUnique<CXFA_FFDocHandler>();
return m_pDocHandler.get();
}
@@ -120,7 +121,7 @@ CXFA_FFDoc* CXFA_FFApp::CreateDoc(IXFA_DocEnvironment* pDocEnvironment,
void CXFA_FFApp::SetDefaultFontMgr(std::unique_ptr<CXFA_DefFontMgr> pFontMgr) {
if (!m_pFontMgr)
- m_pFontMgr.reset(new CXFA_FontMgr());
+ m_pFontMgr = pdfium::MakeUnique<CXFA_FontMgr>();
m_pFontMgr->SetDefFontMgr(std::move(pFontMgr));
}
@@ -133,7 +134,7 @@ CFGAS_FontMgr* CXFA_FFApp::GetFDEFontMgr() {
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
m_pFDEFontMgr = CFGAS_FontMgr::Create(FX_GetDefFontEnumerator());
#else
- m_pFontSource.reset(new CFX_FontSourceEnum_File);
+ m_pFontSource = pdfium::MakeUnique<CFX_FontSourceEnum_File>();
m_pFDEFontMgr = CFGAS_FontMgr::Create(m_pFontSource.get());
#endif
}
@@ -142,14 +143,14 @@ CFGAS_FontMgr* CXFA_FFApp::GetFDEFontMgr() {
CXFA_FWLTheme* CXFA_FFApp::GetFWLTheme() {
if (!m_pFWLTheme)
- m_pFWLTheme.reset(new CXFA_FWLTheme(this));
+ m_pFWLTheme = pdfium::MakeUnique<CXFA_FWLTheme>(this);
return m_pFWLTheme.get();
}
CXFA_FWLAdapterWidgetMgr* CXFA_FFApp::GetWidgetMgr(
CFWL_WidgetMgrDelegate* pDelegate) {
if (!m_pAdapterWidgetMgr) {
- m_pAdapterWidgetMgr.reset(new CXFA_FWLAdapterWidgetMgr);
+ m_pAdapterWidgetMgr = pdfium::MakeUnique<CXFA_FWLAdapterWidgetMgr>();
pDelegate->OnSetCapability(FWL_WGTMGR_DisableForm);
m_pWidgetMgrDelegate = pDelegate;
}
diff --git a/xfa/fxfa/app/xfa_ffdoc.cpp b/xfa/fxfa/app/xfa_ffdoc.cpp
index 516f3d7fa0..c34213c17e 100644
--- a/xfa/fxfa/app/xfa_ffdoc.cpp
+++ b/xfa/fxfa/app/xfa_ffdoc.cpp
@@ -16,6 +16,7 @@
#include "core/fpdfdoc/cpdf_nametree.h"
#include "core/fxcrt/fx_ext.h"
#include "core/fxcrt/fx_memory.h"
+#include "third_party/base/ptr_util.h"
#include "xfa/fde/xml/fde_xml_imp.h"
#include "xfa/fwl/cfwl_notedriver.h"
#include "xfa/fxfa/app/xfa_ffnotify.h"
@@ -166,10 +167,9 @@ uint32_t CXFA_FFDoc::GetDocType() {
}
int32_t CXFA_FFDoc::StartLoad() {
- m_pNotify.reset(new CXFA_FFNotify(this));
- m_pDocumentParser.reset(new CXFA_DocumentParser(m_pNotify.get()));
- int32_t iStatus = m_pDocumentParser->StartParse(m_pStream, XFA_XDPPACKET_XDP);
- return iStatus;
+ m_pNotify = pdfium::MakeUnique<CXFA_FFNotify>(this);
+ m_pDocumentParser = pdfium::MakeUnique<CXFA_DocumentParser>(m_pNotify.get());
+ return m_pDocumentParser->StartParse(m_pStream, XFA_XDPPACKET_XDP);
}
bool XFA_GetPDFContentsFromPDFXML(CFDE_XMLNode* pPDFElement,
@@ -272,7 +272,7 @@ void CXFA_FFDoc::StopLoad() {
CXFA_FFDocView* CXFA_FFDoc::CreateDocView(uint32_t dwView) {
if (!m_TypeToDocViewMap[dwView])
- m_TypeToDocViewMap[dwView].reset(new CXFA_FFDocView(this));
+ m_TypeToDocViewMap[dwView] = pdfium::MakeUnique<CXFA_FFDocView>(this);
return m_TypeToDocViewMap[dwView].get();
}
diff --git a/xfa/fxfa/app/xfa_ffdocview.cpp b/xfa/fxfa/app/xfa_ffdocview.cpp
index 78b690afc1..e88517c00c 100644
--- a/xfa/fxfa/app/xfa_ffdocview.cpp
+++ b/xfa/fxfa/app/xfa_ffdocview.cpp
@@ -7,6 +7,7 @@
#include "xfa/fxfa/xfa_ffdocview.h"
#include "core/fxcrt/fx_ext.h"
+#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
#include "xfa/fxfa/app/xfa_ffbarcode.h"
#include "xfa/fxfa/app/xfa_ffcheckbutton.h"
@@ -313,9 +314,9 @@ int32_t CXFA_FFDocView::ProcessWidgetEvent(CXFA_EventParam* pParam,
return XFA_EVENTERROR_Success;
}
CXFA_FFWidgetHandler* CXFA_FFDocView::GetWidgetHandler() {
- if (!m_pWidgetHandler) {
- m_pWidgetHandler.reset(new CXFA_FFWidgetHandler(this));
- }
+ if (!m_pWidgetHandler)
+ m_pWidgetHandler = pdfium::MakeUnique<CXFA_FFWidgetHandler>(this);
+
return m_pWidgetHandler.get();
}
diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.cpp b/xfa/fxfa/app/xfa_ffwidgetacc.cpp
index e95c04b331..c1c18ebbb3 100644
--- a/xfa/fxfa/app/xfa_ffwidgetacc.cpp
+++ b/xfa/fxfa/app/xfa_ffwidgetacc.cpp
@@ -11,6 +11,7 @@
#include <vector>
#include "fxjs/cfxjse_value.h"
+#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
#include "xfa/fde/tto/fde_textout.h"
#include "xfa/fde/xml/fde_xml_imp.h"
@@ -60,9 +61,9 @@ class CXFA_TextLayoutData : public CXFA_WidgetLayoutData {
if (m_pTextLayout)
return;
- m_pTextProvider.reset(
- new CXFA_TextProvider(pAcc, XFA_TEXTPROVIDERTYPE_Text));
- m_pTextLayout.reset(new CXFA_TextLayout(m_pTextProvider.get()));
+ m_pTextProvider =
+ pdfium::MakeUnique<CXFA_TextProvider>(pAcc, XFA_TEXTPROVIDERTYPE_Text);
+ m_pTextLayout = pdfium::MakeUnique<CXFA_TextLayout>(m_pTextProvider.get());
}
private:
@@ -120,7 +121,8 @@ class CXFA_FieldLayoutData : public CXFA_WidgetLayoutData {
return false;
m_pCapTextProvider.reset(
new CXFA_TextProvider(pAcc, XFA_TEXTPROVIDERTYPE_Caption));
- m_pCapTextLayout.reset(new CXFA_TextLayout(m_pCapTextProvider.get()));
+ m_pCapTextLayout =
+ pdfium::MakeUnique<CXFA_TextLayout>(m_pCapTextProvider.get());
return true;
}
@@ -857,7 +859,7 @@ void CXFA_WidgetAcc::CalculateTextContentSize(CFX_SizeF& size) {
CXFA_FieldLayoutData* layoutData =
static_cast<CXFA_FieldLayoutData*>(m_pLayoutData.get());
if (!layoutData->m_pTextOut) {
- layoutData->m_pTextOut.reset(new CFDE_TextOut);
+ layoutData->m_pTextOut = pdfium::MakeUnique<CFDE_TextOut>();
CFDE_TextOut* pTextOut = layoutData->m_pTextOut.get();
pTextOut->SetFont(GetFDEFont());
pTextOut->SetFontSize(fFontSize);
@@ -1388,25 +1390,25 @@ void CXFA_WidgetAcc::InitLayoutData() {
}
switch (GetUIType()) {
case XFA_Element::Text:
- m_pLayoutData.reset(new CXFA_TextLayoutData);
+ m_pLayoutData = pdfium::MakeUnique<CXFA_TextLayoutData>();
return;
case XFA_Element::TextEdit:
- m_pLayoutData.reset(new CXFA_TextEditData);
+ m_pLayoutData = pdfium::MakeUnique<CXFA_TextEditData>();
return;
case XFA_Element::Image:
- m_pLayoutData.reset(new CXFA_ImageLayoutData);
+ m_pLayoutData = pdfium::MakeUnique<CXFA_ImageLayoutData>();
return;
case XFA_Element::ImageEdit:
- m_pLayoutData.reset(new CXFA_ImageEditData);
+ m_pLayoutData = pdfium::MakeUnique<CXFA_ImageEditData>();
return;
default:
break;
}
if (GetElementType() == XFA_Element::Field) {
- m_pLayoutData.reset(new CXFA_FieldLayoutData);
+ m_pLayoutData = pdfium::MakeUnique<CXFA_FieldLayoutData>();
return;
}
- m_pLayoutData.reset(new CXFA_WidgetLayoutData);
+ m_pLayoutData = pdfium::MakeUnique<CXFA_WidgetLayoutData>();
}
void CXFA_WidgetAcc::StartTextLayout(FX_FLOAT& fCalcWidth,
diff --git a/xfa/fxfa/app/xfa_fontmgr.cpp b/xfa/fxfa/app/xfa_fontmgr.cpp
index e83cf48eb8..636017d4e3 100644
--- a/xfa/fxfa/app/xfa_fontmgr.cpp
+++ b/xfa/fxfa/app/xfa_fontmgr.cpp
@@ -13,6 +13,7 @@
#include "core/fpdfapi/font/cpdf_font.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_document.h"
+#include "third_party/base/ptr_util.h"
#include "xfa/fgas/font/cfgas_gefont.h"
#include "xfa/fxfa/xfa_ffapp.h"
#include "xfa/fxfa/xfa_ffdoc.h"
@@ -2047,7 +2048,7 @@ CFGAS_GEFont* CXFA_FontMgr::GetFont(CXFA_FFDoc* hDoc,
void CXFA_FontMgr::LoadDocFonts(CXFA_FFDoc* hDoc) {
if (!m_PDFFontMgrMap[hDoc])
- m_PDFFontMgrMap[hDoc].reset(new CXFA_PDFFontMgr(hDoc));
+ m_PDFFontMgrMap[hDoc] = pdfium::MakeUnique<CXFA_PDFFontMgr>(hDoc);
}
void CXFA_FontMgr::ReleaseDocFonts(CXFA_FFDoc* hDoc) {
diff --git a/xfa/fxfa/app/xfa_textlayout.cpp b/xfa/fxfa/app/xfa_textlayout.cpp
index 2a7161333e..69b53eedb4 100644
--- a/xfa/fxfa/app/xfa_textlayout.cpp
+++ b/xfa/fxfa/app/xfa_textlayout.cpp
@@ -9,6 +9,7 @@
#include <algorithm>
#include "core/fxcrt/fx_ext.h"
+#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
#include "xfa/fde/cfde_path.h"
#include "xfa/fde/css/fde_csscache.h"
@@ -97,7 +98,7 @@ void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) {
CXFA_FFDoc* pDoc = pTextProvider->GetDocNode();
CFGAS_FontMgr* pFontMgr = pDoc->GetApp()->GetFDEFontMgr();
ASSERT(pFontMgr);
- m_pSelector.reset(new CFDE_CSSStyleSelector(pFontMgr));
+ m_pSelector = pdfium::MakeUnique<CFDE_CSSStyleSelector>(pFontMgr);
FX_FLOAT fFontSize = 10;
CXFA_Font font = pTextProvider->GetFontNode();
if (font) {
@@ -896,7 +897,7 @@ void CXFA_TextLayout::InitBreak(IFDE_CSSComputedStyle* pStyle,
m_pBreak->SetLineStartPos(fStart);
m_pBreak->SetTabWidth(m_textParser.GetTabInterval(pStyle));
if (!m_pTabstopContext)
- m_pTabstopContext.reset(new CXFA_TextTabstopsContext);
+ m_pTabstopContext = pdfium::MakeUnique<CXFA_TextTabstopsContext>();
m_textParser.GetTabstops(pStyle, m_pTabstopContext.get());
for (int32_t i = 0; i < m_pTabstopContext->m_iTabCount; i++) {
XFA_TABSTOPS* pTab = m_pTabstopContext->m_tabstops.GetDataPtr(i);
@@ -946,7 +947,7 @@ FX_FLOAT CXFA_TextLayout::GetLayoutHeight() {
}
FX_FLOAT CXFA_TextLayout::StartLayout(FX_FLOAT fWidth) {
if (!m_pLoader)
- m_pLoader.reset(new CXFA_LoaderContext);
+ m_pLoader = pdfium::MakeUnique<CXFA_LoaderContext>();
if (fWidth < 0 || (m_pLoader->m_fWidth > -1 &&
FXSYS_fabs(fWidth - m_pLoader->m_fWidth) > 0)) {
diff --git a/xfa/fxfa/parser/cxfa_document_parser.cpp b/xfa/fxfa/parser/cxfa_document_parser.cpp
index 1bf327d667..90be568785 100644
--- a/xfa/fxfa/parser/cxfa_document_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_document_parser.cpp
@@ -6,6 +6,7 @@
#include "xfa/fxfa/parser/cxfa_document_parser.h"
+#include "third_party/base/ptr_util.h"
#include "xfa/fxfa/fxfa.h"
#include "xfa/fxfa/parser/cxfa_document.h"
@@ -23,7 +24,7 @@ int32_t CXFA_DocumentParser::StartParse(
int32_t nRetStatus = m_nodeParser.StartParse(pStream, ePacketID);
if (nRetStatus == XFA_PARSESTATUS_Ready) {
- m_pDocument.reset(new CXFA_Document(this));
+ m_pDocument = pdfium::MakeUnique<CXFA_Document>(this);
m_nodeParser.SetFactory(m_pDocument.get());
}
return nRetStatus;
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 1721cb7982..f385b11b69 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -13,6 +13,7 @@
#include "core/fxcrt/fx_ext.h"
#include "fxjs/cfxjse_value.h"
+#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
#include "xfa/fde/xml/fde_xml_imp.h"
#include "xfa/fgas/crt/fgas_codepage.h"
@@ -118,11 +119,11 @@ CXFA_NodeSetPair* NodeSetPairForNode(CXFA_Node* pNode,
return nullptr;
if (!(*pMap)[pParentNode])
- (*pMap)[pParentNode].reset(new CXFA_NodeSetPairMap);
+ (*pMap)[pParentNode] = pdfium::MakeUnique<CXFA_NodeSetPairMap>();
CXFA_NodeSetPairMap* pNodeSetPairMap = (*pMap)[pParentNode].get();
if (!(*pNodeSetPairMap)[dwNameHash])
- (*pNodeSetPairMap)[dwNameHash].reset(new CXFA_NodeSetPair);
+ (*pNodeSetPairMap)[dwNameHash] = pdfium::MakeUnique<CXFA_NodeSetPair>();
return (*pNodeSetPairMap)[dwNameHash].get();
}
diff --git a/xfa/fxfa/parser/cxfa_scriptcontext.cpp b/xfa/fxfa/parser/cxfa_scriptcontext.cpp
index 8cad0e08c4..60ee722c91 100644
--- a/xfa/fxfa/parser/cxfa_scriptcontext.cpp
+++ b/xfa/fxfa/parser/cxfa_scriptcontext.cpp
@@ -9,6 +9,7 @@
#include <utility>
#include "core/fxcrt/fx_ext.h"
+#include "third_party/base/ptr_util.h"
#include "fxjs/cfxjse_arguments.h"
#include "fxjs/cfxjse_class.h"
#include "fxjs/cfxjse_value.h"
@@ -142,8 +143,9 @@ void CXFA_ScriptContext::Initialize(v8::Isolate* pIsolate) {
m_pIsolate = pIsolate;
DefineJsContext();
DefineJsClass();
- m_ResolveProcessor.reset(new CXFA_ResolveProcessor);
+ m_ResolveProcessor = pdfium::MakeUnique<CXFA_ResolveProcessor>();
}
+
bool CXFA_ScriptContext::RunScript(XFA_SCRIPTLANGTYPE eScriptType,
const CFX_WideStringC& wsScript,
CFXJSE_Value* hRetValue,
diff --git a/xfa/fxgraphics/cfx_graphics.cpp b/xfa/fxgraphics/cfx_graphics.cpp
index 824e7c68da..5b3bc8cb9d 100644
--- a/xfa/fxgraphics/cfx_graphics.cpp
+++ b/xfa/fxgraphics/cfx_graphics.cpp
@@ -12,6 +12,7 @@
#include "core/fxge/cfx_gemodule.h"
#include "core/fxge/cfx_renderdevice.h"
#include "core/fxge/cfx_unicodeencoding.h"
+#include "third_party/base/ptr_util.h"
#include "xfa/fxgraphics/cagg_graphics.h"
#include "xfa/fxgraphics/cfx_color.h"
#include "xfa/fxgraphics/cfx_path.h"
@@ -597,7 +598,7 @@ FWL_Error CFX_Graphics::Create(int32_t width,
m_type = FX_CONTEXT_Device;
m_info.isAntialiasing = isAntialiasing;
- m_aggGraphics.reset(new CAGG_Graphics);
+ m_aggGraphics = pdfium::MakeUnique<CAGG_Graphics>();
return m_aggGraphics->Create(this, width, height, format);
}
diff --git a/xfa/fxgraphics/cfx_path.cpp b/xfa/fxgraphics/cfx_path.cpp
index d02b7a8e48..3288631f15 100644
--- a/xfa/fxgraphics/cfx_path.cpp
+++ b/xfa/fxgraphics/cfx_path.cpp
@@ -7,6 +7,7 @@
#include "xfa/fxgraphics/cfx_path.h"
#include "core/fxge/cfx_pathdata.h"
+#include "third_party/base/ptr_util.h"
#include "xfa/fxgraphics/cfx_path_generator.h"
CFX_Path::CFX_Path() {}
@@ -15,7 +16,7 @@ FWL_Error CFX_Path::Create() {
if (m_generator)
return FWL_Error::PropertyInvalid;
- m_generator.reset(new CFX_PathGenerator());
+ m_generator = pdfium::MakeUnique<CFX_PathGenerator>();
return FWL_Error::Succeeded;
}