OLD | NEW |
---|---|
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 // This takes ownership of |pList| |
Lei Zhang
2016/06/14 19:29:12
No need, already implied by unique_ptr.
dsinclair
2016/06/14 20:19:43
Done.
| |
43 void AddToCacheList(std::unique_ptr<CXFA_NodeList> pList) { | |
44 m_CacheList.push_back(std::move(pList)); | |
Lei Zhang
2016/06/14 19:29:12
The Clang plugin may complain this is complex and
dsinclair
2016/06/14 20:19:43
Moved.
| |
45 } | |
41 CXFA_Object* GetThisObject() const { return m_pThisObject; } | 46 CXFA_Object* GetThisObject() const { return m_pThisObject; } |
42 v8::Isolate* GetRuntime() const { return m_pIsolate; } | 47 v8::Isolate* GetRuntime() const { return m_pIsolate; } |
43 | 48 |
44 int32_t GetIndexByName(CXFA_Node* refNode); | 49 int32_t GetIndexByName(CXFA_Node* refNode); |
45 int32_t GetIndexByClassName(CXFA_Node* refNode); | 50 int32_t GetIndexByClassName(CXFA_Node* refNode); |
46 void GetSomExpression(CXFA_Node* refNode, CFX_WideString& wsExpression); | 51 void GetSomExpression(CXFA_Node* refNode, CFX_WideString& wsExpression); |
47 | 52 |
48 void SetNodesOfRunScript(CXFA_NodeArray* pArray); | 53 void SetNodesOfRunScript(CXFA_NodeArray* pArray); |
49 void AddNodesOfRunScript(const CXFA_NodeArray& nodes); | 54 void AddNodesOfRunScript(const CXFA_NodeArray& nodes); |
50 void AddNodesOfRunScript(CXFA_Node* pNode); | 55 void AddNodesOfRunScript(CXFA_Node* pNode); |
(...skipping 29 matching lines...) Expand all Loading... | |
80 CFXJSE_Arguments& args); | 85 CFXJSE_Arguments& args); |
81 static int32_t NormalPropTypeGetter(CFXJSE_Value* pObject, | 86 static int32_t NormalPropTypeGetter(CFXJSE_Value* pObject, |
82 const CFX_ByteStringC& szPropName, | 87 const CFX_ByteStringC& szPropName, |
83 FX_BOOL bQueryIn); | 88 FX_BOOL bQueryIn); |
84 static int32_t GlobalPropTypeGetter(CFXJSE_Value* pObject, | 89 static int32_t GlobalPropTypeGetter(CFXJSE_Value* pObject, |
85 const CFX_ByteStringC& szPropName, | 90 const CFX_ByteStringC& szPropName, |
86 FX_BOOL bQueryIn); | 91 FX_BOOL bQueryIn); |
87 FX_BOOL RunVariablesScript(CXFA_Node* pScriptNode); | 92 FX_BOOL RunVariablesScript(CXFA_Node* pScriptNode); |
88 CXFA_Object* GetVariablesThis(CXFA_Object* pObject, | 93 CXFA_Object* GetVariablesThis(CXFA_Object* pObject, |
89 FX_BOOL bScriptNode = FALSE); | 94 FX_BOOL bScriptNode = FALSE); |
90 void ReleaseVariablesMap(); | |
91 FX_BOOL IsStrictScopeInJavaScript(); | 95 FX_BOOL IsStrictScopeInJavaScript(); |
92 XFA_SCRIPTLANGTYPE GetType(); | 96 XFA_SCRIPTLANGTYPE GetType(); |
93 CXFA_NodeArray& GetUpObjectArray() { return m_upObjectArray; } | 97 CXFA_NodeArray& GetUpObjectArray() { return m_upObjectArray; } |
94 CXFA_Document* GetDocument() const { return m_pDocument; } | 98 CXFA_Document* GetDocument() const { return m_pDocument; } |
95 | 99 |
96 static CXFA_Object* ToObject(CFXJSE_Value* pValue, CFXJSE_Class* pClass); | 100 static CXFA_Object* ToObject(CFXJSE_Value* pValue, CFXJSE_Class* pClass); |
97 | 101 |
98 private: | 102 private: |
99 void DefineJsContext(); | 103 void DefineJsContext(); |
100 CFXJSE_Context* CreateVariablesContext(CXFA_Node* pScriptNode, | 104 CFXJSE_Context* CreateVariablesContext(CXFA_Node* pScriptNode, |
101 CXFA_Node* pSubform); | 105 CXFA_Node* pSubform); |
102 void DefineJsClass(); | 106 void DefineJsClass(); |
103 void RemoveBuiltInObjs(CFXJSE_Context* pContext) const; | 107 void RemoveBuiltInObjs(CFXJSE_Context* pContext) const; |
104 | 108 |
105 CXFA_Document* m_pDocument; | 109 CXFA_Document* m_pDocument; |
106 CFXJSE_Context* m_pJsContext; | 110 std::unique_ptr<CFXJSE_Context> m_JsContext; |
107 v8::Isolate* m_pIsolate; | 111 v8::Isolate* m_pIsolate; |
108 CFXJSE_Class* m_pJsClass; | 112 CFXJSE_Class* m_pJsClass; |
109 XFA_SCRIPTLANGTYPE m_eScriptType; | 113 XFA_SCRIPTLANGTYPE m_eScriptType; |
110 CFX_MapPtrTemplate<CXFA_Object*, CFXJSE_Value*> m_mapXFAToValue; | 114 std::map<CXFA_Object*, std::unique_ptr<CFXJSE_Value>> m_mapObjectToValue; |
111 CFX_MapPtrTemplate<CXFA_Object*, CFXJSE_Context*> m_mapVariableToContext; | 115 CFX_MapPtrTemplate<CXFA_Object*, CFXJSE_Context*> m_mapVariableToContext; |
112 CXFA_EventParam m_eventParam; | 116 CXFA_EventParam m_eventParam; |
113 CXFA_NodeArray m_upObjectArray; | 117 CXFA_NodeArray m_upObjectArray; |
114 CFX_ArrayTemplate<CXFA_NodeList*> m_CacheListArray; | 118 // CacheList holds the NodeList items so we can clean them up when we're done. |
119 std::vector<std::unique_ptr<CXFA_NodeList>> m_CacheList; | |
115 CXFA_NodeArray* m_pScriptNodeArray; | 120 CXFA_NodeArray* m_pScriptNodeArray; |
116 CXFA_ResolveProcessor* m_pResolveProcessor; | 121 std::unique_ptr<CXFA_ResolveProcessor> m_ResolveProcessor; |
117 CXFA_FM2JSContext* m_hFM2JSContext; | 122 std::unique_ptr<CXFA_FM2JSContext> m_FM2JSContext; |
118 CXFA_Object* m_pThisObject; | 123 CXFA_Object* m_pThisObject; |
119 uint32_t m_dwBuiltInInFlags; | 124 uint32_t m_dwBuiltInInFlags; |
120 XFA_ATTRIBUTEENUM m_eRunAtType; | 125 XFA_ATTRIBUTEENUM m_eRunAtType; |
121 }; | 126 }; |
122 | 127 |
123 #endif // XFA_FXFA_PARSER_XFA_SCRIPT_IMP_H_ | 128 #endif // XFA_FXFA_PARSER_XFA_SCRIPT_IMP_H_ |
OLD | NEW |