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_CXFA_SCRIPTCONTEXT_H_ | 7 #ifndef XFA_FXFA_PARSER_CXFA_SCRIPTCONTEXT_H_ |
8 #define XFA_FXFA_PARSER_CXFA_SCRIPTCONTEXT_H_ | 8 #define XFA_FXFA_PARSER_CXFA_SCRIPTCONTEXT_H_ |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 11 matching lines...) Expand all Loading... |
22 class CXFA_ResolveProcessor; | 22 class CXFA_ResolveProcessor; |
23 | 23 |
24 class CXFA_ScriptContext { | 24 class CXFA_ScriptContext { |
25 public: | 25 public: |
26 explicit CXFA_ScriptContext(CXFA_Document* pDocument); | 26 explicit CXFA_ScriptContext(CXFA_Document* pDocument); |
27 ~CXFA_ScriptContext(); | 27 ~CXFA_ScriptContext(); |
28 | 28 |
29 void Initialize(v8::Isolate* pIsolate); | 29 void Initialize(v8::Isolate* pIsolate); |
30 void SetEventParam(CXFA_EventParam param) { m_eventParam = param; } | 30 void SetEventParam(CXFA_EventParam param) { m_eventParam = param; } |
31 CXFA_EventParam* GetEventParam() { return &m_eventParam; } | 31 CXFA_EventParam* GetEventParam() { return &m_eventParam; } |
32 FX_BOOL RunScript(XFA_SCRIPTLANGTYPE eScriptType, | 32 bool RunScript(XFA_SCRIPTLANGTYPE eScriptType, |
33 const CFX_WideStringC& wsScript, | 33 const CFX_WideStringC& wsScript, |
34 CFXJSE_Value* pRetValue, | 34 CFXJSE_Value* pRetValue, |
35 CXFA_Object* pThisObject = nullptr); | 35 CXFA_Object* pThisObject = nullptr); |
36 | 36 |
37 int32_t ResolveObjects(CXFA_Object* refNode, | 37 int32_t ResolveObjects(CXFA_Object* refNode, |
38 const CFX_WideStringC& wsExpression, | 38 const CFX_WideStringC& wsExpression, |
39 XFA_RESOLVENODE_RS& resolveNodeRS, | 39 XFA_RESOLVENODE_RS& resolveNodeRS, |
40 uint32_t dwStyles = XFA_RESOLVENODE_Children, | 40 uint32_t dwStyles = XFA_RESOLVENODE_Children, |
41 CXFA_Node* bindNode = nullptr); | 41 CXFA_Node* bindNode = nullptr); |
42 CFXJSE_Value* GetJSValueFromMap(CXFA_Object* pObject); | 42 CFXJSE_Value* GetJSValueFromMap(CXFA_Object* pObject); |
43 void AddToCacheList(std::unique_ptr<CXFA_NodeList> pList); | 43 void AddToCacheList(std::unique_ptr<CXFA_NodeList> pList); |
44 CXFA_Object* GetThisObject() const { return m_pThisObject; } | 44 CXFA_Object* GetThisObject() const { return m_pThisObject; } |
45 v8::Isolate* GetRuntime() const { return m_pIsolate; } | 45 v8::Isolate* GetRuntime() const { return m_pIsolate; } |
46 | 46 |
47 int32_t GetIndexByName(CXFA_Node* refNode); | 47 int32_t GetIndexByName(CXFA_Node* refNode); |
48 int32_t GetIndexByClassName(CXFA_Node* refNode); | 48 int32_t GetIndexByClassName(CXFA_Node* refNode); |
49 void GetSomExpression(CXFA_Node* refNode, CFX_WideString& wsExpression); | 49 void GetSomExpression(CXFA_Node* refNode, CFX_WideString& wsExpression); |
50 | 50 |
51 void SetNodesOfRunScript(CXFA_NodeArray* pArray); | 51 void SetNodesOfRunScript(CXFA_NodeArray* pArray); |
52 void AddNodesOfRunScript(const CXFA_NodeArray& nodes); | 52 void AddNodesOfRunScript(const CXFA_NodeArray& nodes); |
53 void AddNodesOfRunScript(CXFA_Node* pNode); | 53 void AddNodesOfRunScript(CXFA_Node* pNode); |
54 CFXJSE_Class* GetJseNormalClass(); | 54 CFXJSE_Class* GetJseNormalClass(); |
55 | 55 |
56 void SetRunAtType(XFA_ATTRIBUTEENUM eRunAt) { m_eRunAtType = eRunAt; } | 56 void SetRunAtType(XFA_ATTRIBUTEENUM eRunAt) { m_eRunAtType = eRunAt; } |
57 FX_BOOL IsRunAtClient() { return m_eRunAtType != XFA_ATTRIBUTEENUM_Server; } | 57 bool IsRunAtClient() { return m_eRunAtType != XFA_ATTRIBUTEENUM_Server; } |
58 FX_BOOL QueryNodeByFlag(CXFA_Node* refNode, | 58 bool QueryNodeByFlag(CXFA_Node* refNode, |
59 const CFX_WideStringC& propname, | 59 const CFX_WideStringC& propname, |
| 60 CFXJSE_Value* pValue, |
| 61 uint32_t dwFlag, |
| 62 bool bSetting); |
| 63 bool QueryVariableValue(CXFA_Node* pScriptNode, |
| 64 const CFX_ByteStringC& szPropName, |
60 CFXJSE_Value* pValue, | 65 CFXJSE_Value* pValue, |
61 uint32_t dwFlag, | 66 bool bGetter); |
62 FX_BOOL bSetting); | 67 bool QueryBuiltinValue(const CFX_ByteStringC& szPropName, |
63 FX_BOOL QueryVariableValue(CXFA_Node* pScriptNode, | 68 CFXJSE_Value* pValue); |
64 const CFX_ByteStringC& szPropName, | |
65 CFXJSE_Value* pValue, | |
66 FX_BOOL bGetter); | |
67 FX_BOOL QueryBuiltinValue(const CFX_ByteStringC& szPropName, | |
68 CFXJSE_Value* pValue); | |
69 static void GlobalPropertyGetter(CFXJSE_Value* pObject, | 69 static void GlobalPropertyGetter(CFXJSE_Value* pObject, |
70 const CFX_ByteStringC& szPropName, | 70 const CFX_ByteStringC& szPropName, |
71 CFXJSE_Value* pValue); | 71 CFXJSE_Value* pValue); |
72 static void GlobalPropertySetter(CFXJSE_Value* pObject, | 72 static void GlobalPropertySetter(CFXJSE_Value* pObject, |
73 const CFX_ByteStringC& szPropName, | 73 const CFX_ByteStringC& szPropName, |
74 CFXJSE_Value* pValue); | 74 CFXJSE_Value* pValue); |
75 static void NormalPropertyGetter(CFXJSE_Value* pObject, | 75 static void NormalPropertyGetter(CFXJSE_Value* pObject, |
76 const CFX_ByteStringC& szPropName, | 76 const CFX_ByteStringC& szPropName, |
77 CFXJSE_Value* pValue); | 77 CFXJSE_Value* pValue); |
78 static void NormalPropertySetter(CFXJSE_Value* pObject, | 78 static void NormalPropertySetter(CFXJSE_Value* pObject, |
79 const CFX_ByteStringC& szPropName, | 79 const CFX_ByteStringC& szPropName, |
80 CFXJSE_Value* pValue); | 80 CFXJSE_Value* pValue); |
81 static void NormalMethodCall(CFXJSE_Value* hThis, | 81 static void NormalMethodCall(CFXJSE_Value* hThis, |
82 const CFX_ByteStringC& szFuncName, | 82 const CFX_ByteStringC& szFuncName, |
83 CFXJSE_Arguments& args); | 83 CFXJSE_Arguments& args); |
84 static int32_t NormalPropTypeGetter(CFXJSE_Value* pObject, | 84 static int32_t NormalPropTypeGetter(CFXJSE_Value* pObject, |
85 const CFX_ByteStringC& szPropName, | 85 const CFX_ByteStringC& szPropName, |
86 FX_BOOL bQueryIn); | 86 bool bQueryIn); |
87 static int32_t GlobalPropTypeGetter(CFXJSE_Value* pObject, | 87 static int32_t GlobalPropTypeGetter(CFXJSE_Value* pObject, |
88 const CFX_ByteStringC& szPropName, | 88 const CFX_ByteStringC& szPropName, |
89 FX_BOOL bQueryIn); | 89 bool bQueryIn); |
90 FX_BOOL RunVariablesScript(CXFA_Node* pScriptNode); | 90 bool RunVariablesScript(CXFA_Node* pScriptNode); |
91 CXFA_Object* GetVariablesThis(CXFA_Object* pObject, | 91 CXFA_Object* GetVariablesThis(CXFA_Object* pObject, bool bScriptNode = false); |
92 FX_BOOL bScriptNode = FALSE); | 92 bool IsStrictScopeInJavaScript(); |
93 FX_BOOL IsStrictScopeInJavaScript(); | |
94 XFA_SCRIPTLANGTYPE GetType(); | 93 XFA_SCRIPTLANGTYPE GetType(); |
95 CXFA_NodeArray& GetUpObjectArray() { return m_upObjectArray; } | 94 CXFA_NodeArray& GetUpObjectArray() { return m_upObjectArray; } |
96 CXFA_Document* GetDocument() const { return m_pDocument; } | 95 CXFA_Document* GetDocument() const { return m_pDocument; } |
97 | 96 |
98 static CXFA_Object* ToObject(CFXJSE_Value* pValue, CFXJSE_Class* pClass); | 97 static CXFA_Object* ToObject(CFXJSE_Value* pValue, CFXJSE_Class* pClass); |
99 | 98 |
100 private: | 99 private: |
101 void DefineJsContext(); | 100 void DefineJsContext(); |
102 CFXJSE_Context* CreateVariablesContext(CXFA_Node* pScriptNode, | 101 CFXJSE_Context* CreateVariablesContext(CXFA_Node* pScriptNode, |
103 CXFA_Node* pSubform); | 102 CXFA_Node* pSubform); |
(...skipping 13 matching lines...) Expand all Loading... |
117 std::vector<std::unique_ptr<CXFA_NodeList>> m_CacheList; | 116 std::vector<std::unique_ptr<CXFA_NodeList>> m_CacheList; |
118 CXFA_NodeArray* m_pScriptNodeArray; | 117 CXFA_NodeArray* m_pScriptNodeArray; |
119 std::unique_ptr<CXFA_ResolveProcessor> m_ResolveProcessor; | 118 std::unique_ptr<CXFA_ResolveProcessor> m_ResolveProcessor; |
120 std::unique_ptr<CXFA_FM2JSContext> m_FM2JSContext; | 119 std::unique_ptr<CXFA_FM2JSContext> m_FM2JSContext; |
121 CXFA_Object* m_pThisObject; | 120 CXFA_Object* m_pThisObject; |
122 uint32_t m_dwBuiltInInFlags; | 121 uint32_t m_dwBuiltInInFlags; |
123 XFA_ATTRIBUTEENUM m_eRunAtType; | 122 XFA_ATTRIBUTEENUM m_eRunAtType; |
124 }; | 123 }; |
125 | 124 |
126 #endif // XFA_FXFA_PARSER_CXFA_SCRIPTCONTEXT_H_ | 125 #endif // XFA_FXFA_PARSER_CXFA_SCRIPTCONTEXT_H_ |
OLD | NEW |