OLD | NEW |
| (Empty) |
1 // Copyright 2014 PDFium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
6 | |
7 #ifndef XFA_SRC_FXFA_PARSER_XFA_SCRIPT_IMP_H_ | |
8 #define XFA_SRC_FXFA_PARSER_XFA_SCRIPT_IMP_H_ | |
9 | |
10 #include <map> | |
11 | |
12 #include "xfa/src/fxfa/fm2js/xfa_fm2jsapi.h" | |
13 #include "xfa/src/fxfa/parser/xfa_document.h" | |
14 #include "xfa/src/fxfa/parser/xfa_script.h" | |
15 | |
16 #define XFA_RESOLVENODE_TagName 0x0002 | |
17 | |
18 class CXFA_ResolveProcessor; | |
19 | |
20 class CXFA_ScriptContext : public IXFA_ScriptContext { | |
21 public: | |
22 explicit CXFA_ScriptContext(CXFA_Document* pDocument); | |
23 ~CXFA_ScriptContext(); | |
24 | |
25 virtual void Release(); | |
26 virtual void Initialize(FXJSE_HRUNTIME hRuntime); | |
27 virtual void SetEventParam(CXFA_EventParam param) { m_eventParam = param; } | |
28 virtual CXFA_EventParam* GetEventParam() { return &m_eventParam; } | |
29 virtual FX_BOOL RunScript(XFA_SCRIPTLANGTYPE eScriptType, | |
30 const CFX_WideStringC& wsScript, | |
31 FXJSE_HVALUE hRetValue, | |
32 CXFA_Object* pThisObject = NULL); | |
33 | |
34 virtual int32_t ResolveObjects(CXFA_Object* refNode, | |
35 const CFX_WideStringC& wsExpression, | |
36 XFA_RESOLVENODE_RS& resolveNodeRS, | |
37 FX_DWORD dwStyles = XFA_RESOLVENODE_Children, | |
38 CXFA_Node* bindNode = NULL); | |
39 virtual FXJSE_HVALUE GetJSValueFromMap(CXFA_Object* pObject); | |
40 virtual void CacheList(CXFA_NodeList* pList) { m_CacheListArray.Add(pList); } | |
41 virtual CXFA_Object* GetThisObject() const { return m_pThisObject; } | |
42 virtual FXJSE_HRUNTIME GetRuntime() const { return m_hJsRuntime; } | |
43 | |
44 virtual int32_t GetIndexByName(CXFA_Node* refNode); | |
45 virtual int32_t GetIndexByClassName(CXFA_Node* refNode); | |
46 virtual void GetSomExpression(CXFA_Node* refNode, | |
47 CFX_WideString& wsExpression); | |
48 | |
49 virtual void SetNodesOfRunScript(CXFA_NodeArray* pArray); | |
50 virtual void AddNodesOfRunScript(const CXFA_NodeArray& nodes); | |
51 virtual void AddNodesOfRunScript(CXFA_Node* pNode); | |
52 virtual FXJSE_HCLASS GetJseNormalClass(); | |
53 | |
54 virtual void SetRunAtType(XFA_ATTRIBUTEENUM eRunAt) { m_eRunAtType = eRunAt; } | |
55 virtual FX_BOOL IsRunAtClient() { | |
56 return m_eRunAtType != XFA_ATTRIBUTEENUM_Server; | |
57 } | |
58 FX_BOOL QueryNodeByFlag(CXFA_Node* refNode, | |
59 const CFX_WideStringC& propname, | |
60 FXJSE_HVALUE hValue, | |
61 FX_DWORD dwFlag, | |
62 FX_BOOL bSetting); | |
63 FX_BOOL QueryVariableHValue(CXFA_Node* pScriptNode, | |
64 const CFX_ByteStringC& szPropName, | |
65 FXJSE_HVALUE hValue, | |
66 FX_BOOL bGetter); | |
67 FX_BOOL QueryBuiltinHValue(const CFX_ByteStringC& szPropName, | |
68 FXJSE_HVALUE hValue); | |
69 static void GlobalPropertyGetter(FXJSE_HOBJECT hObject, | |
70 const CFX_ByteStringC& szPropName, | |
71 FXJSE_HVALUE hValue); | |
72 static void GlobalPropertySetter(FXJSE_HOBJECT hObject, | |
73 const CFX_ByteStringC& szPropName, | |
74 FXJSE_HVALUE hValue); | |
75 static void NormalPropertyGetter(FXJSE_HOBJECT hObject, | |
76 const CFX_ByteStringC& szPropName, | |
77 FXJSE_HVALUE hValue); | |
78 static void NormalPropertySetter(FXJSE_HOBJECT hObject, | |
79 const CFX_ByteStringC& szPropName, | |
80 FXJSE_HVALUE hValue); | |
81 static void NormalMethodCall(FXJSE_HOBJECT hThis, | |
82 const CFX_ByteStringC& szFuncName, | |
83 CFXJSE_Arguments& args); | |
84 static int32_t NormalPropTypeGetter(FXJSE_HOBJECT hObject, | |
85 const CFX_ByteStringC& szPropName, | |
86 FX_BOOL bQueryIn); | |
87 static int32_t GlobalPropTypeGetter(FXJSE_HOBJECT hObject, | |
88 const CFX_ByteStringC& szPropName, | |
89 FX_BOOL bQueryIn); | |
90 FX_BOOL RunVariablesScript(CXFA_Node* pScriptNode); | |
91 CXFA_Object* GetVariablesThis(CXFA_Object* pObject, | |
92 FX_BOOL bScriptNode = FALSE); | |
93 void ReleaseVariablesMap(); | |
94 FX_BOOL IsStrictScopeInJavaScript(); | |
95 XFA_SCRIPTLANGTYPE GetType(); | |
96 CXFA_NodeArray& GetUpObjectArray() { return m_upObjectArray; } | |
97 CXFA_Document* GetDocument() const { return m_pDocument; } | |
98 | |
99 protected: | |
100 void DefineJsContext(); | |
101 FXJSE_HCONTEXT CreateVariablesContext(CXFA_Node* pScriptNode, | |
102 CXFA_Node* pSubform); | |
103 void DefineJsClass(); | |
104 void RemoveBuiltInObjs(FXJSE_HCONTEXT jsContext) const; | |
105 | |
106 CXFA_Document* m_pDocument; | |
107 FXJSE_HCONTEXT m_hJsContext; | |
108 FXJSE_HRUNTIME m_hJsRuntime; | |
109 FXJSE_HCLASS m_hJsClass; | |
110 XFA_SCRIPTLANGTYPE m_eScriptType; | |
111 FXJSE_CLASS m_JsGlobalClass; | |
112 FXJSE_CLASS m_JsNormalClass; | |
113 CFX_MapPtrTemplate<CXFA_Object*, FXJSE_HVALUE> m_mapXFAToHValue; | |
114 FXJSE_CLASS m_JsGlobalVariablesClass; | |
115 CFX_MapPtrTemplate<CXFA_Object*, FXJSE_HCONTEXT> m_mapVariableToHValue; | |
116 CXFA_EventParam m_eventParam; | |
117 CXFA_NodeArray m_upObjectArray; | |
118 CFX_PtrArray m_CacheListArray; | |
119 CXFA_NodeArray* m_pScriptNodeArray; | |
120 CXFA_ResolveProcessor* m_pResolveProcessor; | |
121 XFA_HFM2JSCONTEXT m_hFM2JSContext; | |
122 CXFA_Object* m_pThisObject; | |
123 FX_DWORD m_dwBuiltInInFlags; | |
124 XFA_ATTRIBUTEENUM m_eRunAtType; | |
125 }; | |
126 | |
127 #endif // XFA_SRC_FXFA_PARSER_XFA_SCRIPT_IMP_H_ | |
OLD | NEW |