1 // Copyright 2016 The PDFium Authors 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 FXJS_IJS_EVENT_CONTEXT_H_ 8 #define FXJS_IJS_EVENT_CONTEXT_H_ 9 10 #include "core/fxcrt/widestring.h" 11 #include "fxjs/ijs_runtime.h" 12 #include "third_party/abseil-cpp/absl/types/optional.h" 13 14 class CPDF_FormField; 15 16 // Records the details of an event and triggers JS execution for it. There 17 // can be more than one of these at any given time, as JS callbacks to C++ 18 // may trigger new events on top of one another. 19 class IJS_EventContext { 20 public: 21 virtual ~IJS_EventContext() = default; 22 23 virtual absl::optional<IJS_Runtime::JS_Error> RunScript( 24 const WideString& script) = 0; 25 26 virtual void OnDoc_Open(const WideString& strTargetName) = 0; 27 virtual void OnDoc_WillPrint() = 0; 28 virtual void OnDoc_DidPrint() = 0; 29 virtual void OnDoc_WillSave() = 0; 30 virtual void OnDoc_DidSave() = 0; 31 virtual void OnDoc_WillClose() = 0; 32 33 virtual void OnPage_Open() = 0; 34 virtual void OnPage_Close() = 0; 35 virtual void OnPage_InView() = 0; 36 virtual void OnPage_OutView() = 0; 37 38 virtual void OnField_MouseDown(bool bModifier, 39 bool bShift, 40 CPDF_FormField* pTarget) = 0; 41 virtual void OnField_MouseEnter(bool bModifier, 42 bool bShift, 43 CPDF_FormField* pTarget) = 0; 44 virtual void OnField_MouseExit(bool bModifier, 45 bool bShift, 46 CPDF_FormField* pTarget) = 0; 47 virtual void OnField_MouseUp(bool bModifier, 48 bool bShift, 49 CPDF_FormField* pTarget) = 0; 50 virtual void OnField_Focus(bool bModifier, 51 bool bShift, 52 CPDF_FormField* pTarget, 53 WideString* Value) = 0; 54 virtual void OnField_Blur(bool bModifier, 55 bool bShift, 56 CPDF_FormField* pTarget, 57 WideString* Value) = 0; 58 virtual void OnField_Calculate(CPDF_FormField* pSource, 59 CPDF_FormField* pTarget, 60 WideString* Value, 61 bool* bRc) = 0; 62 virtual void OnField_Format(CPDF_FormField* pTarget, WideString* Value) = 0; 63 virtual void OnField_Keystroke(WideString* strChange, 64 const WideString& strChangeEx, 65 bool KeyDown, 66 bool bModifier, 67 int* nSelEnd, 68 int* nSelStart, 69 bool bShift, 70 CPDF_FormField* pTarget, 71 WideString* Value, 72 bool bWillCommit, 73 bool bFieldFull, 74 bool* bRc) = 0; 75 virtual void OnField_Validate(WideString* strChange, 76 const WideString& strChangeEx, 77 bool bKeyDown, 78 bool bModifier, 79 bool bShift, 80 CPDF_FormField* pTarget, 81 WideString* Value, 82 bool* bRc) = 0; 83 84 virtual void OnExternal_Exec() = 0; 85 }; 86 87 #endif // FXJS_IJS_EVENT_CONTEXT_H_ 88