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

Side by Side Diff: xfa/fxfa/parser/xfa_script_imp.h

Issue 2062113002: Cleanup ownership in CXFA_ScriptContext. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Review feedback Created 4 years, 6 months 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/xfa_object_imp.cpp ('k') | xfa/fxfa/parser/xfa_script_imp.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 #ifndef XFA_FXFA_PARSER_XFA_SCRIPT_IMP_H_ 7 #ifndef XFA_FXFA_PARSER_XFA_SCRIPT_IMP_H_
8 #define XFA_FXFA_PARSER_XFA_SCRIPT_IMP_H_ 8 #define XFA_FXFA_PARSER_XFA_SCRIPT_IMP_H_
9 9
10 #include <map> 10 #include <map>
11 #include <memory>
12 #include <vector>
11 13
12 #include "fxjse/include/cfxjse_arguments.h" 14 #include "fxjse/include/cfxjse_arguments.h"
13 #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h" 15 #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h"
14 #include "xfa/fxfa/parser/xfa_document.h" 16 #include "xfa/fxfa/parser/xfa_document.h"
15 #include "xfa/fxfa/parser/xfa_script.h" 17 #include "xfa/fxfa/parser/xfa_script.h"
16 18
17 #define XFA_RESOLVENODE_TagName 0x0002 19 #define XFA_RESOLVENODE_TagName 0x0002
18 20
19 class CXFA_ResolveProcessor; 21 class CXFA_ResolveProcessor;
20 22
21 class CXFA_ScriptContext { 23 class CXFA_ScriptContext {
22 public: 24 public:
23 explicit CXFA_ScriptContext(CXFA_Document* pDocument); 25 explicit CXFA_ScriptContext(CXFA_Document* pDocument);
24 ~CXFA_ScriptContext(); 26 ~CXFA_ScriptContext();
25 27
26 void Initialize(v8::Isolate* pIsolate); 28 void Initialize(v8::Isolate* pIsolate);
27 void SetEventParam(CXFA_EventParam param) { m_eventParam = param; } 29 void SetEventParam(CXFA_EventParam param) { m_eventParam = param; }
28 CXFA_EventParam* GetEventParam() { return &m_eventParam; } 30 CXFA_EventParam* GetEventParam() { return &m_eventParam; }
29 FX_BOOL RunScript(XFA_SCRIPTLANGTYPE eScriptType, 31 FX_BOOL RunScript(XFA_SCRIPTLANGTYPE eScriptType,
30 const CFX_WideStringC& wsScript, 32 const CFX_WideStringC& wsScript,
31 CFXJSE_Value* pRetValue, 33 CFXJSE_Value* pRetValue,
32 CXFA_Object* pThisObject = NULL); 34 CXFA_Object* pThisObject = NULL);
33 35
34 int32_t ResolveObjects(CXFA_Object* refNode, 36 int32_t ResolveObjects(CXFA_Object* refNode,
35 const CFX_WideStringC& wsExpression, 37 const CFX_WideStringC& wsExpression,
36 XFA_RESOLVENODE_RS& resolveNodeRS, 38 XFA_RESOLVENODE_RS& resolveNodeRS,
37 uint32_t dwStyles = XFA_RESOLVENODE_Children, 39 uint32_t dwStyles = XFA_RESOLVENODE_Children,
38 CXFA_Node* bindNode = NULL); 40 CXFA_Node* bindNode = NULL);
39 CFXJSE_Value* GetJSValueFromMap(CXFA_Object* pObject); 41 CFXJSE_Value* GetJSValueFromMap(CXFA_Object* pObject);
40 void CacheList(CXFA_NodeList* pList) { m_CacheListArray.Add(pList); } 42 void AddToCacheList(std::unique_ptr<CXFA_NodeList> pList);
41 CXFA_Object* GetThisObject() const { return m_pThisObject; } 43 CXFA_Object* GetThisObject() const { return m_pThisObject; }
42 v8::Isolate* GetRuntime() const { return m_pIsolate; } 44 v8::Isolate* GetRuntime() const { return m_pIsolate; }
43 45
44 int32_t GetIndexByName(CXFA_Node* refNode); 46 int32_t GetIndexByName(CXFA_Node* refNode);
45 int32_t GetIndexByClassName(CXFA_Node* refNode); 47 int32_t GetIndexByClassName(CXFA_Node* refNode);
46 void GetSomExpression(CXFA_Node* refNode, CFX_WideString& wsExpression); 48 void GetSomExpression(CXFA_Node* refNode, CFX_WideString& wsExpression);
47 49
48 void SetNodesOfRunScript(CXFA_NodeArray* pArray); 50 void SetNodesOfRunScript(CXFA_NodeArray* pArray);
49 void AddNodesOfRunScript(const CXFA_NodeArray& nodes); 51 void AddNodesOfRunScript(const CXFA_NodeArray& nodes);
50 void AddNodesOfRunScript(CXFA_Node* pNode); 52 void AddNodesOfRunScript(CXFA_Node* pNode);
(...skipping 29 matching lines...) Expand all
80 CFXJSE_Arguments& args); 82 CFXJSE_Arguments& args);
81 static int32_t NormalPropTypeGetter(CFXJSE_Value* pObject, 83 static int32_t NormalPropTypeGetter(CFXJSE_Value* pObject,
82 const CFX_ByteStringC& szPropName, 84 const CFX_ByteStringC& szPropName,
83 FX_BOOL bQueryIn); 85 FX_BOOL bQueryIn);
84 static int32_t GlobalPropTypeGetter(CFXJSE_Value* pObject, 86 static int32_t GlobalPropTypeGetter(CFXJSE_Value* pObject,
85 const CFX_ByteStringC& szPropName, 87 const CFX_ByteStringC& szPropName,
86 FX_BOOL bQueryIn); 88 FX_BOOL bQueryIn);
87 FX_BOOL RunVariablesScript(CXFA_Node* pScriptNode); 89 FX_BOOL RunVariablesScript(CXFA_Node* pScriptNode);
88 CXFA_Object* GetVariablesThis(CXFA_Object* pObject, 90 CXFA_Object* GetVariablesThis(CXFA_Object* pObject,
89 FX_BOOL bScriptNode = FALSE); 91 FX_BOOL bScriptNode = FALSE);
90 void ReleaseVariablesMap();
91 FX_BOOL IsStrictScopeInJavaScript(); 92 FX_BOOL IsStrictScopeInJavaScript();
92 XFA_SCRIPTLANGTYPE GetType(); 93 XFA_SCRIPTLANGTYPE GetType();
93 CXFA_NodeArray& GetUpObjectArray() { return m_upObjectArray; } 94 CXFA_NodeArray& GetUpObjectArray() { return m_upObjectArray; }
94 CXFA_Document* GetDocument() const { return m_pDocument; } 95 CXFA_Document* GetDocument() const { return m_pDocument; }
95 96
96 static CXFA_Object* ToObject(CFXJSE_Value* pValue, CFXJSE_Class* pClass); 97 static CXFA_Object* ToObject(CFXJSE_Value* pValue, CFXJSE_Class* pClass);
97 98
98 private: 99 private:
99 void DefineJsContext(); 100 void DefineJsContext();
100 CFXJSE_Context* CreateVariablesContext(CXFA_Node* pScriptNode, 101 CFXJSE_Context* CreateVariablesContext(CXFA_Node* pScriptNode,
101 CXFA_Node* pSubform); 102 CXFA_Node* pSubform);
102 void DefineJsClass(); 103 void DefineJsClass();
103 void RemoveBuiltInObjs(CFXJSE_Context* pContext) const; 104 void RemoveBuiltInObjs(CFXJSE_Context* pContext) const;
104 105
105 CXFA_Document* m_pDocument; 106 CXFA_Document* m_pDocument;
106 CFXJSE_Context* m_pJsContext; 107 std::unique_ptr<CFXJSE_Context> m_JsContext;
107 v8::Isolate* m_pIsolate; 108 v8::Isolate* m_pIsolate;
108 CFXJSE_Class* m_pJsClass; 109 CFXJSE_Class* m_pJsClass;
109 XFA_SCRIPTLANGTYPE m_eScriptType; 110 XFA_SCRIPTLANGTYPE m_eScriptType;
110 CFX_MapPtrTemplate<CXFA_Object*, CFXJSE_Value*> m_mapXFAToValue; 111 std::map<CXFA_Object*, std::unique_ptr<CFXJSE_Value>> m_mapObjectToValue;
111 CFX_MapPtrTemplate<CXFA_Object*, CFXJSE_Context*> m_mapVariableToContext; 112 CFX_MapPtrTemplate<CXFA_Object*, CFXJSE_Context*> m_mapVariableToContext;
112 CXFA_EventParam m_eventParam; 113 CXFA_EventParam m_eventParam;
113 CXFA_NodeArray m_upObjectArray; 114 CXFA_NodeArray m_upObjectArray;
114 CFX_ArrayTemplate<CXFA_NodeList*> m_CacheListArray; 115 // CacheList holds the NodeList items so we can clean them up when we're done.
116 std::vector<std::unique_ptr<CXFA_NodeList>> m_CacheList;
115 CXFA_NodeArray* m_pScriptNodeArray; 117 CXFA_NodeArray* m_pScriptNodeArray;
116 CXFA_ResolveProcessor* m_pResolveProcessor; 118 std::unique_ptr<CXFA_ResolveProcessor> m_ResolveProcessor;
117 CXFA_FM2JSContext* m_hFM2JSContext; 119 std::unique_ptr<CXFA_FM2JSContext> m_FM2JSContext;
118 CXFA_Object* m_pThisObject; 120 CXFA_Object* m_pThisObject;
119 uint32_t m_dwBuiltInInFlags; 121 uint32_t m_dwBuiltInInFlags;
120 XFA_ATTRIBUTEENUM m_eRunAtType; 122 XFA_ATTRIBUTEENUM m_eRunAtType;
121 }; 123 };
122 124
123 #endif // XFA_FXFA_PARSER_XFA_SCRIPT_IMP_H_ 125 #endif // XFA_FXFA_PARSER_XFA_SCRIPT_IMP_H_
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/xfa_object_imp.cpp ('k') | xfa/fxfa/parser/xfa_script_imp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698