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> |
(...skipping 10 matching lines...) Expand all Loading... |
21 class CXFA_ScriptContext { | 21 class CXFA_ScriptContext { |
22 public: | 22 public: |
23 explicit CXFA_ScriptContext(CXFA_Document* pDocument); | 23 explicit CXFA_ScriptContext(CXFA_Document* pDocument); |
24 ~CXFA_ScriptContext(); | 24 ~CXFA_ScriptContext(); |
25 | 25 |
26 void Initialize(v8::Isolate* pIsolate); | 26 void Initialize(v8::Isolate* pIsolate); |
27 void SetEventParam(CXFA_EventParam param) { m_eventParam = param; } | 27 void SetEventParam(CXFA_EventParam param) { m_eventParam = param; } |
28 CXFA_EventParam* GetEventParam() { return &m_eventParam; } | 28 CXFA_EventParam* GetEventParam() { return &m_eventParam; } |
29 FX_BOOL RunScript(XFA_SCRIPTLANGTYPE eScriptType, | 29 FX_BOOL RunScript(XFA_SCRIPTLANGTYPE eScriptType, |
30 const CFX_WideStringC& wsScript, | 30 const CFX_WideStringC& wsScript, |
31 FXJSE_HVALUE hRetValue, | 31 CFXJSE_Value* pRetValue, |
32 CXFA_Object* pThisObject = NULL); | 32 CXFA_Object* pThisObject = NULL); |
33 | 33 |
34 int32_t ResolveObjects(CXFA_Object* refNode, | 34 int32_t ResolveObjects(CXFA_Object* refNode, |
35 const CFX_WideStringC& wsExpression, | 35 const CFX_WideStringC& wsExpression, |
36 XFA_RESOLVENODE_RS& resolveNodeRS, | 36 XFA_RESOLVENODE_RS& resolveNodeRS, |
37 uint32_t dwStyles = XFA_RESOLVENODE_Children, | 37 uint32_t dwStyles = XFA_RESOLVENODE_Children, |
38 CXFA_Node* bindNode = NULL); | 38 CXFA_Node* bindNode = NULL); |
39 FXJSE_HVALUE GetJSValueFromMap(CXFA_Object* pObject); | 39 CFXJSE_Value* GetJSValueFromMap(CXFA_Object* pObject); |
40 void CacheList(CXFA_NodeList* pList) { m_CacheListArray.Add(pList); } | 40 void CacheList(CXFA_NodeList* pList) { m_CacheListArray.Add(pList); } |
41 CXFA_Object* GetThisObject() const { return m_pThisObject; } | 41 CXFA_Object* GetThisObject() const { return m_pThisObject; } |
42 v8::Isolate* GetRuntime() const { return m_pIsolate; } | 42 v8::Isolate* GetRuntime() const { return m_pIsolate; } |
43 | 43 |
44 int32_t GetIndexByName(CXFA_Node* refNode); | 44 int32_t GetIndexByName(CXFA_Node* refNode); |
45 int32_t GetIndexByClassName(CXFA_Node* refNode); | 45 int32_t GetIndexByClassName(CXFA_Node* refNode); |
46 void GetSomExpression(CXFA_Node* refNode, CFX_WideString& wsExpression); | 46 void GetSomExpression(CXFA_Node* refNode, CFX_WideString& wsExpression); |
47 | 47 |
48 void SetNodesOfRunScript(CXFA_NodeArray* pArray); | 48 void SetNodesOfRunScript(CXFA_NodeArray* pArray); |
49 void AddNodesOfRunScript(const CXFA_NodeArray& nodes); | 49 void AddNodesOfRunScript(const CXFA_NodeArray& nodes); |
50 void AddNodesOfRunScript(CXFA_Node* pNode); | 50 void AddNodesOfRunScript(CXFA_Node* pNode); |
51 CFXJSE_Class* GetJseNormalClass(); | 51 CFXJSE_Class* GetJseNormalClass(); |
52 | 52 |
53 void SetRunAtType(XFA_ATTRIBUTEENUM eRunAt) { m_eRunAtType = eRunAt; } | 53 void SetRunAtType(XFA_ATTRIBUTEENUM eRunAt) { m_eRunAtType = eRunAt; } |
54 FX_BOOL IsRunAtClient() { return m_eRunAtType != XFA_ATTRIBUTEENUM_Server; } | 54 FX_BOOL IsRunAtClient() { return m_eRunAtType != XFA_ATTRIBUTEENUM_Server; } |
55 FX_BOOL QueryNodeByFlag(CXFA_Node* refNode, | 55 FX_BOOL QueryNodeByFlag(CXFA_Node* refNode, |
56 const CFX_WideStringC& propname, | 56 const CFX_WideStringC& propname, |
57 FXJSE_HVALUE hValue, | 57 CFXJSE_Value* pValue, |
58 uint32_t dwFlag, | 58 uint32_t dwFlag, |
59 FX_BOOL bSetting); | 59 FX_BOOL bSetting); |
60 FX_BOOL QueryVariableHValue(CXFA_Node* pScriptNode, | 60 FX_BOOL QueryVariableValue(CXFA_Node* pScriptNode, |
61 const CFX_ByteStringC& szPropName, | 61 const CFX_ByteStringC& szPropName, |
62 FXJSE_HVALUE hValue, | 62 CFXJSE_Value* pValue, |
63 FX_BOOL bGetter); | 63 FX_BOOL bGetter); |
64 FX_BOOL QueryBuiltinHValue(const CFX_ByteStringC& szPropName, | 64 FX_BOOL QueryBuiltinValue(const CFX_ByteStringC& szPropName, |
65 FXJSE_HVALUE hValue); | 65 CFXJSE_Value* pValue); |
66 static void GlobalPropertyGetter(FXJSE_HOBJECT hObject, | 66 static void GlobalPropertyGetter(CFXJSE_Value* pObject, |
67 const CFX_ByteStringC& szPropName, | 67 const CFX_ByteStringC& szPropName, |
68 FXJSE_HVALUE hValue); | 68 CFXJSE_Value* pValue); |
69 static void GlobalPropertySetter(FXJSE_HOBJECT hObject, | 69 static void GlobalPropertySetter(CFXJSE_Value* pObject, |
70 const CFX_ByteStringC& szPropName, | 70 const CFX_ByteStringC& szPropName, |
71 FXJSE_HVALUE hValue); | 71 CFXJSE_Value* pValue); |
72 static void NormalPropertyGetter(FXJSE_HOBJECT hObject, | 72 static void NormalPropertyGetter(CFXJSE_Value* pObject, |
73 const CFX_ByteStringC& szPropName, | 73 const CFX_ByteStringC& szPropName, |
74 FXJSE_HVALUE hValue); | 74 CFXJSE_Value* pValue); |
75 static void NormalPropertySetter(FXJSE_HOBJECT hObject, | 75 static void NormalPropertySetter(CFXJSE_Value* pObject, |
76 const CFX_ByteStringC& szPropName, | 76 const CFX_ByteStringC& szPropName, |
77 FXJSE_HVALUE hValue); | 77 CFXJSE_Value* pValue); |
78 static void NormalMethodCall(FXJSE_HOBJECT hThis, | 78 static void NormalMethodCall(CFXJSE_Value* hThis, |
79 const CFX_ByteStringC& szFuncName, | 79 const CFX_ByteStringC& szFuncName, |
80 CFXJSE_Arguments& args); | 80 CFXJSE_Arguments& args); |
81 static int32_t NormalPropTypeGetter(FXJSE_HOBJECT hObject, | 81 static int32_t NormalPropTypeGetter(CFXJSE_Value* pObject, |
82 const CFX_ByteStringC& szPropName, | 82 const CFX_ByteStringC& szPropName, |
83 FX_BOOL bQueryIn); | 83 FX_BOOL bQueryIn); |
84 static int32_t GlobalPropTypeGetter(FXJSE_HOBJECT hObject, | 84 static int32_t GlobalPropTypeGetter(CFXJSE_Value* pObject, |
85 const CFX_ByteStringC& szPropName, | 85 const CFX_ByteStringC& szPropName, |
86 FX_BOOL bQueryIn); | 86 FX_BOOL bQueryIn); |
87 FX_BOOL RunVariablesScript(CXFA_Node* pScriptNode); | 87 FX_BOOL RunVariablesScript(CXFA_Node* pScriptNode); |
88 CXFA_Object* GetVariablesThis(CXFA_Object* pObject, | 88 CXFA_Object* GetVariablesThis(CXFA_Object* pObject, |
89 FX_BOOL bScriptNode = FALSE); | 89 FX_BOOL bScriptNode = FALSE); |
90 void ReleaseVariablesMap(); | 90 void ReleaseVariablesMap(); |
91 FX_BOOL IsStrictScopeInJavaScript(); | 91 FX_BOOL IsStrictScopeInJavaScript(); |
92 XFA_SCRIPTLANGTYPE GetType(); | 92 XFA_SCRIPTLANGTYPE GetType(); |
93 CXFA_NodeArray& GetUpObjectArray() { return m_upObjectArray; } | 93 CXFA_NodeArray& GetUpObjectArray() { return m_upObjectArray; } |
94 CXFA_Document* GetDocument() const { return m_pDocument; } | 94 CXFA_Document* GetDocument() const { return m_pDocument; } |
95 | 95 |
96 private: | 96 private: |
97 void DefineJsContext(); | 97 void DefineJsContext(); |
98 CFXJSE_Context* CreateVariablesContext(CXFA_Node* pScriptNode, | 98 CFXJSE_Context* CreateVariablesContext(CXFA_Node* pScriptNode, |
99 CXFA_Node* pSubform); | 99 CXFA_Node* pSubform); |
100 void DefineJsClass(); | 100 void DefineJsClass(); |
101 void RemoveBuiltInObjs(CFXJSE_Context* pContext) const; | 101 void RemoveBuiltInObjs(CFXJSE_Context* pContext) const; |
102 | 102 |
103 CXFA_Document* m_pDocument; | 103 CXFA_Document* m_pDocument; |
104 CFXJSE_Context* m_pJsContext; | 104 CFXJSE_Context* m_pJsContext; |
105 v8::Isolate* m_pIsolate; | 105 v8::Isolate* m_pIsolate; |
106 CFXJSE_Class* m_pJsClass; | 106 CFXJSE_Class* m_pJsClass; |
107 XFA_SCRIPTLANGTYPE m_eScriptType; | 107 XFA_SCRIPTLANGTYPE m_eScriptType; |
108 FXJSE_CLASS m_JsGlobalClass; | 108 FXJSE_CLASS m_JsGlobalClass; |
109 FXJSE_CLASS m_JsNormalClass; | 109 FXJSE_CLASS m_JsNormalClass; |
110 CFX_MapPtrTemplate<CXFA_Object*, FXJSE_HVALUE> m_mapXFAToHValue; | 110 CFX_MapPtrTemplate<CXFA_Object*, CFXJSE_Value*> m_mapXFAToValue; |
111 FXJSE_CLASS m_JsGlobalVariablesClass; | 111 FXJSE_CLASS m_JsGlobalVariablesClass; |
112 CFX_MapPtrTemplate<CXFA_Object*, CFXJSE_Context*> m_mapVariableToContext; | 112 CFX_MapPtrTemplate<CXFA_Object*, CFXJSE_Context*> m_mapVariableToContext; |
113 CXFA_EventParam m_eventParam; | 113 CXFA_EventParam m_eventParam; |
114 CXFA_NodeArray m_upObjectArray; | 114 CXFA_NodeArray m_upObjectArray; |
115 CFX_ArrayTemplate<CXFA_NodeList*> m_CacheListArray; | 115 CFX_ArrayTemplate<CXFA_NodeList*> m_CacheListArray; |
116 CXFA_NodeArray* m_pScriptNodeArray; | 116 CXFA_NodeArray* m_pScriptNodeArray; |
117 CXFA_ResolveProcessor* m_pResolveProcessor; | 117 CXFA_ResolveProcessor* m_pResolveProcessor; |
118 XFA_HFM2JSCONTEXT m_hFM2JSContext; | 118 XFA_HFM2JSCONTEXT m_hFM2JSContext; |
119 CXFA_Object* m_pThisObject; | 119 CXFA_Object* m_pThisObject; |
120 uint32_t m_dwBuiltInInFlags; | 120 uint32_t m_dwBuiltInInFlags; |
121 XFA_ATTRIBUTEENUM m_eRunAtType; | 121 XFA_ATTRIBUTEENUM m_eRunAtType; |
122 }; | 122 }; |
123 | 123 |
124 #endif // XFA_FXFA_PARSER_XFA_SCRIPT_IMP_H_ | 124 #endif // XFA_FXFA_PARSER_XFA_SCRIPT_IMP_H_ |
OLD | NEW |