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 #include "fpdfsdk/javascript/cjs_context.h" | 7 #include "fpdfsdk/javascript/cjs_context.h" |
8 | 8 |
9 #include "fpdfsdk/javascript/JS_EventHandler.h" | 9 #include "fpdfsdk/javascript/JS_EventHandler.h" |
10 #include "fpdfsdk/javascript/cjs_runtime.h" | 10 #include "fpdfsdk/javascript/cjs_runtime.h" |
11 #include "fpdfsdk/javascript/resource.h" | 11 #include "fpdfsdk/javascript/resource.h" |
12 | 12 |
13 CJS_Context::CJS_Context(CJS_Runtime* pRuntime) | 13 CJS_Context::CJS_Context(CJS_Runtime* pRuntime) |
14 : m_pRuntime(pRuntime), | 14 : m_pRuntime(pRuntime), |
15 m_pEventHandler(new CJS_EventHandler(this)), | 15 m_pEventHandler(new CJS_EventHandler(this)), |
16 m_bBusy(FALSE) {} | 16 m_bBusy(FALSE) {} |
17 | 17 |
18 CJS_Context::~CJS_Context() {} | 18 CJS_Context::~CJS_Context() {} |
19 | 19 |
20 CPDFSDK_Document* CJS_Context::GetReaderDocument() { | 20 CPDFSDK_FormFillEnvironment* CJS_Context::GetFormFillEnv() { |
21 return m_pRuntime->GetReaderDocument(); | |
22 } | |
23 | |
24 CPDFSDK_FormFillEnvironment* CJS_Context::GetReaderEnv() { | |
25 return m_pRuntime->GetReaderEnv(); | 21 return m_pRuntime->GetReaderEnv(); |
26 } | 22 } |
27 | 23 |
28 FX_BOOL CJS_Context::RunScript(const CFX_WideString& script, | 24 FX_BOOL CJS_Context::RunScript(const CFX_WideString& script, |
29 CFX_WideString* info) { | 25 CFX_WideString* info) { |
30 v8::Isolate::Scope isolate_scope(m_pRuntime->GetIsolate()); | 26 v8::Isolate::Scope isolate_scope(m_pRuntime->GetIsolate()); |
31 v8::HandleScope handle_scope(m_pRuntime->GetIsolate()); | 27 v8::HandleScope handle_scope(m_pRuntime->GetIsolate()); |
32 v8::Local<v8::Context> context = m_pRuntime->NewLocalContext(); | 28 v8::Local<v8::Context> context = m_pRuntime->NewLocalContext(); |
33 v8::Context::Scope context_scope(context); | 29 v8::Context::Scope context_scope(context); |
34 | 30 |
(...skipping 27 matching lines...) Expand all Loading... |
62 m_pEventHandler->Destroy(); | 58 m_pEventHandler->Destroy(); |
63 m_bBusy = FALSE; | 59 m_bBusy = FALSE; |
64 | 60 |
65 return nRet >= 0; | 61 return nRet >= 0; |
66 } | 62 } |
67 | 63 |
68 void CJS_Context::OnApp_Init() { | 64 void CJS_Context::OnApp_Init() { |
69 m_pEventHandler->OnApp_Init(); | 65 m_pEventHandler->OnApp_Init(); |
70 } | 66 } |
71 | 67 |
72 void CJS_Context::OnDoc_Open(CPDFSDK_Document* pDoc, | 68 void CJS_Context::OnDoc_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv, |
73 const CFX_WideString& strTargetName) { | 69 const CFX_WideString& strTargetName) { |
74 m_pEventHandler->OnDoc_Open(pDoc, strTargetName); | 70 m_pEventHandler->OnDoc_Open(pFormFillEnv, strTargetName); |
75 } | 71 } |
76 | 72 |
77 void CJS_Context::OnDoc_WillPrint(CPDFSDK_Document* pDoc) { | 73 void CJS_Context::OnDoc_WillPrint(CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
78 m_pEventHandler->OnDoc_WillPrint(pDoc); | 74 m_pEventHandler->OnDoc_WillPrint(pFormFillEnv); |
79 } | 75 } |
80 | 76 |
81 void CJS_Context::OnDoc_DidPrint(CPDFSDK_Document* pDoc) { | 77 void CJS_Context::OnDoc_DidPrint(CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
82 m_pEventHandler->OnDoc_DidPrint(pDoc); | 78 m_pEventHandler->OnDoc_DidPrint(pFormFillEnv); |
83 } | 79 } |
84 | 80 |
85 void CJS_Context::OnDoc_WillSave(CPDFSDK_Document* pDoc) { | 81 void CJS_Context::OnDoc_WillSave(CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
86 m_pEventHandler->OnDoc_WillSave(pDoc); | 82 m_pEventHandler->OnDoc_WillSave(pFormFillEnv); |
87 } | 83 } |
88 | 84 |
89 void CJS_Context::OnDoc_DidSave(CPDFSDK_Document* pDoc) { | 85 void CJS_Context::OnDoc_DidSave(CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
90 m_pEventHandler->OnDoc_DidSave(pDoc); | 86 m_pEventHandler->OnDoc_DidSave(pFormFillEnv); |
91 } | 87 } |
92 | 88 |
93 void CJS_Context::OnDoc_WillClose(CPDFSDK_Document* pDoc) { | 89 void CJS_Context::OnDoc_WillClose(CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
94 m_pEventHandler->OnDoc_WillClose(pDoc); | 90 m_pEventHandler->OnDoc_WillClose(pFormFillEnv); |
95 } | 91 } |
96 | 92 |
97 void CJS_Context::OnPage_Open(CPDFSDK_Document* pTarget) { | 93 void CJS_Context::OnPage_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
98 m_pEventHandler->OnPage_Open(pTarget); | 94 m_pEventHandler->OnPage_Open(pFormFillEnv); |
99 } | 95 } |
100 | 96 |
101 void CJS_Context::OnPage_Close(CPDFSDK_Document* pTarget) { | 97 void CJS_Context::OnPage_Close(CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
102 m_pEventHandler->OnPage_Close(pTarget); | 98 m_pEventHandler->OnPage_Close(pFormFillEnv); |
103 } | 99 } |
104 | 100 |
105 void CJS_Context::OnPage_InView(CPDFSDK_Document* pTarget) { | 101 void CJS_Context::OnPage_InView(CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
106 m_pEventHandler->OnPage_InView(pTarget); | 102 m_pEventHandler->OnPage_InView(pFormFillEnv); |
107 } | 103 } |
108 | 104 |
109 void CJS_Context::OnPage_OutView(CPDFSDK_Document* pTarget) { | 105 void CJS_Context::OnPage_OutView(CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
110 m_pEventHandler->OnPage_OutView(pTarget); | 106 m_pEventHandler->OnPage_OutView(pFormFillEnv); |
111 } | 107 } |
112 | 108 |
113 void CJS_Context::OnField_MouseDown(FX_BOOL bModifier, | 109 void CJS_Context::OnField_MouseDown(FX_BOOL bModifier, |
114 FX_BOOL bShift, | 110 FX_BOOL bShift, |
115 CPDF_FormField* pTarget) { | 111 CPDF_FormField* pTarget) { |
116 m_pEventHandler->OnField_MouseDown(bModifier, bShift, pTarget); | 112 m_pEventHandler->OnField_MouseDown(bModifier, bShift, pTarget); |
117 } | 113 } |
118 | 114 |
119 void CJS_Context::OnField_MouseEnter(FX_BOOL bModifier, | 115 void CJS_Context::OnField_MouseEnter(FX_BOOL bModifier, |
120 FX_BOOL bShift, | 116 FX_BOOL bShift, |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 void CJS_Context::OnScreen_OutView(FX_BOOL bModifier, | 243 void CJS_Context::OnScreen_OutView(FX_BOOL bModifier, |
248 FX_BOOL bShift, | 244 FX_BOOL bShift, |
249 CPDFSDK_Annot* pScreen) { | 245 CPDFSDK_Annot* pScreen) { |
250 m_pEventHandler->OnScreen_OutView(bModifier, bShift, pScreen); | 246 m_pEventHandler->OnScreen_OutView(bModifier, bShift, pScreen); |
251 } | 247 } |
252 | 248 |
253 void CJS_Context::OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) { | 249 void CJS_Context::OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) { |
254 m_pEventHandler->OnBookmark_MouseUp(pBookMark); | 250 m_pEventHandler->OnBookmark_MouseUp(pBookMark); |
255 } | 251 } |
256 | 252 |
257 void CJS_Context::OnLink_MouseUp(CPDFSDK_Document* pTarget) { | 253 void CJS_Context::OnLink_MouseUp(CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
258 m_pEventHandler->OnLink_MouseUp(pTarget); | 254 m_pEventHandler->OnLink_MouseUp(pFormFillEnv); |
259 } | 255 } |
260 | 256 |
261 void CJS_Context::OnConsole_Exec() { | 257 void CJS_Context::OnConsole_Exec() { |
262 m_pEventHandler->OnConsole_Exec(); | 258 m_pEventHandler->OnConsole_Exec(); |
263 } | 259 } |
264 | 260 |
265 void CJS_Context::OnExternal_Exec() { | 261 void CJS_Context::OnExternal_Exec() { |
266 m_pEventHandler->OnExternal_Exec(); | 262 m_pEventHandler->OnExternal_Exec(); |
267 } | 263 } |
268 | 264 |
269 void CJS_Context::OnBatchExec(CPDFSDK_Document* pTarget) { | 265 void CJS_Context::OnBatchExec(CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
270 m_pEventHandler->OnBatchExec(pTarget); | 266 m_pEventHandler->OnBatchExec(pFormFillEnv); |
271 } | 267 } |
272 | 268 |
273 void CJS_Context::OnMenu_Exec(CPDFSDK_Document* pTarget, | 269 void CJS_Context::OnMenu_Exec(CPDFSDK_FormFillEnvironment* pFormFillEnv, |
274 const CFX_WideString& strTargetName) { | 270 const CFX_WideString& strTargetName) { |
275 m_pEventHandler->OnMenu_Exec(pTarget, strTargetName); | 271 m_pEventHandler->OnMenu_Exec(pFormFillEnv, strTargetName); |
276 } | 272 } |
OLD | NEW |