Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(512)

Side by Side Diff: xfa/fxfa/parser/cxfa_scriptcontext.cpp

Issue 2571913002: Avoid the ptr.reset(new XXX()) anti-pattern (Closed)
Patch Set: rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/parser/cxfa_node.cpp ('k') | xfa/fxgraphics/cfx_graphics.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fxfa/parser/cxfa_scriptcontext.h" 7 #include "xfa/fxfa/parser/cxfa_scriptcontext.h"
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "core/fxcrt/fx_ext.h" 11 #include "core/fxcrt/fx_ext.h"
12 #include "third_party/base/ptr_util.h"
12 #include "fxjs/cfxjse_arguments.h" 13 #include "fxjs/cfxjse_arguments.h"
13 #include "fxjs/cfxjse_class.h" 14 #include "fxjs/cfxjse_class.h"
14 #include "fxjs/cfxjse_value.h" 15 #include "fxjs/cfxjse_value.h"
15 #include "xfa/fxfa/app/xfa_ffnotify.h" 16 #include "xfa/fxfa/app/xfa_ffnotify.h"
16 #include "xfa/fxfa/cxfa_eventparam.h" 17 #include "xfa/fxfa/cxfa_eventparam.h"
17 #include "xfa/fxfa/parser/cxfa_document.h" 18 #include "xfa/fxfa/parser/cxfa_document.h"
18 #include "xfa/fxfa/parser/cxfa_nodehelper.h" 19 #include "xfa/fxfa/parser/cxfa_nodehelper.h"
19 #include "xfa/fxfa/parser/cxfa_resolveprocessor.h" 20 #include "xfa/fxfa/parser/cxfa_resolveprocessor.h"
20 #include "xfa/fxfa/parser/xfa_basic_data.h" 21 #include "xfa/fxfa/parser/xfa_basic_data.h"
21 #include "xfa/fxfa/parser/xfa_localemgr.h" 22 #include "xfa/fxfa/parser/xfa_localemgr.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 136 }
136 m_mapVariableToContext.RemoveAll(); 137 m_mapVariableToContext.RemoveAll();
137 138
138 m_upObjectArray.RemoveAll(); 139 m_upObjectArray.RemoveAll();
139 } 140 }
140 141
141 void CXFA_ScriptContext::Initialize(v8::Isolate* pIsolate) { 142 void CXFA_ScriptContext::Initialize(v8::Isolate* pIsolate) {
142 m_pIsolate = pIsolate; 143 m_pIsolate = pIsolate;
143 DefineJsContext(); 144 DefineJsContext();
144 DefineJsClass(); 145 DefineJsClass();
145 m_ResolveProcessor.reset(new CXFA_ResolveProcessor); 146 m_ResolveProcessor = pdfium::MakeUnique<CXFA_ResolveProcessor>();
146 } 147 }
148
147 bool CXFA_ScriptContext::RunScript(XFA_SCRIPTLANGTYPE eScriptType, 149 bool CXFA_ScriptContext::RunScript(XFA_SCRIPTLANGTYPE eScriptType,
148 const CFX_WideStringC& wsScript, 150 const CFX_WideStringC& wsScript,
149 CFXJSE_Value* hRetValue, 151 CFXJSE_Value* hRetValue,
150 CXFA_Object* pThisObject) { 152 CXFA_Object* pThisObject) {
151 CFX_ByteString btScript; 153 CFX_ByteString btScript;
152 XFA_SCRIPTLANGTYPE eSaveType = m_eScriptType; 154 XFA_SCRIPTLANGTYPE eSaveType = m_eScriptType;
153 m_eScriptType = eScriptType; 155 m_eScriptType = eScriptType;
154 if (eScriptType == XFA_SCRIPTLANGTYPE_Formcalc) { 156 if (eScriptType == XFA_SCRIPTLANGTYPE_Formcalc) {
155 if (!m_FM2JSContext) { 157 if (!m_FM2JSContext) {
156 m_FM2JSContext.reset( 158 m_FM2JSContext.reset(
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 return; 765 return;
764 if (nodes.GetSize() > 0) 766 if (nodes.GetSize() > 0)
765 m_pScriptNodeArray->Copy(nodes); 767 m_pScriptNodeArray->Copy(nodes);
766 } 768 }
767 void CXFA_ScriptContext::AddNodesOfRunScript(CXFA_Node* pNode) { 769 void CXFA_ScriptContext::AddNodesOfRunScript(CXFA_Node* pNode) {
768 if (!m_pScriptNodeArray) 770 if (!m_pScriptNodeArray)
769 return; 771 return;
770 if (m_pScriptNodeArray->Find(pNode) == -1) 772 if (m_pScriptNodeArray->Find(pNode) == -1)
771 m_pScriptNodeArray->Add(pNode); 773 m_pScriptNodeArray->Add(pNode);
772 } 774 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/cxfa_node.cpp ('k') | xfa/fxgraphics/cfx_graphics.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698