From ee2abec93f22bd10522181dc0362f24d389fc66b Mon Sep 17 00:00:00 2001 From: dsinclair Date: Tue, 14 Jun 2016 14:36:49 -0700 Subject: Cleanup ownership in CXFA_ScriptContext. This Cl substitutes some unique_ptrs for various bits of manual memory management in CXFA_ScriptContext. Review-Url: https://codereview.chromium.org/2062113002 --- xfa/fxfa/parser/xfa_script_imp.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'xfa/fxfa/parser/xfa_script_imp.h') diff --git a/xfa/fxfa/parser/xfa_script_imp.h b/xfa/fxfa/parser/xfa_script_imp.h index 64d1e1a6d7..d36e468b50 100644 --- a/xfa/fxfa/parser/xfa_script_imp.h +++ b/xfa/fxfa/parser/xfa_script_imp.h @@ -8,6 +8,8 @@ #define XFA_FXFA_PARSER_XFA_SCRIPT_IMP_H_ #include +#include +#include #include "fxjse/include/cfxjse_arguments.h" #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h" @@ -37,7 +39,7 @@ class CXFA_ScriptContext { uint32_t dwStyles = XFA_RESOLVENODE_Children, CXFA_Node* bindNode = NULL); CFXJSE_Value* GetJSValueFromMap(CXFA_Object* pObject); - void CacheList(CXFA_NodeList* pList) { m_CacheListArray.Add(pList); } + void AddToCacheList(std::unique_ptr pList); CXFA_Object* GetThisObject() const { return m_pThisObject; } v8::Isolate* GetRuntime() const { return m_pIsolate; } @@ -87,7 +89,6 @@ class CXFA_ScriptContext { FX_BOOL RunVariablesScript(CXFA_Node* pScriptNode); CXFA_Object* GetVariablesThis(CXFA_Object* pObject, FX_BOOL bScriptNode = FALSE); - void ReleaseVariablesMap(); FX_BOOL IsStrictScopeInJavaScript(); XFA_SCRIPTLANGTYPE GetType(); CXFA_NodeArray& GetUpObjectArray() { return m_upObjectArray; } @@ -103,18 +104,19 @@ class CXFA_ScriptContext { void RemoveBuiltInObjs(CFXJSE_Context* pContext) const; CXFA_Document* m_pDocument; - CFXJSE_Context* m_pJsContext; + std::unique_ptr m_JsContext; v8::Isolate* m_pIsolate; CFXJSE_Class* m_pJsClass; XFA_SCRIPTLANGTYPE m_eScriptType; - CFX_MapPtrTemplate m_mapXFAToValue; + std::map> m_mapObjectToValue; CFX_MapPtrTemplate m_mapVariableToContext; CXFA_EventParam m_eventParam; CXFA_NodeArray m_upObjectArray; - CFX_ArrayTemplate m_CacheListArray; + // CacheList holds the NodeList items so we can clean them up when we're done. + std::vector> m_CacheList; CXFA_NodeArray* m_pScriptNodeArray; - CXFA_ResolveProcessor* m_pResolveProcessor; - CXFA_FM2JSContext* m_hFM2JSContext; + std::unique_ptr m_ResolveProcessor; + std::unique_ptr m_FM2JSContext; CXFA_Object* m_pThisObject; uint32_t m_dwBuiltInInFlags; XFA_ATTRIBUTEENUM m_eRunAtType; -- cgit v1.2.3