Initial commit.
[pdfium.git] / fpdfsdk / include / javascript / JS_Runtime.h
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4  \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #ifndef _JS_RUNTIME_H_\r
8 #define _JS_RUNTIME_H_\r
9 \r
10 class CJS_FieldEvent\r
11 {\r
12 public:\r
13         CFX_WideString          sTargetName;\r
14         JS_EVENT_T                      eEventType;\r
15         CJS_FieldEvent*         pNext;\r
16 };\r
17 \r
18 class CJS_Runtime : public IFXJS_Runtime\r
19 {\r
20 public:\r
21         CJS_Runtime(CPDFDoc_Environment * pApp);\r
22         virtual ~CJS_Runtime();\r
23 \r
24         virtual IFXJS_Context *                                 NewContext();\r
25         virtual void                                                    ReleaseContext(IFXJS_Context * pContext);\r
26         virtual IFXJS_Context*                                  GetCurrentContext();\r
27 \r
28         virtual void                                                    SetReaderDocument(CPDFSDK_Document *pReaderDoc);\r
29         virtual CPDFSDK_Document *                              GetReaderDocument(){return m_pDocument;}\r
30 \r
31         virtual void                                                    GetObjectNames(CFX_WideStringArray& array);\r
32         virtual void                                                    GetObjectConsts(const CFX_WideString& swObjName, CFX_WideStringArray& array);\r
33         virtual void                                                    GetObjectProps(const CFX_WideString& swObjName, CFX_WideStringArray& array);\r
34         virtual void                                                    GetObjectMethods(const CFX_WideString& swObjName, CFX_WideStringArray& array);\r
35 \r
36         virtual void                                                    Exit();\r
37         virtual void                                                    Enter();\r
38         virtual FX_BOOL                                                 IsEntered();\r
39 \r
40         CPDFDoc_Environment *                                                   GetReaderApp(){return m_pApp;}\r
41 \r
42         FX_BOOL                                                                 InitJSObjects();\r
43 \r
44         FX_BOOL                                                                 AddEventToLoop(const CFX_WideString& sTargetName, JS_EVENT_T eEventType);\r
45         void                                                                    RemoveEventInLoop(const CFX_WideString& sTargetName, JS_EVENT_T eEventType);\r
46         void                                                                    RemoveEventsInLoop(CJS_FieldEvent* pStart);\r
47 \r
48         void                                                                    BeginBlock(){m_bBlocking = TRUE;}\r
49         void                                                                    EndBlock(){m_bBlocking = FALSE;}\r
50         FX_BOOL                                                                 IsBlocking(){return m_bBlocking;}\r
51 \r
52         operator                                                                IJS_Runtime*() {return (IJS_Runtime*)m_isolate;}\r
53         v8::Isolate*                                                            GetIsolate(){return m_isolate;};\r
54         void                                                                    SetIsolate(v8::Isolate* isolate){m_isolate = isolate;}\r
55 \r
56         v8::Handle<v8::Context>                                                 NewJSContext();\r
57 protected:\r
58         CFX_ArrayTemplate<CJS_Context *>                m_ContextArray;\r
59         CPDFDoc_Environment *                                                   m_pApp;\r
60         CPDFSDK_Document *                                              m_pDocument;\r
61         FX_BOOL                                                                 m_bBlocking;\r
62         CJS_FieldEvent*                                                 m_pFieldEventPath;\r
63 \r
64         v8::Isolate*                                                            m_isolate;\r
65         v8::Persistent<v8::Context>                                             m_context;\r
66         FX_BOOL                                                                 m_bRegistered;\r
67 };\r
68 \r
69 #endif //_JS_RUNTIME_H_\r
70 \r