summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-12-14 05:57:10 -0800
committerCommit bot <commit-bot@chromium.org>2016-12-14 05:57:10 -0800
commita9caab94c1f16929e5acf2676117224617d80f53 (patch)
treed71ff9a82fae6e6080deb76375f43056127b3ee2 /xfa/fxfa/parser
parent992ecf7c189e5cabf43e5ad862511cf63d030966 (diff)
downloadpdfium-a9caab94c1f16929e5acf2676117224617d80f53.tar.xz
Avoid the ptr.reset(new XXX()) anti-pattern
Be suspicious of |new|. This removes some of the easy cases. Review-Url: https://codereview.chromium.org/2571913002
Diffstat (limited to 'xfa/fxfa/parser')
-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
3 files changed, 8 insertions, 4 deletions
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,