• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/javascript/JS_EventHandler.h"
8 
9 #include "fpdfsdk/javascript/Document.h"
10 #include "fpdfsdk/javascript/Field.h"
11 #include "fpdfsdk/javascript/JS_Define.h"
12 #include "fpdfsdk/javascript/JS_Object.h"
13 #include "fpdfsdk/javascript/JS_Value.h"
14 #include "fpdfsdk/javascript/cjs_event_context.h"
15 #include "fpdfsdk/javascript/cjs_runtime.h"
16 
CJS_EventHandler(CJS_EventContext * pContext)17 CJS_EventHandler::CJS_EventHandler(CJS_EventContext* pContext)
18     : m_pJSEventContext(pContext),
19       m_eEventType(JET_UNKNOWN),
20       m_bValid(false),
21       m_pWideStrChange(nullptr),
22       m_nCommitKey(-1),
23       m_bKeyDown(false),
24       m_bModifier(false),
25       m_bShift(false),
26       m_pISelEnd(nullptr),
27       m_nSelEndDu(0),
28       m_pISelStart(nullptr),
29       m_nSelStartDu(0),
30       m_bWillCommit(false),
31       m_pValue(nullptr),
32       m_bFieldFull(false),
33       m_pbRc(nullptr),
34       m_bRcDu(false),
35       m_pTargetBookMark(nullptr),
36       m_pTargetFormFillEnv(nullptr),
37       m_pTargetAnnot(nullptr) {}
38 
~CJS_EventHandler()39 CJS_EventHandler::~CJS_EventHandler() {}
40 
OnApp_Init()41 void CJS_EventHandler::OnApp_Init() {
42   Initial(JET_APP_INIT);
43 }
44 
OnDoc_Open(CPDFSDK_FormFillEnvironment * pFormFillEnv,const CFX_WideString & strTargetName)45 void CJS_EventHandler::OnDoc_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv,
46                                   const CFX_WideString& strTargetName) {
47   Initial(JET_DOC_OPEN);
48   m_pTargetFormFillEnv.Reset(pFormFillEnv);
49   m_strTargetName = strTargetName;
50 }
51 
OnDoc_WillPrint(CPDFSDK_FormFillEnvironment * pFormFillEnv)52 void CJS_EventHandler::OnDoc_WillPrint(
53     CPDFSDK_FormFillEnvironment* pFormFillEnv) {
54   Initial(JET_DOC_WILLPRINT);
55   m_pTargetFormFillEnv.Reset(pFormFillEnv);
56 }
57 
OnDoc_DidPrint(CPDFSDK_FormFillEnvironment * pFormFillEnv)58 void CJS_EventHandler::OnDoc_DidPrint(
59     CPDFSDK_FormFillEnvironment* pFormFillEnv) {
60   Initial(JET_DOC_DIDPRINT);
61   m_pTargetFormFillEnv.Reset(pFormFillEnv);
62 }
63 
OnDoc_WillSave(CPDFSDK_FormFillEnvironment * pFormFillEnv)64 void CJS_EventHandler::OnDoc_WillSave(
65     CPDFSDK_FormFillEnvironment* pFormFillEnv) {
66   Initial(JET_DOC_WILLSAVE);
67   m_pTargetFormFillEnv.Reset(pFormFillEnv);
68 }
69 
OnDoc_DidSave(CPDFSDK_FormFillEnvironment * pFormFillEnv)70 void CJS_EventHandler::OnDoc_DidSave(
71     CPDFSDK_FormFillEnvironment* pFormFillEnv) {
72   Initial(JET_DOC_DIDSAVE);
73   m_pTargetFormFillEnv.Reset(pFormFillEnv);
74 }
75 
OnDoc_WillClose(CPDFSDK_FormFillEnvironment * pFormFillEnv)76 void CJS_EventHandler::OnDoc_WillClose(
77     CPDFSDK_FormFillEnvironment* pFormFillEnv) {
78   Initial(JET_DOC_WILLCLOSE);
79   m_pTargetFormFillEnv.Reset(pFormFillEnv);
80 }
81 
OnPage_Open(CPDFSDK_FormFillEnvironment * pFormFillEnv)82 void CJS_EventHandler::OnPage_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
83   Initial(JET_PAGE_OPEN);
84   m_pTargetFormFillEnv.Reset(pFormFillEnv);
85 }
86 
OnPage_Close(CPDFSDK_FormFillEnvironment * pFormFillEnv)87 void CJS_EventHandler::OnPage_Close(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
88   Initial(JET_PAGE_CLOSE);
89   m_pTargetFormFillEnv.Reset(pFormFillEnv);
90 }
91 
OnPage_InView(CPDFSDK_FormFillEnvironment * pFormFillEnv)92 void CJS_EventHandler::OnPage_InView(
93     CPDFSDK_FormFillEnvironment* pFormFillEnv) {
94   Initial(JET_PAGE_INVIEW);
95   m_pTargetFormFillEnv.Reset(pFormFillEnv);
96 }
97 
OnPage_OutView(CPDFSDK_FormFillEnvironment * pFormFillEnv)98 void CJS_EventHandler::OnPage_OutView(
99     CPDFSDK_FormFillEnvironment* pFormFillEnv) {
100   Initial(JET_PAGE_OUTVIEW);
101   m_pTargetFormFillEnv.Reset(pFormFillEnv);
102 }
103 
OnField_MouseEnter(bool bModifier,bool bShift,CPDF_FormField * pTarget)104 void CJS_EventHandler::OnField_MouseEnter(bool bModifier,
105                                           bool bShift,
106                                           CPDF_FormField* pTarget) {
107   Initial(JET_FIELD_MOUSEENTER);
108 
109   m_bModifier = bModifier;
110   m_bShift = bShift;
111 
112   m_strTargetName = pTarget->GetFullName();
113 }
114 
OnField_MouseExit(bool bModifier,bool bShift,CPDF_FormField * pTarget)115 void CJS_EventHandler::OnField_MouseExit(bool bModifier,
116                                          bool bShift,
117                                          CPDF_FormField* pTarget) {
118   Initial(JET_FIELD_MOUSEEXIT);
119 
120   m_bModifier = bModifier;
121   m_bShift = bShift;
122   m_strTargetName = pTarget->GetFullName();
123 }
124 
OnField_MouseDown(bool bModifier,bool bShift,CPDF_FormField * pTarget)125 void CJS_EventHandler::OnField_MouseDown(bool bModifier,
126                                          bool bShift,
127                                          CPDF_FormField* pTarget) {
128   Initial(JET_FIELD_MOUSEDOWN);
129   m_eEventType = JET_FIELD_MOUSEDOWN;
130 
131   m_bModifier = bModifier;
132   m_bShift = bShift;
133   m_strTargetName = pTarget->GetFullName();
134 }
135 
OnField_MouseUp(bool bModifier,bool bShift,CPDF_FormField * pTarget)136 void CJS_EventHandler::OnField_MouseUp(bool bModifier,
137                                        bool bShift,
138                                        CPDF_FormField* pTarget) {
139   Initial(JET_FIELD_MOUSEUP);
140 
141   m_bModifier = bModifier;
142   m_bShift = bShift;
143   m_strTargetName = pTarget->GetFullName();
144 }
145 
OnField_Focus(bool bModifier,bool bShift,CPDF_FormField * pTarget,const CFX_WideString & Value)146 void CJS_EventHandler::OnField_Focus(bool bModifier,
147                                      bool bShift,
148                                      CPDF_FormField* pTarget,
149                                      const CFX_WideString& Value) {
150   Initial(JET_FIELD_FOCUS);
151 
152   m_bModifier = bModifier;
153   m_bShift = bShift;
154   m_strTargetName = pTarget->GetFullName();
155   m_pValue = (CFX_WideString*)&Value;
156 }
157 
OnField_Blur(bool bModifier,bool bShift,CPDF_FormField * pTarget,const CFX_WideString & Value)158 void CJS_EventHandler::OnField_Blur(bool bModifier,
159                                     bool bShift,
160                                     CPDF_FormField* pTarget,
161                                     const CFX_WideString& Value) {
162   Initial(JET_FIELD_BLUR);
163 
164   m_bModifier = bModifier;
165   m_bShift = bShift;
166   m_strTargetName = pTarget->GetFullName();
167   m_pValue = (CFX_WideString*)&Value;
168 }
169 
OnField_Keystroke(CFX_WideString & strChange,const CFX_WideString & strChangeEx,bool KeyDown,bool bModifier,int & nSelEnd,int & nSelStart,bool bShift,CPDF_FormField * pTarget,CFX_WideString & Value,bool bWillCommit,bool bFieldFull,bool & bRc)170 void CJS_EventHandler::OnField_Keystroke(CFX_WideString& strChange,
171                                          const CFX_WideString& strChangeEx,
172                                          bool KeyDown,
173                                          bool bModifier,
174                                          int& nSelEnd,
175                                          int& nSelStart,
176                                          bool bShift,
177                                          CPDF_FormField* pTarget,
178                                          CFX_WideString& Value,
179                                          bool bWillCommit,
180                                          bool bFieldFull,
181                                          bool& bRc) {
182   Initial(JET_FIELD_KEYSTROKE);
183 
184   m_nCommitKey = 0;
185   m_pWideStrChange = &strChange;
186   m_WideStrChangeEx = strChangeEx;
187   m_bKeyDown = KeyDown;
188   m_bModifier = bModifier;
189   m_pISelEnd = &nSelEnd;
190   m_pISelStart = &nSelStart;
191   m_bShift = bShift;
192   m_strTargetName = pTarget->GetFullName();
193   m_pValue = &Value;
194   m_bWillCommit = bWillCommit;
195   m_pbRc = &bRc;
196   m_bFieldFull = bFieldFull;
197 }
198 
OnField_Validate(CFX_WideString & strChange,const CFX_WideString & strChangeEx,bool bKeyDown,bool bModifier,bool bShift,CPDF_FormField * pTarget,CFX_WideString & Value,bool & bRc)199 void CJS_EventHandler::OnField_Validate(CFX_WideString& strChange,
200                                         const CFX_WideString& strChangeEx,
201                                         bool bKeyDown,
202                                         bool bModifier,
203                                         bool bShift,
204                                         CPDF_FormField* pTarget,
205                                         CFX_WideString& Value,
206                                         bool& bRc) {
207   Initial(JET_FIELD_VALIDATE);
208 
209   m_pWideStrChange = &strChange;
210   m_WideStrChangeEx = strChangeEx;
211   m_bKeyDown = bKeyDown;
212   m_bModifier = bModifier;
213   m_bShift = bShift;
214   m_strTargetName = pTarget->GetFullName();
215   m_pValue = &Value;
216   m_pbRc = &bRc;
217 }
218 
OnField_Calculate(CPDF_FormField * pSource,CPDF_FormField * pTarget,CFX_WideString & Value,bool & bRc)219 void CJS_EventHandler::OnField_Calculate(CPDF_FormField* pSource,
220                                          CPDF_FormField* pTarget,
221                                          CFX_WideString& Value,
222                                          bool& bRc) {
223   Initial(JET_FIELD_CALCULATE);
224 
225   if (pSource)
226     m_strSourceName = pSource->GetFullName();
227   m_strTargetName = pTarget->GetFullName();
228   m_pValue = &Value;
229   m_pbRc = &bRc;
230 }
231 
OnField_Format(CPDF_FormField * pTarget,CFX_WideString & Value,bool bWillCommit)232 void CJS_EventHandler::OnField_Format(CPDF_FormField* pTarget,
233                                       CFX_WideString& Value,
234                                       bool bWillCommit) {
235   Initial(JET_FIELD_FORMAT);
236 
237   m_nCommitKey = 0;
238   m_strTargetName = pTarget->GetFullName();
239   m_pValue = &Value;
240   m_bWillCommit = bWillCommit;
241 }
242 
OnScreen_Focus(bool bModifier,bool bShift,CPDFSDK_Annot * pScreen)243 void CJS_EventHandler::OnScreen_Focus(bool bModifier,
244                                       bool bShift,
245                                       CPDFSDK_Annot* pScreen) {
246   Initial(JET_SCREEN_FOCUS);
247 
248   m_bModifier = bModifier;
249   m_bShift = bShift;
250   m_pTargetAnnot.Reset(pScreen);
251 }
252 
OnScreen_Blur(bool bModifier,bool bShift,CPDFSDK_Annot * pScreen)253 void CJS_EventHandler::OnScreen_Blur(bool bModifier,
254                                      bool bShift,
255                                      CPDFSDK_Annot* pScreen) {
256   Initial(JET_SCREEN_BLUR);
257 
258   m_bModifier = bModifier;
259   m_bShift = bShift;
260   m_pTargetAnnot.Reset(pScreen);
261 }
262 
OnScreen_Open(bool bModifier,bool bShift,CPDFSDK_Annot * pScreen)263 void CJS_EventHandler::OnScreen_Open(bool bModifier,
264                                      bool bShift,
265                                      CPDFSDK_Annot* pScreen) {
266   Initial(JET_SCREEN_OPEN);
267 
268   m_bModifier = bModifier;
269   m_bShift = bShift;
270   m_pTargetAnnot.Reset(pScreen);
271 }
272 
OnScreen_Close(bool bModifier,bool bShift,CPDFSDK_Annot * pScreen)273 void CJS_EventHandler::OnScreen_Close(bool bModifier,
274                                       bool bShift,
275                                       CPDFSDK_Annot* pScreen) {
276   Initial(JET_SCREEN_CLOSE);
277 
278   m_bModifier = bModifier;
279   m_bShift = bShift;
280   m_pTargetAnnot.Reset(pScreen);
281 }
282 
OnScreen_MouseDown(bool bModifier,bool bShift,CPDFSDK_Annot * pScreen)283 void CJS_EventHandler::OnScreen_MouseDown(bool bModifier,
284                                           bool bShift,
285                                           CPDFSDK_Annot* pScreen) {
286   Initial(JET_SCREEN_MOUSEDOWN);
287 
288   m_bModifier = bModifier;
289   m_bShift = bShift;
290   m_pTargetAnnot.Reset(pScreen);
291 }
292 
OnScreen_MouseUp(bool bModifier,bool bShift,CPDFSDK_Annot * pScreen)293 void CJS_EventHandler::OnScreen_MouseUp(bool bModifier,
294                                         bool bShift,
295                                         CPDFSDK_Annot* pScreen) {
296   Initial(JET_SCREEN_MOUSEUP);
297 
298   m_bModifier = bModifier;
299   m_bShift = bShift;
300   m_pTargetAnnot.Reset(pScreen);
301 }
302 
OnScreen_MouseEnter(bool bModifier,bool bShift,CPDFSDK_Annot * pScreen)303 void CJS_EventHandler::OnScreen_MouseEnter(bool bModifier,
304                                            bool bShift,
305                                            CPDFSDK_Annot* pScreen) {
306   Initial(JET_SCREEN_MOUSEENTER);
307 
308   m_bModifier = bModifier;
309   m_bShift = bShift;
310   m_pTargetAnnot.Reset(pScreen);
311 }
312 
OnScreen_MouseExit(bool bModifier,bool bShift,CPDFSDK_Annot * pScreen)313 void CJS_EventHandler::OnScreen_MouseExit(bool bModifier,
314                                           bool bShift,
315                                           CPDFSDK_Annot* pScreen) {
316   Initial(JET_SCREEN_MOUSEEXIT);
317 
318   m_bModifier = bModifier;
319   m_bShift = bShift;
320   m_pTargetAnnot.Reset(pScreen);
321 }
322 
OnScreen_InView(bool bModifier,bool bShift,CPDFSDK_Annot * pScreen)323 void CJS_EventHandler::OnScreen_InView(bool bModifier,
324                                        bool bShift,
325                                        CPDFSDK_Annot* pScreen) {
326   Initial(JET_SCREEN_INVIEW);
327   m_bModifier = bModifier;
328   m_bShift = bShift;
329   m_pTargetAnnot.Reset(pScreen);
330 }
331 
OnScreen_OutView(bool bModifier,bool bShift,CPDFSDK_Annot * pScreen)332 void CJS_EventHandler::OnScreen_OutView(bool bModifier,
333                                         bool bShift,
334                                         CPDFSDK_Annot* pScreen) {
335   Initial(JET_SCREEN_OUTVIEW);
336   m_bModifier = bModifier;
337   m_bShift = bShift;
338   m_pTargetAnnot.Reset(pScreen);
339 }
340 
OnLink_MouseUp(CPDFSDK_FormFillEnvironment * pTargetFormFillEnv)341 void CJS_EventHandler::OnLink_MouseUp(
342     CPDFSDK_FormFillEnvironment* pTargetFormFillEnv) {
343   Initial(JET_LINK_MOUSEUP);
344   m_pTargetFormFillEnv.Reset(pTargetFormFillEnv);
345 }
346 
OnBookmark_MouseUp(CPDF_Bookmark * pBookMark)347 void CJS_EventHandler::OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) {
348   Initial(JET_BOOKMARK_MOUSEUP);
349   m_pTargetBookMark = pBookMark;
350 }
351 
OnMenu_Exec(CPDFSDK_FormFillEnvironment * pTargetFormFillEnv,const CFX_WideString & strTargetName)352 void CJS_EventHandler::OnMenu_Exec(
353     CPDFSDK_FormFillEnvironment* pTargetFormFillEnv,
354     const CFX_WideString& strTargetName) {
355   Initial(JET_MENU_EXEC);
356   m_pTargetFormFillEnv.Reset(pTargetFormFillEnv);
357   m_strTargetName = strTargetName;
358 }
359 
OnExternal_Exec()360 void CJS_EventHandler::OnExternal_Exec() {
361   Initial(JET_EXTERNAL_EXEC);
362 }
363 
OnBatchExec(CPDFSDK_FormFillEnvironment * pTargetFormFillEnv)364 void CJS_EventHandler::OnBatchExec(
365     CPDFSDK_FormFillEnvironment* pTargetFormFillEnv) {
366   Initial(JET_BATCH_EXEC);
367   m_pTargetFormFillEnv.Reset(pTargetFormFillEnv);
368 }
369 
OnConsole_Exec()370 void CJS_EventHandler::OnConsole_Exec() {
371   Initial(JET_CONSOLE_EXEC);
372 }
373 
Initial(JS_EVENT_T type)374 void CJS_EventHandler::Initial(JS_EVENT_T type) {
375   m_eEventType = type;
376 
377   m_strTargetName = L"";
378   m_strSourceName = L"";
379   m_pWideStrChange = nullptr;
380   m_WideStrChangeDu = L"";
381   m_WideStrChangeEx = L"";
382   m_nCommitKey = -1;
383   m_bKeyDown = false;
384   m_bModifier = false;
385   m_bShift = false;
386   m_pISelEnd = nullptr;
387   m_nSelEndDu = 0;
388   m_pISelStart = nullptr;
389   m_nSelStartDu = 0;
390   m_bWillCommit = false;
391   m_pValue = nullptr;
392   m_bFieldFull = false;
393   m_pbRc = nullptr;
394   m_bRcDu = false;
395 
396   m_pTargetBookMark = nullptr;
397   m_pTargetFormFillEnv.Reset();
398   m_pTargetAnnot.Reset();
399 
400   m_bValid = true;
401 }
402 
Destroy()403 void CJS_EventHandler::Destroy() {
404   m_bValid = false;
405 }
406 
IsValid()407 bool CJS_EventHandler::IsValid() {
408   return m_bValid;
409 }
410 
Change()411 CFX_WideString& CJS_EventHandler::Change() {
412   if (m_pWideStrChange) {
413     return *m_pWideStrChange;
414   }
415   return m_WideStrChangeDu;
416 }
417 
ChangeEx()418 CFX_WideString CJS_EventHandler::ChangeEx() {
419   return m_WideStrChangeEx;
420 }
421 
CommitKey()422 int CJS_EventHandler::CommitKey() {
423   return m_nCommitKey;
424 }
425 
FieldFull()426 bool CJS_EventHandler::FieldFull() {
427   return m_bFieldFull;
428 }
429 
KeyDown()430 bool CJS_EventHandler::KeyDown() {
431   return m_bKeyDown;
432 }
433 
Modifier()434 bool CJS_EventHandler::Modifier() {
435   return m_bModifier;
436 }
437 
Name()438 const FX_WCHAR* CJS_EventHandler::Name() {
439   switch (m_eEventType) {
440     case JET_APP_INIT:
441       return L"Init";
442     case JET_BATCH_EXEC:
443       return L"Exec";
444     case JET_BOOKMARK_MOUSEUP:
445       return L"Mouse Up";
446     case JET_CONSOLE_EXEC:
447       return L"Exec";
448     case JET_DOC_DIDPRINT:
449       return L"DidPrint";
450     case JET_DOC_DIDSAVE:
451       return L"DidSave";
452     case JET_DOC_OPEN:
453       return L"Open";
454     case JET_DOC_WILLCLOSE:
455       return L"WillClose";
456     case JET_DOC_WILLPRINT:
457       return L"WillPrint";
458     case JET_DOC_WILLSAVE:
459       return L"WillSave";
460     case JET_EXTERNAL_EXEC:
461       return L"Exec";
462     case JET_FIELD_FOCUS:
463     case JET_SCREEN_FOCUS:
464       return L"Focus";
465     case JET_FIELD_BLUR:
466     case JET_SCREEN_BLUR:
467       return L"Blur";
468     case JET_FIELD_MOUSEDOWN:
469     case JET_SCREEN_MOUSEDOWN:
470       return L"Mouse Down";
471     case JET_FIELD_MOUSEUP:
472     case JET_SCREEN_MOUSEUP:
473       return L"Mouse Up";
474     case JET_FIELD_MOUSEENTER:
475     case JET_SCREEN_MOUSEENTER:
476       return L"Mouse Enter";
477     case JET_FIELD_MOUSEEXIT:
478     case JET_SCREEN_MOUSEEXIT:
479       return L"Mouse Exit";
480     case JET_FIELD_CALCULATE:
481       return L"Calculate";
482     case JET_FIELD_FORMAT:
483       return L"Format";
484     case JET_FIELD_KEYSTROKE:
485       return L"Keystroke";
486     case JET_FIELD_VALIDATE:
487       return L"Validate";
488     case JET_LINK_MOUSEUP:
489       return L"Mouse Up";
490     case JET_MENU_EXEC:
491       return L"Exec";
492     case JET_PAGE_OPEN:
493     case JET_SCREEN_OPEN:
494       return L"Open";
495     case JET_PAGE_CLOSE:
496     case JET_SCREEN_CLOSE:
497       return L"Close";
498     case JET_SCREEN_INVIEW:
499     case JET_PAGE_INVIEW:
500       return L"InView";
501     case JET_PAGE_OUTVIEW:
502     case JET_SCREEN_OUTVIEW:
503       return L"OutView";
504     default:
505       return L"";
506   }
507 }
508 
Type()509 const FX_WCHAR* CJS_EventHandler::Type() {
510   switch (m_eEventType) {
511     case JET_APP_INIT:
512       return L"App";
513     case JET_BATCH_EXEC:
514       return L"Batch";
515     case JET_BOOKMARK_MOUSEUP:
516       return L"BookMark";
517     case JET_CONSOLE_EXEC:
518       return L"Console";
519     case JET_DOC_DIDPRINT:
520     case JET_DOC_DIDSAVE:
521     case JET_DOC_OPEN:
522     case JET_DOC_WILLCLOSE:
523     case JET_DOC_WILLPRINT:
524     case JET_DOC_WILLSAVE:
525       return L"Doc";
526     case JET_EXTERNAL_EXEC:
527       return L"External";
528     case JET_FIELD_BLUR:
529     case JET_FIELD_FOCUS:
530     case JET_FIELD_MOUSEDOWN:
531     case JET_FIELD_MOUSEENTER:
532     case JET_FIELD_MOUSEEXIT:
533     case JET_FIELD_MOUSEUP:
534     case JET_FIELD_CALCULATE:
535     case JET_FIELD_FORMAT:
536     case JET_FIELD_KEYSTROKE:
537     case JET_FIELD_VALIDATE:
538       return L"Field";
539     case JET_SCREEN_FOCUS:
540     case JET_SCREEN_BLUR:
541     case JET_SCREEN_OPEN:
542     case JET_SCREEN_CLOSE:
543     case JET_SCREEN_MOUSEDOWN:
544     case JET_SCREEN_MOUSEUP:
545     case JET_SCREEN_MOUSEENTER:
546     case JET_SCREEN_MOUSEEXIT:
547     case JET_SCREEN_INVIEW:
548     case JET_SCREEN_OUTVIEW:
549       return L"Screen";
550     case JET_LINK_MOUSEUP:
551       return L"Link";
552     case JET_MENU_EXEC:
553       return L"Menu";
554     case JET_PAGE_OPEN:
555     case JET_PAGE_CLOSE:
556     case JET_PAGE_INVIEW:
557     case JET_PAGE_OUTVIEW:
558       return L"Page";
559     default:
560       return L"";
561   }
562 }
563 
Rc()564 bool& CJS_EventHandler::Rc() {
565   if (m_pbRc) {
566     return *m_pbRc;
567   }
568   return m_bRcDu;
569 }
570 
SelEnd()571 int& CJS_EventHandler::SelEnd() {
572   if (m_pISelEnd) {
573     return *m_pISelEnd;
574   }
575   return m_nSelEndDu;
576 }
577 
SelStart()578 int& CJS_EventHandler::SelStart() {
579   if (m_pISelStart) {
580     return *m_pISelStart;
581   }
582   return m_nSelStartDu;
583 }
584 
Shift()585 bool CJS_EventHandler::Shift() {
586   return m_bShift;
587 }
588 
Source()589 Field* CJS_EventHandler::Source() {
590   CJS_Runtime* pRuntime = m_pJSEventContext->GetJSRuntime();
591   v8::Local<v8::Object> pDocObj =
592       pRuntime->NewFxDynamicObj(CJS_Document::g_nObjDefnID);
593   if (pDocObj.IsEmpty())
594     return nullptr;
595 
596   v8::Local<v8::Object> pFieldObj =
597       pRuntime->NewFxDynamicObj(CJS_Field::g_nObjDefnID);
598   if (pFieldObj.IsEmpty())
599     return nullptr;
600 
601   CJS_Document* pJSDocument =
602       static_cast<CJS_Document*>(pRuntime->GetObjectPrivate(pDocObj));
603   CJS_Field* pJSField =
604       static_cast<CJS_Field*>(pRuntime->GetObjectPrivate(pFieldObj));
605 
606   Document* pDocument = static_cast<Document*>(pJSDocument->GetEmbedObject());
607   pDocument->SetFormFillEnv(m_pTargetFormFillEnv
608                                 ? m_pTargetFormFillEnv.Get()
609                                 : m_pJSEventContext->GetFormFillEnv());
610 
611   Field* pField = static_cast<Field*>(pJSField->GetEmbedObject());
612   pField->AttachField(pDocument, m_strSourceName);
613   return pField;
614 }
615 
Target_Field()616 Field* CJS_EventHandler::Target_Field() {
617   CJS_Runtime* pRuntime = m_pJSEventContext->GetJSRuntime();
618   v8::Local<v8::Object> pDocObj =
619       pRuntime->NewFxDynamicObj(CJS_Document::g_nObjDefnID);
620   if (pDocObj.IsEmpty())
621     return nullptr;
622 
623   v8::Local<v8::Object> pFieldObj =
624       pRuntime->NewFxDynamicObj(CJS_Field::g_nObjDefnID);
625   if (pFieldObj.IsEmpty())
626     return nullptr;
627 
628   CJS_Document* pJSDocument =
629       static_cast<CJS_Document*>(pRuntime->GetObjectPrivate(pDocObj));
630   CJS_Field* pJSField =
631       static_cast<CJS_Field*>(pRuntime->GetObjectPrivate(pFieldObj));
632 
633   Document* pDocument = static_cast<Document*>(pJSDocument->GetEmbedObject());
634   pDocument->SetFormFillEnv(m_pTargetFormFillEnv
635                                 ? m_pTargetFormFillEnv.Get()
636                                 : m_pJSEventContext->GetFormFillEnv());
637 
638   Field* pField = static_cast<Field*>(pJSField->GetEmbedObject());
639   pField->AttachField(pDocument, m_strTargetName);
640   return pField;
641 }
642 
Value()643 CFX_WideString& CJS_EventHandler::Value() {
644   return *m_pValue;
645 }
646 
WillCommit()647 bool CJS_EventHandler::WillCommit() {
648   return m_bWillCommit;
649 }
650 
TargetName()651 CFX_WideString CJS_EventHandler::TargetName() {
652   return m_strTargetName;
653 }
654