Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Side by Side Diff: fpdfsdk/src/javascript/JS_Context.cpp

Issue 1799773002: Move fpdfsdk/src up to fpdfsdk/. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/src/javascript/JS_Context.h ('k') | fpdfsdk/src/javascript/JS_Define.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #include "fpdfsdk/src/javascript/JS_Context.h"
8
9 #include "fpdfsdk/include/javascript/IJavaScript.h"
10 #include "fpdfsdk/src/javascript/JS_EventHandler.h"
11 #include "fpdfsdk/src/javascript/JS_Runtime.h"
12 #include "fpdfsdk/src/javascript/resource.h"
13
14 /* -------------------------- CJS_Context -------------------------- */
15
16 CJS_Context::CJS_Context(CJS_Runtime* pRuntime)
17 : m_pRuntime(pRuntime), m_bBusy(FALSE), m_bMsgBoxEnable(TRUE) {
18 m_pEventHandler = new CJS_EventHandler(this);
19 }
20
21 CJS_Context::~CJS_Context() {
22 delete m_pEventHandler;
23 }
24
25 CPDFSDK_Document* CJS_Context::GetReaderDocument() {
26 return m_pRuntime->GetReaderDocument();
27 }
28
29 CPDFDoc_Environment* CJS_Context::GetReaderApp() {
30 return m_pRuntime->GetReaderApp();
31 }
32
33 FX_BOOL CJS_Context::RunScript(const CFX_WideString& script,
34 CFX_WideString* info) {
35 v8::Isolate::Scope isolate_scope(m_pRuntime->GetIsolate());
36 #ifdef PDF_ENABLE_XFA
37 v8::Locker locker(m_pRuntime->GetIsolate());
38 #endif // PDF_ENABLE_XFA
39 v8::HandleScope handle_scope(m_pRuntime->GetIsolate());
40 v8::Local<v8::Context> context = m_pRuntime->NewJSContext();
41 v8::Context::Scope context_scope(context);
42
43 if (m_bBusy) {
44 *info = JSGetStringFromID(this, IDS_STRING_JSBUSY);
45 return FALSE;
46 }
47 m_bBusy = TRUE;
48
49 ASSERT(m_pEventHandler->IsValid());
50 CJS_Runtime::FieldEvent event(m_pEventHandler->TargetName(),
51 m_pEventHandler->EventType());
52 if (!m_pRuntime->AddEventToSet(event)) {
53 *info = JSGetStringFromID(this, IDS_STRING_JSEVENT);
54 return FALSE;
55 }
56
57 CFX_WideString sErrorMessage;
58 int nRet = 0;
59 if (script.GetLength() > 0) {
60 nRet = m_pRuntime->Execute(this, script.c_str(), &sErrorMessage);
61 }
62
63 if (nRet < 0) {
64 *info += sErrorMessage;
65 } else {
66 *info = JSGetStringFromID(this, IDS_STRING_RUN);
67 }
68
69 m_pRuntime->RemoveEventFromSet(event);
70 m_pEventHandler->Destroy();
71 m_bBusy = FALSE;
72
73 return nRet >= 0;
74 }
75
76 void CJS_Context::OnApp_Init() {
77 m_pEventHandler->OnApp_Init();
78 }
79
80 void CJS_Context::OnDoc_Open(CPDFSDK_Document* pDoc,
81 const CFX_WideString& strTargetName) {
82 m_pEventHandler->OnDoc_Open(pDoc, strTargetName);
83 }
84
85 void CJS_Context::OnDoc_WillPrint(CPDFSDK_Document* pDoc) {
86 m_pEventHandler->OnDoc_WillPrint(pDoc);
87 }
88
89 void CJS_Context::OnDoc_DidPrint(CPDFSDK_Document* pDoc) {
90 m_pEventHandler->OnDoc_DidPrint(pDoc);
91 }
92
93 void CJS_Context::OnDoc_WillSave(CPDFSDK_Document* pDoc) {
94 m_pEventHandler->OnDoc_WillSave(pDoc);
95 }
96
97 void CJS_Context::OnDoc_DidSave(CPDFSDK_Document* pDoc) {
98 m_pEventHandler->OnDoc_DidSave(pDoc);
99 }
100
101 void CJS_Context::OnDoc_WillClose(CPDFSDK_Document* pDoc) {
102 m_pEventHandler->OnDoc_WillClose(pDoc);
103 }
104
105 void CJS_Context::OnPage_Open(CPDFSDK_Document* pTarget) {
106 m_pEventHandler->OnPage_Open(pTarget);
107 }
108
109 void CJS_Context::OnPage_Close(CPDFSDK_Document* pTarget) {
110 m_pEventHandler->OnPage_Close(pTarget);
111 }
112
113 void CJS_Context::OnPage_InView(CPDFSDK_Document* pTarget) {
114 m_pEventHandler->OnPage_InView(pTarget);
115 }
116
117 void CJS_Context::OnPage_OutView(CPDFSDK_Document* pTarget) {
118 m_pEventHandler->OnPage_OutView(pTarget);
119 }
120
121 void CJS_Context::OnField_MouseDown(FX_BOOL bModifier,
122 FX_BOOL bShift,
123 CPDF_FormField* pTarget) {
124 m_pEventHandler->OnField_MouseDown(bModifier, bShift, pTarget);
125 }
126
127 void CJS_Context::OnField_MouseEnter(FX_BOOL bModifier,
128 FX_BOOL bShift,
129 CPDF_FormField* pTarget) {
130 m_pEventHandler->OnField_MouseEnter(bModifier, bShift, pTarget);
131 }
132
133 void CJS_Context::OnField_MouseExit(FX_BOOL bModifier,
134 FX_BOOL bShift,
135 CPDF_FormField* pTarget) {
136 m_pEventHandler->OnField_MouseExit(bModifier, bShift, pTarget);
137 }
138
139 void CJS_Context::OnField_MouseUp(FX_BOOL bModifier,
140 FX_BOOL bShift,
141 CPDF_FormField* pTarget) {
142 m_pEventHandler->OnField_MouseUp(bModifier, bShift, pTarget);
143 }
144
145 void CJS_Context::OnField_Focus(FX_BOOL bModifier,
146 FX_BOOL bShift,
147 CPDF_FormField* pTarget,
148 const CFX_WideString& Value) {
149 m_pEventHandler->OnField_Focus(bModifier, bShift, pTarget, Value);
150 }
151
152 void CJS_Context::OnField_Blur(FX_BOOL bModifier,
153 FX_BOOL bShift,
154 CPDF_FormField* pTarget,
155 const CFX_WideString& Value) {
156 m_pEventHandler->OnField_Blur(bModifier, bShift, pTarget, Value);
157 }
158
159 void CJS_Context::OnField_Calculate(CPDF_FormField* pSource,
160 CPDF_FormField* pTarget,
161 CFX_WideString& Value,
162 FX_BOOL& bRc) {
163 m_pEventHandler->OnField_Calculate(pSource, pTarget, Value, bRc);
164 }
165
166 void CJS_Context::OnField_Format(CPDF_FormField* pTarget,
167 CFX_WideString& Value,
168 FX_BOOL bWillCommit) {
169 m_pEventHandler->OnField_Format(pTarget, Value, bWillCommit);
170 }
171
172 void CJS_Context::OnField_Keystroke(CFX_WideString& strChange,
173 const CFX_WideString& strChangeEx,
174 FX_BOOL bKeyDown,
175 FX_BOOL bModifier,
176 int& nSelEnd,
177 int& nSelStart,
178 FX_BOOL bShift,
179 CPDF_FormField* pTarget,
180 CFX_WideString& Value,
181 FX_BOOL bWillCommit,
182 FX_BOOL bFieldFull,
183 FX_BOOL& bRc) {
184 m_pEventHandler->OnField_Keystroke(
185 strChange, strChangeEx, bKeyDown, bModifier, nSelEnd, nSelStart, bShift,
186 pTarget, Value, bWillCommit, bFieldFull, bRc);
187 }
188
189 void CJS_Context::OnField_Validate(CFX_WideString& strChange,
190 const CFX_WideString& strChangeEx,
191 FX_BOOL bKeyDown,
192 FX_BOOL bModifier,
193 FX_BOOL bShift,
194 CPDF_FormField* pTarget,
195 CFX_WideString& Value,
196 FX_BOOL& bRc) {
197 m_pEventHandler->OnField_Validate(strChange, strChangeEx, bKeyDown, bModifier,
198 bShift, pTarget, Value, bRc);
199 }
200
201 void CJS_Context::OnScreen_Focus(FX_BOOL bModifier,
202 FX_BOOL bShift,
203 CPDFSDK_Annot* pScreen) {
204 m_pEventHandler->OnScreen_Focus(bModifier, bShift, pScreen);
205 }
206
207 void CJS_Context::OnScreen_Blur(FX_BOOL bModifier,
208 FX_BOOL bShift,
209 CPDFSDK_Annot* pScreen) {
210 m_pEventHandler->OnScreen_Blur(bModifier, bShift, pScreen);
211 }
212
213 void CJS_Context::OnScreen_Open(FX_BOOL bModifier,
214 FX_BOOL bShift,
215 CPDFSDK_Annot* pScreen) {
216 m_pEventHandler->OnScreen_Open(bModifier, bShift, pScreen);
217 }
218
219 void CJS_Context::OnScreen_Close(FX_BOOL bModifier,
220 FX_BOOL bShift,
221 CPDFSDK_Annot* pScreen) {
222 m_pEventHandler->OnScreen_Close(bModifier, bShift, pScreen);
223 }
224
225 void CJS_Context::OnScreen_MouseDown(FX_BOOL bModifier,
226 FX_BOOL bShift,
227 CPDFSDK_Annot* pScreen) {
228 m_pEventHandler->OnScreen_MouseDown(bModifier, bShift, pScreen);
229 }
230
231 void CJS_Context::OnScreen_MouseUp(FX_BOOL bModifier,
232 FX_BOOL bShift,
233 CPDFSDK_Annot* pScreen) {
234 m_pEventHandler->OnScreen_MouseUp(bModifier, bShift, pScreen);
235 }
236
237 void CJS_Context::OnScreen_MouseEnter(FX_BOOL bModifier,
238 FX_BOOL bShift,
239 CPDFSDK_Annot* pScreen) {
240 m_pEventHandler->OnScreen_MouseEnter(bModifier, bShift, pScreen);
241 }
242
243 void CJS_Context::OnScreen_MouseExit(FX_BOOL bModifier,
244 FX_BOOL bShift,
245 CPDFSDK_Annot* pScreen) {
246 m_pEventHandler->OnScreen_MouseExit(bModifier, bShift, pScreen);
247 }
248
249 void CJS_Context::OnScreen_InView(FX_BOOL bModifier,
250 FX_BOOL bShift,
251 CPDFSDK_Annot* pScreen) {
252 m_pEventHandler->OnScreen_InView(bModifier, bShift, pScreen);
253 }
254
255 void CJS_Context::OnScreen_OutView(FX_BOOL bModifier,
256 FX_BOOL bShift,
257 CPDFSDK_Annot* pScreen) {
258 m_pEventHandler->OnScreen_OutView(bModifier, bShift, pScreen);
259 }
260
261 void CJS_Context::OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) {
262 m_pEventHandler->OnBookmark_MouseUp(pBookMark);
263 }
264
265 void CJS_Context::OnLink_MouseUp(CPDFSDK_Document* pTarget) {
266 m_pEventHandler->OnLink_MouseUp(pTarget);
267 }
268
269 void CJS_Context::OnConsole_Exec() {
270 m_pEventHandler->OnConsole_Exec();
271 }
272
273 void CJS_Context::OnExternal_Exec() {
274 m_pEventHandler->OnExternal_Exec();
275 }
276
277 void CJS_Context::OnBatchExec(CPDFSDK_Document* pTarget) {
278 m_pEventHandler->OnBatchExec(pTarget);
279 }
280
281 void CJS_Context::OnMenu_Exec(CPDFSDK_Document* pTarget,
282 const CFX_WideString& strTargetName) {
283 m_pEventHandler->OnMenu_Exec(pTarget, strTargetName);
284 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/javascript/JS_Context.h ('k') | fpdfsdk/src/javascript/JS_Define.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698